akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    ll n, k;
    cin >> n >> k;
    ll x[n];
    rep(i,n) cin >> x[i];

    ll ans = pow(10, 18);
    for (int i = 0; i + k - 1 <= n - 1; ++i) {
        ll l = x[i];
        ll r = x[i+k-1];
        ll tmp = min(max(l, -l), max(r, -r)) + max(l-r, r-l);
        ans = min(ans, tmp);
    }

    out(ans);

    return 0;
}








Measured memory_bytes: 1024
from collections import deque
h,w = map(int,input().split())
m = ["#"*(w+2)]+["#"+input()+"#" for i in range(h)]+["#"*(w+2)]
temp = [[-1]*(w+2) for i in range(h+2)]
opt = [(1,0),(0,1),(-1,0),(0,-1)]
dq = deque()
ans = 0
for i in range(1,h+1):
    for j in range(1,w+1):
        if m[i][j] == "#":
            dq.append((i,j))
            temp[i][j] = 0
while dq:
    y,x = dq.popleft()
    for i in opt:
        y1 = y+i[0]
        x1 = x+i[1]
        if m[y1][x1] == "." and temp[y1][x1] == -1:
            temp[y1][x1] = temp[y][x]+1
            ans = max(ans,temp[y1][x1])
            dq.append((y1,x1))
print(ans)

Measured memory_bytes: 86492
#include <string.h>

int map[92][92];
int max;
int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};

void solve(int i, int j, int count){
  int k,ni,nj;

  if(count>max) max=count;
  for(k=0;k<4;k++){
    ni=i+dir[k][0];
    nj=j+dir[k][1];
    if(map[ni][nj]){
      map[i][j] = 0;
      solve(ni,nj,count+1);
      map[i][j] = 1;
    }
  }
}

int main(void){
  int i,j,w,h;

  while(1){
    scanf("%d%d",&w,&h);
    if(!w && !h) break;

    max = 0;
    memset(map,0,sizeof(map));
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        scanf("%d",&map[i][j]);
      }
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        if(map[i][j]) solve(i,j,1);
      }
    }
    printf("%d\n",max);
  }

  return 0;
}

Measured memory_bytes: 0
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()
n = int(input())
S = set(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
for i in T:
    if i in S:
        ans += 1
print(ans)




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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, m, A[maxn], a[maxn], b[maxn];
vector<int> odd;

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

	cin >> n >> m;
	int cnt = 0;
	for (int i = 0; i < m; i++)
	{
		cin >> A[i];
		if (A[i] & 1)
		{
			cnt++;
			odd.pb(A[i]);
		}
	}
	if (cnt > 2)
	{
		cout << "Impossible" << endl;
		return 0;
	}

	if (cnt)
	{
		a[0] = odd[0];
		if (cnt == 2)
			a[m - 1] = odd[1];
		int ind = 1;
		for (int i = 0; i < m; i++)
			if (A[i] % 2 == 0)
				a[ind++] = A[i];
	}
	else
		swap(a, A);
	
	int ind = 0;
	if (n == 1)
		b[ind++] = n;
	else if (m == 1)
	{
		ind = 2;
		b[0] = n - 1;
		b[1] = 1;
	}
	else
	{
		b[ind++] = a[0] + 1;
		for (int i = 1; i < m - 1; i++)
			b[ind++] = a[i];
		if (a[m - 1] > 1)
			b[ind++] = a[m - 1] - 1;
	}

	for (int i = 0; i < m; i++)
		cout << a[i] << ' ';
	cout << endl << ind << endl;
	for (int i = 0; i < ind; i++)
		cout << b[i] << ' ';
	cout << endl;
}



Measured memory_bytes: 1024
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Maximal Value
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int bs[MAX_N + 1], as[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++) scanf("%d", bs + i);
  bs[0] = bs[n] = INF;

  int sum = 0;
  for (int i = 0; i < n; i++) sum += min(bs[i], bs[i + 1]);

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next()); 
    int K = Integer.parseInt(sc.next()); 
    int Q = Integer.parseInt(sc.next()); 
    int[] A = new int[Q]; 
    int[] B = new int[N]; 
    for (int i=0; i < N; i++) {
        B[i] = K - Q;
    }
    for (int i=0; i < Q; i++) {
        B[Integer.parseInt(sc.next()) -1]++; 
    }

    for (int i=0; i < N; i++) {
        if(B[i]>0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
  }
}



