akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int n,d[100],sum,i,j;
	scanf("%d",&n);
	sum=n;
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(d[i]==d[j]){
				sum=sum-1;
				d[j]=100+j;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, m = map(int, readline().split())
    h = [int(i) for i in readline().split()]
    g = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, readline().split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)
    cnt = 0
    for i in range(n):
        hi = h[i]
        f = True
        for j in g[i]:
            hj = h[j]
            if hi <= hj:
                f = False
        if f:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  vector <int> arr;
  for (int l = 0; l < sz(s);) {
    int r = l;
    while (r + 1 < sz(s) and s[l] == s[r + 1]) r++;
    arr.push_back(r - l + 1);
    l = r + 1;
  }
  vector <int> ans(sz(s));
  int cur = 0;
  for (int pos = 0; pos < sz(arr); pos += 2) {
    cur = cur + arr[pos];
    int l = cur - 1;
    int r = cur;
    ans[l] += (arr[pos] + 1) / 2;
    ans[r] += arr[pos] / 2;
    ans[r] += (arr[pos + 1] + 1) / 2;
    ans[l] += arr[pos + 1] / 2;
    cur += arr[pos + 1];
  }
  for (int i = 0; i < sz(s); i++) cout << ans[i] << " \n"[i == sz(s) - 1];
  return (0);
}

Measured memory_bytes: 1480
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int s = 0;
        for (int i = 0; i < N.length(); i++) {
            s+=N.charAt(i)-'0';
        }

        System.out.println(Integer.parseInt(N)%s==0?"Yes":"No");
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

ll MAX_V = 1e5 + 5; //頂点数
struct edge {
    ll to;
    ll cost;
};

// <最短距離, 頂点の番号>
using P = pair<ll, ll>;

vector<vector<struct edge>> G(MAX_V); //隣接リスト
vector<ll> d(MAX_V); //各頂点への最短距離
void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(ALL(d), INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); i++) {
            struct edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
  ll i, j;
  ll n;
  cin >> n;
  bool judge = true;
  vector<ll> u(n),v(n),a(n);
  for(i=0;i<n-1;i++){
    cin>>u[i]>>v[i]>>a[i];
    struct edge e ={v[i],a[i]};
    G[u[i]].push_back(e);
    e ={u[i],a[i]};
    G[v[i]].push_back(e);
  }
  dijkstra(1);
  for(i=1;i<=n;i++){
    //cout<<d[i]<<endl;
    //cout<<d[i]<<endl;
    cout<<d[i]%2<<endl;
  }
  return 0;
}

Measured memory_bytes: 11008
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define double long double
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-15;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
struct Point{double x,y;};
double dis(Point a,Point b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
Point tri(Point a, Point b, Point c){
  double a1,a2,b1,b2,c1,c2;
  a1=2*(b.x-a.x);
  b1=2*(b.y-a.y);
  c1=a.x*a.x-b.x*b.x+a.y*a.y-b.y*b.y;
  a2=2*(c.x-a.x);
  b2=2*(c.y-a.y);
  c2=a.x*a.x-c.x*c.x+a.y*a.y-c.y*c.y;
  Point p;
  p.x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  p.y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  return p;
}
int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,k,l,N;
  cin>>N;
  double ans=inf,fir;
  vector<Point> v(N);
  Point x;
  rep(i,N)cin>>v[i].x>>v[i].y;
  sort(all(v),[](auto a,auto b){if(a.x!=b.x){return a.x<b.x;}else{return a.y<b.y;}});
  rep(i,N)For(j,i+1,N){
    double res=dis(v[i],v[j])*0.5;
    fir=res;
    x.x=(v[i].x+v[j].x)/2;
    x.y=(v[i].y+v[j].y)/2;
    rep(k,N){
      if(i==k||j==k)continue;
      if(dis(x,v[k])>fir+eps){
        res=inf;
        break;
      }
    }
    chmin(ans,res);
  }
  rep(i,N)For(j,i+1,N)For(k,j+1,N){
    if((v[i].x-v[k].x)*(v[j].y-v[k].y)!=(v[i].y-v[k].y)*(v[j].x-v[k].x)){
      x=tri(v[i],v[j],v[k]);
      fir=dis(x,v[i]);
      rep(l,N){
        if(dis(x,v[l])>fir+eps){
        fir=inf;
        break;
        }
      }
      chmin(ans,fir);
    }
  }
  print(ans);
  return 0;
}


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

