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

using namespace std;

int main()
{
  string T[2];
  cin >> T[0] >> T[1];
  
  typedef unsigned int int_type;
  const int_type base = 9973;

  vector<int_type> hashed[2], power[2];  

  for(int i = 0; i < 2; i++){
    int sz = T[i].size();
    hashed[i].assign(sz + 1, 0);
    power[i].assign(sz + 1, 0);
          
    hashed[i][0] = 0;
    power[i][0] = 1;
    for(int j = 0; j < sz; j++){
      power[i][j+1] = power[i][j] * base;
      hashed[i][j+1] = (hashed[i][j]+T[i][j])*base;
    }
  }

  for(int i = 0; i <= (int)(T[0].size()-T[1].size()); i++){
    if(hashed[0][i+T[1].size()] - hashed[0][i]*power[0][T[1].size()] == 
       hashed[1][T[1].size()] - hashed[1][0]*power[0][T[1].size()]){
      printf("%d\n", i);
    }
  }

  return 0;
}

Measured memory_bytes: 10096
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
int main() {
   long long a,b,c;
   cin>>a>>b>>c;
   long long d;
   if(a>=c+b){
      d=0;
   }
   else{
      d=c+b-a;
   }
   cout<<min(b,c)<<" "<<d<<endl;
}



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

int main(){
    long long  a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    long long distance_a = v*t;
    long long distance_b = w*t;
    long long between_ab;
    if (a>b){
        between_ab = a - b;
    }else{
        between_ab = b - a;
    }

    if (distance_b + between_ab <= distance_a){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

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

  rep(i,a,b+1){
    if(i<a+k||i>b-k)out(i);
  }

  return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
A=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
L=[0]*26

for j in range(H):
    a=list(input())
    for k in range(W):
        for l in range(26):
            if a[k]==A[l]:
                L[l]+=1
                
for x in range(26):
    L[x]=L[x]%4
                
if H*W%2==1:
    if L.count(1)+L.count(3)==1 and L.count(2)+L.count(3)<=(H+W-2)//2:
        print("Yes")
    else:
        print("No")
elif H%2==1:
    if L.count(1)+L.count(3)==0 and L.count(2)<=W//2:
        print("Yes")
    else:
        print("No")
elif W%2==1:
    if L.count(1)+L.count(3)==0 and L.count(2)<=H//2:
        print("Yes")
    else:
        print("No")
else:
    if sum(L)==0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3444
a = []
b = []
a[0] = gets.to_i
a[1] = gets.to_i
a[2] = gets.to_i
a[3] = gets.to_i
b[0] = gets.to_i
b[1] = gets.to_i
puts a.inject(:+) + b.inject(:+) - a.min - b.min


Measured memory_bytes: 6868
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-7;
const int N=3e5+10;
const ll mod=1e9+7;
const ll MOD=998244353;
inline ll read()  
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
   return x*f;
}
int n,ans;
ll a[N];
int main()
{  cin>>n;
   for(int i=1;i<=n;i++)cin>>a[i];
   sort(a+1,a+1+n);
   for(int i=1;i<=n;i++)
     for(int j=i+1;j<=n;j++)
       for(int k=j+1;k<=n;k++)
         if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])ans++;
   cout<<ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>

using namespace std;


int main(){
    ios::sync_with_stdio(0);
   long long int n,z=0,i,j,y,arr[100001],s=0;
   cin>>n;
   for(i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   for(j=0,i=1;i<n;j++,i=j+1)
   {
       if(arr[j]>=arr[i])
        s++;
       else
       {
           s=0;
       }
       if(s>=z)
        z=s;
   }
   cout<<z;
}


Measured memory_bytes: 1024
def main():
    K = int(input())
    
    a_i = 7
    if a_i % K == 0:
        print(1)
        return

    for i in range(2, 10 ** 6+1):
        a_i = a_i * 10 + 7
        if a_i % K == 0:
            print(i)
            return
        a_i %= K
    print(-1)

main()


Measured memory_bytes: 62976
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) <<LF;

  return 0;
}



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

