akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdint>
#include <functional>
#include <vector>

template <typename Monoid> class SegmentTree {
	using uint32 = std::uint_fast32_t;

public:
	using value_type = Monoid;
	using reference = value_type &;
	using const_reference = const value_type &;

private:
	using F = std::function<value_type(const_reference, const_reference)>;
	const F f;
	const value_type neutral_;
	const uint32 size_;
	std::vector<value_type> tree;
	static uint32 getsize(const uint32 size) {
		uint32 ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const uint32 index) {
		tree[index] = f(tree[index << 1], tree[index << 1 | 1]);
	}

public:
	SegmentTree(const uint32 size, const_reference neutral = value_type(),
		const F &f = std::plus<value_type>())
		: f(f), neutral_(neutral), size_(getsize(size)),
		tree(size_ << 1, neutral_) {}
	SegmentTree(const std::vector<value_type> &arr,
		const_reference neutral = value_type(),
		const F &f = std::plus<value_type>())
		: f(f), neutral_(neutral), size_(getsize(arr.size())),
		tree(size_ << 1, neutral_) {
		for (uint32 i = 0; i < arr.size(); ++i)
			tree[size_ + i] = arr[i];
		for (uint32 i = size_; --i;)
			recalc(i);
	}
	void update(uint32 index, const std::function<void(reference)> &g) {
		assert(index < size_);
		g(tree[index += size_]);
		while (index >>= 1)
			recalc(index);
	}
	void update(uint32 index, const_reference data) {
		update(index, [&data](reference e) { e = data; });
	}
	value_type range(uint32 begin, uint32 end) const {
		assert(begin <= end);
		assert(begin <= size_);
		assert(end <= size_);
		value_type retL = neutral_, retR = neutral_;
		for (begin += size_, end += size_; begin < end; begin >>= 1, end >>= 1) {
			if (begin & 1)
				retL = f(retL, tree[begin++]);
			if (end & 1)
				retR = f(tree[end - 1], retR);
		}
		return f(retL, retR);
	}
	uint32 search(const std::function<bool(const_reference)> &b) const {
		if (!b(tree[1]))
			return size_;
		value_type acc = neutral_;
		uint32 i = 1;
		while (i < size_)
			if (!b(f(acc, tree[i <<= 1])))
				acc = f(acc, tree[i++]);
		return i - size_;
	}
	const_reference operator[](const uint32 index) const {
		assert(index < size_);
		return tree[index + size_];
	}
};

