akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  for(int c: ran(N)) {
    i64 s, f;
    cin >> s >> f;
    if(f <= a || b <= s);
    else {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);


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

  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> w(n, 0);

  char prev = s[0];
  w[0] = 0;
  for (int i = 1; i < s.size(); i++) {
    if (prev == 'A' && s[i] == 'C') {
      w[i] = w[i-1] + 1;
    } else {
      w[i] = w[i-1];
    }
    prev = s[i];
  }

  rep(i, q) {
    int l, r;
    cin >> l >> r;
    l--; r--;
    cout << w[r] - w[l] << endl;
  }

  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string S;
    cin >> S;
    ll N = (ll)S.size();
    reverse(S.begin(), S.end());
    Vl nums(2019);
    ll t = 0;
    ll base = 1;
    ++nums[0];
    for (ll i = 0; i < N; i++) {
        ll d = S[i] - '0';
        t = (d * base + t) % 2019;
        ++nums[t];
        base = base * 10 % 2019;
    }

    ll ans = 0;
    for (ll i = 0; i < 2019; i++) {
        ans += nums[i] * (nums[i] - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{ 
  int64_t a, b, k ;
  cin >> a >> b >> k ;

  for(int i = 0 ; i < k ; i++)
  {
    if(i == 0 || i % 2 == 0)
    {
      if(a % 2 == 0)
      {
        b += a / 2 ;
        a /= 2 ;
      }
      else
      {
        a -= 1 ;
        b += a / 2 ;
        a /= 2 ;
      }
    }
    else
    {
      if(b % 2 == 0)
      {
        a += b / 2 ;
        b /= 2 ;
      }
      else
      {
        b -= 1 ;
        a += b / 2 ;
        b /= 2 ;
      }
    }
  }

  cout << a << " " << b << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
 
int main(){
  int n,sy = 1;
  cin >> n;
  vector<int> a(n);
  REP(i,n) {
    cin >> a[i];
  }
  VSORT(a)
  for(int i = 1;i < n;i++) {
    if (a[i] != a[i-1]) {
      sy++;
    }
  }
  if(sy % 2 == 0) {
    cout << sy-1;
  } else {
    cout << sy;
  }
}

Measured memory_bytes: 640
n,m=map(int,raw_input().split())
ab=[map(int,raw_input().split()) for _ in xrange(n)]
cd=[map(int,raw_input().split()) for _ in xrange(m)]
ans=[]
for i in xrange(n):
    a,b=ab[i]
    tmp=10**12
    idx=-1
    for j in xrange(m):
        c,d=cd[j]
        if abs(a-c)+abs(b-d)<tmp:
            tmp=abs(a-c)+abs(b-d)
            idx=j
    ans.append(idx)
for i in xrange(n):
    print ans[i]+1


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int main () {
    int a;
    int b;
    cin >> a;
    cin >> b;
    if ((a+b)%2 == 0){
        cout << (a+b)/2 << endl;
    }
    else {
        cout << (a+b)/2 + 1<< endl;
    }
}

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

int main(){
  int s = 100050;
  int n;
  int a[200700];
  cin >> n;
  for(int i = 0;i < 200500;i++){
    a[i] = -1;
  }
  for(int i = 1;i <= n;i++){
    if(i == 1){
      cin >> a[s];
    }
    else if(i % 2 == 0){
      cin >> a[s - i/2];
    }
    else if(i % 2 != 0){
      cin >> a[s + (i-1)/2];
    }
  }
  int start,end;
  for(int i = 0;i < 200300;i++){
    if(a[i] == -1 && a[i+1] != -1){
      start = i+1;
    }
    if(a[i] != -1 && a[i+1] == -1){
      end = i;
    }
  }
  if(n % 2 == 0){
    for(int i = start;i <= end;i++){
      cout << a[i] <<  " ";
    }
  }
  if(n % 2 != 0){
    for(int i = end;i >= start;i--){
      cout << a[i] << " ";
    }
  }
  cout << " " << endl;
}  

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

int main() {
    string checklist[] = {"dream", "dreamer", "erase", "eraser"}; 
    string S = "";
    cin >>S;

    reverse(S.begin(), S.end());
    for(int i = 0; i<4; i++) reverse(checklist[i].begin(), checklist[i].end());

    int check_pos = 0;
    string res = "YES";
    while(1){
        bool check_flg = false;
        for(int i = 0; i<4; i++) {
            if(S.substr(check_pos, checklist[i].size()) == checklist[i]) {
                check_pos += checklist[i].size();
                check_flg = true;
            }
        }
        if(check_flg == false) {
            res = "NO";
            break;
        }
        if(check_pos >= S.size() - 1) break;
    }
    cout << res << endl;
}

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

const int N=100009;
const int M=200009;

int n,m,l,r,d;
int x[N],fa[N];
int dis[N];

inline int findfa(int x)
{
	if(fa[x]==x)return x;
	int f=findfa(fa[x]);
	dis[x]=dis[x]+dis[fa[x]];
	fa[x]=f;
	return f;
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		fa[i]=i,dis[i]=0;

	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&l,&r,&d);
		if(findfa(l)==findfa(r))
		{
			if(dis[l]+d!=dis[r])
			{
				puts("No");
				return 0;
			}
		}
		else	
		{
			int x=findfa(l),y=findfa(r);
			fa[y]=x;dis[y]=dis[l]+d-dis[r];
		}
	}

	puts("Yes");
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<stack>
#include<iterator>
#include<functional>
#include<string.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	unsigned long long int n, p; cin >> n >> p;
	unsigned long long int tmp = 0;
	float t = 1.0000000000000000 / n;
	unsigned long long int s = pow(p, t);
	if (s < 0) {
		s = 1;
	}
	for (unsigned long long int i = s; i>0; i--) {
		unsigned long long k = pow(i, n);
		if (p%k == 0) {
			tmp = i;
			break;
		}
	}
	cout << tmp << endl;
}
	

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	 	Scanner sc = new Scanner(System.in);
	 	int A = sc.nextInt();
	 	int B = sc.nextInt();
	 	int C = sc.nextInt();
	 	int D = sc.nextInt();
	 	int time = 0;

	 	if(Math.max(A,C) <= Math.min(B,D)) {
	 		time = Math.min(B,D) - Math.max(A,C);
	 	}

	 	System.out.println(time);
	 }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
long long dp[10005][101][2],mod=1000000007;
string k;
long long solve(int i,int n ,int su,bool tight,int d){
    if(i==n){
        return su==0;
    }
    if(dp[i][su][tight]!=-1)
        return dp[i][su][tight];
    int mx=(tight?k[i]-'0':9);
    long long ans=0;
    for(int j=0;j<=mx;j++){
        ans=(ans%mod+solve(i+1,n,(su+j)%d,tight&(j==mx),d)%mod)%mod;
    }
    dp[i][su][tight]=ans;
    return ans;
}
 
int main(){
 
long long d;
cin>>k;
cin>>d;
 
memset(dp,-1,sizeof(dp));
cout<<(solve(0,k.size(),0,1,d)-1+mod)%mod<<"\n";
 
 
}

Measured memory_bytes: 17152
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	S += S;
	bool check = true;
	for (int i = 0; i < T.size(); i++) {
		check = true;
		for (int j = 0; j < T.size(); j++) {
			if (S.at(j + i) != T.at(j)) check = false;
		}
		if (check) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
average = 0
def sum(m,array)
  wa = 0
  for i in 0..m
    wa += array[i]
  end
  wa
end

average = sum(n-1,a).to_f/2
y = 0
for i in 0..(n-2)
  y += a[i]
  if y.to_f == average
    puts 0
  elsif y < average && (y+a[i+1]) > average
    x = [(average - y).abs,(average - (y+a[i+1])).abs].min
    puts (2*x).to_i
  end
end

Measured memory_bytes: 17804
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();		//n個の整数
		/*long zyou = (long) Math.pow(10, 18);
		
		long result=0;

		for(int i=0;i<n;i++) {		//n個の整数を計算
			long a=sc.nextLong();
			
			if(i==0) {
				result=a;
			}else {
				result=result*a;
			}
		}
		
		//System.out.println(zyou);
		//System.out.println(result);
		
		if(zyou<result) {
			System.out.println(-1);
		}else {
			System.out.println(result);
		}*/
		
		long result=1;
		long zyou = (long) Math.pow(10, 18);
		
		for(int i=0;i<n;i++) {
			long a=sc.nextLong();
			if(a==0) {
				result=0;
				break;
			}
			if(zyou/result>=a) {
				result*=a;
			}else {
				result=-1;
			}
		}
		System.out.println(result);
		sc.close();
	}
}

