akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }
 
#define int long long
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int INF = 0x3f3f3f3f;
 
int n, a, b;
vector<int> h;
 
bool B(int x) {
        int cnt = 0;
        rep(i, n) {
                if (cnt > x) return false;
                if (b * x >= h[i]) continue;
                else {
                        int c = h[i] - b * x;
                        if (c % (a - b) == 0) cnt += c / (a - b);
                        else cnt += c / (a - b) + 1LL;
                }
        }
        if (cnt > x) return false;
        return true;
}
 
signed main() { 
        cin >> n >> a >> b;
        h.resize(n);
        rep(i, n) cin >> h[i];
        int l = 0, r = INF;
        while (r - l > 1) {
                int mid = (l + r) / 2;
                if (B(mid)) r = mid;
                else l = mid;
        }
        cout << r << endl;
        return 0;
}               
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
using ll=long long;
using vi=vector<ll>;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
int main() {
  ll n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n) cin>>a[i];
  rep(i,n) a[i]--;
  ll now=0,p,q;
  vi b(n,-1);//訪問
  rep(i,n){
    b[now]=i;
    now=a[now];
    if(b[now]>-1){
      p=b[now]; q=i-p+1; break;
    }
  }
  ll x;
  if(k<p) x=k;
  else x=(k-p)%q+p;
  rep(i,n) if(b[i]==x) out(i+1);
}

Measured memory_bytes: 6416
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
#define popcount(x) __builtin_popcountll(x)
const int MOD =1e9+7;

mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> istream& operator >> (istream &in,vector<T> &A){ for(auto &x:A) in>>x; return in; };
template<typename T> ostream& operator << (ostream &out,vector<T> &A){ for(auto &x:A) out<<x<<" "; return out; };
template<typename T,typename W> istream& operator >> (istream &in,pair<T,W> &A){ in>>A.fi>>A.se; return in; };
const int N = 100;
// vector<int> g[N];
// bool vis[N];
void solve()
{
	// int n;
	// cin>>n;
	// string a,b;
	// cin>>a>>b;
	// for(int i=0;i<N;i++)
	// {
	// 	g[i].clear();
	// 	vis[i]=false;
	// }
	// for(int i=1;i<n;i++)
	// {
	// 	if(a[i-1]=='Y'&&b[i]=='Y')
	// 	{
	// 		g[i+1].pb(i);
	// 	}
	// 	if(b[i-1]=='Y'&&a[i]=='Y')
	// 	{
	// 		g[i].pb(i+1);
	// 	}
	// }
	int x;
	cin>>x;
	for(int i=400,cnt=8;i<=1800;i+=200,cnt--)
	{
		if(x>=i&&x<=(i+200-1))
		{
			cout<<cnt<<"\n";
			return;
		}
	}
}

// (1<<)
int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif

	int t=1;
	// cin>>t;
	for(int _t=1;_t<=t;_t++){
		// cout<<"Case #"<<_t<<": ";
		solve();
	}
} 


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

using namespace std;


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

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

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

	bool flag = false;
	int s_size = s.length();
	int t_size = t.length();
	for (int i = s_size-1; i >= 0; i--)
	{
		if (s[i] == '?' || s[i] == t[0])
		{
			bool stupidFlag = true;
			if (i + t_size - 1 >= s_size) 
			{
				stupidFlag = false;
			}
			else
			for (int j = 1; i+j < s_size && j < t_size; j++)
			{
				if (s[i+j] != '?' && s[i+j] != t[j])
				{
					stupidFlag = false;
					break;
				}
			}

			if (stupidFlag)
			{
				flag = true;
				for (int j = 0; i+j < s_size && j < t_size; j++)
				{
					s[i+j] = t[j];
				}
				for (int i = 0; i < s_size; ++i)
				{
					if (s[i] == '?') s[i] = 'a';
				}
				break;
			}
		}
	}
	if (flag)
	{
		cout << s;
	}
	else cout << "UNRESTORABLE";

	return 0;
}


Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_2_A
//p063.cpp

#include<iostream>
using namespace std;

