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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    int N; cin >> N;

    string S;
    cin >> S;

    vector<vector<int>> dp(5005, vector<int>(5005, 0));

    for(int i = N-1; i >= 0; i--){
        for(int j = N-1; j >= 0; j--){
            if(S[i] != S[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1] + 1;
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i >= j) continue;
            int val = min(dp[i][j],j-i);
            ans = max(ans, val);
        }
    }
    
    cout << ans << endl;

    return 0;
}


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

vector<int> bipartite(vector<pair<int,int>> edge){
    int M = edge.size();
    if(M==0)return {};
    int N = 0;
    for(int i=0;i<M;i++){
        N=max(N,edge[i].first+1);
        N=max(N,edge[i].second+1);
    }
    vector<int> R(N,-1);
    vector<int> S(0);
    vector<vector<int>> es(N,vector<int>(0));
    for(int i=0;i<M;i++){
        es[edge[i].first].push_back(edge[i].second);
        es[edge[i].second].push_back(edge[i].first);
    }
    //cout << N << " " << M << endl;
    //REP(i,N){REP(j,es[i].size()){cout << es[i][j]+1 << " ";}cout << endl;}
    queue<int> Q;
    vector<bool> visited(N,false);
    for(int j=0;j<N;j++){
        if(visited[j])continue;
        Q.push(j);
        R[j]=0;
        visited[j]=true;
        while(!Q.empty()){
            int q=Q.front();
            Q.pop();
            visited[q]=true;
            for(int i=0;i<es[q].size();i++){
                if(R[es[q][i]]==R[q]){
                    return S;
                }
                if(visited[es[q][i]])continue;
                Q.push(es[q][i]);
                R[es[q][i]]=1-R[q];
            }
            
        }
    }
    return R;
}

signed main(void){
    long long N,M;
    int a,b;
    vector<int> A,B;
    cin >> N >> M;
    REP(i,M){
        cin >> a >> b;
        a--;b--;
        A.push_back(a);
        B.push_back(b);
    }
    vector<pair<int,int>> AB;
    REP(i,M){
        AB.push_back({A[i],B[i]});
        //cout << A[i] MM B[i] << endl;
    }
    
    vector<int> d=bipartite(AB);
    //vector<int> d(N,1);
    if(d.size()==0){
        cout << N*(N-1)/2 - M << endl;
        return 0;
    }
    //REP(i,N){cout << d[i] << " ";}cout << endl;
    long long x=0,y=0;
    REP(i,N){
        if(d[i]){
            x++;
        }else{
            y++;
        }
    }
    cout << x*y - M << endl;
    return 0;
}



Measured memory_bytes: 9072
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 200000 + 10;
int a[MAXN], b[MAXN],dp[MAXN];

int solve (int s, int n) {
    int base = 1<<(s+1);
    for (int i = 0; i < n; i++) {
        dp[i] = b[i] % base;
    }
    sort(dp, dp+n);
    int ret = 0, val, x, y, cnt = 0;
    for (int i = 0; i < n; i++) {
        val = a[i] % base;
        x = max(0, (1<<s) - val);
        y = base - 1 - val;
        if (x <= y) {
            cnt += upper_bound(dp, dp+n, y) - lower_bound(dp, dp+n, x);
        }
        x = (base+(1<<s)) - val;
        y = (1<<(s+2))-1 - val;
        if (x <= y) {
            cnt += upper_bound(dp, dp+n, y) - lower_bound(dp, dp+n, x);
        }
        cnt = cnt % 2;
    }
    if (cnt % 2 == 1) ret = 1<<s;
    return ret;
}


int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    int ret = 0;
    for (int i = 0; i <= 29; i++) {
        ret ^= solve (i, n);
    }
    cout << ret << endl;

}

Measured memory_bytes: 2560
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++){
			x[i] = scan.nextInt();
		}
		for(int i = 0; i < n; i++){
			y[i] = scan.nextInt();
		}

		double d1 = 0;
		double sum2 = 0;
		double sum3 = 0;
		double dd = 0;
		for(int i = 0; i < n; i++){
			d1 += Math.abs(x[i] - y[i]);
			sum2 += Math.pow(Math.abs(x[i] - y[i]), 2);
			sum3 += Math.pow(Math.abs(x[i] - y[i]), 3);
			dd = Math.max(dd, Math.abs(x[i] - y[i]));
		}
		double d2 = Math.sqrt(sum2);
		double d3 = Math.cbrt(sum3);
		System.out.printf("%f\n", d1);
		System.out.printf("%f\n", d2);
		System.out.printf("%f\n", d3);
		System.out.printf("%f\n", dd);
	}
}

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

