akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nums = br.readLine().split(" ");
        long a = Long.parseLong(nums[0]);
        long b = Long.parseLong(nums[1]);
        System.out.println((a / b) + " " + (a % b) + " " + String.format("%f", ((double) a / b)));
    }
}

Measured memory_bytes: 24748
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

void print(string word,vector<string>& output)
{
  int a,b;
  cin >> a >> b;
  output.push_back(word.substr(a,b-a+1));
}

void reverse(string& word)
{
  int a,b;
  cin >> a >> b;
  string temp = word.substr(a,b-a+1);
  reverse(temp.begin(),temp.end());
  word.replace(a,b-a+1,temp);
}

void replace(string& word)
{
  int a,b;
  string change;
  cin >> a >> b >> change;
  word.replace(a,b-a+1,change);
}

int main(int argc, char* argv[])
{
  string word,command;
  vector<string> output;
  int count;
  cin >> word >> count;
  for(int i=0;i<count;i++)
  {
    cin >> command;
    if(command=="print") print(word,output);
    else if(command=="reverse") reverse(word);
    else if(command=="replace") replace(word);
  }
  for(string n:output)
  {
    cout << n << endl;
  }
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s;
    cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        out(-1);
        return 0;
    }
    if(s.length()<26){
    cout<<s;
    char c='a';
    rep(i,26){
        if(count(all(s),c)==0){
            cout<<c<<endl;
            return 0;
        }
        c++;
    }
    }else if(s.length()==26){
        int n=25,d=0;
        while(1){
            s[n]++;
            if(s[n]>'z'){
                s[n-1]++;
                s.erase(s.begin()+n);
                n--;
            }
            if(s[n]>='a'&&s[n]<='z'&&count(all(s),s[n])==1)break;
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 3660
import java.util.Scanner;

class Main{
	public static void main(String args[]){
	Scanner scan = new Scanner(System.in);
	int i = 1;
	int x,y;
		do{
			x = scan.nextInt();
			y = scan.nextInt();
			if(x == 0 && y == 0){
				break;
			}
			if(x < y){	
				System.out.println(x + " " + y);			
			}
			else{
				System.out.println(y + " " + x);
			}
			i++;
		}while(true);
	}
}

Measured memory_bytes: 35860
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int w,h;// =<20
	char map[20][20];
	int res[20][20]={};
	int result=0;
	int x,y;
	int start;// xxyy
	int stage;
	int check;
	int finish=0;
	
	scanf("%d%d",&w,&h);
	while(finish==0){
	for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			cin >> map[x][y];
			if(map[x][y]=='@'){start=x*100+y;}
		}
	}
	
	x=start/100;
	y=start%100;
	res[x][y]=1;
	stage=1;
	check=1;
	while(check==1){
		check=0;
		for(y=0;y<h;y++){
			for(x=0;x<w;x++){
				if(res[x][y]==stage){
					if(x>0){
						if((map[x-1][y]=='.')&&(res[x-1][y]==0)){res[x-1][y]=stage+1;check=1;}
					}
					if(y>0){
						if((map[x][y-1]=='.')&&(res[x][y-1]==0)){res[x][y-1]=stage+1;check=1;}
					}
					if(x<w-1){
						if((map[x+1][y]=='.')&&(res[x+1][y]==0)){res[x+1][y]=stage+1;check=1;}
					}
					if(y<h-1){
						if((map[x][y+1]=='.')&&(res[x][y+1]==0)){res[x][y+1]=stage+1;check=1;}
					}
				}
			}
		}
		stage+=1;
	}

	result=0;
	for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			if(res[x][y]!=0){result+=1;}
		}
	}
	cout << result << endl;

	for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			map[x][y]=0;
			res[x][y]=0;
		}
	}

	scanf("%d%d",&w,&h);
	if((w==0)&&(h==0)){
		finish=1;
	}
	}
	return 0;
}

Measured memory_bytes: 1224
n = int(raw_input())
ans = ""

