akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  string S;
  cin >> S;
  vector<int> ans;
  
  int now = N;
  while (0 == 0) {
    int t = -1;
    for (int i = max(0,now - M); i < now; i++) {
      if (S[i] == '0') {
        t = now - i;
        break;
      }
    }
    if (t == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(t);
    now -= t;
    if (now == 0) {
      break;
    }
  }

  for (int i = (int)ans.size() - 1; i >= 0; i--) {
    cout << ans[i] << " ";
  }
  return 0;
}

Measured memory_bytes: 3960
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max(x,max(y,z))
#define MX4(x,y,z,p) max(x,max(y,max(z,p)))
#define MX5(x,y,z,p,q) max(x,max(y,max(z,max(p,q))))
#define MN3(x,y,z) min(x,min(y,z))
#define MN4(x,y,z,p) min(x,min(y,min(z,p)))
#define MN5(x,y,z,p,q) min(x,min(y,min(z,min(p,q))))
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################
const long long MOD = 998244353;

const double __gauss_template_EPS = 1e-8;
const double EPS = __gauss_template_EPS;

int Gauss(vector<vector<int>> &mat) {
    int n = mat.size(), m = mat.size();
  	int r = 0, c = 0;
	for(; r < n && c < m; r ++, c ++){
		int p = -1;
		REPP(i, r, n-1) if(mat[i][c]){ p = i; break; }
		if(p == -1){ r --; continue; }
		if(p != r) swap(mat[r], mat[p]);
		REPP(i, r + 1, n-1) if(mat[i][c])
			for(int j = m-1 ; j >= c ; j--)  mat[i][j] ^= mat[r][j];
	}
	return r;
}



const long long __exp_template_MOD = MOD;

long long exp(int a, int b) {
    if(b == 0) return 1;
    long long tmp = exp(a, b/2);
    if(b & 1) {
        return (long long)tmp*tmp%__exp_template_MOD*a%__exp_template_MOD;
    }
    return (long long)tmp*tmp%__exp_template_MOD;
}

void solve() {
    int n, m;
    SI(n);
    SI(m);
    vvi rec(max(n, m),vi(max(n,m), 0));
    REP(i, n) {
        REP(j, m) {
            scanf("%d", &rec[i][j]);
        }
    }
    int r = Gauss(rec);

    printf("%lld\n", ((exp(2, n+m-1) - exp(2, n+m-r-1))%MOD+MOD)%MOD);
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}




Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main
{
	static class Position
	{
		double x, y;
	}
	static ArrayList<Position> pos = new ArrayList<>();
	
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			String[] input = scanner.next().split(",");
			Position p = new Position();
			p.x = Double.parseDouble(input[0]);
			p.y = Double.parseDouble(input[1]);
			pos.add(p);
		}
		
		double sum = 0;
		for(int i=2; i<pos.size(); i++)
		{
			double a = distance(0, i-1);
			double b = distance(0, i);
			double c = distance(i-1, i);
			
			double z = (a+b+c) / 2;
			sum += Math.sqrt(z*(z-a)*(z-b)*(z-c));	
		}
		
		System.out.printf("%1$.6f", sum);
	}
	
	static double distance(int m, int n)
	{
		double x = pos.get(m).x - pos.get(n).x;
		double y = pos.get(m).y - pos.get(n).y;
		return Math.sqrt(x*x + y*y);
	}
}

Measured memory_bytes: 26588
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>



#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 1000000007;


int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  string sc = string(S);
  int l = 0;
  int r = 0;

  bool end = true;
  while(end) {
    end = false;
    for(int i = 0; i < (int)S.length() - 1; i++) {
      if(S[i] == '(' && S[i+1] == ')') {
        S.erase(S.begin() + i,S.begin() + i+2);
        end = true;

        break;
      }
    }
  }
  for(int i = 0; i < S.length(); i++) {
    if(S[i] == '(') l++;
    else r++;
  }

  for(int i = 0; i < l; i++) {
    sc = sc + ")";
  }
  for(int i = 0; i < r; i++) {
    sc = "(" + sc;
  }
  cout << sc << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int> > v;
    for(int i= 0;i < n;i++)
    {
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    long double sum = 0.0;
    for(int i = 0;i < v.size();i++)
    {
        for(int j = 0;j < v.size();j++)
        {
            if(i != j)
            {
                sum += sqrt(pow((v[j].first - v[i].first),2) + pow((v[j].second - v[i].second),2));
            }
        }
    }
    cout << setprecision(15) << sum / n;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    char a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c) cout << "No" << endl;
    else    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