int main() {
  int x;
  cin >> x;
  int y = x;
  int k = 1;
  while (y != 0) {
    y += x;
    y %= 360;
    k++;
  }

  cout << k << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

ll f(ll a,ll b,ll x)
{
    a+=(x-(a%x))%x;
    if(b<a) return 0;
    return (b-a+1+x-1)/x;
}

int main()
{
    long long a,b,c,d,cnt,t1,t2;

    cin>>a>>b>>c>>d;

    cout << b-a+1 -f(a,b,c)-f(a,b,d)+f(a,b,(c*d)/(__gcd(c,d))) <<endl;

    return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int N;
  cin >> N;
  Vi H(N);
  rep(i,N){
    cin >> H[i];
  }
  
  
  Vi dp(N, 1000000000);
  dp[0]=0;
  
  rep2(i, 1, N){
    
    if(dp[i]>dp[i-1]+abs(H[i]-H[i-1])){
      dp[i] = dp[i-1]+abs(H[i]-H[i-1]);
    }
    if(i>1){
      if(dp[i]>dp[i-2]+abs(H[i]-H[i-2])){
      dp[i] = dp[i-2]+abs(H[i]-H[i-2]);
      }   
    }
    
  }
  
  cout << dp[N-1] << endl;
}

      
      
       




Measured memory_bytes: 3984
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n;
	cin >> n;

	ll res = n;
	for (ll i = 0; i <= n; i++)
	{
		ll cnt = 0;
		
		for (ll j = i; j > 0; j /= 6)
		{
			cnt += j % 6;
		}

		for (ll j = n - i; j > 0; j /= 9)
		{
			cnt += j % 9;
		}

		res = min(res, cnt);
	}

	println(res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a,b) + min(c,d) << endl;
}


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

int main(){
  	int N,K;
	string S;
  cin>> N ;
  cin>> K ;
  cin>> S ;
  if(S.at(K-1) == 'A'){S.at(K-1) = 'a' ;}
  else if(S.at(K-1) == 'B'){S.at(K-1) = 'b' ;}
  else if(S.at(K-1) == 'C'){S.at(K-1) = 'c' ;}
  cout<< S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main(void){
    int n, a, b=0,c=0;
    map<int, int> m;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        if((++m[a])>=3)m[a] = 1;
    }
    for(auto x=m.begin();x!=m.end();x++){
        if((x->second)==2){
            b++;
        }else{
            c+=(x->second);
        }
    }
    cout << c + b - b%2 << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<double, double>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   P P1, P2;
   cin >> P1.first >> P1.second >> P2.first >> P2.second;
   double dist2 = (P1.first - P2.first) * (P1.first - P2.first) +
                  (P1.second - P2.second) * (P1.second - P2.second);
   printf("%0.5f\n", sqrt(dist2));
   return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }

  int ans = 0;
  if (k < 1e7) {
    for (int i = 0; i < k; i++) {
      ans = a[ans];
    }
    cout << ans + 1<< endl;
    return 0;
  }

  vector<int> v(n, -1);
  v[0] = 0;
  ll x, y;
  int cur = 0;
  rep(i, n) {
    cur = a[cur];
    if (v[cur] == -1) v[cur] = i+1;
    else {
      ans = cur;
      x = v[cur];
      y = i + 1;
      break;
    }
  }

  k -= x;
  k %= (y - x);

  for (int i = 0; i < k; i++) {
    ans = a[ans];
  }

  cout << ans + 1 << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int N, M;
bool G[10][10];
ll ans = 0;
vector<int> path;

void check() {
    if (path[0] != 0) return;
    rep(i, path.size() - 1) if (!G[path[i]][path[i + 1]]) return;
    ans++;
}


int main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a][b] = true;
        G[b][a] = true;
    }
    rep(i, N) path.push_back(i);
    do {
        check();
    } while (next_permutation(path.begin(), path.end()));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


struct city{
    string name;
    int point;
    int number;
};


bool cmp(const city &a, const city &b){
    if(a.name != b.name){
        return a.name < b.name;
    }
    return a.point > b.point;
    
}

int main(){

    int n;
    cin >> n;

    vector< city > v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i].name;
        cin >> v[i].point;
        v[i].number = i + 1;
    }
    sort(all(v), cmp);
    for(int i = 0; i < n; i++) cout << v[i].number << endl;
}

Measured memory_bytes: 256
import math

N, M = map(int, input().split())
X = list(map(int, input().split()))
mod_arr = [{} for i in range(M)]
for x in X:
    d = mod_arr[x % M]
    if x in d:
        d[x] += 1
    else:
        d[x] = 1
ans = 0