#include <iostream>
#include <algorithm>
int main(void) {
	int n,q;
	std::cin >>n>> q;
	SegmentTree<int> T(n, 2147483647, [](int l, int r) {return std::min(l, r);});
	while (q--) {
		int t, x,y;
		std::cin >> t >> x>>y;
		if (t == 0) {
			T.update(x, y);
		}
		else {
			std::cout << T.range(x,y+1) << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3848
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  double ret = n * n * n/27.0;
  printf("%.10f\n",ret);
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<int> cnt(4);
    Rep(i, N) {
        string S;
        cin >> S;
        if (S == "AC")cnt[0]++;
        else if (S == "WA")cnt[1]++;
        else if (S == "TLE")cnt[2]++;
        else cnt[3]++;
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())

#素因数分解。
pf={}
m=N
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
#print(pf)

val = list(pf.values())
#print('val', val)

T = len(val)
count=0

for i in range(T):
    j=1
    while True:
        val[i] -= j
        j+=1
        if val[i]>=0:
            count+=1
        else:
            break

print(count)

Measured memory_bytes: 63560
#include <stdio.h>
#include <math.h>
#include <string.h>

#define MAX_a 300000

int isprime[MAX_a];
int prime[MAX_a];

void eratosthenes(){

	int i,j;

	for(i=0;i<=MAX_a;i++){
		isprime[i] = 1;
	}
	isprime[0] = isprime[1] = 0;
	for(i=0;i<=sqrt((double)MAX_a)+1;i++){
		if(isprime[i]==1){
			for(j = i + i; j <= MAX_a; j+=i){
				isprime[j] = 0;
			}
		}
	}
}

int main() {

	int i,j;

	eratosthenes();

	int cnt=0;

	for(i=1;i<=55555;i++){
		if(isprime[i] == 1){
			prime[cnt]=i;
			cnt++;
		}
	}

	int N;

	scanf("%d",&N);

	int m,x1;

	int cnt2;

	int ans[60];

	for(m=1;m<cnt;m++){
		memset(ans,0,sizeof(ans));
		ans[0]=2;
		cnt2=1;
		for(x1=5;;x1+=5){
			if(prime[m]+(2*x1)>=MAX_a){return 0;}
			if(isprime[prime[m]+(2*x1)]==1){
				ans[cnt2]=prime[m]+(2*x1);
				cnt2++;
				if(cnt2==N){
					for(j=0;j<N-1;j++){
					printf("%d ",ans[j]);
					}
					printf("%d\n",ans[N-1]);
					return 0;
				}
			}

		}
	}

		return 0;
	}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans=0;
    rep(i,n-1){
        int tmp=0;
        rep(a,26){
            bool ok=false;
            rep(j,i+1){
                if(s[j]=='a'+a){
                    ok=true;
                    break;
                }
            }
            bool ok2=false;
            for(int j=i+1; j<n; j++){
                if(s[j]=='a'+a){
                    ok2=true;
                    break;
                }
            }
            if(ok && ok2) tmp++;
        }
        ans=max(ans,tmp);
    }

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

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll A, B ;
    cin >> A >> B ;

    if(A >= 13) cout << B  << endl;
    else if(A >= 6) cout << B/2 << endl;
    else cout << 0 << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		int a[]=new int[N];
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		boolean x=true;
		int ctn=0;
		while(x) {
			for(int i=0;i<N;i++) {
				if(a[i]%2==1) {
					x=false;
					break;
				}else {
					a[i]/=2;
				}
			}
			if(x)ctn++;
		}
		p(ctn);
		
		}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxm=2e3+10,maxn=1e3+10,mod=1e9+7;
vector<pair<int,int> > G[maxn];
struct Edge{
	int x,y,z;
	void input(){
		x=read(),y=read(),z=read();
	}
	bool operator <(const Edge &rhs) const{
		return z<rhs.z;
	}
}E[maxm];
bool p[maxm];
int fa[maxn];
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=1ll*res*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return res;
}
inline int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int u;
bool dfs(int x,int to,int ff){
	if(x==to) return 1;
	REP(i,0,G[x].size()-1){
		if(G[x][i].first==ff) continue;
		if(dfs(G[x][i].first,to,x)){
			u=max(u,G[x][i].second);
			return 1;
		}
	}
	return 0;
}
int main(){
	int n=read(),m=read();
	ll num=readll();
	REP(i,1,m) E[i].input();
	sort(E+1,E+m+1);
	REP(i,1,n) fa[i]=i;
	REP(i,1,m){
		int x=E[i].x,y=E[i].y,z=E[i].z;
		if(find(x)==find(y)) continue;
		p[i]=1;
		num-=z;fa[find(x)]=find(y);
		G[x].push_back(make_pair(y,z));
		G[y].push_back(make_pair(x,z));
	}
	if(num<0){
		printf("0\n");
		return 0;
	}
	int num2,num3;
	num2=num3=0;
	REP(i,1,m){
		if(p[i]) continue;
		u=0;
		dfs(E[i].x,E[i].y,0);
		u=E[i].z-u;
		if(u==num) num2++;
		else if(u>num) num3++;
	}
	int ans=2ll*(ksm(2,num2)-1)%mod*ksm(2,num3)%mod;
	if(num==0) ans=(ans+1ll*ksm(2,m-n+2)*(ksm(2,n-2)-1)%mod)%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int N, Sn;

    cin >> N;
    Sn = 0;
    for (int i = N; i > 0; i /= 10) {
        Sn += i % 10;
    }
    cout << (N % Sn == 0 ? "Yes" : "No") << endl;
}

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


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int h, w, n;
	vector<pair<int,int>> xys;
	bool fin = false;

	scanf("%d%d%d", &h, &w, &n);
	xys.resize(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d%d", &xys[i].first, &xys[i].second);
		if(xys[i].first == 2 && xys[i].second == 1) {
			fin = true;
		}
	}
	sort(xys.begin(), xys.end());

	if(fin) {
		printf("1\n");
		return 0;
	}

	int ans = h;
	int right = 1;
	int it = 0;

	for(int x = 2; x <= h; ++x) {

		while(it < n && xys[it].first < x) {
			it += 1;
		}

		bool valid_it = (it < n && xys[it].first == x);
		int by = (valid_it ? xys[it].second : (w + 1));

		if(right >= by) {
			ans = x - 1;
			break;
		}
		if(right + 1 < by) {
			right += 1;
		}
	}

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

	return 0;
}

