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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  char c;
  while(cin >> h >> w && h+w){
    vector<vector<ll>> v(h,vector<ll>(w));
    auto v2 = v;
    rep(j,h){
      rep(i,w){
        cin >> c;
        if(c == '.'){
          v[j][i] = 1;
        }
      }
    }
    ll ans = 0;
    {
      stack<pll> st;
      rep(i,w){
        v2[0][i] = v[0][i];
        if(st.empty()){
          st.push(mp(v2[0][i],i));
        }
        else if(st.top().fi < v2[0][i]){
          st.push(mp(v2[0][i],i));
        }
        else if(st.top().fi > v2[0][i]){
          ll pos = i;
          while(!st.empty()){
            if(st.top().fi >= v2[0][i]){
              auto t = st.top();st.pop();
              ans = max(ans,t.fi * (i - t.se));
              pos = t.se;
            }
            else break;
          }
          st.push(mp(v2[0][i],pos));
        }
      }
      ans = max(ans,st.top().fi * (w - st.top().se));
    }
    REP(j,1,h){
      stack<pll> st;
      rep(i,w){
        if(v[j][i]){
          v2[j][i] += v2[j-1][i] + 1;
        }
        if(st.empty()){
          st.push(mp(v2[j][i],i));
        }
        else if(st.top().fi < v2[j][i]){
          st.push(mp(v2[j][i],i));
        }
        else if(st.top().fi > v2[j][i]){
          ll pos = i;
          while(!st.empty()){
            if(st.top().fi >= v2[j][i]){
              auto t = st.top();st.pop();
              ans = max(ans,t.fi * (i - t.se));
              pos = t.se;
            }
            else break;
          }
          st.push(mp(v2[j][i],pos));
        }
      }
      while(!st.empty()){
        auto t = st.top();st.pop();
        ans = max(ans,t.fi * (w - t.se));
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  int n,m,ans=0;
  cin>>n>>m;
  
  ans += n*(n-1)/2+m*(m-1)/2;
  cout << ans;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))


if n>= m:
	print(0)
else:
	x = sorted(x)
	x_interval = [x[i+1]-x[i] for i in range(m-1)]
	x_interval = sorted(x_interval)
	print(sum(x_interval[0:m-n]))

Measured memory_bytes: 13968
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int N=1e5+5;
int n,m,ans=1e9+7;
map<int,vector<int> > E[N];
map<int,int> d[N];
vector<int> G[N];
struct three{
	int First;
	int Second;
	int Third;
};
string to_string(int n){
	string s="";
	while(n){
		s+=n%10+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
three make_three(int x,int y,int z){
	three re;
	re.First=x;
	re.Second=y;
	re.Third=z;
	return re;
}
queue<three> q;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		E[x][z].push_back(y);
		E[y][z].push_back(x);
		G[x].push_back(z);
		G[y].push_back(z);
	}
	q.push(make_three(0,0,0));
	d[0][0]=0;
	while(!q.empty()){
		three now=q.front();
		int f=now.First,s=now.Second,t=now.Third;
		q.pop();
		if(d[f][s]!=t) continue;
		if(d[f].find(0)==d[f].end()||d[f][0]>t){
			d[f][0]=t;
			q.push(make_three(f,0,t));
		}
		if(s==0){
			for(int i=0;i<G[f].size();i++){
				int color=G[f][i];
				if(d[f].find(color)==d[f].end()||d[f][color]>t+1){
					d[f][color]=t+1;
					q.push(make_three(f,color,t+1));
				}
			}
		}
		else for(int i=0;i<E[f][s].size();i++){
			int to=E[f][s][i];
			if(d[to].find(s)==d[to].end()||d[to][s]>t){
				d[to][s]=t;
				q.push(make_three(to,s,t));
			}
		}
	}
	for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++){
		ans=min(ans,(*it).second);
	}
	if(ans!=1e9+7){
		cout<<ans;
	}
	else{
		cout<<-1;
	}
	return 0;
}

