akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int n;
string s[2];
ll f[maxn][3][3];

int main() {
//  freopen("in.cpp","r",stdin);
  cin>>n;
  cin>>s[0]>>s[1];
  for(int i=0;i<3;i++)
  for(int j=0;j<3;j++){
    if((i==j)==(s[0][0]==s[1][0]))f[0][i][j]=1;
  }
  for(int i=0;i+1<n;i++){
    for(int j=0;j<3;j++)
    for(int k=0;k<3;k++){
      if(f[i][j][k]==0)continue;
      for(int p=0;p<3;p++)
      for(int q=0;q<3;q++){
        if((s[0][i+1]==s[1][i+1])!=(p==q))continue;
        if((s[0][i]==s[0][i+1])!=(p==j))continue;
        if((s[1][i]==s[1][i+1])!=(q==k))continue;
        f[i+1][p][q]+=f[i][j][k];
        f[i+1][p][q]%=mod;
      }
    }
  }
  ll ret=0;
  for(int i=0;i<3;i++)
  for(int j=0;j<3;j++)
  ret=(ret+f[n-1][i][j])%mod;
  cout<<ret<<endl;
  return 0;
}



Measured memory_bytes: 256
S = input()
T = input()

d1, d2 = {}, {}
ans = 'Yes'
for s, t in zip(S, T):
    if s in d1 and d1[s] != t:
        ans = 'No'
        break
    if t in d2 and d2[t] != s:
        ans = 'No'
        break
    d1[s] = t
    d2[t] = s
print(ans)


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

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

    vector<int> L(n);
    rep(i,n) cin >> L[i];

    sort(L.rbegin(), L.rend());
    ll ans = 0;
    for (int i=0; i<=n-3; i++) { // 最大の辺
        for(int j= i+2; j<=n-1; j++) { // 最小の辺
            int c = [&](){
                if (L[i+1] + L[j] <= L[i]) return 0;

                int l=i+1;
                int r= j;
                while(l+1<r) {
                    int mid = (l+r)/2;
                    if(L[j] + L[mid] > L[i]) l=mid;
                    else r=mid;
                }
                return l-i;
            }();
            ans += c;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int k, q;
    cin >> k >> q;
    Vl d(k);
    for (int i = 0; i < k; i++) {
        cin >> d[i];
    }

    Vl m(q), x(q), n(q);
    for (int i = 0; i < q; i++) {
        cin >> n[i] >> x[i] >> m[i];
    }

    Vl dm(k);
    for (int i = 0; i < q; i++) {
        ll out = 0;
        for (int j = 0; j < k; j++) {
            dm[j] = d[j] % m[i];
        }
        for (int j = 0; j < k; j++) {
            if (dm[j] == 0) {
                if (j <= (n[i] - 1) % k - 1)
                    out += (n[i] - 1) / k + 1;
                else
                    out += (n[i] - 1) / k;
            }
        }
        ll a_last = x[i] % m[i];
        for (int j = 0; j < k; j++) {
            if (j <= (n[i] - 1) % k - 1)
                a_last += dm[j] * ((n[i] - 1) / k + 1);
            else
                a_last += dm[j] * ((n[i] - 1) / k);
        }
        out += a_last / m[i];
        cout << n[i] - 1 - out << "\n";
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int N;

    cin >> N;

    if(N%10 == 2 || N%10 == 4 || N%10 == 5 || N%10 == 7 || N%10 == 9)
    {
        cout << "hon" << endl;
    }
    else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "bon" << endl;    
    }
    
    
    return 0;
}

Measured memory_bytes: 3584
package main

import "fmt"

var (
	n int
	a [15]int
	x [15][14]int
	y [15][14]int
)

func main() {
	fmt.Scan(&n)
	fmt.Scan(&a)
	for i := 0; i < n; i++ {
		fmt.Scan(&(a[i]))
		for j := 0; j < a[i]; j++ {
			var v, w int
			fmt.Scan(&v)
			fmt.Scan(&w)
			x[i][j], y[i][j] = v-1, w
		}
	}
	// fmt.Println(n)
	// fmt.Println(a)
	// fmt.Println(x)
	// fmt.Println(y)
	var answer int

	for i := 0; i < (1 << uint(n)); i++ {
		cnt := judge(i)
		// fmt.Println(cnt, i)
		if cnt > answer {
			answer = cnt
		}
	}

	fmt.Println(answer)
}

func judge(bits int) int {
	honest := make([]bool, n)
	var cnt int
	for i := 0; i < n; i++ {
		honest[i] = (bits & (1 << uint(i))) > 0
		if honest[i] {
			cnt++
		}
	}
	// fmt.Println(honest)
	for i := 0; i < n; i++ {
		if !honest[i] {
			continue
		}
		for j := 0; j < a[i]; j++ {
			v := x[i][j]
			w := y[i][j]
			if (honest[v] && w == 0) || (!honest[v] && w == 1) {
				return 0
			}
		}
	}
	return cnt
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        for (int i = 0, a = 32; a > 0; ++i) {
            if(i&1){
                a -= v[(i/2)%v.size()];
            }else {
                a -= (a-1)%5;
            }
            cout << max(a, 0) << "\n";
        }
    }
    return 0;
}


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

