akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N, K;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;

  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (K < ans) {
      ans += K;
    }
    else {
      ans *= 2;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N,Alice=0,Bob=0;

  cin>>N;//カードの数

  vector<int> A(N);

  for(int i=0;i<N;i++){

  cin>>A.at(i);

  }//カードの点数入力


  sort(A.begin(),A.end(),greater<int>());
  
  for(int i=0;i<N;i++){
    
    if(i%2==0){
      Alice+=A.at(i);
    }//アリスのターン

    else{
      Bob+=A.at(i);
    }//ボブのターン
  }
   
  cout << Alice-Bob << endl;//点差
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;
int n,a[N],sz[N];Pii dp[N][4];
bool cmp(Pii x, Pii y){return x.se!=y.se?x.se<y.se:x.fi<y.fi;}
int main() {
	read(n);rep(i,1,n)read(a[i]);n++;//1..n
	dp[0][1]=Pii(0,0);sz[0]=1;
	rep(i,1,n){
		Pii cur[25];int tot=0;
		rep(j,1,sz[i-1]){
			int p[4]={0};int len=0,bas=dp[i-1][j].se;
			if(dp[i-1][j].fi+1<=a[i])p[++len]=dp[i-1][j].fi+1;
			if(dp[i-1][j].fi+1+a[i]-a[i-1]<=a[i]){
				if(dp[i-1][j].fi+1+a[i]-a[i-1]<=0)bas++;
				else p[++len]=max(dp[i-1][j].fi+1+a[i]-a[i-1],0);
			}
			p[++len]=a[i]+1;sort(p+1,p+len+1);
		//	printf("qwq %d %d\n",bas,len);
			rep(k,1,len)cur[++tot]=Pii(p[k]-1,bas+k-1);
		}
		sort(cur+1,cur+tot+1,cmp);
		rep(j,1,tot){
			int k=j;while(k+1<=tot&&cur[k+1].se==cur[j].se)k++;
			if(!sz[i]||cur[k].fi>dp[i][sz[i]].fi)dp[i][++sz[i]]=cur[k];
			j=k;
		}
	//	rep(j,1,sz[i])printf("%d:%d %d\n",i,dp[i][j].fi,dp[i][j].se);
	}
	int res=1e9;rep(i,1,sz[n])umin(res,dp[n][i].se);cout<<res<<endl;
	return 0;
}


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

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

    vector<long long> ryuka(n+1);
    ryuka[0] = 2;
    ryuka[1] = 1;
    for(int i=2; i<n+1; i++){
        ryuka[i] = ryuka[i-1] + ryuka[i-2];
    }
    cout << ryuka[n] << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

ll f(ll x, ll y, ll z){
	return x*x + y*y + z*z + x*y + y*z + z*x;
}

bool is_square_number(ll n){
	return ( (ll)( sqrt(n) ) * (ll)( sqrt(n) ) == n );
}

// main -----------------------------------------------

int main() {
	ll n;
	cin >> n;
	PREP(q, 1, n+1){
		ll ans = 0;
		PREP(x, 1, 101){
			PREP(y, 1, 101){
				ll a = 1, b = x+y, c = y*x + y*y + x*x - q;
				ll d = b*b - (4*a*c);
				if(is_square_number(d)){
					ll rd = (ll)(sqrt(d));
					if((-b + rd) % (2*a) == 0){
						if((-b + rd) / (2*a) >= 1){
							ans ++;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,q,i,j,t,l,r,cnt;
  string s;
  char c;
  cin>>n>>s>>q;
  vector<set<int>> a(26);
  for(i=0;i<n;i++) a.at(s.at(i)-'a').insert(i+1);
  for(j=1;j<=q;j++) {
    cin>>t;
    if(t==1) {
      cin>>i>>c;
      if (s.at(i-1)!=c) {
        a.at(s.at(i-1)-'a').erase(i);
        a.at(c-'a').insert(i);
        s.at(i-1)=c;
      }
    }
    else if(t==2) {
      cin>>l>>r;
      cnt=0;
      for(i=0;i<26;i++){
        auto m=a.at(i).lower_bound(l);
        if(m!=a.at(i).end() && *m<=r) cnt++;
      }
      cout<<cnt<<endl;
    }
  }
}

Measured memory_bytes: 24196
#include <iostream>
using namespace std;
int main(){
	int N,P[200][3];
	int check[101][3]={};
	cin >> N ;
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
		cin  >> P[i][j];
		check[P[i][j]][j]+=1;
		}
	}
	
	for(int i=0;i<N;i++){
		int point=0;
		for(int j=0;j<3;j++){
		
			if(check[P[i][j]][j]==1){
			point += P[i][j];
			}

		}
		cout << point << endl;
	}
		return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int N;
int memo[1000][110]; //A:1 C:2 G:3 T:4

bool agc(int prev3,int n){
    int a, b, c;
    a = prev3 / 100;
    b = (prev3 - 100 * a) / 10;
    c = (prev3 - 100 * a - 10 * b);
    if ( (b == 1 && c == 3 && n == 2) || (b == 3 && c == 1 && n == 2) || (b == 1 && c == 2 && n == 3) || (a == 1 && c == 3 && n == 2) || (a == 1 && b == 3 && n == 2))
    {
        return true;
    }else{
        return false;
    }
}

int dfs(int prev3 ,int n)
{
    if (memo[prev3][n] != -1) return memo[prev3][n];
    if (n == N) return 1;
    int ret = 0;
    FOR(i,1,5){
        if (!agc(prev3, i))
        {
            int nex3 = (prev3 - (prev3 /100)*100)*10 + i;
            //cout << nex3 << endl;
            ret = (ret + dfs(nex3, n + 1)) % MOD;
        }
    }
    memo[prev3][n] = ret;
    return ret;
}

int main()
{
    ciosup;
    cin >> N;
    REP(i,1000){
        REP(j,110){
            memo[i][j] = -1;
        }
    }
    cout << dfs(444, 0) << endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	s := nextLine()
	l, r, ans := 0, len(s)-1, 0
	for l < r {
		if s[l] != s[r] {
			ans++
		}
		l++
		r--
	}
	fmt.Println(ans)
}

func nscan(n int, val ...interface{}) {
	for _, ptr := range val {
		fmt.Scan(ptr)
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextSlice() []string {
	sc.Scan()
	return strings.Split(sc.Text(), " ")
}

func atoi(a []string) (b []int) {
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	for i := 0; i < n; i++ {
		nscan(2, &a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	for i := 0; i < n; i++ {
		nscan(2, &a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func smallest(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) string {
	if b {
		return "Yes"
	}
	return "No"
}

func yesorNO(b bool) string {
	if b {
		return "YES"
	}
	return "NO"
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int s, t, d;
    cin >> d >> t >> s;
    if (t * s >= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

bool is_integer_modf(float x)
{
  float r;
  return 0 == modf(x, &r);
}

int main()
{
  int x, n;
  cin >> x >> n;
  int p[n];
  int d[101];
  int min = 1000;
  int min_num;

  for (int i = 0; i < 101; i++)
  {
    d[i] = 0;
  }

  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
    d[p[i]] = 1;
  }

  for (int i = 0; i < 101; i++)
  {
    if (d[i] == 0)
    {
      if (abs(i - x) < min)
      {
        min = abs(i - x);
        min_num = i;
      }
    }
  }

  if (abs(101 - x) < min)
  {
    min_num = 101;
  }

  cout << min_num;

  return 0;
}

Measured memory_bytes: 3160
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String[] input = sc.next().split("");
		List<String> acgt = new ArrayList<>();
		acgt.add("A");
		acgt.add("C");
		acgt.add("G");
		acgt.add("T");
		int res = 0;
		int resTmp = 0;
		for (String string : input) {
			if (acgt.contains(string)) {
				resTmp++;
			} else {
				if (resTmp > res) {
					res = resTmp;
				}
				resTmp = 0;
			}
		}
		if (resTmp > res) {
			res = resTmp;
		}

		System.out.println(res);
	}
}


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

int main(){
  int n, m, l, r, lmax, rmin, gen;
  
  cin >> n >> m;
  
  int i = 0;
  cin >> lmax >> rmin;
  
  for(int i = 1; i < m; i++){
    cin >> l >> r;
    if(lmax < l) lmax = l;
    if(rmin > r) rmin = r;
  }
  gen = rmin - lmax + 1;
  
  if(lmax > rmin){
    cout << 0 << endl;
  }
  else{
  cout << gen << endl;
  }
}

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 r,g,w,b;
    cin >> r >> g >>w >> b;
    cout << r + g + w + b << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3096
import sys



def plus_or_minus(opr1, opr2, op):
    if op == '+':
        return opr1 + opr2
    else:
        return opr1 - opr2


A, B, C, D = map(int,list(input()))

op = ['+', '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            o2 = plus_or_minus(A, B, op[i])
            o3 = plus_or_minus(o2, C, op[j])
            o4 = plus_or_minus(o3, D, op[k])
            if o4 == 7:
                print('{}{}{}{}{}{}{}=7'.format(A, op[i], B, op[j], C, op[k], D))
                sys.exit()


Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <algorithm>

using namespace std;

int i,j,n,x[510],a[300000],b[300000],y[510];
pair<int,int> p[510];
int main(){
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> x[i];
		a[x[i]] = i;
		b[x[i]] = 1;
		y[i]=n-i;
		p[i]=make_pair(x[i],i);
	}
	
	for(i=1;i<=n*n;i++){
		if(b[i]==1){
			int cnt = a[i]-1;
			for(j=1;j<=i;j++){
				if(cnt==0){
					break;
				}
				if(b[j]==0){
					a[j] = a[i];
					b[j] = 1;
					cnt--;
				}
				if(j==i){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	sort(p,p+n);
	for(i=1;i<=n*n;i++){
		if(b[i]==0){
			for(j=1;j<=n;j++){
				if(y[p[j].second]!=0){
					y[p[j].second]--;
					a[i]=p[j].second;
					b[i]=1;
					break;
				}
			}
		}
	}
	for(i=1;i<=n*n;i++){
		b[i]=0;
	}
	for(i=1;i<=n*n;i++){
		b[a[i]]++;
		if(b[a[i]]==a[i]){
			if(i!=x[a[i]]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	
	cout << "Yes" << endl;
	for(i=1;i<=n*n;i++){
		cout << a[i] << " ";
	}
	cout << endl;
}
	

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  int ma = 0;
  for(int i=2;i<SZ(s);i += 2) {
    int sz = i / 2;
    string s1 = s.substr(0, sz);
    string s2 = s.substr(sz, sz);
    if(s1 == s2) ma = i;
  }
  cout << ma << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
const int MAXN = 1e6+10;
const int modul = 1e9+7;
long long dp[3000][3000];
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);

	dp[0][0] = 1;
	for (int i = 1;i<=2000;i++)
		for (int j = 0;j<=i;j++)
		{
			dp[i][j] = dp[i-1][j];
			if (j)dp[i][j]+= dp[i-1][j-1];
			dp[i][j] %= modul;
		}


	for (int i = 1;i<=k;i++){
		long long sol = dp[n-k+1][i] * dp[k-1][i-1];
		sol%=modul;
		printf("%lld\n",sol);
	}



	return 0;
}

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

long long N, K;
string S;

long long pow(long long N, long long K) {
    long long res = 1;
    for (int i = 0; i < K; i++)
    {
        res *= N;
    }
    return res;
}

long long com(long long N, long long R) {
    if(N < R || R < 0) return 0;
    if(R == 1) return N;
    else if(R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long solve(int i, int k, int smaller) {
    if(i == N) {
        if(k == 0) return 1;
        else return 0;
    }
    if(k == 0) return 1;

    if(smaller) return com(N-i, k) * pow(9, k);
    else {
        if(S[i] == '0') return solve(i+1, k, false);
        else {
            long long zero = solve(i+1, k, true);
            long long aida = solve(i+1, k-1, true) * (S[i] - '1');
            long long icchi = solve(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}

int main() {
    cin >> S >> K;
    N = S.size();
    cout << solve(0, K, false) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, a, b;
        cin >> n >> a >> b;
        if(n == 0)
            return 0;

        vector<bool> check(n+1, false);
        check[0] = true;
        for(int i=0; i<=n; ++i){
            if(!check[i])
                continue;
            if(i+a <= n)
                check[i+a] = true;
            if(i+b <= n)
                check[i+b] = true;
        }

        int ret = n;
        for(int i=1; i<=n; ++i){
            if(check[i])
                -- ret;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s;
  cin >> s;
  if ((s.at(2) == s.at(3)) && (s.at(4) == s.at(5)))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

ll mainmain(){
	int n;
	cin>>n;
	ll ans1;
	cin>>ans1;
	if(n==1){
		return ans1;
	}
	vint op(n-1);
	vll v(n-1);
	vint minus;
	rep(i,n-1){
		char t;
		cin>>t;
		cin>>v[i];
		if(t=='-'){
			minus.PB(i);
			op[i] = -1;
		}
		else{
			op[i] = 1;
		}
	}
	vll suf(n-1);
	for(int i=n-2; i>=0; i--){
		suf[i] = v[i];
		if(i<n-2) suf[i] += suf[i+1];
	}
	ll ans2 = -INFL;
	ll tval = ans1;
	int p = 0;
	if(minus.size()>1) rep(i,minus.size()-1){
		int l = minus[i];
		int r = minus[i+1];
		while(p<l) tval += op[p]*v[p],p++;
		ll tmp = suf[l]-suf[r];
		tmp *= -1;
		// cout<<l<<" "<<r<<endl;
		// cout<<tval<<" "<<tmp<<" "<<suf[r]<<endl;
		tmp += tval;
		tmp += suf[r];
		maxs(ans2, tmp);
	}
	ll tmp = ans1;
	rep(i,n-1) tmp += op[i]*v[i];
	maxs(ans2, tmp);
	return ans2;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    cout<<mainmain()<<endl;
}

Measured memory_bytes: 2680
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int H = nextInt();
    int W = nextInt();
    int h = nextInt();
    int w = nextInt();

    int ans = (H*W) - (h*W) - (w*H) + (h*w);

    System.out.println(ans);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool CHMAX(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool CHMIN(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vector<pair<ll, ll>> prime_factor(ll n) {
  vector<pair<ll,ll>> res;
  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0) continue;
    ll ex = 0;
    while (n % a == 0) { ++ex; n /= a; }
    res.push_back({a, ex});
  }
  if (n != 1) res.push_back({n, 1});
  return res;
}

ll counter(ll n){
  ll ans = 0;
  for(ll i=1; i<=n; i++) { n-=i; ans++; }
  return ans;
}

int main(){
  IOS;
  ll n; cin >> n;
  auto l = prime_factor(n);

  ll ans = 0;
  for (pair<ll,ll>x: l) ans += counter(x.second);
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, X, Y, x, y;
  cin >> N >> x >> y;
  X = min(x, y);
  Y = max(x, y);
  vector<int> a(N-1);
  
  int tmp;
  for(int i = 1; i <= N; i++){
    for(int j = i + 1; j <= N; j++){
      if (i==j) continue;
      tmp = min(abs(j - i), abs(X - i) + abs(Y - j)+1);
      // printf("%d %d %d\n", i, j, tmp);
      a[tmp-1]++;
    }
  }

  rep(i, N-1){
    cout << a[i] << "\n";
  }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  int cnt = 1;
  while(true){
    int w;
    cin>>w;
    if(w==0)break;
    int n;
    cin>>n;
    vi dp(w+1,-INF);
    dp[0] = 0;
    REP(_,n){
      int val,wei;
      scanf("%d,%d",&val,&wei);
      for(int i=w;i>=0;--i){
        if(i-wei<0)break;
        dp[i] = max(dp[i],dp[i-wei]+val);
      }
    }
    int mxval = 0, thenwei = 0;
    REPR(i,w+1){
      if(dp[i]>mxval){
        mxval = dp[i];
        thenwei = i;
      }
    }
    printf("Case %d:\n",cnt);
    cout<<mxval<<endl<<thenwei<<endl;
    ++cnt;
  }
  return 0;
}

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

int main()
{
    int i, n, rem, ck=0;

    cin>>n;

    while(n!=0)
    {
        rem = n%10;
        n = n/10;

        if(rem==7)
        {
            ck=1;
            break;
        }
    }

    if(ck==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main(void){
int N;
string s,u,v;
cin>>N;
cin>>s;

int x=0,y=0;
for(int i=0;i<N;i++){
  if('A'<=s[i] && s[i]<='M'){x++;}
  else if('N'<=s[i] && s[i]<='Z'){x--;}
  else if('a'<=s[i] && s[i]<='m'){y++;}
  else{y--;}
}


if(x==0 && y==0){cout<<0<<endl;return 0;}
if(x>0)for(int i=0;i<x;i++)u+="A";
else if(x<0)for(int i=0;i<-x;i++)u+="N";

if(y>0)for(int i=0;i<y;i++)v+="a";
else if (y<0)for(int i=0;i<-y;i++)v+="n";

string ret=u+v;
cout<<ret.length()<<endl<<ret<<endl;


return 0;
}


Measured memory_bytes: 3344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
using vi = vector<int>;
using vll = vector<ll>;
ll fast_exp(ll base,ll e){
    ll r=1;
    while(e>0){
        if(e%2)r=(r*base);
        base=base*base;
        e/=2;
    }
    return r;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int n;scanf("%d",&n);
    vector<double> dp(n+1);dp[0]=1;
    for(int coin=0;coin<n;coin++){
        double p_heads;
        scanf("%lf",&p_heads);
        for(int i=coin+1;i>=0;i--){
            dp[i] = (i==0 ? 0: dp[i-1]*p_heads)+dp[i]*(1-p_heads);
        }
    }
    double ans=0;
    for(int i=0;i<=n;i++){
        int tails=n-i;
        if(i>tails)ans+=dp[i];
    }
    printf("%.10lf",ans);
    
}

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

#define ll long long
#define int long long
#define f(i,l,n) for(ll i=l;i<n;i++)
#define E "\n"
#define bp __builtin_popcount
const int N = 2e3 + 5;
vector<int> graph[N];
int dp[N][N];

int32_t main()
{


    long double d,t,s;
  cin >> d >> t >> s;
  if(t*s<d) cout<<"No\n";
  else cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100005;
int assign[MAXN];

int n;

string s;

void fill() {
    for (int i = 1; i < n-1; i++) {
        if (assign[i] == 0) {  // sheep
            if (s[i] == 'o') {
                assign[i+1] = assign[i-1];
            }
            else {
                assign[i+1] = 1 - assign[i-1];
            }
        }
        else {  // wolf
            if (s[i] == 'o') {
                assign[i+1] = 1 - assign[i-1];
            }
            else {
                assign[i+1] = assign[i-1];
            }
        }
    }
}

bool check() {
    for (int i = 0; i < n; i++) {
        int ni = (i + 1) % n;
        int pi = (i + n - 1) % n;

        if (assign[i] == 0) {
            if (s[i] == 'o' && assign[pi] != assign[ni]) return false;
            if (s[i] == 'x' && assign[pi] == assign[ni]) return false;
        }
        else {
            if (s[i] == 'x' && assign[pi] != assign[ni]) return false;
            if (s[i] == 'o' && assign[pi] == assign[ni]) return false;
        }
    }
    
    return true;
}

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

    FORN(i, 2) FORN(j, 2) {
        assign[0] = i;
        assign[1] = j;

        fill();

        if (check()) {
            FORN(k, n) {
                if (assign[k] == 0) printf("S");
                else printf("W");
            }
            printf("\n");
            return 0;
        }
    }

    printf("-1\n");
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

ll Q, H, S, D, N;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> Q >> H >> S >> D >> N;
	ll vq = Q * 4;
	ll vh = H * 2;
	ll mn = min(vq, min(vh, S));
	if (mn * 2 <= D) {
		cout << mn * N << endl;
	} else {
		cout << D * (N / 2) + mn * (N % 2) << endl;
	}
	return 0;
}


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


int main(void){

	vector<int> v;
	while(1){
		int temp;
		cin >> temp;
		if(temp == 0) break;
		v.push_back(temp);
	}
	for(int i = 0; i < v.size(); i++ ){
		cout << "Case " << i+1 << ": " << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1320
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
char s[20];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int cnt=0;
	for(int i=1;i<=n;++i){
		cnt+=(s[i]=='o');
	}
	printf(15-n+cnt>=8?"YES\n":"NO\n");
	return 0;
}



Measured memory_bytes: 3788
while l = gets
  w, k = l.split.map(&:to_i)
  break if w == 0 && k == 0
  cats = Hash.new
  wall = Array.new
  wall << [0, w]
  k.times do
    l = gets.split
    s = l.shift
    if s == "s"
       id, wide = l.map(&:to_i)
      (0..wall.size-1).each do |i|
        left = wall[i][0]
        len = wall[i][1]
        if len >= wide
          cats[id] = [left, wide]
          if len > wide
            wall[i] = [left + wide, len - wide] 
          else
            wall.delete_at(i)
          end
          break
        end
      end
      if cats[id] == nil
        puts "impossible"
      else
        puts cats[id][0]
      end
    else
      id = l[0].to_i
      wall.push(cats[id])
      wall.sort!
      cnt = 0
      (wall.size - 1).times do |i|
        left = wall[i - cnt][0]
        len = wall[i - cnt][1]
        n_left = wall[i + 1 - cnt][0]
        n_len = wall[i + 1 - cnt][1]
        if left + len == n_left
          wall[i - cnt,2] = [[left, len + n_len]]
          cnt += 1
        end
      end
    end
  end
  puts "END"
end

Measured memory_bytes: 8788
N,M=map(int,input().split())

import heapq
def dijkstra_heap(s):
  #始点sから各頂点への最短距離
  dist=[float("inf")]*size_v
  used=[False]*size_v
  prev=[-1]*size_v
  dist[s]=0
  used[s]=True

  hq_edge=[]
  for v,w in graph[s]:
    heapq.heappush(hq_edge,(w,v,s))

  while hq_edge:
    min_w,min_v,u=heapq.heappop(hq_edge)
    #まだ使われてない頂点の中から最小の距離のものを探す
    if used[min_v]:
      continue

    dist[min_v]=min_w
    used[min_v]=True
    prev[min_v]=u
    for v,w in graph[min_v]:
      if not used[v]:
        heapq.heappush(hq_edge,(min_w+w,v,min_v))

  return dist,prev

ablist=[]
graph=[[] for _ in range(N+1)]
for _ in range(M):
  a,b=map(int,input().split())
  graph[a].append((b,1))
  graph[b].append((a,1))
  ablist.append((a,b))
#print(graph)

size_v=N+1
dist,prev=dijkstra_heap(1)
#print(dist)
#print(prev)

print("Yes")
for i in range(2,N+1):
  print(prev[i])

Measured memory_bytes: 80824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    vector<int>x(3);
    cin >> x[0] >> x[1] >> x[2];
    sort(x.begin(),x.end());
    int a=x[0],b=x[1],c=x[2];
    int ans=0;
    if(a%2==b%2&&b%2==c%2){
        int dif1,dif2;
        dif1=c-a;
        dif2=c-b;
        ans=dif1/2 + dif2/2;
    }
    else {
        if(a%2!=b%2&&a%2!=c%2){
            b++;
            c++;
            int dif1,dif2;
            dif1=c-a;
            dif2=c-b;
            ans=dif1/2 + dif2/2+1;
        }
        else if(a%2!=b%2&&b%2!=c%2){
            a++;
            c++;
            int dif1,dif2;
            dif1=c-a;
            dif2=c-b;
            ans=dif1/2 + dif2/2+1;
        }
        else{
            b++;
            a++;
            int dif1,dif2;
            dif1=c-a;
            dif2=c-b;
            ans=dif1/2 + dif2/2+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3544
class Node():
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None

    def prewalk(self):
        ret = [self.key]
        if self.left:
            ret += self.left.prewalk()
        if self.right:
            ret += self.right.prewalk()
        return ret

    def inwalk(self):
        ret = []
        if self.left:
            ret += self.left.inwalk()
        ret += [self.key]
        if self.right:
            ret += self.right.inwalk()
        return ret


class Tree():
    def __init__(self):
        self.root = None

    def insert(self, key):
        z = Node(key)
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y is None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def find(self, key):
        x = self.root
        while x and x.key != key:
            if x.key < key:
                x = x.right
            else:
                x = x.left
        return x

    def delete(self, key):
        z = self.find(key)
        y = self.successor(z) if z.left and z.right else z
        x = y.left if y.left else y.right

        if x:
            x.parent = y.parent
        if y.parent is None:
            self.root = x
        elif y == y.parent.left:
            y.parent.left = x
        else:
            y.parent.right = x
        if y != z:
            z.key = y.key

    def successor(self, x):
        if x.right:
            return self.minimum(x.right)
        y = x.parent
        while y and x == y.right:
            x = y
            y = y.parent
        return y

    def minimum(self, x):
        while x.left:
            x = x.left
        return x

    def print(self):
        print('', ' '.join(map(str, self.root.inwalk())))
        print('', ' '.join(map(str, self.root.prewalk())))


if __name__ == "__main__":
    tree = Tree()
    node_num = int(input())
    for _ in range(node_num):
        command, *value = input().split()
        if "insert" == command:
            tree.insert(int(value[0]))
        elif "find" == command:
            print('yes' if tree.find(int(value[0])) else 'no')
        elif "delete" == command:
            tree.delete(int(value[0]))
        elif "print" == command:
            tree.print()
        else:
            pass



Measured memory_bytes: 117544
#include <iostream>
using namespace std;
typedef long long ll;
#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  int d = 0;
  for (ll i = n; i > 0; i >>= 1) d++;
  int dp[d][3] = {};
  dp[d-1][0] = 1;
  dp[d-1][1] = 1;
  for (int i = d-2; i >= 0; i--) {
    int b = n >> i & 1;
    if (b == 0) {
      dp[i][0] = (1LL*dp[i+1][0] + dp[i+1][1]) % MOD;
      dp[i][1] = dp[i+1][1];
      dp[i][2] = (dp[i+1][1] + 1LL*dp[i+1][2]*3) % MOD;
    }
    else {
      dp[i][0] = dp[i+1][0];
      dp[i][1] = (1LL*dp[i+1][0] + dp[i+1][1]) % MOD;
      dp[i][2] = (1LL*dp[i+1][1]*2 + 1LL*dp[i+1][2]*3) % MOD;
    }
  }
  int sum = 0;
  for (int j = 0; j < 3; j++)
    sum = (1LL*sum + dp[0][j]) % MOD;
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      	char[] s = in.next().toCharArray();
      	char[] output = new char[s.length];
      	int k=0;
		 for(int i = 0;i<s.length;i++){
         	if(s[i]!='B'){
           		output[k++] = s[i]; 
            }
           else{
             if(k>0)
           		k--;
           }
         }
      		for(int i =0;i<k;i++){
            	System.out.print(output[i]);
            }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	long N,K; cin >> N >> K;
	
	long minSum = 0;
	long maxSum = 0;
	long ans = 0;
	for (long i = K; i <= N + 1; i++) {
		minSum = (i * (i - 1) / 2) % MOD;	
		minSum *= 2;
		minSum %= MOD;
		ans += (i * N) % MOD  - minSum + 1;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
  int ret, N;

  ret = scanf("%d",&N);
  N %= 10;
  switch(N) {
  case 3:
    printf("bon\n");
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    printf("pon\n");
    break;
  default:
    printf("hon\n");
    break;
  }
  return 0;
}



Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.List;
import java.util.Map;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> firstRow = Arrays.asList(br.readLine().split(" "));
            int N = Integer.parseInt(firstRow.get(0));
            int M = Integer.parseInt(firstRow.get(1));
            List<String> heightInputList = Arrays.asList(br.readLine().split(" "));
            Map<Integer, Integer> heightMap = new HashMap<>();
            Map<Integer, Boolean> goodTowerMap = new HashMap<>();
            int towerNumber = 1;
            for (String str : heightInputList) {
                heightMap.put(towerNumber, Integer.parseInt(str));
                goodTowerMap.put(towerNumber, true);
                towerNumber++;
            }

            List<List<String>> passList = new ArrayList<>();
            for (int i = 0; i < M; i++) {
                passList.add(Arrays.asList(br.readLine().split(" ")));
            }

            for (List<String> list : passList) {
                int i = Integer.parseInt(list.get(0));
                int j = Integer.parseInt(list.get(1));
                if (heightMap.get(i).intValue() > heightMap.get(j).intValue()) {
                    goodTowerMap.put(j, false);
                } else if (heightMap.get(i).intValue() < heightMap.get(j).intValue()) {
                    goodTowerMap.put(i, false);
                } else if (heightMap.get(i).intValue() == heightMap.get(j).intValue()) {
                    goodTowerMap.put(i, false);
                    goodTowerMap.put(j, false);
                }
            }

            int count = 0;
            for (Map.Entry<Integer, Boolean> entrySet : goodTowerMap.entrySet()) {
                if (entrySet.getValue()) {
                    count++;
                }
            }

            System.out.println(count);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 85736
s = input()
n = len(s)

if n == 2 and s[0] == s[1]:
    print(1, 2)
    exit()

for i in range(n - 2):
    if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
        print(i + 1, i + 3)
        exit()

print(-1, -1)

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

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) begin(v),end(v)

vector<bool> is_prime;

void make_primes(int n){
  is_prime.resize(n+1,true);
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(!is_prime[i])continue;
    for(int j=2;j*i<=n;j++){
      is_prime[i*j]=false;;
    }
  }
}

int main()
{
  make_primes(1000000);
  while(true){
    int a,d,n;
    cin>>a>>d>>n;
    if(a==0 and d==0 and n==0)break;
    int cnt=0;
    for(int i=a;;i+=d){
      if(is_prime[i]){
        cnt++;
        if(cnt==n){
          cout<<i<<endl;
          break;
        }
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 1320
#include<stdio.h>
#define N 100001

int A[N];

int Partition(int A[], int p, int r){
  int x, i, j, temp;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }  
  temp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = temp;
  return i + 1;
}

int main(){
  int n, i, q;
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
 q = Partition(A, 0, i - 1);
  for(i = 0; i < n; i++){
    if(i == q) printf("[%d]", A[i]);
    else printf("%d", A[i]);
    if(i < n - 1)printf(" ");
  }
  printf("\n");
  return 0;
}

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

int main(){
int N;
cin>>N;

vector<int> K(N);
for(int i=0;i<N;i++){
  cin>>K[i];
}
for(int i=0;i<N;i++){
  if(K[i]%2==0){
    if(!((K[i]%3==0)||(K[i]%5==0))){
        cout<<"DENIED"<<endl;
        return 0;
    }
  }
}


  cout<<"APPROVED"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;

    int n = s.size();
    int p[3] = {};
    for (int i = 0; i < n; i++) {
        p[s[i] - 'a']++;
    }

    sort(p, p + 3);

    cout << (p[2] - p[0] <= 1 ? "YES" : "NO") << endl;

    return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL powm(LL x, LL y){
  if(y == 0) return 1;
  return powm(x*x%MOD, y/2) * (y%2==0?1:x) % MOD;
}

LL inv(LL x){
  return powm(x,MOD-2);
}

LL dp[5010][5010];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  string S; cin >> S;
  int M = SZ(S);

  dp[0][0] = 1;
  REP(i,N) REP(j,i+2)
	if(j > 0)
	  dp[i+1][j] = (dp[i][j-1]*2 + dp[i][j+1]) % MOD;
	else
	  dp[i+1][0] = (dp[i][0] + dp[i][1]) % MOD;

  cout << dp[N][M] * inv(powm(2,M)) % MOD << endl;
  
  return 0;
}


Measured memory_bytes: 116992
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
string s[2];
long long n,g[60][8]={0},f[60][4]={0},res;

int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	cin>>s[0];
	cin>>s[1];
	if (s[0][0] == s[0][1]){
		g[0][1] = g[0][2] = g[0][3] = g[0][4] = g[0][5] = g[0][6] = 1;
	} else{
		f[0][1] = f[0][2] = f[0][3] = 1;
	}
	for (int i=1; i<n; i++){
		if (s[0][i] == s[0][i-1]){
			g[i][1] = g[i-1][1];
			g[i][2] = g[i-1][2];
			g[i][3] = g[i-1][3];
			g[i][4] = g[i-1][4];
			g[i][5] = g[i-1][5];
			g[i][6] = g[i-1][6];
		} else{
			if (s[0][i] == s[1][i]){
				if (s[0][i-1] == s[1][i-1]){
					f[i][1] = (f[i-1][2]%mod + f[i-1][3]%mod)%mod;
					f[i][2] = (f[i-1][1]%mod + f[i-1][3]%mod)%mod;
					f[i][3] = (f[i-1][1]%mod + f[i-1][2]%mod)%mod;
				} else{
					f[i][1] = (g[i-1][3]%mod + g[i-1][4]%mod)%mod;
					f[i][2] = (g[i-1][5]%mod + g[i-1][6]%mod)%mod;
					f[i][3] = (g[i-1][1]%mod + g[i-1][2]%mod)%mod;
				}
			} else{
				g[i][1] = (g[i-1][2]%mod + g[i-1][4]%mod + g[i-1][5]%mod + f[i-1][3]%mod)%mod;
				g[i][2] = (g[i-1][1]%mod + g[i-1][3]%mod + g[i-1][6]%mod + f[i-1][3]%mod)%mod;
				g[i][3] = (g[i-1][2]%mod + g[i-1][4]%mod + g[i-1][6]%mod + f[i-1][1]%mod)%mod;
				g[i][4] = (g[i-1][1]%mod + g[i-1][3]%mod + g[i-1][5]%mod + f[i-1][1]%mod)%mod;
				g[i][5] = (g[i-1][1]%mod + g[i-1][4]%mod + g[i-1][6]%mod + f[i-1][2]%mod)%mod;
				g[i][6] = (g[i-1][2]%mod + g[i-1][3]%mod + g[i-1][5]%mod + f[i-1][2]%mod)%mod;
				//cout<<g[i][1]<<endl;
			}
		}
	}
	res = (f[n-1][1]%mod + f[n-1][2]%mod + f[n-1][3]%mod + g[n-1][1]%mod + g[n-1][2]%mod + g[n-1][3]%mod + g[n-1][4]%mod + g[n-1][5]%mod + g[n-1][6]%mod)%mod;
	cout<<res<<"\n";
}

Measured memory_bytes: 256