Measured memory_bytes: 83200
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=1e6;
char s[MAXN+5];
int n,a,b,c,d;
bool flag=false;
int main()
{
	//freopen("jump.in","r",stdin);
	//freopen("jump.out","w",stdout);
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	int cnt=0;
	s[0]='#';
	for(int i=a;i<=c;i++)
		if(s[i]=='#'&&s[i-1]=='#')
		{
			printf("No\n");
			return 0;
		}
	for(int i=b;i<=d;i++)
		if(s[i]=='#'&&s[i-1]=='#')
		{
			printf("No\n");
			return 0;
		}
	for(int i=b;i<=d;i++)
	{
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
			flag=true;
	}
	if(c<d||(c>d&&flag))
		printf("Yes\n");
	else
		printf("No\n");
    return 0;
}


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

int main() {
    ll N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N - 1));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N - 1; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    //[i][j] := iにとってjは何番目の相手か
    vector<vector<ll>> num_to_index(N, vector<ll>(N));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N - 1; j++) {
            num_to_index[i][A[i][j]] = j + 1;
        }
    }

    //dp[i][j] := iがj番目の相手と対戦し終える最小日数
    vector<vector<ll>> dp(N, vector<ll>(N, -1));
    for (ll i = 0; i < N; i++) {
        dp[i][0] = 0;
    }

    function<ll(ll, ll, ll)> f = [&](ll i, ll j, ll depth) {
        if (dp[i][j] != -1) {
            return dp[i][j];
        }
        if (depth >= 2 * N) {
            cout << -1 << endl;
            exit(0);
        }
        ll opponent = A[i][j - 1];

        ll left = f(i, j - 1, depth + 1);
        ll right = f(opponent, num_to_index[opponent][i] - 1, depth + 1);

        ll result = max(left, right) + 1;

        return dp[i][j] = result;
    };

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans = max(ans, f(i, N - 1, 0));
    }

    cout << ans << endl;
}

Measured memory_bytes: 24064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var xy = ConsoleUtil.IntArrayReadLine();

        if (xy[0] != xy[1])
        {
            if (xy[0] == 1)
            {
                Console.WriteLine("Alice");
            }
            else if(xy[1] == 1)
            {
                Console.WriteLine("Bob");
            }
            else if (xy[0] > xy[1])
            {
                Console.WriteLine("Alice");
            }
            else
            {
                Console.WriteLine("Bob");
            }
        }
        else
        {
            Console.WriteLine("Draw");
        }
        
    }
}

static class MathUtil
{
    static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}

static class ConsoleUtil
{
    public static string[] StrArrayReadLine(char sepalator)
    {
        string str = Console.ReadLine();
        return str.Split(sepalator).ToArray();
    }
    public static string[] StrArrayReadLine()
    {
        string str = Console.ReadLine();
        if (str.Contains(','))
        {
            return str.Split(',').ToArray();
        }
        {
            return str.Split(' ').ToArray();
        }
    }
    public static int[] IntArrayReadLine()
    {
        return StrArrayReadLine().Select(s => int.Parse(s)).ToArray();
    }
    public static int[] IntArrayReadLine(char sepalator)
    {
        return StrArrayReadLine(sepalator).Select(s => int.Parse(s)).ToArray();
    }
    public static int IntReadLine() => int.Parse(Console.ReadLine());
    public static long LongReadLine() => long.Parse(Console.ReadLine());
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int H,N,K;
	unsigned long long max1=0,max2=0;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < N-K; ++i) {
		max1+=a.at(i);
	}
	// if(max1+max2>=H){
	// 	cout << "Yes" << endl;
	// }else{
	// 	cout << "No" << endl;
	// }
	cout<<max1<<endl;
	return 0;
}

Measured memory_bytes: 1024
# 全方位木DP
# トポロジカルソート→木DP→全方位
from collections import deque
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

# modの会場が必要なのでライブラリから
mod = 10 ** 9 + 7
N = n + 5
bikkuri = [0 for i in range(N)]
bikkuri[0] = 1
gyaku = [0 for i in range(N)]
gyaku[0] = 1
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod
    gyaku[i] = pow(bikkuri[i], mod - 2, mod)

graph = [[] for _ in range(n + 1)]
m = map(int, read().split())
AB = zip(m, m)
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

# topological sort
par = [-1] * (n + 1)
que = deque([])
que.append(1)
topo = []
while que:
    v = que.popleft()
    topo.append(v)
    for u in graph[v]:
        if u == par[v]:
            continue
        par[u] = v
        graph[u].remove(v)
        que.append(u)