int main(){
  int N;
  cin>>N;
  vector<int> W(N),sum(N+1);
  sum.at(0)=0;
  for(int i=0;i<N;i++){
    cin>>W.at(i);
    sum.at(i+1)=W.at(i)+sum.at(i);
  }
  int ans=300;
  for(int i=1;i<N;i++){
    int A=sum.at(N)-2*sum.at(i);
    if(A<0){
      A=-A;
    }
    ans=min(ans,A);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
C, A = [], []

for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

ans = float('inf')
for j in range(1<<N):
    curr = 0
    score = [0] * M
    for k in range(N):
        if 1<<k & j :
            curr += C[k]
            for m in range(M):
                score[m] += A[k][m]
                
    if min(score) >= X:
        ans = min(curr, ans)

if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9208
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a && r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		is_min = min;
		if (min) {
			v.resize(num, MOD*MOD);
		}
		else v.resize(num, -MOD * MOD);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};

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

	cin >> N;
	vector<long long int>h(N);
	vector<long long int>a(N);
	for (auto &i : h)cin >> i;
	for (auto &i : a)cin >> i;
	vector<pair<int, int>>box(N);
	for (int i = 0; i < N; i++) {
		box[i] = { h[i],-i };
	}
	sort(box.begin(), box.end());
	vector<int>converter(N);
	for (int i = 0; i < N; i++) {
		converter[-box[i].second] = i;
	}
	Segment_Tree sg(N, false);
	for (int i = 0; i < N; i++) {
		long long int ans = max(0LL, sg.RMQ(0, converter[i]));
		sg.Insert(converter[i], ans + a[i],true);
	}
	cout << sg.RMQ(0, N - 1) << endl;
	return 0;
} 

Measured memory_bytes: 13952
use std::io::prelude::*;
use std::io;
use std::str::FromStr;
#[cfg(local)]
use std::fs::File;
#[cfg(local)]
use std::io::BufReader;

#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = String;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    // let h = usize::from_str(input_vectors[0][0]);
    let h = input_vectors[0][0].parse::<i64>().unwrap() as usize;
    // for str in input_vectors[1].iter() {
    for i in 1..h + 1 {
        println!("{}", input_vectors[i][0]);
        println!("{}", input_vectors[i][0]);
    }
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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;
}
int dfs(vector<vector<int>> &G, vector<bool> visit, int v, int N, int cnt){
    visit.at(v)=true;
    cnt++;
    if(cnt==N){
        bool ok=true;
        rep(i,N){
            if(visit.at(i)==false) ok=false;
        }
        if(ok) return 1;
        else return 0;
    }
    int ans=0;
    for(int u:G.at(v)){
        if(visit.at(u)) continue;
        ans+=dfs(G,visit,u,N,cnt);
    }
    return ans;
}
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> a(M),b(M);
    vector<vector<int>> G(N);
    rep(i,M){
        int from,to;
        cin>>from>>to;
        from--;
        to--;
        G.at(from).push_back(to);
        G.at(to).push_back(from);
    }
    vector<bool> visit(N,false);
    int ans=dfs(G,visit,0,N,0);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#define SGN(X) ((X)!=0?(X)<0?-1:1:0)

using namespace std;

int main(void){
  int n;
  int p[50];
  int flg, ans;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> p[i];
  }
  ans = 0;
  for (int i=1; i<n-1; i++){
    ans += ((p[i]-p[i-1])*(p[i]-p[i+1])<0?1:0);
  }
  cout << ans << endl;
  return 0;
}
  

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

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

    for(int i=0;i<S.length();i++){
        if(S[i] != S[K-1]){
            S[i] = '*';
        }
    }
    cout << S << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

vector<vector<int>> g;

int dfs(int s) {
	int res = 0;
	vector<int> vec;
	for (auto ns : g[s]) {
		vec.emplace_back(dfs(ns));
	}

	sort(begin(vec), end(vec));
	for (auto v : vec) {
		res = max(res + 1, v);
	}
	return res + 1;
}

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

	int n;
	cin >> n;

	g.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int a;
		cin >> a;
		a--;
		g[a].emplace_back(i + 1);
	}

	cout << dfs(0) - 1 << endl;
	return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>

#define Max 200000

