akhauriyash/Code-Regression huggingface dataset:
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 100;

int n;
int a[MAXN];
int b[MAXN];
const int INF = 100;

int dd[MAXN][MAXN];
int av[MAXN][MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i <= 50; ++i)
		for (int j = 0; j <= 50; ++j)
			dd[i][j] = INF;
	for (int i = 0; i <= 50; ++i)
		dd[i][i] = 0;
	for (int k = 1; k <= 50; ++k) {
		for (int i = 0; i <= 50; ++i) {
			dd[i][i % k] = min(dd[i][i % k], k);
		}
	}
	for (int k = 0; k <= 50; ++k)
		for (int i = 0; i <= 50; ++i)
			for (int j = 0; j <= 50; ++j) {
				if (dd[i][j] > max(dd[i][k], dd[k][j])) {
					dd[i][j] = max(dd[i][k], dd[k][j]);
				}
			}
	for (int i = 0; i < n; ++i)
		av[i][a[i]] = 1;
	ll ans = 0;
	for (int i = 50; i > 0; --i) {
		int fl = 0;
		for (int j = 0; j < n; ++j) {
			int fl2 = 0;
			for (int k = 0; k <= 50; ++k)
				if (av[j][k] && dd[k][b[j]] < i) {
					fl2 = 1;
					break;
				}
			if (!fl2) {
				fl = 1;
				break;
			}
		}
		if (fl) {
			ans += (1ll << i);
			for (int j = 0; j < n; ++j)
				for (int k = 0; k <= 50; ++k)
					if (av[j][k]) {
						av[j][k % i] = 1;
					}
		}
	}
	for (int i = 0; i < n; ++i)
		if (!av[i][b[i]]) {
			cout << -1 << "\n";
			return 0;
		}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int lower, int higher)
{
    if (lower == 0)
        return higher;
    else
        return gcd(higher % lower, lower);
}

int main(int argc, char const *argv[])
{
    int x, y;
    cin >> x >> y;

    if (x > y)
        swap(x, y);
    cout << gcd(x, y) << endl;

    return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String N = sc.next();
		int sum = 0;

		if (N.substring(0).startsWith("1")) {
			sum++;
		}
		if (N.substring(1).startsWith("1")) {
			sum++;
		}
		if (N.substring(2).startsWith("1")) {
			sum++;
		}

		System.out.println(sum);

		sc.close();
	}
}