//flagを用いたバブルソート
int bubbleSort(int A[], int N) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				//隣接要素を交換する
				swap( A[j], A[j - 1] );
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

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

	sw = bubbleSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>

int main()
{
    int n, m;
    scanf("%d %d",&n,&m);
    int a[n+1][m+1];
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    int b[m+1];
    for(int i = 1; i<=m; i++){
        scanf("%d",&b[i]);
    }
    int c[n+1];
    for(int i = 1; i<=n; i++){
        int sum = 0;
        for(int j = 1; j<=m; j++){
            sum+=(a[i][j]*b[j]);       
        }
        c[i] = sum;
    }
    for(int i = 1; i<=n; i++){
        printf("%d\n",c[i]);
    }
    return 0;
}



Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i, n) {
		cin >> v[i];
		if (v[i] == 0) {
			cout << 0 << endl;
			return;
		}
	}
	ll ans = v[0];
	rep2(i, 1, n) {
		if (ans > INT64_MAX / v[i]) {
			cout << -1 << endl;
			return;
		}
		ans *= v[i];
	}
	if (ans > 1e18L) cout << -1 << endl;
	else cout << ans << endl;
}

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

	solve();
}


Measured memory_bytes: 3996
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

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

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int h,w;
    while (cin >> h >> w) {
        int vis[h][w];
        memset(vis,0,sizeof(vis));
        vector<PII> Q[2]; int cur,nxt; cur = 0, nxt = 1;
        FOR(i,0,h) FOR(j,0,w) {
            char ch; cin >> ch;
            if (ch == '#') {
                vis[i][j]++; Q[cur].push_back(PII(i,j));
            }
        }
        int ans = 0;
        while (Q[cur].size()) {
            Q[nxt].clear();
            FOR_ALL(p,Q[cur]) {
                const int i = p->first;
                const int j = p->second;
                FOR(d,0,4) {
                    const int x = i+dx[d];
                    const int y = j+dy[d];
                    if (0 <= x && x < h && 0 <= y && y < w) {
                        if (!vis[x][y]) {
                            vis[x][y]++; Q[nxt].push_back(PII(x,y));
                        }
                    }
                }
            }
            ans++; swap(cur,nxt);
        }
        cout << ans-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 16232
def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2:
        return True

    # all other even numbers are not primes
    if not n & 1:
        return False

    # range starts with 3 and only needs to go up
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True

def resolve():
	q = int(input())
	qs = [list(map(int, input().split())) for _ in range(q)]
	t = [0]*(10**5+1)
	for i in range(10**5):
		v = 1 if isprime(i+1) and isprime((i+2)/2) else 0
		t[i+1] = t[i] + v
	for l, r in qs:
		if l == r:
			print(1 if isprime(l) and isprime((l+2)/2) else 0)
		else:
			print(t[r] - t[l-1])
resolve()

Measured memory_bytes: 78552
#include <cstdio>
#include <string>
#include <iostream>
#include <map>
#include <vector>

#define reep(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

map<string,int> name_id;
vector<int> recipe[100];
int price[100];

int solve(int x){

    int len = recipe[x].size();

    if(len==0){
        return price[x];
    }

    int ans=0;
    rep(i,len){
        ans += solve(recipe[x][i]);
    }
    //printf("%d->%d\n",x,price[x]);
    return min(ans, price[x]);
}

int main(){
    int n;
    while(cin >> n,n){
        name_id.clear();
        rep(i,100)recipe[i].clear();
        rep(i,n){
            string name;
            int p;
            cin >> name >> p;
            name_id[name] = i;
            price[i] = p;
        }

        int m;
        cin >> m;

        rep(i,m){
            string name;
            int num;
            cin >> name >> num;
            int id = name_id[name];
            rep(k,num){
                string r;
                cin >> r;
                recipe[id].push_back(name_id[r]);
            }
        }

        string a;
        cin >> a;
        cout << solve(name_id[a]) << endl;
    }
    return 0;
}

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

using namespace std;

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

typedef long long int lo;
#define pb push_back
#define st first
#define nd second
#define inf (int)1e9
#define N (int)1e5 * 5
#define mod (int)1e9 + 7
#define all(x) (x).begin(), (x).end()
int in(){ int a; cin >> a; return a; }

void solve(){
	lo n;
	cin >> n;
	vector<lo> a(n);
	lo sum = 0;
	map<lo, lo> m;
	for(lo &it : a){
		cin >> it;
		sum += it;
		m[it]++;
	}
	lo q;
	cin >> q;
	while(q--){
		lo b, c;
		cin >> b >> c;
		sum -= m[b] * b;
		sum += m[b] * c;
		cout << sum << endl;
		m[c] += m[b];
		m[b] = 0;
	}
}

int main(){
  	ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
	// freopen("gir.gir", "r", stdin);
	// freopen("cik.cik", "w", stdout);
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main() {
  ll n,d; cin >> n >> d;
  ll ans;
  if(n%(d*2+1)==0) cout << n/(d*2+1) << endl;
  else cout << n/(d*2+1)+1 << endl;
  
  return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int a = 0;
  int b = 0;
  int c = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') a++;
    if (s[i] == 'b') b++;
    if (s[i] == 'c') c++;
  }
  if (abs(a-b) == 0 || abs(a-b) == 1) {
    if (abs(a-c) == 0 || abs(a-c) == 1) {
      if (abs(b-c) == 0 || abs(b-c) == 1) {
        cout << "YES" << '\n';
        return 0;
      }
    }
  }
  cout << "NO" << '\n';
}

Measured memory_bytes: 512
#author : dokueki

import sys
import math
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n = int(sys.stdin.readline())
    print(2*math.pi*n)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 61984
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();

int A[100][100];
int B[100][100];
bool dp[81][81][12801];

int32_t main(){
  fast;

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

  int h,w;
  cin >> h >> w;
  // fill(dp,INF);
  FOR(i,1,h)FOR(j,1,w)cin >> A[i][j];
  FOR(i,1,h)FOR(j,1,w)cin >> B[i][j];
  fill(dp,false);
  FOR(i,0,80)dp[i][0][0] = true;
  FOR(i,0,80)dp[0][i][0] = true;

  FOR(i,1,h) {
    FOR(j,1,w) {
      FOR(d, 0, 12800) {
        if(i == 1) {
          if(dp[i][j-1][d]) {
            dp[i][j][abs(A[i][j] - d - B[i][j])] = true;
            dp[i][j][abs(B[i][j] - d - A[i][j])] = true;
          }
        }
        else if(j == 1) {
          if(dp[i-1][j][d]) {
            dp[i][j][abs(A[i][j] - d - B[i][j])] = true;
            dp[i][j][abs(B[i][j] - d - A[i][j])] = true;
          }
        }
        else {
          if(dp[i-1][j][d] or dp[i][j-1][d]) {
            dp[i][j][abs(A[i][j] - d - B[i][j])] = true;
            dp[i][j][abs(B[i][j] - d - A[i][j])] = true;
          }
        }
      }
    }
  } 
  int ans = INF;
  FOR(d,0,12800)if(dp[h][w][d])ans = min(ans,d);
  assert(ans < INF);
  cout << ans << "\n";
  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

  return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a/d+(a%d!=0)<c/b+(c%b!=0)) re("No")
	else re("Yes")
	return 0;}

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