Measured memory_bytes: 49160
n = int(input())
A = list(map(int, input().split()))

for i in range(len(A)):
  if A[i] %2 == 0:
    if A[i]%3 != 0 and A[i]%5 != 0:
      print("DENIED")
      exit()
    else:
      pass
  else:
    pass
  
print("APPROVED")

Measured memory_bytes: 3060
#5問目
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = []
for i in range(N):
    t = int(input())
    T.append(t)
    
print(lcm_list(T))

Measured memory_bytes: 5052
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    int st, en;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') {
            st = i;
            break;
        }
    }
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s[i] == 'Z') {
            en = i;
            break;
        }
    }
    cout << en - st + 1 << "\n";
    return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]

    ans = 0
    for i in range(len(B)-1, -1, -1):
        m = min(A[i+1], B[i])
        ans += m
        A[i+1] -= m
        B[i] -= m

        m = min(A[i], B[i])
        ans += m
        A[i] -= m
        B[i] -= m

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 25356
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    int n,a,b;
    string str;
    cin >> n >> a >> b;
    cin >> str;
    int total = 0;
    int bc = 0;
    rep(i,n) {
        if(str[i]=='c') {
            cout << "No" << endl;
            continue;
        }
        if(str[i]=='b' && bc<b && total<(a+b)) {
            total++;
            bc++;
            cout << "Yes" << endl;
        }else if(str[i]=='a'&& total<(a+b)) {
            total++;
            cout << "Yes" << endl;
        }else
        {
            cout << "No" << endl;
        }
        
    }

  return 0;
}



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

