akhauriyash/Code-Regression huggingface dataset:
using System.Linq;
using System;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		WriteLine(Calc());
	}
	long[,] next;
	void Add(int x, int y, long z) { next[x, y] = (next[x, y] + z) % Mod; }
	void Add(ref long x, long z) { x = (x + z) % Mod; }
	bool IsOK(int[] q, int x, int y) => q[0] > x && x >= q[1] && q[2] > y && y >= q[3];
	long Calc()
	{
		var I = G();
		int N = I[0], M = I[1];
		var qs = new int[N][];
		for (var i = 0; i < N; i++) qs[i] = new int[] { N + 10, -10, N + 10, -10 };
		for (var i = 0; i < M; i++)
		{
			I = G();
			if (I[0] != I[1])
			{
				int l = I[0] - 1, r = I[1] - 1;
				switch (I[2])
				{
					case 1: qs[r][0] = Min(qs[r][0], l); break;
					case 2: qs[r][1] = Max(qs[r][1], l); qs[r][2] = Min(qs[r][2], l); break;
					case 3: qs[r][3] = Max(qs[r][3], l); break;
					default: break;
				}
			}
			else if (I[2] != 1) return 0;
		}
		var dp = new long[N, N];
		dp[N - 1, N - 1] = 3;
		if (qs[0][1] >= 0 || qs[0][2] <= N || qs[0][3] >= 0) return 0;
		for (var n = 0; n < N - 1; n++)
		{
			next = new long[N, N];
			for (var x = 0; x < n; x++)
				for (var y = 0; y < x; y++)
					if (dp[x, y] != 0)
					{
						Add(x, y, dp[x, y]);
						Add(n, y, dp[x, y]);
						Add(n, x, dp[x, y]);
					}
			Add(N - 1, N - 1, dp[N - 1, N - 1]);
			Add(n, N - 1, 2 * dp[N - 1, N - 1]);
			for (var x = 0; x < n; x++)
				if (dp[x, N - 1] != 0)
				{
					Add(x, N - 1, dp[x, N - 1]);
					Add(n, N - 1, dp[x, N - 1]);
					Add(n, x, dp[x, N - 1]);
				}
			for (var x = 0; x <= n; x++) for (var y = 0; y < x; y++) if (!IsOK(qs[n + 1], x, y)) next[x, y] = 0;
			for (var x = 0; x <= n; x++) if (!IsOK(qs[n + 1], x, -1)) next[x, N - 1] = 0;
			if (!IsOK(qs[n + 1], -1, -2)) next[N - 1, N - 1] = 0;
			dp = next;
		}
		var ans = 0L;
		for (var x = 0; x < N; x++) for (var y = 0; y < N; y++) Add(ref ans, dp[x, y]);
		return ans;
	}
}