int main() {
  int64_t n,a,b;
  cin>>n>>a>>b;
  vector<int64_t> x(n);
  for(int i=0;i<n;i++){
    cin>>x.at(i);
  }
  int64_t ans=0;
  for(int i=0;i<n-1;i++){
    ans+=min(a*(x.at(i+1)-x.at(i)),b);
  }
  cout<<ans;
}

Measured memory_bytes: 1024
function isEnd(str) {
    let end = true
    if(str.length < 2) return true
	const arr = str.split("")
	for (let idx in arr) {
		if (idx === 0) {
			end = arr[idx + 1] === arr[idx] ? false : true
			if (end === false) break;

		} else if (idx < arr.length) {
			end = arr[idx] === arr[idx - 1] ? false : true
			if (end === false) break;

		} else {
			end = arr[idx + 1] === arr[idx] || arr[idx] === arr[idx - 1] ? false : true
			if (end === false) break;
		}
	}
	return end
}

const fusion = (str) => {
	const result = str.split("").reduce((acc, cur, idx, arr) => {

		let isFusion = 0

		if(idx === 0){
			isFusion = arr[idx + 1] === cur ? idx + 1  : 0;
		}else if(idx >= arr.length - 1){
			isFusion = arr[idx - 1] ===cur  ?  idx -1 : 0;
		}else{
			 if(arr[idx - 1] === cur){
				isFusion = idx - 1
			 }else if(arr[idx + 1] === cur){
				isFusion = idx + 1
			 }

		}

		if (isFusion) {
			if(idx % 2 !== 0 || idx === 0)return  acc
			return acc + arr[isFusion]

		} else {
			return acc + cur
		}
	}, "")

    if(!isEnd(result)){
       return fusion(result)
    }
	return result
}
function main(input) {
    const args = input.split("\n");
    const str = args[1]
    let result = str
    
    result = fusion(result)
	console.log(result.length)
}

// main("20" + "\n" + "xxzaffeeeeddfkkkkllq")