# これでparのリストとtopological_sortと子供方向のみグラフを得る
# 木DP
dp1 = [0] * (n + 1)
size = [0] * (n + 1)
edge_index = [{} for _ in range(n + 1)]
dpl = [[] for _ in range(n + 1)]
dpr = [[] for _ in range(n + 1)]
for v in topo[::-1]:
    dp1[v] = 1
    size[v] = 1
    # サイズを先に計算
    for u in graph[v]:
        size[v] += size[u]
        dp1[v] *= dp1[u]
        dp1[v] *= gyaku[size[u]]
    # 次に組み合わせを考える
    # 左から
    temp = 1
    for i in range(len(graph[v])):
        u = graph[v][i]
        edge_index[v][u] = i
        temp *= dp1[u]
        temp %= mod
        temp *= gyaku[size[u]]
        temp %= mod
        dpl[v].append(temp)
    # 右から
    temp = 1
    for i in range(len(graph[v]))[::-1]:
        u = graph[v][i]
        temp *= dp1[u]
        temp *= gyaku[size[u]]
        temp %= mod
        dpr[v].append(temp)
    dp1[v] *= bikkuri[size[v] - 1]
    dp1[v] %= mod

# 全方位
ans = [0] * (n + 1)
dp2 = [0] * (n + 1)

for v in topo:
    # 根の時
    if par[v] == -1:
        dp2[v] = 1
        ans[v] = dp1[v]
    else:
        # 上側の処理
        dp2[v] = 1
        p = par[v]
        # 上からみたv以外の累積積を取りたい。
        # graph[p]において、vは何番目かを考える。
        v_idx = edge_index[p][v]
        dp2[v] *= dp2[p] * gyaku[n - size[p]]
        dp2[v] *= bikkuri[n - size[v] - 1]
        dp2[v] %= mod
        # 左からv_idx個, idxはv_idx-1まで
        if dpl[p]:
            if v_idx - 1 >= 0:
                dp2[v] *= dpl[p][v_idx - 1]
                dp2[v] %= mod
            # 右からlen(grap[v])-(v_idx+1)個→idxはlen(graph[v])-v_idx-2
            if v_idx < len(graph[p]) - 1:
                dp2[v] *= dpr[p][len(graph[p]) - 2 - v_idx]
                dp2[v] %= mod
    # 上側と下側の合体
    ans[v] = bikkuri[n - 1]
    if dpl[v]:
        ans[v] *= dpl[v][-1]
    ans[v] *= dp2[v] * gyaku[n - size[v]]
    ans[v] %= mod

for i in range(1, n + 1):
    print(ans[i])


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

int main(){
    char c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
            if(i==j){
                cout << c[i][j];
            }
        }
    }
    cout << endl;
}

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

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

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

const int N=1e5+10;
bool dp[N];

int main()
{
    mem(dp,false);
    rep(i,100,106)dp[i]=true;
    for(int i=100;i<N;i+=100)
        dp[i]=true;
    for(int i=101;i<N;i+=101)
        dp[i]=true;
    for(int i=102;i<N;i+=102)
        dp[i]=true;
    for(int i=103;i<N;i+=103)
        dp[i]=true;
    for(int i=104;i<N;i+=104)
        dp[i]=true;
    for(int i=105;i<N;i+=105)
        dp[i]=true;
    rep(i,106,N)
    {
        dp[i]=(dp[i]|dp[i-100]);
        dp[i]|=dp[i-101];
        dp[i]|=dp[i-102];
        dp[i]|=dp[i-103];
        dp[i]|=dp[i-104];
        dp[i]|=dp[i-105];
    }
    int nn;cin>>nn;
    if(dp[nn])
        cout<<1;
    else
        cout<<0;
}


Measured memory_bytes: 384
// ABC153_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    // input(sunippets: inpv, inpn, inps)
    ll N, K;
    cin >> N >> K;
    vector<ll> vec(N);
    rep(i, N) cin >> vec[i];
    
    // calculation
    sort(vec.begin(), vec.end(), greater<>());  // ll big -> small
    ll res = 0;
    for (ll i = 0; i < N; ++i) {
        if (i < K) continue;
        else {
            res += vec[i];
        }
    }
    cout << res << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int tar;
    for (int i=0; i<a; i++){
        cin>>tar;
        if (tar%2==0){
            if (tar%3!=0 && tar%5!=0){
                cout<<"DENIED\n";
                return 0;
            }
        }
    }
    cout<<"APPROVED\n";
}