Measured memory_bytes: 31012
A = 0
B = 0
C = 0
D = 0


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    g = gcd(a, b)
    return a * (b // g)


def f(n):
    return n - n // C - n // D + n // lcm(C, D)


def main():
    global A, B, C, D
    A, B, C, D = map(int, input().split())
    print(f(B) - f(A - 1))
    return


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int A,B,C;
  cin>>A>>B>>C;
  int ans=B/A;
  if(ans>C){
      ans=C;
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3636
#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()

int main(){
  int d,c;
  cin >> d >> c;
  cout << d* c << endl;
}



Measured memory_bytes: 3100
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
//#define int long long
using namespace std;
const int MOD = 1e9 + 7;
// const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

int convert(string s) {
  int sum = 0;
  string t, u, v;
  t = s.substr(0, 2);
  u = s.substr(3, 2);
  v = s.substr(6, 2);
  sum += ((t[0] - '0') * 10 + (t[1] - '0')) * 3600;
  // cout << sum << ' ';
  sum += ((u[0] - '0') * 10 + u[1] - '0') * 60;
  // cout << sum << ' ';
  sum += (v[0] - '0') * 10 + v[1] - '0';
  // cout << sum << endl;
  return sum;
}

int main() {
  int n;
  while (cin >> n, n) {
    int times[1000006] = {};
    rep(i, n) {
      string s, e;
      cin >> s >> e;
      int start = convert(s);
      int end = convert(e);
      // cout << start << ' ' << end << endl;
      times[start] += 1;
      times[end] += -1;
    }
    rep(i, 1000000) times[i + 1] += times[i];
    int ans = 0;
    rep(i, 1000000) cmax(ans, times[i]);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 6908
#include<stdio.h>
#include<cstdlib>
#define NI ( 1<<30 )
int a[2000001];
int H;
void swp(int *a,int *b){
int t = *a; *a = *b; *b = t;
}
void maxtree(int x){
int l = x * 2;
int r = 2 * x + 1;
int p;
if( l <= H && a[l] > a[x])p = l;
else p = x;
if( r <= H && a[r] > a[p])p = r;
if(p != x){
    swp(a+x,a+p);
    maxtree(p);
}
}
int extract(){
int maxv;
if(H < 1)return -NI;
maxv = a[1];
a[1] = a[H--];
maxtree(1);
return maxv;
}

void inserts(int i , int key){
  if( key < a[i] )return;
  a[i] = key ;
  while( i > 1 && a[i / 2] < a[i] ){
    swp(&a[i],&a[i/2]);
    i = i / 2;
  }
}

void insertp(int key){
  H++;
   a[H] = -NI;
   inserts(H,key);
}

int main(){
int key;
char s[10];
while(1){
    scanf("%s",s);
    if(s[0] == 'e' && s[1] == 'n')break;
    else if(s[0] == 'i'){
        scanf("%d",&key);insertp(key);
    }
    else printf("%d\n",extract());
}
return 0;
}

Measured memory_bytes: 6504
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve(){
    int n, x, t; cin >> n >> x >> t;
    cout << (n+x-1)/x*t << nl;
}



int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int a = stdIn.nextInt();
        String s = stdIn.next();

        if(a >= 3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
    }
}

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

int main(){
    char b;
    cin>>b;
    if(b=='A'){cout<<"T"<<endl;}
    if(b=='T'){cout<<"A"<<endl;}
    if(b=='C'){cout<<"G"<<endl;}
    if(b=='G'){cout<<"C"<<endl;}
}

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

int main()
{
    //残るのは長方形なのでその4点の情報を持っておくのが良い
    int w, h, n;
    cin >> w >> h >> n;
    int p, q, r, e;
    p = 0;
    q = 0;
    r = w;
    e = h;
    rep(i, n)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1)
        {
            p = max(p, x);
        }
        if (a == 2)
        {
            r = min(r, x);
        }
        if (a == 3)
        {
            q = max(q, y);
        }
        if (a == 4)
        {
            e = min(e, y);
        }
    }
    //cout << p << q << r << e;
    if ((r - p) < 0 || (e - q) < 0)
    {
        cout << 0;
    }
    else
    {
        cout << (r - p) * (e - q);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll h,n; cin>>h>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    ll inf=1001001001;
    vector<vector<ll>> dp(n+1,vector<ll>(1e5+5,inf));
    //dp[i][j]:i番目の魔法までを使ってj与えたときの最小魔法消費
    dp[0][0]=0;
    rep(i,n){
        rep(j,1e5+1){
          	chmin(dp[i+1][j],dp[i][j]);
            if(j>=a[i]) dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-a[i]]+b[i]);
        }
    }
    ll res=inf;
    rep(i,1e5-h) chmin(res, dp[n][h+i]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 785792
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int res = 0;
    int resA = k-a;
    if (resA <= 0)
    {
        res = k;
        cout << res;
        return 0;
    }
    else 
    {
        res = a;
        int resB = resA - b;
        if (resB <= 0)
        {
            cout << res;
            return 0;
        }
        else 
        {
            res = res - resB;
            cout << res;
            return 0;
        }
    }
    return 0;
}

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

int main(){
  int N;cin>>N;
  int A[N],B[N],C[N-1];
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++) cin>>B[i];
  for(int i=0;i<N-1;i++) cin>>C[i];
  int ans=0;
  for(int i=0;i<N;i++) ans+=B[A[i]-1];
  for(int i=0;i<N-1;i++) if(A[i+1]==A[i]+1) ans+=C[A[i]-1];
  cout<<ans<<endl;
}

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

struct SplayNode{
    SplayNode *left, *right, *parent;
    int size, value;

    SplayNode(){
        left = nullptr;
        right = nullptr;
        parent = nullptr;
        size = 1;
    }