main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 18868
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef LL
#define LL long long
#endif
#ifndef uLL
#define uLL unsigned long long
#endif
#ifndef uL
#define uL unsigned int
#endif
#ifndef iL
#define iL int
#endif
#ifndef iS
#define iS short
#endif
#ifndef uS
#define uS unsigned short
#endif
#ifndef uC
#define uC unsigned char
#endif
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(a) (((a)<0)?(-(a)):(a))
#define sgn(a) (((a)<0)?(1):(0))
#define movs(a,b,l) (memmove((a),(b),sizeof(*(b))*(l)))
#define stosb(a,b,l) (memset((a),(b),sizeof(*(a))*(l)))
LL num[1000000];
LL re[4][1000000];
LL legal(char ch)
{
	if (ch=='.') {return 1;}
	if (ch=='#') {return 2;}
	return 0;
}
LL travel1(LL st,LL n,LL *ans)
{
	LL i,j,k,a,b,c;
	memset(ans+1,0,sizeof(*ans)*n);
	if (num[st]==1) {ans[st]=1;}
	for (i=st;i<=n;i++)
	{
		//printf("%lld\n",i);
		if (ans[i]==1)
		{
			if (num[i+1]==1) {ans[i+1]=1;}
			if (num[i+2]==1) {ans[i+2]=1;}
		}
	}
}
LL travel2(LL st,LL n,LL *ans)
{
	LL i,j,k,a,b,c;
	memset(ans+1,0,sizeof(*ans)*n);
	if (num[st]==1) {ans[st]=1;}
	for (i=st;i>1;i--)
	{
		//printf("%lld-%lld\n",i,num[i-2]);
		if (ans[i]==1)
		{
			if ((i>1)&&(num[i-1]==1)) {ans[i-1]=1;}
			if ((i>2)&&(num[i-2]==1)) {ans[i-2]=1;}
		}
	}
}
int main()
{
	//freopen("in.in","r",stdin);
	char ch;
	LL i,j,k,a,b,c,d,n,m,iq,qq,ans,x,y;
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for (i=1;i<=n;i++)
	{
		while (1)
		{
			scanf("%c",&ch);
			if (legal(ch)>0) {break;}
		}
		num[i]=legal(ch);
	}
	//printf("shit\n");
	travel1(a,n,re[0]);
	travel1(b,n,re[1]);
	//printf("shit\n");
	travel2(c,n,re[2]);
	travel2(d,n,re[3]);
	//printf("shit\n");
	if (c<d)
	{
		if ((re[0][c]==1)&&(re[1][d]==1)) {printf("Yes\n");}
		else {printf("No\n");}
	}
	else
	{
		for (i=max(a,b);i<=d;i++)
		{
			if ((re[0][i-1]==1)&&(re[1][i]==1)&&(re[2][i+1]==1)&&(re[3][i]==1))
			{
				printf("Yes\n");return 0;
			}
		}
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    string n;
    cin >> n;
    int ans=10000;
    rep(i,n.size()-2){
        int memo=(n[i]-'0')*100+(n[i+1]-'0')*10+(n[i+2]-'0');
        ans = min(ans,abs(memo-753));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	string S, T;
	cin>>S;
	cin>>T;
	int hanbetu=0;
	int len = S.length();
	for(int i=0;i<len;i++){
		S = S.substr(1, len-1) + S.substr(0, 1);
		if(S==T){
			cout<<"Yes";
			hanbetu+=1;
			break;
		}
	}
	if(hanbetu==0){
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

   static int n;
   static Matrix[] matrix;
   static Matrix result  ;
   static int[][] DP;
   static int[] p;

	public static void main( String args[] ) throws IOException {

		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         n =  Integer.parseInt( br.readLine() );
         matrix = new Matrix[n];
          DP = new int[101][101];
          p = new int[n + 1];


         String string = br.readLine();
         p[0] = Integer.parseInt(string.split(" ")[0] );
         p[1] = Integer.parseInt(string.split(" ")[1] );

         for(int i = 2; i <= n ; i++){

             String order =  br.readLine();
             p[i] = Integer.parseInt(order.split(" ")[1] );
         }

         for(int i = 1; i < n ; i++){
            // System.out.println("i = "+i + " p = "+p[ i +1]);
        	 DP[i][i] = 0;
        	 DP[i][i+1] = p[ i-1 ]*p[ i ]*p[ i+1 ];
         }


          for(int j = 0; j <= n-3 ; j++){
        	  for( int i = 3+j; i <= n ; i++ ){
        		  //System.out.println("i-2-j = "+(i-2-j) + " i = "+i);
        		  DP[i-2-j][i] = rec(i-2-j, i);
        	  }

          }



          System.out.println(DP[1][n]);

	}


          public static int rec(int r, int c){

        	  int Min = Integer.MAX_VALUE;
        	  int num = c - r;

        	  for(int i = 0;i < num;i++ ){
                    Min = Math.min( Min, DP[r][r+i] + DP[r+i+1][c] + p[r-1]*p[r+i]*p[c]);
        	  }
        	  return Min;

          }


}


class Matrix{

	int ROW;//???
    int COLUMN;//???

    Matrix(int x, int y){

    	ROW = x;
    	COLUMN = y;
	}


}

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

#define MOD 1000000007  //E9

typedef long long int ll;
typedef pair<ll,ll> P;
//a^n%m
ll modpow(ll a,ll n,ll m){
    ll r=1;
    while(n>0){
        if(n&1)r=r*a%m;
        a=a*a%m;
        n>>=1;
    }
    return r;
}
//愚直なnCk
//modpowが必要
ll COM(int n,int k){
    ll r=1;//分母
    ll a=1;//分子
    for(int i=0;i<k;i++){
        r=(r*(n-i))%MOD;
        a=(a*(i+1))%MOD;
    }
    return (r*modpow(a,MOD-2,MOD))%MOD;
}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<((modpow(2,n,MOD)-1)-COM(n,a)-COM(n,b)+2*MOD)%MOD;
    
    return 0;

}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>

//
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    cout << (N / (A + B)) * A + min((N % (A + B)), A);
}

Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {

	int x, a, b;
	cin >> x >> a >> b;

	if (abs(x - a) > abs(x - b)) {
		cout << 'B' << endl;
	}
	else {
		cout << 'A' << endl;
	}
	
	return 0;
	
}



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

int main() {
	int n;
	cin >> n;
	int a[n],b[n];
	for(int i=0;i<n;i++)cin >>a[i];
	for(int i=0;i<n;i++)cin >>b[i];
	int ans = 0;
	for(int i = 0;i<n;i++){
		int temp = 0;
		for(int j=0;j<=i;j++)temp=temp+a[j];
		for(int l=i;l<n;l++)temp=temp+b[l];
		ans = max(ans,temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, count;
    count = 0;
    scanf("%d %d %d", &a, &b, &c);

    if (c < a) {
        printf("%d\n", 0);
        return 0;
    }

    if (a == b) {
        printf("%d\n", 1);
        return 0;
    }

    while (a <= b) {
        if ((c % a) == 0)
            count = count + 1;
        a = a + 1;
    }
    
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 2748
if __name__ == "__main__":
    n = int(input())
    an = list(map(int, input().split()))

    for a in an:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                print('DENIED')
                exit()

    print('APPROVED')


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#define R register
#define next kkksc03
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
inline ll read();
inline void write(ll x);
inline void writesp(ll x);
inline void writeln(ll x);
ll a,b;
int main(){
	a=read();b=read();
	writeln(6-a-b);
}
inline ll read(){
	ll x=0,t=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*t;
}
inline void write(ll x){
	if(x<0){putchar('-');x=-x;}
	if(x<=9){putchar(x+'0');return;}
	write(x/10);putchar(x%10+'0');
}
inline void writesp(ll x){
	write(x);putchar(' ');
}
inline void writeln(ll x){
	write(x);putchar('\n');
}

Measured memory_bytes: 256
import sys

n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in ( 'S', 'H', 'C', 'D' ) }
for i in range( n ):
	pattern, num = sys.stdin.readline().split( " " )
	cards[ pattern ][ int( num )-1 ] = True

for pattern in ( 'S', 'H', 'C', 'D' ):
	for i in range( 13 ):
		if not cards[ pattern ][ i ]:
			print( "{:s} {:d}".format( pattern, i+1 ) )

Measured memory_bytes: 4220
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
    KAKA
    vector<ll> s(n);
    ll tot = 0;
    pragi(0,n)
    {
        cin>>s[i];
        tot += s[i];
    }
    if(tot % 10)
    {
        cout<<tot<<"\n";
    }
    else
    {
        ll lst = -1;
        sort all(s);
        pragi(0,n)
        {
            if((s[i] % 10) != 0)
            {
                lst = s[i];
                break;
            }
        }
        if(lst == -1) cout<<0<<"\n";
        else cout<<(tot - lst)<<"\n";
    }
    
}
int main()
{
    KAKA
    ll n;
    cin>>n;
    Compute(n);
}


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

namespace SandboxForAtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var line1 = Console.In.ReadLine();

            var a = int.Parse(line1.Split(" ")[0]);
            var b = int.Parse(line1.Split(" ")[1]);


            Console.WriteLine(a * b);
        }
    }
}

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