using namespace std;

#define int long long
#define MP make_pair
#define F first
#define S second
#define pi pair<int,int> 
#define sz(s) ((int)s.size())

const unsigned mod = 1e9 + 7;
const unsigned N = 5e5 + 4;

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

  
  string s;
  cin >> s;
  cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes\n" : "No\n") << '\n';



  
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int LinearSearch(int );
int S[1000000],n;
int main(){

  int j,i,q,T[1000000],count=0,flag;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    }
  scanf("%d",&q);
   for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
    for(j=0;j<q;j++){
      flag=LinearSearch(T[j]);
      if(flag==1) count++;
    }
 
  printf("%d\n",count);
  return 0;


}

int LinearSearch(int key){
  int i;
  for(i=0;i<n;i++){
    if(S[i]==key) return 1;
  }
  return 0;
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

vvi G(200050);
vi bw(200050, 0);
int bc=0, wc=0;
int N;

void dfs(int now, int prev, int cost) {
    bw[now] = cost%2;
    if(cost%2==0) bc++; else wc++;
    rep(i, G[now].size()) {
        if(G[now][i]!=prev) dfs(G[now][i], now, cost+1);
    }
}

signed main() {
    cin >> N;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    dfs(0, -1, 0);

    int n1=1, n2=2, n3=3;
    vi res(N);
    if(bc>N/3 && wc>N/3) {
        rep(i, N) {
            if(bw[i]==0) {
                if(n1>N) {
                    res[i] = n3;
                    n3+=3;
                } else {
                    res[i] = n1;
                    n1+=3;
                }
            } else {
                if(n2>N) {
                    res[i] = n3;
                    n3 += 3;
                } else {
                    res[i] = n2;
                    n2 += 3;
                }
            }
        }
    } else if(bc<=N/3) {
        rep(i, N) {
            if(bw[i]==0) {
                res[i]=n3;
                n3+=3;
            } else {
                if(n1>N) {
                    if(n2>N) {
                        res[i] = n3;
                        n3 += 3;
                    } else {
                        res[i] = n2;
                        n2 += 3;
                    }
                } else {
                    res[i] = n1;
                    n1 += 3;
                }
            }
        }
    } else {
        rep(i, N) {
            if(bw[i]==1) {
                res[i] = n3;
                n3 += 3;
            } else {
                if(n1>N) {
                    if(n2 > N) {
                        res[i] = n3;
                        n3 += 3;
                    } else {
                        res[i] = n2;
                        n2 += 3;
                    }
                } else {
                    res[i] = n1;
                    n1 += 3;
                }
            }
        }
    }

    rep(i, N) {
        cout << res[i] << " ";
    } cout << endl;

    return 0;
}


Measured memory_bytes: 20608
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
    return int(a * b / gcd(a, b))

def main():
    A, B, C, D = [int(c) for c in input().split()]
    N_U = (B) - (A - 1)
    N_C = B // C - (A - 1) // C
    N_D = B // D - (A - 1) // D
    N_C_D = int(B // lcm(C, D) - (A - 1) // lcm(C, D))
    excluded_N_C_D = N_C + N_D - N_C_D
    print(int(N_U - excluded_N_C_D))


if __name__ == '__main__':
    main()

Measured memory_bytes: 21444
#include <stdio.h>
int main (void)
{
  int n, x, y, z;
  scanf("%d", &n);
  x = n / 100;
  y = (n - 100 * x) / 10;
  z = n - 100 * x - 10 * y;
  if ( x == 7 || y == 7 || z == 7)
  {
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

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

int main() {
  int a,b,c,x,ans = 0;
  cin >> a >> b >> c >> x;
  for(int i = 0;i < a+1;i++){
    for(int j = 0;j < b+1;j++){
      for(int k = 0;k < c+1;k++){
        if(i*500+j*100+k*50 == x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    int K, A, B;
    cin >> K >> A >> B;
    bool ok = false;
    for (int i = 1; i <= 1000; i++) {
        int x = K * i;
        if (A <= x && x <= B) {
            ok = true;
            break;
        }
    }
    if (ok) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


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

class UnionFind {
private:
  int sz;
  vector<int> par, size_;
public:
  UnionFind() {}
  UnionFind(int n) : sz(n), par(sz), size_(sz, 1) {
    iota(par.begin(), par.end(), 0);
  }
  int find(int x) {
    if (par.at(x) == x) return x;
    else return par.at(x) = find(par.at(x));
  }
  void unit(int x,int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (size_.at(x) < size_.at(y)) swap(x, y);
    par.at(y) = x;
    size_.at(x) += size_.at(y);
  }
  int size(int x) {
    x = find(x);
    return size_.at(x);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind UF(N);
  vector<int> V(N);
  for (int i = 0, a, b; i < M && cin >> a >> b; i++) {
    UF.unit(--a, --b);
    V.at(a)++;
    V.at(b)++;
  }
  vector<vector<int>> B(N);
  for (int i = 0, c, d; cin >> c >> d; i++) {
    if (UF.same(--c, --d)) {
      V.at(c)++;
      V.at(d)++;
    }
  }
  for (int i = 0; i < N; i++) {
    int ans = UF.size(i);
    ans--;
    ans -= V.at(i);
    cout << ans << "\n"; 
  }
}

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

int main() {
	string  s,s1;
	cin>>s>>s1;
	int sum=0;
	for(int i=0;i<3;i++){
		if(s.at(i)==s1.at(i)||(int)s.at(i)==32+(int)s1.at(i)||(int)s.at(i)+32==(int)s1.at(i)){
			sum++;
		}
	}
	cout<<sum<<endl;
	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define all(_v) _v.begin(), _v.end()
#define ll long long

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    string s;
    cin >> s;
    for(auto i : s) if(i == '7') cout << "Yes", exit(0);
    cout << "No";
	return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        boolean[] d = new boolean[10];
        for(int i = 0; i < K; i++) {
            d[scan.nextInt()] = true;
        }
        int current = N;
        while (true) {
            String t = Integer.toString(current);
            char[] digits = t.toCharArray();
            boolean ok = true;
            for (int i = 0; i < digits.length; i++) {
                if (d[digits[i]-'0']) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                break;
            }
            current += 1;
        }
        System.out.println(current);
    }
}


Measured memory_bytes: 28372
num = STDIN.gets.to_i
for i in 0.. num-1
  data = STDIN.gets.split(/ /)
  for i in 0.. data.length-1
    data[i] = data[i].to_i
  end
  a = Array.new
  b = [0]
  a.push(data.shift)
  for i in 0.. data.length-1
    if data[0] > a[a.length-1]
      a.push(data.shift)
    else
      if data[0] > b[b.length-1]
        b.push(data.shift)
      else
        puts "NO"
        break
      end
    end
  end
  if data.length == 0
    puts "YES"
  end
end

Measured memory_bytes: 2372
#include <iostream>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}else if(a>b){
		cout<<"a > b"<<endl;
	}else{
		cout<<"a == b"<<endl;
	}
}

Measured memory_bytes: 3092
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct {
  int p;
  int l;
  int r;
} Node;

Node T[MAX];
int n;

void preParse(int u)
{
    if(u==NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u)
{
    if(u==NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

void postParse(int u)
{
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    int i,v,l,r,root;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        T[i].p=NIL;
    }
    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL) T[l].p=v;
        if(r!=NIL) T[r].p=v;
    }

    for(i=0;i<n;i++){
        if(T[i].p==NIL) root=i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2004
#include<stdio.h>
int main(void){
	int n,m,l;
	int i,j,k;

	scanf("%d %d %d",&n,&m,&l);
	/*C99kikaku deha hairetutyou ni hensuu siyo kanou
	  {0}syokika ha fukano rasii..*/
	int A[n][m],B[m][l];
	long int C[n][l];

	//torikomi
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&B[i][j]);
		}
	}
	
	//keisan
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			C[i][j]=0;						//kokode syokika
			for(k=0;k<m;k++){
				C[i][j]+=A[i][k]*B[k][j];
			}
		}
	}

	//hyouji
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			printf("%ld",C[i][j]);
			if(j!=(l-1)) printf(" ");
			else printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 760
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())

mod=998244353

seg_el=1<<(N.bit_length()) # Segment treeの台の要素数
seg_height=1+N.bit_length() # Segment treeの高さ
SEG=[0 for i in range(2*seg_el)] # 区間の和
LAZY=[0 for i in range(2*seg_el)]


POW10=[1]
for i in range(N+1):
    POW10.append(POW10[-1]*10%mod)

gyaku=pow(9,mod-2,mod)

def seg_function(x,y):
    return (x+y)%mod
    
for i in range(N): # Aを対応する箇所へupdate
    SEG[i+seg_el]=POW10[i]
        
for i in range(seg_el-1,0,-1): # 親の部分もupdate
    SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])

def lazy_change(ind,b):
    kousuu = 1<< (seg_height - (ind.bit_length()))
    tyousei = (ind - (1<<((ind.bit_length())-1)))*kousuu

    #print(ind,tyousei,kousuu)
    SEG[ind] = POW10[tyousei] * b * (POW10[kousuu]-1) %mod * gyaku %mod

def lazy_compose(ind,b):
    LAZY[ind]=b

def indexes(L,R): # 遅延伝搬すべきノードのリストを下から上の順に返す. （つまり, updateやgetvaluesで見るノードより上にあるノードたち）
    INDLIST=[]

    R-=1
    
    L>>=1
    R>>=1

    while L!=R:
        if L>R:
            INDLIST.append(L)
            L>>=1
        else:
            INDLIST.append(R)
            R>>=1

    while L!=0:
        INDLIST.append(L)
        L>>=1

    return INDLIST
        

def changes(l,r,b0): # 区間[l,r)更新
        
    L=l+seg_el
    R=r+seg_el

    L//=(L & (-L))
    R//=(R & (-R))

    UPIND=indexes(L,R)
    
    for ind in UPIND[::-1]:
        if LAZY[ind]!=0:
            b=LAZY[ind]
            
            lazy_change(ind<<1,b)
            lazy_change(1+(ind<<1),b)
            
            lazy_compose(ind<<1,b)
            lazy_compose(1+(ind<<1),b)
            
            LAZY[ind]=0

    #print(SEG)
    
    while L!=R:
        if L > R:
            lazy_change(L,b0)
            lazy_compose(L,b0)
            L+=1
            L//=(L & (-L))

        else:
            R-=1
            lazy_change(R,b0)
            lazy_compose(R,b0)
            R//=(R & (-R))

    for ind in UPIND:
        SEG[ind]=seg_function(SEG[ind<<1],SEG[1+(ind<<1)])
    

for qu in range(Q):
    L,R,D=map(int,input().split())
    L,R=N-R+1,N-L+1
    #print(SEG)

    changes(L-1,R,D)
    sys.stdout.write(str(SEG[1])+"\n")


Measured memory_bytes: 123592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ALL(v)   v.begin(),v.end()
int main()
{
	speed
	ll l,r;
	cin >> l >> r;
	if(r - l >= 2019)
		cout << 0;
	else
	{
		ll s = 2019;
		for(ll x = l; x<r; x++)
		{
			for(ll y = x+1; y<=r; y++)
			{
				s = min(s, ((x*y)%2019) );
			}
		}
		cout << s;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
#define keta(n) fixed<<setprecision(n)
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


int main(){
    int n;
    double ans=0;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    rep(i,n){
        ans+=(p[i]/(pow(2,(n-i))));
    }
    ans+=(p[0]/(pow(2,n)));
    cout<<keta(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
class RollingHash():
    def __init__(self, s):
        self.mask30 = (1 << 30) - 1
        self.mask31 = (1 << 31) - 1
        self.length = len(s)
        self.base = 1009
        self.mod = (1 << 61) - 1
        self.hash = [0] * (self.length + 1)
        self.pow = [1] * (self.length + 1)

        for i in range(self.length):
            self.hash[i+1] = self.calcmod(self.mul(self.hash[i], self.base) + ord(s[i]))
            self.pow[i+1] = self.calcmod(self.mul(self.pow[i], self.base))
    
    def mul(self, l, r):
        lu = l >> 31
        ld = l & self.mask31
        ru = r >> 31
        rd = r & self.mask31
        middle = ld * ru + lu * rd
        return ((lu * ru) << 1) + ld * rd + ((middle & self.mask30) << 31) + (middle >> 30)
    
    def calcmod(self, val):
        val = (val & self.mod) + (val >> 61)
        if val > self.mod:
            val -= self.mod
        return val

    def get(self, l, r):
        t = self.calcmod(self.hash[r] - self.mul(self.hash[l], self.pow[r-l]) + self.mod)
        return t

n = int(input())
s = input()
RH = RollingHash(s)

def check(l):
    place = {}
    for i in range(n - l + 1):
        hs = RH.get(i, i + l)
        if hs in place:
            if i - place[hs] >= l:
                return True
        else:
            place[hs] = i
    return False

l = 0; r = n // 2 + 1
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        l = m
    else:
        r = m

print(l)

Measured memory_bytes: 44908
#include <stdio.h>
#define abs(a) ((a) > 0 ? (a) : -(a))

int
main(int argc, char *argv[])
{
  int n, m, a[100005], d[100005];
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; i++) scanf("%d", &a[i]);

   long long x[100005]; x[0] = 1; x[1] = 2;
  for(int i = 2; i <= n; i++) {
    x[i] = x[i - 1] + x[i - 2];
    x[i] = x[i] % 1000000007;
  }

  d[0] = a[0] - 1;
  if(m != 0){
  for(int i = 1; i < m; i++){
    d[i] = a[i] - a[i - 1] - 2;
  }
  d[m] = n - a[m - 1] - 1;
 

  long long ans = 1;

  for(int i = 0; i <= m; i++){
    if(d[i] < 0){ans = 0; break;}
    else if(d[i] == 0) continue;
    else {
      ans = (ans * x[d[i] - 1]);
      ans = ans % 1000000007;
    }
  }
  printf("%lld\n", ans);
  }

  else{
    printf("%lld\n", x[n - 1]);
  }

 

  return 0;
}

				   
    


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


int main(){
  string str,str_1;
  int m,b;
  cin >> str;
  cin >> m;
  int T = 0;
  int H = 0;
  for(int i=0;i<m;i++){
    cin >> str_1;
    int a,b;
    if(str_1 == "replace"){   
       cin>>a>>b;
       string p;
       cin>>p;
       for(int j = 0;j<str.size();j++){
           if(a == j){
               for(int k = 0;k<=(b-a);k++){
                   str[j+k] = p[k];
               }
           }
       }
    }else if(str_1 == "reverse"){
        cin>>a>>b;
        for(int j = 0;j<(b-a+1)/2;j++){
           char temp = str[a+j];
            str[a+j] = str[b-j];
            str[b-j] = temp; 
        }
    }else if(str_1 == "print"){
        cin>>a>>b;
        for(int j = a;j<=b;j++){
            cout<<str[j];
            if(j == b){
                cout<<""<<endl;
            }
        }
    }   
  }
  return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){
  return o<<"("<<p.first<<","<<p.second<<")";
}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
vector<int> score;

int calcScore(const vector<vector<int> > &mp, int bonus){
  
  auto okw=[&](int i,int j){
    if(j + 2 >= 5) return false;
    if(mp[i][j] == -1) return false;
    return mp[i][j] == mp[i][j+1] && mp[i][j] == mp[i][j+2];
  };
  
  auto okh=[&](int i,int j){
    if(i + 2 >= 5) return false;
    if(mp[i][j] == -1) return false;
    return mp[i][j] == mp[i+1][j] && mp[i][j] == mp[i+2][j];
  };
  
  int flag = 0;
  vector<vector<int> > res = mp;
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++){
      if(okw(i,j)) res[i][j] = res[i][j+1] = res[i][j+2] = -2;
      if(okh(i,j)) res[i][j] = res[i+1][j] = res[i+2][j] = -2;
    }
  
  int block = 0;
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++)
      if(res[i][j] == -2){
	assert(mp[i][j] >= 0);
	flag = 1;
	res[i][j] = -1;
	block += score[mp[i][j] - 1];
      }
  
  for(int j=0;j<5;j++)
    for(int k=0;k<5;k++)
      for(int i = 0; i < 5-1; i++)
	if(res[i][j] == -1) swap(res[i][j],res[i+1][j]);

  int ans = bonus * block;
  // if(bonus == 2) cout<<"2="<<ans<<endl;
  if(flag) ans += calcScore(res,bonus+1);
  return ans;
}

int dfs(int i,int j,int n,vector<vector<int> > mp){
  
  
  if(n == 0) return calcScore(mp,1);
  

  int res = calcScore(mp,1);
  for(int k=0;k<4;k++){
    int ni = i + dy[k];
    int nj = j + dx[k];
    if(ni < 0 || nj < 0 || ni >= 5 || nj >= 5) continue;
    swap(mp[i][j], mp[ni][nj]);
    res = max(res,dfs(ni,nj,n-1,mp));
    swap(mp[i][j], mp[ni][nj]);
  }
  return res;
}

signed main(){
  while(1){
    int n;
    cin>>n;
    if(n == -1) break;
    vector<vector<int> > A(5,vector<int>(5));
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++) cin>>A[4-i][j];

    score.clear();
    score.resize(5);
    for(int i=0;i<5;i++) cin>>score[i];
    
    int ans = -INF;
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++) Max(ans,dfs(i,j,n,A));
    
    cout<<ans<<endl;
  }
  return 0;
}




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

const int mx = 100005,inf = 1e18;
int dp[mx],n,arr[mx],k;

int solve(int i)
{
    if(i<1) return inf;
    if(i==1) return 0;

    if(dp[i]!=-1) return dp[i];

    int temp = inf;
    for(int j=1;j<=k;j++)
    {
        temp = min(temp,solve(i-j)+abs(arr[i]-arr[i-j]));
    }
    return dp[i]=temp;
}

main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    cout<<solve(n);
}