    void rotate(){
        SplayNode *pp, *p, *c;
        p = this->parent;
        pp = p->parent;

        if(p->left == this){
            c = this->right;
            this->right = p;
            p->left = c;
        }
        else{
            c = this->left;
            this->left = p;
            p->right = c;
        }

        if(pp && pp->left == p) pp->left = this;
        if(pp && pp->right == p) pp->right = this;
        this->parent = pp;
        p->parent = this;
        if(c) c->parent = p;

        p->update();
        this->update();
    }

    int state(){
        if(!this->parent) return 0;
        if(this->parent->left == this) return 1;
        if(this->parent->right == this) return -1;
        return 0;
    }

    void splay(){
        while(this->state() != 0){
            if(this->parent->state() == 0){
                this->rotate();
            }
            else if(this->state() == this->parent->state()){
                this->parent->rotate();
                this->rotate();
            }
            else{
                this->rotate();
                this->rotate();
            }
        }
    }

    void update(){
        this->size = 1;
        if(this->left) this->size += this->left->size;
        if(this->right) this->size += this->right->size;
    }
};

SplayNode *get(int idx, SplayNode *root){
    SplayNode *now = root;
    
    while(1){
        int lsize = now->left ? now->left->size : 0;

        if(idx < lsize){
            now = now->left;
        }
        if(idx == lsize){
            now->splay();
            return now;
        }
        if(idx > lsize){
            now = now->right;
            idx = idx - lsize - 1;
        }
    }
}

SplayNode node[220000];

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

    int q, ord, x;
    cin >> q;
    int vecsize = 0;

    for(int i = 0; i < q; ++i){
        node[i].parent = &node[i+1];
        node[i+1].left = &node[i];
        node[i+1].update();
    }
    
    SplayNode *root = &node[q];

    for(int i = 0; i < q; ++i){
        cin >> ord;
        if(ord == 0){
            cin >> x;
            root = get(vecsize++, root);
            root->value = x;
        }
        if(ord == 1){
            cin >> x;
            root = get(x, root);
            cout << root->value << endl;
        }
        if(ord == 2){
            --vecsize;
        }
    }


    return 0;
}


Measured memory_bytes: 10092
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int>W(10);
  vector<int>H(10);
  for(int i=0;i<10;i++)
    cin>>W[i];
  for(int i=0;i<10;i++)
    cin>>H[i];
  sort(W.begin(),W.end(),greater<int>());
  sort(H.begin(),H.end(),greater<int>());
  cout<<W[0]+W[1]+W[2]<<" "<<H[0]+H[1]+H[2]<<endl;
  return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
//using P = pair<int, int>;
typedef long long ll;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> w(n);
    vector<ll> v(n);
    for(ll i=0;i<n;i++)cin>>v[i]>>w[i];
    vector<vector<ll> > dp(n+1,vector<ll>(m+1,0));
    for(ll i=n-1;i>=0;i--){
        for(int j=0;j<=m;j++){
            if(w[i]>j)dp[i][j]=dp[i+1][j];
            else dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
        }
    }
    cout<<dp[0][m]<<endl;
    return 0;
}



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

using namespace std;

int main()
{
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S, T;
    cin >> S >> T;
    
    int n = (int)S.size();
    int m = (int)T.size();
    int maxCnt = 0;
    for (int i = 0; i + m <= n; ++i)
    {
        int cnt = 0;
        for (int j = 0; j < m; ++j)
            if (S[i + j] == T[j])
                ++cnt;
        if (maxCnt < cnt)
            maxCnt = cnt;
    }
    cout << m - maxCnt;

    return 0;
}

Measured memory_bytes: 3656
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int K, A, B;
    cin >> K >> A >> B;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK";
            return;
        }
    }
    cout << "NG";
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3596
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