/* waffle */


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INF = (int) 1e9;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.00001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	const int MAXV = 100000;
	int N, W;
	cin >> N >> W;
	vector<ll> dp(MAXV + 1, 1e18);
	dp[0] = 0;
	for (int k = 0; k < N; k++) {
		int w, v;
		cin >> w >> v;
		for (int i = MAXV; i >= v; i--) {
			if (dp[i - v] != -1) dp[i] = min(dp[i], dp[i - v] + w);
		}
	}
	ll v = -1;
	for (int i = 0; i <= MAXV; i++) {
		if (dp[i] <= W) v = i;
	}
	cout << v << endl;
	return 0;
}


Measured memory_bytes: 1024
def f(dt, v):
    a=sum(dt)*1.0*v[0]/sum(v)
    b=0
    for i in range(len(dt)):
        b += dt[i]
        if b>= a: return i+1
    return

while True:
    try:
        dt=map(int, raw_input().split(","))
    except:
        break
    dt, v = dt[:10], dt[10:]
    print f(dt,v)

Measured memory_bytes: 4232
N, M = gets.chomp.split(' ').map(&:to_i)
prices = gets.chomp.split(' ').map(&:to_i)

# シンプルにこの実装だと計算量が N * M でOVER
# M.times do
#   max = prices.max
#   index = prices.index(max)

#   prices[index] = prices[index] / 2
# end

# puts prices.inject(:+)


class MaxHeap
  attr_reader :targets

  def initialize(array)
    @targets = {}
    @length = array.length
    @length.times { |i| @targets[i + 1] = array[i] }
  end

  def max_heap(i)
    l = 2 * i
    r = 2 * i + 1

    if l <= @length && @targets[l] > @targets[i]
      largest = l
    else
      largest = i
    end
    largest = r if r <= @length && @targets[r] > @targets[largest]

    return if largest == i

    @targets[i], @targets[largest] = @targets[largest], @targets[i]
    max_heap(largest)
  end

  def build_max_heap()
    (@targets.length / 2).downto(1) do |i|
      max_heap(i)
    end
  end

  # 下からつけてどんどん上に
  def insert(val)
    @length += 1
    @targets[@length] = val

    h = @length
    while h > 1 && @targets[h / 2] < @targets[h]
      @targets[h / 2], @targets[h] = @targets[h], @targets[h / 2]
      h /= 2
    end
  end

  def extra_max
    max = @targets[1]
    @targets[1] = @targets[@length]
    @targets.delete(@length)
    @length -= 1
    max_heap(1)

    max
  end
end

heap = MaxHeap.new(prices)
heap.build_max_heap

M.times do
  price = heap.extra_max
  heap.insert(price / 2)
end

p heap.targets.values.inject(:+)


Measured memory_bytes: 18828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