int main() {
	int m, f, r;
	int i, t;
	for (i = 0;; i++) {
		cin >> m >> f >> r;
		t = m+f;
		if (m == -1 && f == -1 && r == -1) break;
		else if (m == -1 || f == -1) cout << 'F' << endl;
		else if (t >= 80) cout << 'A' << endl;
		else if (t >= 65) cout << 'B' << endl;
		else if (t >= 50) cout << 'C' << endl;
		else if (t >= 30) {
			if (r >= 50) cout << 'C' << endl;
			else cout << 'D' << endl;
		}
		else cout << 'F' << endl;
	}
	return 0;
}

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        S: chars,
    }
    let mut rl = Vec::new();
    let mut r = 0;
    let mut l = 0;
    for i in 0..S.len() {
        if S[i] == 'R' && l > 0 {
            rl.push((r, l));
            r = 1;
            l = 0;
        } else if S[i] == 'R' {
            r += 1;
        } else {
            l += 1;
        }
    }
    rl.push((r, l));
    use std::cmp::max;
    let mut ans = vec![0; S.len()];
    let mut cur = 0;
    for (r, l) in rl {
        if (r + l) % 2 == 0 {
            let t = (r + l) / 2;
            ans[cur + r - 1] = t;
            ans[cur + r] = t;
        } else {
            let balance = max(r, l) - 1;
            let big = (r + l + 1) / 2;
            let small = (r + l - 1) / 2;
            if balance % 2 == 0 {
                if r > l {
                    ans[cur + r - 1] = big;
                    ans[cur + r] = small;
                } else {
                    ans[cur + r - 1] = small;
                    ans[cur + r] = big;
                }
            } else {
                if r > l {
                    ans[cur + r - 1] = small;
                    ans[cur + r] = big;
                } else {
                    ans[cur + r - 1] = big;
                    ans[cur + r] = small;
                }
            }
        }
        cur += r + l;
    }
    println!("{}", ans.into_iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
}