if n % 2:

    ab.sort()
    l = ab[(n+1)//2-1][0]

    ab.sort(key=lambda x:x[1], reverse=True)
    r = ab[(n+1)//2-1][1]

    print(r-l+1)

else:

    a = [ai for ai, bi in ab]
    b = [bi for ai, bi in ab]

    a.sort()
    b.sort()

    ll = a[n//2-1]
    lr = b[n//2-1]

    rl = a[n//2]
    rr = b[n//2]


    print((lr+rr) - (ll+rl) + 1)

Measured memory_bytes: 49028
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int w=0, k=0;
		int ws[] = new int[10], ks[] = new int[10];
		for(int i=0; i<10; i++)
                   ws[i] = in.nextInt();
		for(int i=0; i<10; i++)
                   ks[i] = in.nextInt();
		Arrays.sort(ks);
		Arrays.sort(ws);
		for(int i=0; i<3; i++)
                  w += ws[9-i];
		for(int i=0; i<3; i++)
                  k += ks[9-i];
		System.out.println(w + " " + k);
	}
	
}

Measured memory_bytes: 17156
n,nWorks,nSp = map(int,input().split())

s = input()

leftList = [0]*n
rightList = [0]*n

num = 0
count = 0

while num < n:
    if s[num] == "o":
        leftList[num] = 1
        count +=1
        num += 1 + nSp
    else:
        num +=1

if count > nWorks:
    exit()

num = n-1
count = 0
while num >= 0:
    if s[num] == "o":
        rightList[num] = 1
        count +=1
        num -= (1 + nSp)
    else:
        num -=1

for kk in range(n):
    if leftList[kk] and rightList[kk]:
        print(kk+1)

Measured memory_bytes: 7876
#include<stdio.h>

void trace( int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
   }
   printf("\n");
 }
 
 void insertSort( int A[], int N) {
   int j, i, v;
   for ( i = 1; i < N; i++ ) {
     v = A[i];
     j = i - 1;
    while ( j >= 0 && A[j] > v ) {
       A[j + 1] = A[j];
       j--;
     }
     A[j + 1] = v;
     trace(A, N);
  }
}

int main(void) {
  int N, i;
  int A[100];
  
  scanf("%d" , &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  
  trace(A, N);
  insertSort(A, N);
  
  return 0;
  
}


Measured memory_bytes: 1932
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x,y; cin>>x>>y;
    ll n1,n2,n3; cin>>n1>>n2>>n3;
    vector<ll> a,b,c,v;
    for(int i=0;i<n1;i++){
        ll t;
         cin>>t;
         a.push_back(t);
    }
    for(int i=0;i<n2;i++){
        ll t; cin>>t;
        b.push_back(t);
    }
    for(int i=0;i<n3;i++ ) { ll t; cin>>t; c.push_back(t); }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    for(int i=0;i<x;i++){
        v.push_back(a[i]);
    }
    for(int i=0;i<y;i++) v.push_back(b[i]);
    sort(v.begin(),v.end());
    sort(c.rbegin(),c.rend());
    
    int j=0;
    for(int i=0;i<c.size();i++){
        if(c[i]>v[j]) v[j]=c[i], j++;
        else break;
        if(j==v.size()) break;
    }
    ll sum=0;
    for(int i=0;i<v.size();i++) sum+=v[i];
    cout<<sum<<endl;
    
    
    
    
    
    
}

Measured memory_bytes: 4852
import java.io.*;
import java.util.*;


public class Main{
	public static void main(String[] args) {
		int[] n=new int[3];
		
		String s=null;
		InputStreamReader isr=new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try{
			s=br.readLine();
			StringTokenizer st=new StringTokenizer(s," ");
			for(int i=0;i<3;i++){
				n[i]=Integer.parseInt(st.nextToken());
			}
		}catch(IOException e){
			e.printStackTrace();
		}
		int temp;
		int minIndex;
		
		for(int i=0;i<3;i++){
			minIndex=i;
			for(int j=i;j<3;j++){
				if(n[j]<n[minIndex]){
					minIndex=j;
				}
			}
			if(minIndex!=i){
				temp=n[i];
				n[i]=n[minIndex];
				n[minIndex]=temp;
			}
		}
		System.out.println(n[0] + " " + n[1] + " " + n[2]);
		
	}

}



Measured memory_bytes: 24228
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int k;cin>>k;
  char res;
  int cnt=0;
  for(auto& val:s){
    ++cnt;
    if(cnt==k){
      res=val;
      break;
    }
    if(val!='1'){
      res=val;
      break;
    }
  }
  cout<<res<<endl;
  return 0;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 1e5 +11;
int siz[N],fa[N],son[N],a[N],cnt,to[N],t[N],de[N];
int T[N<<2];
int laz[N<<2];
vector<int>v[N];
int n,m,p,r,x[N];
void dfs1(int now,int pre,int d){
    siz[now]=1;
    fa[now]=pre;
    de[now]=d;
    int cnt=-1;
    for(auto k:v[now]){
        if(k==pre)continue;
        dfs1(k,now,d+1);
        siz[now]+=siz[k];
        if(siz[k]>cnt){
            cnt=siz[k];
            son[now]=k;
        }
    }
}
void dfs2(int now,int pre){
    to[now]=pre;
    a[now]=++cnt;
    t[cnt]=x[now];
    if(!son[now])return ;
    dfs2(son[now],pre);
    for(auto k:v[now]){
        if(k==fa[now]||k==son[now])continue;
        dfs2(k,k);
    }
}
int find_lca(int l,int r){
    int res=0,x=l,y=r;
    while(to[l]!=to[r]){
        if(de[to[l]]<de[to[r]])swap(l,r);
        l=fa[to[l]];
    }
    if(de[l]>de[r])swap(l,r);

    //cout<<x<<' '<<y<<' '<<de[x]+de[y]-2*de[l]<<endl;
    return de[x]+de[y]-2*de[l];
}
int xa,xb;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>xa>>xb;
    for(int i=1;i<n;i++){
        int s,t;
        cin>>s>>t;
        v[s].pb(t);
        v[t].pb(s);
    }
    dfs1(1,0,0);
    dfs2(1,1);
    int sta=1,ans=0,x1=1e9,x2=-1;
    for(int i=1;i<=n;i++){
        int La=find_lca(xa,i);
        int Lb=find_lca(xb,i);
        if(La<Lb){
            x2=max(x2,Lb);
        }
    }
    cout<<x2-1;
    return 0;
}


Measured memory_bytes: 18304
def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = mips()
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])