if M == 1:
    print(N // 2)
    exit()

def calc_only_one(d):
    sum_v = sum(d.values())
    return sum_v // 2

ans += calc_only_one(mod_arr[0])
# even pattern
if M % 2 == 0:
    ans += calc_only_one(mod_arr[M // 2])

def calc_two(d_S, d_T):
    res = 0
    if len(d_S) == 0:
        for v in d_T.values():
            res += v // 2
        return res
    elif len(d_T) == 0:
        for v in d_S.values():
            res += v // 2
        return res

    if sum(d_S.values()) < sum(d_T.values()):
        d_S, d_T = d_T, d_S
    cnt_S = sum(d_S.values())
    cnt_T = sum(d_T.values())
    remain_for_pair = cnt_S - cnt_T
    max_pair_cnt = sum([v // 2 for v in d_S.values()])
    pair_cnt = min(remain_for_pair // 2 , max_pair_cnt)
    res = cnt_T + pair_cnt
    # print(d_S, d_T)
    # print(remain_for_pair, max_pair_cnt, pair_cnt, res)
    return res


for i in range(1, math.ceil(M / 2)):
    ans += calc_two(mod_arr[i], mod_arr[M - i])
print(ans)



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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	while(true){
		string s;
		cin >> s;
		if(s == "") break;
		int is = 0, js = 0;
		REP(i, s.size()-2){
			if(s.substr(i, 3) == "JOI") js++;
			if(s.substr(i, 3) == "IOI") is++; 
		}
		cout << js << endl << is << endl;
	}
	return 0;
} 


Measured memory_bytes: 3172
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();

    let n: usize = sc.cin();
    let m: usize = sc.cin();

    let mut edges = vec![];
    for i in 0..m {
        let a: usize = sc.cin();
        let b: usize = sc.cin();
        edges.push((b, a));
    }
    edges.sort();

    let mut ans = 0;
    let mut last = 0;
    for i in 0..m {
        let (b, a) = edges[i];
        if a <= last && last <= b {
            // ok
        } else {
            last = b-1;
            // trace!(last);
            ans += 1;
        }
    }
    put!(ans);
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


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

int main() {
  
  int N, K; cin >> N >> K;
  
  int64_t maxSum = 0, indexMemo = 0; double ans = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  vector<int64_t> vecSum(N + 1, 0);
  
  for (int i = 0; i < N; i++) vecSum[i + 1] = vecSum[i] + vec[i];
  
  for (int i = 0; i <= N - K; i++) {
    
    int left = i, right = i + K;
    
    int64_t tmpSum = vecSum[right] - vecSum[left];
    
    if (maxSum < tmpSum) { maxSum = tmpSum; indexMemo = i; }
    
  }
  
  for (int i = indexMemo; i < indexMemo + K; i++) {
    
    int tmp = vec[i];
    
    ans = ans + double(tmp + 1) / 2;
    
  }
  
  cout << fixed << setprecision(10);
  
  cout << ans << endl;
  
}

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

int main(){
  int a,b;
  char s[10],t[10],u[10];

  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);

  if(strcmp(s,u) == 0) printf("%d %d\n", a - 1, b);

  else if(strcmp(t,u) == 0) printf("%d %d\n", a, b - 1);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    cin >> a >> b;
    //処理
    //出力
    if(a<=b) cout << a << ENT;
    else cout << a-1 << ENT;
    return 0;
}

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


Measured memory_bytes: 256
/* created   : 2019-11-09 20:00:47
 * accepted  : 2019-11-09 20:03:38
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  unordered_set<int> st;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (st.count(n - i)) {
      ans++;
    }
    st.insert(i);
  }
  cout << ans << '\n';
}

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


Measured memory_bytes: 39824
#include <bits/stdc++.h>
#define lol long long
using namespace std;
signed main(){
  string s,t;
  int n,ans=0,co;
  cin>>n>>co;
  while(n>0){
    n/=co;
    ans++;
  }
  cout<<ans<<"\n";
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
//=============================
void input()
{
    cin>>S;
    cin>>K;
}
//=============================
void func(){}
/*
//  - 樹形図をかく
// */

// void rec(string s, int k, int ind){
//     if (ind == s.size()-1){
//         k %= 26;
//         s[ind] = ((s[ind] - 'a') + k )%26 + 'a';
//         ans = s;
//         return;
//     }
//     else if (s[ind] != 'a'){
//         int aa = 'z' + 1 - s[ind];
//         if (aa <= k) {
//             s[ind] = 'a';
//             rec(s,k-aa,ind+1);
//         }
//         else {
//             rec(s,k,ind+1);
//         }
//     }
//     else {
//         rec(s,k,ind+1);
//     }

// }
//=============================
void solve()
{
    int ind = 0;
    string s = S;
    string ans = S;
    int N = s.size();
    for( ; ind < N ; ++ind){
        if (ind == N-1) {
            K %= 26;
            ans[ind] =  ((S[ind] - 'a') + K)%26 + 'a';
        }
        else {
            if (S[ind] == 'a') continue;
            else {
                int aa = 'z'+1-S[ind];
                if (K >= aa) {
                    ans[ind] = 'a';
                    K -= aa;
                }
                else continue;
            }
        }
    }

    cout<<ans<<endl;


}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 640
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int a,b,c,d;
	cin>>a>>b>>c>>d; 
	int now=1;
	while(1){
		if(now&1){
			c-=b;
			if(c<=0){
				
				cout<<"Yes"<<endl;;
				return 0;
			}
		}
		else{
			a-=d;
			if(a<=0){
				cout<<"No"<<endl;;
				return 0;
			}
		}
		now++;
	} 
	
	return 0;
}


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

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

    int N; cin >> N;
    string s; cin >> s;
    ll R=0;
    ll G=0;
    ll B=0;
    for(int i=0;i<N;i++){
        if(s[i]=='R'){
            R++;
        }
        if(s[i]=='G'){
            G++;
        }
        if(s[i]=='B'){
            B++;
        }
    }
    ll ans = R*G*B;


    for(int i=0;i<N;i++){
        for(int k=i+2;k<N;k+=2){
            int j = (i+k)/2;
            if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]){
                ans--;
            }
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define M 200005
int fir,sec;
int A[M],n;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",A+i);
		if(A[i]>=fir) {
			sec=fir;
			fir=A[i];
		} else if(A[i]>sec)sec=A[i];
	}
	for(int i=1; i<=n; i++)
		printf("%d\n",A[i]==fir?sec:fir);
}



Measured memory_bytes: 2432
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
A = list(accumulate(A))
answer = abs((A[-1] - A[0]) - A[0])
for i in range(N - 1):
    L = A[-1] - A[i]
    K = abs(L - A[i])
    if K < answer:
        answer = K


print(answer)


Measured memory_bytes: 24168
#include<iostream>
using namespace std;
int N;
struct mu {int aite; int order;} A[1001][1000];
int f[1001];
int x[1001];
int dmax;

int match(int, int);

int main()
{
	int day;
	int i,j,k;
    // 整数の入力
    cin >> N;
	for (i=1; i<=N; i++) {
		for (j=1; j<N; j++) {
			cin >> A[i][j].aite;
			f[i] = 1;
			x[i] = 0;
		}
	}
	for (i=1; i<=N; i++) {
		for (j=1; j<N; j++) {
			for (k=1; k<N; k++) {
				if (A[A[i][j].aite][k].aite != i) continue;
				A[i][j].order = k;
				break;
			}
		}
	}

	int fin=1;
	for (day=1; ; day++) {
		for (i=1; i<=N; i++) {
#ifdef DEBUG
printf("f[%d]=%d\n", i, f[i]);
#endif
			int ax;
			if (f[i]>=N) continue;
			ax = A[i][f[i]].aite;
			x[i] = f[i];
			if (A[i][f[i]].order == f[ax]) { //対戦相手が試合可能な状態
				x[i]++;
#ifdef DEBUG
printf("%d [%d-%d]\n", day, i, ax);
#endif
			}
		}
		fin = 0;
		for (i=1; i<=N; i++) {
			if (f[i] != x[i]) {
				f[i] = x[i];
				if (f[i] < N) fin = 1;
			}
		}
		if (fin) continue;
		break;
	}
	for (i=1; i<=N; i++)
		if (f[i] != N) {
			day = -1;
			break;
		}

    // 出力
    cout << day << endl;
    return 0;
}


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

int main(){
	char ch;
	while(1){
		scanf("%c",&ch);
		if(islower(ch))cout<<(char)toupper(ch);
		else if(isupper(ch))cout<<(char)tolower(ch);
		else if(ch=='\n')break;
		else  cout<<ch;
	}
	cout<<endl;
}



Measured memory_bytes: 3144
n = int(input())
v = list(map(int, input().split()))

even_dict = {}
odd_dict = {}
for i, value in enumerate(v):
    if i % 2:
        even_dict[value] = 1 if value not in even_dict else even_dict[value] + 1
    else:
        odd_dict[value] = 1 if value not in odd_dict else odd_dict[value] + 1

counter = 0
even = sorted(even_dict.items(), key=lambda x: x[1], reverse=True)
odd = sorted(odd_dict.items(), key=lambda x: x[1], reverse=True)

if even[0][0] == odd[0][0]:
    even_second = 0 if len(even) < 2 else even[1][1]
    odd_second = 0 if len(odd) < 2 else odd[1][1]
    if even[0][1] - even_second > odd[0][1] - odd_second:
        counter += sum([x[1] for x in even[1:]])
        counter += sum([x[1] for x in odd[2:] + [odd[0]]])
    else:
        counter += sum([x[1] for x in odd[1:]])
        counter += sum([x[1] for x in even[2:] + [even[0]]])
else:
    counter += sum([x[1] for x in even[1:]])
    counter += sum([x[1] for x in odd[1:]])

print(counter)

Measured memory_bytes: 21792
import numpy as np
n,m=map(lambda x: int(x), input().split())
start=[]
end=[]
for i in range(m):
    a,b=map(lambda x: int(x), input().split())
    start.append(a)
    end.append(b)
start=np.array(start)
end=np.array(end)
ans=0
while len(start):
    ans+=1
    idx1=(end==end.min()) ## 終点が最小
    idx2=(start<end.min()) ## idx1で分断される組み合わせ
    idx3=np.logical_or(idx1, idx2)
    idx4=np.logical_not(idx3) ## 残る組み合わせ
    start=start[idx4]
    end=end[idx4]
print(ans)

Measured memory_bytes: 20840
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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


Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <string>

int n, m, k, q;
int main() { 
	int T = 1; //rd(T);
	while(T--) {
		std::string s, t; std::cin >> s >> t;
		bool flag = false;
		for(int i = 0; i < 26; ++i) if(s + (char)(i + 'a') == t) flag = true;
		printf(flag ? "Yes" : "No");
	} return 0;
}

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

int main(){
	int n,m;	cin>>n>>m;
	char a[n][n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)cin>>a[i][j];
	}

	char b[m][m];
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++)cin>>b[i][j];
	}