const int M = 1000005;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    vector<int> cnt(M);
    for(int x : A){
        if(cnt[x] != 0){  //xのcntが既に0でない場合
            cnt[x] = 2;
            continue;
        }
        for(int i = x; i < M; i+= x) cnt[i]++; //xの倍数にチェックしていく
    }
    int ans = 0;
    for(int x : A){
        if(cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    bool tate[w] = {}, yoko[h] = {};
    for(int i = 0; i < h; i++){
        cin >> a[i];
    }
    for(int i = 0;i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                yoko[i] = true;
                tate[j] = true;
            }
        }
    }
    for(int i = 0; i < h; i++){
        if(yoko[i]){
            for(int j = 0; j < w; j++){
                if(tate[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
// ProblemURL : https://atcoder.jp/contests/abc090/tasks/arc091_a
// ---------------------------------------------
package main

import "fmt"

func solve(n, m int) int {
	if n == 1 && m == 1 {
		return 1
	}
	if n == 1 {
		return m - 2
	}
	if m == 1 {
		return n - 2
	}
	return (n - 2) * (m - 2)
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	fmt.Println(solve(n, m))
}


Measured memory_bytes: 512
N = int(input())

ans = 0
tmp_M0 = -float("inf")
tmp_m0 = float("inf")
tmp_M1 = -float("inf")
tmp_m1 = float("inf")
for i in range(N):
    x,y =map(int, input().split())
    if x-y > tmp_M0:
        tmp_M0 = x-y
    if x-y < tmp_m0:
        tmp_m0 = x-y
    if x+y > tmp_M1:
        tmp_M1 = x+y
    if x+y < tmp_m1:
        tmp_m1 = x+y
    
    if max(tmp_M0-tmp_m0, tmp_M1-tmp_m1) > ans:
        ans = max(tmp_M0-tmp_m0, tmp_M1-tmp_m1)
        
print(ans)

Measured memory_bytes: 9148
import sys

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

alp = list("abcdefghijklmnopqrstuvwxyz")

def div26(N):
    #print("N=",N)
    a = N // 26
    b = N % 26
    #print(a,b)
    return [a,b]

def getAlp(N):
    if N==0:
        N = 26
    return alp[N-1]

def solver(N):

    ans = ""

    x = div26(N)
    ans += getAlp(x[1])
    if x[1]==0:
        x[0] -= 1

    #print("ans=",ans)

    while x[0] > 0:
        #print("in")
        x = div26(x[0])
        ans += getAlp(x[1])
        if x[1]==0:
            x[0] -= 1

    print(ans[::-1])




def main():
    N = I()
    #print(N,K,Pn)
    solver(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9008
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int even = sc.nextInt();
        int odd = sc.nextInt();
        int ans = even*(even-1)/2 + odd*(odd-1)/2;
        System.out.println(ans);
    }

}

Measured memory_bytes: 23380
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>
using namespace std;
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
//const double PI = acos(-1) ;
db PI=3.1415926;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     pf("Case %d: %lld\n",z,x)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)


using namespace std;
ll n,m,y,x,h,e,l,o;


int main()
{
	CIN;
	//cin>>n;
	string  s,t;
	cin>>s>>t;
	int p=s.size();
	for0(i,p)if(s[i]!=t[i])x++;
	pf("%lld\n",x);


	
	
}

Measured memory_bytes: 3868
a=[]
n=0
for x in input().split(" "):
    a.append(int(x))
if a[0]==3:
    n+=100000
elif a[0]==2:
    n+=200000
elif a[0]==1:
    n+=300000
if a[1]==3:
    n+=100000
elif a[1]==2:
    n+=200000
elif a[1]==1:
    n+=300000
if a[0]==1 and a[1]==1:
    n+=400000
print(n)

Measured memory_bytes: 3064
def main():
    A, B = map(int, input().split())
    if B == 1:
        print(0)
        exit()
    
    cnt = A
    tap = 1
    while True:
        if cnt >= B:
            print(tap)
            exit()
        cnt += (A - 1)
        tap += 1




if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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


int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a >= 1 && a < 10 && b >= 1 && b < 10) {
		cout << a * b << endl;
		return 0;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ab = n.times.map{gets.chomp.split(" ").map(&:to_i)}.sort_by{|coo|coo[0]}
cd = n.times.map{gets.chomp.split(" ").map(&:to_i)}.sort_by{|coo|coo[0]}
count = 0
for i in 0..n-1
  tmp = []
  tmp = ab.select{|coo|coo[0] < cd[i][0] && coo[1] < cd[i][1]}
  if !(tmp.empty?)
    count += 1
    tmp.sort_by!{|coo|coo[1]}
    ab.delete(tmp[-1])
  end
end
puts count

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

using namespace std;

string str;
string key="qwertasdfgzxcvb";

void solve() {
    bool left=true;
    int ans=0;
    for(int i=0;i<str.size();i++) {
        if(key.find(str[i])!=string::npos) {
            //find!
            if(!left) ans++;
            left=true;
        }
        else {
            //notfind
            if(left) ans++;
            left=false;
        }
    }

    if(key.find(str[0])==string::npos) ans--;
    cout<<ans<<endl;

}

int main() {
    while(cin>>str) {
        if(str=="#") return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;



int main(){
  int a,b;
  cin >>a>>b;
  rep1(c,1000){
    //cout<<c<<":"<<int(1.08*c)<<" "<<int(1.1*c)<<endl;
    if(int(0.08*c)==a && int(0.1*c)==b){
     cout<<c<<endl;
      return 0;
      
    }

  }
  
  cout<<-1<<endl;
  return 0;
  

}


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

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

    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            for(int k=j;k<n;k++){
                if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]){
                    if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i])
                        ans ++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
  

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

int main(){
    int n;
    cin>>n;
    int a=0,b=0,c=0,d=0;
    while(n--){
        string s;
        cin>>s;

        if(s=="AC")
            a++;
        else if(s=="WA")
            b++;
        else if(s=="TLE")
            c++;
        else
            d++;
    }

    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
}


Measured memory_bytes: 3612
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

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

n = ni()
if n == 1:
    print(0)
else:
    print((pow(10, n, mod)-(2 * pow(9, n, mod) - pow(8, n, mod))) % mod)

Measured memory_bytes: 10936
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,k;cin>>n>>k;
	int w[100003];
	REP(i,n){cin>>w[i];}
	int l = 0,r = 1e9+1;
	while(abs(r-l)>1){
		int p = (r+l)/2;
		int j = 0;
		REP(i,k){
			int tmpp = 0;
			while(tmpp + w[j] <= p){
				tmpp += w[j];
				j++;
				if(j == n)break;
			}
			if(j==n)break;
		}
		if(j == n)r = p;
		else l = p;
	}
	cout << r << endl;
  return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.size()) {
		if (s[i] == t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	ll h, w;
	cin >> h >> w;
	if (min(h, w) == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) << endl;
}


Measured memory_bytes: 256
fn main() {
    let (n,m) = {
        let t = rv::<usize>();
        (t[0], t[1])
    };
    let s = rv::<i32>();
    let t = rv::<i32>();
    let mut dp = vec![vec![1i64;m+1];n+1];
    for i in 0..n {
        for j in 0..m {
            let a=dp[i][j+1];
            let b=dp[i+1][j];
            let v=if s[i]==t[j] {0} else {dp[i][j]};
            dp[i+1][j+1] = (a+b-v+MOD)%MOD;
        }
    }
    println!("{}",dp[n][m]);
}
const MOD: i64=1000000007;
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 45308
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACoffee solver = new ACoffee();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACoffee {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            char[] a = s.next().toCharArray();
            if (a[2] == a[3] && a[4] == a[5])
                w.println("Yes");
            else
                w.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    int ans;
    for(int i=1;i<10;i++){
        ans=111*i;
        if(n<=ans){
            cout << 111*i << endl;
            break;
        }
    }
        

    return 0;
}




Measured memory_bytes: 256
iipt=lambda:int(input())
miipt=lambda:list(map(int,input().split(" ")))
import bisect
 
N=iipt()
c=miipt()
M=iipt()
qu=miipt()
ans=0
for q in qu:
    a=0
    b=N-1
    while b-a>1:
        x=(a+b)//2
        if c[a]==q or c[b]==q:
            ans+=1
            break
        if c[x]<q:
            a=x
        else:
            b=x
    else:
        if c[a]==q or c[b]==q:
            ans+=1

    """        
    if a==-1 or b==N:
        print(q,a,b)
        ans-=1"""

print(ans)


Measured memory_bytes: 16744
#coding:utf-8
s = input()

if s[0]!='A':
    print ('WA')
    exit()

cnt = 0
for char in s[2:-1]:
    if char=='C':
        cnt += 1
if cnt!=1:
    print ('WA')
    exit()

cnt_upper = 0
for char in s:
    cnt_upper += char.isupper()
if cnt_upper != 2:
    print ('WA')
    exit()

print ('AC')


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

int T[50000],S[100000];
	int binarySearch(int,int);
int main() {
	int n,i,q,j,k=0;
	scanf("%d",&n);
	for(j=0;j<n;j++) {
		scanf("%d",&S[j]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++) {
		scanf("%d",&T[i]);
		if(binarySearch(T[i],n)==1) k++;
	}
printf("%d\n",k);
return 0;
}
	
	int binarySearch(int key, int n) {
 int   left = 0,mid;
     int right = n;
    while( left < right) {
        mid = (left + right) / 2;
        if (S[mid] == key)
            return 1; 
        else if (key < S[mid])
            right = 	mid;
        else
            left = mid + 1;
          }
      return 0;
    
    }


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


int main() {
	int v,h;
	int x;
	
	int p1;
	int p2;
	int qa1,qa2;
	int qb1,qb2;
	int count;

	cin >> v >> h;
	
	for (x = v; x <= h; x++){
	//一つ目の判定
	p1 = x / 10000;
	p2 = x % 10;
	if(p1 == p2)
	{
		qa1 = x / 1000;
		qb1 = qa1 % 10;
		
		qa2 = x % 100;
		qb2 = qa2 / 10;
		
		//二つ目の判定
		if(qb1 == qb2){
			count ++;
		}
	}
	
	}
	
	cout << count << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N;
ll a[10010];
ll ans = 0;

int main() {
    cin >> N;
    rep(i,N) cin >> a[i];
    rep(i,N){
        while(a[i]%2 == 0){
            ans++;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

int main() {
    int n; cin >> n;
    int cnt = 0;
    for(int i=0; i<n; i++) {
        int x, y; cin >> x >> y;
        if (x==y) {
            cnt++;
            if (cnt==3) {
                cout << "Yes";
                return 0;
            }
        } else cnt=0;
    }
    cout << "No";
}


Measured memory_bytes: 3588
x, y = map(int, input().split())

ans = 0
Button = [(1, 1), (1, 0), (0, 1), (0, 0)]

ans = float("INF")
for fb, lb in Button:
  t, tx, ty = 0, x, y
  if fb:
    tx = -x
    t += 1
  if lb:
    ty = -y
    t += 1
  if tx > ty:
    continue
  t += ty - tx
  ans = min(ans, t)

print(ans)

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

int main(){
int N;
  cin >> N ;
  vector<char> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  bool a=true;
  for(int i=0;i<N;i++){
  if(vec.at(i)=='Y'){
  a=false;
  break;
  }
     }
 if(a){
 cout << "Three";
 }   
  else{
  cout << "Four";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll p = 1;
    while(p*(p+1) < N){
        if((N-p)%p == 0){
            ans += (N-p)/p;
        }
        p++;
    }

    cout << ans;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

// hassuffixを使う

var texts = []string{"dream", "dreamer", "erase", "eraser"}

func main() {
	var s string
	fmt.Scan(&s)
	ans := false
	for {
		// sがtextを末尾に持つかどうか
		have := false
		for _, t := range texts {
			// もっていたらそれを消す
			if strings.HasSuffix(s, t) {
				s = s[:len(s)-len(t)]
				have = true
				break
			}
		}
		if have {
			continue
		} else if len(s) == 0 {
			ans = true
			break
		} else {
			break
		}
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1280
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define lowbit(a) (a & (-a))
#define INF 0x3f3f3f3f
#define MAX 1010
#define mod 1000000007
#define PI 3.1415926

int main()
{

    ll a, b;
    cin >> a >> b;
    cout << max(a + b, max(a * b, a - b)) << endl;

    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    vector<int> A(5);
    for(int i = 0; i < 5; i++){
        cin >> A[i];
    }
    int k;
    cin >> k;
    bool flg = true;
    for(int i = 0; i < 5; i++){
        for(int j = i; j < 5; j++){
            if(A[j] - A[i] > k) flg = false;
        }
    }
    if(flg) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

//宣言忘れない！！
int main() {
  double x; cin >> x;
  double n = 100;
  ll cnt = 0;
  while(n < x){
    n *= 1.01;
    n = (ll)n;
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3724
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int n;
string s,t[2]={"dreamer","eraser"};
bool memo[123456],done[123456];

bool dp(int i){
	int j,p=0;
	if(done[i]){
		return memo[i];
	}
	done[i] = true;
	memo[i] = false;
	if(i==n){
		memo[i] = true;
		return memo[i];
	}
	if(s[i]!='d' && s[i]!='e'){
		return memo[i];
	}
	for(j=i; j<min(n,i+(int)(t[s[i]-'d'].l_ength())); ++j){
		if(s[j]!=t[s[i]-'d'][j-i]){
			break;
		}
		++p;
		if(p>4 && (p!=6 || (s[i]-'d'))){
			memo[i] |= dp(i+p);
		}
	}
	return memo[i];
}

int main(void){
	fill(done,done+123456,false);
	cin >> s;
	n = s.l_ength();
	cout << ((dp(0)?"YES":"NO")) << endl;
	return 0;
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<iostream>
#include<string.h>
#define len 100010

using namespace std;


struct Q{
  char name[110];
  int tim;
};

Q Que[len];
int n;
int head=0;
int tail=0;

/*int initialize(){
  head=tail=0;
  }*/

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

/*int isEmpty(){
  if(head==tail){
    return 1;
  }
  }*/

Q dequeue(){
  //if(isEmpty()==1)fprintf(stderr,"UnderFlow\n");
  Q y=Que[head];
  head=(head+1)%len;
  return y;
}

/*int isFull(){
  if(head==(tail+1)%len){
    return 1;
  }
  }*/

int main(){
  int c=0,d=0;
  int del=0;
  Q ll;
  //if(isFull()!=1)fprintf(stderr,"OverFlow\n");
  
  cin>>n>>del;
  head=1;
  tail=n+1;
  for(int i=1;i<=n;i++){
    cin>>Que[i].name;
    cin>>Que[i].tim;
  }
  while(1){
    //if(isEmpty()==1)break;
    if(head==tail)break;
    ll=dequeue();
    if(del<ll.tim)c=del;
    else c=ll.tim;
    ll.tim=ll.tim-c;
    d=d+c;
    if(ll.tim>0)enqueue(ll);
    else cout<<ll.name<<" "<<d<<endl;
  }
  return 0;
}



Measured memory_bytes: 14384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
    
      System.out.printf("%d %d %.5f", a/b, a%b, (double)a/(double)b);
    }
}


Measured memory_bytes: 26364
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = n - 1; i >= 0; i--) {
		cout << a[i];
		if (i == 0) cout << endl;
		else cout << " ";
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	vl dp(m+1);
	ll res=0;
	for(int j=0;j<n;j++){
		int x;
		cin>>x;
		if(x>m) continue;
		vl DP(m+1);
		(DP[x]+=j+1)%=mod;
		for(int j=0;j<=m-x;j++) (DP[j+x]+=dp[j])%=mod;
		(res+=DP[m]*(n-j))%=mod;
		for(int j=0;j<=m;j++) (dp[j]+=DP[j])%=mod;
	}
	cout<<res<<endl;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  string s; cin >> s;
  for(int i = 0; i < s.size()-1; i++){
    if(s[i] == s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;

  return 0;
}


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

int main(int argc, char *argv[]){
  string s;
  int n;
  cin >> s >> n;
  int LtoR = atoi(&s[0]), correct = 0;
  for (int i = 1; i < s.length(); i+=2) {
    if(s[i] == '+'){
      LtoR += atoi(&s[i + 1]);
    }else{
      LtoR *= atoi(&s[i + 1]);
    }
  }
  vector<int> remove_mal;
  remove_mal.push_back(atoi(&s[0]));
  for (int i = 1; i < s.length(); i+=2) {
    if(s[i] == '*'){
      remove_mal[remove_mal.size() - 1] *= atoi(&s[i + 1]);
    }else{
      remove_mal.push_back(atoi(&s[i + 1]));
    }
  }
  for (int i:remove_mal){
    //    std::cout << i << std::endl;
    correct += i;
  }
  if(LtoR == correct && correct == n){
    std::cout << "U" << std::endl;
  }else if(LtoR == n){
    std::cout << "L" << std::endl;
  }else if(correct == n){
    std::cout << "M" << std::endl;
  }else{
    std::cout << "I" << std::endl;
  }
   // std::cout << "LtoR:   " << LtoR    << std::endl;
   // std::cout << "correct:" << correct << std::endl;
  return 0;
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//~ const int mod = (int)1e9 + 7;
const int mod = 998244353;
const ll linf = (ll)1e18 + 7;

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

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}




int main(void) 
{	
	int a, b;
	cin>> a >> b;
	if(a >= 13)
		cout<<b;
	else if( a>=6 && a <= 12)
		cout<<b/2;
	else
		cout<<0;
	return 0;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
const int C=150001;

int n, k, a, b, c, dp[3][C];

int abs(int a){return (a>0)?(a):(-a);}

int main(){
	int j;
	scanf ("%d", &n);
	for (int i=1;i<=n;i++)	{
		scanf ("%d %d %d", &a, &b, &c);
		dp[0][i]=max(dp[1][i-1], dp[2][i-1])+a;
		dp[1][i]=max(dp[0][i-1], dp[2][i-1])+b;
		dp[2][i]=max(dp[1][i-1], dp[0][i-1])+c;
	}
	printf ("%d\n", max(dp[2][n], max(dp[1][n], dp[0][n])));
	
return 0;}

Measured memory_bytes: 1280
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c,d,res1=1,res2=1,res3=1,res4=1,max=-1000000000000000000;
  cin>>a>>b>>c>>d;
  res1=a*c;
  res2=a*d;
  res3=b*c;
  res4=b*d;
  if(max<=res1)
	max=res1;
  if(max<=res2)
    max=res2;
  if(max<=res3)
    max=res3;
  if(max<=res4)
    max=res4;
  cout<<max;
  return 0;
}  
  
  

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    ll n;
    cin>>n;
    double x[n],y[n];
    char d[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>d[i];
    }
    double dx[4] = {1,0,-1,0};
    double dy[4] = {0,1,0,-1};
    string s="RULD";    
    double INF = 1e18;
    double low = 0.0, up = 1e12;
    for(int c=0;c<1000;c++){
        double m[2] = {(low*2+up)/3,(low+up*2)/3};
        double x1[2]={INF,INF},x2[2]={-INF,-INF},y1[2]={INF,INF},y2[2]={-INF,-INF};
        for(int i=0;i<n;i++){
            for(int j=0;j<4;j++){
                if(d[i]==s[j]){
                    for(int k=0;k<2;k++){
                        x1[k] = min(x1[k], x[i]+dx[j]*m[k]);
                        x2[k] = max(x2[k], x[i]+dx[j]*m[k]);
                        y1[k] = min(y1[k], y[i]+dy[j]*m[k]);
                        y2[k] = max(y2[k], y[i]+dy[j]*m[k]);
                    }
                }
            }
        }
        double t1 = (x2[0] - x1[0]) * (y2[0] - y1[0]);
        double t2 = (x2[1] - x1[1]) * (y2[1] - y1[1]);
        if(t1 < t2){
            up = m[1];
        }
        else low = m[0];
    }
    double x1=INF, x2=-INF, y1=INF, y2=-INF;
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            if(d[i]==s[j]){
                x1 = min(x1, x[i]+dx[j]*low);
                x2 = max(x2, x[i]+dx[j]*low);
                y1 = min(y1, y[i]+dy[j]*low);
                y2 = max(y2, y[i]+dy[j]*low);
            }
        }
    }
    double ans = (x2 - x1) * (y2 - y1);
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
  	else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
 	string s; cin>>s;
    ll ans=0,red=0,blu=0;
    rep(i,s.size()){
    	if(s[i]=='0') red++;
      	else blu++;
    }
  	printf("%lld",min(red,blu)*2);
}

Measured memory_bytes: 512
INF = 2**31-1
class SegmentTree():
    def __init__(self, N):
        self.N0 = 2**(N-1).bit_length()
        self.data = [INF]*((2*self.N0)+1)

    # a_k の値を x に更新
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])

    # 区間[l, r)の最小値
    def query(self, l, r):
        L = l + self.N0; R = r + self.N0
        s = INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])

            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s


n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 10**18
segtree = SegmentTree(2*n)
for i in range(n):
    segtree.update(i, a[i])
    segtree.update(i+n, a[i])


for k in range(n):
    temp = k*x
    for i in range(n, 2*n):
        temp += segtree.query(i-k, i+1)
    ans = min(ans, temp)

print(ans)


Measured memory_bytes: 53852