Measured memory_bytes: 22868
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int A1[110];
  int A2[110];

  for (int i = 0; i < N; i++) {
    cin >> A1[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> A2[i];
  }
  int max = 0;
  for (int k = 0; k < N; k++) {
    int count = 0;
    for (int l = 0; l <= k; l++) {
      count += A1[l];
    }
    for (int l = k; l < N; l++) {
      count += A2[l];
    }

    if (count > max) {
      max = count;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  long long i,c=0;
  cin>>s>>t;
  for(i=0;i<s.size();i++)
  {
    if(s[i]!=t[i]) c++;
  }
  cout<<c<<endl;



 return 0;

}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

using P = pair<i64, i64>;
i64 solve(i64 N, vector<P> item) {
    int sz = item.size();
    if(sz == 0) return N;
    else if(sz == 1) { // 得する品が１つだけ
        int a, b;
        tie(a, b) = item[0];
        return N % a + (N / a) * b;
    } else if(sz == 2) { // 得する品が２つ
        i64 retval = 0;
        int a0, b0, a1, b1;
        tie(a0, b0) = item[0], tie(a1, b1) = item[1];
        for(i64 i = 0; i * a0 <= N; i++) { // １つ目をi個買う
            i64 remain = N - i * a0;
            retval = max(retval, i * b0 +
                remain % a1 + (remain / a1) * b1);
        }
        return retval;
    } else if(sz == 3) { // 全部得する
        vector<i64> dp(5001, 0);
        for(int i = 0; i < sz; i++) {
            int a, b;
            tie(a, b) = item[i];
            for(int j = 0; j + a <= N; j++) {
                dp[j + a] = max(dp[j + a], dp[j] + b);
            }
        }
        i64 retval = 0;
        for(int i = 0; i <= N; i++) {
            retval = max(retval, dp[i] + N - i);
        }
        return retval;
    } else return -1;
}

int main() {
    int N;
    cin >> N;
    vector<i64> A(3), B(3);
    for(auto &x : A) cin >> x;
    for(auto &x : B) cin >> x;
    vector<P> items[2];
    for(int i = 0; i < 3; i++) {
        if (A[i] < B[i]) {
            items[0].push_back({A[i], B[i]});
        } else if(A[i] > B[i]) {
            items[1].push_back({B[i], A[i]});
        }
    }
    cout << solve(solve(N, items[0]), items[1]) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        List<TreeMap> mapList = new ArrayList<TreeMap>();
        int[][] valAry = new int[M][2];

        for(int i = 0; i < N ; i++){
            TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
            mapList.add(map);
        }
        for(int i = 0; i < M ; i++){
            int P = sc.nextInt();
            int Y = sc.nextInt();
            mapList.get(P-1).put(Y, i);
            valAry[i][0] = P;
            valAry[i][1] = Y;
        }
        for(Map map : mapList){
            Iterator<Map.Entry<Object, Object>> it = map.entrySet().iterator();
            int i = 1;
            while (it.hasNext()) {
                Map.Entry<Object, Object> entry = it.next();
                entry.setValue(i);
                i++;
            }
            System.out.println();
        }
        for(int i = 0; i < M ; i++){
            System.out.println(format(valAry[i][0])+format((int) mapList.get(valAry[i][0]-1).get(valAry[i][1])));
        }

    }

    public static String format(int val){
        if(val > 99999) return "" + val;
        else if(val > 9999) return "0" + val;
        else if(val > 999) return "00" + val;
        else if(val > 99) return "000" + val;
        else if(val > 9) return "0000" + val;
        else if(val > 0) return "00000" + val;
        else return "";
    }
}

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

int main(){
	int A,B,idxA,idxB; cin >> A >> B;
	int c[13]={2,3,4,5,6,7,8,9,10,11,12,13,1}; 
	for(int i=0;i<13;i++){
		if(A==c[i]){
			idxA = i;
		}
		if(B==c[i]){
			idxB = i;
		}
	}
	if(idxA>idxB){
		cout << "Alice";
	}
	else if(idxA<idxB){
		cout << "Bob";
	}
	else if(idxA==idxB){
		cout << "Draw";
	}
} 

Measured memory_bytes: 256
#include <cstdio>
#define min(a,b) ((a)<=(b)?(a):(b))
int C[10000],N;
int solve(int x) {
	int i,j,count=1;
	for(i=x-1;i>=0;i--) if(C[x]!=C[i]) break; else count++;
	for(j=x+1;j<N;j++) if(C[x]!=C[j]) break; else count++;
	if(count<4) return N;
	if(C[i]!=C[j]) return N-count;
	while(i>=0 && j<N) {
		int chr=C[i],Count=0;
		for(i;i>=0;i--) if(C[i]!=chr) break; else Count++;
		for(j;j<N;j++) if(C[j]!=chr) break; else Count++;
		if(Count<4) break; else count+=Count;
	}
	return N-count;
}
int main() {
	while(scanf("%d",&N),N) {
		for(int i=0;i<N;i++) scanf("%d",&C[i]);
		int ans=1<<30;
		for(int i=0;i<N;i++) {
			int chr=C[i];
			for(int j=1;j<=3;j++) {
				if(chr==j) continue;
				C[i]=j;
				ans=min(ans,solve(i));
			}
			C[i]=chr;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1064
N,X=map(int,input().split())
a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def burger(L,x):
    if L == 0:
        return 0 if x == 0 else 1
    if x <= 1:
        return 0
    if x <a[L-1]+2:
        return burger(L-1,x-1)
    if x == a[L-1]+2:
        return p[L-1]+1
    if x < a[L]:
        return p[L-1]+1+burger(L-1,x-a[L-1]-2)
    if x == a[L]:
        return p[L]
print(burger(N,X))

Measured memory_bytes: 3064
#include <iostream>
#define M 998244353

using namespace std;

long long v[400005];
long long putere(long long n,long long p)
{
    long long power=1;
    while(p)
    {
        if(p%2==1)
            power=(power*n)%M;
        n=(n*n)%M;
        p/=2;
    }
    return power;
}
long long C(int n,int nr)
{

    return v[n]*putere(v[nr],M-2)%M*putere(v[n-nr],M-2)%M;
}
int main()
{
    int n,A,B;
    long long k;
    cin>>n>>A>>B>>k;
    long long sol=0;
    v[0]=1;
    for(int i=1;i<=n;i++)
        v[i]=v[i-1]*i%M;
    for(int a=0;a<=n;a++)
    {
        if(k-A*a>=0 and (k-A*a)%B==0)
        {
            if((k-A*a)/B<=n)
            {
                int b=(k-A*a)/B;
                sol=(sol%M+C(n,a)*C(n,b)%M)%M;
            }
        }
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int MAX_N = 505050;
vector<int>e[MAX_N], er[MAX_N];
int fin[MAX_N], li[MAX_N], state[MAX_N];
int cnt = 0;
void dfs1(int now) {
	state[now] = 1;
	fore(x, e[now]) {
		if (state[x] == 0) {
			cnt++;
			dfs1(x);
		}
	}
	cnt++;
	fin[now] = cnt;
}
void dfs2(int now, int num) {
	state[now] = 1;
	li[now] = num;
	fore(x, er[now]) {
		if (state[x] == 0)dfs2(x, num);
	}
}
void scc(int N) {
	//各頂点について終了時間を計算
	for (int i = 0; i < N; i++) {
		if (state[i] == 0)dfs1(i);
	}
	//逆辺を計算
	for (int i = 0; i < N; i++) {
		fore(x, e[i])er[x].pb(i);
	}

	for (int i = 0; i < N; i++)state[i] = 0;

	//終了時間の降順でdfsをしていく
	vector<pair<int, int>>finli;
	for (int i = 0; i < N; i++) {
		finli.pb({ fin[i],i });
	}
	sort(all(finli));
	reverse(all(finli));
	int num = 0;
	for (int i = 0; i < N; i++) {
		int v = finli[i].second;
		if (state[v] == 0) {
			dfs2(v, num);
			num++;
		}
	}
}

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

	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		e[a].pb(b);
	}
	scc(N);

	map<int, vector<int>>mp;
	for (int i = 0; i < N; i++)mp[li[i]].pb(i);
	puts(mp.size());
	for (int i = 0; i < mp.size(); i++) {
		cout << mp[i].size() << " ";
		fore(x, mp[i])cout << x << " ";
		puts("");
	}

	return 0;
}

Measured memory_bytes: 109600
r1,c1,r2,c2=map(int,input().split())

F = 2*10**6+5
mod = 10**9+7
fact = [1]*F
inv = [1]*F
for i in range(2,F):
    fact[i]=(fact[i-1]*i)%mod
inv[F-1]=pow(fact[F-1],mod-2,mod)
for i in range(F-2,1,-1):
    inv[i] = (inv[i+1]*(i+1))%mod

ans=fact[r2+c2+2]*inv[r2+1]*inv[c2+1]-fact[r2+c1+1]*inv[r2+1]*inv[c1]-fact[r1+c2+1]*inv[r1]*inv[c2+1]+fact[r1+c1]*inv[r1]*inv[c1]
ans%=mod
print(ans)

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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};


ull fu(ll a, ll b, ll x)
{
	ll ans=((b/x)-(a/x));
	return a%x==0?ans+1:ans;
}


int main()
{
	f();
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll ans=0;
	ll lc=((c*d)/__gcd(c,d));
	
	ll tot=(b-a+1)+fu(a,b,lc)-fu(a,b,c)-fu(a,b,d);


	cout<<tot<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
using namespace __gnu_pbds;
typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;*/

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    //freopen("connect_the_dots.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int x;
    cin >> x;
    cout << 3*x*x << endl;
}



Measured memory_bytes: 256
input_data = list(map(int,input().split()))

a = input_data[0]
b = input_data[1]

ans = 0

while True:
    if b <= 1 and ans == 0:
        break
    elif b > a:
        b = b - a +1
        ans += 1
    else:
        ans += 1
        break

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,x,y;
string a[50],b[50];
bool res=false;
int main()
{
  cin>>n>>m;
  for(;i<n;i++)cin>>a[i];
  for(i=0;i<m;i++)cin>>b[i];

  for(i=0;i<n-m+1;i++){
    for(;j<n-m+1;j++){
      for(;x<m;x++){
        if(b[0].compare(a[i].substr(j,m))!=0)break;
        if(x==m-1)res=true;
      }
    }
    if(res)break;
  }
  cout<<(res?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define gg return puts("No"),0
#define ok return puts("Yes"),0

using namespace std;

inline int read() {
    int res=0,fh=1;
    char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    return fh*res;
}

const int maxn=100010;
const int INF= (1<<30);
int a[maxn],n,maxx=-INF,minn=INF,cnt=0;

inline int Max(int a,int b){
	return a<b?b:a;
}
inline int Min(int a,int b){
	return a>b?b:a;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		maxx=Max(maxx,a[i]);
		if(a[i]<minn) cnt=1;
		else if(a[i]==minn) cnt++;
		minn=Min(minn,a[i]);
	}
	if(maxx>minn+1) gg;
	else if(maxx==minn){
		if(minn==n-1||(minn<<1)<=n) ok;
		else gg; 
	}
	else{
		if(minn<cnt||n-cnt<2*(maxx-cnt)) gg;
		else ok;
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int n,ans=0,a,i;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a;
    while(a%2==0){a=a/2;ans++;}
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  string a;
  string b;
  int c;
  int d;
  string e;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  
  if (a == e) {
    cout << c - 1;
    cout << " ";
    cout << d;
    return 0;
  }
    
  cout << c;
  cout << " ";
  cout << d - 1;
    
  return 0;   
}

Measured memory_bytes: 3492
#include <stdio.h>
int main()
{
	long long int N, A,B;
	scanf("%lld %lld %lld",&N,&A,&B);
    if(A>B)printf("0");else{
	if(N>=2)printf("%lld", (N-2)*(B-A) +1);
    
    if(N==1){if(A==B)printf("1");else printf("0");}}
    
    
 
 
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;scanf("%lld",&n);
    ll l=1,r=26,cot=26,len=1;
    while(r<n) len++,cot*=26,l=r+1,r+=cot;
    n-=l;
    stack<char>s;
    for(int i=1;i<=len;i++)
        s.push(n%26+'a'),n/=26;
    while(!s.empty())
        putchar(s.top()),s.pop();
}


Measured memory_bytes: 3696
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt(), W = sc.nextInt();
			if(H == 0 && W == 0) break;
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 32964
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,A[1000];

void push(int x){    
  A[++top] = x;
}

int pop(){
  top--;
  return A[top+1];
}

int main(){
  int a,b;
  top = 0;
  char c[100];

  while(scanf("%s", c) != EOF){
    if(c[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(c[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(c[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else{
      push(atoi(c));
    }
  }

  printf("%d\n",pop());

  return 0;
}



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

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for(int i=0;i<s.size();i++){
        cout << s[i];
    }
    
    return 0;
}

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

using namespace std;
struct UnionFind {
    vector<int> data;
    int size;
    UnionFind(int N) : 
        data(N, -1), size(N) {}
    int root(int x){
        if(data[x] < 0) return x;
        return data[x] = root(data[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(-data[x] < -data[y]) swap(x, y);
        size--;
        data[x] += data[y];
        data[y] = x;
    }
};

const int MOD = 1000000007;

int main(){
    int N, M;
    while(cin >> N >> M && N > 0){
        UnionFind uf(N);
        REP(i, M){
            int a, b;
            cin >> a >> b;
            a--; b--;
            uf.unite(a, b);
        }
        int s = uf.size;
        int ans = 1;
        REP(i, s) ans = (2LL * ans) % MOD;
        if(s < N) {
            ans = (ans + 1) % MOD;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1580
a,b,c=map(int, input().split())
al=[]
bl=[]
for i in range(1,a+1):
    if a%i==0:
        al.append(i)
for i in range(1,b+1):
    if b%i==0:
        bl.append(i)
co=sorted(list(set(al)&set(bl)))
print(co[-c])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    set<int> mut;
    rep(i,n-1) {
        if(s[i] == 'R' && s[i+1] == 'L') mut.insert(i);
    }
    vector<int> ans(n);
    rep(i,n) {
        if(mut.count(i) || mut.count(i-1)) ans[i]++;
        else {
            auto it = mut.lower_bound(i);
            if(s[i] == 'R') {
                int dis = *it-i;
                if(dis%2 == 0) ans[*it]++;
                else ans[*it+1]++;
            } else {
                it--;
                int dis = i-(*it+1);
                if(dis%2 == 0) ans[*it+1]++;
                else ans[*it]++;
            }
        }
    }
    rep(i,n-1) cout << ans[i] << " ";
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define pfd(n) printf("%d", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")

#define PI 3.1415926 

using namespace std;

int main() {
	int n;
	string str;
	cin >> n;
	getchar();
	cin >> str;
	string s1 = "(", s2 = ")";
	string s = str;
	for( int i=0; i<s.size()-1;  ) {
		if( s[i]=='('&&s[i+1]==')' ) {
			s.erase(s.begin()+i, s.begin()+i+2);
			i = 0;
		}else {
			i++;
		}
		if( s.size()<=0 ) {
			break;
		}
	}
	int len = s.size();
	for( int i=0; i<len; i++ ) {
		if( s[i]=='(' ) {
			str = str + ')';
		}else {
			str = '(' + str;
		}
	}
	cout << str;
	pfn;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  string ans = "";
  while (N--)
  {
    ans += (char)(N % 26 + 'a');
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <string>
using namespace std;

int main() {
    int N,K;
    cin >> N >> K;
    double ret = 0;

    for(int i = 1;i <= N;i++){
      double temp = 1.0 / N;
      int now = i;

      while(now < K){
        now *= 2;
        temp /= 2;
        }

        ret += temp;
    }
    printf("%.12f\n",ret);
}


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

int main() {
    int n, m; cin >> n >> m;
    vector<set<pair<int, int>>> p_y_i(n);
    for (int i=0; i<m; ++i) {
        int p, y; cin >> p >> y;
        p--;
        p_y_i[p].insert(make_pair(y, i));
    }
    vector<pair<int, int>> cities(m);
    for (int p=0; p<n; ++p) {
        if (p_y_i[p].empty()) continue;

        int cnt = 1;
        for (auto i: p_y_i[p]) {
            cities[i.second] = make_pair(p + 1, cnt);
            cnt++;
        }
    }
    for (auto i: cities) {
        printf("%06d%06d\n", i.first, i.second);
    }
}

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	if(a>b){
		cout<<"a > b"<<endl;
	}
	if(a==b){
		cout<<"a == b"<<endl;
	}
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;
double X[10], Y[10];

double ans = 0;
bool used[10];

void solve(int pos = 0, int pre = -1, double dist = 0) {
  if(pos == N) {
    ans += dist;
    return;
  } else {
    REP(n,N) {
      if(used[n]) continue;
      used[n] = true;
      double nextD = dist;
      if(pos != 0) {
        nextD += sqrt(pow(X[pre] - X[n], 2) + pow(Y[pre] - Y[n], 2));
      }
      solve(pos+1, n, nextD);
      used[n] = false;
    }
  }
}

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> X[n] >> Y[n];
  }

  solve();

  double t = 1;
  FOR(n,1,N+1) {
    t *= n;
  }

  printf("%.10f\n", ans/t);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    multiset<double> V;
    for(int i = 0;i < N;i++) {
        double d;
        cin>>d;
        V.insert(d);
    }
    for(int i = 0;i < N-1;i++) {
        double a = *V.begin();V.erase(V.begin());
        double b = *V.begin();V.erase(V.begin());
        V.insert((a+b)/2);
    }

    cout<<*V.begin()<<endl;

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll N;
	scanf("%lld",&N);

	ll A,B;
	scanf("%lld %lld",&A,&B);

	switch(N%12){
	case 0:
		printf("%lld %lld\n",A,B);
		break;
	case 1:
		printf("%lld %lld\n",A-B,B);
		break;
	case 2:
		printf("%lld %lld\n",A-B,A);
		break;
	case 3:
		printf("%lld %lld\n",-B,A);
		break;
	case 4:
		printf("%lld %lld\n",-B,A-B);
		break;
	case 5:
		printf("%lld %lld\n",-A,A-B);
		break;
	case 6:
		printf("%lld %lld\n",-A,-B);
		break;
	case 7:
		printf("%lld %lld\n",-A+B,-B);
		break;
	case 8:
		printf("%lld %lld\n",-A+B,-A);
		break;
	case 9:
		printf("%lld %lld\n",B,-A);
		break;
	case 10:
		printf("%lld %lld\n",B,-A+B);
		break;
	case 11:
		printf("%lld %lld\n",A,-A+B);
		break;
	}

	return 0;
}



Measured memory_bytes: 3216
n,m=map(int,input().split())
ab=[]
l=[0 for i in range(n+1)]
for i in range(m):
    a=[int(j)-1 for j in input().split()]
    ab.append(a)

par=[-1 for i in range(n)]

def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

ans=[0 for i in range(m)]
ans[m-1]=n*(n-1)//2

for i in range(1,m):
    i=m-i
    ans[i-1]=ans[i]
    if root(ab[i][0])!=root(ab[i][1]):
        ans[i-1]-=size(ab[i][0])*size(ab[i][1])
        connect(ab[i][0],ab[i][1])

for i in range(m):
    print(ans[i])




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

int main()
{
  int x, sum;

  sum = 0;

  for (int i = 0; i < 5; i++){
    cin >> x;
    if (x < 40){
      x = 40;
    }
    sum += x;
  }

  cout << sum / 5 << endl;

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static ll n;
	static ll a[100010];
	scanf("%lld",&n);
	rep(i,n)scanf("%lld",&a[i]);
	
	ll ret = a[0]-1;
	ll t = 2;
	rep1(i,n-1){
		if(a[i] == t)t ++;
		ret += (a[i]-1)/t;
	}
	cout << ret << endl;
}



Measured memory_bytes: 1024
N = int(input())
is_exist = False
for h in range(1, 3501):
  for n in range(1, 3501):
    if (4*h*n-N*n-N*h) > 0 and (N*h*n) % (4*h*n-N*n-N*h) == 0:
      print(h, n, (N*h*n) // (4*h*n-N*n-N*h))
      is_exist = True
      break
  if is_exist:
    break


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<ll, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main() {
	ll a, b, c, d, x; cin >> a >> b >> x >> c >> d >> x >> x;
	ll out = 0;
	ll sum = b + (ll)2 * (a / 2) + (ll)2 * (c / 2) + (ll)2 * (d / 2);
	out = sum;
	if (a > 0 && c > 0 && d > 0) {
		a--; c--; d--; sum = 3;
		sum += b + (ll)2 * (a / 2) + (ll)2 * (c / 2) + (ll)2 * (d / 2);
		out = max(out, sum);
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	int n;
	int c;
	int s;
	int d;
	scanf("%d %d", &n,&c);	
	d = 2 * n - 1;
	if (c > 1){
		if (c < d){
			printf("Yes\n");
			for (int i = 0; i < d; i++){
				s = i + c - n;
				if (s < 0)s = s + d;
				s = s%d;
				printf("%d\n", s + 1);
			}
		}
		else printf("No\n");
	}
	else printf("No\n");	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
#define nl cout<<"\n";
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    
   

    fastio;
    string s1;
    cin>>s1;
    bool flag = false;
    for(int i=0;i<s1.length();i++){if(s1[i]=='7'){flag = true;break;}}
    if(flag){cout<<"Yes";}else{cout<<"No";}    
}

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x;
double p;

int main(){
	cin>>x>>p;
	p/=100;
	if(x%2==1) x++;
	cout<<syosu(9)<<(double)x/2/p<<endl;
}

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

int N, M;
vector<vector<int> > G;

int s, t;

vector<bool> seen;
bool rec(int v, int p = -1) {
    if (v == s && p != -1) return true;
    if (v != s) seen[v] = true;
    for (auto nv :  G[v]) {
        if (nv == p || nv == t || seen[nv]) continue;
        if (rec(nv, v)) return true;
    }
    return false;
}
        

bool solve() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    map<int,int> degs;
    for (int v = 0; v < N; ++v) degs[(int)G[v].size()]++;

    for (auto it : degs) if (it.first % 2 != 0) return false;
    if (degs[6] > 0) return true;
    if (degs[4] > 2) return true;
    if (degs[4] <= 1) return false;

    vector<int> four;
    for (int v = 0; v < N; ++v) {
        if (G[v].size() == 4) four.push_back(v);
    }
    s = four[0], t = four[1];
    seen.assign(N, 0);
    bool ok1 = rec(s);
    //s = four[1], t = four[0];
    //seen.assign(N, 0);
    //bool ok2 = rec(s);

    if (ok1) return true;
    else return false;
}

int main() {
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 6912
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)


ll N,M;

int main() {
    cin >> N >> M;
    ll t = 100*(N-M)+1900*M;
    ll s = pow(2,M);
    cout << s*t << endl;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      System.Console.ReadLine();
      string str = System.Console.ReadLine();
      int a=0;
      int b=str.Length-1;
      int cnt=0;
      while(a<b){
        if(str[a]=='R'){
          a++;
        }else if(str[b]=='W'){
          b--;
        }else{
          cnt++;
          a++;
          b--;
        }
      }
    Console.WriteLine(cnt);
	}
}

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

int main(){
  string s,ans; cin>>s;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='1')ans+='1';
    else if(s[i]=='0')ans+='0';
    else{
      if(ans.empty())continue;
      ans.erase((int)ans.size()-1,1);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
    int n,i,j,k,flag=0,jflag=0,p[50];
    scanf("%d", &n);
    for (i = 0; i < n;i++)
    {
        scanf("%d", &p[i]);
    }
   /*  for (i = 0; i < n;i++)
    {
        if(p[i]!=i+1&&flag==0)
        {
            if(p[p[i]-1]!=i+1)
                break;
            flag = 1;
        }
    }
    printf("%d", i);
    if(i==n)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }*/
    k = 0;
    for (i = 0; i < n; i++)
    {
        if(p[i]!=i+1)
            k++;
    }
    //printf("%d", i);
    if (k == 0||k==2)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }

        return 0;
}

Measured memory_bytes: 128
n, a, b = list(map(int, input().split(' ')))
mod = pow(10, 9) + 7


def comb2(n, i, mod):
    p = 1
    q = 1

    for s in range(n, n - i, -1):
        p = (p * s) % mod

    for s in range(1, i + 1):
        q = (q * s) % mod

    d = pow(q, mod-2, mod)

    return p * d


print((pow(2, n, mod) - 1 - comb2(n, a, mod) - comb2(n, b, mod)) % mod)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int w;
cin>>n>>w;
int a[n+1];
long long value[n+1];
for (int i =1;i<=n; ++i)
{
	cin>>a[i];
	cin>>value[i];
}

long long dp[n+1][w+1];

for(int i=0;i<=n;i++)
{
	for(int j=0;j<=w;j++)
	{
		if(i==0 || j==0)
			dp[i][j]=0;

		else if(a[i]<=j)
			dp[i][j]=std::max(dp[i-1][j],((long long)value[i]+dp[i-1][j-a[i]]));

		else
			dp[i][j]=dp[i-1][j];
			
	}
	
}

cout<<dp[n][w]<<endl;

return 0;
}

Measured memory_bytes: 79104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int main()
{
  int N, L, R;
  vector<ii> byleft, byright;
  bool visited[100002];
  
  scanf("%d", &N);

  REP(i, 0, N-1)
  {
    visited[i] = false;
    scanf("%d %d", &L, &R);
    byleft.push_back(make_pair(-L, i));
    byright.push_back(make_pair(R, i));
  }
  
  sort(byleft.begin(), byleft.end());
  sort(byright.begin(), byright.end());
  
  int a = 0, b = 0;
  int step = 0;
  int where = 0;
  long long int tot = 0;
  
  REP(i, 0, N-1)
  {
    if(step == 0)
    {
      while(visited[byleft[a].second]) a++;
      visited[byleft[a].second] = true;
      int go = -byleft[a].first;
      //cout << go << endl;
      if(go > where)
      {
        tot += (long long int)(go-where);
        where = go;
      }
    }
    else
    {
      while(visited[byright[b].second]) b++;
      visited[byright[b].second] = true;
      int go = byright[b].first;
      //cout << go << endl;
      if(go < where)
      {
        tot += (long long int)(where-go);
        where = go;
      }
    }
    step = 1-step;
  }
  
  if(where > 0) tot += where;
  else tot += -where;
  
  REP(i, 0, N-1) visited[i] = false;
  
  a = 0;
  b = 0;
  step = 1;
  where = 0;
  long long int tot2 = 0;
  
  REP(i, 0, N-1)
  {
    if(step == 0)
    {
      while(visited[byleft[a].second]) a++;
      visited[byleft[a].second] = true;
      int go = -byleft[a].first;
      //cout << go << endl;
      if(go > where)
      {
        tot2 += (long long int)(go-where);
        where = go;
      }
    }
    else
    {
      while(visited[byright[b].second]) b++;
      visited[byright[b].second] = true;
      int go = byright[b].first;
      //cout << go << endl;
      if(go < where)
      {
        tot2 += (long long int)(where-go);
        where = go;
      }
    }
    step = 1-step;
  }
  
  if(where > 0) tot2 += where;
  else tot2 += -where;
  
  cout << max(tot, tot2) << endl;
    
  return 0;
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
P a[1000000];

int main(){
  cin>>n;
  rep(i,n){
    int b;
    cin>>b;
    a[i] = P(b,i);
  }
  sort(a,a+n);
  vector<int> v(n);

  rep(i,n){
    if(i<n/2){
      v[a[i].second] = a[n/2].first;
    }
    else{
      v[a[i].second] = a[n/2-1].first;
    }
  }

  rep(i,n){
    cout<<v[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char dc[5] = "RDLU";
 
bool cangocw(int y, int x, int dir, vector<string> &s){
    if(dir%2==0){
        return s[2*y +1][x +1-(dir/2)] == '0';
    }else{
        return s[2*y +(1-dir/2)*2][x+1] == '0';
    }
}
 
int main(){
    vector<string> s(11);
    s[0] = s[10] = "0000000";
    for(int i=1; i<=9; i++){
        cin >> s[i];
        s[i] = "0" + s[i] + "0";
    }
    int dir=0;
    int x=0, y=0;
    string ans = "";
     
    do{
        if(cangocw(y, x, dir, s)){
            dir = (dir+1)%4;
            continue;
        }
        x += dx[dir];
        y += dy[dir];
        ans += dc[dir];
        dir = (dir+3)%4;
    }while(!(x==0 && y==0 && dir==0));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,t;
    ll ans=INF;
    cin >> n >> t;
    rep(i,n){
        ll m,c;
        cin >> m >> c;
        if(t<c){
            continue;
        }
        else{
            chmin(ans,m);
        }
    }
    if(ans==INF){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }
}

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

const int N = 2e6;

int main() {
	clog << "Ready\n";
	
	string s;
	cin >> s;
	#define sz(s) (int)(s.size())
	int cnt = 0;
	for (int i = 0; i < sz(s); ++ i) {
		cnt += (s[i] != s[sz(s) - i - 1]);
		cerr << s[i] << " " << s[sz(s) - i - 1] << '\n';
	}
	cout << cnt / 2;
	
	cerr << '\n';

	return 0;
}


Measured memory_bytes: 256
def post_from_pre_in(preorder_elements, inorder_elements):
    if preorder_elements:
        global cnt
        root = preorder_elements[0]
        root_index = inorder_elements.index(root)
        preorder_left = preorder_elements[1:root_index+1]
        inorder_left = inorder_elements[:root_index]
        preorder_right = preorder_elements[root_index+1:]
        inorder_right = inorder_elements[root_index+1:]
        post_from_pre_in(preorder_left, inorder_left)
        post_from_pre_in(preorder_right, inorder_right)
        if cnt:
            print(root, end = ' ')
            cnt -= 1
        else:
            print(root)


cnt = int(input()) - 1

a = list(map(int, input().split()))
b = list(map(int, input().split()))

post_from_pre_in(a, b)

Measured memory_bytes: 7716
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
    int n; cin >> n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    vector<ll> v,u;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){
            v.push_back(a[i]-b[i]);
        }
        else{
            u.push_back(b[i]-a[i]);
        }
    }
    if(u.size()==0){
        cout << 0 << endl;
        return 0;
    }
    ll need=0;
    for(int i=0;i<u.size();i++){
        need+=u[i];
    }
    sort(v.begin(),v.end());
    int cnt=0;
    for(int i=v.size()-1;i>=0;i--){
        cnt++;
        need-=v[i];
        if(need<=0)break;
    }
    if(need>0){
        cout << -1 << endl;
        return 0;
    }
    cout << cnt+u.size() << endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<long double> p(n);
  vector<long double> e(n,0);
  vector<long double> s(n,0);
  for(int i=0; i < n; i++)
    cin >> p.at(i);
  
  for(int i=0; i < n; i++)
    e.at(i) = (1+p.at(i))/2; 
  
  s.at(0) = e.at(0);
  for(int i=1; i<n; i++)
    s.at(i) = s.at(i-1) + e.at(i);
  
  long double ans=s.at(k-1);
  for(int i=0; i<n-k; i++)
    ans = max(ans, s.at(i+k)-s.at(i));
  
  cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 9600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	puts((A>C||A+B<C)?"NO":"YES");
}


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

#define int long long


const int N=1e5+5;

vector<int> graph[N];
vector<int> in_degree(N,0); //number of edges to i
vector<bool> visited(N, false);
vector<int> dist(N,0);


void dfs(int a){
    visited[a]=true;
    for(auto b: graph[a]){
        //we visit the node 'b' and if there is no in_edges then we go deep othewise wait for all incoming edges to be processed....
        dist[b]=max(dist[b], dist[a]+1);
        --in_degree[b];
        if(in_degree[b]==0){
            dfs(b);
        }
    }
}

int32_t main(){
    
    
    int n,m;cin>>n>>m;
    
    for(int i=0;i<m;i++){
        int x, y;cin>>x>>y;
        graph[x].push_back(y);
        ++in_degree[y];
    }
    
    for(int i=1;i<=n;i++){
        if(!visited[i] and in_degree[i]==0){
            dfs(i);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans, dist[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 14772
n, y = map(int, input().split())

for a in range(n+1):
    for b in range(n-a+1):
        if a*10000 + b*5000 + (n-a-b)*1000 == y:
            print(str(a)+' '+str(b)+' '+str(n-a-b))
            quit()
print('-1 -1 -1')

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

using namespace std;

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


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

    
    int a,b;
    
    cin >> a >> b;
    
    if(a>b)
        cout << "safe" << endl;
    else
        cout << "unsafe" << endl;
        

    
    return 0;
}


Measured memory_bytes: 3620
/****************************************************************
 * 2 ????????°?????????
 ***************************************************************/
#include <stdio.h>

int main(){
        int  x, y, swap;
        char line[30];

        while(1){

                fgets(line, sizeof(line), stdin );
                sscanf(line, " %d %d", &x, &y );

                if(x > y ){
                        swap = x;
                        x = y;
                        y = swap;
                }else if (x == 0 && y == 0 ) break;

                printf("%d %d\n", x, y );

        }

        return 0;
}

Measured memory_bytes: 612
COLORS = [
  1..399,
  400..799,
  800..1199,
  1200..1599,
  1600..1999,
  2000..2399,
  2400..2799,
  2800..3199
]

_ = gets.to_i
a = gets.split.map(&:to_i)

cs = []
anycolor = 0
a.each do |r|
  if r < 3200
    COLORS.each_with_index do |c, i|
      cs << i if c.include? r
      cs.uniq!
    end
  else
    anycolor += 1
  end
end

min = [cs.size, 1].max
max = cs.size + anycolor
puts "#{min} #{max}"


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int k;
	cin>>k;
	if (k%2==1){
		cout<<(k+1)/2*(k-1)/2;
	}
	else {
		cout<<k*k/4;
	}
	return 0;
}

Measured memory_bytes: 256