int main()
{
	int n, m, a;
	while (cin >> n >> m >> a && n != 0 && m != 0 && a != 0)
	{
		int line[1000 + 10][100 + 10] = {};
		int h, p, q;
		int max_height = 0;
		for (int i = 0; i < m; i++)
		{
			cin >> h >> p >> q;
			line[h][p] = 1;
			line[h][q] = -1;
			max_height = max(max_height, h);
		}
		int x = a;
		for (int y = max_height; y > 0; y--)
		{
			//cout << "x :" << x << " y :" << y << endl;
			x += line[y][x];
		}
		cout << x << endl;
	}
	return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
int H, W;
cin >> H >> W;
char A[H][W];
REP(y, H)REP(x, W){
    cin >> A[y][x];
}

vector<bool> h_flag(H, false), w_flag(W, false);
REP(y, H)REP(x, W){
    if(A[y][x] == '#'){
        h_flag[y] = true;
        w_flag[x] = true;
    }
}

REP(y, H){
    if(h_flag[y]){
        REP(x, W){
            if(w_flag[x]) cout << A[y][x];
            if(x == W - 1) cout << endl;
        }
    }
}
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;

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

  std::cout << (N+999)/1000*1000-N << std::endl;

  return 0;
}

Measured memory_bytes: 3632
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            long MOD = 1000000007;

            long a10 = 1;
            long a9 = 1;
            long a8 = 1;

            for (int i = 0; i < N; i++)
            {
                a10 *= 10;
                a10 %= MOD;
                a9 *= 9;
                a9 %= MOD;
                a8 *= 8;
                a8 %= MOD;
            }
            long result = a10 - 2 * a9 + a8;
            result %= MOD;
            if (result < 0) result += MOD;
            Console.WriteLine(result);
        }
    }
}


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

using namespace std;

int v[100001], t = 1;

vector <vector <int> > e;

void DFS(int x, int m)
{
	v[x] = m;
	
	for (int i = 0; i < e[x].size(); i++)
		if (!v[e[x][i]])
			DFS(e[x][i], m);
}

int main()
{
	int n, m, a[100001], p[100001], x, y;
	cin >> n >> m;
	e.resize(n+1);
	
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		p[a[i]] = i;
	}
	
	for (int i = 0; i < m; i++)
	{
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	
	for (int i = 1; i <= n; i++)
		if (!v[i])
			DFS(i, t++);
			
	for (int i = 1; i <= n; i++)
	{
		if (i != a[i] && v[i] == v[p[i]])
		{
			int z1 = a[i], z3 = i, z4 = p[i];
			swap(a[i], a[p[i]]);
			p[i] = i;
			p[z1] = z4;
		}
	}
	
	int count = 0;
	
	for (int i = 1; i <= n; i++)
		count += (a[i] == i);
		
	cout << count;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(0);

    int n,x; cin >> n >> x;
    vi a(n); rep(i,n) cin >> a[i];
    cout<<n+(x-SUM(a))/MIN(a)<<endl;

}

Measured memory_bytes: 3612
from fractions import gcd
from functools import reduce
n=int(input())
t=[int(input()) for i in range(n) ]
def lcm_sorce(x,y):
    return (x*y)//gcd(x,y)
def lcm_list(list_name):
    return reduce(lcm_sorce,list_name)
print(lcm_list(t))

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

using namespace std;

typedef long long int LL;

#define lowbit(x) ((x)&-(x))

int x;
int n,m;
vector<pair<pair<int,int>,int> > v;

int main(int argc, char const *argv[]){
    while(~scanf("%d",&x)){
        v.clear();

        n = 1;
        
        int tmp = x;
        while(tmp - lowbit(tmp) > 0) {
            tmp -= lowbit(tmp);
        }

        for(int i=2,tem=1;tem<tmp;++i,tem<<=1){
            // (i-1)->(i) : tem
            v.push_back({{i-1,i},tem});
            v.push_back({{i-1,i},0});
            ++n;
        }

        for(int i=n-2;x > tmp;i--) if(x - (1<<i) >=tmp ){
            x -= 1<<i;
            v.push_back({{i+1,n},x});
        }

        printf("%d %d\n",n,v.size());
        for(auto x: v){
            printf("%d %d %d\n",x.first.first,x.first.second,x.second);
        }

    }
    return 0;
}

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


using intBil7 = unsigned int;
class modBil7 {
private:
	static const intBil7 bil7 = 1000000007;
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); }
};


