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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int h,w,n;
	cin>>h>>w>>n;
	int a=max(h,w);
	if(n%a==0)cout << n/a << endl;
	else cout << n/a+1 << endl;

	return 0;
}

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

int main() {
	int n; cin >> n;
	deque<int>a;
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp;
		if (n % 2 == 0) {
			if (i % 2 != 0)a.push_front(tmp);
			else a.push_back(tmp);
		}
		else {
			if (i % 2 == 0)a.push_front(tmp);
			else a.push_back(tmp);

		}
	}
	for (auto&& x : a)cout << x << ' '; cout << endl;

	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            int H = scan.nextInt();
            int W = scan.nextInt();
            if (H == 0 || W == 0) {
                break;
            }
            for (int i = 0;i < H; i++) {
                for (int j = 0;j < W; j++) {
                    if ((i + j) % 2 == 0 ) {
                        sb.append("#");
                    } else {
                        sb.append(".");
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }

}

Measured memory_bytes: 27676
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    double ans=0;
    for(int i=0;i<N;i++){
        ans+=(double)1/A[i];
    }
    cout << fixed << setprecision(10);
    cout << (double)1/ans << endl;

    return 0;
}

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

using namespace std;

int main() {


	long a, b, k;
	scanf("%ld %ld %ld", &a, &b, &k);

	if(b - a + 1 <= 2 * k) {
		for(long i = a; i <= b; i++) {
			printf("%ld\n", i);
		}
	} else {
		for(long i = a; i < a + k; i++) {
			printf("%ld\n", i);
		}

		for(long i = b - k + 1; i <= b; i++) {
			printf("%ld\n", i);
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  if (S.substr(5, 2) <= "04") {
    std::cout << "Heisei" << std::endl;
  } else {
    std::cout << "TBD" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int compUp(const void* a, const void* b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int N, K;
    scanf("%d%d", &N, &K);
    int h[N];
    int i;
    for(i = 0; i < N; i++){scanf("%d", &h[i]);}

    int d;
    int min = 1000000001;
    qsort(h, N, sizeof(int), compUp);
  //今度はprintf消すの忘れてた・・・
    //for(i = 0; i < N; i++){printf("%d ", h[i]);}printf("\n");
    for(i = 0; (i+K-1) < N; i++){
        d = h[i+K-1] - h[i];
        if(min > d){min = d;}
        //printf("min:%d d:%d\n", min, d);
    }

    printf("%d\n", min);
    return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    ll num ;
    set<int> vv ;
    cin >> num ;
    ll s = num ;
    bool t = true ;
    loop(1000000){
        vv . insert (s) ;
        s = (s % 2 == 0 ? s / 2 : 3 * s + 1 ) ;
        }
        //loopcout(9 , vv) ;

    cout << vv .size () + 1 << endl ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
require "prime"
class Integer
  def fac
    return 1 if self.zero?
    ary = [*1..self]
    loop do
      return ary[0] if ary.size == 1
      ary = ary.each_slice(2).map{|a| a.size == 2 ? a[0] * a[1] : a[0]}
    end
  end
 
  def combi(r)
    self.fac / ((r.fac) * ((self - r).fac))
  end
end
 
n, m = gets.chomp.split.map(&:to_i)
primes = Prime.prime_division(m)
 
ans = primes.reduce(1) do |sum, prime|
  sum * (prime.last + n - 1).combi(n - 1) % (10 ** 9 + 7)
end
 
puts ans

Measured memory_bytes: 40184
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
void read(int &x) {
	char ch; bool ok;
	for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
	for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}
#define rg register
const int maxn=3010,mod=1e9+7;
char ch[maxn];
int n,m,f[maxn][maxn],tot,sum[maxn],las[maxn];
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int main()
{
	read(n),read(m);scanf("%s",ch+1);
	for(rg int i=1;i<=n+1;i++){
		sum[i]=sum[i-1],las[i]=i;
		if(ch[i]=='1')tot++,sum[i]++;
	}
	for(rg int i=1,x,y;i<=m;i++)read(x),read(y),las[x]=max(las[x],y);
	for(rg int i=1;i<=n+1;i++)las[i]=max(las[i],las[i-1]);
	f[1][sum[las[1]]]=1;
	for(rg int i=1;i<=n;i++){
		for(rg int j=0;j<=tot;j++){
			int a=las[i],b=las[i+1];
			if(j)f[i+1][j+sum[b]-sum[a]-1]=add(f[i+1][j+sum[b]-sum[a]-1],f[i][j]);
			if(las[i]+1-i-j)f[i+1][j+sum[b]-sum[a]]=(f[i+1][j+sum[b]-sum[a]],f[i][j]);
		}
	}
	printf("%d\n",f[n+1][0]);
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e5 + 10;
int n, T, tot, cnt;
ll dp[2][30], sum[maxn];

struct node {
  int x, y;
} a[maxn];

int main() {
  cin >> n >> T;
  rep(i, 1, n) {
    int x = read(), y = read();
    if (!x) {
      sum[++cnt] = y;
    } else {
      a[++tot] = {x, y};
    }
  }
  sort(sum + 1, sum + cnt + 1);
  sort(a + 1, a + tot + 1, [] (node P, node Q) {
    return 1ll * Q.x * (P.y + 1) < 1ll * P.x * (Q.y + 1);
  });
  rep(i, 1, cnt) sum[i] += sum[i - 1] + 1;
  int sel = 1;
  memset(dp, 0x3f, sizeof dp);
  dp[0][0] = 0;
  rep(i, 1, tot) {
    memset(dp[sel], 0x3f, sizeof dp[sel]);
    dp[sel][0] = 0;
    rep(j, 1, 29) {
      dp[sel][j] = dp[sel ^ 1][j];
      ll v = dp[sel ^ 1][j - 1] + 1;
      if (v <= T) chkmin(dp[sel][j], v + a[i].x * v + a[i].y);
    }
    sel ^= 1;
  }
  int res = 0;
  rep(i, 0, 29) {
    ll v = dp[sel ^ 1][i];
    if (v > T) continue;
    int tmp = upper_bound(sum + 1, sum + cnt + 1, T - v) - sum - 1;
    chkmax(res, i + tmp);
  }
  cout << res;
  return 0;
} //

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var D = int.Parse(Console.ReadLine());

            switch (D)
            {
                case 25:
                    Console.WriteLine("Christmas");
                    break;
                case 24:
                    Console.WriteLine("Christmas Eve");
                    break;
                case 23:
                    Console.WriteLine("Christmas Eve Eve");
                    break;
                case 22:
                    Console.WriteLine("Christmas Eve Eve Eve");
                    break;
            }
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN];
int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
		if (s[i] == '?') s[i] = 'D';
	printf("%s\n", s + 1);
	return 0;
}


Measured memory_bytes: 3844
// Problem : E - Coprime
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	vector<int> v(n);
	int temp=0;
	int s=0,p=1;
	vector<int> prime((int)1e6+5),par((int)1e6+5);
	for(int i=2;i<=(int)1e6;++i)
	{
		if(!prime[i])
		{
			par[i]=i;
			for(int j=i+i;j<=(int)1e6;j+=i)
			{
				prime[j]=1;
				par[j]=i;
			}
		}
	}
	for(int i=0;i<n;++i)
	{
		cin >> v[i];
		if(i==0)
		temp=v[i];
		else
		temp=__gcd(temp,v[i]);
	}
	if(temp==1)
	s=1;
	set<int> S;
	for(int i=0;i<n;++i)
	{
		while(v[i]!=1)
		{
			if(S.find(par[v[i]])!=S.end())
			{
				p=0;
				break;
			}
			S.insert(par[v[i]]);
			int t=par[v[i]];
			while(v[i]%t==0)
			v[i]/=t;
		}
	}
	if(p)
	cout << "pairwise coprime" << endl;
	else if(s)
	cout << "setwise coprime" << endl;
	else
	cout << "not coprime" << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 18384
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int x,a,b;
	cin >>x>>a>>b;
	string s = "NO";
	if ((10*a+b)%4==0) {
		s = "YES";
	}
	
	cout <<s<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans;
    if(s=="SUN") ans = 7;
    else if(s=="MON") ans = 6;
    else if(s=="TUE") ans = 5;
    else if(s=="WED") ans = 4;
    else if(s=="THU") ans = 3;
    else if(s=="FRI") ans = 2;
    else ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Yeah bitch thats how I do it
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second     
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define mp make_pair
#define int long long
using namespace std;
const int INF = 1e18;
const int MAX = 2e5+5;

int MOD = 1e9+7;
// a^b
int fexpo(int a, int b)
{
	int ans = 1;
	while(b > 0)
	{
		if(b%2)
			ans = (ans*a)%MOD;
		b /= 2;
		a = (a*a)%MOD;
	}
	return ans;
}


int binarySearch(vector<int> &v, int x)
{
	int lo = 0, hi = v.size()-1, mid;
	while(lo <= hi)
	{
		mid = lo + (hi-lo)/2;
		if(v[mid] == x)
			return mid;
		else if(v[mid] > x)
			hi = mid-1;
		else
			lo = mid+1;
	}
	return -1;
}


int32_t main()
{
	
	int N, K, C;
	cin>>N>>K>>C;
	string str;
	cin>>str;
	vector<int> work_day;
	for(int i=0;i<str.size();i++)
	{
		if(str[i] == 'o')
			work_day.pb(i+1);
	}
	vector<int> pre_work_day;
	int beg = work_day[0];
	pre_work_day.pb(beg);
	for(int i=1;i<work_day.size();i++)
	{
		if(work_day[i]-beg >= C+1){
			pre_work_day.pb(work_day[i]);
			beg = work_day[i];
		}
	}
	const int sz = work_day.size();
	int dp[N+1];
	memset(dp, 0, sizeof(dp));
	for(int i=sz-1;i>=0;i--)
	{
		dp[work_day[i]] = 1;
		int ind = upper_bound(work_day.begin(), work_day.end(), work_day[i] + C)-work_day.begin();
		if(ind < sz)
			dp[work_day[i]] += dp[work_day[ind]];
	}
	vector<int> ans;
	for(int i=0;i<sz;i++)
	{
		int ind = binarySearch(pre_work_day, work_day[i]);
		if(ind != -1 && pre_work_day.size() >= K)
		{
			if(ind + dp[work_day[i+1]] < K)
				ans.pb(work_day[i]);
		 	else if(i == sz-1 && pre_work_day.size() == K)
		 		ans.pb(work_day[i]);
		}
	}
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<"\n";
	
}	





Measured memory_bytes: 8180
#include<iostream>
using namespace std;
int main(){
	int n,m,res=0;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	cin>>m;
	string t[m];
	for(int i=0;i<m;i++){
		cin>>t[i];
	}
	/*for(int i=0;i<n;i++){
			cout<<s[i]<<endl;
			cout<<t[i]<<endl;
		}*/
	int tmp=0;
	for(int i=0;i<n;i++){
		res=0;
		for(int j=0;j<n;j++){
			if(s[i]==s[j]){
				//if(i==j)continue;
				res++;
			}
		}
		for(int k=0;k<m;k++){
			if(s[i]==t[k]){
				res--;
			}
		}
		tmp=max(tmp,res);
	}
	cout<<tmp<<endl;
}


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




int main(){
    string S, T; cin >> S >> T;
    ll N = S.size(), M = T.size();
    vector<vector<ll>> DP(N+1, vector<ll>(M+1));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            if(S[i] == T[j]) DP[i+1][j+1] = DP[i][j]+1;
            else DP[i+1][j+1] = max(DP[i+1][j], DP[i][j+1]);
        }
    }
    string ans = "";
    ll cnt = DP[N][M];
    ll n = N, m = M;
    while(cnt >= 1){
        while(n >= 1 && m >= 1 && DP[n-1][m] == DP[n][m]) n--;
        while(n >= 1 && m >= 1 && DP[n][m-1] == DP[n][m]) m--;
        ans += T[max((ll)0, m-1)];
        cnt--;

        while(n >= 1 && m >= 1 && DP[n][m] == DP[n-1][m-1]){ n--; m--;}
        n--;m--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;


    
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e18;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main(){
  int n;
  cin >> n;
  vector<ll> d(n);
  rep(i,n) cin >> d[i];
  int m;
  cin >> m;
  vector<ll> t(m);
  rep(i,m) cin >> t[i];

  sort(d.begin(),d.end());
  sort(t.begin(),t.end());

  int id = 0;
  int it = 0;
  while(true){
    if(it == m) {
      cout << "YES" << endl;
      return 0;
    }
    if(id == n) {
      cout << "NO" << endl;
      return 0;
    }

    if (d[id] != t[it]) id++;
    else {
      it++;
      id++;
    }
  }

  return 0;
}


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

const int maxn = 200000 + 7;
const long long INF = (1LL << 62);

long long f[maxn * 4], g[maxn * 4];
long long G = 0;
void build(int u, int x, int y) {
    if (x == y) {
        f[u] = g[u] = INF;
        return ;
    }
    int mid = (x + y) >> 1;
    build(u * 2, x, mid);
    build(u * 2 + 1, mid + 1, y);
    f[u] = min(f[u * 2], f[u * 2 + 1]);
    g[u] = min(g[u * 2], g[u * 2 + 1]);
}

void update(long long *f, int u, int x, int y, int p, long long v) {
    if (p < x || p > y) return ;
    if (x == y) {
        f[u] = min(f[u], v);
        return ;
    }
    int mid = (x + y) >> 1;
    update(f, u * 2, x, mid, p, v);
    update(f, u * 2 + 1, mid + 1, y, p, v);
    f[u] = min(f[u * 2], f[u * 2 + 1]);
}

long long query(long long *f, int u, int x, int y, int L, int R) {
    if (y < L || x > R) return INF;
    if (L <= x && y <= R) return f[u];
    int mid = (x + y) >> 1;
    return min(query(f, u * 2, x, mid, L, R), query(f, u * 2 + 1, mid + 1, y, L, R));
}

long long ask(int u, int x, int y) {
    if (x == y) return (f[u] == INF)? INF : (f[u] + g[u]) / 2;
    int mid = (x + y) >> 1;
    return min(ask(u * 2, x, mid), ask(u * 2 + 1, mid + 1, y));
}


int n, q, a, b;
int x[maxn];
void update(int p, long long v) {
    update(f, 1, 1, n, p, v - p - G);
    update(g, 1, 1, n, p, v + p - G);
}

int main() {
    scanf("%d%d%d%d", &n, &q, &a, &b);
    build(1, 1, n);

    for (int i = 1; i <= q; i++) scanf("%d", &x[i]);

    update(b, abs(a - x[1]));
    update(a, abs(b - x[1]));
    // for (int j = 1; j <= n; j++) cout << query(f, 1, 1, n, j, j) + j + G << ' ';
    // cout << endl;
    for (int i = 2; i <= q; i++) {
        long long new_value = min(query(g, 1, 1, n, x[i], n) - x[i], query(f, 1, 1, n, 1, x[i]) + x[i]) + G;

        G += abs(x[i - 1] - x[i]);
        update(x[i - 1], new_value);

        // for (int j = 1; j <= n; j++) cout << query(f, 1, 1, n, j, j) + j + G << ' ';
        // cout << endl;
    }
    cout << ask(1, 1, n) + G << endl;
    return 0;
}



Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

typedef double ld;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 1e8 + 10;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main(){ _

	int N,M;
	cin >> N >> M;

	vector<vector<int>> g(N+1, vector<int>(N+1, INF));

	vector<tuple<int,int,int>> E;

	while(M--){
		int x,y,z;	
		cin >> x >> y >> z;
		
		g[x][y] = z;
		g[y][x] = z;
		E.pb({x,y,z});
	}

	for(int k = 1; k <= N; k++){
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= N; j++){
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	int ans = 0;
	for(auto [x,y,z] : E){
		if(g[x][y] != z) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
typedef long long ll;

ll x, res=0;
int main(){
        scanf("%lld", &x);
        res+=1000*(x/500);
        x%=500;
        res+=5*(x/5);
        printf("%lld\n", res);
        return 0;


 }


Measured memory_bytes: 256
local n = io.read("*n")
local a = io.read("*n")
local b = io.read("*n")
local c = io.read("*n")
local d = io.read("*n")
io.read("*l")
local s = io.read("*l")
local empty = string.byte(".", 1)
local rock = string.byte("#", 1)
if a > b then
	a, b = b, a
	c, d = d, c
end
local threeempty = false
for i = 1, math.max(c, d) do 
	if a < i and i < c and string.byte(s, i) == rock and string.byte(s, i + 1) == rock then
		print("No")
		return
	end
	if b < i and i < d and string.byte(s, i) == rock and string.byte(s, i + 1) == rock then
		print("No")
		return
	end
	if b - 1 <= i and i < d and i + 2 <= n and string.byte(s, i) == empty and string.byte(s, i + 1) == empty and string.byte(s, i + 2) == empty then
		threeempty = true
	end
end

if d < c then
	if not threeempty then
		print('No')
		return
	end
end
print("Yes")

Measured memory_bytes: 2696
from collections import deque
k = int(input())
d = deque([1,2,3,4,5,6,7,8,9])
result = []
append = d.append
popleft = d.popleft
for i in range(10**5):
    work = popleft()
    result.append(work)
    if work%10 == 0:
        append(work*10+0)
        append(work*10+1)
    elif work%10 == 9:
        append(work*10+8)
        append(work*10+9)
    else:
        append(work*10+work%10-1)
        append(work*10+work%10)
        append(work*10+work%10+1)
print(result[k-1])

Measured memory_bytes: 16092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF  = (1LL<<60);

ll mul(ll a,ll b){
  if( a > INF/b )return INF;
  else return a*b;
}

ll lcm(ll a,ll b){
  
  return mul(a/__gcd(a,b),b);
}

ll gcd(ll a,ll b){
  return __gcd(a,b);
}

int N;
ll t[500][500];

bool isPrime(ll x){
  if(x<2)return false;
  for(ll i=2;i*i<=x;i++)
    if(x%i==0)return false;

  return true;
}

int main(){
  vector<ll> primes;
  for(int i=3;i<10000;i++){
    if(isPrime(i)){
      primes.push_back(i);
    }
    
  }
  cin>>N;
  int copyn=N;
  N=min(500,N+1);
  
  int cc=0;

  for(int i=0;i<N;i+=2){
    int py=0, px=i;
    for(int j=0;;j++){
      t[py][px]=primes[cc];
      py++;
      px++;
      if(py>=N || px>=N)break;
    }
    cc++;
  }

  for(int i=2;i<N;i+=2){
    int py=i, px=0;
    for(int j=0;;j++){
      t[py][px]=primes[cc];
      py++;
      px++;
      if(py>=N || px>=N)break;
    }
    cc++;
  }


  for(int i=0;i<N;i+=2){
    int py=0, px=i;
    for(int j=0;;j++){
      t[py][px]*=primes[cc];
      py++;
      px--;
      if(py>=N || px<0)break;
    }
    cc++;
  }

  for(int i= (N%2==1?2:1) ;i<N;i+=2){
    int py=i, px=N-1;
    for(int j=0;;j++){

      t[py][px]*=primes[cc];
      py++;
      px--;
      if(py>=N || px<0)break;
    }
    cc++;
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(t[i][j]!=0)continue;
      t[i][j]=1;
      if(i>0)t[i][j]=lcm(t[i][j],t[i-1][j]);
      if(j>0)t[i][j]=lcm(t[i][j],t[i][j-1]);
      if(i+1<N)t[i][j]=lcm(t[i][j],t[i+1][j]);
      if(j+1<N)t[i][j]=lcm(t[i][j],t[i][j+1]);
      t[i][j]++;
    }
  }

  N=copyn;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(j)cout<<' ';
      cout<<t[i][j];
    }
    cout<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 4992
from functools import partial

N = int(input())
S = input()

lst = [chr(ord("A")+i) for i in range(26)]

def convert(x,n):
  id = ord(x) - ord("A")
  return lst[(id+n)%26]

convert1 = partial(convert,n=N)

ans = "".join(map(convert1,S))
print(ans)

Measured memory_bytes: 9604
# -*- coding: utf-8 -*-
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K = int(input())
ans = 0
 
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, j, k)
print(ans)

Measured memory_bytes: 84616
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1e9+7
using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  cout << max({A,B,C})-min({A,B,C}) << endl;
}


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

#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) (v.begin(),v.end())
#define vi vector<int>

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    char c;
    cin >> c;
    cout << char(c + 1);
}

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

const int N = 1e5 + 10;
vector<int> G[N];

int main() {
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int h[n];
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++) {
        bool ok = true;
        for(int u : G[i]) {
            if(h[u] >= h[i]) ok = false;
        }
        if(ok) ans++;
    }

    cout << ans << "\n";



    return 0;
}

Measured memory_bytes: 9140
import java.util.*;

public class Main  {
   public static void main(String[] args)  {
      Scanner sc = new Scanner(System.in);
          
      int k = sc.nextInt();
      String s = sc.next();
      
      if (s.length() <= k) {
         System.out.println(s);
      } else {
         System.out.println(s.substring(0, k) + "...");
      }        
   }
}

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

int N,M,Q,v[100009],d[100009],c[100009],dp[100009][19];
vector<int>x[100009];

int main(){
	cin>>N>>M;
	for(int i=1;i<=M;i++){
		int a,b;cin>>a>>b;
		x[a].push_back(b);
		x[b].push_back(a);
	}
	cin>>Q;
	for(int i=1;i<=Q;i++){
		cin>>v[i]>>d[i]>>c[i];
		dp[v[i]][d[i]]=max(dp[v[i]][d[i]],i);
	}
	for(int i=10;i>=1;i--){
		for(int j=1;j<=N;j++){
			dp[j][i-1]=max(dp[j][i-1],dp[j][i]);
			for(int k=0;k<x[j].size();k++){
				dp[x[j][k]][i-1]=max(dp[x[j][k]][i-1],dp[j][i]);
			}
		}
	}
	for(int i=1;i<=N;i++){
		int maxn=0;
		for(int j=0;j<=10;j++) maxn=max(maxn,dp[i][j]);
		cout<<c[maxn]<<endl;
	}
	return 0;
}


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

int main() {
	string s,t;
    cin >> s;
    cin >> t;
    int count=0;
    for(int i=0;i<3;i++){
      if(s.at(i)==t.at(i)){
        count++;
      }      
    }
    cout << count << endl;
}


Measured memory_bytes: 256
target = int(input())
potential = input().split(" ")
min = int(potential[0])
max = int(potential[1])
 
can = []
for i in range(min,max+1):
  result = str(i/target)
  result = result.split(".")
  if result[1] == "0":
    can.append(i)
if len(can) != 0:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

int main(void) {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a.rbegin(), a.rend());
    int cnt = 0;
    int one = 0;
    int two = 0;
    int i = 0;
    while (i < n - 1) {
        if (a[i] == a[i + 1]) {
            cnt++;
            if (cnt == 1) {
                one = a[i];
            } else {
                two = a[i];
                break;
            }
            i += 2;
        } else {
            ++i;
        }
    }
    printf("%lld\n", (long long)one * (long long)two);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin >> A >> B;
    int ans=0;
    if(A>12) ans=B;
    else if(A>5) ans=B/2;
    cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int  n,q;
    ll ans=0;
    string s;
    in(n,q,s);
    vector<ll> vec(n);
    vec[0]=0;
    for(int i=1;i<n;i++){
        if(s[i-1]=='A'&&s[i]=='C'){
            ans++;
        }
        vec[i]=ans;
    } 
    int l,r;
    rep(i,q){
        in(l,r);
        out(vec[r-1]-vec[l-1]);
    }
}

Measured memory_bytes: 4344
n = gets.to_i
robots = []
n.times do
  robots << gets.split.map(&:to_i)
end
robots.sort_by!{|x,l| x+l}
r = -10**10
ans = 0
robots.each do |x,l|
  next if r > x-l
  r = x+l
  ans += 1
end
p ans

Measured memory_bytes: 12664
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto i &a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int pow(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DTriangles {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(ALL(L));
    int ans = 0;
    REP(i, 0, N - 1) {
      REP(j, i + 1, N) {
        ans += LOWER_BOUND(L, L[i] + L[j]) - j - 1;
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  DTriangles solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main() {
    int n,ans;
    cin >> n;
    ans=1001001001;
    for(int i = 1;i < n; i++){
        int b = n - i, a = i;
        int hoge = 0;
        while(a > 0){
            hoge += a%10;
            a /= 10;
        }
        while( b > 0){
            hoge += b%10;
            b /= 10;
        }
        ans = min(ans, hoge);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

string s;
std::vector<char> v(3,'0');

int main() {
  std::cin >> s;
  rep(i, 0, 1<<(s.size()-1)){
    int tmp = s[0]-'0';
    rep(j,1,s.size()){
      if(i&(1<<(j-1))){
        tmp += s[j]-'0';
        v[j] = '+';
      }
      else{
        tmp -= s[j]-'0';
        v[j] = '-';
      }
    }
    if(tmp==7){
      std::cout << s[0];
      rep(i,1,4){
        std::cout << v[i]<<s[i];
      }
      std::cout <<"=7" << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	int a, b ,d, r;
	double x,f;
	cin >>a >>b;
	d = a/b;
	r = a%b;
	f = (double)a / (double) b;
	cout << d <<" "<<r << " ";
	printf("%.8lf\n", f);
	

}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;

int main()
{
	int n;
	string s;
	cin>>n;
 	cin>>s;
 	if(s.length()<=n){
 		cout<<s<<endl;
	 }else{
	 	for(int i=0;i<n;i++){
	 		cout<<s[i];
		 }
		 cout<<"..."<<endl;
	 }
	 return 0;
 	
}







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

typedef long long ll;

void solve() {
    ll A; cin >> A;
    long double B; cin >> B;
    cout << (ll)(A * B) << '\n';
}

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

    solve();
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define RFOR(i, l, r) for (int i = (int)(r); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

vector<int> G[100001], rG[100001];
vector<int> cmp(100001, -1);

void dfs(int v, vector<bool>& used, vector<int>& vs) {
    used[v] = true;
    for (auto u: G[v]) {
        if (!used[u]) dfs(u, used, vs);
    }
    vs.push_back(v);
}

void rdfs(int v, vector<bool>& used, int k) {
    used[v] = true;
    cmp[v] = k;
    for (auto u: rG[v]) {
        if (!used[u]) rdfs(u, used, k);
    }
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int V, E;
    cin >> V >> E;

    REP(i, E) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        rG[t].push_back(s);
    }

    vector<int> vs;
    vector<bool> used(V, false);
    REP(i, V) if (!used[i]) dfs(i, used, vs);

    REP(i, V) used[i] = false;
    int k = 0;
    RREP(i, V) if (!used[vs[i]]) rdfs(vs[i], used, k++);

    int Q;
    cin >> Q;
    REP(i, Q) {
        int u, v;
        cin >> u >> v;
        if(cmp[u] == cmp[v]) cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int sum = 0;
	int num = 0;
	int i = 0;

	int a, b;
	char c;
	while( cin >> a >> c >> b ) {
		sum += a*b;
		num += b;
		i += 1;
	}

	double avg = num / (double)i;
	cout << sum << '\n' << (int)(avg + 0.5) << '\n';
	return 0;
}



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

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    double x = (n - d) / (n * n);
    if (d > 0) x *= 2;
    double ans = x * (m - 1);
    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

#[derive(Debug, Copy, Clone)]
struct P {
    to: usize,
    c: u64,
}

fn walk(i: usize, p: usize, l: u64, t: &Vec<Vec<P>>, mut ll: &mut Vec<u64>) {
    ll[i] = l;
    for j in t[i].iter() {
        if j.to != p {
            walk(j.to, i, l+j.c, t, ll);
        }
    }
}

fn main() {
    let n = get!(usize);
    let mut t = vec![Vec::new(); n];
    for _ in 1..n {
        let (a, b, c) = get!(usize, usize, u64);
        t[a-1].push(P { to: b-1, c: c });
        t[b-1].push(P { to: a-1, c: c });
    }
    let (q, k) = get!(usize, usize);
    let mut ll = vec![0; n];
    walk(k-1, n, 0, &t, &mut ll);
    for _ in 0..q {
        let (x, y) = get!(usize, usize);
        println!("{}", ll[x-1] + ll[y-1]);
    }
}

Measured memory_bytes: 22396
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val w: String = sc.next

    val map = collection.mutable.Map[Char, Int]()

    val ans = w.foldLeft(map) { (map, c) =>
    	if (map.contains(c)) map(c) += 1 else map(c) = 1
    	map
    }.values.count(_ % 2 != 0) == 0

    println(if (ans) "Yes" else "No")
  }
}

Measured memory_bytes: 22040
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: usize, y: usize, a: usize, b: usize, c: usize,
        p: [u64;a],
        q: [u64;b],
        r: [u64;c],
    }

    let mut p = p.clone();
    p.sort_by(|a, b| b.cmp(a));
    let mut q = q.clone();
    q.sort_by(|a, b| b.cmp(a));

    let mut r = r.clone();
    r.sort_by(|a, b| a.cmp(b));

    let mut px = Vec::from(&p[..x]);
    let mut qy = Vec::from(&q[..y]);

    let mut res = 0;

    while px.last().is_some() || qy.last().is_some() {
        let n = r.pop().unwrap_or(0);
        let m = if px.last().unwrap_or(&1_000_000_001) <= qy.last().unwrap_or(&1_000_000_001) {
            px.pop().unwrap()
        } else {
            qy.pop().unwrap()
        };

        res += std::cmp::max(n, m);
    }

    println!("{}", res);
}


Measured memory_bytes: 16504
def dfs(i, sum, count, nokori):
  global ans
  if i == D:    
    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < G:
      use = max(nokori)
      n = min(PC[use-1][0], -(-(G-sum)//(use*100)))
      count += n
      sum += n*use*100
    if sum >= G:
      ans = min(ans, count)
  else:
    # 総合スコア、解いた問題数、まだ解いてない問題を更新
    dfs(i+1, sum, count, nokori)
    dfs(i+1, sum+PC[i][0]*(i+1)*100+PC[i][1],
       count+PC[i][0], nokori-{i+1})

D, G = map(int, input().split())
PC = [list(map(int, input().split())) for i in range(D)]
ans = float("inf")
    
dfs(0,0,0,set(range(1, D+1)))    
print(ans)




Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LEN 100005

using namespace std;

typedef struct PP{
    char name[100];
    int t;
} PP;

PP Q[LEN];

int  head,tail,n;

PP dequeue(){
    PP x = Q[head];
    head = (head+1)%LEN;
    return x;
}

void enqueue(PP x){
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

int main(void){
    int elaps = 0, c;
    int i,q;
    PP u;
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;++i){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
        
    }
    head = 1;
    tail = n+1;
    
    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t>0) enqueue(u);
        else{
            cout<<u.name<<' '<<elaps<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 13276
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    string s;
    cin>>s;

    int n=s.length();

    if(n%2)
    {
        cout<<"No";
        return;
    }


    for(int i=0;i+1<n;i+=2)
    {
        if(s[i]=='h' && s[i+1]=='i')
            ;
        else
        {
            cout<<"No";
            return;
        }
    }

    cout<<"Yes";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 764
s = input()
data = []
target = 'LR'
pre = 0
for i in range(len(s) - 1):
    if s[i:i+2] == target:
        data.append(s[pre:i+1])
        pre = i + 1

data.append(s[pre:len(s)])
ans = []
for i in range(len(data)):
    ans.append([0] * len(data[i]))
target = 'RL'
for i in range(len(data)):
    for j in range(len(data[i]) - 1):
        if data[i][j:j+2] == target:
            if len(data[i]) % 2 == 0:
                ans[i][j] = len(data[i]) // 2
                ans[i][j + 1] = len(data[i]) // 2
                break
            else:
                if j % 2 == 0:
                    ans[i][j] = (len(data[i]) + 1 ) // 2
                    ans[i][j + 1] = len(data[i]) // 2
                else:
                    ans[i][j + 1] = (len(data[i]) + 1 ) // 2
                    ans[i][j] = len(data[i]) // 2
                break
for i in range(len(ans)):
    for j in range(len(ans[i])):
        print(ans[i][j], end = " ")


Measured memory_bytes: 12220