int main(){
  int i, j, n, R[Max], minv, maxv;

  scanf("%d", &n);

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

  maxv = R[1] - R[0];
  minv = R[0];

  for(j = 1 ; j <= n - 1 ; j++){
    //if(minv > R[j]) minv = R[j];
    if(maxv < R[j] - minv) maxv = R[j] - minv;
    if(minv > R[j]) minv = R[j];
  }

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

  return 0;
}



Measured memory_bytes: 2536
#include<string>
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    char a[10][10];
    int x = 0;

    while(scanf("%s",a[x])!=EOF){
        if(x == 7){
            getchar();
            for(int i = 0;i < 8; i++){
                for(int j = 0;j < 8; j++){
                    if(a[i][j] == '1'&& a[i+1][j] == '1' && a[i][j+1] == '1' && a[i+1][j+1] == '1')printf("A\n");
                    if(a[i][j] == '1'&& a[i+1][j] == '1' && a[i+2][j] == '1' && a[i+3][j] == '1')printf("B\n");
                    if(a[i][j] == '1'&& a[i][j+1] == '1' && a[i][j+2] == '1' && a[i][j+3] == '1')printf("C\n");
                    if(a[i][j] == '1'&& a[i][j+1] == '1' && a[i-1][j+1] == '1' && a[i+1][j] == '1')printf("D\n");
                    if(a[i][j] == '1'&& a[i][j+1] == '1' && a[i+1][j+1] == '1' && a[i+1][j+2] == '1')printf("E\n");
                    if(a[i][j] == '1'&& a[i+1][j] == '1' && a[i+1][j+1] == '1' && a[i+2][j+1] == '1')printf("F\n");
                    if(a[i][j] == '1'&& a[i][j+1] == '1' && a[i-1][j+1] == '1' && a[i-1][j+2] == '1')printf("G\n");
                }
            }
            x = 0;
        }
        else {
            x++;
        }
    }
    return 0;
}

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

int main() {
  int N, ans=0;
  cin >> N;
  for(int i=int(N/1.08); i<=N; i++){
    if(int(i*1.08)==N){
      ans=i;
      break;
    }
  }
  if(ans!=0) cout << ans << endl;
  else cout << ":(" << endl;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector< vector<char> > field(n + 1, vector<char>(n + 1));
		for(int i = 1; i <= n; ++i)
		{
			for(int j = 1; j <= n; ++j)
			{
				cin >> field[i][j];
			}
		}
		int max_val = 0;
		vector< vector<int> > dp(n + 1, vector<int>(n + 1));
		for(int i = 1; i <= n; ++i)
		{
			for(int j = 1; j <= n; ++j)
			{
				if(field[i][j] == '*')
				{
					dp[i][j] = 0;
				}
				else
				{
					dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
					if(max_val < dp[i][j])
					{
						max_val = dp[i][j];
					}
				}
			}
		}
		cout << max_val << endl;
	}
}

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

Measured memory_bytes: 6088
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b, c;
    int ab, bc, ac;

    cin >> a >> b >> c;

    ab = a + b;
    bc = b + c;
    ac = a + c;

    cout << min(ab, min(bc, ac)) << endl;

    return 0;
}



Measured memory_bytes: 256
// D - Sum of Large Numbers
#include <bits/stdc++.h>
using namespace std;

