akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

void dfs(int n, int x, string s) {
    if(n == 0) {
        cout << s << endl;
        return;
    }
    rep(i, x) {
        s.push_back('a' + i);
        dfs(n - 1, x, s);
        s.pop_back();
    }
    s.push_back('a' + x);
    dfs(n - 1, x + 1, s);
}

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

    int n;
    cin >> n;
    dfs(n, 0, "");

    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==4 || a==9 || a==6 || a== 11){
		if(b==4 || b==9 || b==6 || b== 11){
			printf("Yes");
		} else{
			printf("No");
		}
	} else if(a==2){
		if(b==2){
			printf("Yes");
		} else {
			printf("No");
		}
	}else if(b==4 || b==9 || b==6 || b== 11 || b==2){
			printf("No");
		} else{
			printf("Yes");
		}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
  double a,b,c;
  cin >> a >> b >> c;
double v = a*a*b;
  if(c >= v/2){
    v -= c;
    cout << fixed << setprecision(8) << atanf(v/a*2/a/a)*180/M_PI << endl;
  }else{
    cout << fixed << setprecision(8) << atanf(b*b*a/c/2)*180/M_PI << endl;
  }


  return 0;
}

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

typedef long long lli;

const lli MAXN = 4004;
const lli INF = 1LL<<60;
lli N;
lli w[MAXN], dp[MAXN][MAXN], K[MAXN][MAXN];

int main() {
  while (cin >> N) {
    w[0] = 0;
    for (lli i = 0; i < N; ++i) {
      cin >> w[i+1];
      w[i+1] += w[i];
    }
    fill(dp[0], dp[MAXN], INF);
    for (lli i = 0; i < N; ++i) {
      dp[i][i+1] = 0;
      K[i][i+1] = i;
    }
    for (lli l = 2; l <= N; ++l) {
      for (lli i = 0, j; (j = i + l) <= N; ++i) {
        for (lli s = K[i][j-1]; s <= K[i+1][j]; ++s) {
          lli v = dp[i][s] + dp[s][j] + (w[j] - w[i]);
          if (dp[i][j] > v) {
            dp[i][j] = v;
            K[i][j] = s;
          }
        }
      }
    }
    cout << dp[0][N] << endl;
  }
  return 0;
}

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

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

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

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

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
int N;
int A[250000], v[500][500];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
bool B[500][500];