Measured memory_bytes: 6528
#include<stdio.h>

long long gcd(long long a,long long b){
    while(b ^= a ^= b ^= a%=b);
    return a;

}
int main(){
	long long n,x,g;
	
	scanf("%lld%lld",&n,&x);
	g = gcd(n,x);

	printf("%lld\n",(n/g-1)*3*g);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;
vector<pi> vec;

int d[MAX_N];
int C[MAX_N];

int loop(int v, char c) {
	if(S[v] != c) return v;
	if(d[v] != -1) return d[v];
	int res;
	if(S[v] == 'R') res = loop(v + 1, c);
	else res = loop(v - 1, c);
	return d[v] = res;
}

void solve() {
	cin >> S;
	N = sz(S);
	memset(d, -1, sizeof(d));
	rep(i, 0, N) {
		loop(i, S[i]);
	}
	rep(i, 0, N) {
		int v = abs(d[i] - i) % 2;
		if(v == 0) C[d[i]]++;
		else {
			if(S[i] == 'R') C[d[i] - 1]++;
			else C[d[i] + 1]++;
		}
	}
	rep(i, 0, N) {
		cout << C[i] << " ";
	}
	cout << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 7376
import sys
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

r=[list(map(int,line.split())) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[1])
    p=i[0]*i[1]/o
    print(o,int(p))



Measured memory_bytes: 5608
import java.util.Scanner;

public class Main {
    //Snack
    //求最小公倍数, 我也不知道怎么写, 试试辗转相除法求最小公约数?
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        System.out.println(helper(a, b));
        sc.close();
    }

    static long helper(long a, long b) {
        long v = a, u = b, y;
        while (b > 0) {
            y = a % b;
            a = b;
            b = y;
        }
        return v * u / a;
    }
}


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

using namespace std;

int main() {
  vector<int> V(5);
  for (int i = 0; i < 5; i++) cin >> V[i];
  sort(V.begin(), V.end());
  int K;
  cin >> K;
  if (V.back() - V.front() <= K) {
    cout << "Yay!";
  } else {
    cout << ":(";
  }

  return 0;
}


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

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

int a, b;
int t[999];

int main() {
  scanf("%d%d", &a, &b);

  t[0] = 1;
  FOR(i,2,1000) t[i-1] = t[i-2] + i;
 
  printf("%d\n", t[b-a-1] - b);
  return 0;
}

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

int main(){
  ll k,n;
  cin >> k >> n;
  vector<ll> s(n),t(n);
  for(int i=0;i<n;i++)cin >> s[i] >> t[i];

  ll res = 0, sum = 0;
  int r = 0;
  for(int l=0;l<n;l++){
    while(r<n && s[r]<=s[l]+k){
      sum += t[r]-s[r];
      r++;
    }
    res = max(res, sum - ((t[r-1]<=s[l]+k)? 0 : t[r-1]-s[l]-k));

    sum -= t[l]-s[l];
  }
  cout << res << endl;
}

Measured memory_bytes: 4420
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N: usize,
    }
    let mut ans = 0;
    for i in 1..=N {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

    FOR(i, 1, N + 1) {
        if ((int)(i * 1.08) == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 256