win = 0

SR = sr
SC = sc
sr = SR
sc = SC
for i in range(n):
    if S[i] == "L":
        sc -= 1
    if sc <= 0:
        break
    if T[i] == "R" and sc < w:
        sc += 1
if sc <= 0:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "R":
        sc += 1
    if sc > w:
        break
    if T[i] == "L" and sc > 1:
        sc -= 1
if sc > w:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "D":
        sr += 1
    if sr > h:
        break
    if T[i] == "U" and sr > 1:
        sr -= 1
if sr > h:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "U":
        sr -= 1
    if sr <= 0:
        break
    if T[i] == "D" and sr < h:
        sr += 1
if sr <= 0:
    win = 1

if win:
    print("NO")
else:
    print("YES")

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 10e18+1000
#define INF 0x3f3f3f3f
#define MAR 10e5+100

int main() {
    shutdown;
    int a,b,c;
    cin>>a>>b>>c;
    a=a-c;
    cout<<a/(b+c)<<endl;
    return 0;
}



Measured memory_bytes: 256
S = input()

zero_start_cnt = 0
one_start_cnt = 0

for i in range(len(S)):
    if i % 2 == 0:
        zero_color = '0'
        one_color = '1'
    else:
        zero_color = '1'
        one_color = '0'

    if S[i] != one_color:
        one_start_cnt += 1
    else:
        zero_start_cnt += 1

print(min(one_start_cnt, zero_start_cnt))





Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a; double b; cin >> a >> b;

  ll nb = b * 100.01;
  // cout << nb << endl;
  ll ans = a * nb;
  // cout << ans << endl;
  ans /= 100;
  cout << ans << endl;
}


Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][][] room = {{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}}};

        int N = sc.nextInt();

        for(int i=0; i<N; i++){
            int b = sc.nextInt() -1;
            int f = sc.nextInt() -1;
            int r = sc.nextInt() -1;
            int v = sc.nextInt();

            room[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++){
                    System.out.print(" " + room[i][j][k]);
                 
                }
                if(j==2 && i==3){
                    int a = 0;
                }else{
                System.out.print("\n");
                }
            }
            if(i != 3)
            System.out.println("####################");
        }
        System.out.print("\n");
    }
}