//	for(int i=0;i<n;i++){
//		for(int j=0;j<n;j++)cout<<a[i][j];
//		cout<<endl;
//	}
//	
//	for(int i=0;i<m;i++){
//		for(int j=0;j<m;j++)cout<<b[i][j];
//		cout<<endl;
//	}

	string ans;
	for(int y=0;y<=n-m;y++){
		for(int x=0;x<=n-m;x++){
			// この二重ループで検索エリアの始点（左上）をセット

			ans="Yes";

			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(a[y+i][x+j]!=b[i][j]){
						ans="No";
					}
				}
			}

			if(ans=="Yes")break;
		}
		if(ans=="Yes")break;
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdbool.h>

int main(){
	bool fumiyasui = true;
	char S[100];
	scanf("%s",S);
	int N = strlen(S);
	for(int i=0;i<N;i+=2){
		if (S[i]=='R' || S[i]=='U' || S[i]=='D'){
			continue;
		}else {
			fumiyasui = false;
			break;
		}
	}
	if (fumiyasui == true){
		for(int i=1;i<N;i+=2){
			if (S[i]=='L' || S[i]=='U' || S[i]=='D'){
				continue;
				}else {
					fumiyasui = false;
					break;
					}
		}
	}
	if (fumiyasui == true){
		printf("Yes\n");
	}else {
		printf("No\n");
	}
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c=-1;
  string s,t;
  cin >>a>>b;
  if(a<10&&b<10)c=a*b;
  cout <<c;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    char[]n = N.toCharArray();
    
    int cou = 0;
    for(int i=0; i<3; i++){
      if(n[i]=='7'){
        cou++;
      }
    }
    if(cou>0){
    System.out.println("Yes");
      }else{
	System.out.println("No");
      }
      }
}