Measured memory_bytes: 10620
#include<bits/stdc++.h>
using namespace std;
short cnt[4100][4100];
int main(){
  string str1,str2;
  while(cin >> str1){
    cin >> str2;
    int len1 = str1.size();
    int len2 = str2.size();
    str1 = ' ' + str1;
    str2 = ' ' + str2;
    for(int i=1;i<=len1;i++){
      cnt[i][0] = 0;
    } 
    for(int i=1;i<=len2;i++){
      cnt[0][i] = 0;
    }
    short ret = 0;
    for(int i=1;i<=len1;i++){
      for(int j=1;j<=len2;j++){
	if(str1[i] == str2[j]){
	  cnt[i][j] = cnt[i-1][j-1] + 1;
	}
	else {
	  cnt[i][j] = 0;
	}
	ret = max(ret,cnt[i][j]);
      }
    }
    cout << ret << endl;
  }	
}

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

int main ()
{
    string str;
    cin >> str;
    string res;

    for (int i = 0; i < str.size(); i++) {
        if ((res.size() == 0 || res[res.size()-1] == 'Z') && str[i] == 'A') {
            res += 'A';
        } else if (res.size() && res[res.size()-1] == 'A' && str[i] == 'Z') {
            res += 'Z';
        }
    }

    if (res.size() < 2) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < (res.size() / 2) * 2; i++) {
        cout << res[i];
    } cout << endl;

    return 0;
}