Measured memory_bytes: 30084
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	vector<int>v;
	int n,k;
	cin>>n>>k;
	int a[n+3],b[n+3];
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i];
	v.push_back(k);
	for(int i=0;i<=30;i++)
	{
		int msk=(1<<i);
		if(k & msk)
		{
			int tp=k ^ msk;
			tp |=msk-1;
			v.push_back(tp);
		}
	}
	int64_t ans=0;
	for(int i=0;i<v.size();i++)
	{
		int64_t kk=v[i],res=0;
		for(int j=0;j<n;j++)
		{
        			if((a[j] | kk)==kk) res+=b[j];
		}
		ans=max(ans,res);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define TENS(n) int(1e##n + n)

char a[1002][1002];
LL dp[1002][1002];
LL mod = 1e9 + 7;

struct pos
{
    int x;
    int y;
};

void solve()
{
    int H;
    cin >> H;
    int W;
    cin >> W;

    REP1(i, H)
    {
        REP1(j, W)
        {
            cin >> a[i][j];
        }
    }
    dp[1][1] = 1;

    REP1(y, H)
    {
        REP1(x, W)
        {
            if (a[y - 1][x] == '.')
            {
                dp[y][x] += (dp[y - 1][x] % mod);
                dp[y][x] %= mod;
            }

            if (a[y][x - 1] == '.')
            {
                dp[y][x] += (dp[y][x - 1] % mod);
                dp[y][x] %= mod;
            }
        }
    }

    // queue<pos> Q;
    // Q.push(pos{1, 1});
    // while (Q.size())
    // {
    //     pos now = Q.front();
    //     Q.pop();

    //     if (a[now.y - 1][now.x] == '.')
    //     {
    //         dp[now.y][now.x] += (dp[now.y - 1][now.x] % mod);
    //         dp[now.y][now.x] %= mod;
    //     }

    //     if (a[now.y][now.x - 1] == '.')
    //     {
    //         dp[now.y][now.x] += (dp[now.y][now.x - 1] % mod);
    //         dp[now.y][now.x] %= mod;
    //     }
    //     if (a[now.y + 1][now.x] == '.')
    //         Q.push(pos{now.y + 1, now.x});
    //     if (a[now.y][now.x + 1] == '.')
    //         Q.push(pos{now.y, now.x + 1});
    // }

    cout << dp[H][W] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

int main() {
	int n,c,tt,ss,ch,act=0,jwb=0;
	bool tmp[40]={0}, cc[40]={0};
	map<int, vector<int>> s,t;
	cin >> n >> c;
	for (int i=1;i<=n;++i) {
		cin >> ss >> tt >> ch;
		s[ss].push_back(ch);
		t[tt].push_back(ch);
	}
	for (int i=1;i<=100000;++i) {
		for (int i=1;i<=30;++i) tmp[i] = 0;
		int st=s[i].size(), fi=t[i].size(), bar=0;
		for (int j=0;j<fi;++j) {
			cc[t[i][j]] = 0;
			tmp[t[i][j]] = 1;
		}
		for (int j=0;j<st;++j) {
			cc[s[i][j]] = 1;
			if (tmp[s[i][j]]) ++bar;
		}
		jwb = max(jwb, act+st-bar);
		act = act-fi+st;
	}
	cout << jwb << endl;
	return 0;
}

Measured memory_bytes: 22144
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 n;
  cin >> n;
  vector<int64> a(n);
  cin >> a;
  int64 shou = n / 2;
  int amari = n % 2;
  string str = "";
  for (int64 i = 0; i < shou; i++) {
    str += to_string(a[n - 1 - i * 2]);
    str += ' ';
  }
  if (amari == 0) {
    for (int64 i = 0; i < shou; i++) {
      str += to_string(a[i * 2]);
      str += ' ';
    }
  } else {
    str += to_string(a[0]);
    str += ' ';
    for (int64 i = 0; i < shou; i++) {
      str += to_string(a[i * 2 + 1]);
      str += ' ';
    }
  }
  str.pop_back();
  cout << str << endl;
  return 0;
}

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

string s;
int n;
int k;
long long kq;

int main(){
//  freopen("G:\\Documents\\Code\\Themis\\Task\\AGC039A\\Test03\\AGC039A.inp","r",stdin);
  cin>>s>>k;
  n=s.length();
  int tmp=0;
  string s1=s+" ";int cnt=1;
  for(int i=1;i<=n;i++){
    if (s1[i]==s1[i-1]) cnt++;
    else{
//      cout<<"Cnt= "<<cnt<<endl;
      tmp=tmp+cnt/2;
      cnt=1;
    }
  }
  if (k==1) kq=tmp;
  else{
    if (s[0]==s[n-1]){
      int cnt1=1;int cnt2=1;
      for(int i=1;i<n;i++)
        if (s[i]==s[i-1]) cnt1++;
        else break;
      for(int i=n-2;i>=0;i--)
        if (s[i]==s[i+1]) cnt2++;
        else break;
//      cout<<"Cnt1= "<<cnt1<<" Cnt2= "<<cnt2<<endl;
      if (cnt1==n){
        kq=1ll*cnt1*k/2;
      }
      else
//        cout<<"Cnt= "<<cnt1<<" Cnt2= "<<cnt2<<" Cnt3= "<<(tmp-cnt1/2-cnt2/2)<<" Cnt4= "<<((cnt1+cnt2)/2)<<endl;
        kq=cnt1/2+cnt2/2+1ll*k*(tmp-cnt1/2-cnt2/2)+1ll*(k-1)*((cnt1+cnt2)/2);
    }
    else{
      kq=1ll*tmp*k;
    }
  }
  cout<<kq;
}


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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;
		static T MIN<T>(params T[] args) => args.Min();
		static T MAX<T>(params T[] args) => args.Max();

		static void Main(string[] args)
		{
			var s = R;
			var k = "keyence";
			if(s.Length < k.Length)
			{
				Out("NO");
				return;
			}
			else
			{
				var sa = s.Length - k.Length;
				for(int i = 0;i < s.Length - sa + 1;i++)
				{
					if(s.Remove(i,sa) == k)
					{
						Out("YES");
						return;
					}
				}
				Out("NO");
			}
			
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
long long x,a,b;
int main()
{
	cin>>x;
	bool i=0;
	for(a=0;a<=127;a++)
	{
		long long a1=a*a*a*a*a;
		long long x1=x-a1;
		long long x2=a1-x;
		for(b=0;b<=a;b++)
		{
			long long b1=b*b*b*b*b;
			if(b1==x1)
			{
				b=0-b;
				i=1;
				break;
			}
			if(b1==x2)
			{
				i=1;
				break;
			}
		}
		if(i)
		{
			break;
		}
	} 
	cout<<a<<' '<<b;
    return 0;
}


Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

signed main(){
    int n;
    cin>>n;
    
    vector<vector<int>> d(n,vector<int>(n));
    rep(i,n){
        rep(j,n){
            cin>>d[i][j];
        }
    }
    
    vector<vector<int>> dd = d;
    
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dd[i][j] = min(dd[i][j],dd[i][k]+dd[k][j]);
            }
        }
    }
    
    if(d!=dd){
        cout<<-1<<endl;
        return 0;
    }
    
    int sum = 0;
    
    rep(i,n){
        rep(j,n){
            bool f = false;
            rep(k,n){
                if(d[i][j] == d[i][k]+d[k][j]&&i!=k&&k!=j)f = true;
            }
            if(!f)sum+=d[i][j];
        }
    }

    cout<<sum/2<<endl;
}


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