int main(){
	long long k, ans = 0, MOD = 1'000'000'007;
	int N, K; cin>>N>>K;
	for(k=K; k<=N+1; ++k) // k:[0,N+1] k 個選択時の値の種数(max-min+1)
		ans = (ans + k*(N-k+1) + 1) % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans += A[i] / 2;
        A[i] %= 2;
        if(i < n && A[i] > 0 && A[i + 1] > 0)
        {
            A[i]--;
            A[i + 1]--;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
char c;
signed main(){
    cin>>c;
    cout<<(char)(c+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((b / a) > c) cout << c << endl;
	else cout << b / a << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())


num = 0
for i in range(1, N + 1):
    s = 0
    tmp = i
    while True:
        if i == 0:
            break
        s += i % 10
        i = int(i / 10)
    if A <= s and s <= B:
        num += tmp

print(num)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 

const int N = 2e5 + 2;

int a[N], siz[N];

int root(int u) {
    while(a[u]!=u) {
        a[u] = a[a[u]];
        u = a[u];
    }
    return u;
}

void uni(int u, int v) {
    u = root(u);
    v = root(v);
    if(u==v) return;
    a[u] = v;
    siz[v]+=siz[u];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    // #endif
    
    // int T;cin>>T;while(T--) 
    {
        int n, m, x, y;
        cin>>n>>m;
        iota(a, a+n, 0);
        fill(siz, siz+n, 1);
        ifr(i, 0, m) {
            cin>>x>>y; x--; y--;
            uni(x, y);
        }
        vll v;
        ifr(i, 0, n)
            if(a[i]==i)
                v.pb(siz[i]);
        
        sort(all(v));
        ll ans = v[0];
        ifr(i, 1, v.size())
            ans+=(v[i]-v[i-1]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 6816
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
signed main(){
	int ans=0;
	string s,t;
	cin>>s>>t;
	f(i,3){
		if(s[i]==t[i])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define SIZE 200000

using namespace std;

int main() {
    long long int A,B,i,j,k,N,M,K,Q;
    long long int X,Y,Y2;
  //  long long int A[100][100];

cin >> X >> Y;
if (Y % 2)
  cout << "No" << endl;
else {
  Y2 = Y >> 1;
  N = (X << 1) -Y2;
  if ((N >= 0) && (N <= X))
   cout << "Yes" << endl;
  else
  cout << "No" << endl;
}

  return 0;

}


Measured memory_bytes: 3672
// AFTER CONTEST, WIP

// NOTE: A bit of refactoring after contest

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
template<class T, size_t N>  istream& operator>>(istream& i, array<T, N>& x)  { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T, size_t N>  ostream& operator<<(ostream& o, const array<T, N>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  ll n, m, k; // n, m <= 3000, k <= 10^5
  cin >> n >> m >> k;

  map<ll, map<ll, ll>> vs;
  FOR(i, 0, k) {
    ll x, y, v;
    cin >> x >> y >> v;
    x--; y--; // zero-based
    vs[x][y] = v;
  }
  // DD(vs);

  auto getMax = [](auto& x) { return *max_element(ALL(x)); };

  vector<array<ll, 4>> dp(m, array<ll, 4>({0, 0, 0, 0}));
  auto dp_prev = dp;
  FOR(i, 0, n) {
    if (i) {
      dp[0][0] = getMax(dp_prev[0]);
    }
    if (vs[i].count(0)) {
      dp[0][1] = dp[0][0] + vs[i][0];
    }
    FOR(j, 1, m) {
      dp[j] = dp[j - 1];
      if (i) {
        dp[j][0] = max(dp[j][0], getMax(dp_prev[j]));
      }
      if (vs[i].count(j)) {
        FOR(p, 1, 4) {
          dp[j][p] = max(dp[j - 1][p], dp[j - 1][p - 1] + vs[i][j]);
        }
        if (i) {
          dp[j][1] = max(dp[j][1], getMax(dp_prev[j]) + vs[i][j]);
        }
      }
    }
    // DD(dp);
    dp_prev = dp;
  }

  ll res = getMax(dp[m - 1]);
  cout << res << endl;
}

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


Measured memory_bytes: 16576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n,k;
    cin >> n >> k;
    if(n%k == 0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define N 400001
using namespace std;
typedef long long ll;
string s[N];
ll n,maxl=-1;
queue<ll> q;  
inline bool cmp(string sa,string sb){
	return sa<sb;
}
main(){
	register int i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>s[i];
	sort(s+1,s+n+1,cmp);
	ll p=1,tot=1;
	while(p<=n){
		if(s[p]==s[p+1])tot++;
		else{
			if(maxl<tot){
				maxl=tot;
				while(!q.empty())q.pop();
				q.push(p);
			}
			else if(maxl==tot)q.push(p);
			tot=1;
		}
		p++;
	} 
	while(!q.empty()){
		ll k=q.front();
		cout<<s[k]<<endl;
		q.pop();
	}
	return 0;
} 

Measured memory_bytes: 17536
#include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
	vector<int> prid(MAX);
	vector<int> pri(MAX);
	int k=0;
	for(int i=0;i<MAX;i++)
		prid[i]=1;
	prid[0]=0;
	prid[1]=0;
	for(int i=0;i*i<MAX;i++){
		if(prid[i]){
			for(int j=i*2;j<MAX;j+=i)
				prid[j]=0;
		}
	}
	for(int i=0;i<MAX;i++)
	if(prid[i])
	pri[k++]=i;
	int x;
	while(cin>>x){
		for(int i=0;i<MAX;i++)
		if(pri[i]>x){
			if(pri[i-1]==x)
			cout<<pri[i-2]<<' ';
			else cout<<pri[i-1]<<' ';
			cout<<pri[i]<<endl;
			
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd

def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    p.sort()
    print(sum(p[:k]))



BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")


if __name__ == "__main__":
    main()



Measured memory_bytes: 67260
#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 <bitset>
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int l, t;
		cin >> l >> t;
		sum += t - l + 1;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3568
use std::io;
use std::io::BufRead;
use std::io::BufReader;

fn main() {
    let reader = io::stdin();
    let mut reader = BufReader::new(reader.lock());

    let mut s = String::new();

    let _ = reader.read_line(&mut s);
    let vec: Vec<u32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let a = vec[0];
    let b = vec[1];
    println!("{}", a * b - (a + b) + 1);
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    VI a1(n), a2(n);
    REP(i, n){
        int a;
        cin >> a;
        a1[i] = a;
        a2[i] = a;
    }

    ll ans1 = 0;
    REP(i, n - 1){
        int sum = a1[i] + a1[i + 1];
        if(sum > x){
            a1[i + 1] -= sum - x;
            ans1 += (ll)(sum - x);
            if(a1[i + 1] < 0){
                a1[i] += a1[i + 1];
                a1[i + 1] = 0;
            }
        }
    }
    ll ans2 = 0;
    FORR(i, n - 1, 1){
        int sum = a2[i] + a2[i - 1];
        if(sum > x){
            a2[i - 1] -= sum - x;
            ans2 += (ll)(sum - x);
            if(a2[i - 1] < 0){
                a2[i] += a2[i - 1];
                a2[i - 1] = 0;
            }
        }
    }

    cout << min(ans1, ans2) << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int Ans=1000000;
  for(int i=0; i<=N; i++){
    int K=i;
    int L=N-i;
    int subAns=0;
    while(K>0){
      subAns+=K%6;
      K/=6;
    }
    while(L>0){
      subAns+=L%9;
      L/=9;
    }
    Ans=min(Ans, subAns);
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        long[] l = new long[2];
        l[0] = sc.nextLong();
        l[1] = sc.nextLong();
        long ans =  l[0] * l[1];
        long[] s = new long[3];
        for (int i = 0; i < 2; i++) {
            for (int j = 1; j <= l[i]; j++) {
                s[0]=(long)j*l[abs(1-i)];
                s[1]=(l[i]-(long)j)/2*l[abs(1-i)];
                s[2]=l[0]*l[1]-s[0]-s[1];
                Arrays.sort(s);
                ans=min(ans,s[2]-s[0]);
                s[0]=(long)j*l[abs(1-i)];
                s[1]=l[abs(1-i)]/2*(l[i]-(long)j);
                s[2]=l[0]*l[1]-s[0]-s[1];
                Arrays.sort(s);
                ans=min(s[2]-s[0],ans);
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 24788
def selection_sort(n, as)
  count = 0
  i = 0
  while i < n do
    min = as[i]
    min_index = i
    j = i + 1
    while j < n do
      if min > as[j]
        min = as[j]
        min_index = j
      end
      j = j + 1
    end
    if min_index > i
      a = as[min_index]
      as[min_index] = as[i]
      as[i] = a
      count = count + 1
    end
    i = i + 1
  end
  puts as.join(' ')
  puts count
end

n = STDIN.gets.to_i
as = STDIN.gets.split(' ').map {|x| x.to_i }
selection_sort(n, as)




Measured memory_bytes: 6868
import java.util.*;

class Main{
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=Integer.parseInt(Integer.toString(a).concat(Integer.toString(b)));
		if((int)Math.sqrt(c)*(int)Math.sqrt(c)==c)
		System.out.println("Yes");
		else
		System.out.println("No");
	}
}

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


class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer st1 = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st1.nextToken());
        int k = Integer.parseInt(st1.nextToken());

        st1 = new StringTokenizer(br.readLine());

        int arr[] = new int [n];

        for(int i = 0 ; i < n ; i++)
        {
            arr[i] = Integer.parseInt(st1.nextToken());
        }

        int dp[] = new int [n];

        for(int i = 1 ; i < n ; i++)
        {
            dp[i] = Integer.MAX_VALUE;
            for(int j = 1 ; j <= k && i - j >= 0 ; j++)
                dp[i] = Math.min(Math.abs(arr[i]-arr[i-j]) + dp[i-j] , dp[i]);
        }

        out.println(dp[n-1]);

        out.flush();
        out.close();
    }

}

Measured memory_bytes: 34404
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  ll x, y;
  ll ans = 0;
  cin >> x >> y;
  if( x >= 0 ) { //x:+
    if( y >= 0 ) { //y:+
      if( x > y ) {
	ans++;
	ans += y - (-x);
	ans = min(ans, x - y + 2);
      } else { //x < y
	ans = y - x;
      }
    } else { //y:-
      if( x > -y ) {
	ans++;
	ans += x + y;
      } else {
	ans++;
	ans += (-y) - x; 
      } 
    }
  } else { //x:-
    if( y >= 0 ) { //y:+
      if( -x > y ) {
	ans = (-x) + y;
	ans = min(ans, (-x) - y + 1);
      } else {
	ans = x + y;
	ans++;
      }
    } else { //y:-
      if( x > y ) {
	ans += (-y) - (-x);
	ans += 2;
      } else {
	ans += (-x) - (-y);
      }
    }
  }

  cout << ans << endl;
}


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

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

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  vector<pair<int,int>> v;
  if(s[0] == '0' || s[n-1] == '1') NO();
  for(int i = 0; i < n - 1; i++) if(s[i] != s[n - 2 - i]) NO();
  v.emplace_back(1, 2);
  int last = 2;
  for(int i = 2; i <= n - 1; i++) {
    v.emplace_back(last, i + 1);
    if(s[i-1] == '0') {
    } else {
      last = i + 1;
    }
  }
  for(int i = 0; i < n - 1; i++) cout << v[i].first << " " << v[i].second << endl;
  return 0;
}


Measured memory_bytes: 2372
import java.util.*;
 
 
import java.io.*;
 
 
 
public class Main 
{   
	
	static int dp[][][];
	static long mod=1000000007;
	public static void main(String[] args) throws IOException 
	{ 
		 
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
			StringTokenizer s=new StringTokenizer(br.readLine());
			String st=s.nextToken();
			s=new StringTokenizer(br.readLine());
			int d=Integer.parseInt(s.nextToken());		 
			dp=new int[10005][105][2];
			
			
			for (int i = 0; i < 10005; i++) {
	            for (int j = 0; j < 105; j++) {
	                for (int k = 0; k < 2; k++) {
	                    dp[i][j][k] = -1;
	                }
	            }
	        }
			
			long ans=solveD(st,0,0,d,true);			
			pw.println((ans-1+mod)%mod);
			pw.close();
		
		
	}
	private static int solveD(String s, int pos,int cnt, int d, boolean tight) {
		// TODO Auto-generated method stub
		if(pos==s.length())
			return (cnt==0)?1:0;
		
		if(dp[pos][cnt][(tight)?1:0]!=-1)
			return dp[pos][cnt][(tight)?1:0];
		
		int ans=0;
		
		int end=(tight)?(s.charAt(pos)-'0'):9;
		
		for(int i = 0; i<=end ;i++){
			
				ans = (int) ((ans+ solveD(s,pos+1,(cnt+i)%d,d, tight&(i==end)))%mod);
		}
		return dp[pos][cnt][(tight)?1:0] = ans;
	}
	
	
}

Measured memory_bytes: 60560
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = (a); i < (n); i++)
#define ford(i,n,a)     for(ll i = (n); i >= (a); i--)
#define pb              push_back
#define lb              lower_bound   // first element >= val(itr) 
#define ub              upper_bound   // first element >  val(itr)
#define vll             vector<ll>
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a)) //x can be 0 or -1

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a; }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod;   }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;       }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod; }

#ifdef LOCAL_TEST
  #include"C:\\Users\\kaush\\OneDrive\\Desktop\\debug.h"
#endif

const ll inf = 1e18;
const int nax = 2e5 + 5;

void SolveTestCase()
{
  ll n;
  cin>>n;
  
  ll a[n];
  ll Xor = 0;
  forn(i,0,n){
    cin>>a[i];
    Xor = Xor^a[i];
  }
  
  forn(i,0,n){
    cout<<(Xor^a[i])<<" ";
  }
}

int main()
{
  speedup_IO;

  int t = 1;
  //cin >> t;
  forn(i, 0, t)
  {
    SolveTestCase();
  }

  return 0;
}


Measured memory_bytes: 5136
#include <stdio.h>
int main()
{
    long long n,k,b,ans;
    scanf("%lld%lld",&n,&k);
    if (k==0) {printf("%lld",n*n);return(0);}
    ans=0;
    for (b=k;b<=n;b++)
    {
        if (n%b<k) ans+=(b-k)*(n/b); else
        ans+=(b-k)*(n/b)+(n%b)-k+1;
    }
    printf("%lld",ans);
    return(0);
}

Measured memory_bytes: 128
from heapq import *

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

r = 0
Q = [-A[0]]
for v in A[1:]:
	c = -heappop(Q)
	r += c
	heappush(Q, -v)
	heappush(Q, -v)

print(r)


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

int main()
{
  int n, m;
  cin >> n >> m;
  
  int result = 0;
  
  for (int i = 2 ; i <= 100; i++)
  {
    if (n >= i) result += i - 1;
    if (m >= i) result += i - 1;
  }
  
  cout << result << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=45,MAXM=131072,MOD=1000000007;
int dp[MAXN][MAXM+5];
int n,x,y,z;
bool check(int t)
{
	if((t&(1<<(x+y+z-1)))!=0&&(t&(1<<(y+z-1)))!=0&&(t&(1<<(z-1)))!=0)
		return 1;
	return 0;
}
long long ksm(long long x,long long y)
{
	long long k=1;
	while(y)
	{
		if(y&1)
			k=(k*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return k;
}
int main()
{
	scanf("%d %d %d %d",&n,&x,&y,&z);
	dp[0][0]=1;
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<MAXM;j++)
		{
			if(dp[i][j])
			{
				for(int k=1;k<=10;k++)
				{
					int j1=((j<<k)+(1<<(k-1)))%MAXM;
					if(check(j1))
					{
						ans+=(dp[i][j]*ksm(10,n-i-1))%MOD;
						ans%=MOD;
					}
					else
					{
						dp[i+1][j1]+=dp[i][j];
						dp[i+1][j1]%=MOD;
					}
				}
			}
		}
	}
	printf("%lld\n",ans);
}

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define fst first
#define snd second

int main()
{
	long double a, b, c, x, y, z;
	cin >> a >> b >> c;
	x = sqrt(a), y = sqrt(b), z = sqrt(c);
	
	if(a + b + 2*(sqrt(a*b)) < c) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],b[1000000],c[1000000];
long long f[1000000],xx;
long long sum;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;for (int i=1;i<=n;i++)cin>>a[i];
	for (int i=1;i<=n;i++)cin>>b[i];
	for (int i=1;i<=n;i++)cin>>c[i];sort(a+1,a+1+n);sort(b+1,b+1+n);sort(c+1,c+1+n);
	xx=1;for (int i=1;i<=n;i++){
		while (c[xx]<=b[i]&&xx<=n)xx++;
		f[i]=n-xx+1;
	} for (int i=n;i>=1;i--)f[i]+=f[i+1];
	xx=1;for (int i=1;i<=n;i++){
		while (b[xx]<=a[i]&&xx<=n)xx++;
		sum+=f[xx];
	}cout<<sum<<endl;
} 

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

int main(){
	int num[4] = { -1,-1,-1,-1 };
	int number = 0;
	cin >> number;
	num[0] = number / 1000;
	number = number % 1000;
	num[1] = number / 100;
	number = number % 100;
	num[2] = number / 10;
	num[3] = number % 10;
	if ((num[0] == num[1] && num[1] == num[2]) || (num[1] == num[2] && num[2] == num[3]) ){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  int time = 1 ;
  vint d(n,0) ;
  vint f(n,0) ;
  vint seen(n,0) ;
  vint chec(n,0) ;
  vector<queue<int>> gra(n) ;
  REP(i,n){
    int a, b ;
    cin >> a >> b ;
    REP(j,b){
      int c ;
      cin >> c ;
      gra[a-1].push(c-1) ;
    }
    gra[a-1].push(-1) ;
  }
  
  stack<int> S ;
  
  S.push(0) ;
  
  while(!S.empty()){
    int k = S.top() ;
    if(seen[k]==0){
      seen[k] = 1 ;
      d[k] = time ;
    }
    if(gra[k].front()!=-1){
      if(seen[gra[k].front()]==0){
        int l = gra[k].front() ;
        S.push(l) ;
        gra[k].pop() ;
        time++ ;
      }
      else{
        gra[k].pop() ;
        continue ;
      }
    }
    else{
      if(chec[k]==0){
        time++ ;
        chec[k] = 1 ;
        f[k] = time ;
      }
      S.pop() ;
    }
    if(S.empty()){
      REP(i,n){
        if(seen[i]==0){
          S.push(i) ;
          time++ ;
          break ;
        }
      }
    }
  }
  
  
  REP(i,n){
    cout << i+1 <<" "<<d[i] <<" " <<f[i] <<endl ;
  }
      
  return 0 ;
}




Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < (n);i++)
#define lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

signed main(){
    int n;
    lint sum = 0;
    cin >> n;
    vector<lint>a(n);
    REP(i, n) cin >> a[i];
    vector<lint>acm(n+1);
    acm[0] = 0;
    REP(i, n){
        acm[i + 1] = (acm[i] + a[i]) % mod;
    }
    REP(i, n) {
        sum += acm[i] * a[i] % mod;
        sum %= mod;
    }
    cout << sum << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  vector<int> vv[4];
  ll w1;

  rep (i, N) {
    int w, v;
    cin >> w >> v;
    if (i == 0) w1 = w;
    vv[w - w1].eb(v);
  }

  vector<int> sum[4];
  rep (i, 4) {
    sort(rall(vv[i]));
    sum[i].eb(0);
    rep (j, vv[i].size()) {
      sum[i].eb(sum[i].back() + vv[i][j]);
    }
  }

  int ans = 0;
  rep (i, sum[0].size()) rep (j, sum[1].size()) rep (k, sum[2].size()) rep (l, sum[3].size()) {
    ll w = w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l;
    if (w > W) continue;
    ans = max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
  }

  cout << ans << endl;
}


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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<vector<ll>> ab;
    for (int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        ab.push_back({a, b});
    }
    sort(ab.begin(), ab.end());
    for (int i = 0; i < N; i++) {
        K -= ab[i][1];
        if (K <= 0) {
            cout << ab[i][0] << endl;
            return 0;
        }
    }
}


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

int main() {
  int N, K;
  int j = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++){
    if(2*j < j + K){
      j += j;
    }
    else{
      j += K;
    }
  }
  cout << j << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  string s,t; cin>>s>>t;
  map<char,char> m;
  for(int i=0; i<s.size(); i++){
    if(m[s.at(i)]!=0){
      if(m[s.at(i)]!=t.at(i)){
        cout<<"No"<<endl;
        return 0;
      }
    }
    else{
      m[s.at(i)] = t.at(i);
    }
  }
  set<char> c;
  for(char x='a'; x<='z'; x++){
    if(m[x]==0) continue;
    if(c.count(m[x])){
      cout << "No"<<endl;
      return 0;
    }
    else c.insert(m[x]);
  }
  cout <<"Yes"<<endl;
  
}



Measured memory_bytes: 3904