Measured memory_bytes: 1184
s=list(input())
n=len(s)
ans=0
for i in range(1<<(n-1)):

    """
    ここで既に、n-1個の文字間のうち、どこに+を入れるかが決まる。入れるところにはbit
    が立ち(その桁が1となる)、入れないところにはbitが立たない(その桁が0となる)
    """

    S=s[0]
    for j in range(n-1):
        if i & (1<<j): #bitが立っている時
            S+="+"+s[j+1]
        else: #bitが立っていない時
            S+=s[j+1]
    ans+=eval(S)
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  ll N;
  cin >> N;
  
  if(N%2==1){ // 奇数は0が出てこない
    cout << 0 << endl;
    return 0;
  }

  ll d = N, div=10;
  ll ans = 0;
  while(div<=N){
    d = N;
    // cout << d << " " << div<< endl;
    d /= div;
    ans+= d;
    div *= 5;
  }
   
  cout << ans << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

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

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

    string s;cin>>s;
    cout<<"ABC"<<s<<el;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    int ans=0;
    rep(i,N){
        if (A[i]==B[i]&&B[i]==C[i]) continue;
        if (A[i]!=B[i]&&B[i]!=C[i]&&C[i]!=A[i]) ans+=2;
        else ans+=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
P = 2019
 
res = 0
mp = [0]*P
mp[0] = 1
cur = 0
p10 = 1
for c in S[::-1]:
    cur = (cur + int(c)*p10) % P
    res += mp[cur]
    mp[cur] += 1
    p10 *= 10
    p10 %= P
 
print(res)

Measured memory_bytes: 9332
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50,vector<int>(4,0));

int main() {
	int K, S;
	int ans = 0;
	cin >> K >> S;
	rep(i, 0, K + 1) {
		if (i == S) {
			++ans;
		}
		else if(i < S){
			rep(j, 0, K + 1) {
				if (i + j <= S && S - (i + j) <= K)ans++;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string s;
  cin >> s;
  bool check_c = false;
  bool check_t = false;
  for (unsigned int i = 0; i < s.size(); i++)
    {
      if (s[i] == 'C')
	check_c = true;
      if (s[i] == 'F' && check_c)
	check_t = true;
    }
  if (check_t)
    cout << "Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////
ll board[35][35];
ll moto[35][35];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,K; cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H) cin >> S[i];

    rep(i,H) rep(j,W) moto[i][j] = S[i][j] - '0';

    ll ans = 0;
    rep(z,H) {
        rep(w,W) {
            rep(i,H) rep(j,W) board[i][j] = moto[i][j];
            for (int i = z; i > 0; --i) board[i][w] = board[i-1][w];
            board[0][w] = 0;

            ll val = 0;
            ll b = 1;
            while (true) {
                bool ok = false;
                rep(i,H) {
                    for (int j = W; j >= K; --j) {
                        rep(k,W-j+1) {
                            if (!board[i][k]) continue;
                            bool ok10 = true;
                            rep(l,j) {
                                if (board[i][k] != board[i][k+l]) {
                                    ok10 = false;
                                    break;
                                }
                            }
                            if (!ok10) continue;
                            ok = true;
                            val += board[i][k]*j*b;
                            rep(l,j) {
                                board[i][k+l] = 0;
                            }
                        }
                    } 
                }

                if (!ok) break;
                rep(j,W) {
                    for (int i = H-1; i >= 0; --i) {
                        if (board[i][j]) continue;
                        int k = i-1;
                        while (k >= 0 && !board[k][j]) --k;
                        if (k==-1) break;
                        board[i][j] = board[k][j];
                        board[k][j] = 0;
                    }
                }
                b *= 2;
            }
            /*
            rep(i,H) {
                rep(j,W) cout << board[i][j];
                cout << ln;
            }
            cout << ln;
            */
            chmax(ans,val);
        }
    }

    cout << ans << ln;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m[2][101];
	while(~scanf("%d",&n)){
		int l,i;
		for(l=0;l<2;l++)
			for(i=0;i<n;i++)
				scanf("%d",&m[l][i]);
		for(i=1;i<n;i++){
			m[0][i]+=m[0][i-1];
		}
		m[1][0]+=m[0][0];
		for(i=1;i<n;i++){
			m[1][i]+=(m[0][i]>m[1][i-1]?m[0][i]:m[1][i-1]);
		}
		printf("%d\n",m[1][n-1]);
	}
}

Measured memory_bytes: 128
#include <stdio.h>
     
    int main()
    {
        int n, k;
        int graph[105][105] = {};
        int maxv;
        int edge = 0;
     
        scanf("%d %d", &n, &k);
     
        maxv = (n - 1) * (n - 2) / 2;
     
        if (maxv < k) {
            printf("-1\n");
            return 0;
        }
     
        for (int i = 2; i <= n; i++) {
            graph[1][i] = 1;
            edge++;
        }
     
        int i = 2;
        while (maxv > k) {
            for (int j = i + 1; j <= n && maxv > k; j++) {
                graph[i][j] = 1;
                edge++;
                maxv--;
            }
            i++;
        }
     
        printf("%d\n", edge);
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (graph[i][j]) {
                    printf("%d %d\n", i, j);
                }
            }
        }
     
        return 0;
    }

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