using namespace std;
int main(){
	int a,b;
	cin >> a>>b;
	if(a > 9 || b > 9 || a <= 0 || b <= 0){
		cout << -1 << "\n";
		return 0;
	}
	cout << a*b<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long;

int main()
{
	int x;
	cin >> x;
	int n = x%10;
	if (n == 2 || n == 4 || n == 5|| n == 7 || n == 9)
	cout << "hon\n";
	else if (n == 0 || n == 1 || n == 6 || n == 8)
	cout << "pon\n";
	else
	cout << "bon\n";
}


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

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n*n,sizeof(int));
  int i;
  for(i=0;i<n*n;i++) scanf("%d",a+i);
  const int mod=1000000007;
  int *dp=(int *)calloc(1<<n,sizeof(int));
  dp[0]=1;
  for(i=1;i<(1<<n);i++){
    int v=0;
    int t=i;
    while(t>0){
      v+=t&1;
      t>>=1;
    }
    v--;
    for(int j=0;j<n;j++){
      if(((i>>j)&1) && a[v*n+j]){
	dp[i]+=dp[i^(1<<j)];
	dp[i]%=mod;
      }
    }
  }
  printf("%d\n",dp[(1<<n)-1]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  if (n >= 30) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3664
cnt = 0
def SelectionSort(L):
    global cnt
    for i in range(len(L)):
        minj = i
        for j in range(i+1, len(L)):
            if L[minj] > L[j]:
                minj = j
        if minj != i:
            cnt += 1
            L[i], L[minj] = L[minj], L[i]

n = int(input())
NUM_LIST = list(map(int, input().split()))

SelectionSort(NUM_LIST)
STR = list(map(str, NUM_LIST))
print(" ".join(STR))
print(cnt)


Measured memory_bytes: 5600
import java.lang.StringBuilder

fun main(arr:Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val map = (1..h).map { readLine()!! }
    val ans = (1..h).map { (1..w).toMutableList() }
    for(r in ans.indices) {
        for(c in ans[r].indices) {
            if(map[r][c] == '#') {
                ans[r][c] = 9
                continue
            }
            var cnt = 0
            for(r2 in (Math.max(0, r-1)..Math.min(r+1,ans.lastIndex))) {
                for(c2 in (Math.max(0, c-1)..Math.min(c+1, ans[r].lastIndex))) {
                    if(map[r2][c2] == '#') {
                        cnt++
                    }
                }
            }
            ans[r][c] = cnt
        }
    }
    val ansText = StringBuilder()
    ans.forEach { ansText.appendln(it.map { if(it == 9) "#" else it.toString() }.joinToString("")) }
    print(ansText.toString())
}

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

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;

	string s;
	cin >> s;

	smatch smatch;
	string reg = "\\d{" + to_string(a) + "}-\\d{" + to_string(b) + "}";
	cerr << reg << endl;
	if(regex_search(s, smatch, regex(reg))){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
def main():
    from itertools import accumulate
    n, k = map(int, input().split())
    *exp, = map(lambda x: (int(x) + 1) / 2, input().split())
    l = accumulate(exp)
    l = list(l)
    ans = l[k - 1]
    for i in range(0, n - k):
        x = l[i + k] - l[i]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23616
n = int(input())
a = [int(i) for i in input().split()]

box = [0] * n
ans = []
for i in range(n, 0, -1):
    if sum(box[i - 1:n:i]) % 2 != a[i - 1]:
        box[i - 1] = 1
        ans.append(i)

print(len(ans))
print(*ans)

Measured memory_bytes: 14048
import java.util.*;

public class Main {
    public static final long INF = 1000000000000000000L;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        final int N = in.nextInt();
        long[] as = new long[N];
        for (int i = 0; i < N; i++) {
            as[i] = in.nextLong();
        }

        long K = 0;
        while (true) {
            boolean isFinished = true;
            for (int i = 0; i < N; i++) {
                final long k = as[i] / N;
                if (k > 0) {
                    isFinished = false;
                    K += k;
                    for (int j = 0; j < N; j++) {
                        if (j == i) {
                            as[j] = as[j] % N;
                        } else {
                            as[j] += k;
                        }
                    }
                }
            }
            if (isFinished) {
                break;
            }
        }
        System.out.printf("%d\n", K);
    }
}


Measured memory_bytes: 23124
#include<stdio.h>
int main(){
    int W, H, x, y, r;

    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if( r > x || r > y ){
        printf("No\n");
    }
    else if( x+r > W || y+r > H ){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    cout << n * (n-1) / 2 + m * (m-1) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x[105], y[105];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i];
  x[n] = x[0], y[n] = y[0];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += x[i] * y[i + 1] - x[i + 1] * y[i];
  }
  cout << (ans / 2) << "." << (ans % 2 ? "5" : "0") << endl;
}


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