Measured memory_bytes: 35252
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    }
}


Measured memory_bytes: 26284
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
using data=pair<ll,ll>;

int main(){
  ll i,N,M,Q,l,r,bfl=-1,bfr,ans;
  cin>>N>>M>>Q;
  mat v(N,vec(N,0));
  vector<data> list(M);
  rep(i,M){
    cin>>l>>r;
    list[i]=data(l-1,r-1);
  }
  vsort(list);

  bfr=N;
  rep(i,M){
    l=list[i].first;r=list[i].second;
    if(bfl==l){
      if(bfr==r){
        v[l][r]++;
      }else{
        while(bfr<r){bfr++;v[l][bfr]=v[l][bfr-1];}
        v[l][r]++;
      }
    }else{
      while(bfr<N-1){bfr++;v[bfl][bfr]=v[bfl][bfr-1];}
      v[l][r]++;
      bfl=l;
      bfr=r;
    }
  }
  while(bfr<N-1){bfr++;v[bfl][bfr]=v[bfl][bfr-1];}
  while(Q--){
    cin>>l>>r;
    l--;r--;
    ans=0;
    For(i,l,r+1){
      ans+=v[i][r];
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 6016
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2


def generate_adj_table(v_table):
    for each in v_table:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        # assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_table[v_index].setdefault(pair[0], pair[1])

    return init_adj_table


def dijkstra_path_heap():
    # path search init
    distance[root] = 0
    path_heap = []
    # heapq: rank by tuple[0], at here it's d[u]
    hp.heappush(path_heap, (0, root))

    while path_heap:
        current = hp.heappop(path_heap)[1]

        color[current] = BLACK

        for adj, cost in adj_table[current].items():
            if color[adj] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = distance[current] + cost
                if alt_path < distance[adj]:
                    # update path_list
                    distance[adj] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj))
                    color[adj] = GRAY
                    parents[adj] = current

    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices = int(_input[0])
    v_info = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    distance = [float('inf')] * vertices
    parents = [-1] * vertices
    color = [WHITE] * vertices
    init_adj_table = tuple(dict() for _ in range(vertices))
    root = 0

    adj_table = generate_adj_table(v_info)
    ans = dijkstra_path_heap()
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 63004
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n,0),d(n,0);
  vector<vector<int>> c(n,vector<int>(0));
  rep(i,n-1){
    cin >> a[i+1];
    a[i+1]--;
    b[a[i+1]]++;
  }
  queue<int> q;
  rep(i,n){
    if (b[i]==0) q.push(i);
  }
  while(!q.empty()){
    int f=q.front();
    q.pop();
    sort(all(c[f]));
    reverse(all(c[f]));
    rep(i,c[f].size()){
      d[f]=max(d[f],c[f][i]+i+1);
    }
    if (f==0) break;
    c[a[f]].push_back(d[f]);
    b[a[f]]--;
    // cout << f << " " << d[f] << endl;
    if (b[a[f]]==0) q.push(a[f]);
  }
  cout << d[0] << endl;
}


