akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include "bits/stdc++.h"

#define REP(i,n) for(int 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) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#include "stdio.h"
ll h, w;
char mass[1001][1001] = {};
char neomass[1001][1001] = {};

ll n, q;
ll score[210000] = {};
std::list<ll> num[210000] = {};

void dfs(ll p,ll x,ll parent) {
	//親ノードにx点を足し、さらに親自身が持つ得点を次に渡していく
	score[p] += x;
	//子ノードにもx点を追加していく
	for (auto itr = num[p].begin(); itr != num[p].end(); ++itr) {
		if (parent != *itr) { dfs(*itr, score[p], p); };
	}

}

int main() {
	cin >> n >> q;
	   
	//リストに追加する
	REP(i, n-1) {
	ll tmp1,tmp2;
	cin >> tmp1>>tmp2;
	num[tmp1-1].push_back(tmp2-1);
	num[tmp2 - 1].push_back(tmp1 - 1);
	}

	//点数を足す
	REP(i, q) {
		ll ptmp, xtmp;
		cin >> ptmp >> xtmp;
		score[ptmp - 1] += xtmp;
	}
	dfs(0, 0, -1);
	REP(i, n) {
		cout << score[i];
		if (i != n - 1) { cout << " "; }
	}
	return 0;
}

Measured memory_bytes: 30336
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cstdio>
#include <cmath>
#include <deque>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

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

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	string ss = s;
	vi xs;
	int ans = 0;
	RREP(i, ss.size()){
		if(ss[i] == 'x'){
			xs.push_back(i);
			ss.erase(ss.begin() + i);
		}
	}

	REP(i, ss.size() / 2 + 1){
		if(ss[i] != ss[ss.size() - i - 1]){
			cout << "-1\n";
			return 0;
		}
	}

	REP(i, s.size()){
		if(s[i] != s[s.size() - i - 1]){
			ans++;
			if(s[i] == 'x'){
				s.insert(s.begin() + s.size() - i, 'x');
			}
			else{
				s.insert(s.begin() + i, 'x');
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1352
from collections import deque

readline = open(0).readline
N, M = map(int, readline().split())
deg = [0]*N
G = [[] for i in range(N)]
RG = [[] for i in range(N)]
for i in range(N-1+M):
    a, b = map(int, readline().split())
    deg[b-1] += 1
    G[a-1].append(b-1)
    RG[b-1].append(a-1)

que = deque()
for i in range(N):
    if deg[i] == 0:
        que.append(i)

res = ["0\n"]*N
L = [0]*N
while que:
    v = que.popleft()
    r = 0; x = None
    for w in RG[v]:
        if r < L[w] + 1:
            r = L[w] + 1
            x = w
    if x is not None:
        L[v] = r
        res[v] = "%d\n" % (x+1)
    for w in G[v]:
        deg[w] -= 1
        if deg[w] == 0:
            que.append(w)

open(1, 'w').writelines(res)

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

int const N = 100;
vector<int> tr[N + 1], r;
int mxs[N], mx, n;

inline void up(int &x, int y) { x = max(x, y); }

int dp(int v, int p = 0){
	int an = 1;
	f(i, 0, tr[v].size()){
		int u = tr[v][i];
		if (u == p)continue;
		an = max(an, 1 + dp(u, v));
	}
	return an;
}

void as(int v, bool ff = false, int p = 0, int dp = 0){
	if (ff && dp == 0)up(mxs[dp], (int)tr[v].size());
	else up(mxs[dp], (int)tr[v].size() - 1);
	f(i, 0, tr[v].size()){
		int u = tr[v][i];
		if (u == p)continue;
		as(u, ff, v, dp + 1);
	}
}

ll sn(){
	f(i, 0, n)mxs[i] = 0;
	ll an = 1;
	as(r[0], true);
	f(i, 0, mx - 1)an *= mxs[i];
	return an;
}

ll db(int a, int b){
	f(i, 0, n)mxs[i] = 0;
	ll an = 2;
	as(a, false, b);
	as(b, false, a);
	int lm = mx;
	if ((int)r.size() == 2)--lm;
	f(i, 0, lm - 1)an *= mxs[i];
	return an;
}

int main(){
	scanf("%d", &n);
	f(i, 1, n){
		int a, b;
		scanf("%d%d", &a, &b);
		tr[a].push_back(b);
		tr[b].push_back(a);
	}
	mx = 1e9;
	f(i, 1, n + 1){
		int t = dp(i);
		if (t < mx){
			r.clear();
			r.push_back(i);
			mx = t;
		}
		else if (t == mx)r.push_back(i);
	}
	ll an = 1;
	if ((int)r.size() == 1){
		an = sn();
		f(i, 0, tr[r[0]].size())an = min(an, db(r[0], tr[r[0]][i]));
	}
	else an = db(r[0], r[1]);
	mx = mx + 1 - (int)r.size();
	printf("%d %lld\n", mx, an);
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    s = input()
    for i, c in enumerate(s):
        if i % 2 == 0 and c == 'L':
            print("No")
            return
        if i % 2 == 1 and c == 'R':
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define pdd pair<double,double>
#define cpdd const pdd

int main(){
    int m,d;
    scanf("%d %d",&m,&d);
    int ans=0;
    for(int i = 1;i<=m;i++){
        for(int j = 10;j<=d;j++){
            int x=j%10,y=j/10;
            if(x*y==i&&x>=2&&y>=2){
                ans++;
                //printf9"%d %d\n
            }
        }
    }
    printf("%d\n",ans);
}

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

using namespace std;

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

	if (B % A == 0)
	{
		cout << A + B << endl;
	}
	else
	{
		cout << B - A << endl;
	}

	return 0;
}

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

using namespace std;

string s;
int ans;

signed main(){
	cin >> s;
	int len = s.length();
	for(int i = 0; i < len; ++ i)
		if(i % 2){
			if(s[i] == 'g') ans ++; 
		}
		else{
			if(s[i] =='p') ans --;
		}
	cout << ans;	
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int t = a%b;
    for(int i=1; i<=100; i++){
        if(t == c){
            cout << "YES" << endl;
            return 0;
        }
        t = (a+t)%b;
    }

    cout << "NO" << endl;
    return 0;
}

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

int main(){
    int n,m;
    cin >>n>>m;
    vector<vector<int>> vv(n+1);
    rep(i,m){
        int a,b;
        cin >>a>>b;
        vv[a].push_back(b);
        vv[b].push_back(a);
    }
    map<int,int> ans;
    vector<int> que{1};
    while(true){
        int flag=1;
        vector<int> temp;
        for(int& q :que){
            for(int& v : vv[q]){
                if(ans[v]==0){
                    ans[v]=q;
                    flag=0;
                    temp.push_back(v);
                }
            }
        }
        if(flag) break;
        swap(temp,que);
    }
    for(int i=2;i<=n;i++){
        if(ans[i]==0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=2;i<=n;i++) cout << ans[i] <<endl;
    return 0;
}

Measured memory_bytes: 14392
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
q = [int(input()) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(2):
        if (0 <= ai + i < a):
            ac.append(ai + i);
        if (0 <= ai - i < a):
            ac.append(ai - i);
    for i in range(2):
        if (0 <= bi + i < b):
            bc.append(bi + i);
        if (0 <= bi - i < b):
            bc.append(bi - i);
    for i in ac:
        for j in bc:
            aa = s[i];
            bb = t[j];
            if (max(aa, bb) <= qi):
                qans = min(qans, qi - min(aa, bb))
            elif (qi <= min(aa, bb)):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
    print(qans)


Measured memory_bytes: 69084
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll b, ll exp){
    ll res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

int main()
{
    boost
    string s;
    cin >> s;
    ll ans=0,cnt=0;
    for(ll i=0;i<3;i++) {
        if( s[i]=='R' ) {
            cnt++;
        }
        else {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    if( cnt>0 )
        ans=max(ans,cnt);
    cout << ans ;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

const int N = 100;
string arr[N];
int dp[N][N];

bool add(char a, char b) {
	return a == '.' && b == '#';
}

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

	int h, w;
	cin >> h >> w;
	for (int y = 0; y < h; ++y) cin >> arr[y];

	dp[0][0] = (arr[0][0] == '#');
	for (int y = 0; y < h; ++y) {
		for (int x = 0; x < w; ++x) {
			if (y == 0 && x == 0) continue;
			dp[y][x] = h+w;
			if (x > 0) {
				dp[y][x] = min(dp[y][x], dp[y][x-1] + add(arr[y][x-1], arr[y][x]));
			}
			if (y > 0) {
				dp[y][x] = min(dp[y][x], dp[y-1][x] + add(arr[y-1][x], arr[y][x]));
			}
		}
	}
	cout << dp[h-1][w-1] << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int n;
    cin>>n;
    int rcount=0;
    int rcount2=0;
    vector<char>c(n);
    rep(i,n){
        cin>>c.at(i);
        if(c.at(i)=='R'){
            rcount++;
        }
    }
    rep(i,rcount){
        if(c.at(i)=='R'){
            rcount2++;
        }
    }
    if(rcount>rcount2){
        cout<<rcount-rcount2<<endl;
    }else{
        cout<<0<<endl;
    }



}

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

int main(){
    int a, b;
    cin >> a >> b;
    int q = 1, ans =0;
    
    if(a == b){
        rep(i,a){ 
            ans += a*q;
            q = q*10;
        }
        cout << ans << endl;
    }
    q=1;
    int dic_a = 0, dic_b = 0;
    if(a != b){
        rep(i,a){ 
            dic_b += b*q;
            q = q*10;
        }
        q=1;
        rep(i,b){ 
            dic_a += a*q;
            q = q*10;
        }
    
    vector<int> a_sort;
    a_sort.push_back(dic_a);
    a_sort.push_back(dic_b);
    
    sort(a_sort.begin(), a_sort.end());
    cout << a_sort[1] << endl;
    } 

    return 0;
}

Measured memory_bytes: 256
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
//const long long INF = 1LL << 60;
const int INF = 1e9;
using ll = long long;

int main()
{
	int N;
	std::cin >> N;

	std::vector<int> A(N);

	std::vector<int> ans(N);
	rep(i, N)
	{
		int id = i + 1;
		int ppl = 0;
		std::cin >> ppl;
		ans[ppl - 1] = id;
	}

	for( int i : ans  )
	{
		std::cout << i << " ";
	}

    return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
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;
}

int N, M, K, Q;

int row[100];   // iが使えないか
int col[100];   // jが使えないか
int dpos[200];  // i+jが使えないか
int dneg[200];  // i-j+(N-1)が使えないか

char board[100][100];
void init_board() {
    REP(i, N) {
        REP(j, N) { board[i][j] = '.'; }
    }
}
void use(int r, int c) {
    board[r][c] = 'Q';
    row[r] = 1;
    col[c] = 1;
    dpos[r + c] = 1;
    dneg[r - c + (N - 1)] = 1;
}

void unuse(int r, int c) {
    board[r][c] = '.';
    row[r] = 0;
    col[c] = 0;
    dpos[r + c] = 0;
    dneg[r - c + (N - 1)] = 0;
}

bool rec(int i) {
    if (i == N) return true;

    REP(r, N) {
        if (row[r] == 1) {
            continue;
        }
        REP(c, N) {
            if ((col[c] == 1) | (dpos[r + c] == 1) | (dneg[r - c + (N - 1)] == 1)) {
                continue;
            }
            use(r, c);
            if (rec(i + 1)) return true;
            unuse(r, c);
        }
    }
    return false;
}
int main() {
    N = 8;
    cin >> K;
    init_board();
    REP(i, K) {
        int r, c;
        cin >> r >> c;
        use(r, c);
    }

    if (rec(K)) {
        REP(i, N) {
            REP(j, N) { cout << board[i][j]; }
            cout << endl;
        }
    }

    return 0;
}



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

int main(){
  int N = 0;
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(S[i] == '+') N++;
    else N--;
  }
  cout << N << endl;
  
  return 0;
}

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

using ll = long long;
const int INF = 1e9+7;

void solve(){
	int n;cin >> n;
	//string s;cin >> s;
	int ac = 0,wa=0,re=0,tle = 0;
	for(int i = 0;i<n;++i)
	{
		string s;cin >> s;
		if(s == "TLE") tle++;
		else if(s == "AC") ac++;
		else if(s=="WA") wa++;
		else re++;
	}
	cout << "AC x " << ac << '\n';
	cout << "WA x " << wa << '\n';
	cout << "TLE x " << tle << '\n';
	cout << "RE x " << re << '\n';

}

int main()
{
	int t=1;
	//int t;cin >> t;
	while(t--) solve();
}	


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")


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

	ll s;
	cin >> s;

	vector<int> a(1000000);
	a[s]++;

	ll val = s;
	for (int i = 1;; i++)
	{
		val = ((val + 1) % 2)*(val / 2) + (val % 2)*(3 * val + 1);
		a[val]++;
		if (a[val] == 2)
		{
			cout << i + 1 << endl;
			break;
		}
	}

	debug;


}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdint>
#include <vector>

int testcase_ends() {
  int n, k, s;
  scanf("%d %d %d", &n, &k, &s);
  if (n == 0 && k == 0 && s == 0) return 1;

  int res = 0;
  for (int i = 0; i < (1 << n); ++i) {
    if (__builtin_popcount(i) != k) continue;
    int cur = 0;
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) cur += j+1;
    }
    if (cur == s) ++res;
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2680
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 200010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-9
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, cnt, ans;
double a[SIZE];
int main() {
	io(); cin >> n;
	double x = 0;
	rep(i, 1, n) cin >> a[i], x += 1.0 / a[i];
	cout << fixed << setprecision(12) << 1.0 / x;
}

Measured memory_bytes: 256
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
import bisect


MOD = 10 ** 9 + 7

N, M = [int(x) for x in input().split()]

KenList = [[] for _ in range(N)]

PYlist = [None] * M
for i in range(M):
    P, Y = [int(x) for x in input().split()]
    P = P - 1
    PYlist[i] = (P, Y)
    KenList[P].append((i, Y))


for i in range(N):
    KenList[i] = sorted(KenList[i], key=lambda x: x[1])

cityOrder = [None] * N
for i in range(N):
    kl = KenList[i]
    dic = {}
    for j in range(len(kl)):
        city = kl[j][0]
        dic[city] = j
    cityOrder[i] = dic


for i in range(M):
    ken = PYlist[i][0]
    kl = KenList[ken]
    idx = cityOrder[ken][i]
    # for j in range(len(kl)):
    #     if kl[j][0] == i:
    #         idx = j
    #         break

    print("{0:06d}{1:06d}".format(ken+1, idx+1))


sys.exit(0)


Measured memory_bytes: 77176
#include<iostream>
using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for(int d=0;d<b;d++)cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;}

Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        String s = sc.next();

        if (!validString(s, a, c) || !validString(s, b, d)) {
            System.out.println("No");
            return;
        }

        if (c > d) {
            if (check(s, a, b, c, d))
                System.out.println("Yes");
            else
                System.out.println("No");
        } else {
            System.out.println("Yes");
        }

    }

    private static boolean validString(String s, int min, int max) {
        for (int i=min-1; i < max-1; i++) {
            if (s.substring(i, i+2).equals("##"))
                return false;
        }
        return true;
    }

    private static boolean check(String s, int a, int b, int c, int d) {
        for (int i=b-2; i <= d-2; i++) {
            if (s.substring(i, i+3).equals("..."))
                return true;
        }
        return false;
    }

}


Measured memory_bytes: 44684
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(),greater<char>());
	if (s < t) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int ans[7] = {0};
        rep(i,n){
            int inp;
            cin >> inp;
            if(inp >= 60){
                ans[6]++;
            }else{
                ans[inp / 10]++;
            }
        }
        rep(i,7){
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
#define S second
#define F first
using namespace std;

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



void solve()
{
    ll k;
    cin >> k;
    vector<ll> vis(k);
    queue<pair<ll,ll>> q;
    q.push(mp(7%k,1));
    vis[7%k]=1;
    while(!q.empty())
    {
        auto p=q.front();
        q.pop();
        if(p.F==0)
        {
            cout << p.S << endl;
            return;
        }
        ll t=p.F*10+7;
        t%=k;
        if(vis[t]==0)
        {
            vis[t]=1;
            q.push(mp(t,p.S+1));
        }
    }
    cout << -1 << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    //cin >> t;
    t=1;
    while (t--)
    {
        solve();
    }

    return 0;
}

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

using intBil7 = unsigned int;
class modBil7 {
private:
	static const intBil7 bil7 = 1000000007;
	vector<intBil7> fact;
	vector<intBil7> invfact;
public:
	intBil7 add(intBil7 a, intBil7 b) { return (a + b) % 1000000007; }
	intBil7 sub(intBil7 a, intBil7 b) { return (a + (bil7 - b)) % 1000000007; }
	intBil7 mul(intBil7 a, intBil7 b) { return (intBil7)((unsigned long long)a * (unsigned long long)b % (unsigned long long)bil7); }
	intBil7 div1(intBil7 b) {
		stack<pair<intBil7, pair<int, int>>> divbuf;
		intBil7 buf = bil7;
		while (b != 0) { divbuf.push(make_pair(buf / b, make_pair(buf, b))); buf %= b; swap(b, buf); }
		pair<int, int> m = make_pair(buf, buf);
		while (!divbuf.empty()) {
			m.second = sub(m.second, mul(m.first, divbuf.top().first));
			divbuf.pop(); swap(m.first, m.second);
		}
		return m.first;
	}
	intBil7 div(intBil7 a, intBil7 b) { return mul(div1(b), a); }
	intBil7 factorial(unsigned int a) {
		if (fact.empty()) fact.push_back(1);
		if (a >= bil7) return mul(factorial(bil7 - 1), a - bil7);
		for (int i = fact.size(); i <= a; i++) {
			fact.push_back(mul(fact.back(), i));
		}
		return fact[a];
	}
	intBil7 ifactorial(unsigned int a) { return div1(factorial(a)); }
	intBil7 C(unsigned int n, unsigned int m) {
		return mul(mul(factorial(n), ifactorial(n - m)), ifactorial(m));
	}
};

int main() {
	intBil7 n, m, k;
	cin >> n >> m >> k;
	modBil7 bil7;

	int N =
		bil7.mul(
			bil7.mul(n, n),
			bil7.div(bil7.mul(bil7.mul(m, m - 1), m + 1), 6));
	int M =
		bil7.mul(
			bil7.mul(m, m),
			bil7.div(bil7.mul(bil7.mul(n, n-1), n + 1), 6));
	int C = bil7.C( bil7.sub(bil7.mul(m, n), 2), bil7.sub(k, 2));

	cout << bil7.mul(bil7.add(N, M), C) << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 2e5+1;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;

vector<int>adj[N];
ll col[N],cnt[N],sub[N],ans[N],freq[N];

void dfs(int node,int par=0){
    sub[node] = 1;
    ll before = cnt[col[node]];

    for(int nxt: adj[node]){
        if(nxt==par) continue;
        ll temp = cnt[col[node]];
        dfs(nxt,node);
        ll tempp = sub[nxt] - (cnt[col[node]]-temp); // the size of the subtree that was added
        ans[col[node]] += (tempp*(tempp-1))/2; 
        sub[node]+=sub[nxt];
    }

    cnt[col[node]] = before + sub[node];
}

int main(){

    FASTIO;
    PRECISION; 

    ll n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>col[i];
        freq[col[i]]++;
    }

    int u,v;

    for(int i=0;i<n-1;i++){
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1);

    ll tot = (n*(n-1))/2;

    for(int i=1;i<=n;i++){
        ll temp = n - cnt[i];
        ans[i]+=(temp*(temp-1))/2;
    }

    for(int i=1;i<=n;i++){
        cout<<tot-ans[i]+freq[i]<<"\n";
    }

}

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

vector<vector<pair<int,long long>>>V;
vector<int>color;
vector<bool>visit;

void dfs(int parent) {
	for (auto edge : V[parent]) {

		if (visit[edge.first])continue;

		if (edge.second % 2 == 0) color[edge.first] = color[parent];
		else color[edge.first] = !color[parent];
		visit[parent] = true;

		dfs(edge.first);
	}
}
int main() {
	int N,u,v;
	long long w;
	cin >> N;
	V.resize(N);
	color.resize(N);
	visit.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> u >> v >> w;
		V[u-1].push_back(make_pair(v-1, w));
		V[v-1].push_back(make_pair(u-1, w));
	}
	color[0] = 0;
	dfs(0);
	for (int w : color)cout << w << endl;
	return 0;
}
//int main() {
//	int zero = 0;
//	int one = 1;
//	cout << zero << " " << !zero << endl;
//	cout << one << " " << !one << endl;
//}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
#define in(A, n)                                                                                                       \
    rep(i, n) {                                                                                                        \
        cin >> f;                                                                                                      \
        A.push_back(f);                                                                                                \
    }

void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
void input() { cin >> a >> b >> c >> d; }
void solve() { print(max({a * c, b * c, a * d, b * d})); }
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 3652
N,Y=map(int,input().split())
x,y,z=0,0,0
a,b,c=0,0,0
x=Y//1000
y=x-N
a=min(N+1,Y//10000+1)
b=min(N+1,Y//5000+1)
for i in range(a):
  for j in range(b):
    if 9*i+4*j==y and N-i-j>=0:
      z=z+1
      a,b,c=i,j,x-y-i-j
if z==0:
  print(-1,-1,-1)
else:
  print(a,b,c)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main(void)
{
	int N;
	set<ULL>A;
	cin >> N;
	int las = -1;
	for (int i = 0; i < N; ++i) {
		string S;
		cin >> S;
		if (las >= 0 && las != S.front()) {
			cout << "No" << endl;
			return 0;
		}
		las = S.back();
		ULL H = 0;
		for (char c : S) {
			H *= 1000000007;
			H += c;
		}
		if (A.count(H)) {
			cout << "No" << endl;
			return 0;
		}
		A.insert(H);
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

ll dp[200001];
long long multiple_of_2019(string s) {
  int n = (int) s.size();
  int mul = 1;
  for(int i=n-1;i>=0;i--) {
    int digit = (int) s[i] - '0';
    dp[i] = (digit * mul + dp[i+1]) % 2019;
    mul = (mul * 10) % 2019;
  }
  map<int, ll> mp;
  for(int i =0;i<=n;i++) {
    mp[dp[i]] += 1; 
  }
  ll ans = 0;
  for(auto i = mp.begin(); i != mp.end();i++) {
    //cout << i->first << " => " << i->second << endl;
    ll a = i->second;
    ans += a * (a -1) / 2;
  }
  /*
  for(int i=0;i<=n;i++) {
    cout << i << " -> " << dp[i] << endl;
  }
  */
  return ans;
}

int main() {
  string s;
  cin >> s;
  cout << multiple_of_2019(s); 
}

Measured memory_bytes: 5248
#include<iostream>
#include<set>
#include<queue>
using namespace std;

const int limit = 100001;
int memo[limit];

int main() {
    int n;
    cin >> n;

    fill(memo, memo+limit, 1e9+1);

    set<int> st;

    queue<int> que;
    que.push(1);
    st.insert(1); memo[1] = 1; memo[0] = 0;
    for(int i = 6; i <= n; i *= 6) {
        st.insert(i);
        que.push(i);
        memo[i] = 1;
    }
    for(int i = 9; i <= n; i *= 9) {
        st.insert(i);
        que.push(i);
        memo[i] = 1;
    }
    while(!que.empty()) {
        int p = que.front(); que.pop();
        for(auto e : st) {
            if(p + e <= n && memo[p + e] > memo[p] + 1) {
                memo[p + e] = memo[p] + 1;
                que.push(p + e);
            }
        }
    }

    cout << memo[n] << endl;

    return 0;
}

Measured memory_bytes: 768
// 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;


lli b[200005] = {};
void solve(long long N, std::vector<long long> a) {
  rep(i, N+1)b[i] = -1;
  b[0] = 0;
  rep(i, N){
    if(b[a[i]-1] != -1 && b[a[i]] == -1){
      b[a[i]] = i;
    }
  }
  if(b[1]==-1){
    cout << -1 << endl;
    return;
  }
  int cnt = 0;
  for(int i = 1;i<=N;i++){
    if(b[i]==-1){
      cout << N - cnt << endl;
      return ;
    }
    cnt++;
  }
  cout << 0 << endl;
}

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


Measured memory_bytes: 3328
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
int main() {
	string a;
	cin >> a;
	cout << ((a[a.size()-1] == 's') ? a+"es":a+"s");
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
#include<queue>
using namespace std;
int w,h,mas[30][30],c[4];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
bool used[30][30][4];
struct P{
  int x,y,MUKI,cnt;
  P(){}
  P(int x,int y,int MUKI,int cnt) : x(x),y(y),MUKI(MUKI),cnt(cnt) {}
  bool operator < (const P &s) const{
    return cnt > s.cnt;
  }
};
int bfs();
int main(){
  while(cin >> w >> h && w||h){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> mas[i][j];
      }
    }
    for(int i=0;i<4;i++) cin >> c[i];
    memset(used,false,sizeof(used));
    cout << bfs() << endl;
  }
}
int bfs(){
  priority_queue<P> que;
  que.push(P(0,0,0,0));
  while(!que.empty()){
    P p = que.top();
    que.pop();
    if(used[p.x][p.y][p.MUKI]) continue;
    used[p.x][p.y][p.MUKI] = true;
    if(p.x == h-1 && p.y == w-1) return p.cnt;
    for(int i=0;i<4;i++){
      int nMUKI = (p.MUKI + i) % 4,ncos = p.cnt;
      int nx = p.x + dx[nMUKI],ny = p.y + dy[nMUKI];
      if(mas[p.x][p.y] != i) ncos += c[i];
      if(nx>=0&&nx<h&&ny>=0&&ny<w){
        que.push(P(nx,ny,nMUKI,ncos));
      }
    }
  }
}

Measured memory_bytes: 1336
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++) 
#define ll long long
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll diff = b - a;
    if(n == 2) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = 0;
    if(diff % 2 == 0) {
        cout << abs((b+a)/2-a) << endl;
    }
    else {
        //cout << min(abs(1-b), abs(n-a)) << endl;
        ans = min(abs(1-b), abs(n-a));
        ll ans2 = 0;
        ll tmp1, tmp2;
        tmp1 = a-1;
        tmp2 = n-b;
        if(tmp1 == min(tmp1, tmp2)) {
            b -= tmp1;
            a -= tmp1;
            ans2 += tmp1;
            b--;
            //cout << tmp1 << endl;
            //cout << a << " " << b << " " << ans2 << endl;
        }
        else if(tmp2 == min(tmp1, tmp2)) {
            a += tmp2;
            b += tmp2;
            ans2 += tmp2;
            a++;
        }
        

        ans2++;
        //cout << ans2 << endl;
        ll tmp3 = (b+a)/2;
        if(tmp3 != 0) {
            ans2 += abs(tmp3-a);
        }
        
        cout << min(ans, ans2) << endl;
        //cout << ans << " " << ans2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int i;

int main (void)
{
    long Q,H,S,D,N,sum=0,min,k=0,l=0;
    scanf("%ld\t%ld\t%ld\t%ld",&Q,&H,&S,&D);
    long a[]={4*Q,2*H,S,D/2};
    scanf("%ld",&N);
    min=a[0];
    for(i=1;i<4;i++)
    {
        if(min>a[i])
        {
            min=a[i];
            k=i;
        }
    }
    min=a[0];
    for(i=1;i<3;i++)
    {
        if(min>a[i])
        {
            min=a[i];
            l=i;
        }
    }
    switch (k) {
        case 0:
            sum=N*4*Q;
            break;
        case 1:
            sum=N*2*H;
            break;
        case 2:
            sum=N*S;
            break;
        case 3:
            sum=N/2*D;
            switch (l) {
                case 0:
                    sum+=(N%2)*4*Q;
                    break;
                case 1:
                    sum+=(N%2)*2*H;
                    break;
                case 2:
                    sum+=(N%2)*S;
            }
            break;
    }
    printf("%ld",sum);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

int a,b,c,d;

map<ll,ll> mem;
ll f(ll x) {
  if (!x) return 0;
  if (mem.count(x)) return mem[x];
  ll res = LINF;
  if (LINF/d > x) res = x*d;
  auto f2 = [&](ll y) {
    if (y >= x) return LINF;
    return f(y);
  };
  {
    ll l = x/2*2, r = l+2;
    mins(res, f2(l/2)+a+(x-l)*d);
    mins(res, f2(r/2)+a+(r-x)*d);
  }
  {
    ll l = x/3*3, r = l+3;
    mins(res, f2(l/3)+b+(x-l)*d);
    mins(res, f2(r/3)+b+(r-x)*d);
  }
  {
    ll l = x/5*5, r = l+5;
    mins(res, f2(l/5)+c+(x-l)*d);
    mins(res, f2(r/5)+c+(r-x)*d);
  }
  return mem[x] = res;
}

void solve() {
  ll n;
  cin>>n;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  mem = map<ll,ll>();
  cout<<f(n)<<endl;
}

int main() {
  int ts;
  scanf("%d",&ts);
  rep(ti,ts) solve();
  return 0;
}






















Measured memory_bytes: 4892
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main(void) {
	int x;
	cin >> x;
	int c_500 = 0;
	int c_5 = 0;

	c_500 = x / 500;
	c_5 = (x - x/500 * 500)/5;

	cout << 1000*c_500 + 5*c_5 << endl;
}


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

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<int> A(N);
    int cnt = 0;
    rep(i, N) {
        if(S[i] == 'R') cnt++;
        else A[i] = cnt, cnt = 0;
    }
    cnt = 0;
    for(int i = N - 1; i >= 0; --i) {
        if(S[i] == 'L') cnt++;
        else A[i] = cnt, cnt = 0;
    }
    vector<int> ans(N);
    rep(i, N) {
        if(A[i]) swap(A[i], A[i + 1]), i++;
    }
    rep(i, N) {
        if(A[i] && S[i] == 'R') {
            ans[i] += (A[i] + 1) / 2;
            ans[i + 1] += A[i] / 2;
        }
    }
    rep(i, N) {
        if(A[i] && S[i] == 'L') {
            ans[i] += (A[i] + 1) / 2;
            ans[i - 1] += A[i] / 2;
        }
    }
    for(auto &e : ans) cout << e << " ";
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            z = 4*i*j - N*(j+i)
            if z > 0:
                h, r = divmod((N*i*j), z)
                if r == 0:
                    print(h, i, j)
                    exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


# #!/usr/bin/env python3
# n = int(input())
# for i in range(1, 3501):
#   for j in range(1, 3501):
#     seed = 4 * i * j - n * (i + j) 
#     if seed > 0:
#       k, mod = divmod(n * i * j, seed) 
#       if mod == 0:
#         print(i, j, k)
#         exit()

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N, X, T = LI()

    time = math.ceil(N/X)
    ans = T*time

    print(ans)
 

if __name__ == '__main__':
    main()


Measured memory_bytes: 10016
#include <iostream>

using namespace std;

int main(){
    int t;
    int h,m,s;
    
    cin >> t;
    
    
    h = t / 3600;
    t = t % 3600;
    
    m = t / 60;
    t = t % 60;
    
    s = t;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3080
import scala.util.control.Breaks

object Main extends App {
  val n =  scala.io.StdIn.readLong()
  val max = math.sqrt(n).toInt
  val b = new Breaks
  var coordinate = (1L, n)
  b.breakable {
    for (i <- max to 2 by -1) {
      if (n % i == 0) {
        coordinate = (i.toLong, n / i)
        b.break
      }
    }
  }
  println(coordinate._1 + coordinate._2 - 2L)
}

Measured memory_bytes: 27212
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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() {
    double r;
    cin >> r;
    cout << std::fixed << std::setprecision(15) << 2*3.141592653589793*r << endl;
}


Measured memory_bytes: 3728
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
a, b  =  map(int, sys.stdin.readline().split())

A = 0

for i in range(b - a, 0, -1):
    A += i

print(A - b)

Measured memory_bytes: 64492
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map {it.toInt()}
    val X = readLine()!!.split(" ").map {it.toInt()}.sorted()

    val res = X.last() - X.first()
    val Y = Array(M - 1) { X[it + 1] - X[it] }.sortedDescending().take(N - 1).sum()

    println(res - Y)
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e9 + 10;
const int maxn = 3e3 + 10;
const int maxq = 6e2 + 10;
const int alf = 26;
const ll dlm = 1e9+7;
const int del = 1234234 ;
const int eps = 1e-7 ;
string O[]={"YES","NO","Yes","No"};

ll dp[maxn][maxn];
ll a[maxn];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=n;i>=1;i--){
        for(int j=i;j<=n;j++){
            ll len = j-i + 1;
            if((len%2)==(n%2)){
                dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
            }else{
                dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
            }
        }
    }
    cout<<dp[1][n];
    return 0;
}


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

int pow10(int n){
  int tmp=1;
  rep(i,n)
    tmp*=10;
  return tmp;
}

int main(){

  int n;
  scanf("%d",&n);

  int d[1000];
  rep(i,n){
    scanf("%d",&d[i]);
  }

  int count=0,end=0;
  rep(j,n){
    int c[1000]={0};
    if(end) break;
    int k=0;
    rep(i,n-j){
      rep(k,j+1){
	c[i] += d[i+k] * pow10(j-k);
      }
    }
 
    sort(c,c+n-j);

    rep(i,n-j){
      if(count>=c[i]);
      else if(c[i]==count+1)
	count++;
      else{
	end=1;
	break;
      }
    }
  }
  if(count)
    count++;
  printf("%d\n",count);

}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  int A[N];
  fill(A, A + N, 0);

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;

    A[a - 1] += 1;
  }

  sort(A, A + N);

  int answer = 0;
  for (int i = 0; i < N - K; i++) {
    answer += A[i];
  }

  cout << answer << endl;
}


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

using namespace std;

#define ll long long

ll n , m;

vector<ll>dv;

int main()
{
    cin >> n >> m;
    ll ans = 0;
    for(int i = 1; i<=sqrt(m); i++){
        if(m%i == 0){
            dv.push_back(i);
            dv.push_back(m/i);
        }
    }
    for(int i = 0; i<dv.size(); i++){
        ll k = m/dv[i];
        if(k >= n){
            ans = max(ans , dv[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int i, n, s, sum, avg;
  vector<int> data;

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

    for(i=0; i<n; ++i){
      cin >> s;
      data.push_back(s);
    }

    sort(data.begin(), data.end());

    for(i=1, sum=0; i<n-1; ++i)
      sum += data[i];

    avg = sum / (data.size()-2);

    cout << avg << endl;
    data.clear();
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    long long int n,i;
    cin>>n;
    long long int a[n],dp[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792