using namespace std;

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

  int N, a;
  map<int, int> M;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    M[a]++;
  };

  int ans = 0;
  for(auto x : M) {
    if (x.second % 2 == 1) ans++;
  }

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


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  ll X;
  cin >> X;
  ll lo = 0;
  ll hi = 100000;
  ll ret = hi;
  while( lo <= hi ){
    ll mid = (lo+hi)/2;
    ll v = (mid+1)*mid/2;
    if( v >= X ){
      ret = min( ret, mid );
      hi = mid-1;
    } else {
      lo = mid+1;
    }
  }
  cout << ret << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a,b,c;
    while(cin >> a >> b >> c)
        cout << (a+b >= c? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
S = [s() for _ in range(N)]
ac = S.count('AC')
wa = S.count('WA')
tle = S.count('TLE')
re = S.count('RE')
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 17116
import sys

l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n = int(input())
if n < 3:
  print("No")
  sys.exit()

l = [int(input()) for i in range(n)]
if (l1[0] in l and l1[1] in l and l1[2] in l) or (l2[0] in l and l2[1] in l and l2[2] in l) or (l3[0] in l and l3[1] in l and l3[2] in l) or (l1[0] in l and l2[0] in l and l3[0] in l) or (l1[1] in l and l2[1] in l and l3[1] in l) or (l1[2] in l and l2[2] in l and l3[2] in l) or (l1[0] in l and l2[1] in l and l3[2] in l) or (l1[2] in l and l2[1] in l and l3[0] in l):
  print("Yes")
  sys.exit()
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;

int A,B,l,r;

void solve()
{
    cin >> A >> B >> l >> r;

    if(A >= B)
    {
        int maxi = (A-1)/max(B+1,1ll) + 1;
        int sum = A+B;
        vector<int> temp;
        int ile = 0;
        for(int i = 0; i < (sum); ++i)
        {
            if(ile >= maxi or A == 0)
            {
                temp.pb(2); B--;
                ile = 0;
                continue;
            }

            if(A >= B)
            {
                A--;
                temp.pb(1); ile++;
                continue;
            }

            if((B-1) / max(A,1ll)  + 1 <= maxi)
            {
                A--; temp.pb(1); ile++; continue;
            }

            temp.pb(2); B--; ile = 0; continue;
        }
        for(int i = l-1; i < r; ++i) cout << (char)(temp[i]+'A'-1);
        cout << "\n";
    }
    else
    {
        int maxi = (B-1)/max(A+1,1ll) + 1;
        int sum = A+B;
        vector<int> temp;
        int ile = 0;
        for(int i = 0; i < (sum); ++i)
        {
            if(ile >=  maxi or A == 0)
            {
                temp.pb(2); B--;
                ile = 0;
                continue;
            }

            if(A >= B)
            {
                A--;
                temp.pb(1); ile++;
                continue;
            }

            if((B-1) / max(A,1ll)  + 1 <= maxi)
            {
                A--; temp.pb(1); ile++; continue;
            }

            temp.pb(2); B--; ile = 0; continue;
        }
        for(int i = l-1; i < r; ++i) cout << (char)(temp[i]+'A'-1);
        cout << "\n";
    }
}


int32_t main()
{
    ios_base::sync_with_stdio(false);
    int n,a,b; cin >> n >> a >> b;
    if((b-a) & 1)
    {
        cout << "Borys\n";
    }
    else
    {
        cout << "Alice\n";
    }
    return 0;
}



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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
pair<pair<string,int>,int> p[110];

int main() {
	int n; cin >> n;
	rep(i,n) {
		int t;
		string in;
		cin >> in >> t;
		p[i]=make_pair(make_pair(in,-t),i);
	}
	sort(p,p+n);
	rep(i,n) {
		cout << p[i].second+1 << endl;
	}
}

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

typedef long long ll;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  gcd(b,a%b);
}