Measured memory_bytes: 66612
#include <bits/stdc++.h>
using namespace std;
#define N 2010
#define ll long long
#define int long long
const ll mod=1e9+7;

struct edge {
	int u,v,w;
}e[N];
bool cmp(edge x,edge y) {return x.w<y.w;}

int n,m,x,tmp;
int fa[N];

int find(int x) {return x==fa[x] ? x : fa[x]=find(fa[x]);}

int kruskal(int now) {
	int res=0;
	for (int i=1;i<=n;i++) fa[i]=i;
	if (now) {res+=e[now].w; fa[e[now].u]=e[now].v;}
	for (int i=1;i<=m;i++)
	{
		int fx=find(e[i].u),fy=find(e[i].v);
		if (fx==fy) continue;
		res+=e[i].w; fa[fx]=fy;
	}
	return res;
}

inline ll power(ll x,ll y) {
	ll res=1;
	for (;y;y>>=1,x=x*x%mod)
		if (y&1) res=res*x%mod;
	return res;
}

int val,cnt1,cnt2;
ll ans;

signed main()
{
	scanf("%lld%lld%lld",&n,&m,&x);
	for (int i=1;i<=m;i++) scanf("%lld%lld%lld",&e[i].u,&e[i].v,&e[i].w);
	sort(e+1,e+m+1,cmp);
	tmp=kruskal(0);
	//printf("%lld\n",tmp);
	if (tmp>x) {puts("0"); return 0;}
	if (tmp==x)
	{
		for (int i=1;i<=m;i++)
		{
			val=kruskal(i);
			if (val==x) cnt1++;
			else cnt2++;
		}
		//printf("%lld %lld\n",cnt1,cnt2);
		ans=((power(2,cnt1)-2)*power(2,cnt2)%mod+mod)%mod;
	} else
	{
		for (int i=1;i<=m;i++)
		{
			val=kruskal(i);
			if (val==x) cnt1++;
			else if (val>x) cnt2++;
		}
		//printf("%lld %lld\n",cnt1,cnt2);
		ans=(2*(power(2,cnt1)-1)%mod*power(2,cnt2)%mod+mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
from numba import njit
from numba import prange

import re

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

def solver(N,K,Pn):
    Pn.sort()

    s = 0
    for i,p in enumerate(Pn):
        s = s + p
        if i == K - 1:
            break

    print(s)

def main():
    N,K = LI()
    Pn = LI()
    #print(N,K,Pn)
    solver(N,K,Pn)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91852
#include <stdio.h>
#include <stdlib.h>
#define N 10000

int main(){
  int t,i,j,C[N+1];
  unsigned short *A,*B;

  scanf("%d",&t);

  A = malloc(sizeof(short)*t+1);
  B = malloc(sizeof(short)*t+1);

 for(i=0 ; i<=N ; i++){
    C[i]=0;
  }

  for(i=1 ; i<=t ; i++){
    scanf("%d",&A[i]); 
    C[A[i]]++;
  } 

  for(i=1 ; i<=N ; i++){
    C[i] = C[i] + C[i-1];
  }

  for (j=1 ; j<=t ; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1 ; i<t ; i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[t]);
 
  return 0;
}

  
   

Measured memory_bytes: 8456
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    s = input()
    len_s = len(s)
    for i in range(2, len_s-1, 2):
        len_s -= 2
        left = s[:len_s//2]
        right = s[len_s//2:len_s]
        if left == right:
            break
    print(len_s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9064
import bisect

a,b,q = map(int, input().split())
s = [-(10 ** 21)] + [int(input()) for i in range(a)] + [10 ** 21]
t = [-(10 ** 21)] + [int(input()) for i in range(b)] + [10 ** 21]
x = [int(input()) for i in range(q)]

for i in x:
  bs = bisect.bisect_left(s,i)
  bt = bisect.bisect_left(t,i)
  p_s,p_t = i-s[bs-1], i-t[bt-1]
  n_s,n_t = s[bs]-i, t[bt]-i
  a = max(p_s, p_t)
  b = max(n_s, n_t)
  c = n_t + p_s + min(p_s,n_t)
  d = n_s + p_t + min(p_t,n_s)
  print(min(a,b,c,d))

Measured memory_bytes: 16144
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
vector<int> divisor(int n) {
    vector<int> ret;

    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) ret.push_back(n / i);
        }
    }

    return move(ret);
}

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

signed main() {
    int A, B, K;
    cin >> A >> B >> K;
    int G = gcd(A, B);
    vector<int> g = divisor(G);
    sort(g.begin(), g.end(), greater<>());
    cout << g[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll R,C,k; cin>>R>>C>>k;
    vector<vector<ll>> m(R,vector<ll>(C,-1));
    rep(i,k){
        ll r,c,v; cin>>r>>c>>v;
        r--; c--;
        m[r][c]=v;
    }
    vector<vector<vector<ll>>> dp(4,vector<vector<ll>>(R+1,vector<ll>(C,-1)));
    dp[0][0][0]=0;
    rep(i,R)rep(j,C)for(int K=3;K>=0;K--){
        if(dp[K][i][j]==-1) continue;
        if(j!=C-1) dp[K][i][j+1]=max(dp[K][i][j+1],dp[K][i][j]);
        dp[0][i+1][j]=max(dp[0][i+1][j],dp[K][i][j]);
        if(m[i][j]!=-1){
            if(K<3 && dp[K+1][i][j]<dp[K][i][j]+m[i][j]){
                dp[K+1][i][j]=dp[K][i][j]+m[i][j];
                if(j!=C-1) dp[K+1][i][j+1]=max(dp[K+1][i][j+1],dp[K+1][i][j]);
                dp[0][i+1][j]=max(dp[0][i+1][j],dp[K+1][i][j]);
            }
        }
    }
    ll ans=0;
    rep(i,4)rep(j,C) ans=max(ans,dp[i][R][j]);
    cout<<ans<<endl;
}

Measured memory_bytes: 425692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n,ans=0;cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll r=0,sum=0;
    rep(l,n){
        while(r<n&&sum+v[r]==(sum^v[r])){
            sum+=v[r];
            r++;
        }
        ans+=r-l;
        if(r==l)r++;
        else sum-=v[l];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1920
import itertools

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

count=0
y=[]

for x in itertools.combinations(a, 3):
  if (x[0]==x[1] or x[0]==x[2] or x[1]==x[2]):
    pass
  else:
    if(x[0]+x[1]>x[2] and x[0]+x[2]>x[1] and x[1]+x[2]>x[0]):
      count+=1
    else:
      pass

print(count)

Measured memory_bytes: 73192
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  long a,b,c,d;
  C4(a,b,c,d);
  cout << max(a*b,c*d) << endl;
  ret 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)  {
        //input
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int broken = 0;
        int idx = 1;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (num != idx) {
                broken++;
            } else {
                idx++;
            }
        }
        if ((n - broken) == idx - 1 && idx > 1) {
            System.out.println(broken);
        } else {
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 65052
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
//#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
//#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;


void P(auto a){
    REP(i,a.size()){
        if(i){
            cout << " ";
        }
        cout << a[i];
    }
    cout << "\n";
}


signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int q;
    cin >> n >> q;
    vector<vector<int>> a(n);
    REP(i,q){
        int tmp;
        cin >> tmp;
        switch (tmp)
        {
        case 0:
            int t,x;
            cin >> t >> x;
            a[t].push_back(x);
            break;
        case 1:
            cin >> t;
            P(a[t]);
            break;
        default:
            cin >> t;
            a[t].clear();
            break;
        }
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 6984
num_list = [int(i) for i in input().split()]

if num_list[3] <= num_list[0]:
    print(1*num_list[3])
elif num_list[3] > num_list[0] and num_list[3] <= num_list[0] + num_list[1]:
    print(1*num_list[0])
else:
    print(1*num_list[0]+(-1*(num_list[3] - (num_list[0]+num_list[1]))))

Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(),x.end()
#define lb lower_bound
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
int main()
{
    fast;
    ll n;
    cin>>n;
    ll a[n+1];
    vector<ll> g,v;
    g.pb(0);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        g.pb(a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        ll t1;
        bool f=0;
        for(int i=1;i<g.size();i++)
        {
            if(i==g[i])
            {
                f=1;
                t1=g[i];
            }
        }
        if(f==0)
        {
            cout<<"-1";
            return 0;
        }
        v.pb(t1);
        g.erase(g.begin()+t1);
    }
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    cin >> n;

    vector<Int> ans(n);
    for (Int i = 1; i < n; i++) {
        Int a;
        cin >> a;
        a--;
        ans[a]++;
    }

    for (auto e : ans) {
        cout << e << endl;
    }

    return 0;
}


Measured memory_bytes: 4788
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int MOD = 1_000_000_007;
		char[] T = sc.next().toCharArray();
		long[] dp = new long[5];
		dp[1] = 1;
		for(int i = 0; i < T.length; i++) {
			if(T[i] == '?') {
				for(int j = 4; j >= 1; j--)
					dp[j] = (3 * dp[j] + dp[j-1]) % MOD;
			}
			else
				dp[T[i]-'A'+2] = dp[T[i]-'A'+2] + dp[T[i]-'A'+1];
		}
		System.out.println(dp[4] % MOD);
	}
 
}

Measured memory_bytes: 27848
#include<iostream>
#include<string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
 
int main(){
    string S,T;
    int count = 0,n;
    cin >> S >> T;
    n = S.length();
    rep(i,n){
        if(S[i] != T[i])count++;
    }

    cout << count;
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld n;
  cin >> n;
  cout << (10000 - n) % 1000 << "\n";
}

Measured memory_bytes: 3636
a,b,c = map(int,input().split())
ans = 0
while a%2==b%2==c%2==0:
    a,b,c = (b+c)//2, (a+c)//2, (a+b)//2
    ans += 1
    if ans >100:
        ans = -1
        break
print(ans)

Measured memory_bytes: 38256
#include <stdio.h>

struct _six {
    int f1;
    int f2;
    int f3;
    int f4;
    int f5;
    int f6;
} six;


int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    scanf("%d", &six.f1);
    scanf("%d", &six.f2);
    scanf("%d", &six.f3);
    scanf("%d", &six.f4);
    scanf("%d", &six.f5);
    scanf("%d", &six.f6);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        if(a == six.f1) {
            if(b == six.f2) {
                printf("%d\n", six.f3);
            } else if (b == six.f3) {
                printf("%d\n", six.f5);
            } else if (b == six.f5) {
                printf("%d\n", six.f4);
            } else {
                printf("%d\n", six.f2);
            }
        }else if(a == six.f2) {
            if(b == six.f6) {
                printf("%d\n", six.f3);
            } else if (b == six.f3) {
                printf("%d\n", six.f1);
            } else if (b == six.f1) {
                printf("%d\n", six.f4);
            } else {
                printf("%d\n", six.f6);
            }
        } else if (a == six.f3) {
            if(b == six.f2) {
                printf("%d\n", six.f6);
            } else if (b == six.f6) {
                printf("%d\n", six.f5);
            } else if (b == six.f5) {
                printf("%d\n", six.f1);
            } else {
                printf("%d\n", six.f2);
            }
        } else if (a == six.f4) {
            if(b == six.f2) {
                printf("%d\n", six.f1);
            } else if (b == six.f1) {
                printf("%d\n", six.f5);
            } else if (b == six.f5) {
                printf("%d\n", six.f6);
            } else {
                printf("%d\n", six.f2);
            }
        } else if (a == six.f5) {
            if(b == six.f1) {
                printf("%d\n", six.f3);
            } else if (b == six.f3) {
                printf("%d\n", six.f6);
            } else if (b == six.f6) {
                printf("%d\n", six.f4);
            } else {
                printf("%d\n", six.f1);
            }
        } else {
            if(b == six.f2) {
                printf("%d\n", six.f4);
            } else if (b == six.f4) {
                printf("%d\n", six.f5);
            } else if (b == six.f5) {
                printf("%d\n", six.f3);
            } else {
                printf("%d\n", six.f2);
            }
        }
    }

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second



ll gcd(ll a, ll b) {
  if (a > b) swap(a,b);
  if (b % a == 0) return a;
  return gcd(b%a,a);
}

std::vector<ll> cd(ll a, ll b) {
  ll _gcd = gcd(a,b);
  std::vector<ll> res;
  ll _sqrt = sqrt(_gcd);
  FOR(i,1,_sqrt) {
    if (_gcd % i == 0) {
      res.PB(i);
      res.PB(_gcd/i);
    }
  }
  sort(ALL(res));
  return res;
}


int main(int argc, char const *argv[]) {
  ll a,b; std::cin >> a >> b;
  std::vector<ll> CD = cd(a,b);
  std::map<ll, ll> map;
  int ans = 0;
  CD.erase(unique(ALL(CD)), CD.end());
  ll multi = CD[0];
  FOR(i,1,SIZE(CD)-1) {
    // std::cout << "multi " << multi << '\n';
    // std::cout << "CD " << CD[i] << '\n';
    if (gcd(CD[i],multi) != 1) ans--;
    else multi=multi*CD[i];
  }
  // REP(i,SIZE(CD)) std::cout << CD[i] << '\n';
  std::cout << SIZE(CD) + ans << '\n';
  return 0;
}


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

int main() {
  long A,B, T;
  long V, W;
  
  cin >> A >> V >> B >> W >> T;
  
  long diff = abs(A-B);
  if(V<=W){
    cout << "NO" << endl;
    return 0;
  }
  
  long run = (V-W) * T;
  if(run >= diff){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        long p = 0;
        bool s = false;
        if (N >= 11)
        {            
            p += (N / 11) * 2;
            N %= 11;
        }
        while (N > 0)
        {
            if (!s)
                N -= 6;
            else
                N -= 5;
            p++;
        }
        Console.WriteLine(p);   
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
 
public class Main {
     
    static int gcd(int a, int b) {
        if(a<b) {
            return gcd(b,a);
        }
        if(b==0) {
            return a;
        }
        return gcd(b, a%b);
    }
     
    public static void main(String args[]){
        try(Scanner sc=new Scanner(System.in)){
            int n=sc.nextInt();
            int[] a=new int[n+1];
            for(int i=0; i<n; i++) {
                a[i]=sc.nextInt();
            }
            int lcm=a[0];
            for(int i=1; i<n; i++) {
                lcm=a[i]*lcm/gcd(a[i], lcm);
            }
            System.out.println(lcm);
        }
    }
}


Measured memory_bytes: 26280
#include <cstdio>
#include <cstdlib>
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Node {int key;Node *right,*left,*parent;};
Node *root,*NIL;
Node *find(Node *u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}
void insert(int k){
  Node *y=NIL,*x=root,*z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}
void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n,x;
  char com[6];
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(com[0]=='f'){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 21976
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const int INF = 1 << 25;

void sum2d(vec<int, 2>& sum) {
  int H = sum.size(), W = sum[0].size();
  for (int i = 1; i < H; i++) {
    for (int j = 1; j < W; j++) {
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    }
  }
}

int main() {
  int N;
  while (cin >> N) {
    vector<int> bQ(N, -1), wQ(N, -1);
    vec<int, 2> sumB = make_v(2 * N + 1, N + 1, 0);
    vec<int, 2> sumW = make_v(2 * N + 1, N + 1, 0);
    for (int i = 0; i < 2 * N; i++) {
      char c;
      int x;
      cin >> c >> x;
      --x;
      if (c == 'B') {
        bQ[x] = i;
        ++sumB[i + 1][x + 1];
      } else {
        wQ[x] = i;
        ++sumW[i + 1][x + 1];
      }
    }
    sum2d(sumB);
    sum2d(sumW);
    vec<int, 2> dp = make_v(N + 1, N + 1, INF);
    dp[0][0] = 0;
    for (int i = 0; i < 2 * N; i++) {
      for (int b = 0; b <= N && b <= i; b++) {
        int w = i - b;
        if (w > N || dp[b][w] >= INF) continue;
        // black
        if (b + 1 <= N) {
          int q = bQ[b];
          int cost = q - sumW[q][w] - sumB[q][b];
          dp[b + 1][w] = min(dp[b + 1][w], dp[b][w] + cost);
        }
        // white
        if (w + 1 <= N) {
          int q = wQ[w];
          int cost = q - sumW[q][w] - sumB[q][b];
          dp[b][w + 1] = min(dp[b][w + 1], dp[b][w] + cost);
        }
      }
    }
    cout << dp[N][N] << endl;
  }
  return 0;
}


Measured memory_bytes: 80896
#include<stdio.h>

#define N 1001

static const int INFTY = (1<<21);

int n,A[N][N],C[N],d[N],f[N],Q[N*2],head,tail,tt;

void init(){

  head = tail = 1;

}


void enqueue(int x){

  Q[tail++] = x;

}

int empty(){

  return head == tail;

}

int dequeue(){

  int x = Q[head++];

  return x;

}

void bfs_b(int s){

  int i,u,v;

  init();

  enqueue(s);

  for(i=0;i<n;i++){

    d[i] = INFTY;

  }
  
  d[s] = 0;

  while(!empty()){

    u = dequeue();

    for(v=0;v<n;v++){
      
      if(A[u][v] == 0){
	continue;
      }
      
      if(d[v] != INFTY){
	continue;
      }
      
      d[v] = d[u] + 1;

      enqueue(v);

    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,((d[i]==INFTY)?(-1):d[i]));
  }
}

int main(){

  int u,k,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    
    scanf("%d%d",&u,&k);
    
    u--;

    for(j=0;j<k;j++){
      
      scanf("%d",&v);

      v--;
      A[u][v] = 1;

    }
  }

  bfs_b(0);


  return 0;
}



Measured memory_bytes: 2212
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC70 solver = new ABC70();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC70 {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            if (c < a) {
                c ^= a;
                a ^= c;
                c ^= a;
                b ^= d;
                d ^= b;
                b ^= d;
            }
            if (b < c) {
                out.println("0");
                return;
            }
            int l = c;
            int r = Math.min(d, b);
            out.println(r - l);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
satisfaction = 0
for i in range(N):
    satisfaction += B[A[i] - 1]
    if (i != 0) and (A[i - 1] + 1 == A[i]):
        satisfaction += C[A[i - 1] - 1]
print(satisfaction)


Measured memory_bytes: 9180
import sys
# 整数の入力
z = list(map(int, input().split()))
# 整数
N = z[0]
# 進数
K = z[1]

tmp = 1
inc = 0
while True:
  if tmp <= N:
      tmp = tmp * K
      inc = inc + 1
  else:
      break
print(inc)


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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string a, b;
  cin >> a >> b;

  string x = a + b;
  int y = stoi(x);

  bool ans = false;
  for (int i = 1; i <= 1000; i++) {
    if (i * i == y) ans = true;
  }

  // 解答
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            boolean ans = false;
            for (int i = 0; i < 3; i++) {
                ans |= args.get(0).charAt(i) == args.get(0).charAt(i + 1);
            }
            System.out.println(ans ? "Bad" : "Good");
        };
    }

}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll N, K;
  cin >> N >> K;

  cout << min(N % K, K - N % K) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int main() {
  while (cin >> N) {
	cout << N * 800 - (N/15)*200 << endl;
  }
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	ll n,k;
    cin>>n>>k;
    if(n>k) n=n%k;
    if(n>k/2) n=k-n;
    cout<<n;
    return 0;
}



Measured memory_bytes: 256
N = list(map(int,[i for i in input()]))
op = ["000","001","010","100","011","101","110","111"]

num = sum(N)
for i in op:
  tmp = num
  if i[0] == "1":
    tmp -= N[1]*2
  if i[1] == "1":
    tmp -= N[2]*2
  if i[2] == "1":
    tmp -= N[3]*2
  if tmp == 7:
    ans = str(N[0])
    for j in range(3):
      if i[j] == "0":
        ans += "+"+ str(N[j+1])
      else:
        ans += "-"+ str(N[j+1])
    break
print(ans+"=7")

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

int main(){

    string n;
    cin >> n;

    if (n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7') {
        cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

}


Measured memory_bytes: 3600
open Scanf
open Printf

let (n,k) = sscanf (read_line ()) "%d %d" (fun x y -> (x,y));;
let str = sscanf (read_line ()) "%s" (fun x -> x);;

let string2cnt_array s =
  let len = String.length s in
  let array = Array.make len (0,'0') in
  let rec loop i c num cnt =
    if (i = len) then
      let () = array.(num) <- (cnt,c) in
      let ret = Array.make (num+1) (0,'0') in
      let () = Array.blit array 0 ret 0 (num+1) in
      ret
    else if (s.[i] = c) then
      loop (i+1) c num (cnt+1)
    else
      let () = array.(num) <- (cnt,c) in
      loop (i+1) (s.[i]) (num+1) 1
    in loop 0 s.[0] 0 0;;


let cnt_array = string2cnt_array str;;
let len = Array.length cnt_array;;
let ruiseki = Array.make len 0;;
let () = ruiseki.(0) <- fst cnt_array.(0) in
for i = 1 to len - 1 do
  ruiseki.(i) <- ruiseki.(i-1) + (fst cnt_array.(i))
done

let rec solve i ans =
  if i = len then ans
  else
    let num = if snd cnt_array.(i) = '0' then 0 else 1 in
    let target = 2 * k - (1 - num) + i in
    let si = min (len - 1) target in
    let ruiseki_minus = if i = 0 then 0 else ruiseki.(i-1) in
    let next_ans = max ans (ruiseki.(si) - ruiseki_minus) in
    solve (i+1) next_ans;;

printf ("%d\n") (solve 0 0);;

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

ll solve(int n, vector<int> const & l, vector<int> const & r) {
    // prepare
    ll answer = 0;
    ll shift_l = l[0];
    ll shift_r = l[0];
    priority_queue<ll> imos_l;
    reversed_priority_queue<ll> imos_r;
    auto top_l = [&]() { return (imos_l.empty() ? 0 : imos_l.top()) + shift_l; };
    auto top_r = [&]() { return (imos_r.empty() ? 0 : imos_r.top()) + shift_r; };
    auto push_l = [&](ll value) { imos_l.push(value - shift_l); };
    auto push_r = [&](ll value) { imos_r.push(value - shift_r); };
    auto flush = [&]() {
        while (top_l() > top_r()) {
            assert (not imos_l.empty());
            assert (not imos_r.empty());
            ll a = top_l();
            ll b = top_r();
            imos_l.pop();
            imos_r.pop();
            answer += a - b;
            push_l(b);
            push_r(a);
        }
    };

    // init
    push_l(l[0]);
    push_r(l[0]);
    flush();

    REP (j, n - 1) {
        int l_i = l[j + 1];
        int r_i = r[j + 1];
        ll cur_len = r_i  - l_i;
        ll prv_len = r[j] - l[j];

        // update
        shift_l -= cur_len;
        shift_r += prv_len;
        push_l(l_i);
        push_r(l_i);
        flush();
    }
    return answer;
}

int main() {
    int n; cin >> n;
    vector<int> l(n), r(n);  // [l, r)
    REP (i, n) cin >> l[i] >> r[i];
    cout << solve(n, l, r) << endl;
    return 0;
}


Measured memory_bytes: 2804
S = list(input())
R = [0 for i in range(len(S))]
L = [0 for i in range(len(S))]
ans = [0 for i in range(len(S))]
r_cnt = 0
l_cnt = 0
for i in range(len(S)):
    if S[i] == "R":
        r_cnt+=1
    else:
        if r_cnt!=0:
            R[i]+=r_cnt//2
            R[i-1]+=r_cnt-r_cnt//2
            r_cnt=0
S.reverse()
for i in range(len(S)):
    if S[i] == "L":
        l_cnt+=1
    else:
        if l_cnt!=0:
            L[i]+=l_cnt//2
            L[i-1]+=l_cnt-l_cnt//2
            l_cnt=0
L.reverse()

for i in range(len(S)):
    ans[i]+=R[i]+L[i]
print(*ans)

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

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
  for(long long i = 0; i <= X; i++) {
    if((i*2)+((X-i)*4) == Y) {
      cout << YES << endl;
      return;
    }
  }

  cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


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

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

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

#ifdef false

const int MAX = 1e4 + 10;
char strbuf[MAX];
string next() {
scanf("%s", strbuf);
return strbuf;
}
int N;
string S[MAX];
string T;

int main() {
    scanf("%d", &N);
    REP(i, N) {
        S[i] = next();
    }
    sort(S, S + N);
    T = next();

}

#else
const int MAX = 20;
int N, K;
LL a[MAX];
LL dp[1 << MAX];
int main() {
    memset(dp, 0, sizeof(dp));
    scanf("%d%d", &N, &K);
    REP(i, N) {
        scanf("%lld", a + i);
    }
    REP(i, (1 << N)) {
        LL ma = 0;
        REP(j, N) {
            if (i & (1 << j)) {
                if (ma >= a[j]) {
                    dp[i] += ma - a[j] + 1;
                    ++ma;
                }
            }
            chmax(ma, a[j]);
        }
    }
    LL ans = LLINF;
    REP(i, (1 << N)) {
        if (__builtin_popcountll(i) >= K) {
            chmin(ans, dp[i]);
            DEBUG(dp[i])DEBUG(i)
        }
    }
    printf("%lld\n", ans);
}
#endif


Measured memory_bytes: 8448
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [X, N] = r.nn()

    if (N === 0) return X
    const p = r.nn()

    const lib = {}

    p.forEach((pv) => {
      lib[pv] = true
    })
    if (!lib[X]) return X
    for (let i = 1; i < 1000; i++) {
      if (!lib[X - i]) return X - i
      if (!lib[X + i]) return X + i
    }

    return -1
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


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

int main() {
    int a, b, c, x, y, total_value=0;
    cin >> a >> b >> c >> x >> y;
    if(2 * c < a + b) {
        int less = min(x, y);
        total_value+=2*c*less;
        x-=less;
        y-=less;
        
    }
    if(x > 0) {
        if(2 * c < a) total_value += 2*c*x;
        else total_value += a*x;
    }
    if(y > 0) {
        if(2 * c < b) total_value += 2*c*y;
        else total_value += b*y;
    }
    cout << total_value << endl;
}


Measured memory_bytes: 256
# encoding: utf-8
import math, sys

N = int(input())
A = [int(input()) for i in range(N)]

A_up = sorted(A)
A_down = list(A_up[::-1])

# magic-hand-like order
# 1 2 3
# |X X  4 <- this node is taken last
# 7 6 5

ans = 0
for i in range(N // 2):
    if i == 0:
        ans += (A_down[0] - A_up[0])
    else:
        ans += (A_down[i - 1] - A_up[i])
        ans += (A_down[i] - A_up[i - 1])

if N % 2:
    ans += max((A_down[N // 2 - 1] - A_down[N // 2], A_up[N // 2] - A_up[N // 2 - 1]))

print(ans)

Measured memory_bytes: 10704
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll fact(ll n)
{
    ll ans = 1e14;
    for(ll i = 1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll sol = (i - 1) + (n/i - 1);
            ans = min(ans,sol);
        }
    }
    return ans;
}
int main()
{
    float d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3760