akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>

struct TPoint
{
	double X;
	double Y;
};

TPoint GetLeft(TPoint Left,TPoint Right)
{
	TPoint Result;
	Result.X = (Left.X * 2 + Right.X) / 3;
	Result.Y = (Left.Y * 2 + Right.Y) / 3;
	return Result;
}

void Turn(TPoint& Vector)
{
    double TempX = (Vector.X - (std::sqrt)(3.) * Vector.Y) / 2;
    double TempY = ((std::sqrt)(3.) * Vector.X + Vector.Y) / 2;
    Vector.X = TempX;
	Vector.Y = TempY;
}
 
TPoint GetCenter(const TPoint& Left,const TPoint& Right)
{
    TPoint Vector;
	Vector.X = GetLeft(Left,Right).X - Left.X;
	Vector.Y = GetLeft(Left,Right).Y - Left.Y;
    Turn(Vector);
	TPoint Result;
	Result.X = GetLeft(Left,Right).X + Vector.X;
	Result.Y = GetLeft(Left,Right).Y + Vector.Y;
	return Result;
}
 
TPoint GetRight(const TPoint& Left,const TPoint& Right)
{
	TPoint Result;
	Result.X = (Left.X + Right.X * 2) / 3;
	Result.Y = (Left.Y + Right.Y * 2) / 3;
	return Result;
}

void OutputKochCurve(TPoint Left,TPoint Right,int N)
{
	if(N < 1) return;
	OutputKochCurve(Left,GetLeft(Left,Right),N-1);
	std::cout << GetLeft(Left,Right).X << " " << GetLeft(Left,Right).Y << std::endl;
	OutputKochCurve(GetLeft(Left,Right),GetCenter(Left,Right),N-1);
	std::cout << GetCenter(Left,Right).X << " " << GetCenter(Left,Right).Y << std::endl;
	OutputKochCurve(GetCenter(Left,Right),GetRight(Left,Right),N-1);
	std::cout << GetRight(Left,Right).X << " " << GetRight(Left,Right).Y << std::endl;
	OutputKochCurve(GetRight(Left,Right),Right,N-1);
}

int main()
{
	int N;
	std::cin >> N;
	std::cout << 0 << " " << 0 << std::endl;
	TPoint Left = {0.,0.};
	TPoint Right = {100.,0.};
	OutputKochCurve(Left,Right,N);
	std::cout << 100 << " " << 0 << std::endl;
	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t A, B, C, K, ans;
  cin >> A >> B >> C >> K;
  if (K <= A) {
    ans = K;
  }
  else if (A < K && K <= A + B) {
    ans = A;
  }
  else {
    ans = A - (K - A - B);
  }
  cout << ans << endl;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const ll MAX = 100010;
const ll INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

ll weight[MAX], val[MAX];
ll n,w;
ll dp[105][MAX];

ll call(ll pos,ll left) {
    if(left<0) return -INF;
    if(pos>n) return 0;
    if(dp[pos][left]!=-1) return dp[pos][left];
    ll ret = max(val[pos] + call(pos+1,left-weight[pos]),call(pos+1,left));
    return dp[pos][left] = ret;
}

int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    sll(n,w);

    for(ll i=1;i<=n;i++) {
        sll(weight[i],val[i]);
    }
    SET(dp);

    cout << call(1,w) << endl;

    return 0;
}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