room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    b, f, r, v = map(int, raw_input().split())
    room[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            ans += " %d" % (room[i][j][k])
        print ans
        ans = ""
    if i != 3:
        print "#"*20
    

Measured memory_bytes: 6472
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys
sys.setrecursionlimit(4100000)
rl = sys.stdin.readline

N,M,K  =Ints()

mod = 998244353


#N = # Combination　における，最大整数部分
#mod = # 大体modで割った余りを求めさせられる．

def make_bikkuri(N):
    bikkuri = [1]
    for i in range(1,N+1):
        bikkuri.append((bikkuri[-1]*i)%mod)
    return bikkuri

bikkuri = make_bikkuri(N)

def nCk(n,k):
    ans = bikkuri[n] * pow(bikkuri[k], mod-2, mod) * pow(bikkuri[n-k], mod-2, mod)
    return ans%mod


ans = 0

for i in range(K+1):
    ans += nCk(N-1,i)*pow(M-1,N-1-i,mod)
    ans %= mod
ans *= M
ans %= mod

print(ans)
#print(pow(100-1,))

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
ll a,x,n,p,ans;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>p;
	cin>>a;
	if(a>p){
		ans=a-p;
		a-=a-p;
	}
	while(--n){
		x=a;
		cin>>a;
		if(x+a>p){
			ans+=x+a-p;
			a-=x+a-p;
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  if(A==0){
    cout << 1 << endl;
  }
  else if(B==0){
    cout << 2 << endl;
  }
  else if(C==0){
    cout << 3 << endl;
  }
  else if(D==0){
    cout << 4 << endl;
  }
  else{
    cout << 5 << endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
int main(){
int x,N;
  cin>>x>>N;
 vector<int>d(102);
  for(int i=0;i<N;i++){
  int p;
    cin>>p;
    d.at(p)=1;
  }
 P ans(99999,-1);
  for(int i=0;i<=101;i++){
  if(d.at(i)==1){
  continue;
  }
    else{
  	   int sa;
      sa=abs(x-i);
      ans=min(ans,P(sa,i));
    }
  
  }
  cout<<ans.second<<endl;
  }
  

Measured memory_bytes: 3628
// 配列に全部の島のデータを突っ込む
// 各島はparent,sizeから成る、自分がどの島かはインデックスで判断。

function UnionFind(n){
  this.islands = [];
  for(var i=0; i<n; i++){
    this.islands[i] = {
      parent: i,
      size: 1,
    }
  }
}

UnionFind.prototype.same_group = function(left_index, right_index){
  const right_root = this.root(right_index);
  const left_root = this.root(left_index);
  return (right_root == left_root);
}


UnionFind.prototype.marge = function(ax,bx){
  var base = this.root(ax);
  var child = this.root(bx);
  if(base.parent==child.parent) return 0;
  var baseSize = this.getSize(base.no);
  var childSize = this.getSize(child.no);
  if(baseSize > childSize){
    child.parent = base.no;
    base.size += childSize;
  }else{
    base.parent = child.no;
    child.size += baseSize;
  }
  return 1;
}


UnionFind.prototype.merge_islands = function(left_index, right_index){
  const right_root = this.root(right_index);
  const left_root = this.root(left_index);

  if(right_root.parent==left_root.parent){return 0;}

  if(left_root.size > right_root.size){
    left_root.size = left_root.size + right_root.size;
    right_root.parent = left_index;
  }else{
    right_root.size = left_root.size + right_root.size;
    left_root.parent = right_index;
  }

  return 1;
}

UnionFind.prototype.root = function(index){
  if(this.islands[index].parent == index){
    return this.islands[index];
  }

  var parent_node = this.root(this.islands[index].parent);
  this.islands[index].parent = parent_node.parent;
  return parent_node;
}

UnionFind.prototype.get_size = function(index){
  var root_node = this.root(index);
  return root_node.size;
}

function main(input) {
  const formatted_input = input.split('\n').map( x => x.split(' ').map( x => parseInt(x, 10) ) );
  const N = formatted_input[0][0];
  const M = formatted_input[0][1];
  var reverse_bridges = [];

  for(var i=0;i<M;i++){
    reverse_bridges.push(formatted_input[1+i]);
  }
  reverse_bridges = reverse_bridges.reverse();

  var uf = new UnionFind(N)

  var unconvinience = N*(N-1)/2;
  var results = [unconvinience];

  for(bridge of reverse_bridges){

    left_index = bridge[0]-1
    right_index =  bridge[1]-1

    var diff = uf.get_size((left_index)) * uf.get_size(right_index);

    if(uf.merge_islands(left_index, right_index)==1){
      unconvinience -= diff;
    }
    results.push(unconvinience);
  }

  const reversed_result = results.reverse();

  for(var i = 1; i<=M ; i++){
    console.log(reversed_result[i]);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

//02:05:00 > 

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	ll a[200005];
	vector<ll> b;
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n){
		if(i%2==0) b.pb(a[i]);
		else b.insert(b.begin(), a[i]);
	}
	if(n%2==1) reverse(b.begin(), b.end());
	rep(i, 0, n-1) cout << b[i] << ' ';
	cout << b[n-1] << endl;
	return 0;
}

Measured memory_bytes: 6908
//#pragma GCC optimize(2)
#include <bits/stdc++.h>

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

int h, w, k;
int res = 0;
int balckNum = 0;

int main()
{
    cin >> h >> w >> k;
    char b[6][6];
    rep(i, 0, h)
    {
        string s;
        cin >> s;
        rep(j, 0, w)
        {
            b[i][j] = s[j];
            if (s[j] == '#')
            {
                balckNum++;
            }
        }
    }

    int n = h;
    rep(i, 0, 1 << n)
    {
        vector<int> s;
        s.push_back(-1);
        rep(j, 0, n)
        {
            if (i & (1 << j))
                s.push_back(j);
        }

        int m = w;

        rep(l, 0, 1 << m)
        {
            vector<int> s2;
            s2.push_back(-1);
            rep(p, 0, m)
            {
                if (l & (1 << p))
                    s2.push_back(p);
            }

            char bb[h][w];
            rep(q, 0, h)
                rep(e, 0, w)
            {
                bb[q][e] = b[q][e];
            }

            int bn = balckNum;

            for (int a : s)
            {
                if (a != -1)
                {
                    rep(v, 0, w)
                    {
                        if (bb[a][v] == '#')
                        {
                            bb[a][v] = '.';
                            bn--;
                        }
                    }
                }
            }

            for (int a : s2)
            {
                if (a != -1)
                {
                    rep(v, 0, h)
                    {
                        if (bb[v][a] == '#')
                        {
                            bb[v][a] = '.';
                            bn--;
                        }
                    }
                }
            }

            if (bn == k)
            {
                res++;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main(){
    IOS;
    in x,y,A,B,C;
    cin >> x >> y >> A >> B >> C;
    vector<in> red,green,color;
    rep(i,0,A){
        in a; cin>>a;
        red.pb(a);
    }
    rep(i,0,B){
        in a; cin >> a;
        green.pb(a);
    }
    rep(i,0,C){
        in a; cin >> a;
        color.pb(a);
    }
    while(sz(red)<x) red.pb(0);
    while(sz(green)<y) green.pb(0);
    sort(all(red));
    sort(all(green));
    sort(all(color));
    vector<in> f1,f2;
    in ans=0;
    rep(i,0,x){
        f1.pb(red[A-1-i]);
        ans+=red[A-1-i];
    }
    rep(i,0,y){
        f2.pb(green[B-1-i]);
        ans+=green[B-1-i];
    }
    in cur1=x-1,cur2=y-1;
    rep(i,0,C){
        in agr = color[C-i-1];
        if(cur1<0 and cur2<0) break;
        else if(cur1<0 and cur2>=0){
            if(f2[cur2] < agr){
                ans-=f2[cur2--];
                ans+=agr;
            }
            else break;
        }
        else if(cur1>=0 and cur2<0){
            if(f1[cur1] < agr){
                ans-=f1[cur1--];
                ans+=agr;
            }
            else break;
        }
        else{
            if(f1[cur1] >= f2[cur2]){
                if(f2[cur2] < agr){
                    ans-=f2[cur2--];
                    ans+=agr;
                }
                else break;
            }
            else{
                if(f1[cur1] < agr){
                    ans-=f1[cur1--];
                    ans+=agr;
                }
                else break;
             }
        }
        
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4852
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    auto S1 = sread();
    auto S2 = sread();
    long[] S;
    {
        long i = 0;
        while (i < N)
        {
            if (S1[i] == S2[i])
            {
                S ~= 1;
                i++;
            }
            else
            {
                S ~= 2;
                i += 2;
            }
        }
    }
    long ans = (S[0] == 1) ? 3 : 6;
    foreach (i; 1 .. S.length)
    {
        if (S[i] == 1)
        {
            ans *= (S[i - 1] == 1) ? 2 : 1;
        }
        else
        {
            ans *= (S[i - 1] == 1) ? 2 : 3;
        }
        ans %= MOD;
    }
    writeln(ans);
}


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

#define lint long long
#define P pair<int, int>

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

int main() {
    int N;
    cin >> N;
    lint T[N], A[N];
    for(int i = 0; i < N; ++i){
        cin >> T[i] >> A[i];
    }

    lint a = 1, b = 1;

    for(int i = 0; i < N; ++i){
        lint tmp = max((a - 1) / T[i], (b - 1) / A[i]) + 1;
        a = T[i] * tmp; b = A[i] * tmp;
    }

    cout << a + b << endl;
    


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int s,w;
	cin>>s>>w;
	if(w>=s) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

ll gcm(ll a,ll b);

int main(){
  int n;
  cin >> n;
  string A;
  cin >> A;
  vint LW(n);
  vint RE(n);
  rep(i,n){
    if(i == 0){
      LW[i] = 0;
    }
    else{
      if(A[i-1] == 'W'){
        LW[i] = LW[i-1] + 1;
      }
      else{
        LW[i] = LW[i-1];
      }
    }
  }
  for(int i = n-1;i>=0;i--){
    if(i == n-1){
      RE[i] = 0;
    }
    else{
      if(A[i+1] == 'E'){
        RE[i] = RE[i+1] + 1;
      }
      else{
        RE[i] = RE[i+1];
      }
    }
  }
  int ans = INF;
  //rep(i,n) cout << LW[i] << " " << RE[i] << endl;
  rep(i,n){
    ans = min(LW[i] + RE[i],ans);
  }
  cout << ans << endl;
}






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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int max=0;
		int maxin=0;
		int sec=0;
		for(int i=0;i<n;i++)
		{
			int a=in.nextInt();
			if(a>=max)
			{
				sec=max;
				max=a;
				maxin=i;
			}
			else if(a<max&&a>sec)
			{
				sec=a;
			}
		}
		for(int i=0;i<n;i++)
		{
			if(i!=maxin)
			{
				System.out.println(max);
			}
			else
			{
				System.out.println(sec);
			}
		}
		
	}
}
	

Measured memory_bytes: 82492
#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 a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
return 0;}
/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int lowbit(int x){return x&-x;}
const int N=200000;
int n,m;
int a[N+1];
vector<int> nums;
void discrete(){
	sort(nums.begin(),nums.end());
	nums.resize(unique(nums.begin(),nums.end())-nums.begin());
	for(int i=0;i<=n;i++)a[i]=lower_bound(nums.begin(),nums.end(),a[i]-i*m)-nums.begin()+1;
}
struct bitree{
	int sum[N+2];
	void init(){memset(sum,0,sizeof(sum));}
	void add(int x){
		while(x<=n+1)sum[x]++,x+=lowbit(x);
	}
	int Sum(int x){
		int res=0;
		while(x)res+=sum[x],x-=lowbit(x);
		return res;
	}
}bit;
signed main(){
	cin>>n>>m;
	nums.pb(0);
	for(int i=1;i<=n;i++)scanf("%lld",a+i),a[i]+=a[i-1],nums.pb(a[i]-i*m);
//	for(int i=0;i<=n;i++)cout<<a[i]-i*m<<" ";puts("");
	discrete();
//	for(int i=0;i<=n;i++)cout<<a[i]<<" ";puts("");
	int ans=0;
	bit.init();
	bit.add(a[0]);
	for(int i=1;i<=n;i++){
		ans+=bit.Sum(a[i]); 
		bit.add(a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5104
N,M,X=list(map(int,input().split()))
lines = []

for i in range(N):
	lines.append(list(map(int,input().split())))
pricemin = 1500000
for i in range(2**N):
	price = 0
	count = 0
	A = [0]*M
	for j in range(N):
		if ((i >> j) & 1):
			for k in range(M):
				A[k] += lines[j][k+1]
			price += lines[j][0]
	for j in range(M):
		if A[j] >= X:
			count += 1
	if count == M and pricemin > price:
		pricemin = price
if pricemin == 1500000:
	print('-1')
else:
	print(pricemin)
			
	



Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
ll a[100005];
int p[100005];
int main()
{
        FastIO
        ll n,lcm,ans=1,i,m,count=0,c=1;
        cin>>n>>m;
       
        for(i=0;i<n;i++)
        {
        	cin>>a[i];
        	a[i]/=2; 

        	lcm= (ans*a[i])/(__gcd(ans,a[i]));
        	while(!(a[i]&1))
        	{
        		c++;
        		a[i]/=2;
        	}
        	p[i]=c;
        	c=1;
        	ans=lcm;
        }
        //db(lcm);



        for(i=1;i<n;i++)
        {
        	if(p[i]!=p[i-1])
        		{cout<<"0";return 0;}
        	
        }

        
        cout<<(m/lcm +1)/2;
        return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}
 
int main() {
    int n,m,c,b,a;
    cin >> n >> m >> c;
    vector<int> B(m);
    vector<vector<int>> A(n, vector<int>(m));
    rep(i, m){
        cin >> B[i];
    }
    rep(i,n) {
        rep(j,m) {
            cin >> A[i][j];
        }
    }
    int cnt = 0;
    rep(i,n) {
        int res = 0;
        rep(j,m) {
            res += A[i][j]*B[j];
        }
        res += c;
        if (res>0) {
            cnt++;
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));
	int s_len = (int)s.length(), t_len = (int)t.length();
	for (int i = 1; i <= s_len; i++) {
		for (int j = 1; j <= t_len; j++) {

			if (s[i - 1] == t[j - 1] && dp[i][j] < dp[i - 1][j - 1] + 1) dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

		}
	}
	
	string ans;
	int x = (int)s.length(), y = (int)t.length();
	while (x > 0 && y > 0) {

		if (dp[x][y] == dp[x - 1][y]) x--;
		else if (dp[x][y] == dp[x][y - 1]) y--;
		else {
			ans.push_back(s[x - 1]);
			x--, y--;
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 35584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] students = new int[n][2];
		int[][] checkpoints = new int[m][2];
				
		for (int i = 0; i < n; i++) {
			students[i][0] = in.nextInt();
			students[i][1] = in.nextInt();
		}
		
		for (int i = 0; i < m; i++) {
			checkpoints[i][0] = in.nextInt();
			checkpoints[i][1] = in.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			int checkpoint = 0;
			int prevRes = Math.abs(students[i][0] - checkpoints[0][0]) + 
					Math.abs(students[i][1] - checkpoints[0][1]);

			for (int j = 0; j < m; j++){
				int tmpRes = Math.abs(students[i][0] - checkpoints[j][0]) + 
						Math.abs(students[i][1] - checkpoints[j][1]);
				if (tmpRes < prevRes) {
					checkpoint = j;
					prevRes = tmpRes;
				}
			}
			System.out.println((int)checkpoint + 1);
		}
		in.close();
	}
}


Measured memory_bytes: 36056
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    // input
    string S;
    lint ans = 0;
    cin >> S;

    lint left_point = 0;
    lint right_point = S.length() - 1;
    char left = S[left_point];
    char right = S[right_point];


    while ((right_point - left_point) > 1) {
        ++left_point;
        --right_point;
        if (S[left_point] != left) {
            left = S[left_point];
            ++ans;
        }
        if (S[right_point] != right) {
            right = S[right_point];
            ++ans;
        }
    }

    if (S[left_point] != S[right_point]) {
        cout << ans + 1 << endl;
    } else {
        cout << ans << endl;
    }
    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll sum=0,a[202020],mind,front=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    mind=sum;
    for(int i = 0;i < n-1;i++){
        front+=a[i];
        sum-=a[i];
        if(abs(sum-front)<mind){
            mind=abs(sum-front);
        }
    }
    cout << mind << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1000000000 //1e9

int graph[8][8];

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

    int N, M;
    cin >> N >> M;
    for(int i=0;i<M;i++) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    vector<int> v(N);
    for(int i=0;i<N;i++) v[i] = i;
    int ans = 0;
    do {
        if (v[0] != 0) continue;
        bool ok = true;
        for(int i=0;i<N-1;i++) {
            if (!graph[v[i]][v[i+1]]) ok = false;
        }
        if (ok) ans++;
    } while (next_permutation(v.begin(), v.end()));

    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
check = [0]*N
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        check[B-1] = -1
    elif H[B-1] > H[A-1]:
        check[A-1] = -1
    else:
        check[A-1],check[B-1] = -1,-1
print(check.count(0))

Measured memory_bytes: 20068
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000];

LL ans = 0;

void solve(){
	for(int i=1;i<N;i++){
		if(A[i-1]>A[i]){
			ans += A[i-1] - A[i];
			A[i] = A[i-1];
		}
	}
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

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

Measured memory_bytes: 4752
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

X, A, B = map(int, read().split())
print((X-A)%B)

Measured memory_bytes: 2940
#!/bin/ruby
require 'prime'
prm=Prime.instance.each.first(1500)
lcm=2
start=2
ncmp=1
x=1
factors=[2]
while ncmp<1500
  start+=lcm
  if (start+ncmp)%prm[x]==0 then
    ncmp+=1
    factors<< prm[x]
    lcm*=prm[x]
    x+=1
    while true
      f=false
      (0...x).each do |e|
        if (start+ncmp)%prm[e]==0 then
          f=true
          factors<< prm[e]
          ncmp+=1
          break
        end
      end
      break if f
    end
  end
end
n=gets.to_i
puts start,factors[0...n]

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

vector<int> graph[100010];
vector<int> tree[100010];

int mas[100010];
int n;

bool used[100010] = {};
void makeTree(int m){
  used[m] = true;
  for(int i = 0;i < graph[m].size();i++){
    if(!used[graph[m][i]]){
      tree[m].push_back(graph[m][i]);
      makeTree(graph[m][i]);
    }
  }
  return;
}

int dp[100010] = {};
int ep[100010] = {};
int fp[100010] = {};

void dfs(int x){
  dp[x] = mas[x];
  ep[x] = 0;
  fp[x] = 0;

  if(tree[x].size() == 0) return;

  for(int i = 0;i < tree[x].size();i++){
    dfs(tree[x][i]);
  }

  //bool used[100010] = {};
  memset(used,false,sizeof(used));
  for(int i = 0;i < tree[x].size();i++){
    if(dp[tree[x][i]] - 2 >= 0){
      used[tree[x][i]] = true;
      dp[x] += dp[tree[x][i]] - 2;
    }
  }

  int kari = 0;
  int kari2 = 0;
  for(int i = 0;i < tree[x].size();i++){
    if(used[tree[x][i]]){
      if(ep[tree[x][i]]+1 > kari){
        kari2 = kari;
        kari = ep[tree[x][i]]+1;
      }else if(ep[tree[x][i]]+1 > kari2){
        kari2 = ep[tree[x][i]]+1;
      }
    }else{
      if(ep[tree[x][i]]+1+dp[tree[x][i]]-2 > kari){
        kari2 = kari;
        kari = ep[tree[x][i]]+1+dp[tree[x][i]]-2;
      }else if(ep[tree[x][i]]+1+dp[tree[x][i]]-2 > kari2){
        kari2 = ep[tree[x][i]]+1+dp[tree[x][i]]-2;
      }
    }
  }

  if(kari >= 0){
    ep[x] = kari;
  }

  int kari3 = 0;
  for(int i = 0;i < tree[x].size();i++){
    if(used[tree[x][i]]){
      kari3 = max(kari3,fp[tree[x][i]]);
    }else{
      kari3 = max(kari3,fp[tree[x][i]]+dp[tree[x][i]]-2);
    }
  }

  fp[x] = max(kari3,max(kari+kari2,max(kari,kari2)));
  return;
}


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

  int a, b;
  for(int i = 0;i < n-1;i++){
    cin >> a >> b;
    a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  makeTree(0);
  dfs(0);

  int ans = INT_MIN;
  for(int i = 0;i < n;i++){
    ans = max(ans,dp[i]+fp[i]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 23588
#include <iostream>
#include <string>
#define int long long
#define MOD 1000000007
using namespace std;

signed main(){
	int n,dp[5001][5001] = {};
	string s;
	cin >> n >> s;
	dp[0][s.length()] = 1;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= n;j++){
			if(j + 1 <= n) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * 2) % MOD;
			dp[i + 1][max(0ll,j - 1)] = (dp[i + 1][max(0ll,j - 1)] + dp[i][j]) % MOD;
		}
	}
	cout << dp[n][0] << endl;
	return 0;
}

Measured memory_bytes: 195712
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	int count = 0;

	int N;
	cin >> N;
	vector<int> v(N);
	REP(i, N) cin >> v.at(i);

	REP(i, N) {
		RFOR(j, N, i+1) {
			if(v.at(j) < v.at(j-1)) {
				count++;
				swap(v.at(j), v.at(j-1));
			}
		}
	}
	print_array(v);
	cout << count << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<string> lines;
	string cmds;
	for(string s;getline(cin,s),s!="END_OF_TEXT";)
		lines.push_back(s);
	for(char c;cin>>c,c!='-';)
		cmds+=c;
	
	int i=0,j=0;
	string buf;
	for(char c:cmds){
		if(c=='a')
			j=0;
		else if(c=='e')
			j=lines[i].size();
		else if(c=='p'){
			if(i>0)
				i--;
			j=0;
		}
		else if(c=='n'){
			if(i+1<lines.size())
				i++;
			j=0;
		}
		else if(c=='f'){
			if(j<lines[i].size())
				j++;
			else if(i+1<lines.size()){
				i++;
				j=0;
			}
		}
		else if(c=='b'){
			if(j>0)
				j--;
			else if(i>0){
				i--;
				j=lines[i].size();
			}
		}
		else if(c=='d'){
			if(j<lines[i].size())
				lines[i].erase(j,1);
			else if(i+1<lines.size()){
				lines[i]+=lines[i+1];
				lines.erase(lines.begin()+i+1);
			}
		}
		else if(c=='k'){
			if(j<lines[i].size()){
				buf=lines[i].substr(j);
				lines[i].erase(j);
			}
			else if(i+1<lines.size()){
				buf="\n";
				lines[i]+=lines[i+1];
				lines.erase(lines.begin()+i+1);
			}
		}
		else if(c=='y'){
			if(buf=="\n"){
				lines.insert(lines.begin()+i+1,lines[i].substr(j));
				lines[i].erase(j);
				i++;
				j=0;
			}
			else if(buf.size()){
				lines[i].insert(j,buf);
				j+=buf.size();
			}
		}
	}
	for(int i=0;i<lines.size();i++)
		cout<<lines[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
#define MOD 2019
//---------------------

int l,r;
int mul[MOD];

int main(){
  	cin>>l>>r;
  	MINUS(mul);
  	int ct=0;
  	REP(i,MOD){
  		mul[i]=mul[i]=(l+i)%MOD;
  		ct++;
  		if(l+i>=r) break;
  	}
  	
  	int minn=MOD+10086;
  	
  	REP(i,ct-1){
  		FOR(j,i+1,ct){
  			MIN(minn,((mul[i]*mul[j])%MOD));
  		}
  	}
  	
  	cout<<minn<<endl;
  	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  

n_rem = n  
res = ""

while True:
    x = n_rem % 26
   
    if x == 0:
        x = 26
    res += chars[x]

    
    n_rem -= x

    
    if n_rem == 0:
        break

    n_rem //= 26


print(res[::-1])

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, n, a, x = 0;
  cin >> h >> n;
  for (int i = 0; i < n; i ++) {
    cin >> a;
    x += a;
  }
  if (h <= x) {
    cout << "Yes" << endl;
  }
  else if (h > x) {
    cout << "No" << endl;
  }
}  

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int x = 0, y = 0;
	REP(i, n) {
		bool f = (x + y < a + b && (s[i] == 'a' || (s[i] == 'b' && y < b)));
		cout << (f ? "Yes" : "No") << endl;
		if (f && s[i] == 'a') ++x;
		if (f && s[i] == 'b') ++y;
	}
	return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();

            StringBuilder WB = new StringBuilder();
            WB.append(S.charAt(0));
            for (int i = 1; i < S.length(); i++) {
                if (S.charAt(i) == S.charAt(i - 1)) {
                    continue;
                } else {
                    WB.append(S.charAt(i));
                }
            }

            System.out.println(WB.length() - 1);
        }
    }
}


Measured memory_bytes: 31264
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	sort(ALL(a));
	VE tmp(n);
	if (n % 2 == 1) {
		rep(i, n) {
			tmp[i] = 2 * ((i+1) / 2);
		}
	}
	else {
		rep(i, n) {
			tmp[i] = 2 * ((i + 2) / 2) - 1;
		}
	}
	bool ok = true;
	rep(i, n) {
		if (a[i] != tmp[i])ok = false;
	}
	if (ok) {
		int ans = 1;
		rep(i, n / 2) {
			ans *= 2; ans %= MOD;
		}
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define endl "\n"

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

    ll n,i,c=0;
    cin >> n;
    ll a[n];
    for(i=0;i<n;i++) {
        cin >> a[i];
    }
    for(i=0;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            ll x = a[i]-a[i+1];
            a[i+1]+=x;
            c+=x; 
        }
    }
    cout << c;
}

Measured memory_bytes: 5164
A = input()
B = input()
C = input()
turn = "a"

for i in range(10**8):
    if turn == "a":
        if len(A) == 0:
            print("A")
            exit()
        else:
            turn = A[0]
            A = A[1::]
    elif turn == "b":
        if len(B) == 0:
            print("B")
            exit()
        else:
            turn = B[0]
            B = B[1::]
    else:
        if len(C) == 0:
            print("C")
            exit()
        else:
            turn = C[0]
            C = C[1::]

Measured memory_bytes: 38256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;
int n;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    n = s.length();
    for (int i = 0; i < n; i++)
        cout << 'x';
    cout << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
heights = list(map(int, input().split()))
a = []
b = []
for i in range (0, m):
    am, bm =map(int,input().split())
    a.append(am)
    b.append(bm)
not_peaks = {}
for i in range(0, m):
    if heights[a[i]-1]>heights[b[i]-1]:
        not_peaks[b[i]]=0
    elif heights[b[i]-1]>heights[a[i]-1]:
        not_peaks[a[i]]=0
    else:
        not_peaks[a[i]]=0
        not_peaks[b[i]]=0
print(n-len(not_peaks))

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

using namespace std;

int main(){
    char a[1010], b[1010];

    scanf(" %s %s", a, b);

    int ln = strlen(b), mn = ln;
    for(int i = 0; a[i + ln - 1]; i++){
        int r = ln;

        for(int j = 0; b[j] && a[i + j]; j++){
            if(a[i + j] == b[j])
                r--;
        }

        mn = min(mn, r);
    }

    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int t = sc.nextInt();
		for(int i = 0; i < t ; i++){
			if(X > 0){
			X --;
			}else{
				break;
			}
		}
		System.out.println(X);
	}
}


Measured memory_bytes: 21844
#pragma warning(disable:4996)
#include <stdio.h>
typedef long long ll;
ll MOD = 1000000007;
ll sum[200200];
ll a[200200];
int main()
{
	ll n;
	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		sum[i] = sum[i - 1] + a[i];
		sum[i] %= MOD;
	}
	ll ans=0;
	for (ll i = n; i >= 1; i--)
	{
		ans += (a[i] * (sum[i-1]))%MOD;
		ans %= MOD;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 6336
#include <iostream>
#include <algorithm>
#include <stack>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int N, M;
int used[51];

struct Edge
{
    int from, to;
    Edge() {};
    Edge(int _from, int _to) : from(_from), to(_to) {};

};
Edge edge[51];

signed main()
{
    cin >> N >> M;
    REP(i, M)
    {
        int a, b;
        cin >> a >> b;
        edge[i] = Edge(a, b);
    }

    int ans = 0;
    REP(i, M)
    {
        REPS(j, N) used[j] = 0;

        stack<int> s;
        s.push(1);

        while (!s.empty())
        {
            int v = s.top(); s.pop();
            used[v] = 1;
            REP(j, M)
            {
                if (i == j) continue;

                Edge& e =  edge[j];
                if (e.from == v)
                {
                    if (used[e.to] == 1) continue;
                    s.push(e.to);
                }
                else if (e.to == v)
                {
                    if (used[e.from] == 1) continue;
                    s.push(e.from);
                }
            }
        }

        bool bConnect = true;
        REPS(j, N)
        {
            if (used[j] == 0)
            {
                bConnect = false;
                break;
            }
        }
        if (!bConnect) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
main()
{
	int n, i, j, w, a[100];

	scanf("%d", &n);

	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	for(i = n - 1; i >= 0; i--){
		if(i == 0){
			printf("%d\n", a[i]);
		}else{
			printf("%d ", a[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 596