int main() {
  int x,a;
  cin>>x>>a;

  if ((x%500) <= a) cout<<"Yes"<<endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int a, b, t; cin>>a>>b>>t;
    cout << t / a * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    double x[n];
    string s[n];
    for(int i=0;i<n;++i) cin >> x[i] >> s[i];
    double sum=0;
    for(int i=0;i<n;++i) {
        if(s[i]=="JPY") sum+=x[i];
        else sum+=(380000.0*x[i]);
    }
    cout << fixed << setprecision(8) << sum << endl;
}

    

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<long long> find_divisors(long long N) {
	vector<long long> res;
	for (int i = 1; 1LL * i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			if (1LL * i * i != N) {
				res.push_back(N / i);
			}
		}
	}
	sort(res.begin(), res.end());
	return res;
}
int main() {
	long long N;
	cin >> N;
	vector<long long> d1 = find_divisors(N);
	vector<long long> d2 = find_divisors(N - 1);
	vector<long long> d3 = d1;
	d3.insert(d3.end(), d2.begin(), d2.end());
	sort(d3.begin(), d3.end());
	d3.erase(unique(d3.begin(), d3.end()), d3.end());
	int ans = 0;
	for (long long i : d3) {
		if (i == 1) continue;
		long long x = N;
		while (x % i == 0) x /= i;
		if (x % i == 1) {
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C;
    cin >>A>>B>>C;


    
    cout << min(B/A,C) << endl;


    return 0;
    

}

Measured memory_bytes: 3600
import math
import copy

n = int(input())
# k, x = [int(i) for i in input().split()]
# table = [[int(i) for i in input().split()] for j in range(n)]
# table = [list(input()) for n in range(h)]
# s = [int(i) for i in input().split()]
# num = [int(i) for i in range(n)]
# s = [input() for i in range(n)]
# s = input()
# list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]
#s = [input() for i in range(n)]

print(n*n*n)

Measured memory_bytes: 3956
from itertools import groupby

n, m = map(int, input().split())
ipy = [[i] + list(map(int, input().split())) + [0] for i in range(m)]

ipy.sort(key=lambda x: (x[1], x[2]))

cnt = 1
for itr, v in enumerate(ipy):
  if itr > 0:
    if ipy[itr - 1][1] != ipy[itr][1]:
      cnt = 1 
  p = str(v[1]).zfill(6) + str(cnt).zfill(6)
  ipy[itr][3] = p
  cnt += 1

ipy.sort(key=lambda x: (x[0]))

for i in ipy:
  print(i[3])

Measured memory_bytes: 38676
n,m=map(int,input().split())
x=[2,5,5,4,5,6,3,7,6]#各数に使うマッチ棒の本数
a=[]#使う数字でけ格納するリスト
for i in map(int,input().split()):
    a.append([i,x[i-1]])#数と使う本数をリストで入力
    #ここでタプルにするとソートできない
a.sort(reverse=True)
#tuple(a)#タプルにしても実行時間、メモリーに大きな変化なし
#ソートしないと、大きい数字が先に来ないので間違う
#(OK)print(a)使える数字だけ
dp=[0]*(n+1)
#dp[i]：ちょうどi本使った時に表せる最大の数
#ループの順番が、いまひとつ、腑に落ちない
for i in range(m):
#外側ループが使用できる数、最初１番大きい数字、その後、使える数字が増える
    for j in range(n+1):#マッチ棒は0からnまで使える
        if j==0 or dp[j]!=0:
        #(NG)if dp[j]!=0: 「jの範囲を1始め」でもNG
            if j+a[i][1]<=n:#マッチ棒が使用範囲内なら
                #print(dp[j+a[i][1]],dp[j]*10+a[i][0])
                #print(max(dp[j+a[i][1]],dp[j]*10+a[i][0]))
                dp[j+a[i][1]]=max(dp[j+a[i][1]],dp[j]*10+a[i][0])
#この更新はDP典型。右１項が左と同じ。右は両項とも、前から使っているj本に
#新しく使うi番目を使った　本数での数を表している。
print(dp[n])

Measured memory_bytes: 16492
#include<iostream>
using namespace std;
int main() {
	long long X;
	cin >> X;
	long long sum = 0;
	for (long long i = 1; i <= X; ++i) {
		sum += i;
		if (sum >= X) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

n = int(input())
s = []
s.append(input())
s.append(input())
MOD = 1000000007
ans = 1
last = 0
i = 0
while i < n:
    if s[0][i] == s[1][i]:
        if last == 1:
            ans = ans * 2 % MOD
        elif last == 0:
            ans = 3
        last = 1
        i += 1
    else:
        if last == 1:
            ans = ans * 2 % MOD
        elif last == 2:
            ans = ans * 3 % MOD
        else:
            ans = 6
        last = 2
        i += 2
print(ans)


Measured memory_bytes: 3064
function main()
	X,N=map(x->parse(Int,x),split(readline()))
	A=map(x->parse(Int,x),split(readline()))
	function f(T)
		for i=1:N
			if A[i]==T
				return true
			end
		end
		return false
	end
	for k=0:114514
		if !f(X-k)
			println(X-k)
			exit()
		elseif !f(X+k)
			println(X+k)
			exit()
		end
	end
end
main()


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

int main()
{
    ios_base::sync_with_stdio(false);
    int n, k, q;
    cin >> n >> k >> q;
    int score[n + 1];
    fill(score, score + n + 1, 0);
    for(int i= 0;i < q;i++)
    {
        int a;
        cin >> a;
        score[a]++;
    }
    for(int i = 1;i <= n;i++)
    {
        if(q - score[i] < k)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << x[k-1] << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)
	ac := make([]int, N+1)
	wa := make([]int, N+1)
	var p int
	var s string
	for i := 0; i < M; i++ {
		fmt.Scanf("%d %s", &p, &s)
		if s == "AC" {
			ac[p]++
		} else {
			if ac[p] == 0 {
				wa[p]++
			}
		}
	}
	count := 0
	penalty := 0
	for i := 0; i < N+1; i++ {
		if ac[i] > 0 {
			count++
			penalty += wa[i]
		}
	}
	fmt.Printf("%d %d\n", count, penalty)
}


Measured memory_bytes: 5504
//catgo
#include <iostream>
#define ll long long int
using namespace std;
ll n,k,a[5000000];
bool check(int m)
{
    ll sl=0;
    for(ll i=1; i<=n; ++i)
    {
        sl=sl+a[i]/m;
        if(a[i]%m==0) sl--;
    }
    return (sl<=k);
}
int main()
{
    //freopen("b.inp","r",stdin);
    cin>>n>>k;
    for(ll i=1; i<=n; ++i) cin>>a[i];
    ll d=1, c=a[1],g,m;
    for(ll i=2; i<=n; ++i) c=max(c,a[i]);
    while(d<=c)
    {
        g=(d+c)/2;
        if(check(g))
        {
            m=g;
            c=g-1;
        }
        else d=g+1;
       // cout<<m<<" "<<g<<endl;;
    }
    cout<<m;
    return 0;
}


Measured memory_bytes: 5036
function main()
	nx = parse.(split(readline()))
	a = parse.(split(readline()))
	l = nx[1]
	for i in 1:l
		for j in 1:l-1
			if a[j] > a[j+1]
				temp = a[j+1]
				a[j+1] = a[j]
				a[j] = temp
			end
		end
	end

	sum = 0
	count = 0
	while sum < nx[2]
		if count == nx[1]
			break
		else
			count += 1
			sum = sum + a[count]
		end
		if sum == nx[2]
			count +=1
		end
	end
	print(count-1)
end


main()

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N, K;
  cin >> N >> K;
  if (N < 2*K - 1) {
    cout << -1 << endl;
    return 0;
  }
  if (1) {
    int64 x = K, y = K+2*N-1, z = K+3*N-(N+1)/2;
    REP(i, (N+1)/2) {
      cout << x << " " << y << " " << z << endl;
      x += 2; y--; z++;
    }
    x = K+1; z = K+2*N;
    REP(i, N/2) {
      cout << x << " " << y << " " << z << endl;
      x += 2; y--; z++;
    }
  }
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int, int>>
#define fi first
#define se second

#define p 1000000007

using namespace std;

typedef long long ll;

string s;
int main(){
	int n, k;
	cin >> n >> k >> s;
	int partition = 1;
	int prev = s[0];
	for(int i=1;i<n;i++){
		if(s[i] != prev){
			partition++;
		}
		prev = s[i];
	}
	for(int i = 0; i < k; i++){
		if(partition >= 3){
			partition -= 2;
		}else if(partition == 2){
			partition--;
		}
	}
	cout << n - partition << endl;
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 110;
const ll inf = 1e18;


const ll N = 1000;

int n, m;
string grid[maxn];

struct edge {
    int to, rev; ll cap;
};

vector<edge> g[maxn*2];
bool viz[maxn*2];

void add_edge(int v1, int v2, ll cost) {
    g[v1].push_back(edge{v2, (int)g[v2].size(), cost});
    g[v2].push_back(edge{v1, (int)g[v1].size()-1, 0});
}

ll find_augment(int at, int dest, ll curflow) {
    if (at == dest) {
	return curflow;
    }
    viz[at]=true;

    for (auto& ed: g[at]) {
	if (!viz[ed.to] && ed.cap>0) {
	    ll newflow = find_augment(ed.to, dest, min(curflow, ed.cap));
	    if (newflow > 0) {
		ed.cap -= newflow;
		g[ed.to][ed.rev].cap += newflow;
		return newflow;
	    }
	}
    }
    return 0;
}



ll max_flow(int src, int dst) {
    ll res = 0;
    while (1) {
	memset(viz,false,sizeof(viz));
	ll x = find_augment(src, dst, inf);
	if (x==0) break;
	res += x;
	if (res > N) break;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    for (int i=0; i<n; i++) {
	cin>>grid[i];
    }

    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    if (grid[i][j] == 'S') {
		add_edge(n+m, i, inf);
		add_edge(i, j+n, inf);
		add_edge(j+n, i, inf);
	    }
	    if (grid[i][j] == 'T') {
		add_edge(i, j+n, inf);
		add_edge(j+n, i, inf);
		add_edge(i, n+m+1, inf);
	    }
	    if (grid[i][j] == 'o') {
		add_edge(i, j+n, 1);
		add_edge(j+n, i, 1);
	    }
	}
    }




    ll res = max_flow(n+m, n+m+1);
    if (res>N) out(-1);
    out(res);
  

    return 0;
}


Measured memory_bytes: 1152
//ITP1_6_B
//????????????  ???

using System;
using System.Collections.Generic;

class ITP1_6_B
{
    static void Main(string[] args)
    {
        //n????????±??°?????£??\

        int n = int.Parse(Console.ReadLine());
        int[,,] iarray = new int[ 4, 3, 10];
        
        //n???sarray???????????£??\

        for (int i = 0; i < n; i++)
        {
            int[] st= Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
            {
                return int.Parse(value);
            });

            //b?£?f??????r???????????¨?±????v??????????????§??\?±?

            iarray[st[0] - 1, st[1] - 1, st[2] - 1] += st[3];

        }

        //???????????????

        for(int b = 0; b < 4 ; b++)
        {
            for(int f = 0; f < 3; f++)
            {
                for(int r = 0; r < 10; r++)
                {
                    if (iarray[b, f, r] >= 0)
                        Console.Write(" " + iarray[b, f, r]);
                    else
                        Console.Write(" " + 0);
                }

                Console.Write("\r\n");

            }
            if(b != 3)
                Console.WriteLine("####################");
        }

    }
}

Measured memory_bytes: 9132
N = int(input())

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

for i in range(len(nums)):
    num = nums[i]
    j = i - 1
    while j >= 0 and nums[j] > num:
        nums[j + 1] = nums[j]
        j -= 1
    nums[j + 1] = num

    print(*nums)


Measured memory_bytes: 5984
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    cout << s[0];
    cout << (int)s.size() - 2;
    cout << s[(int)s.size() - 1];
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

ll N;
vector<string> ans;
void dfs(string s) {
  if(stoll(s) > N) return;
  if(s.size() > 10) return;
  if(s.size() <= 10 && s.size() > 2) {
    bool flag = false;
    map<char, int> m; m['3'] = 0; m['5'] = 0; m['7'] = 0;
    REP(i, s.size()) m[s[i]]++;
    if(m['3'] > 0 && m['5'] > 0 && m['7'] > 0) flag = true;
    if(flag == true) ans.push_back(s);
  }
  dfs(s + "3");
  dfs(s + "5");
  dfs(s + "7");
}

int main() {
  cin >> N;
  dfs("3");
  dfs("5");
  dfs("7");
  cout << ans.size() << endl;
}


Measured memory_bytes: 4304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = a[0];
  reps1(i, n) {
    ans = __gcd(ans, a[i]);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2 scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%ld",n)
#define prln(n) printf("%ld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)


const int N=1000005;
int a[N];
int vis[N];

int main()
{
    ll ans=0ll,temp=0ll;
    int n;
    read(n);
    while(n--)
    {
        int x;
        read(x);
        if(x)
        temp+=x;
        else{
            ans+=temp/2;
            temp=0;
        }
    }
    ans+=temp/2;
    prln(ans);
    return 0;
}















Measured memory_bytes: 256
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
void solve(long long N, std::vector<long long> P) {
  lli mi = 1e8;
  lli ans = 0;
  rep(i, N) {
    if (mi > P[i]) {
      ans++;
    }
    mi = min(P[i], mi);
  }
  cout << ans << endl;
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  std::vector<long long> P(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &P[i]);
  }
  solve(N, std::move(P));
  return 0;
}


Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
V = LIST()
C = LIST()

ans = 0

for i in range(N):
	if V[i]-C[i] >= 0:
		ans +=  V[i]-C[i]

print(ans)

Measured memory_bytes: 5396
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int p[]=new int[N];
		for(int i=0;i<N;i++)
			p[i]=sc.nextInt();
		sc.close();
		Arrays.sort(p);
		int sum=0;
		for(int i=0;i<K;i++)
			sum+=p[i];
		System.out.println(sum);
	}
}


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

int main(int argc, char *argv[]){
  int n;
  cin>>n;
  vector<int> pvec(n);
  vector<int> sor(3);
  int p;
  for(int i=0; i<n; i++){
    cin>>p;
    pvec[i]=p;
  }
  int count=0;
  for(int i=0; i<n; i++){
    if(i==0||i==n-1) continue;
    sor[0]=pvec[i-1];
    sor[1]=pvec[i];
    sor[2]=pvec[i+1];
    sort(sor.begin(),sor.end());
    if(sor[1]==pvec[i]) count++;
  }
  cout<<count<<endl;


}

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}
#define int ll
void solve() {
	int h, w, n;
	cin >> h >> w >> n;
	cout << (n+max(h,w)-1) / max(h, w) << endl;
}