int main() {

	modBil7 b7;

	string in;
	cin >> in;
	vector<intBil7> pow3(in.size());
	pow3[0] = 1;
	for (int i = 1; i < pow3.size(); i++) {
		pow3[i] = b7.mul(pow3[i - 1], 3);
	}

	intBil7 ans = 1;

	for (int i = 0; i < in.size(); i++) {
		if (in[in.size() - i - 1] == '1') {
			ans = b7.add(pow3[i], b7.mul(ans, 2));
		}
		else {

		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {

	uint H, W, K;
	cin >> H >> W >> K;

	vector<vector<bool>> S(H, vector<bool>(W));
	for(uint i=0; i<H; i++) {
		string l;
		cin >> l;
		for(uint j=0; j<W; j++) {
			S[i][j] = (l[j] == '#');
		}
	}

	vector<vector<uint>> A(H, vector<uint>(W, 0));
	uint aid = 1;
	for(uint i=0; i<H; i++) {
		uint exist = (0 != accumulate(S[i].begin(), S[i].end(), uint(0)));

		if(exist) {
			bool f = false;
			for(uint j=0; j<W; j++) {
				if(S[i][j]) {
					if(f) {
						aid++;
					}
					f = true;
				}
				A[i][j] = aid;
			}
			aid++;
		}
	}

	for(uint i=1; i<H; i++) {
		if(A[i][0] == 0 && A[i-1][0] != 0) {
			copy(A[i-1].begin(), A[i-1].end(), A[i].begin());
		}
	}

	for(int i=H-2; i>=0; i--) {
		if(A[i][0] == 0) {
			copy(A[i+1].begin(), A[i+1].end(), A[i].begin());
		}
	}

	for(uint i=0; i<H; i++) {
			for(uint j=0; j<W; j++) {
				cout << A[i][j] << " ";
			}
			cout << endl;
	}


	return 0;
}


Measured memory_bytes: 1152
import math
N, D = map(int, input().split())
X = [list(map(int,input().split())) for _ in range(N)]
def distance(X,Y):
  ans = 0
  for i,j in zip(X,Y):
    ans += (i - j)**2
  return math.sqrt(ans)

count = 0
for i in range(N):
  for j in range(i+1,N):
    temp = distance(X[i],X[j])
    if temp == temp //1:
      count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[200000],b[200000];
ll  c[200000];

int main() {
	//ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	ll ans=0;
	for(int i=0;i<n;i++){
	    c[i]=a[i]+b[i];
	    ans-=b[i];
	}
	sort(c,c+n);
//cout<<ans<<endl;
	for(int i=0;i<n;i++){
	    if((i+n+1)%2==0) ans+=c[i];   
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3584
N=int(input())
def f(s):
    t=s
    num=0
    ten=1
    L=[0,0,0,1]
    while t!=0:
        a=t%4
        if a==1:
            num+=3*ten
            L[0]=1
        elif a==2:
            num+=5*ten
            L[1]=1
        elif a==3:
            num+=7*ten
            L[2]=1
        elif a==0:
            L[3]=0
        ten*=10
        t=t//4
    return num,L
ans=0
for i in range(1,4**9):
    num,L=f(i)
    if num<=N and L==[1,1,1,1]:
        ans+=1
        #print(num)
print(ans)

Measured memory_bytes: 47196
package main

import (
	"fmt"
)

func main() {
	var a, s, d, f, g string
	fmt.Scan(&a, &s, &d, &f, &g)
	if a == "0" {
		fmt.Println(1)
	}
	if s == "0" {
		fmt.Println(2)
	}
	if d == "0" {
		fmt.Println(3)
	}
	if f == "0" {
		fmt.Println(4)
	}
	if g == "0" {
		fmt.Println(5)
	}

}


Measured memory_bytes: 1820
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
ll longinf=1ll<<60;



ll n,m,s,t;
ll dista[100002],distb[100002];
vector<P> machia[100002],machib[100002];
priority_queue<P,vector<P>,greater<P>> quea,queb;
ll mini[100002];

int main(){
  cin>>n>>m>>s>>t;
  rep1(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    machia[u].push_back(make_pair(a,v));
    machia[v].push_back(make_pair(a,u));
    machib[u].push_back(make_pair(b,v));
    machib[v].push_back(make_pair(b,u));
  }
  rep1(i,n){
    dista[i]=longinf;
    distb[i]=longinf;
  }
  dista[s]=0;
  rep0(i,machia[s].size()){
    quea.push(machia[s][i]);
    dista[machia[s][i].second]=machia[s][i].first;
  }
  while(quea.size()){
    P p=quea.top();
    quea.pop();
    if(p.first>dista[p.second]) continue;
    for(int i=0;i<machia[p.second].size();i++){
      ll c=machia[p.second][i].first;
      ll ne=machia[p.second][i].second;
      if(c+dista[p.second]<dista[ne]){
        dista[ne]=c+dista[p.second];
        quea.push({c,ne});
      }
    }
  }
   distb[t]=0;
  rep0(i,machib[t].size()){
    queb.push(machib[t][i]);
    distb[machib[t][i].second]=machib[t][i].first;
  }
  while(queb.size()){
    P p=queb.top();
    queb.pop();
    if(p.first>distb[p.second]) continue;
    for(int i=0;i<machib[p.second].size();i++){
      ll c=machib[p.second][i].first;
      ll ne=machib[p.second][i].second;
      if(c+distb[p.second]<distb[ne]){
        distb[ne]=c+distb[p.second];
        queb.push({distb[ne],ne});
      }
    }
  }
  ll shozikin=1e15;
  mini[n]=dista[n]+distb[n];
  for(int i=n-1;i>=1;i--){
    mini[i]=min(mini[i+1],dista[i]+distb[i]);
  }
  rep1(i,n){
    printf("%ld\n",shozikin-mini[i]);
  }
    return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int k;
    cin >> k;
    string s;
    for(int i=0; i<k; i++){
        s += "ACL";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int a[5], k;
    bool flag = true;
    REP(i, 5){
        cin >> a[i];
    }
    
    cin >> k;

    REP(i, 5){
        FOR(j, i, 4){
            if (abs(a[i] - a[j]) > k) flag = false;
        }
    }

    if(flag) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 3592
@S=map$|++,@p=@i=0..1e5;$\-=<>;sub f{my$U=pop;$p[$U]=$U-$p[$U]?f($p[$U]):$U}/ />${*a=-$'}||($v=f$`)-(f$a)&&($S[$p[$v]=f$a]+=$S[$v]),$a=$`for<>;$\+=$S[f${-$_}]for@i;print

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

int main(){
  int n;
  cin >> n;
  while(n--){
    int out=0, base = 0, score = 0;

    while(out<3){
      string s;
      cin >> s;
      if(s == "OUT"){
	out++;
      }else if(s == "HIT"){
	base++;
	if(base == 4){
	  base--;
	  score++;
	}
      }else{
	score += base + 1;
	base = 0;
      }
    }

    cout << score << endl;
  }
}

Measured memory_bytes: 1212
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int K = Integer.parseInt(tokens[0]);
		tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		boolean enable = false;
		for (int i = A; i <= B; ++i) {
			if (i % K == 0) {
				enable = true;
				break;
			}
		}
		System.out.println((enable ? "OK" : "NG"));

	}

	void calc() {
	}

	void showResult() {
	}

}

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

int cnt[2][105] = {0};
int n, ans = 0;

int main() {
  int i, j;
  cin >> n;
  for(i = 0; i < 2; ++i)
    for(j = 1; j <= n; ++j) {
      cin >> cnt[i][j];
      cnt[i][j] += cnt[i][j - 1];
    }
  for(i = 1; i <= n; ++i)
    ans = max(ans, cnt[0][i] + cnt[1][n] - cnt[1][i - 1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//package Contest091;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
            if(a+b >= c)
                out.println("Yes");
            else
                out.println("No");

        out.flush();
    }
}


Measured memory_bytes: 21844
#include<iostream>
#define ll long long int
using namespace std;
ll n,cap,tot = 0;
ll w[110],v[110];
ll memo[1000005][110];

ll knapsack(){
	for(ll i  = 1;i<=tot;i++) for(ll j = 0;j<=n;j++) memo[i][j] = 1e15;
	for(ll  y = 1;y<=tot;y++){
		for(ll x = 1;x<=n;x++){
			if(y>=v[x-1]){
				memo[y][x] = min(memo[y][x-1], memo[y-v[x-1]][x-1] + w[x-1]);
			}else{
				memo[y][x] = memo[y][x-1];
			}
		}
	}
	ll ans = 0;int kluar = 0;
	for(ll  y = 1;y<=tot;y++){
//		cout<<y<<">";
		for(ll x = 1;x<=n;x++){
			if(memo[y][x]<=cap) ans = max(ans,y);
//			if(memo[y][x] == 1e15)cout<<"- ";
//			else cout<<memo[y][x]<<" ";
		}//cout<<"\n";
	}
	return ans;
}

int main(){
	cin>>n>>cap;
	for(ll i = 0;i<n;i++){
		cin>>w[i]>>v[i];
		tot+=v[i];
	}
//	cout<<tot<<"\n";
	cout<<knapsack()<<"\n";
	return 0;
}

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
/*再帰じゃ無理なのかよ
int64_t Lucas(int64_t N){
 if(N == 0){
  return 2; 
 }else if(N == 1){
  return 1; 
 }else{
  return Lucas(N - 1) + Lucas(N -2); 
 }
}
*/
//N = 89の時は実行時間エラー
int main(){
  int N;
  cin >> N;
  
  vector<long long int> lucas(87);
  
  lucas[0] = 2;
  lucas[1] = 1;
  
  for(int i = 2; i < lucas.size();i++){
   lucas[i] = lucas[i - 1] + lucas[i - 2];
  }
  
  
  cout << lucas[N] << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define maxn 1000005
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pp;
const long long inf = 2e18;
int n,f[maxn],sum[maxn];
main(){
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen(".inp","r",stdin); freopen(".out","w",stdout);
	//freopen("inp.txt","r",stdin);
	cin>>n; int i,j,k;
	f[n]=n; sum[n+1]=0; sum[n+2]=0; sum[n]=n;
	for (i=n-1;i>=1;i--){
		f[i]=f[i+1];
		f[i]+=sum[i+3];
		f[i]+=(n-1)*(n-1);
		j=n-(i+3)+1; if (j<0) j=0; j=(n-1-j);
		f[i]+=j; f[i]%=mod;
		sum[i]=sum[i+1]+f[i]; sum[i]%=mod;
	}
	cout<<f[1];
	
}

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


int main (){
        unsigned long long N,M;
        unsigned long long count =0;
        scanf("%llu%llu", &N, &M);

        if (N>M) {
              unsigned long long tmp = N;
              N = M;
              M = tmp;
        }

        if (N<=3) {
              if (N ==2) {
                      count =0;
              }else{
                      if (M==1 || M==3) {
                            count =1;
                      }else if (M==2) {
                            count =0;
                      }else{
                            count = M*N - 2*N;
                      }
              }
        }else{
          count =(N-2)*(M-2);
        }

        printf("%llu\n",count );
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,A,B;
    cin>>n>>A>>B;
    vector<vector<vector<int>>>dp(n+1,vector<vector<int>>(401,vector<int>(401,10000)));
    dp[0][0][0]=0;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
        for(int j=0;j<=390;j++){
            for(int k=0;k<=390;k++){
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
            }
        }
    }
    int m=10000;
    for(int i=1;max(A,B)*i<=400;i++)m=min(m,dp[n][A*i][B*i]);
    if(m<10000)cout<<m<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

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

const int Mod = 1e9+7;

int solve(int n, vector<int> cnt){
  if (n%2 && !cnt[0]) return 0;
  int res = 1;
  for (int i = 1; i <= n-1; ++i) {
    if ((n%2== 1 && i%2 == 1) || (n%2 == 0 && i%2 == 0)) continue;
    res = res * 2 % Mod;
    if (cnt[i] != 2) return 0;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n, 0);
  rep(i, n) {
    int a;
    cin >> a;
    ++cnt[a];
  }
  cout << solve(n, cnt) << endl;
  return 0;
}

Measured memory_bytes: 1024
def isEvenstring(s):
	l = len(s)
	center = int(l/2)
	if l%2 == 0:
		return s[:center]==s[center:]

	else:
		return False




if __name__ == '__main__':
	string = input()
	l = len(string)
	for i in range(1, l):
		if isEvenstring(string[:-i]):
			print (l - i)
			break


Measured memory_bytes: 2940
n = int(input())
a_list = list(map(int, input().split()))
flg = False
for a in a_list:
  if a % 2 == 0:
    if a % 3 > 0 and a % 5 > 0:
      flg = True
      break
  else:
    continue
if flg:
  print("DENIED")
else:
  print("APPROVED")

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

int main(){
    long long n, m;
    cin >> n >> m;
    if (n == 2 || m == 2) cout << 0;
    else if (n == 1 && m > 1) cout << m - 2;
    else if (m == 1 && n > 1) cout << n - 2;
    else cout << (n - 2)*(m - 2);
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            String a = String.valueOf(i);
            if (i % 3 == 0 || a.contains("3")) {
                System.out.print(" " + i);
            }
        }
        System.out.println("");
    }
}



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

for i in range(10000):
    temp = i * (i + 1) // 2
    if temp > N:
        break

temp2 = N - ((i - 1) * i // 2)
del_num = i - temp2

for j in range(1, i + 1):
    if j != del_num:
        print(j)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

    vector<int> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }

    int sum = 0;
    int distance;
    for (int i = 0; i < N; i++)
    {
        distance = min(abs(x[i] - 0), abs(K - x[i]));
        sum += distance * 2;
    }
    cout << sum << endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdint.h>
using namespace std;

int main() {
	int h, w;
	char s[55][55];
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) cin >> s[i][j];
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (s[i][j] == '.') {
				int count = 0;
				for (int k = -1; k < 2; k++) {
					for (int l = -1; l < 2; l++) {
						if (s[i + k][j + l] == '#') count++;
					}
				}
				s[i][j] = '0' + count;
			}
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) cout << s[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 256
//Heaplax
#include<bits/stdc++.h>
#define N 100005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,sg[N];
int cnt,head[N],nxt[N+N],to[N+N];
void dfs(int u,int fa=0)
{
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i]) != fa)
		{
			dfs(v,u);
			sg[u]^=(sg[v]+1);
		}
}
int main()
{
	re(n);
	for(int i=1,u,v;i<n;++i)
	{
		re(u),re(v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1);
	puts(sg[1]?"Alice":"Bob");
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	int N,A[55],x=1;
	scanf ("%d",&N);
	for (int i=1;i<=N;i++){
		scanf ("%d",&A[i]);
		if (abs(A[x]) < abs(A[i])) x = i;
	}
	
	vector<pair<int, int> > op;
	for (int i=1;i<=N;i++) if (i != x){
		op.push_back({x,i});
		A[i] += A[x];
	}

	if (A[1] >= 0) for (int i=2;i<=N;i++) op.push_back({i-1,i});
	else for (int i=N;i>=2;i--) op.push_back({i,i-1});

	printf ("%d\n",op.size());
	for (auto &p : op) printf ("%d %d\n",p.first,p.second);

	return 0;
}

Measured memory_bytes: 256
// Problem : D. Omkar and Bed Wars
// Contest : Codeforces - Codeforces Global Round 10
// URL : https://codeforces.com/contest/1392/problem/D
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#include <random>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 1005;
const int MAXM = 20500;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template <typename T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}

int sx,sy,ex,ey;
int h,w;
char mp[MAXN][MAXN];
// int vis[MAXN][MAXN];
int walk[MAXN][MAXN];
int fly[MAXN][MAXN];
int px[5]{0,1,0,-1,0};
int py[5]{0,0,1,0,-1};
int ppx[21]{0,-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
int ppy[21]{0,2,2,2,2,2,1,1,1,1,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-2};
struct Node{
	int x;
	int y;
	int cnt;	// 1 移动转移 0 为魔法转移 cnt 为魔法转移的次数
	Node (int x = 0,int y = 0,int cnt = 0)
		: x(x),y(y),cnt(cnt){ }
	bool operator<(const Node& x)const 
	{//移动转移优先于魔法转移
		return cnt > x.cnt;
	}
};
inline bool check(int x,int y)
{
	return  (1 <= x && x <= h && 1<=y && y<= w);
} 
int bfs()
{
	priority_queue<Node> q;
	q.push(Node(sx,sy,0));
	walk[sx][sy] = 1;
	while (!q.empty())
	{
		Node cur = q.top();
		q.pop();
		//debug(cur.x,cur.y,cur.cnt);
		if (cur.x== ex && cur.y == ey)
		{
			return cur.cnt;	
		}
		rep (i,1,4)
		{//移动转移
			int xx = cur.x + px[i],yy = cur.y + py[i];
			if (check(xx,yy) && !walk[xx][yy] && mp[xx][yy]!='#')
			{
				walk[xx][yy] = 1;
				q.push(Node(xx,yy,cur.cnt));
			}
		}
		rep (i,1,20)
		{//魔法转移
			int xx = cur.x + ppx[i],yy = cur.y + ppy[i];
			if (check(xx,yy) && !walk[xx][yy] && !fly[xx][yy] && mp[xx][yy]!='#')
			{
				//debug(xx,yy);
				fly[xx][yy] = 1;
				q.push(Node(xx,yy,cur.cnt + 1));
			}
		}
	}
	return -1;
}

int main()
{//closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/input.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	
	cin>>h>>w;
	cin>>sx>>sy>>ex>>ey;
	rep (i,1,h)
		rep (j,1,w)
			cin>>mp[i][j];
	cout<<bfs()<<endl;

	//cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

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

int main() {
    int a, b, n;
    cin >> a >> b >> n;

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;

        if (x < b && a < y) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3096
// D - 連結

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

class DisjointSet {
public:
	vector<int> rank;
	vector<int> parent;

	DisjointSet() {}

	// 0, 1, ... size-1 をそれぞれ唯一の要素とする
	// size個の互いに素な集合を作成
	DisjointSet(int size) {
		rank.resize(size, 0);
		parent.resize(size, 0);
		for (int i=0; i<size; i++) {
			makeSet(i);
		}
	}

	// 要素がXただ一つである新しい集合を作る
	void makeSet(int x) {
		parent[x] = x;
		rank[x] = 0;
	}

	// xとyが同じ集合に属しているかを判定する
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	// 指定された2つの要素x, yを合併する
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	// 低い方の木を高い方の木に合併
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			parent[y] = x;
		} else {
			parent[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	// 要素xが属する集合の代表の要素を求める
	int findSet(int x) {
		if (x != parent[x]) {
			parent[x] = findSet(parent[x]);
		}
		return parent[x];
	}
};

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

	DisjointSet set1 = DisjointSet(N); // road
	DisjointSet set2 = DisjointSet(N); // train

	int p, q;
	for (int i=0; i<K; i++) {
		cin >> p >> q;
		set1.unite(p-1, q-1); // 0開始に
	}

	int r, s;
	for (int i=0; i<L; i++) {
		cin >> r >> s;
		set2.unite(r-1, s-1); // 0開始に
	}

	// 代表値のペアでカウント
	map<pair<int, int>, int> counter;
	for (int i=0; i<N; i++) {
		counter[make_pair(set1.findSet(i), set2.findSet(i))]++;
	}

	// 結果を出力
	for (int i=0; i<N; i++) {
		if (i > 0) cout << " ";
		cout << counter[make_pair(set1.findSet(i), set2.findSet(i))];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 15104
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    vector<lpair> ans;
    ll idx1 = 0, idx2 = 0;
    if((M-1) % 2 == 0){
        idx2 = 2 + M-1;
    }else{
        idx2 = 2 + M-2;
    }
    rrep(i,M-1,0){
        if(i % 2 == 0){
            ans.push_back({idx1, idx1 + i + 1});
            idx1++;
        }else{
            ans.push_back({idx2, idx2 + i + 1});
            idx2++;
        }
    }
    rep(i,0,M){
        print(ans[i].first + 1, ans[i].second + 1);
    }

}

Measured memory_bytes: 5328
use proconio::input;

fn main() {
    input! {
        k: i32,
        a: i32,
        b: i32,
    }

    if a / k < b / k {
        println!("OK");
    } else {
        if a % k == 0 || b % k == 0 {
            println!("OK");
        } else {
            println!("NG");
        }
    }
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string S;
    cin >> S;
    int sum = 0;
    int N = S.size();
    vector<int> a(S.size(),0), b(S.size(),0);
    rep(i,S.size()){
        if(S[i] == 'R'){
            sum++;
        }else{
            //cout << sum << endl;
            a[i] += sum/2.0;
            a[i-1] += int((sum/2.0) + 0.6);
            sum = 0;
        }
    }
    sum = 0;
    rep(i,S.size()){
        if(S[N-1-i] == 'L'){
            sum++;
        }else{
            b[N-1-i] += sum/2;
            b[N-i] += int((sum/2.0) + 0.6);
            sum = 0;
        }
    }
    rep(i,S.size()){
        cout << a[i]+b[i] << " ";
    }
    cout << endl;
    /*
        rep(i,S.size()){
        cout << a[i] << " ";
    }
    cout << endl;
        rep(i,S.size()){
        cout << b[i] << " ";
    }
    cout << endl;
    */
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
 
using namespace std;
 
typedef long long ll;
 
const ll INF = 1e9, MOD = 1e9 + 7, MOD2 = 1e6 + 3;

vector <int> g[1000000], cycle;

int p[1000000], n, cl[1000000], u[1000000], in[1000000];

int d[1000000], d_sec[1000000];

int dfs (int x, int p) {
	if (g[x].size() == 0 || d[x]) return d[x];

	vector <int> v;
	for (int to : g[x])
		if (to != p && !in[to])
			v.push_back(dfs (to, x));

	sort (v.begin(), v.end());
	v.push_back(INF);

	if (v[0] || v.empty()) d[x] = 0;
	else {
		for (int i = 0; i < v.size(); i++)
			if (v[i] + 1 != v[i+1]) {
				if (v[i] == v[i+1]) continue;
				d[x] = v[i] + 1;
				break;
			}
	}

	return d[x];
}

int main () {
	cin >> n;

	for (int i = 0; i < n; i++) {
		scanf ("%d", &p[i]);
		p[i]--;

		g[p[i]].push_back(i);
	}

	int x = 0;

	while (!cl[p[x]]) {
		cl[p[x]] = 1;
		x = p[x];
	}
	
	cycle.push_back(p[x]);
	in[p[x]] = 1;

	int k = p[x];

	while (k != x) {
		k = p[k];
		cycle.push_back(k);
		in[k] = 1;
	}

	for (int i = 0; i < n; i++)
		if (in[i]) dfs(i, -1);

	for (int i = 0; i < n; i++)
		if (in[i]) {
			vector <int> v;

			for (int to : g[i]) 
				if (!in[to]) {
					v.push_back(d[to]);
				}

			v.push_back(d[i]);
			v.push_back(INF);

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

			if (v[0] || v.empty()) d_sec[i] = 0;
			else {
				for (int j = 0; j < v.size() - 1; j++)
					if (v[j] + 1 != v[j+1])	{
						if (v[j] == v[j+1]) continue;
						d_sec[i] = v[j] + 1;
						break;
					}
			}
		}
	
	bool b1 = true, b2 = true;

	vector <int> t(cycle.size ());

	t[0] = d[cycle[0]];
	for (int i = 1; i < cycle.size(); i++) {
		if (t[i-1] == d[cycle[i]]) {
			t[i] = d_sec[cycle[i]];
		}
		else {
			t[i] = d[cycle[i]];
		}

		if (t[i-1] == t[i]) {
			b1 = false;
			break;
		}
	}


	if (t[0] == t.back()) b1 = false;

	t[0] = d_sec[cycle[0]];
	for (int i = 1; i < cycle.size(); i++) {
		if (t[i-1] == d[cycle[i]]) {
			t[i] = d_sec[cycle[i]];
		}
		else {
			t[i] = d[cycle[i]];
		}

		if (t[i-1] == t[i]) {
			b2 = false;
			break;
		}
	}

	if (t.back() != d[cycle[0]]) b2 = false;

	if (!b1 && !b2) cout << "IMPOSSIBLE";
	else cout << "POSSIBLE";
	return 0;
}

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

int main ()
{
    int N;
    cin >> N;
    int W[N];
    int sum = 0;
    for (int i=0; i < N; i++)
    {
        cin >> W[i];
        sum += W[i];
    }

    int dif, ans = 10000;

    for (int i=0;i<N;i++)
    {   
        dif = 0;
        for (int j=0;j<N;j++)
        {
            if (j<i) dif += W[j];
            else dif -= W[j];
        }
        ans = min(ans, max(dif, -dif));
    }
    cout << ans << endl;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

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<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll N,x;
    cin >> N >> x;

    vector<ll> a(N);

    REP(i,N) cin >> a[i];

    auto minset = make_vec<ll>(N,N);
    fill_v(minset,1e9+7);

    for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
        int k = i - j;
        if(k<0) k += N;

        if(j==0) minset[i][j] = a[i];
        else minset[i][j] = min(minset[i][j-1],a[k]);
    }

/*
    REP(i,N) {
        REP(j,N) cout << minset[i][j] << " ";
        cout << endl;
    }
*/

    ll ans = 1LL << 50;
    REP(k,N) {
        ll ans_tmp = k*x;
        REP(i,N) ans_tmp += minset[i][k];
        chmin(ans,ans_tmp);
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 31616
num = gets.to_i

num.times do
  a, b, c = gets.split.map(&:to_i)

  if (a**2 + b**2 == c**2 or
      a**2 + c**2 == b**2 or
      b**2 + c**2 == a**2)
    puts 'YES'
  else
    puts 'NO'
  end
end

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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> can(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        if(a==1){
            can.at(b-1)++;
        }else if(b==n){
            can.at(a-1)++;
        }
    }
    rep(i,n){
        if(can[i]==2){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; 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 ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=998244353;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1,t2,a1,a2,b1,b2;cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll u=a1-b1,v=a2-b2;
    if(u<0){
        u=-u,v=-v;
    }
    ll p=u*t1,q=u*t1+v*t2;
    if(q==0){
        cout << "infinity" << endl;
        return 0;
    }
    if(q>0){
        cout << 0 << endl;
        return 0;
    }
    cout << abs(p)/abs(q)*2+(abs(p)%abs(q)==0?0:1) << endl;
}

Measured memory_bytes: 3624
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int n,k; cin >> n >> k;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    vector<ll> amaxh(n+1);
    amaxh[0] = 0LL;
    rep(i,n) amaxh[i+1] = max(a[i], amaxh[i]);
    ll ans = 1e18;
    for(int bit = 0; bit < (1 << n); ++bit){
        if(__builtin_popcount(bit) != k) continue;

        ll nowh = 0LL, tmp = 0LL;
        rep(i,n){
            if(bit & (1 << i)){
                nowh = max(nowh, amaxh[i]);
                if(nowh >= a[i]){
                    tmp += nowh - a[i] + 1;
                    nowh++;
                }else nowh = a[i];
            }
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int sum=0;
	string s;
	string t="CODEFESTIVAL2016";
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  cout<<setprecision(10)<<pow((int)sqrt(n),2)<<endl;
  return 0;
}


Measured memory_bytes: 256