Measured memory_bytes: 256
import java.util.NoSuchElementException

fun main(args: Array<String>) = FastScanner().run {
    val n = nextInt()
    val a = LongArray(3*n){nextLong()}
    a.sort()
    var sum = 0L
    for (i in n until 3*n step 2) {
        sum += a[i]
    }
    println(sum)
}

class FastScanner {
    private val printable = 33..126
    val `in` = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = `in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun nextInt(): Int {
        val nl = nextLong()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun nextDouble(): Double {
        return next().toDouble()
    }
}

Measured memory_bytes: 39472
#include <iostream>
using namespace std;
int n,m,x,y,z;
int par[100001],ans;
bool a[100001];
int find(int X){
    if(par[X]==X)return X;
    return par[X]=find(par[X]);
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)par[i]=i;
    for(int i=0;i<m;i++){
        cin>>x>>y>>z;
        int X=find(x),Y=find(y);
        if(X!=Y) par[X]=Y;
    }
    for(int i=1;i<=n;i++){
        x=find(i);
        if(!a[x])ans++,a[x]=1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#define int long long
using namespace std;

class segtree {
  private:
    struct node {
      int sum = 0, uniform = 0, size = 1;
      int value() {
        return size * uniform + sum;
      }
    };
    vector<node> dat;
    int sz;
    void add(int a, int b, int x, int k, int l, int r) {
      if (b <= l || r <= a) return;
      if (a <= l && r <= b) {
        dat[k].uniform += x;
        return;
      }
      auto const m = (l + r) / 2;
      add(a, b, x, 2 * k + 1, l, m);
      add(a, b, x, 2 * k + 2, m, r);
      dat[k].sum = dat[2 * k + 1].value() + dat[2 * k + 2].value();
    }
    int sum(int a, int b, int k, int l, int r) {
      if (b <= l || r <= a) return 0;
      if (a <= l && r <= b)
        return dat[k].value();
      dat[2 * k + 1].uniform += dat[k].uniform;
      dat[2 * k + 2].uniform += dat[k].uniform;
      dat[k].sum += dat[k].uniform * dat[k].size;
      dat[k].uniform = 0;
      auto const m = (l + r) / 2;
      return sum(a, b, 2 * k + 1, l, m) + sum(a, b, 2 * k + 2, m, r);
    }
  public:
    void add(int a, int b, int x) {
      add(a, b, x, 0, 0, sz);
    }
    int sum(int a, int b) {
      return sum(a, b, 0, 0, sz);
    }
    segtree(int n) {
      sz = 1;
      while (sz < n) sz *= 2;
      dat.resize(2 * sz - 1);
      for (int i = sz - 2; i >= 0; i--)
        dat[i].size = dat[2 * i + 1].size + dat[2 * i + 2].size;
    }
};

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  segtree stree(n);
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      stree.add(s - 1, t, x);
    }
    else {
      int s, t;
      cin >> s >> t;
      cout << stree.sum(s - 1, t) << '\n';
    }
  }
}

Measured memory_bytes: 8920
#include <iostream>

using namespace std;

int main(){
  int n,k,matrix[105][105];

  while(1){
    bool out = true;
    cin >> n >> k;
    if(!(n|k)) break;

    for(int i=0;i <= n;i++){
      for(int j=0;j < k;j++){
        cin >> matrix[i][j];
      }
    }

    for(int i=0;i < k;i++){
      int sum = 0;
      for(int j=1;j <= n;j++){
        sum += matrix[j][i];
      }
      if(sum > matrix[0][i]){
        out = false;break;
      }
    }

    if(out) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
 int n, i;
 int a[100];

 scanf("%d", &n);

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

printf("%d", a[n-1]);

 for(i = n - 2; i >= 0; i--)
 printf(" %d", a[i]);

printf("\n");

return 0;
}



Measured memory_bytes: 2048
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
A, B = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))
C, D = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(M)]))

C = np.array(C)
D = np.array(D)

for a, b in zip(A, B):
    c = abs(C - a)
    d = abs(D - b)
    xy = (c + d).argmin()
    print(xy + 1)


Measured memory_bytes: 13680
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
#define re register
#define il inline
#define fp(i,a,b) for(re int i=a;i<=b;++i)
#define fq(i,a,b) for(re int i=a;i>=b;--i)
using namespace std;
const int N=1e5+100;
ll n,a[N],pri[N],tot,l[N],r[N],ans;
map<ll,int>num,use;
bool vis[N];
il ll gi()
{
  re ll x=0,t=1;
  re char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
  if(ch=='-') t=-1,ch=getchar();
  while(ch>='0'&&ch<='9') x=x*10+ch-48,ch=getchar();
  return x*t;
}
il void Pre(re int n)
{
  vis[1]=1;
  fp(i,2,n)
    {
      if(!vis[i]) pri[++tot]=i;
      for(re int j=1;j<=tot&&i*pri[j]<=n;++j)
	{
	  vis[i*pri[j]]=1;
	  if(i%pri[j]==0) break;
	}
    }
}
il void split(re ll x,re int p)
{
  re ll A=1,B=1;
  fp(i,1,tot)
    {
      re int gu=0;
      while(x%pri[i]==0)
	{
	  x/=pri[i];++gu;
	}
      gu%=3;
      if(gu==1) A=A*pri[i],B=B*pri[i]*pri[i];
      if(gu==2) A=A*pri[i]*pri[i],B=B*pri[i];
      if(x<pri[i]) break;
    }
  if(x>1)
    {
      re ll t=sqrt(x);
      if(t*t==x) A=A*x,B=B*t;
      else A=A*x,B=B*x*x;
    }
  l[p]=A;r[p]=B;
  ++num[A];
}
int main()
{
  Pre(4000);
  n=gi();
  fp(i,1,n) a[i]=gi(),split(a[i],i);
  fp(i,1,n)
    if(!use[l[i]])
      {
	use[l[i]]=use[r[i]]=1;
	if(l[i]==r[i]) ++ans;
	else ans+=max(num[l[i]],num[r[i]]);
      }
  printf("%lld\n",ans);
  return 0;
}


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

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


Measured memory_bytes: 2560
//O(n^2)
#include<stdio.h>
#include<math.h>

long long n,rui[10000];

long long max( long long x,long long y ){
	if( x > y )
		return x;
	return y;
}

int main()
{
	long long i,j;
	long long ans;
	while( scanf("%lld",&n) != EOF )
	{
		if( n == 0 )break;
		ans = -10000000000;
		for( i = 0;i < n;i++ ){
			scanf("%lld",rui+i );
			if( i )rui[i] += rui[i-1];
		}
		
		for( i = 0;i < n;i++ ){
			for( j = i;j < n;j++ ){
				if( i )
					ans = max( ans, rui[j]-rui[i-1] );
				else
					ans = max( ans,rui[j] );
			}
		}
		
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

int prime[10000100];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector< int > pr;
    for( int i = 2; i <= 10000100; ++i ) {
        if( !prime[i] ) {
            pr.pb( i );
            for( int j = i * 2; j <= 10000100; j += i ) prime[j] = 1;

        }
    }

    while( true ) {
        int n;
        cin >> n;
        if( n == 0 ) break;

        int mx = 0;
        for( int i = 0; pr[i + 3] <= n; ++i ) {
            if( pr[i] + 2 == pr[i + 1] &&
                pr[i] + 6 == pr[i + 2] &&
                pr[i] + 8 == pr[i + 3] ) mx = pr[i + 3];

        }
        cout << mx << endl;
    }

    return 0;
}





Measured memory_bytes: 45972
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}

int main() {
	ll n; cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int n;cin>>n;
    int i;
    vector<int> a(n);
    vector<int> a2(n);
    vector<int> b(n);
    vector<int> b2(n);
    bool ok=true;
    for(i=0;i<n;i++)cin>>a.at(i);
    for(i=0;i<n;i++)cin>>b.at(i);
    vector<pair<int,int>> p(n);
    for(i=0;i<n;i++)p.at(i)=make_pair(b.at(i),a.at(i));
    for(i=0;i<n;i++)
    {
        a2.at(i)=a.at(i);
        b2.at(i)=b.at(i);
    }
    sort(a2.begin(),a2.end());
    sort(b2.begin(),b2.end());
    for(i=0;i<n;i++)if(a2.at(i)>b2.at(i))ok=false;
    if(!ok)cout<<"No"<<endl;
    else
    {
        sort(p.begin(),p.end());
        vector<int> aa(n);
        for(i=0;i<n;i++)aa.at(i)=p.at(i).second;
        vector<pair<int,int>> p2(n);
        for(i=0;i<n;i++)p2.at(i)=make_pair(aa.at(i),i);
        sort(p2.begin(),p2.end());
        vector<int> rot(n);
        for(i=0;i<n;i++)rot.at(i)=p2.at(i).second;
        vector<bool> ch(n,false);
        int now=0;
        int count=0;
        ok=false;
        while(!ch.at(now))
        {
            ch.at(now)=true;
            now=rot.at(now);
            count++;
        }
        if(count<n)ok=true;
        else
        {
            for(i=0;i<n-1;i++)if(b2.at(i)>=a2.at(i+1))ok=true;
        }
        if(ok)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 4224
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    auto f = [&](ll x){
        rep(i,n)x = x / a[i] * a[i];
        return x;
    };
    if(f(1LL<<60)<2){
        cout << - 1 << endl;
        return 0;
    }
    ll b,c;
    {
        ll l = 1, r = 1LL<<60;
        while(r - l > 1){
            ll mid = (l + r) / 2;
            if(f(mid) < 2){
                l = mid;
            }else{
                r = mid;
            }
        }
        b = r;
    }
    {
        ll l = 1, r = 1LL<<60;
        while(r - l > 1){
            ll mid = (l + r) / 2;
            if(f(mid) > 2){
                r = mid;
            }else{
                l = mid;
            }
        }
        c = l;
    }
    if(b > c){
        cout << -1 << endl;
    }else{
        cout << b << " " << c << endl;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int r;
        cin >> r;
        int ans=3*r*r;
        cout << ans << '\n';
        

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  mint tmp(2);
  tmp = tmp.pow(n);
  tmp -= mint(1);
  mint fa(1), fb(1);
  rep(i, a) {
    fa *= (n - i);
    fa *= mint(i + 1).inv();
  }
  rep(i, b) {
    fb *= (n - i);
    fb *= mint(i + 1).inv();
  }
  tmp = tmp - fa - fb;
  cout << tmp.x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};


llint n, m;
UnionFind uf(200005);
map<llint, llint> mp;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	llint a, b;
	for(int i = 1; i <= m; i++){
		cin >> a >> b;
		uf.unite(a, b);
	}
	
	for(int i = 1; i <= n; i++) mp[uf.root(i)]++;
	llint ans = 0;
	for(auto it = mp.begin(); it != mp.end(); it++) ans = max(ans, it->second);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 16360
import java.util.Scanner;


public class Main {
	
	static int[][] memory;
	
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

    	int ans = 0;
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
   
        System.out.println(N/3);
		
	}

    
}

Measured memory_bytes: 23636
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,q;
char str[MAXN];
char x[MAXN][2],y[MAXN][2];
int main()
{
    scanf("%d%d",&n,&q);
    scanf("%s",str+1);
    int l=0,r=n+1;
    for(int i=0;i<q;i++)
    {
        scanf("%s",x[i]);
        scanf("%s",y[i]);
    }
    for(int i=q-1;i>=0;i--)
    {
        if(y[i][0]=='L')
        {
            if(r<=n&&x[i][0]==str[r]) r++;
            if(l<n&&x[i][0]==str[l+1]) l++;
        }
        else 
        {
            if(l>=1&&x[i][0]==str[l]) l--;
            if(r>1&&x[i][0]==str[r-1]) r--;
        }
    }
    int ans=min(n,l+n+1-r);
    printf("%d\n",n-ans);
    return 0;
}



Measured memory_bytes: 1280
/* 
    B - Contiguous Repainting
*/ 
#include <bits/stdc++.h>
#define md(x, y)  (x + y) / 2
#define ls(x)      x << 1
#define rs(x)      x << 1 | 1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
ll n, a[MAXN], k, pre[MAXN], sum[MAXN];
int main()
{
    cin >> n >> k;
    ll cur = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        if(i <= k)
            cur += a[i];
        if(a[i] > 0)
            sum[i] = sum[i - 1] + a[i];
        else 
            sum[i] = sum[i - 1];
    }
    //cur是[1, k] 区间的和.
    //     [i, k + i - 1]
    ll ans = -INF;
    for(int i = 1; i + k - 1<= n; i++)
    {
        if(i > 1)
            cur += -a[i - 1] + a[i + k - 1];
        //printf("cur = %d\n", cur);
        ll ret = sum[n] - sum[k + i - 1] + sum[i - 1];
        //printf("Ret = %d\n", ret);
        ans = max(max(ret + cur, ret + 0), ans);
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1792
/* ex 9_1
   kanon */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//スタックに格納するデータの最大数
#define SIZE 1000

//スタックの定義
typedef struct stack
{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk)
{
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem)
{
    if (stk->count >= stk->size)
    {
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else
    {
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk)
{
    char latest;
    if (stk->count <= 0)
    {
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else
    {
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void)
{
    stack stk;
    char input_char;
    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    //スタックにデータを追加
    while(1)
    {
        scanf("%c", &input_char);
        if (input_char == '\n')
            break;
        //Bがきてないならスタックに文字を追加
        //もしBがきたらスタックの一番上の文字を取り除く
        //スタックにデータがないときBがきたらなにもしない
        if (input_char != 'B')
        {
            push(&stk, input_char);
        }
        else if (stk.count > 0)
        {
            //スタックからデータを取り出す
            pop(&stk);
        }
    }


    for (int i = 0; i < stk.count; i++)
    {
        printf("%c", stk.data[SIZE - 1 - i]);
    }
    printf("\n");
    return 0;
}


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

typedef long long LL;

const int N=200005;
const int MOD=998244353;

int n,a[N],f[N];
char str[N];

int solve(int t)
{
	int s=0;
	for (int i=0;i<t;i++) s=(s*2+a[i])%MOD;
	bool flag=0;
	for (int i=t;i<n;i++)
		if (a[i]<(a[i%t]^((i/t)&1))) {flag=1;break;}
		else if (a[i]>(a[i%t]^((i/t)&1))) break;
	if (!flag) s++;
	return s;
}

int main()
{
	scanf("%d",&n);
	scanf("%s",str);
	int r=0;
	for (int i=0;i<n;i++) a[i]=str[i]-'0',r=(r*2+a[i])%MOD;;
	r++;
	for (int i=1;i<=n;i++)
		if (n%i==0&&n/i%2==1)
		{
			(f[i]+=solve(i))%=MOD;
			for (int j=i*2;j<=n;j+=i)
				if (n%j==0) (f[j]+=MOD-f[i])%=MOD;
			(r+=MOD-f[i])%=MOD;
		}
	int ans=(LL)r*n*2%MOD;
	for (int i=1;i<=n;i++)
		if (n%i==0&&n/i%2==1) (ans+=(LL)f[i]*i*2%MOD)%=MOD;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#define P pair<int,int>
using namespace std;

P b[3000];
int main() {
	int a;
	while (cin >> a, a) {
		for (int c = 0; c < a; c++) {
			int d, e; scanf("%d%d", &d, &e);
			b[c] = P(d, e);
		}
		sort(b, b+a);
		int MAX = 0;
		for (int e = 0; e < a; e++) {
			for (int f = e + 1; f < a; f++) {
				int xi = b[e].first, xj = b[f].first, yi = b[e].second, yj = b[f].second;
				int k = (xi - xj)*(xi - xj) + (yi - yj)*(yi - yj);
				if (k <= MAX)continue;
				if (binary_search(b,b+a, P(xj - yj + yi, yj + xj - xi))) {
					if (binary_search(b,b+a, P(xi - yj + yi, yi + xj - xi))) {
						MAX = k;
					}
				}
			}
		}
		printf("%d\n",MAX);
	}
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define ll long long
using namespace std;
ll sum[114514],ev[114514];
signed main(){
	int n,q;
	cin>>n>>q;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	if(n%2==1){ a.pb(-1); n++; }
	sort(a.begin(),a.end());
	vector<int> qry;
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		qry.pb(x);
	}
	for(int i=1;i<=n;i++){
		sum[i] = sum[i-1] + a[i-1];
		ev[i] = ev[i-1] + a[i-1] * ( (i-1) % 2 );
	}
	for(int i=0;i<=n;i++){
		//cout<<i<<" "<<sum[i]<<" "<<ev[i]<<endl;
	}
	for(int k=0;k<q;k++){
		int cx = qry[k];
		int lef = 0, rig = n/2 + 1;
		while(rig-lef>1){
			int mid = (lef+rig)/2;
			int tak = abs( a[n-mid] - cx );
			int aok = abs( a[n-2*mid+1] -cx);
			if( tak >= aok){
				lef = mid;
			}
			else{
				rig = mid;
			}
		}
		ll ans = 0;
		ans += ev[n-2*lef];
		ans += sum[n]-sum[n-lef];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
int main(){
    int n,m; std::cin >> n >> m;
    std::string s(n,'*');
    for(int i = 0; i < m; ++i){
        int id; char c; std::cin >> id >> c;
        --id;
        if(s[id] == '*' or (s[id] == c)){
            s[id] = c;
        } else {
            return puts("-1") * 0;
        }
    }
    for(int i = 0; i < n; ++i){
        if(i == 0){
            if(s[i] == '0' && i != n - 1) return puts("-1") * 0;
            if(s[i] == '*' && i != n - 1) s[i] = '1';
            else if(s[i] == '*') s[i] = '0';
        } else {
            s[i] = s[i] == '*' ?  '0' : s[i];
        }
    }
    std:: cout << s << std::endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;
bool check(string s)
{
	//cout<<s<<endl;
	int sz=s.size();
	for(int i=0;i<=sz/2;i++)
		if(s[i]!=s[sz-i-1]) return 0;
	return 1;
}
int main()
{
	int l;
	cin>>l;
	printf("%.8lf",l*l*l/27.0); 
	//cout<<();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000



int main(){
	
	int N,M;
	cin>>N>>M;	
	
	if(N==M)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var k int
  A := make([]int, 5)
  for i := 0; i < 5; i++ {
    fmt.Scan(&A[i])
  }
  fmt.Scan(&k)
  for i := 4; i > 1; i-- {
    if A[i]-A[0] > k {
      fmt.Println(":(")
      return
    }
  }
  fmt.Println("Yay!")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      ll n; cin>>n;
      ll m=0,a=0,r=0,c=0,h=0;
      rep(i,0,n){
            string x;
            cin>>x;
            switch(x[0]){
                  case 'M': m++; break;
                  case 'A': a++; break;
                  case 'R': r++; break;
                  case 'C': c++; break;
                  case 'H': h++; break;
            }
      }

      ll cnt= m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
      cout<<cnt<<endl;
}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date 	: June 22, 2019
 * 
 */

#include <bits/stdc++.h>

//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define _ub upper_bound
#define _lb lower_bound
#define bint long long int
#define _in(x) scanf("%lld",&x)
#define _f first
#define _s second
#define _all(x) x.begin(),x.end()
#define _pb push_back
#define _eb emplace_back
#define _mp make_pair
#define _iv(v) for(auto &i:v){cin>>i;}
#define _ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define _ovn(v) for(auto i:v){cout<<i<<endl;}
#define _euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define _eovn(v) for(auto i:v){cerr<<i<<endl;}
#define _os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define _osn(s) for(auto itr:s){cout<<itr<<endl;}
#define _eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define _eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define _rep(x) for(auto i=0 ; i<(x); ++i)
#define _repe(x) for(auto i=0; i<=(x); ++i)
#define _irep(a,b) for(auto i=(a); i<(b); ++i)
#define _irepe(a,b) for(auto i=(a); i<=(b); ++i)
#define _crep(a,b,c) for(auto i=(a); i<(b); i+=(c))
#define _crepe(a,b,c) for(auto i=(a); i<=(b); i+=(c))
#define _min(x,y) ((y) ^ (((x) ^ (y)) & (-((x) < (y)))))
#define _max(x,y) ((x) ^ (((x) ^ (y)) & (-((x) < (y)))))
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    bint a,b;
    cin>>a>>b;
    puts(a<b?"0":"10");



    return ;
}




int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 256