#undef int

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n, t = 0, h = 0;
    cin >> n;

	rep(i, n) {
		string s, w;
        cin >> s >> w;
		if(s > w) t += 3;
		else if(s < w) h += 3;
		else t++, h++;
	}
    
	cout << t << ' ' << h << endl;
    return 0;
}


Measured memory_bytes: 3184
n = int(input())
R = [int(x) for x in input().split()]#リスト内包表記

def bubble_sort(r):
    flag=True
    i=0
    count=0
    while flag:
        flag=False
        for i in range(n-1,i,-1):#iは1でとまらないとi-1が-1となってしまう
            if r[i]<r[i-1]:
                r[i],r[i-1]=r[i-1],r[i]#swap
                count+=1
                flag=True#入れ替える条件があって初めてtrueになる
    print(*r)
    print(count)

bubble_sort(R)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    } else if (abs(a - c) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
s = input()

if len(s) == 1:
    print(0)
else:
    # 最初の文字をそのまま使う場合
    prev_char = s[0]
    cntr1 = 0
    for x in s[1:]:
        if x == prev_char:
            cntr1 += 1  # flip
            prev_char = '0' if x == '1' else '1'
        else:
            prev_char = x
    
    # 最初の文字を反転させる場合
    prev_char = '0' if s[0] == '1' else '1'
    cntr2 = 1
    for x in s[1:]:
        if x == prev_char:
            cntr2 += 1
            prev_char = '0' if x == '1' else '1'
        else:
            prev_char = x
    
    print(min([cntr1, cntr2]))

Measured memory_bytes: 3188
#include<stdio.h>
int main(void){
int a, b;
scanf("%d %d", &a, &b);
if (a < b){
    printf("a < b\n");
}
else if (a > b){
    printf("a > b\n");
}
else {
    printf("a == b\n");
}
return 0;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ans;
  if (N % 2)
  {
    for (int l = 1, r = N - 1; l < r; l++, r--)
    {
      ans.emplace_back(l, r);
    }
  }
  else
  {
    bool flg = false;
    for (int l = 1, r = N - 1; l < r; l++, r--)
    {
      if (!flg && r - l <= N / 2)
      {
        r--;
        flg = true;
      }
      ans.emplace_back(l, r);
    }
  }
  for (int i = 0; i < M; i++)
  {
    cout << ans[i].first << ' ' << ans[i].second << endl;
  }
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int Power3(int p) {
  int r = 1;
  for (int i = 0; i < p; i++) {
    r *= 3;
  }
  return r;
}

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

  int n;
  cin >> n;
  string original_command;
  cin >> original_command;
  vector<vector<int>> output_table(n + 1);
  vector<vector<string>> command_table(n + 1);
  for (int k = 1; k <= n; k++) {
    output_table[k].resize(Power3(k));
    command_table[k].resize(Power3(k));
  }

  for (int k = 1; k <= n; k++) {
    for (int x = 0; x < Power3(k); x++) {
      // cout << "k: " << k << " x: " << x << endl;

      string command;
      if (k == 1) {
        command = original_command;
      } else {
        command = command_table[k - 1][x % Power3(k - 1)];
      }

      int d = x / Power3(k - 1);
      string next_command = "";
      for (char c : command) {
        if (c == 'R') {
          d++;
          if (d == 3) {
            d = 0;
            next_command.append("R");
          }
        } else if (c == 'S') {
          if (d == 1) d = 2;
          else if (d == 2) d = 1;

          next_command.append("S");
        }
      }

      next_command = std::regex_replace(next_command, std::regex("SS"), "");

      output_table[k][x] = d;
      command_table[k][x] = next_command;
    }
  }

  vector<int> outputs;
  for (int x = 0; x < Power3(n); x++) {
    int output = 0;
    for (int k = 1; k <= n; k++) {
      output += output_table[k][x % Power3(k)] * Power3(k - 1);
    }
    outputs.push_back(output);
  }

  for (int i = 0; i < outputs.size(); i++) {
    if (i > 0) cout << " ";
    cout << outputs[i];
  }
  cout << endl;
}


Measured memory_bytes: 38436
#include <iostream>
#include <math.h>
#include <iomanip>

int main(){
	int R;
	std::cin>>R;
	const double pi=acos(-1.0);
	double answer=2*R*pi;
	std::cout<<std::setprecision(20)<<std::fixed<<answer<<std::endl;
  	return 0;
}

Measured memory_bytes: 3796
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<ctime>
using namespace std;

typedef long long ll;
const int MAX=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

const string mode[4]={"dream","dreamer","erase","eraser"};

bool Match(const string&mo,const char* s,const int&k){
    int l=mo.length();
    for(int i=0;i<l;i++){
        if(mo[i]!=s[i+k]) return false;
    }
    return true;
}

void DFS(const int&k,const char* s,bool &F){
    if(k==strlen(s)){
        F=true;
        return;
    }
    for(int i=0;i<4;i++){
        if(Match(mode[i],s,k)){
            DFS(k+mode[i].length(),s,F);
            if(F) return;
        }
    }
}

int main(){
    char s[MAX];
    while(~scanf("%s",s)){
        bool F=false;
        DFS(0,s,F);
        if(F) puts("YES");
        else puts("NO");
    }
    return 0;
}


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

int main(){
    ll n ; cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
 
    ll ans = 1;

    rep(i,n){
        if(ans * a[i] >0 && ans * a[i] <= 1000000000000000000){
            ans = ans * a[i];
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

}

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

int main() {
  
  int n,mx = 0,mn = 1000;
  cin >> n;
  
  vector<int> a(n);
  for ( int i = 0; i < n; i++){
    cin >> a[i];
    if ( mx < a[i] ){
      mx = a[i];
    }
    if ( mn > a[i] ){
      mn = a[i];
    }    
  }
  
  cout << mx - mn << endl; 
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll = long long;
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
#define drep2(i,a,b) for(int i=a; i>=b; i--)

int main()
{
    string s;
	cin >> s;
    if (s[3] == '7')
        s[3] = '8';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    vector<int>c(10);

    long long N,K;
    cin >> N >> K;
    if(N % K == 0){
        cout << 0 << endl;
        return 0;
    }
    long long rest = N % K;
    cout << min(rest,abs(rest - K));
}


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

int main(){
    
    int t;
    //cin >> t;
    t = 1;
    while(t--){
        string s;
        cin >> s;
        int cur = 0;
        int mx = INT_MIN;
        for(int i = 0; i < 3; i++){
            if(s[i] == 'R'){
                cur += 1;
            }else{
                cur = 0;
            }
            mx = max(mx, cur);
        }
        
        cout << mx << endl;
        
    }
    
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

ll mod_inv(ll a, ll m) {
    ll b(m), u(1), v(0);
    while (b) {
        ll t(a / b);
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    if (u < 0) {
        u += m;
    }
    return u;
}

const ll mod = 1e9 + 7;

struct mll {
  ll n;
  mll(ll n = 0) : n(n) {}
};
 
mll operator+(mll a, mll b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mll operator-(mll a, mll b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mll operator*(mll a, mll b) { return 1LL * a.n * b.n % mod; }
mll operator/(mll a, mll b) { return 1LL * a.n * mll(mod_inv(a.n, mod)); }
mll &operator+=(mll &a, mll b) { return a = a + b; }
mll &operator-=(mll &a, mll b) { return a = a - b; }
mll &operator*=(mll &a, mll b) { return a = a * b; }
mll &operator/=(mll &a, mll b) { return a = a / b; }
ostream &operator<<(ostream &o, mll a) { return o << a.n; }

int main() {
	string s;
	cin >> s;
	mll n = 1;
	mll a = 0;
	mll ab = 0;
	mll abc = 0;
	repv(i, s) {
		if (s[i] == 'A') {
			a += n;
		}
		else if (s[i] == 'B') {
			ab += a;
		}
		else if (s[i] == 'C') {
			abc += ab;
		}
		else if (s[i] == '?') {
			abc += 2 * abc + ab;
			ab += 2 * ab + a;
			a += 2 * a + n;
			n *= 3;
		}
	}
	cout << abc << endl;
}


Measured memory_bytes: 512
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        s: String,
    }

    let vc: Vec<char> = s.chars().collect();
    let mut score = Vec::with_capacity(n);
    score.push(0);
    let mut sum = 0;
    for i in 1..n {
        if vc[i - 1] == 'A' && vc[i] == 'C' {
            sum += 1;
        }
        score.push(sum);
    }

    for _ in 0..q {
        input! {
            l: usize,
            r: usize,
        }
        println!("{}", score[r - 1] - score[l - 1]);
    }
}


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

int main() {

	int N;
	cin >> N;
	string S;
	cin >> S;

	int max = 0;
	for (int i = 0; i < N-1; i++) {
		int buf = 0;
		for (int j = 0; j < 26; j++) {
			bool tmp1 = false;
			for (int k = 0; k <= i; k++) {
				if (S.at(k) == 'a' + j) tmp1 = true;
			}
			bool tmp2 = false;
			for (int k = i+1; k <= N-1; k++) {
				if (S.at(k) == 'a' + j) tmp2 = true;
			}
			if (tmp1&&tmp2) buf++;
		}
		if (buf > max) max = buf;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256