Measured memory_bytes: 56544
// 10101010101
/*
f(i, j) = max(f(i+2, j-1)+v[i], f(i+1, j))
len-i >=  2*j
*/
#include <algorithm>
#include <cstdio>
#include <map>

using namespace std;
typedef long long ll;

const int N = 3e5;
int n;
int arr[N];
map<pair<int, int>, ll> cache;

ll f(int i, int j) {
    if (n - i < 2 * j - 1) return -(ll)1e17;
    if (j == 0) return 0;
    if (i == n) return -(ll)1e17;
    if (cache.find({i, j}) == cache.end()) {
        ll value = max(f(i + 2, j - 1) + arr[i], f(i + 1, j));
        return cache[{i, j}] = value;
    } else {
        return cache[{i, j}];
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    ll ans = f(0, n / 2);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 29028
#include<stdio.h>

int gcd(int x,int y)
{
	if(y==0)return x;
	else {return gcd(y,x%y);}
}

int main()
{

	int x,y;
	scanf("%d %d",&x,&y);
	printf("%d\n",gcd(x,y));
	return 0;
}

Measured memory_bytes: 592
import sys
from math import sqrt, floor

def divisors(n):
    res = set()
    for i in range(1, floor(sqrt(n)) + 1):
        if n % i == 0:
            res.add(i)
            res.add(n // i)
    return res - set([1])

n = int(sys.stdin.readline().rstrip())

def main():
    res = divisors(n - 1) 
    cnt = len(res)
    for i in divisors(n):
        if i in res: continue
        m = n
        while m % i == 0:
            m //= i
        if (m - 1) % i == 0:
            cnt += 1
    print(cnt)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <map>
#include <string.h>
#include <algorithm>
#include <cstdlib>
#include <math.h>

using namespace std;

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

    if (N%K == 0)
        cout << 0 << endl;
    else
        cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define size_max 500000
int n;

void maxHeapfy(int *,int);
void buildMaxHeap(int *);
void maxHeapfy(int *A, int i) {
  int largest;
  int left_search = 2*i;
  int right_search = 2*i+1;

  if (left_search <= n && A[left_search] > A[i]) {
    largest = left_search;
  } else {
    largest = i;
  }
  if (right_search <= n && A[right_search] > A[largest]) {
    largest = right_search;
  }

  if (largest != i) {
    int tmp;
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;

    maxHeapfy(A, largest);
  }
}

void buildMaxHeap(int *A) {
  int i;
  for (i = n/2; i >= 1; i--) {
    maxHeapfy(A, i);
  }
}

int main(void) {
  int i;
  int A[size_max];
  scanf("%d", &n);
  for(i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }

  buildMaxHeap(A);

  for (i = 1; i <= n; i++) {
    printf(" %d", A[i]);
  }
  putchar('\n');

  return 0;
}



Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
	int w,a,b;
	scanf("%d%d%d",&w,&a,&b);
	if(b>=a+w) printf("%d\n",b-a-w);
	else if(b+w<=a) printf("%d\n",a-b-w);
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
P = gets.split.map(&:to_i)

target = P.sort

if target == P
  puts 'YES'
  exit
end

N.times do |i|
  (i + 1).upto(N - 1) do |j|
    P[i], P[j] = P[j], P[i]

    if P == target
      puts 'YES'
      exit
    end

    P[i], P[j] = P[j], P[i]
  end
end

puts 'NO'


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

int main(){
  string s;
  cin >> s;
  int a = 700;

  if(s[0] == 'o')
    a+=100;
  if(s[1] == 'o')
    a+=100;
  if(s[2] == 'o')
    a+=100;
  cout << a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  cout << min(B,A*N) << endl;
  return 0;
}

Measured memory_bytes: 3624
from sys import stdin


def main() -> None:
    global N, M, A, B
    N = next_int()
    M = next_int()
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]

    ans = "No"
    for Ni in range(N):
        for Nj in range(N):
            if judge(Ni, Nj):
                ans = "Yes"
                break
        if ans == "Yes":
            break
    print(ans)


def judge(ni: int, nj: int) -> bool:
    for i in range(M):
        for j in range(M):
            if ni + i >= N or nj + j >= N:
                return False
            if B[i][j] != A[ni + i][nj + j]:
                return False
    return True


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
        int k = sc.nextInt();
      	int[] a = new int[n];
      
      	for(int i=0;i<n;i++){
        	a[i] = sc.nextInt();
         }
      		
      		for(int j=k;j<n;j++){
            	if(a[j-k] < a[j]){
                System.out.println("Yes");
                } else {
                System.out.println("No");	
                }
            }

		}
	}