void solve(long long A, long long B, long long C) {
  cout << min(B / A, C) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    if(n < 100){
        Cout(min(n, 9));
    }
    else if(n < 10000){
        Cout(9 + min(900, n-99));
    }
    else{
        Cout(909 + min(90000, n-9999));
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
#define ttttyyyy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fo(i,n,m) for(int i=n;i<m;i++)
#define pb(x) push_back(x)
#define mk(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define ft first
#define se second
#define ci(x) int x; cin>>x
int main(){
    ttttyyyy
    ll n;cin>>n;
    cout<<n*6.28318530717958623200<<endl;
    return 0;
}



Measured memory_bytes: 3800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * The Balance
 */
public class Main {

	static final int INF = 1 << 29;
	static int xmin = 0;
	static int ymin = 0;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int a, b, d;
			a = parseInt(st.nextToken());
			b = parseInt(st.nextToken());
			d = parseInt(st.nextToken());
			if ((a | b | d) == 0) break;

			solve1(a, b, d);
			if (xmin == 0 && ymin == 0) {
				solve2(a, b, d);
			}
			System.out.println(xmin + " " + ymin);

		} //end while
	} //end main

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

	static void solve1(int a, int b, int d) {
		int g = gcd(a, b);
		int xmax = b / g;
		int ymax = a / g;

		int min = INF;
		xmin = ymin = 0;
		for (int i = -xmax; i <= xmax; i++) {
			for (int j = -ymax; j <= ymax; j++) {
				int c = a * i - b * j;
				if (c == d || c == -d) {
					if (Math.abs(i) + Math.abs(j) < min) {
						min = Math.abs(i) + Math.abs(j);
						xmin = Math.abs(i);
						ymin = Math.abs(j);
					}
				}
			}
		}
	}

	static void solve2(int a, int b, int d) {
		int g = gcd(a, b);
		int xmax = d / a;
		int ymax = d / b;

		int min = INF;
		xmin = ymin = 0;
		for (int i = -xmax; i <= xmax; i++) {
			for (int j = -ymax; j <= ymax; j++) {
				int c = a * i - b * j;
				if (c == d || c == -d) {
					if (Math.abs(i) + Math.abs(j) < min) {
						min = Math.abs(i) + Math.abs(j);
						xmin = Math.abs(i);
						ymin = Math.abs(j);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 25732
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class ADodecagon {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int r;
        cin>>r;
        cout<<3*r*r<<endl;
    }
};

int main() {
	ADodecagon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long int n, a, b;
	cin >> n >> a >> b;
	long int sum = a + b;
	long int c, d;
	c = a * (n / sum);
	d = n % sum;
	if(a > d){
	cout << c + d;
		}
	else{
		cout << c + a;
		}
	}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<int> graph[100000];
vector<int> size(100000, -1);
int dfs(int s) {
  if (size[s] == -1) {
    size[s] = 0;
    for (auto t : graph[s]) {
      size[s] = max(size[s], dfs(t)+1);
    }
  }
  return size[s];
}

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

  int n,m; cin>>n>>m;
  for (int i = 0; i < m; i++) {
    int x,y; cin>>x>>y; x--; y--;
    graph[x].push_back(y);
  }
  for (int i = 0; i < n; i++) {
    dfs(i);
  }
  cout << *max_element(size.begin(), size.end()) << endl;

  return 0;
}


Measured memory_bytes: 8192
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ab[100010],ac[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc,sd[1000];
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>sd[i];
    }
    
    for(int i=0;i<n;i++){
        C sd[i] E;
        C sd[i] E;
    }
    
}

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

int main(){
    string a;
    cin>>a;
    if (a=="a" ||a=="i" ||a=="u" || a=="e" ||a=="o") {
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int k, n;
  cin >> k >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int max = 0;
  int num1 = 0;
  int num2 = 0;
  for (int j = 0; j < n - 1; j++) {
    num1 = a[j + 1] - a[j];
    // cout << "num1=" << num1 << endl;
    if (num1 > max) max = num1;
    // cout << max << endl;
  }
  num2 = k - (a[n - 1] - a[0]);
  if (max < num2) max = num2;
  // cout << max << endl;
  cout << k - max;
  return 0;
}

// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp
/*
for (int i = 0; i < n - 2; i++) {
  for (int j = i + 1; j < n - 1; j++) {
    int k = 2 * j - i;*/
/* vector<int>a(n);
   cin>>a.at(n);*/
/* queue<long long> q;
for(i=0;i<n-1;i++){
        pop = q.front();
        if(pop%10!=0) q.push(pop*10 + pop%10 -1);
        q.push(pop*10+pop%10);
        if(pop%10 != 9) q.push(pop*10 + pop%10 + 1);
        q.pop();
    }*/

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <climits>

using namespace std;

int jump(vector<int>* p_heights, int steps){

    vector<int> table(p_heights->size(), 0);

    table[0] = 0;
    for(int i = 1; i < (int)p_heights->size(); i++){

        int min = INT_MAX;
        for(int j = i-1; (j >= (i-steps)) && (j >= 0); j--){
            int diff = abs((*p_heights)[i] - (*p_heights)[j]);
            int cost = table[j]+diff;
            if(cost < min)
                min = cost;
         
        }
        table[i] = min;

        //cout << "table[" << i << "]=" << table[i] << "\n";
    }

    return table.back();
}

int main(){

    int n, k;
    vector<int> heights;

    cin >> n >> k;
    heights = vector<int>(n);

    for(int i = 0; i < n; i++)
        cin >> heights[i];

    int cost = jump(&heights, k);
    cout << cost << "\n";

    return 0;
}


Measured memory_bytes: 1024
// ------------------------------------
// Date:2018/ 3/13
// Problem:ABC 069 GridColoring d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;
static const int MAX_N = 101;

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

// c[hi][wi];
int c[MAX_N][MAX_N] = {-1};

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

  int H, W, N;
  cin >> H >> W >> N;
  vector< int > A(N);
  REP(i, N) {
    cin >> A[i];
  }
    
  int tmp = 0;
  REP(hi, H) {
    REP(wi, W) {
      c[hi][wi] = tmp + 1;
      A[tmp]--;
      if (A[tmp] <= 0) {
	tmp++;
      }
    }
  }

  bool order = true;
  REP(hi, H) {
    REP(wi, W) {
      if (order) {
	cout << c[hi][wi];
      } else {
	cout << c[hi][W - wi - 1];
      }
      if (wi != W - 1) cout << " ";
    }
    order = !order;
    cout << endl;
  }
  return 0;
}



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

lights = []
for i in range(m):
    lights.append(list(map(int, input().split())))

p = list(map(int, input().split()))


switches = [[] for i in range(n)]
for idx, light in enumerate(lights):
    for i in range(n):
        if i + 1 in light[1:]:
            switches[i].append(idx)


def sw(nom):
    ret = []
    for i in range(11):
        if nom >> i & 1 == 1:
            ret.append(i)
    return ret


ans = 0
for i in range(1 << n):
    swNoms = sw(i)
    pp = [0 for i in range(m)]
    for swNom in swNoms:
        for lightNom in switches[swNom]:
            pp[lightNom] += 1
    if p == list(map(lambda x: x % 2, pp)):
        ans += 1

print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;

//第二回全国統一プログラミング王決定戦予選
//A	Sum of Two Integers
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int ans = (N / 2);
		if (N % 2 == 0) {
			ans--;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	string S;
	cin >> S;

	for (int i = 0; i < 3; i++) {
		if (S[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int l,r,d;
    cin>>l>>r>>d;
    int ans =0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int SIZE = 500001;
const int K = 26;
int A[K][SIZE + 1];
#define LSB(i) ((i) & -(i))
char tab[SIZE + 1];

int sum(int ch, int i) // Returns the sum from index 1 to i
{
    int sum = 0;
    while (i > 0) 
        sum += A[ch][i], i -= LSB(i);
    return sum;
}

int rangeSum(int ch, int l, int r) {
	return sum(ch, r) - sum(ch, l - 1);
}
 
void add(int ch, int i, int k) // Adds k to element with index i
{
    while (i <= SIZE) 
        A[ch][i] += k, i += LSB(i);
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	scanf("%d", &n);
	scanf("%s", tab + 1);
	FOR(i, 1, n) {
		add(tab[i] - 'a', i, 1);
	}
	int q;
	scanf("%d", &q);
	REP(i, q) {
		int typ;
		scanf("%d", &typ);
		if (typ == 1) {
			int id;
			char nc;
			scanf("%d %c", &id, &nc);
			char prevc = tab[id];
			add(prevc - 'a', id, -1);
			tab[id] = nc;
			add(nc - 'a', id, 1);
		} else {
			int l,r;
			scanf("%d %d",&l, &r);
			int wyn = 0;
			REP(c, K) {
				int d = rangeSum(c, l, r);
				if (d > 0) wyn += 1;
			}
			printf("%d\n", wyn);
		}
	} 
}

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

int main(void) {
	int n, m;
	int i, j;
	int sum = 0, max = 0;
	int price[1000];

	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;

		for (i = 0; i<n; i++) {
			cin >> price[i];
		}

		for (i = 0; i<n - 1; i++) {
			for (j = i + 1; j<n; j++) {
				sum = price[i] + price[j];
				if (max<sum&&sum <= m) {
					max = sum;
				}
			}
		}

		if (max == 0) {
			cout << "NONE" << endl;
		}
		else {
			cout << max << endl;
		}
		max = 0;
		sum = 0;
	}
	return 0;
}



Measured memory_bytes: 3056
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int X, t;
	cin >> X >> t;
	cout << max(0, X - t) << endl;
}

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



int main() {
int N;
cin >> N;
ll A=2;
ll B=1;
ll luca;
for(int i = 1;i<N;i++){
luca = A + B;
A = B;
B = luca;
}
if(N == 1)luca = 1;
cout << luca << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int col = n;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i-1]) {
            a[i] = col++;
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        for(int j=0; j<s.size(); j++){
            if(s[i]==s[j]&&i!=j){
                printf("no\n");
                goto END;
            }
        }
    }
    printf("yes\n");
END:
    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  vector<pair<int, int>> f, t;
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      cin >> a[i][j];
  for(int i = 0; i < h; i++) {
    if(i & 1) {
      for(int j = 0; j < w; j++) {
        if(a[i][j] % 2 && (j != w - 1 || i != h - 1)) {
          f.push_back({i, j});
          a[i][j]--;
          if(j != w - 1) {
            t.push_back({i, j + 1});
            a[i][j + 1]++;
          } else {
            t.push_back({i + 1, j});
            a[i + 1][j]++;
          }
        }
      }
    } else {
      for(int j = w - 1; j >= 0; j--) {
        if(a[i][j] % 2 && (j != 0 || i != h - 1)) {
          f.push_back({i, j});
          a[i][j]--;
          if(j != 0) {
            t.push_back({i, j - 1});
            a[i][j - 1]++;
          } else {
            t.push_back({i + 1, j});
            a[i + 1][j]++;
          }
        }
      }
    }
  }
  printf("%d\n", (int)f.size());
  for(int i = 0; i < f.size(); i++)
    printf("%d %d %d %d\n", f.at(i).first + 1, f.at(i).second + 1,
           t.at(i).first + 1, t.at(i).second + 1);
}

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

template <int MAX_N>
struct union_find {
    int par[MAX_N], N;

    union_find(int n): N(n) {
        for (int i = 0; i < N; ++i) {
            par[i] = -1;
        }
    }

    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool unite(int x, int y) {
        int xx = find(x), yy = find(y);

        if (xx == yy) return false;
        if (par[xx] < par[yy]) {
            par[yy] = xx;
        } else {
            if (par[xx] == par[yy]) {
                --par[yy];
            }
            par[xx] = yy;
        }
        return true;
    }
};

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

    union_find<101010> uf(N);

    for (int j = 0; j < Q; ++j) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            uf.unite(x, y);
        } else {
            cout << (uf.same(x, y) ? 1 : 0) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define debug(x) ;
//#define debug(x) cerr << #x << " = " << x << "\n";

const int maxN = 5011;
const ll mod = 1000000007;

void add(ll& a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

struct local_data {
    vector<ll> dp[2];

    void init() {
        dp[0] = {0, 1};
        dp[1] = {0, 0};
    }

    local_data operator*(const local_data& who) {
        local_data ans;
        int i, j, a, b, l1, l2;
        
        l1 = dp[0].size();
        l2 = who.dp[0].size();

        ans.dp[0] = ans.dp[1] = vector<ll>(l1 + l2 - 1, 0);

        for (a = 0; a < 2; a++) 
            for (i = 0; i < l1; i++) 
                for (b = 0; b < 2; b++) 
                    for (j = 0; j < l2; j++) 
                        add(ans.dp[a ^ b][i + j], (dp[a][i] * who.dp[b][j]) % mod);

        return ans;
    }
};

int n, i, x, y;
vector<int> list[maxN];
ll cnt[maxN];
local_data data[maxN];
ll sol;

ostream& operator<<(ostream& cerr, vector<ll> aux) {
    cerr << "[";
    for (auto e : aux) cerr << e << ' ';
    cerr << "]";

    return cerr;
}

ll poww(ll a, ll b) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1) ans = (ans * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    } 
    return ans;
}

void pre() {
    int i;

    cnt[0] = 1;
    for (i = 2; i <= n; i++) {
        cnt[i] = (cnt[i - 2] * (i - 1)) % mod;
    }

    for (i = 1; i <= n; i++) {
        debug(i);
        debug(cnt[i]);
    }
}

void dfs(int node, int root) {
    int len;
    data[node].init();

    for (auto to : list[node]) {
        if (to == root) continue;
        dfs(to, node);
        data[node] = data[node] * data[to];
    }

    debug(node);
    debug(data[node].dp[0]);
    debug(data[node].dp[1]);
   
    len = data[node].dp[0].size();
    for (i = 2; i < len; i += 2) {
        add(data[node].dp[1][0], (data[node].dp[0][i] * cnt[i]) % mod);
        add(data[node].dp[0][0], (data[node].dp[1][i] * cnt[i]) % mod);
    }

    debug(node);
    debug(data[node].dp[0]);
    debug(data[node].dp[1]);
}

int main()
{
    //freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        list[x].pb(y);
        list[y].pb(x);
    }

    pre();
    dfs(1, 0);
    sol = data[1].dp[1][0] + mod - data[1].dp[0][0];
    sol %= mod;

    cout << sol;

    return 0;
}

Measured memory_bytes: 138496
using System;
using static System.Console;
public class Hello{
    public static void Main(){
//        string[] a = ReadLine().Split(' ');
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
//        int z = int.Parse(a[2]);
        x %= 500;
        if(x<=y){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int taro = 0, hanako = 0;
    for (int i = 0; i < n; i++) {
        string a, b; cin >> a >> b;
        if (a == b) { taro++; hanako++; }
        else if (a < b) { hanako += 3; }
        else { taro += 3; }
    }
    cout << taro << " " << hanako << endl;
    return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N,A;
	cin>>N>>A;
	ce(N*N-A)
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main()
{
    int n, m; cin >> n >> m;
    cout << (1900 * m  + 100 * (n-m)) * pow(2, m) << endl;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    n=n*(n-1)/2;
    m=m*(m-1)/2;
    ll ans=n+m;
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{  
	long long ans,M;
	cin >> ans >> M;

	for(long long i=0;i<M;i++){
		long long c;
		cin >> c;
		ans-=c;
	}

	if(ans>=0)	cout<<ans <<endl;
	else cout<<-1 <<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>

using namespace std;


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

    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'o') cnt++;
    }
    int x = 15 - s.size();

    if(x + cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}



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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

#define gcd __gcd

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= n; j++)
  for (int k = 1; k <= n; k++) {
    ans += gcd(gcd(i, j), k);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3648
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()

    val x = Array.ofDim[(Int, Int)](N)
    val y = Array.ofDim[(Int, Int)](N)
    (0 until N) foreach { i =>
      x(i) = (sc.nextInt(), i)
      y(i) = (sc.nextInt(), i)
    }
    Sorting.quickSort(x)(Ordering.by(_._1))
    Sorting.quickSort(y)(Ordering.by(_._1))

    type Edge = (Int, (Int, Int))
    def e(a: Array[(Int, Int)], i: Int, j: Int): Edge = {
      val c = abs(a(i)._1 - a(j)._1)
      val u = a(i)._2
      val v = a(j)._2
      (c, u -> v)
    }

    val q = mutable.PriorityQueue[Edge]()(Ordering.by[Edge, Int](_._1).reverse)
    (0 until N - 1) foreach { i =>
      val j = i + 1
      q.enqueue(e(x, i, j))
      q.enqueue(e(y, i, j))
    }

    var ans: Long = 0
    var n: Int = 0
    val uf = new UnionFind(N)
    while(n < N -1) {
      val (c, (u, v)) = q.dequeue()
      if (uf.find(u) != uf.find(v)) {
        uf.unite(u, v)
        ans += c
        n += 1
      }
    }

    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  class UnionFind(n: Int) {
    private val par = Array.iterate(0, n)(_ + 1)
    private val rank = Array.ofDim[Int](n)

    def find(x: Int): Int = {
      if (par(x) == x) x
      else {
        par(x) = find(par(x))
        par(x)
      }
    }

    def unite(x: Int, y: Int): Unit = {
      val x1 = find(x)
      val y1 = find(y)
      if (x1 != y1) {
        if (rank(x1) < rank(y)) {
          par(x1) = y1
        } else {
          par(y1) = x1
          if (rank(x1) == rank(y1)) rank(x1) += 1
        }
      }
    }
  }
}


Measured memory_bytes: 147228
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <functional>
#include <set>

class item {
public:
  std::int_fast64_t weight;
  std::int_fast64_t value;
  friend std::istream& operator>>(std::istream& is, item& self) {
    return is >> self.weight >> self.value;
  }
};

int main() {
  std::int_fast64_t n, w;
  std::cin >> n >> w;
  std::vector<item> items(n);
  std::copy_n(std::istream_iterator<item>(std::cin), n, items.begin());

  std::set<std::int_fast64_t> possible_weights;
  for (std::int_fast64_t i = 0; i <= n; ++i) {
    for (std::int_fast64_t j = 0; j <= 3 * i; ++j) {
      possible_weights.insert(i * items[0].weight + j);
    }
  }
  std::unordered_map<std::int_fast64_t, std::int_fast64_t> reverse_map;
  {
    std::int_fast64_t i = 0;
    for (const std::int_fast64_t& weight : possible_weights) {
      reverse_map[weight] = i;
      ++i;
    }
  }
  auto not_greater_than = [&](const std::int_fast64_t x) {
    std::set<std::int_fast64_t>::iterator it = possible_weights.lower_bound(x);
    return *it == x ? x : *(--it);
  };

  std::vector<std::vector<std::int_fast64_t>> dp(n + 1, std::vector<std::int_fast64_t>(possible_weights.size(), -1));
  std::function<std::int_fast64_t(std::int_fast64_t, std::int_fast64_t)> solve;
  solve = [&](const std::int_fast64_t i, const std::int_fast64_t capacity) {
    const std::int_fast64_t j = reverse_map[not_greater_than(capacity)];
    if (dp[i][j] >= 0) {
      return dp[i][j];
    }
    std::int_fast64_t result;
    if (i == n) {
      result = 0;
    } else if (capacity < items[i].weight) {
      result = solve(i + 1, capacity);
    } else {
      result = std::max(solve(i + 1, capacity), solve(i + 1, capacity - items[i].weight) + items[i].value);
    }
    return dp[i][j] = result;
  };

  std::cout << solve(0, w) << std::endl;
  return 0;
}

Measured memory_bytes: 13952
var k,s,x,y,z,total,sum,i,j:longint;
begin
    total:=0;
    sum:=0;
    readln(k,s);
    for i:=0 to k do
    begin
        if s<i then
            break;
        for j:=0 to k do
        begin
            total:=i+j;
            if (total > s) then
                break;
            if (s-total<=k) then
                inc(sum);
        end;
        
    end;
    writeln(sum);
end.

Measured memory_bytes: 1376
<?php

$a = rtrim(fgets(STDIN));
$b = rtrim(fgets(STDIN));
$x = explode(" ", $b);

$f = "Yes";
for($i = 0; $i < count($x); $i++){
    if( $i == 0) continue;
    if($x[($i-1)] < $x[$i]){
        $x[$i] = $x[$i] - 1;
    }
    if($x[($i-1)] <= $x[$i]){
        continue;
    }
    // echo "i = ". $i. "\n";
    $f = "No";
    break;
}

echo $f. "\n";


Measured memory_bytes: 14840
#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>;
using v  = vector<int>;
using vv = vector<v>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const int INF = 1001001001;

int main(){
    int n,k;cin >>n>>k;
    
    if(k==1){
        cout << 0 << endl;
        return 0;
    }
    
    cout << n-k << endl;
    
    return 0;
}

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

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

long double divLL(ll n, ll k){
    long double ans = 1.0;
    ll tmp = n;

    while(tmp < k){
        tmp *= 2;
        ans *= (long double)0.5;
    }
    return ans;

}

ll divCnt(ll n, ll k){
    ll ans = 0;
    ll tmp = n;

    while(tmp < k){
        tmp *= 2;
        ans ++;
    }
    return ans;

}


int main(){

    ll N, K;
    cin >> N >> K;

    long double ans = 0.0;
    for(ll i = 1; i <= N; i++){
        ans += divLL(i, K);
    }
    ans /= (long double)N;
    cout << std::setprecision(14) << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
using namespace std;
int k,res;
int main()
{
  
    cin>>k;
    res=0;
    FOR(i,1,k){
        FOR(j,1,k){
            FOR(z,1,k){
                int b=__gcd(__gcd(i,j),z);
                res+=b;
            }
        }
    }
    cout<<res;
 
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
char s[100];
int ans[101];
int main()
{
	int n,l=0;
	scanf("%s",s+1),n=strlen(s+1);
	for(register int i=1;i<=n;++i)
	{
		if(s[i]=='1')
			ans[++l]=1;
		if(s[i]=='0')
			ans[++l]=0;
		if(s[i]=='B'&&l)
			--l;
	}
	for(register int i=1;i<=l;++i)
		cout<<ans[i];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int x,y;
	cin >> x >> y;
	int sum = 0;
	sum += x + y;
	int a = max(x,y);
	int b = min(x,y);
	while(b != 0){
		a = a % b;
		int c = a;
		a = b;
		b = c;
	}
	cout << sum - a + 1 << endl;
	return 0;
} 


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

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



Measured memory_bytes: 3096
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,v = LI()
    b,w = LI()
    t = I()
    if v <= w:
        print("NO")
        return
    s = abs(b-a)
    k = v-w
    if s <= t*k:
        print("YES")
    else:
        print("NO")
    return

#Solve
if __name__ == "__main__":
    solve()


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x | (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

int main()
{
    int n,m;
    cin >> n >> m;
    int arr[n];
    REP(i,n) cin >> arr[i];
    int sum=0;
    REP(i,n) sum+=arr[i];
    int cnt=0;
    REP(i,n) if(arr[i]*4*m>=sum) cnt++;
    if(cnt>=m) cout << "Yes";
    else cout << "No";
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> S;

    ll ans=0;

    REP(i,S.size()){
        ll tmp=S.at(i)-'0';
        ans+=tmp;

    }
    if(ans%9==0){
        cout << "Yes" <<endl;
     }
     else{
        cout  << "No" <<endl;
     }



}  


Measured memory_bytes: 3752
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

void warshall_floyd(int n, vector<vector<int>>&d){
    rep(k, n){
        rep(i, n){
            rep(j, n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}


const ll INF = 1e12;
int main(){
    int n, c;
    cin >> n >> c;
    vector<vector<int>>cost(c, vector<int>(c));        //色変化にかかるコストの隣接行列
    vector<vector<int>>field(n, vector<int>(n));    //グリッドの色
    
    rep(i, c)rep(j, c)cin >> cost[i][j];
    rep(i, n)rep(j, n)cin >> field[i][j];

    //warshall_floyd(c, cost);

    map<int, int>remainder_0;
    map<int, int>remainder_1;
    map<int, int>remainder_2;

    rep(i, n){
        rep(j, n){
            if((i+j) % 3 == 0)remainder_0[ field[i][j] - 1 ]++;
            if((i+j) % 3 == 1)remainder_1[ field[i][j] - 1 ]++;
            if((i+j) % 3 == 2)remainder_2[ field[i][j] - 1 ]++;
        }
    }

    ll res = INF;
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            for(int k = 0; k < c; k++){
                if(i == j || j == k || k == i)continue;
                ll sum = 0;
                for(auto r : remainder_0){
                    sum += cost[r.first][i] * r.second;
                }
                for(auto r : remainder_1){
                    sum += cost[r.first][j] * r.second;
                }
                for(auto r : remainder_2){
                    sum += cost[r.first][k] * r.second;
                }

                res = min(res, sum);
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
    int l,r,d,i,s=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            s++;
        }
    }
    cout<<s<<endl;
    return 0;
}

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

int main() {
	long long		a,b,c,i,j,x,y,ans = 0;
	
	cin >> x >> y >> a >> b >> c;
	vector<int>	p(a),q(b),r(c),aa(x+y+c);
	for(i=0;i<a;i++) cin >> p[i];
	for(i=0;i<b;i++) cin >> q[i];
	for(i=0;i<c;i++) cin >> r[i];

	sort(p.begin(),p.end());
	reverse(p.begin(),p.end());
	sort(q.begin(),q.end());
	reverse(q.begin(),q.end());

	j = 0;
	for(i=0;i<x;i++) aa[j++] = p[i];
	for(i=0;i<y;i++) aa[j++] = q[i];
	for(i=0;i<c;i++) aa[j++] = r[i];

	sort(aa.begin(),aa.end());
	reverse(aa.begin(),aa.end());
	for(i=0;i<x+y;i++) ans += aa[i];

	cout << ans << endl;

}


Measured memory_bytes: 5576