int main() {
    init();
    cin >> N;
    rep(i, N * N) cin >> A[i], A[i]--;
    
    rep(i,N)rep(j,N){
        v[i][j] = min(min(i, j), min(N - i - 1, N - j - 1)), B[i][j] = true;
    }

    queue<pair<int,int>> q;
    int ans = 0;

    for(int i = 0; i < N * N; i++) {
        int R = A[i] / N, C = A[i] % N;
        ans += v[R][C];
        B[R][C] = false;

        q.emplace(R, C);
        while(!q.empty()){
            int r,c;
            tie(r, c) = q.front(), q.pop();
            int cost = v[r][c] + B[r][c];

            for (int j = 0; j < 4; j++) {
                int rr = r + dx[j], cc = c + dy[j];
                if (rr < 0 or rr >= N or cc < 0 or cc >= N) continue;
                if (v[rr][cc] > cost) q.emplace(rr, cc), v[rr][cc] = cost;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5728
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int K;
  cin >> K;
  
  bool check = false;
  rep(i,K){
    if(a >= b){
      b *= 2;
    }else if(b >= c){
      c *= 2;
    }
  	if(a < b && b < c){
    	check = true;
    	break;
  	}
  }
  
  if(check) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  char s[4];
  int ans=0;
  for (size_t i = 0; i < 4; i++) {
  std::cin >>s[i];
}
  for (size_t i = 0; i < 4; i++) {
    if (s[i] == '+') {
      ans++;
    }
    else{
      ans-=1;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

constexpr int MOD = 1000000007;

map<long, int> pf(long n) {
  map<long, int> ma;
  for (long i = 2; i * i <= n; i++) {
    while (n % i == 0) ma[i]++, n /= i;
  }
  if (n != 1) ma[n]++;
  return ma;
}

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

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

int main() {
  int N, M;
  cin >> N >> M;
  long ans = 1;
  for (auto m : pf(M)) {
    (ans *= com(m.second + N - 1, N - 1)) %= MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,a[N];
bool check(int mid){
	ll size=0;
	for (int i=1;i<=mid;i++) size+=a[i];
	for (int i=mid+1;i<=n;i++)
		if (a[i]<=size*2) size+=a[i];else return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=1,r=n;
	while (l<r){
		int mid=(l+r)>>1;
		if (check(mid)) r=mid;else l=mid+1;
	}
	printf("%d\n",n-l+1);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 100005;

int main() {
    ios::sync_with_stdio(false);
	int n,m,k;
	cin>>n>>m>>k;
	int cnt=0;
	for(int i = n;i<= m;i++) if(i % k ==0 ) cnt++;
	cout<<cnt<<endl;
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	s := sc.Text()

	for _, r := range s {
		rr := r
		if 65 <= r && r <= 90 {
			rr = r + 32
		} else if 97 <= r && r <= 122 {
			rr = r - 32
		}
		fmt.Printf("%c", rr)
	}
	fmt.Println()
}



Measured memory_bytes: 1076
// coded by- mrNOBODY_

#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin.sync();

    string s;
    getline(cin,s);
    int l = s.length();
    string a;
    if(l>=3 && l<=20)
    {
        a = s.substr(0,3);
    }
    cout<<a;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
const long long mod = 1e9+7;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    int i=0,j=0,k=0;
    char nx = 'a';
    while(true){
        if(nx == 'a' and i==sa.size()){
            cout << "A" << endl;
            return 0;
        }
        if(nx == 'b' and j==sb.size()){
            cout << "B" << endl;
            return 0;
        }
        if(nx == 'c' and k==sc.size()){
            cout << "C" << endl;
            return 0;
        }

        if(nx == 'a'){
            nx = sa[i];
            i++;
        }else if(nx=='b'){
            nx = sb[j];
            j++;
        }else if(nx == 'c'){
            nx = sc[k];
            k++;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int d,now;
  int cnt;
  while(cin >> d){
    now = d;
    cnt = 0;
    while(now < 600){
      cnt += now * now * d;
      now += d;
    }
    cout << cnt << endl;
  }
  return(0);
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	ll n; cin >> n;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];

	vector<ll> dp(n);
	dp[0] = 1000;
	for (int i = 1; i < n; i++) {
		dp[i] = dp[i - 1];
		REP(j, i) {
			ll v = dp[j] / a[j];
			ll w = dp[j] + (a[i] - a[j]) * v;
			dp[i] = max(dp[i], w);
		}
	}

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

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

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 main(){
    ll n;
    cin >> n;
    vector<ll> a(n+5);
    vector<ll> x(n+5);
    ll sum = 0;
    rep(i,n){
        cin >> a[i+1];
        sum += a[i+1];
    }

    x[1] = sum;
    for(ll i = 2; i < n; i+=2){
        x[1] -= 2*a[i];
    }

    for(ll i = 1; i < n; i++){
        x[i+1] = 2*a[i] - x[i];
    }

    rep(i,n){
        cout << x[i+1] << " ";
    }
    cout << endl;





    return 0;
}  


Measured memory_bytes: 2944
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<algorithm>
 */
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int main() {
    string str;
    cin >> str;
    rep(i, (1 << 3)) {
        int sum = str[0] - '0';
        rep(j, 3) {
            if (i & (1 << j)) {
                sum += str[j + 1] - '0';
            } else {
                sum -= str[j + 1] - '0';
            }
        }
        if (sum == 7) {
            cout << str[0];
            rep(j, 3) {
                if (i & (1 << j)) {
                    cout << '+';
                } else {
                    cout << '-';
                }
                cout << str[j + 1] - '0';
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
    int N,X;
    cin>>N>>X;
    vector<int>L(N);
    int ans=0;
    int cnt=0;
  bool a=false;
    rep(i,N){
        cnt++;
        cin>>L[i];
        ans+=L[i];
        if(X<ans){
          cout<<cnt<<endl;
          a=true;
            break;
        }
    }
if(a==false){
  cout<<N+1<<endl;
}
}


Measured memory_bytes: 3632
#include<stdio.h>


int main(void)
{
    int a,b,k,i;
    scanf("%d%d%d",&a,&b,&k);
    for(i=a;i<=b;i++){
        if((i<(a+k))||((b-k)<i)) printf("%d\n",i);
    }   
    return 0;
}



Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int mod = 1e9 + 7;
ll fpow(ll x, ll p) {
	if (!p)
		return 1;
	ll sq = fpow(x, p / 2);
	sq *= sq;
	sq %= mod;
	if (p & 1)
		sq *= x;
	return sq % mod;
}

const int N = 1e5 + 9;
ll arr[N];
int main() {
//	file();
	fast();
	int n, k; cin >> n >> k;
	ll ans = 0;
	for (int i = k; i >= 1; i--) {
		arr[i] = fpow(k / i, n);
		for (int j = i + i; j <= k; j += i)
			arr[i] = (arr[i] - arr[j] + mod) % mod;
		ans += ((arr[i] * i) % mod);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int c_to_i(char c) {
    switch(c) {
        case 'S':return 0;
        case 'H':return 1;
        case 'C':return 2;
        case 'D':return 3;
    }
    return -1;
}

char i_to_c(int i) {
    switch(i) {
        case 0:return 'S';
        case 1:return 'H';
        case 2:return 'C';
        case 3:return 'D';
    }
    return 'A';
}

int n;

bool cs[4][13];

int main(){
	cin.tie(0);
	
	cin>>n;
	char c;
	int m;
	rep(i, n) {
	    cin>>c>>m;
	    cs[c_to_i(c)][m-1] = true;
	}
	
	rep(i, 4) {
	    rep(j, 13) {
	        if(!cs[i][j]) {
	            cout<<i_to_c(i)<<' '<<j+1<<endl;
	        }
	    }
	}

	return 0;
}



Measured memory_bytes: 3064
#include <iostream>

using namespace std;


long long int f_count(long long int n, long long int x){

    long long int count;

    if(n >= 0)
        count = n/x + 1;
    else
        count = 0;

    return count;
}


int main(){
    long long int a, b, x;
    cin >> a >> b >> x;

    long long int count;

    count = f_count(b, x) - f_count(a-1, x);

    cout << count << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define ll long long
using namespace std;

int main(void){
    int n, k, x, y;
    cin >> n;
    cin >> k;
    cin >> x;
    cin >> y;
    if(n>=k){
        cout << k*x+(n-k)*y << endl;
    }else{
        cout << n*x << endl;
    }
    

    
    return 0;
}

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

int main()
{
	double x1, x2, y1, y2;
	double ans, ex, ey;

	cin >> x1 >> y1 >> x2 >> y2;

	ex = pow(x1 - x2, 2);
	ey = pow(y1 - y2, 2);
	ans = sqrt(ex + ey);

	cout << setprecision(10) << ans << endl;

	return 0;
}




Measured memory_bytes: 3288
package main

import (
	"fmt"
	"sort"
)

type Student struct {
	No  int
	Pos int
}
type Students []Student

func (s Students) Len() int           { return len(s) }
func (s Students) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s Students) Less(i, j int) bool { return s[i].Pos < s[j].Pos }

func main() {
	var N, w int
	fmt.Scan(&N)
	var a Students
	for i := 0; i < N; i++ {
		fmt.Scan(&w)
		a = append(a, Student{No: i + 1, Pos: w})
	}
	sort.Sort(Students(a))
	fmt.Printf("%d", a[0].No)
	for i := 1; i < N; i++ {
		fmt.Printf(" %d", a[i].No)
	}
	fmt.Println("")
}


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

pair<int,int> arr[100050];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d", &arr[i].first);
        arr[i].second = i;
    }
    sort(arr + 1, arr + 1 + n);
    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(abs(arr[i].second - i) & 1)
            ++ans;
    }
    printf("%d\n", ans >> 1);
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
        #define int long long
        //#define endl '\n'
        #define modulo 1000000007
        ///I am the backupguy!
        using namespace std;
        int32_t main()
        {
        iostream::sync_with_stdio(0);
        cin.tie(0);
        int n,m;
        cin>>n>>m;
        m+=(n*3);
        cout<<m/2;
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









ll a,b,c,d,e,f,rw,rs,w,w2,s;





void solve()
{
	cin>>a>>b>>c>>d>>e>>f;
	rw=0;
	rs=0;
	for(int i=0;i*a*100<=f;i++)
	{
		for(int j=0;j*b*100<=f;j++)
		{
			w2=(i*a)+(j*b);
			w=w2*100;
			if(w>f)break;
			for(int x=0;x*c<=w2*e;x++)
			{
				for(int y=0;y*d<=w2*e;y++)
				{
					s=min((x*c)+(y*d),f-w);
					if(s>w2*e)break;
					if((rs==0&&rw==0)||s*(rw+rs)>=rs*(w+s))
					{
						rs=s;
						rw=w;
					}
				}
			}
		}
	}
	cout<<rw+rs<<" "<<rs<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL_PROJECT
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int line[3];
    for(int &i:line)cin >> i;
    sort(line, line+3);
    cout << line[0] + line[1] << endl;
    return 0;
}



Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main()
{
	int n, b[512], f[512], r[512], v[512];
	int j[4][3][10] = { 0 };
	int a=0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> b[i] >> f[i] >> r[i] >> v[i];
	}
	for (int i = 0; i < n; i++){
		j[b[i]-1][f[i]-1][r[i]-1]+=v[i];
	}
	for (int i = 0; i < 4; i++){
		if (a)cout << "####################" << endl;
		for (int n = 0; n < 3; n++){
			for (int k = 0; k < 10; k++){
				cout<<" "<<j[i][n][k];
			}
			cout << endl;
			a = 1;
		}
	}
	return 0;
}

Measured memory_bytes: 3104
import fractions

def main():
    n = int(input())
    a = list(map(int, input().split()))

    i = 1
    for ai in a:
        if i == ai:
            i += 1

    if i == 1:
        print(-1)
    else:
        print(n-i+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28552
//55
#include<iostream>

using namespace std;

int main(){
  for(int w,h;cin>>w>>h,w|h;){
    int c[21]={};
    int s=0;
    while(w--){
      int h;
      cin>>h;
      c[h]++;
      s+=h;
    }
    while(h--){
      int hh;
      cin>>hh;
      if(c[hh]>0){
	c[hh]--;
      }else{
	s+=hh;
      }
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    int r;

    cin >> r;

    ll a = sqr(r);
    
    cout << a << endl;
    
    return 0;
}

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

int main() {
  
  int D,T,S;
  cin >> D >> T >> S;
  
  if(D / S < T){
  	cout << "Yes" <<endl;
  }
  
  else if( D / S == T ){
    if ( D % S == 0){
  		cout << "Yes" << endl;
    }
  	else{
    	cout << "No" << endl;
    }
  }
  
  else{
  	cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
using Graph = vector<vector<int>>;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

vector<bool> seen;
void dfs(const Graph &G, int v, int a, int b) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        if ((v == a && next_v == b) || (v == b && next_v == a)) continue;
        dfs(G, next_v, a, b);
    }
}
int main() {
    int N, M; cin >> N >> M;

    Graph G(N+1);
    vector<pair<int,int>> ab;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
        ab.emplace_back(a,b);
    }
    int res = M;
    repp(i, 0, M) {
        seen.assign(N+1, false);
        dfs(G, 1, ab[i].first, ab[i].second);
        bool notBridge = true;
        repp(j, 1, N+1) notBridge &= seen[j];
        if (notBridge) --res;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int a , b;
	
	cin >> a >> b;
	
	cout << (3*a + b)/2;
}

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


Measured memory_bytes: 3624
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    long a = in.nextLong();
    long b = in.nextLong();
    long k = in.nextLong();

    long t = a;
    a = Math.max(a - k, 0);
    k -= t - a;

    b = Math.max(b - k, 0);

    out.println(a + " " + b);

    out.close();
  }

  static class InputReader {

    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}

Measured memory_bytes: 21076
import java.util.Random;
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static Random rand=new Random();
		public static void main(String[] args) {
			int di[]=new int[6];
			for(int i=0;i<6;i++) di[i]=scan.nextInt();
			int di2[]=new int[6];
			for(int i=0;i<6;i++) di2[i]=scan.nextInt();
			for(int i=0;i<10000;i++) {
				int a=rand.nextInt(4);
				char ch=' ';
				switch(a) {
				case 0:ch='E';break;
				case 1:ch='W';break;
				case 2:ch='N';break;
				case 3:ch='S';break;
				}
				di2=dice(di2,ch);
				boolean b=true;
				for(int j=0;j<6;j++) {
					if(di[j]!=di2[j]) {b=false;}
				}
				if(b) {
					System.out.println("Yes");return;
				}
			}
			System.out.println("No");
		}
		public static int[] dice(int d[],char ch) {
			int d1=d[0];//上
			int d2=d[1];//前
			int d3=d[2];//右
			int d4=d[3];//左
			int d5=d[4];//奥
			int d6=d[5];//下
			int a[]=new int[6];
			switch(ch) {
			case'S':
				a[0]=d5;
				a[1]=d1;
				a[2]=d3;
				a[3]=d4;
				a[4]=d6;
				a[5]=d2;
				break;
			case'W':
				a[0]=d3;
				a[1]=d2;
				a[2]=d6;
				a[3]=d1;
				a[4]=d5;
				a[5]=d4;
				break;
			case'E':
				a[0]=d4;
				a[1]=d2;
				a[2]=d1;
				a[3]=d6;
				a[4]=d5;
				a[5]=d3;
				break;
			case'N':
				a[0]=d2;
				a[1]=d6;
				a[2]=d3;
				a[3]=d4;
				a[4]=d1;
				a[5]=d5;
				break;
			
			}
			return a;
		}
}


Measured memory_bytes: 27504
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
# define MOD 1000000000+7
# define INF 1000000000
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n = 0;
	int h[100] = {};
	int ans = 0,maxi = 0;
	cin >> n;
	rep(i, n) {
		cin >> h[i];
	}
	rep(i, n) {

		if (h[i] >= maxi) {
			ans++;
			maxi = max(maxi, h[i]);
		}


	}

	cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt(),m=sc.nextInt();
		
		Pair[] a=new Pair[n],b=new Pair[m];
		
		
		for(int i=0;i<n;i++)
		{
			a[i]=new Pair(sc.nextInt(),sc.nextInt());
		}
		
		for(int i=0;i<m;i++)
		{
			b[i]=new Pair(sc.nextInt(),sc.nextInt());
			
		}
		
		for(int i=0;i<n;i++)
		{
			long min=Long.MAX_VALUE;int res=-1;
			
			
			for(int j=0;j<m;j++)
			{
				long curr=Math.abs(a[i].x-b[j].x)+Math.abs(a[i].y-b[j].y);
				
				if(curr<min)
				{
					min=curr;res=j;
				}
			}
			
			out.println(res+1);
		}
		
		out.close();
    }
}
class Pair
{
	int x,y;
	public Pair(int x,int y)
	{
		this.x=x;this.y=y;
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 22868
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	vector<i64> V(5);
	for (auto& v : V)
	{
		cin >> v;
	}

	i64 last_idx = 0;
	i64 min_mod = 200;
	REP(i, 5)
	{
		i64 mod = V[i] % 10;
		if (mod > 0 && mod < min_mod)
		{
			last_idx = i;
			min_mod = mod;
		}
	}

	i64 ans = 0;
	REP(i, 5)
	{
		if (i == last_idx)
		{
			ans += V[i];
		}
		else
		{
			i64 mod = V[i] % 10;
			if (mod == 0)
			{
				ans += V[i];
			}
			else
			{
				ans += V[i] / 10 * 10 + 10;
			}
		}
	}

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


Measured memory_bytes: 256
def parse_stdin(input_lines: int):
    data_list = []
    for i in range(input_lines):
        data_list.append(input().rstrip())
    return data_list


def find_max_interest(rates):
    min_value = rates[0]
    max_interest = -20000000000
    for i, rate in enumerate(rates[1:]):
        max_interest = max(max_interest, rate - min_value)
        min_value = min(min_value, rate)
    return max_interest


def main():
    input_lists = parse_stdin(int(input()))
    rates = list(map(int, input_lists))
    print(find_max_interest(rates))


if __name__ == '__main__':
    main()



Measured memory_bytes: 29272
S = input()
Q = int(input())
que = [0]*Q
count = 0
flag = True
flist = []
llist = []

for i in range(Q):
    que[i] = list(map(str, input().split()))
for i in que:
    if len(i) == 1:
        count += 1
        flag = not flag
    else:
        if i[1] == '1' and flag:
            flist.append(i[2])
        elif i[1] == '2' and not flag:
            flist.append(i[2])
        elif i[1] == '1' and not flag:
            llist.append(i[2])
        else:
            llist.append(i[2])

F = ''.join(flist)
L = ''.join(llist)

if count % 2 == 1:
    S = S[::-1]
    L = L[::-1]
    print(L + S + F)
else:
    F = F[::-1]
    print(F + S + L)

Measured memory_bytes: 107088
n=int(input())
w=list(map(int,input().split()))
s=[0]*n
for i in range(n-1):
  s[i+1]=s[i]+w[i]
ans=sum(w)
for i in range(1,n):
  ans=min(ans,abs((sum(w)-s[i])-s[i]))
print(ans)

Measured memory_bytes: 9164
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    int ans = 0;
    REP(i, n){
        cin >> x[i];
    }
    REP(i, n){
        ans += 2 * min(abs(x[i]), abs(k - x[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_left

MOD = 998244353

N = int(readline())
m = map(int,read().split())
XD = sorted(zip(m,m))
X, D = zip(*XD)

class MaxSegTree():
    def __init__(self,raw_data):
        N = len(raw_data)
        self.size = 1<<(N.bit_length()) # 葉の要素数
        self.data = [0] * (2*self.size)
        self.build(raw_data)
        
    def build(self,raw_data):
        # raw_data は 0-indexed
        for i,x in enumerate(raw_data):
            self.data[self.size+i] = x
        for i in range(self.size-1,0,-1):
            x = self.data[i+i]; y = self.data[i+i+1]
            self.data[i] = x if x>y else y
    
    def update(self,i,x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i+i]; y = self.data[i+i+1]
            self.data[i] = x if x>y else y
            i >>= 1
    
    def get_data(self,i):
        return self.data[i+self.size]

    def get_max(self,L,R):
        # [L,R] に対する値を返す
        L += self.size
        R += self.size + 1
        # [L,R) に変更
        x = 0
        while L < R:
            if L&1:
                y = self.data[L]
                if x < y: x = y
                L += 1
                
            if R&1:
                R -= 1
                y = self.data[R]
                if x < y: x = y
            L >>= 1; R >>= 1
        return x

R = [0] + [bisect_left(X, x + d) for x,d in XD]
seg = MaxSegTree(R)

S = [0] * len(R)
for n in range(N,0,-1):
    r = R[n]
    x = seg.get_max(n, r)
    S[n] = x
    seg.update(n, x)    

dp = [0] * (N+1)
dp[0] = 1
dp_cum = [1] * (N+1)
for n,r in enumerate(S[1:],1):
    dp[r] += dp_cum[n-1]
    dp[r] %= MOD
    dp_cum[n] = dp_cum[n-1] + dp[n]
    dp_cum[n] %= MOD

print(dp_cum[-1])

Measured memory_bytes: 128732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<string> split(const string& str, char delimi) {
    vector<string> elem;
    string tmp;
    for (int i = 0; i < str.length(); ++i) {
        char c = str[i];
        if (c == delimi) {
            if (!tmp.empty()) {
                elem.push_back(tmp);
            }
            tmp.clear();
        } else {
            tmp += c;
        }
    }
    if (!tmp.empty()) {
        elem.push_back(tmp);
    }
    return elem;
}
int main() {
    while(1) {
        string str;
        getline(cin, str);
        vector<string> line = split(str, ' ');
        int n = atoi(line[0].c_str());
        if (n == 0)
            break;
        int r = atoi(line[1].c_str());
        int card[n];
        for (int i = 0, num = n; i < n; ++i, --num) {
            card[i] = num;
        }
        for (int i = 0; i < r; ++i) {
            string str;
            getline(cin, str);
            vector<string> line = split(str, ' ');
            int p = atoi(line[0].c_str());
            int c = atoi(line[1].c_str());
            rotate(card, card + p - 1, card + p + c - 1);
        }
        cout << card[0] << endl;
    }
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    long long d = c - a - b;
    if (0 < d && 4 * a * b < d * d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
 
#define deb(var) "[" << (#var) << " : " << var <<"]" << " "
#define debv(v) "[" << (#v) << " : {";for(int i = 0; i < v.size() - 1; ++i)\
					cout << v[i] <<", ";cout << v.back() << "}] "
#define deba(a,n) "[" << (#a) << " : {";for(int i = 0; i < n - 1; ++i)\
					cout << a[i] << ", ";cout << a[n - 1] << "}] "
#define debp(p) "[" << (#p) << " : {" << p.first << ", " << p.second << "}] "
#define debs(s) "[" << (#s) << " : {";auto _itr = s.begin();\
					for(int k = s.size(); k > 1; --k) {cout << *_itr << ", "; ++_itr;} cout << *_itr << "}] "
#define debt(t) "[" << (#t) << " : " << "{" << get<0>(t) << ", " <<get<1>(t) << ", " << get<2>(t) << "}]"
 
typedef long long ll;
 
/*LETS BEGIN WITH THE NAME OF LORD MAHADEV*/

int main(){
	int a;
	cin >> a;
	cout << a + a * a + a * a * a  << endl;
	return 0;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
  ll a,b;
  cin>>a>>b;
  ll ans=a*b/GCD(a,b);
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

void prime_factorization(ll N, map<ll, int>& res) {
  if(N == 1 || N == 0) return;
  ll n = N;
  ll i = 2;
  while(n >= i * i) {
    while(n % i == 0) {
      if(res.count(i)) res[i]++;
      else res[i] = 1;
      n /= i;
    }
    if(i == 2) i++;
    else i += 2;
  }
  if(n != 1) res[n]++;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  map<ll, int> res;
  REP(i, 1, n+1) prime_factorization(i, res);
  ll ans = 1;
  for(auto ele: res) {
    (ans *= (ele.second + 1)) %= mod;
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
 
const int inf = 2e9;
const int N = 2e5 + 15;
int n, k, a[N], ans, last = -1, t[2][N << 1], srt[N];
vector <int> g[N];
bool used[N];

inline void build() {
    for(int i = 1; i <= n; ++i)
        for(int j = 0; j < 2; ++j)
            t[j][i + n] = a[i];
    for(int i = n; i; --i) {
        t[0][i] = min(t[0][i << 1], t[0][i << 1 | 1]);
        t[1][i] = max(t[1][i << 1], t[1][i << 1 | 1]);
    }
}
 
inline int get(int l, int r, int j) {
    int res = j ? 0 : inf;
    for(l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
        if(l & 1) {
            if(j)
                res = max(res, t[1][l++]);
            else
                res = min(res, t[0][l++]);
        }
        if(r & 1) {
            if(j)
                res = max(res, t[1][--r]);
            else
                res = min(res, t[0][--r]);
        }
    }
    return res;
}

void dfs(int v) {
    used[v] = true;
    for(int to : g[v])
        if(!used[to])
            dfs(to);
}


main() {
    for(int i = 0; i < N; ++i)
        srt[i] = 1;
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        if(a[i] > a[i-1])
            srt[i] = srt[i-1] + 1;
    }
    build();
    for(int i = 1; i <= n - k; ++i)
        if(get(i, i + k, 0) == a[i] && get(i, i + k, 1) == a[i + k])
            g[i].pb(i + 1), g[i + 1].pb(i);
    for(int i = 1; i <= n - k + 1; ++i) {
        if(srt[i + k - 1] >= k) {
            if(last != -1)
                g[i].pb(last), g[last].pb(i);
            last = i;
        }
    }
    for(int i = 1; i <= n - k + 1; ++i)
        if(!used[i])
            dfs(i), ++ans;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 22272
i = gets.chomp.to_i
p = gets.split(" ")
q = gets.split(" ")
ans = 0
p.each_with_index{|item,n|
 if item.to_i - q[n].to_i > 0 then
   ans = ans + item.to_i - q[n].to_i
 end
   }
  print ans
  



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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		string s;
		cin >> n >> s;
		if(n%2 != 0){
			cout << "No" << endl;
			return;
		}
		for(int i=0; i < n/2; i++){
			if(s[i] != s[i+n/2]){
				cout << "No" << endl;
				return;
			}
		}
		cout << "Yes" << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

using namespace std;

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

    string s;
    cin >> s;

    for (char &c : s)
        if (c == '?')
            c = 'D';

    cout << s;
}


Measured memory_bytes: 3744
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ").map(e => Number(e)).sort();
    console.log(input[0] === 1 && input[1] === 4 && input[2] === 7 && input[3] === 9 ? 'YES' : 'NO');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372