int main() {
  ll N;
  cin >> N;
  vector<ll> T(N);
  for(ll i = 0;i<N;i++){
    cin >> T[i];
  }
  
  if(N>=2){
  ll LCM = (T[0]/gcd(T[0],T[1]))*T[1];
  for(ll i = 2;i<N;i++){
    LCM = (LCM/gcd(LCM,T[i]))*T[i];
  }
  cout << LCM << endl;
}
  else cout << T[0] << endl;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static int dfs(int current, Set<Integer>[] graph, boolean[] visited){
        visited[current] = true;
        int count = 1;
        if(graph[current] != null){
            for(int next : graph[current]){
                if(!visited[next]){
                    visited[next] = true;
                    count += dfs(next, graph, visited);
                }
            }
        }
        return count;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        int[] in = nextIntArray(br, 2);
        int n = in[0];
        int m = in[1];
        Set<Integer>[] graph = new HashSet[n];
        for(int i = 0; i < m; i++){
            int[] arr = nextIntArray(br, 2);
            if(graph[arr[0] - 1] == null) graph[arr[0] - 1] = new HashSet<>();
            if(graph[arr[1] - 1] == null) graph[arr[1] - 1] = new HashSet<>();
            graph[arr[0] - 1].add(arr[1] - 1);
            graph[arr[1] - 1].add(arr[0] - 1);
        }
        boolean[] visited = new boolean[n];
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(!visited[i]){
                ans = Math.max(ans, dfs(i, graph, visited));
            }
        }
        sb.append(ans);
        System.out.print(sb.toString());
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


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

const int N=1e5+5;
ll a[101][2],dp[105][N];
int n,w;

main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin>>n>>w;

    int ma=0;
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1],ma+=a[i][1];
    
    // memset(dp, 0x3f, sizeof(dp));
    fill(dp[0],dp[101]+N,1e18);
    // cout<<dp[0][0]<<"\n";
    for(int i=0;i<n;i++){
        for(int val=0;val<=ma;val++){
            // dp[i][val]=1e18;

            if(val==a[i][1])    
                dp[i][val]=min(dp[i][val],a[i][0]);

            if(i)   dp[i][val]=min(dp[i][val],dp[i-1][val]);

            if(val>=a[i][1] && i && dp[i-1][val-a[i][1]]!=1e18){
                dp[i][val]=min(a[i][0]+dp[i-1][val-a[i][1]],dp[i][val]);    
            }

        }        
    }
    for(int val=ma;val>=0;val--){
        for(int i=0;i<n;i++){
            if(dp[i][val]<=w){
                cout<<val<<"\n";
                return 0;
            }
        }
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {
    int A, B, C;
    cin>>A>>B>>C;
    
    if(A<C && C<B) Yes;
    else if(B<C && C<A) Yes;
    else No;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <string>

using namespace std;

int main(){
 int n, k, c;
 cin >> n >> k >> c;
 string s;
 cin >> s;
 vector <int> a;
 for (int i = 0; i < n; i++)
  if (s[i] == 'o')
   a.push_back(i);
 int l = a.size();
 pair <int,int> par = make_pair(-1,0);
 vector <pair<int,int> > inf(l,par);
 vector <int> najkraci;
 for (int i = 0; i < l; i++){
   if (inf[i].first == -1){
     vector <int> trenutni(1,i);
     int ind = i + 1, len = 1, poz = a[i];
     while (ind < l){
     int ne = poz + c;
     while (ind < l && a[ind] <= ne)
      ind++;
     if (ind >= l)
      break;
     if (inf[ind].first != -1){
       len += inf[ind].second - inf[ind].first + 1;
       break;
     } else {
       trenutni.push_back(ind);
       poz = a[ind];
     }
     len++;
     }
     for (int j = 0; j < trenutni.size(); j++)
      inf[trenutni[j]].first = j + 1, inf[trenutni[j]].second = len;
     if (i == 0)
      for (int j = 0; j < trenutni.size(); j++)
       najkraci.push_back(trenutni[j]);
   }
 }
 /*for (int i = 0; i < l; i++)
  cout << inf[i].first << " " << inf[i].second << endl;*/
 if (inf[0].second > k)
  return 0;
 if (inf[0].second < k)
  return 0;
 /*for (int i = 0; i < k; i++)
  cout << najkraci[i] << endl;*/
 for (int i = 0; i < k; i++){
   int ispit = najkraci[i] + 1;
   if (inf[ispit-1].first + inf[ispit].second - inf[ispit].first < k || ispit >= l)
    cout << a[ispit-1] + 1<<endl;
 }
}


Measured memory_bytes: 5112
import java.util.*;

public class Main {

    static int n, m ,r;
    static int[] R;
    static long[][] d;
    static int[][][] g;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        r = sc.nextInt();
        R = new int[r];
        for (int i = 0; i < r; i++) {
            R[i] = sc.nextInt()-1;
        }
        int[][] e = new int[m][3];
        for (int i = 0; i < m; i++) {
            e[i][0] = sc.nextInt()-1;
            e[i][1] = sc.nextInt()-1;
            e[i][2] = sc.nextInt();
        }
        g = buildWeightedGraph(n, e);
        d = new long[n][];
        for (int i = 0; i < r; i++) {
            d[R[i]] = dijkstra(n, g, R[i]);
        }
        long ans = Long.MAX_VALUE/2;
        for (int i = 0; i < r; i++) {
            boolean[] used = new boolean[r];
            used[i] = true;
            long tmp = dfs(i, used, 0L);
            if(tmp < ans) ans = tmp;
        }
        System.out.println(ans);
        sc.close();

    }

    private static long dfs(int v, boolean[] used, long c) {
        long ret = Long.MAX_VALUE;
        for (int i = 0; i < r; i++) {
            if(used[i]) continue;
            used[i] = true;
            long tmp = dfs(i, used, c + d[R[v]][R[i]]);
            used[i] = false;
            if(tmp < ret) ret = tmp;
        }
        if(ret == Long.MAX_VALUE) ret = c;
        return ret;
    }

    public static long[] dijkstra(int n, int[][][] graph, int s) {
        // {sからの最短距離, 頂点}
        PriorityQueue<long[]> pq = new PriorityQueue<long[]>((x, y) -> Long.compare(x[0], y[0]));
        long[] d = new long[n]; // sからの最短距離
        Arrays.fill(d, Long.MAX_VALUE);
        d[s] = 0;
        pq.add(new long[] { 0, s });
        while (!pq.isEmpty()) {
            long[] a = pq.poll();
            int v = (int) a[1];
            if (d[v] < a[0])
                continue;
            for (int[] g : graph[v]) {
                int to = g[0];
                int cost = g[1];
                if (d[to] > d[v] + cost) {
                    d[to] = d[v] + cost;
                    pq.add(new long[] { d[to], to });
                }
            }
        }

        return d;
    }

    public static int[][][] buildWeightedGraph(int n, int[][] edges){
        int m = edges.length;
        int[][][] graph = new int[n][][];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            deg[ edges[i][0] ]++;
            deg[ edges[i][1] ]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]][2];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            int c = edges[i][2];
            graph[a][--deg[a]][0] = b;
            graph[a][deg[a]][1] = c;
            graph[b][--deg[b]][0] = a;
            graph[b][deg[b]][1] = c;
        }

        return graph;
    }

}