int main() {
  string S,T;
  cin>>S>>T;
  int N=S.size();
  int Z=0;
  for(int i=0;i<N;i++){
    Z+=(S[i]-'0');
  }
  if(Z%9==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3748
n=gets.to_i
cnt=0
ary=[]
(1..n).each do |j|
  if j.odd?
    (1..j).each do |i|
      if j % i ==0
        cnt +=1
      end
    end
    ary<<cnt
    cnt=0
  end
end
puts ary.count(8)

Measured memory_bytes: 3836
#include<stdio.h>

int main(void)
{
  int a=0, b=0, c=0;
  int x=0;
  int i, j, k;
  int cnt = 0;
  scanf("%d", &a); scanf("%d", &b); scanf("%d", &c);
  scanf("%d", &x);

  for(i=0; i<=a; i++){
    for(j=0; j<=b; j++){
      for(k=0; k<=c; k++){
        if(x == 500*i + 100*j + 50*k){
          cnt++;
        }
      }
    }
  }

  printf("%d\n", cnt);
}


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

using namespace std;

int main(){
    int mod=1000000007;
    int n;
    long long ans=0;
    scanf("%d",&n);

    vector<int> a(n);
    for (auto&e:a) scanf("%d",&e);
    sort(a.begin(),a.end());
    if (n%2) {
        for (int i=0;i<n;i++) {
            if (i==0 && a[i]==0) {
                ans=1;
            } else if (i==0 && a[i]!=0) {
                ans=0;
                break;
            } else if (i>0 && a[i]==i && a[i-1]==i) {
                ans*=2;
                ans%=mod;
            } else {
                ans=0;
                break;
            }
            i++;
        }
    } else {
        for (int i=1;i<n;i++) {
            if (i==1 && a[1]==1 && a[0]==1) {
                ans=2;
            } else if (i==1 && (a[i]!=1 || a[i-1]!=1)) {
                ans=0;
                break;
            } else if (i>1 && a[i]==i && a[i-1]==i) {
                ans*=2;
                ans%=mod;
            } else {
                ans=0;
                break;
            }
            i++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;
using ll = long long;
using P = pair<int ,int>;
 
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
 
#define INF 99999999
#define MOD (int)1e9 + 7
#define rep(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end()
 
string s[100010];   
string K;
 
int main() {
	
	int n, m, k;
	
	cin >> n >> m >> k;
 
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (k == j*(n - i) + i*(m - j)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
 
	return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define descend greater<int>()  // sort 降順

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);
    sort(ALL(vec), descend);
    int allice = 0, bob = 0;

    for (int i = 0; i < N; ++i) {
        int tmp = vec.at(i);
        if (i % 2 == 0) {
            allice += tmp;
        } else {
            bob += tmp;
        }
    }
    cout << allice - bob << endl;
    
    return 0;
}


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



int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n;
    string s;
    cin>>s;
    vector<int> arr;
    for(char c : s) {
    	int x  = c - '0';
    	arr.push_back(x);
    }

    for(int i = 0; i < 8; i++) {
    	bitset<3> s(i);
    	int sum = arr[0];
    	for(int j = 0; j < 3; j++) {
    		if(s.test(j))
    			sum += arr[j+1];
    		else 
    			sum -= arr[j+1];
    	}
    	if(sum == 7) {
    		cout<<arr[0];
    		for(int j = 0; j < 3; j++) {
    			if(s.test(j))
    				cout<<"+"<<arr[j+1];
    			else 
    				cout<<"-"<<arr[j+1];
    		}
    		cout<<"=7";
    		return 0;
    	}
    }

	return 0;		
}


//1011




Measured memory_bytes: 256
s = input()
l = [False for i in range(len(s))]
for i in range(len(s)):
    if i%2==1:#偶数
        l[i] = s[i]=='L' or s[i]=='U' or s[i]=='D'
    else:#奇数
        l[i] = s[i]=='R' or s[i]=='U' or s[i]=='D'
if l == [True for i in range(len(s))]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#!/usr/bin/env python3
n, c, k = map(int, input().split())
a = sorted([int(input()) for i in range(n)])

ans = 0
busp = 0
machi = 0

for i in a:
    if busp == 0:
        busp += 1
        machi = i + k
        if busp >= c:
            ans += 1
            busp = 0
            machi = 0

    elif i <= machi:
        busp += 1
        if busp >= c:
            ans += 1
            busp = 0
            machi = 0

    elif i > machi:
        ans += 1
        busp = 1
        machi = i + k

if busp >= 1:
    ans += 1

print(ans)


Measured memory_bytes: 14064
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

  ll N;
  vector<vector<ll>> A(100000,vector<ll>(0));
  vector<ll> dp(100000);
void dfs(ll n){
  if(A.at(n).size()==0){
    dp.at(n)=0;
    return;
  }
  ll a=0,k=A.at(n).size();
  vector<ll> x(k);
  rep(i,k){
    dfs(A.at(n).at(i));
    x.at(i)=dp.at(A.at(n).at(i));
  }
  sort(all(x));
  rep(i,k){
    a=max(a,x.at(i)+k-i);
  }
  dp.at(n)=a;
  return;
}
  
  
int main(){
  cin >> N;
  rep(i,N-1){
    ll a;
    cin >> a;
    A.at(a-1).push_back(i+1);
  }
  dfs(0);
  cout << dp.at(0) << endl;
  
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

int main()
{
	ull a,b,c;
	cin >> a>>b>>c;

	if( a * c <= b ) cout << c << endl;
	else cout << b / a << endl;
	
	return 0;
}

Measured memory_bytes: 256
//Friend Suggestions

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int>par;
    UnionFind(int n){par=vector<int>(n,-1);}
    int root(int x){
        if(par[x]<0)return x;
        return par[x]=root(par[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(par[x]>par[y])swap(x, y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    bool same(int x,int y){return root(x)==root(y);}
    int size(int x){return -par[root(x)];}
};

signed main (){
    int n,m,k;cin>>n>>m>>k;
    graph fr(n),br(n);
    UnionFind fuf(n);
    rep(i,0,m){
        int a,b;cin>>a>>b;
        a--;b--;
        fuf.unite(a,b);
        fr[a].pb(b);
        fr[b].pb(a);
    }
    rep(i,0,k){
        int a,b;cin>>a>>b;
        a--;b--;
        br[a].pb(b);
        br[b].pb(a);
    }
    rep(i,0,n){
        int ans=fuf.size(i)-1;
        ans-=fr[i].size();
        for(auto j:br[i]){
            if(fuf.same(i,j))ans--;
        }
        cout<<max(ans,0LL)<<nnn;
    }
    return 0;
}

Measured memory_bytes: 15956
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string input;
    
    while(getline(cin, input), !cin.eof()){
        int a, b, c;
        int cnt = 0;
        sscanf(input.c_str(), "%d %d %d\n", &a, &b, &c);
        
        for(int i = a; i < b + 1; i++){
            if(c % i == 0){
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }
    return(0);
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int arr[n];
    vector<int> dp(n, INT_MAX);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
		for(int j = i + 1; j <= i + 2; j++) {
			if(j < n)
				dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
		}
	}
	cout << dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024