Measured memory_bytes: 6912
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
	
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	int n, m; 
	cin >> n >> m;
	int res = (n-1) * (m-1);
	cout << res << endl;
	
	return 0;	
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(std::string C)
{
    char c = C[0];
    cout << (char)(c + 1) << endl;
}

int main()
{
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<ll>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

//ll fmul(ll a, ll b, ll mod){ll res=0;while(a){if(a&1)res=(res+b)%mod;a>>=1;b=(b<<1)%mod;}return res;}
//ll fpowfast(ll b, ll exp, ll mod){ll res=1;while(exp){if(exp&1)res=fmul(res,b,mod);b=fmul(b,b,mod);exp>>=1;}return res;}
//inline bool rabbin_miller(ll x){if(x%2==0) return false;for(int i=0;i<5;i++){ll rd=randlong(2,x-2);if(fpowfast(rd,x-1,x)!=1)return false;}return true;}

ll A,B,res=1;

ll fmul(ll a, ll b, ll mod){
	ll res = 0;
	while(a){
		if(a&1) res = (res+b)%mod;
		a>>=1;
		b = (b<<1)%mod;
	}
	return res;
}

ll fpowfast(ll b, ll exp, ll mod){
	ll res = 1;
	while(exp){
		if(exp&1) res = fmul(res,b,mod);
		b = fmul(b,b,mod);
		exp>>=1;
	}
	return res;
}

inline bool prim(ll x){
	if(x == 2 || x == 3) return true;
	if(x%2 == 0) return false;
	for(int i=0; i<30; i++){
		ll rd = randlong(2,x-2);
		if(fpowfast(rd,x-1,x) != 1)
			return false;
	}
	return true;
}

//inline bool prim(ull x){
//	if(x == 2) return true;
//	ull lim = sqrt(x);
//	while(lim*lim < x) lim++;
//	while(lim*lim > x) lim--;
//	for(ull k=2; k<=lim; k++){
//		if(x%k == 0) return false;
//	}
//	return true;
//}

int main(){
	scanf("%lld %lld",&A,&B);
	ll gg = __gcd(A,B);
	ll lim = sqrt(gg);
	while(lim*lim < gg) lim++;
	while(lim*lim > gg) lim--;
	for(ll i=2; i<=lim; i++){
		if(gg%i == 0){
			if(prim(i))
				res++;
			if(i*i != gg && prim(gg/i))
				res++;
		}
	}
	if(prim(gg) && gg != 1) res++;
	printf("%lld\n",res);
}

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

int main() {
    int n, W;
    cin >> n >> W;
    vector<ll> price(n), weight(n);
    for(int i = 0; i < n; ++i)
        cin >> weight[i] >> price[i];
    vector<ll> dp(100000 + 1, numeric_limits<int>::max());
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int val = dp.size() - 1; val >= price[i]; --val) {
                dp[val] = min(dp[val], weight[i] + dp[val - price[i]]);
        }
    }
    for(int i = dp.size() - 1; i >= 0; --i)
        if(dp[i] <= W) {
            cout << i;
            break;
        }
    // cout << "lol";
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000