Measured memory_bytes: 50860
N = int(input())
A = list(map(int, input().strip().split()))
count = 0
for i in range(N):
  if i+1 == A[i]:
    count+=0
  else:
    count+=1
if count == 2:
  print("YES")
elif count ==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    string r = "";
    rep(i, s.size()) {
        if (s[i] == 'B') {
            if (r.size() >= 1){
                r = r.substr(0, r.size() - 1);
            }
        }
        else {
            r.push_back(s[i]);
        }
    }
    put(r)
    return 0;
}

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

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0; i <= 3000/r; i++){
        if(i*r > n) break;
        for(int j = 0; j <= 3000/g; j++){
            if(i*r+j*g > n) break;
            if((n-i*r-j*g)%b == 0)  ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long           ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}

ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
void yes_or_no(ll x) {
    if (x) cout << "YES\n"; else cout << "NO\n";
}
int maxAbsValExpr(vector<int>& x, vector<int>& y) {
    int res = 0, n = x.size(), smallest, cur;
    for (int p : {1, -1}) {
        for (int q : {1, -1}) {
            smallest = p * x[0] + q * y[0] + 0;
            for (int i = 1; i < n; ++i) {
                cur = p * x[i] + q * y[i] ;
                res = max(res, cur - smallest);
                smallest = min(smallest, cur);
            }
        }
    }
    return res;
}
void solve_test() {
    ll ans = 0;
    ll n;
    cin >> n;
    vector<ll> store;
    vector<int> x(n), y(n);

    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    ans = maxAbsValExpr(x, y);

    cout << ans << "\n";
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;

    solve_test();

    return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    s += "####";
    bool f = true;
    string yes = "Yes", no = "No";
    --a;
    --b;
    REP(i, a, c-1) {
        if(s[i] == '#' && s[i+1] == '#') f = false;
    }
    REP(i, b, d-1) {
        if(s[i] == '#' && s[i+1] == '#') f = false;
    }
    if(c > d) {
        f = false;
        REP(i, b, d) {
            if(s[i] == '.' && s[i-1] == '.' && s[i+1] == '.') f = true;
        }
    }
    // else if(a < b && b < c) {
    //     f = false;
    //     REP(i, b, c) {
    //         if(s[i] == '.' && s[i-1] == '.' && s[i+1] == '.') f = true;
    //     }
    // }
    cout << (f ? yes : no) << endl;
    return 0;
}

Measured memory_bytes: 768
x = gets.chomp
prev_s = 0
len = x.length
cnt = 0
len.times do |i|
  if x[i] == 'S'
    prev_s += 1
  else
    if prev_s > 0
      cnt += 1
      prev_s -= 1
    end
  end
end
puts len - 2 * cnt

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

int main(){
  bool ans=1;
  int H,W;
  cin >> H >> W;
  vector<vector<char>> vec(H+2,vector<char>(W+2,'.'));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++)
    cin >> vec.at(i+1).at(j+1);
  }
  for(int k=0;k<H;k++){
    for(int l=0;l<W;l++){
      if(vec.at(k+1).at(l+1)=='#'){
        if(vec.at(k).at(l+1)=='.'&&vec.at(k+2).at(l+1)=='.'&&vec.at(k+1).at(l)=='.'&&vec.at(k+1).at(l+2)=='.')
        ans=0;
      }
    }
  }
  if(ans)
  cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
  

}
  

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> A(H);
	for (int i = 0; i < H; i++) cin >> A[i];
	for (int i = 0; i < W + 2; i++) cout << "#";
	cout << endl;
	for (int i = 0; i < H; i++) cout << "#" << A[i] << "#" << endl;
	for (int i = 0; i < W + 2; i++) cout << "#";
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int f(int n,int k){
  if(n<=1)return 0;
  return (f(n-1,k)+k)%n;
}

int main(void){
  int n,k,m;
  while(cin>>n>>k>>m,n){
    cout<<(f(n-1,k)+m) % n + 1<<endl;
  }
}

//???>??????>??????>??¢????´?

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x;
	cin >> n >> x;
	vi arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr.begin(),arr.end());
	int ans = 0;
	for(int i = 0; i < n-1; i++) {
		if(arr[i] <= x) {
			ans++;
			x-= arr[i];
		} else {
			cout << ans;
			return 0;
		}
	}
	if(x == arr[n-1]) {
		ans++;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(5 * 10**5)
input = sys.stdin.readline
 
y, m, d = map(int, input().split("/"))
 
if y == 2019:
    if m >= 5:
        print("TBD")
    else:
        print("Heisei")
elif y > 2019:
    print("TBD")
else:
    print("Heisei")

Measured memory_bytes: 3060