Measured memory_bytes: 61132
#include<cstdio>
#include<algorithm>

#define x first
#define y second
std::pair<int,int>a[100001];
long long ans[100000];
int main()
{
	int n,i,p;long long sum=0;scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i].x),a[i].x*=-1,a[i].y=i;

	std::sort(a,a+n),p=a[0].y,sum=-a[0].x;
	for(i=1;i<=n;i++)
	{
		if(a[i].y<=p)
		{
			ans[p]=sum+(long long)a[i].x*i;
			sum-=ans[p];
			p=a[i].y;
		}
		sum-=a[i].x;
	}

	for(i=0;i<n;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

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

#define int long long

const int MOD = 1e9 + 7;

// i ???????????????, 13??????????????j????????????.
int dp[100001][13];


signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    int N = s.length();
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 13; j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        if (s[i] == '?') {
            for (int hi = 0; hi < 10; hi++) {
                for (int j = 0; j < 13; j++) {
                    int nj = (j * 10 + hi) % 13;
                    dp[i + 1][nj] += dp[i][j];
                }
            }
        } else {
            for (int j = 0; j < 13; j++) {
                int nj = (j * 10 + s[i] - '0') % 13;
                dp[i + 1][nj] += dp[i][j];
            }
        }
        for (int j = 0; j < 13; j++) {
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[N][5] << endl;
    return 0;
}


Measured memory_bytes: 10704
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int i;
    bool bJudge = false;
    for(i = 1; i < 500; i++){
        if( i * (i + 1) / 2 == n){
            bJudge = true;
        }
        if( i *(i + 1) / 2 >= n){
            break;
        }
    }
  
    if(!bJudge){
        printf("No\n");
    } else {
        int aaiAns[i+1][i];
        int m = 1;
        for(int j = 0; j < i + 1; j++){
            for(int k = 0; k < i; k++){
                if(j <= k){
                    aaiAns[j][k] = m;
                    m++;
                } else {
                    aaiAns[j][k] = aaiAns[k][j-1];
                }
            }
        }
        printf("Yes\n%d\n", i + 1);
        for(int j = 0; j < i + 1; j++){
            printf("%d ", i);
            for(int k = 0; k < i; k++){
                printf("%d ", aaiAns[j][k]);
            }
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 3912
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main() {
    string a;
    cin >> a;
    int num = a.size();
    //cout << num << endl;
    //char c[(num/2)+1];
    for(int i = 0; i < num; i+=2) {
        cout << a[i];
    }

    cout << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int a,b,c,d;
cin >> a >> b >> c >> d;

vector<ll int> A(4);
A[0]=a*c;
A[1]=b*d;
A[2]=a*d;
A[3]=b*c;

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

cout << A[3];










	return 0;

}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int H,W;
    char a[1040][1040];
    int dp[1040][1040]={};
  	dp[0][0]=1;
    cin >> H >> W;
    REP(i,H){
        REP(j,W){
            cin >> a[i][j];
        }
    }
  	ZREP(i,W){
      if(a[0][i]!='.')continue;
      if(a[0][i-1]=='.'){
        dp[0][i]=(dp[0][i]+dp[0][i-1])%MOD;
      }
    }
  	ZREP(i,H){
      if(a[i][0]!='.')continue;
      if(a[i-1][0]=='.'){
        dp[i][0]=(dp[i][0]+dp[i-1][0])%MOD;
      }
    }
  	
    ZREP(i,H){
        ZREP(j,W){
      		if(a[i][j]!='.')continue;
            if(a[i-1][j]=='.'){
                dp[i][j]=(dp[i][j]+dp[i-1][j])%MOD;
            }
            if(a[i][j-1]=='.'){
                dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
    
  
  	REP(i,H){
      REP(j,W){
       cerr << dp[i][j] << " ";
       }
       cerr << endl;
    }
    return 0;
}   


Measured memory_bytes: 9728
s = gets.chomp
n = s.size
m = (n-1)/2
f = true
g = true
(n/2).times do |i|
    f = false if s[i] != s[n-1-i]
end
(m/2).times do |i|
    g = false if s[i] != s[m-1-i]
end
puts (f && g ? "Yes" : "No")

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

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

  if (A+B> C+D) {
    cout << "Left" << endl;
  }
  else if (A+B< C+D){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=3000+10,mod=1e9+7;
bitset<maxn> C,Bas[maxn];
bool vis[maxn];
int Pw[maxn],dp[maxn][maxn];
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
int main(){
	int n=read(),R=0;
	REP(i,1,n){
		REP(j,1,n) C[j]=read();
		REP(j,1,n) if(C[j]){
			if(vis[j]) C^=Bas[j];
			else{
				vis[j]=1,Bas[j]=C;
				++R;
				break;
			}
		}
	}
	Pw[0]=1;
	REP(i,1,n) Pw[i]=(Pw[i-1]<<1)%mod;
	dp[0][0]=1;
	REP(i,1,n) REP(j,0,i){
		dp[i][j]=(ll)dp[i-1][j]*Pw[j]%mod;
		if(j) dp[i][j]=(dp[i][j]+(ll)dp[i-1][j-1]*(Pw[n]-Pw[j-1]+mod))%mod;
	}
	int ans=0;
	REP(i,R,n) ans=(ans+(ll)dp[n][i]*ksm(2,n*(n-i))%mod*dp[i][R])%mod;
	ans=(ll)ans*ksm(dp[n][R],mod-2)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct node{
  struct node *R;
  struct node *L;
  struct node *P;
  int key;
};
typedef struct node Node;
Node *NIL;

Node *root;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->L=NIL;
  z->R=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->L;
    }
    else{
      x=x->R;
    }
  }
  z->P=y;

  if(y==NIL){
    root=z;
  }
  else if(z->key < y->key){
      y->L=z;
    }
  else{
      y->R=z;
    }
}

void inorder(Node *u);
void preorder(Node *u);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}
void inorder(Node *u){
  if (u==NIL)return ;
  inorder(u->L);
  printf(" %d",u->key);
  inorder(u->R);
}
void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->L);
  preorder(u->R);
}


Measured memory_bytes: 25164
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, K; cin >> N >> K;
  vector<ll> h(N), DP(N, 10000000000);
  for(int i = 0; i < N; i++) cin >> h.at(i);
  DP.at(0) = 0; DP.at(1) = DP.at(0) + abs(h.at(1) - h.at(0));
  for(int i = 0; i < N; i++) {
    for(int k = 1; k <= K; k++) {
      if(i + k < N) {
        DP.at(i + k) = min(DP.at(i + k), DP.at(i) + abs(h.at(i) - h.at(i + k)));
      }
    }
  }
  cout << DP.at(N - 1) << endl;
}