int main()
{
        int N;
        int sum;
        int l[MAX];
        int r[MAX];
        int i;

        scanf("%d", &N);
        sum = 0;
        for(i=0; i<N; i++)
        {
                scanf("%d %d", &l[i], &r[i]);
                sum += r[i] - l[i] + 1;
        }

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

        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    rep(i,n){
        long long from = a + c * i - d * (n - i - 1); //小さく上がって大きく下がる
        long long to = a + d * i - c * (n - i - 1);
        if(from <= b  && b <= to){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
}


Measured memory_bytes: 256
import sys

for line in sys.stdin:
  items = line.strip().split()

stack = []

for item in items:
  if item == '+' or item == '-' or item == '*':
    x = stack.pop()
    y = stack.pop()
    exp = "%s %s %s" % (y, item, x)
    stack.append(eval(exp))
  else:
    stack.append(int(item))

print stack.pop()

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

int main() {
	int w, n;
	cin >> w >> n;
	
	vector<int> v(w);
	for (int i = 0; i < w; i++) {
		v.at(i) = i + 1;
	}

	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		cin >> a >> c >> b;

		int n = v.at(a - 1);
		v.at(a - 1) = v.at(b - 1);
		v.at(b - 1) = n;
	}

	for (int i = 0; i < w; i++) {
		cout << v.at(i) << endl;
	}
}


Measured memory_bytes: 3004
#include <iostream>
#include <vector>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

void to_vec(string s, vector<int>& vec) {
	int num = 1;
	for (auto itr = s.begin(); itr != s.end(); itr++) {
		if (*itr == 'm') {
			vec[0] = num;
			num = 1;
		} else if (*itr == 'c') {
			vec[1] = num;
			num = 1;
		} else if (*itr == 'x') {
			vec[2] = num;
			num = 1;
		} else if (*itr == 'i') {
			vec[3] = num;
			num = 1;
		} else {
			num = (*itr) - '0';
		}
	}
}

vector<int> sum(vector<int>& left,vector<int>& right) {
	vector<int> res(4, 0);
	bool over = false;
	int num;
	for (int i = 3; i >= 0; i--) {
		num = left[i] + right[i];
		if (over) {
			num++;
		}
		if (num > 9) {
			over = true;
			num -= 10;
			res[i] = num;
		} else {
			over = false;
			res[i] = num;
		}
	}
	return res;
}

int main(void) {
	int n;
	cin  >> n;

	for (int i = 0; i< n; i++) {
		string left, right;
		cin >> left >> right;
		//cout << left << endl;
		//cout << right << endl;
		vector<int> lvec(4, 0);
		vector<int> rvec(4, 0);
		to_vec(left, lvec);
		to_vec(right, rvec);

		vector<int> res = sum(lvec, rvec);
		int num;
		for (int i = 0; i < 4; i++) {
			num = res[i];
			if (num == 0) {
				continue;
			} else {
				if (num != 1) {
					cout << num;
				}
				if (i == 0) {
					cout << "m";
				} else if (i == 1) {
					cout << "c";
				} else if (i == 2) {
					cout << "x";
				} else {
					cout << "i";
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    as <- heapFromList <$> getIntList
    print $ solve m as
    
solve 0 as = sum $ heapToList as
solve m as = let (a,as') = deleteMax as in solve (m-1) (heapInsert as' (a `div` 2))

----heap
data Heap a = Empty | Heap Int a (Heap a) (Heap a) deriving Show

empty = Empty

singleton :: a -> Heap a
singleton x = Heap 1 x Empty Empty

--併合
merge :: Ord a => Heap a -> Heap a -> Heap a
merge h Empty = h
merge Empty h = h
merge h1@(Heap _ x l1 r1) h2@(Heap _ y l2 r2)
    | x > y     = makeHeap x l1 (merge r1 h2)
    | otherwise = makeHeap y l2 (merge r2 h1)

rank :: Heap a -> Int
rank Empty = 0
rank (Heap r _ _ _) = r

makeHeap :: a -> Heap a -> Heap a -> Heap a
makeHeap x a b
    | ra >= rb  = Heap (rb + 1) x a b
    | otherwise = Heap (ra + 1) x b a
    where ra = rank a
          rb = rank b

--挿入
heapInsert :: Ord a => Heap a -> a -> Heap a
heapInsert h x = merge (singleton x) h

--リストから
heapFromList :: Ord a => [a] -> Heap a
heapFromList = foldl heapInsert Empty

--リストへ
heapToList :: Ord a => Heap a -> [a]
heapToList h | isEmpty h = []
             | otherwise = let (x, h') = deleteMax h in x : heapToList h'

--最大値の取り出し（削除）
deleteMax :: Ord a => Heap a -> (a, Heap a)
deleteMax Empty = error "Empty Heap"
deleteMax (Heap _ x a b) = (x, merge a b)

--最大値を見る（削除しない）
findMax :: Heap a -> a
findMax Empty = error "Empty Heap"
findMax (Heap _ x _ _) = x

--空か
isEmpty :: Heap a -> Bool
isEmpty Empty = True
isEmpty _     = False

Measured memory_bytes: 19836
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(true){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if(a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3636
N = int(input())                                     
A = list(map(int, input().split()))                  
def gcd(a,b):                                        
    if b > a:                                        
        a, b = b, a                                  
    if b == 0:                                       
        return(a)                                    
    else:                                            
        return(gcd(b, a % b))                        
dp = [0 for i in range(N)]                           
dp[0] = A[0]                                         
for i in range(1,N):                                 
    dp[i] = gcd(dp[i-1] , A[i])                      
dpr = [0 for i in range(N)]                          
dpr[N-1] = A[N-1]                                    
for i in range(N-2,-1,-1):                           
    dpr[i] = gcd(dpr[i+1],A[i])                      
maxgcd = dpr[1]                                      
for i in range(1,N-1):                               
    maxgcd = max(maxgcd, gcd(dp[i-1], dpr[i+1]))     
maxgcd = max(maxgcd,dp[N-2])                         
print(maxgcd)                                        

Measured memory_bytes: 14488
#abc043 b
s=input()
ans=[]

def sousa(x):
    if x=="0":
        ans.append("0")
    if x=="1":
        ans.append("1")
    if x=="B":
        if ans!=[]:
            ans.pop()

for c in s:
    sousa(c)

x=""
for c in ans:
    x+=c
print(x)


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

int main(){
    int n;
    cin>>n;
    int A[n];
    int B[n];
    int C[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
        cin>>B[i];
        cin>>C[i];
    }
    
    int dp[n][3]={0};
    
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            if(i==0){
                if(j==0){
                dp[i][j]=A[i];
                }
                if(j==1){
                dp[i][j]=B[i];
                }
                if(j==2){
                dp[i][j]=C[i];
                }
            }
            else{
                for(int k=0;k<3;k++){
                    if(j==k){
                        continue;
                    }
                    if(j==0) dp[i][j]=max(dp[i][j],dp[i-1][k]+A[i]);
                    else if(j==1) dp[i][j]=max(dp[i][j],dp[i-1][k]+B[i]);
                    else  dp[i][j]=max(dp[i][j],dp[i-1][k]+C[i]);
                }
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

const ll MAX_N = 100005;

ll n, m, a[MAX_N];
ll datas[MAX_N*2]{}, bucket[1000]{},siz = 400;

// [f,e)
void add(int f, int e, ll x) {
    for (int i = 0; i * siz <= m*2+1; i++) {
        int l = i * siz, r = (i + 1) * siz;
        if (f >= r || e <= l)
            continue;
        if (f <= l && e >= r)
            bucket[i] += x;
        else {
            for (int j = max(f, l); j < min(e, r); j++) {
                datas[j] += x;
            }
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++) {
        ll dif = (m + a[i + 1] - a[i]) % m;
        add(m + a[i + 1] - dif + 1, m + a[i + 1] + 1, 1);
        datas[a[i + 1]] -= dif;
    }
    for (int i = 0; i <= m * 2 + 1; i++) {
        datas[i] += bucket[i / siz];
    }
    for (int i = m * 2 + 1; i > 0; i--) {
        datas[i - 1] += datas[i];
    }
    ll dmin = 99999999999999;
    for (int i = 1; i <= m; i++) {
        if (datas[i] + datas[i + m] < dmin) {
            dmin = datas[i] + datas[i + m];
        }
    }
    cout << dmin << endl;
    return 0;
}

Measured memory_bytes: 2560
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

k, x = na()
y = max(-1000000, x-k+1)
z = min(1000000, x+k-1)
for u in range(y, z+1):
    sys.stdout.write(str(u) + " ")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#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 pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    int n;
    cin >> n;
    vector<array<int,3>> dp(n);
    vi a(n), b(n), c(n);
    rep(i,0,n) {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    rep(i,0,n-1) {
        dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i+1];
        dp[i+1][1] = max(dp[i][0], dp[i][2]) + b[i+1];
        dp[i+1][2] = max(dp[i][1], dp[i][0]) + c[i+1];
    }
    cout << max({dp[n-1][0],dp[n-1][1], dp[n-1][2]}) << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 5560
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	long long int n;
	cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256