Measured memory_bytes: 1792
n,k = map(int,input().split())
top = [0]*n
sub = []
for i in range(n):
    t,d = map(int,input().split())
    t -=1
    if top[t]==0:
        top[t]=d
    else:
        if top[t]>=d:
            sub.append(d)
        else:
            sub.append(top[t])
            top[t]=d

top.sort()
top = top[::-1]
res = [0]
for i in range(n):
    if top[i]!=0:
        res.append(res[-1]+top[i])
    else:
        res.append(-1)
sub.sort()
sub = sub[::-1]
w = [0]
for i in range(len(sub)):
    w.append(w[-1]+sub[i])
tmp = 0
for i in range(1,k+1):
    if len(w)-1>=k-i and res[i]!=-1:
        tmp = max(res[i]+w[k-i]+i*i,tmp)

print(tmp)
    
    

Measured memory_bytes: 12552
#![allow(non_snake_case)]
#[warn(dead_code)]
fn main() {
    // let s = std::io::stdin();
    // let mut sc = Scanner { stdin: s.lock() };
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    //let n: usize = sc.read();
    //let a: Vec<u64> = sc.vec(n);
    //let s = sc.chars();
    //let mut A: Vec<Vec<u64>> = (0..n).map(|_| sc.vec(n)).collect();
    let D:usize = sc.read();
    let C:Vec<i64> = sc.vec(26);
    let S: Vec<Vec<i64>> = (0..D).map(|_| sc.vec(26)).collect();
    let T: Vec<usize> = (0..D).map(|_| sc.read()).collect();
    let mut past: Vec<i64> = (0..26).map(|_| -1).collect();
    let mut ans:i64 = 0;
    for i in 0..D{
        ans += S[i][T[i]-1];
        past[T[i]-1] = i as i64;
        for j in 0..26{
            ans -= C[j]*((i as i64)-past[j]);
        }
        println!("{}", ans);
    }
}

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);


impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




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


int main()
{
	ll m, d;
	cin >> m >> d;
	int ans = 0;
	for(int k=1;k<=m;k++)
	for(int i=2;i<10;i++)
		if (k % i == 0)
		{
			int j = k / i;
			if (j < 10 && j > 1 && i*10 + j <=d )
				ans++;
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    ll cnt = 0;
    repb(i, 0, 3001)
    {
        if(r * i > n) continue;
        repb(j, 0, 3001)
        {
            if(r * i + g * j > n) continue;
            if((n - r * i - g * j) % b == 0)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

class unionfind {
  vector<int> v;

  int size(int n) {
    return -v[root(n)];
  }

  int parent(int n) {
    return v[n] < 0 ? n : v[n];
  }

  int root(int n) {
    return parent(n) == n ? n : v[n] = root(parent(n));
  }

public:
  int component_count;

  unionfind(int n) {
    v.resize(n, -1);
    component_count = n;
  }

  unionfind(int n, vector<pair<int, int>> vp)
    : unionfind(n)
  {
    unite(vp);
  }

  int unite(int a, int b) {
    int ra = root(a);
    int rb = root(b);
    if (ra == rb) return -1;
    component_count--;
    if (size(ra) < size(rb)) swap(ra, rb);
    v[ra] += v[rb];
    v[rb] = ra;
    return size(ra);
  }

  void unite(vector<pair<int, int>> vp) {
    for (auto&& e : vp) {
      unite(e.first, e.second);
    }
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp(m);

  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    vp[i].first = x - 1;
    vp[i].second = y - 1;
  }

  auto uf = unionfind(n, vp);
  cout << uf.component_count << endl;
}


Measured memory_bytes: 2944
import networkx as nx
N,M = map(int, input().split())
E = [list(map(int,input().split())) for i in range(M)]

G = nx.Graph() 
G.add_edges_from(E)
di = nx.predecessor(G, source = 1)

print("Yes")
for i in range(2,N+1):
  print(di[i][0])


Measured memory_bytes: 221836
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<string, int> count;
  int cm = 0;
  REP(i, n)
  {
    string s;
    cin >> s;
    count[s]++;
    chmax(cm, count[s]);
  }
  REPx(x, count) if (x.second == cm) cout << x.first << endl;

  return 0;
}


Measured memory_bytes: 23808
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))
#define N 105

char s[N];

int main(void) {
	int k;
	scanf("%d", &k);
	scanf("%s", &s);
	string a = (string)s;
	if (sz(a) <= k) {
		printf("%s\n", a.c_str());
	}
	else {
		printf("%s...\n", a.substr(0, k).c_str());
	}
}


Measured memory_bytes: 3752
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n>>m;
    Ff(i,0,10)
    {
      ll temp=m*10+i;
      double ans=(double)temp*(0.08);
      ans=floor(ans);
      ll mahir=(ll)ans;
      if(ans==n)
      {
        cout<<temp;
        return 0;
      }
    }
    cout<<"-1";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 7552