akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() 
{
	string s;
	cin >> s;
	char c1 = s[0] , c2 = s[1];
	if(c1==c2)
	{
		c2 = s[2];
		if(c1 == s[1] && c2 == s[3] && c1!=c2)
			cout << "Yes";
		else 
			cout << "No";
	}
	else if(c1 == s[2] && c2 == s[3])
		cout << "Yes";
	else if(c1 == s[3] && c2 == s[2])
		cout << "Yes";
	else 
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:01:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,k,a,b,i;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>k>>a>>b;
        fs(i,a,b+1)
        {
            if(i%k==0)
            {cout<<"OK";return 0;}
        }
        cout<<"NG";
    }
    return 0;
}












Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll A, B, K;

	cin >> A >> B >> K;

	if (A < K) {
		B -= (K - A);
		A = 0;
	}
	else {
		A -= K;
	}
	if (B < 0) B = 0;

	cout << A << ' ' << B << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, K;
    cin >> N >> K;

    cout << N-K+1 << "\n";
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int mat[3][3];
  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++)
      cin >> mat[i][j];
  int t;
  cin >> t;
  for(int k = 0; k < t; k++)
  {
    int x;
    cin >> x;
    for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++)
        if(mat[i][j] == x)
          mat[i][j] = -1;
  }
  bool can = true;
  for(int i = 0, j = 0; i < 3; i++)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  }
  can = true;
  for(int i = 0, j = 1; i < 3; i++)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  }
  can = true;
  for(int i = 0, j = 2; i < 3; i++)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  }
  can = true;
  for(int i = 0, j = 0; j < 3; j++)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  }
  can = true;
  for(int i = 1, j = 0; j < 3; j++)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  }
  can = true;
  for(int i = 2, j = 0; j < 3; j++)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  }
  can = true;
  for(int i = 0, j = 0; i < 3; i++, j++)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  } 
  can = true;
  for(int i = 0, j = 2; i < 3; i++, j--)
    if(mat[i][j] != -1)
    {
      can = false;
      break;
    }
  if(can)
  {
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector <ll> prime;
	vector <bool> sieve(1e6+10,false);
	for (int z=2;z<sieve.size();z++){
		if (sieve[z]) continue;
		prime.push_back(z);
		ll x= z;
		while (x < sieve.size()){
			sieve[x] = true;
			x += z;
		}
	}
	map <ll,ll> count;
	for (int z=0;z<prime.size();z++){
		while (n > 0 && n % prime[z] == 0){
			n /= prime[z];
			count[prime[z]]++;
		}
	}
	if (n > 1){
		count[n]++;
	}
	ll ans = 0;
	vector <ll> lol;
	lol.push_back(0);
	lol.push_back(1);
	for (int z=2;z<100;z++){
		lol.push_back(lol[lol.size()-1]+z);
	}
	for (ii i : count){
		ans += upper_bound(lol.begin(),lol.end(),i.second)-lol.begin()-1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4468
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        StringBuilder debug = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        int period = sc.nextInt();//D
        debug.append(period+"\n");

        int[] cost = new int[26];//c
        for (int i = 0;i<cost.length;++i)
        {
            cost[i] = sc.nextInt();
            debug.append(cost[i]+" ");
        }
        debug.append("\n");

        int[][] score = new int[period][26];//s
        for (int i = 0;i<score.length;++i)
        {
            for (int j = 0;j<score[i].length;++j)
            {
                score[i][j] = sc.nextInt();
                debug.append(score[i][j]+" ");
            }
            debug.append("\n");
        }

        int[] contestTypes = new int[period];//t
        for (int i = 0;i<contestTypes.length;++i)
        {
            contestTypes[i] = sc.nextInt() - 1;
            debug.append(contestTypes[i]+"\n");
        }
        //System.err.println(debug.toString());

        Map<Integer,Integer> lastDay = new HashMap<>();//contestType,lastDay
        for (int type = 0;type < 26;++type) lastDay.put(type,0);

        long satisfaction = 0L;
        for (int date = 0;date < period;++date)
        {
            satisfaction += score[date][contestTypes[date]];
            lastDay.put(contestTypes[date],(date+1));

            long minus = 0L;
            for (int type = 0;type < 26;++type)
            {
                minus += cost[type] * ((date+1) - lastDay.get(type));
            }
            satisfaction -= minus;
            System.out.println(satisfaction);
        }
        sc.close();
    }
}

Measured memory_bytes: 48320
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = new int[n + 2];
        for (int i = 1; i < n + 1; i++) a[i] = int.Parse(line[i -1]);
        a[n + 1] = a[0];
        var t = 0L;
        for (int i = 1; i <= n+1; i++) t += Math.Abs(a[i] - a[i - 1]);
        for (int i = 1; i <= n; i++)
        {
            if ((a[i - 1] <= a[i] && a[i] <= a[i + 1]) | (a[i - 1] >= a[i] && a[i] >= a[i + 1])) Console.WriteLine(t);
            else
            {
                var ret = t - Math.Abs(a[i - 1] - a[i]) - Math.Abs(a[i] - a[i + 1]) + Math.Abs(a[i - 1] - a[i + 1]);
                Console.WriteLine(ret);
            }
        }
    }
}

Measured memory_bytes: 23900
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main() {
	/*int N, K;
	string S;
	cin >> N >> K >> S;
	S[K - 1] = tolower(S[K - 1]);
	cout << S;*/


	/*int s;
	cin >> s;
	int L = s / 100;
	int R = s % 100;*/




	double N, K;
	cin >> N >> K;
	double ret = 0, n, t;
	int p;
	rep(i, N + 1) {
		if (i == 0) {
			continue;
		}
		p = 0;
		n = K;
		while (n > i) {
			n /= 2;
			p++;
		}
		if (p == 0) {
			t = 1;
		}
		else {
			t = 1;
			rep(i, p) {
				t /= 2;
			}
		}

		ret += 1 / N * t;
	}

	cout << setprecision(10) << ret;


	return 0;
}

Measured memory_bytes: 256
/*
Wai u read my code xD
*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;


void solve()
{
    string s; cin >> s; int a = 0, b = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i]=='S') a++;
        else
        {
            if (a>0) a--;
            else b++;
        }
    }
    nout(a+b);
}

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

Measured memory_bytes: 720
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)
 
for i in range(H):
    up[i] = (up[i-1] + 1) * S[i]
    down[-i-1] = (down[-i] + 1) * S[-i-1]

for i in range(W):
    left[:, i] = (left[:, i-1] + 1) * S[:, i]
    right[:, -i-1] = (right[:, -i] + 1) * S[:, -i-1]

print(np.max(up+down+left+right)-3)

Measured memory_bytes: 219860
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 500005;
const ll mod = 998244353;
const double PI = acos(-1.0);

struct no
{
	int le;
	int ri;
	int max_v;
}node[4 * maxn];

void build(int root, int le, int ri, int v)
{
	if (le == ri)
	{
		node[root].le = le;
		node[root].ri = ri;
		node[root].max_v = v;
		return;
	}
	int mid = (le + ri) >> 1;
	build(root << 1, le, mid, v);
	build((root << 1) | 1, mid + 1, ri, v);
	node[root].le = le;
	node[root].ri = ri;
	node[root].max_v = v;
}

int query(int root, int le, int ri)
{
	if (node[root].le == le&&node[root].ri == ri)
	{
		return node[root].max_v;
	}
	int mid = (node[root].le + node[root].ri) >> 1;
	if (mid >= ri)
	{
		return query(root << 1, le, ri);
	}
	else if (mid + 1 <= le)
	{
		return query(root << 1 | 1, le, ri);
	}
	else
	{
		return max(query(root << 1, le, mid), query(root << 1 | 1, mid + 1, ri));
	}
}

void update(int root, int k, int v)
{
	if (node[root].le == k&&node[root].ri == k)
	{
		node[root].max_v = v;
		return;
	}
	int mid = (node[root].le + node[root].ri) >> 1;
	if (k <= mid)
	{
		update(root << 1, k, v);
	}
	else
	{
		update(root << 1 | 1, k, v);
	}
	node[root].max_v = max(node[root << 1].max_v, node[root << 1 | 1].max_v);
}

int n, k;
int pos[maxn], out[maxn], res[maxn], res2[maxn];
vector<int>ed[maxn];
priority_queue<int>que;

void solve()
{
	int i, j, m;
	sa(n), sa(k);
	repp(i, 1, n)
	{
		sa(m);
		pos[m] = i;
	}
	
	build(1, 1, n, -INF);
	repp(i, 1, n)
	{
		m = query(1, pos[i], min(n, pos[i] + k - 1));
		if (m != -INF)
		{
			int x = m;
			out[pos[x]]++;
			ed[pos[i]].push_back(pos[x]);
		}
		update(1, pos[i], i);
	}

	build(1, 1, n, -INF);
	for (i = n; i >= 1; i--)
	{
		m = query(1, pos[i], min(n, pos[i] + k - 1));
		if (m != -INF)
		{
			int x = -m;
			out[pos[i]]++;
			ed[pos[x]].push_back(pos[i]);
		}
		update(1, pos[i], -i);
	}
	
	repp(i, 1, n)
	{
		if (out[i] == 0)
		{
			que.push(i);
		}
	}
	for (i = n; i >= 1;i--)
	{
		int v = que.top();
		que.pop();
		res[v] = i;
		res2[i] = v;
		rep(j, 0, ed[v].size())
		{
			out[ed[v][j]]--;
			if (out[ed[v][j]] == 0)
			{
				que.push(ed[v][j]);
			}
		}
	}
	repp(i, 1, n)
	{
		printf("%d\n", res[i]);
	}
}

int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 52480
using AtCoderBeginnerContest146.Questions;
using AtCoderBeginnerContest146.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest146.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var s = inputStream.ReadLine();
            yield return string.Concat(s.Select(c => (char)((c - 'A' + n) % 26 + 'A')));
        }
    }
}


namespace AtCoderBeginnerContest146
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest146.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest146.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11280
#include<iostream>
#include<cmath>

int main()
{
    int n;
    int t, a;
    float h[1000];

    std::cin>>n>>t>>a;
    
    for(int i; i<n;i++)
    {
        std::cin>>h[i];
    }

    float point = t - 0.006 * h[0];
    float new_point;
    int num;
    for(int i=1;i<n;i++)
    {
        new_point = t - 0.006 * h[i];
        if(std::abs(new_point-a) <= std::abs(point-a))
        {
            point = new_point;
            num = i;
        }
    }

    std::cout<<num + 1<<"\n";
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int n, k, ans;

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

    if ( k > 1 ) {
        ans = n - k;
    } else {
        ans - 0;
    }
    
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val decimal = listOf(0,1,2,3,4,5,6,7,8,9)
    val N = sc.nextInt()
    val K = sc.nextInt()

    var D = listOf<Int>()
    for(i in 0..(K-1)){
        D += sc.nextInt()
    }
    D = D.distinct()
    var OK = decimal.filterNot{
            it in D
        }
    for(i in N..100000){
        if(i.toString().filterNot{
                    it.toString().toInt() in OK
                }.isEmpty()){
            println(i)
            return
        }
    }
}

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

long long modPow(long long a, long long n, long long waru) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = res * a % waru; }
        a = a * a % waru;
        n >>= 1;
    }

    return res;
}

int main() {
    //
    long long waru = 998244353;
    long long num;
    long long kekka = 1;

    map<long long, long long> m;

    cin >> num;
    for (int i = 0; i < num; i++) {
        long long tmp;
        cin >> tmp;
        m[tmp]++;

        if (i == 0 && tmp != 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    if (m[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    long long cnt = 0;  //飛ばし対策(0，1，2，4ときたらエラー(4は物理的に不可能))
    long long pre = 1;
    for (auto itr : m) {
        if (itr.first == 0) continue;

        if (cnt == itr.first - 1) {
            long long tmp = itr.second;
            kekka *= modPow(pre, tmp, waru);
            kekka = kekka % waru;
            pre = tmp;
            cnt++;
        } else {
            // 0,1,2,3と順番に来なかったのでエラー
            cout << 0 << endl;
            return 0;
        }
    }

    cout << kekka << endl;
    //
}


Measured memory_bytes: 9828
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here

        Scanner scan = new Scanner(System.in);
int D=scan.nextInt();
        int T=scan.nextInt();
        int S=scan.nextInt();

        if(T*S>=D){System.out.println("Yes");}
        else{System.out.println("No");}





        }

}


Measured memory_bytes: 27064
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    SS(ll,n,m)
    vvl jobs(m);
    rep(i,n){
        SS(int,a,b)
        if(a>m)continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans=0;
    for(int i=m-1;i>=0;i--){
        for(int b:jobs[i])q.push(b);
        if(!q.empty()){//空で無ければ優先順位1の仕事を取る
            ans+=q.top();
            q.pop();
        }
    }
    p(ans);
}

Measured memory_bytes: 5632
import java.util.Scanner;

/**
 * Easy Linear Programming.
 */
public class Main {
    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var a = scanner.nextInt();
        var b = scanner.nextInt();
        var c = scanner.nextInt();
        var k = scanner.nextInt();

        var sum = Math.min(k, a);
        var remaining = k - a - b;
        sum += remaining > 0 ? -1 * remaining : 0;
        System.out.println(sum);
    }
}


Measured memory_bytes: 35824
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 1e6+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

const int N = 25;

int n, m;
char a[N][N];
int vis[N][N], dist[N][N];
int dx[]={-1, +1, 0, 0};
int dy[]={0, 0, +1, -1};

int bfs(int x, int y)
{
	memset(vis, 0, sizeof(vis));
	queue<pi>q;
	q.push({x, y});
	vis[x][y]=1;
	dist[x][y]=0;
	int mx = 0;
	while(!q.empty()){
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int dir=0;dir<4;dir++){
			int nx=x+dx[dir];
			int ny=y+dy[dir];
			if(nx<0 || ny<0 || nx>=n || ny>=m || a[nx][ny] == '#')
				continue;
			if(!vis[nx][ny]){
				dist[nx][ny]=dist[x][y]+1;
				mx = max(mx, dist[nx][ny]);
				vis[nx][ny]=1;
				q.push({nx, ny});
			}
		}
	}
	return mx;
}


int main()
{
	ios::sync_with_stdio(false);

	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(a[i][j] == '.'){
				ans = max(ans, bfs(i, j));
			}
		}
    }

	cout << ans <<endl ;

	return 0;
}


Measured memory_bytes: 71936
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

int main() {
    int N, K;
    cin >> N >> K;
    set<int> s;
    s.insert(1);
    REP (i, 0, N) {
        set<int> tmp;
        for (auto i : s) {
            tmp.insert(i * 2);
            tmp.insert(i + K);
        }
        s = tmp;
    }
    cout << *s.begin() << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{

    internal class Solution
    {
        public int N;
        public int[] D;

        public void Run()
        {
            N = Input.ReadInt();
            D = new int[N];
            for (int i = 0; i < N; i++)
            {
                D[i] = Input.ReadInt();
            }

            Console.WriteLine(D.Distinct().Count());
        }

    }

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL r[4040], g[4040], b[4040]; // 'R', 'G', 'B' の 出現位置.
LL rCum[4040], gCum[4040], bCum[4040]; // 累積和.

int main(){
    
    // 1. 入力情報.
    int N;
    char c[4040];
    scanf("%d %s", &N, c);
    
    // 2. 'R', 'G', 'B' の 出現位置を保存.
    rep(i, N){
        if(c[i] == 'R') r[i]++;
        if(c[i] == 'G') g[i]++;
        if(c[i] == 'B') b[i]++;
    }
    
    // 3. 累積和.
    rep(i, N){
        rCum[i + 1] = rCum[i] + r[i];
        gCum[i + 1] = gCum[i] + g[i];
        bCum[i + 1] = bCum[i] + b[i];
    }
    
    // 4. 条件を満たす組を計算.
    // 中央の文字 を 変えながら, 集計.
    LL ans = 0;
    repx(i, 1, N - 1){
        char mc = c[i];
        // 左右の文字数.
        int l = i, r = N - 1 - i;
        // 'R' の 場合.
        if(mc == 'R'){
            // 'G' < 'R' < 'B'.
            ans += gCum[i] * (bCum[N] - bCum[i]);
            // 'B' < 'R' < 'G'.
            ans += bCum[i] * (gCum[N] - gCum[i]);
            // 中央の文字から同じ距離で, 異なる文字('G', 'B')だったら, 減算.
            repx(j, 1, min(l, r) + 1){
                if(c[i - j] == 'G' && c[i + j] == 'B') ans--;
                if(c[i - j] == 'B' && c[i + j] == 'G') ans--;
            }
        }
        
        // 'G' の 場合.
        if(mc == 'G'){
            // 'R' < 'G' < 'B'.
            ans += rCum[i] * (bCum[N] - bCum[i]);
            // 'B' < 'G' < 'R'.
            ans += bCum[i] * (rCum[N] - rCum[i]);
            // 中央の文字から同じ距離で, 異なる文字('R', 'B')だったら, 減算.
            repx(j, 1, min(l, r) + 1){
                if(c[i - j] == 'R' && c[i + j] == 'B') ans--;
                if(c[i - j] == 'B' && c[i + j] == 'R') ans--;
            }
        }
        
        // 'B' の 場合.
        if(mc == 'B'){
            // 'R' < 'B' < 'G'.
            ans += rCum[i] * (gCum[N] - gCum[i]);
            // 'G' < 'B' < 'R'.
            ans += gCum[i] * (rCum[N] - rCum[i]);
            // 中央の文字から同じ距離で, 異なる文字('R', 'G')だったら, 減算.
            repx(j, 1, min(l, r) + 1){
                if(c[i - j] == 'R' && c[i + j] == 'G') ans--;
                if(c[i - j] == 'G' && c[i + j] == 'R') ans--;
            }
        }
    }
    
    // 5. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += i * (n / i) * (n / i + 1);
  }
  ans /= 2;
  cout << ans << '\n';
  return 0;
}

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

int main(){
	int a[100];
	int n;
	cin >> n;
	for(int i=0; i<n; i++)cin >> a[i];
	for(int i=n-1; i>=1; i--)cout << a[i] << " ";
	cout << a[0] << "\n";
	return 0;
	}

Measured memory_bytes: 1168
import sys
import bisect
input = sys.stdin.readline

n = int(input())


colour_list = [-int(input())]
c = len(colour_list)


for i in range(n-1):
    a = -int(input())
    b = bisect.bisect(colour_list,a)
    if b != c:
        colour_list[b] = a
    else:
        colour_list.append(a)
        c += 1

print(c)


Measured memory_bytes: 46684
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	string s;
	cin >> s;

	if (count(all(s), '7'))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  char s;
  cin >> s;

  if(isupper(s)) cout << "A" << endl;
  else cout << "a" << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
int ans;
int n,k;
int main(){
	cin>>n>>k;
	while(n){
		ans++;
		n/=k;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]_){int n,i,j,k,l,a[]=new int[51];for(n=0;n<51;n++){a[n]=0;for(i=0;i<10;i++)for(j=0;j<10;j++)for(k=0;k<10;k++)for(l=0;l<10;l++){if(i+j+k+l>n)break;if(i+j+k+l==n){a[n]++;break;}}}for(Scanner S=new Scanner(System.in);S.hasNext();System.out.println(a[S.nextInt()]));}}

Measured memory_bytes: 12000
#include <stdio.h>
 
int main()
{
    int card[4][13]={0};
    int i, j, n, num;
    char suit;
    const char suits[4]={'S', 'H', 'C', 'D'};
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf(" %c %d", &suit, &num);
        if     (suit=='S') card[0][num-1]=1;
        else if(suit=='H') card[1][num-1]=1;
        else if(suit=='C') card[2][num-1]=1;
        else if(suit=='D') card[3][num-1]=1;
    }
 
    for(i=0; i<4; i++) {
        for(j=0; j<13; j++) {
            if(card[i][j]==0) printf("%c %d\n", suits[i], j+1);
        }
    }
    return 0;
}

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

int f[100003];
int n,m,x;
int main()
{
	scanf("%d %d", &n,&m);
	f[0]=1;
	f[1]=1;
	for (int i=1;i<=m;++i)
	{
		scanf("%d",&x);
		f[x]=-1;
	}
	if (f[1]==-1) f[1]=0;
	for (int i=2;i<=n;++i)
	{
		if (f[i]==-1)f[i]=0;else f[i]=(f[i-1]+f[i-2])%1000000007;
	}
	printf("%d\n",f[n]);
	return 0;
}


Measured memory_bytes: 640
class String
  def to_ia
    self.split(/\s/).map {|s| s.to_i}
  end
end

def create_memo(ary)
  memo = [Array.new(2001)] + ary.map {|i| Array.new(2001)}
  ary.each_with_index do |val, i|
    i += 1
    (1..2000).each do |j|
      res = false
      if val == j
        res = true
      elsif memo[i-1][j]
        res = true
      elsif j-val > 0 and memo[i-1][j-val]
        res = true
      end
      memo[i][j] = res
    end
  end
  memo
end

def solve(ary, dest)
  @memo ||= create_memo(ary)
  @memo.each do |row|
    return true if row[dest]
  end
  false
end

lines = STDIN.read.split(/\n/)
ary = lines[1].to_ia
lines[3].to_ia.each do |i|
  puts solve(ary, i) ? "yes" : "no"
end

Measured memory_bytes: 8980
lst1 = [4,6,9,11]
lst2 = [2]
lst3 = [1,3,5,7,8,10,12]
x,y = map(int,input().split())
if x in lst1 and y in lst1:
    print('Yes')
elif x in lst2 and y in lst2:
    print('Yes')
elif x in lst3 and y in lst3:
    print('Yes')
else:
    print('No')

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

int n, a[100001], dp[100001];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	rep(i, n) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

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

long long int dp[3001];
long long int psum[3001];
int n;

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

    cin >> n;
    long long int sum = 0;
    for(int i=0;i<n;i++)
    {
        int t;
        cin >> t;
        sum += t;
        psum[i+1] = psum[i] + t;
    }

    for(int l=1;l<=n;l++)
    {
        for(int i=0;i+l<=n;i++)
        {
            dp[i] = psum[i+l] - psum[i] - min(dp[i],dp[i+1]);
        }
    }

    long long int Y = sum - dp[0];
    long long int X = dp[0];
    cout << X - Y << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

void Print() { cout << endl; }
template <class Head, class... Args> void Print(Head &&head, Args&&... args)
{
    cout << head;
    Print(args...);
}

#define Repeat(x, i, j) for (size_t x = i; x < j; ++x)

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif


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

    if (N == 0)
    {
        cout << "0" << endl;
        return 0;
    }

    // { 1, -2, 4, -8, 16, -32, 64, ...
    vector<long> B(1, 1);
    while ((N > 0) ? (B.back() < N) : (B.back() > N))
        B.push_back(B.back() * -2);
    Dumps(B);

    // { 1, (-2),  (1+4),  (-2-8), (1+4+16), (-2-8-32), (1+4+16+64), ...
    vector<long> S(B.size(), 0);
    S[0] = B[0];
    S[1] = B[1];
    for (int i = 2; i < B.size(); ++i)
        S[i] = S[i - 2] + B[i];

    int i = 0;
    for (; not ((S[i] > 0) == (N > 0) and abs(S[i]) > abs(N)); ++i);
    Dump(i);

    string out;
    for (; i >= 0; --i)
    {
        if (N == 0)
        {
            out += '0';
            continue;
        }
        
        if ((S[i] > 0) == (N > 0))
        {
            if ((i <= 1) or (abs(N) > abs(S[i - 2])))
            {
                N -= B[i];
                out += '1';
            }
            else
                out += '0';
        }
        else
        {
            if ((i == 0) or (abs(N) > abs(S[i - 1])))
            {
                N -= B[i];
                out += '1';
            }
            else
                out += '0';
        }
    }

    cout << out << endl;
}


Measured memory_bytes: 256
n=gets.chomp.to_i
f=true
p_x=0
p_y=0
p_t=0
n.times do |i|
  t,x,y=gets.chomp.split.map(&:to_i)
  dis=(p_x-x).abs+(p_y-y).abs
  time=t-p_t
  z=time-dis
  if z<0 || z.odd? then
    f=false
  end
  p_x=x
  p_y=y
  p_t=t
end
puts f ? 'Yes' : 'No'

Measured memory_bytes: 1788
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

su = b[a[0] - 1]
for i in range(1, len(a)):
    su += b[a[i] - 1]
    if (a[i] == a[i - 1] + 1):
        su += c[a[i - 1] - 1]

print(su)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #include<algorithm>
    #include<cmath>
    #include<climits>
    using namespace std;
    typedef long long int lli;
    typedef vector<int> vi;
    typedef vector<long long int> vlli;
    typedef pair<int,int> pii;
    typedef pair<long long int,long long int> plli;
    typedef vector< vi > vvi ;
    typedef vector< vlli > vvlli  ;
    #define fi(i,a,b) for(int i=a;i<=b;i++)
    #define flli(i,a,b) for(long long int i=a;i<=b;i++)
    #define bi(i,a,b) for(int i=a;i>=b;i--)
    #define blli(i,a,b) for(long long int i=a;i>=b;i--)
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define all(x) x.begin(),x.end()
    #define sz(x) x.size()
    #define pi 2*acos(0.0)
    #define pb push_back
    #define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
    #define present(v,num) (v.find(num)!=v.end())
    #define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
    #define pq priority_queue
    #define mp make_pair
    const int inf=INT_MAX;
    const lli INF =LLONG_MAX;
    const lli mod = 1e9+7;
    int main() {
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        fast;
        lli n;cin>>n;
        vlli a(n);flli(i,0,n-1)cin>>a[i];
        lli count=0;
        flli(i,0,n-1)if(a[i]%2!=0 && i%2==0)count++;
        cout<<count;
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
        return 0;
    }

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

int main(){
	int x,y,s;
	cin>>x>>y>>s;
	while((x|y|s)!=0){
		int a=1,b=s-1;
		int top=0;
		while(a<=b){
			int a_max= (double)a*100/(100+x);
			int b_max= (double)b*100/(100+x);
			while((double)a_max*(100+x)/100 < a+1) a_max++;
			while((double)b_max*(100+x)/100 < b+1) b_max++;
			a_max--; b_max--;
			if((int)((double)a_max*(100+x)/100) == a && (int)((double)b_max*(100+x)/100) == b ){
				int price=(int)((double)a_max*(100+y)/100) + (int)((double)b_max*(100+y)/100);
				if(price>top) top=price;
			}
			a++; b--;
		}
		cout<<top<<endl;
		cin>>x>>y>>s;
	}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdlib>
#include <map>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string s;
    int g, g_prime, p, l, ans;
    bool flag;
    g = 0;
    g_prime = 0;
    p = 0;
    ans = 0;
    flag = false;
    cin >> s;
    l = s.length();
    // cout << l << endl;
    for (int i=0; i<l; ++i){
        if(s[i] == 'g'){
            g++;
        }
        else if(s[i] == 'p'){
            p++;
        }
    }
    ans = (g - p) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 512
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, r; cin >> n >> r;
	r += max(0LL, 10 - n) * 100;
	cout << r << endl;
}

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

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

int main(){
  int64_t N, M;
  cin >> N >> M;

  vector<pair<int64_t, string>> atcoder;
  for(int64_t i=0; i<M; i++){
    int64_t j;
    string a;
    cin >> j >> a;
    atcoder.push_back(make_pair(j, a));
  }

  int64_t seitousuu = 0;
  int64_t gotou = 0;

  vector<vector<int64_t>> kotae(N, vector<int64_t>(2,0));
  for(int64_t i=0; i<M; i++){
    int64_t mondai = atcoder.at(i).first - 1;
    if(atcoder.at(i).second == "AC" && kotae.at(mondai).at(0) == 0){
      kotae.at(mondai).at(0) = 1;
      seitousuu++;
    }else if(atcoder.at(i).second == "WA" && kotae.at(mondai).at(0) == 0){
      kotae.at(mondai).at(1) += 1;
      //gotou++;
    }
  }

  for(int64_t i=0; i<N; i++){
    if(kotae.at(i).at(0)==1) gotou += kotae.at(i).at(1);
  }

  cout << seitousuu << " " << gotou;
}

Measured memory_bytes: 12016
#
# File    : C.rb
# Author  : Kazune Takahashi
# Created : 2018-6-23 21:01:02
# Powered by Visual Studio Code
#

n, k = gets.chomp.split(" ").map{|i| i.to_i}
a = gets.chomp.split(" ").map{|i| i.to_i}

ind = 0

for i in 0...a.size
  if (a[i] == 1)
    ind = i
    break
  end
end

if n == k
  puts 1
else
  puts 1 + (n - k + k - 2) / (k - 1)
end

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  preprocess();
  string s; cin>>s;
  int n = (int)s.length();
  vi ans(n);
  rep(i,1,n) {
    if(s[i] == 'L' && s[i-1] == 'R') {
      int p1 = i, p2 = i-1;
      while(p1<n && s[p1] == 'L') p1++;
      while(p2>=0 && s[p2] == 'R') p2--;
      int l = (p1-i), r = (i-1-p2);
      debug(l, r);
      if(r>l) {
        ans[i-1] = (l+r+1)/2;
        ans[i] = (l+r)/2;
      }
      else {
        ans[i] = (l+r+1)/2;
        ans[i-1] = (l+r)/2;
      }
      if(max(l, r)%2 == 0)swap(ans[i], ans[i-1]);
    }
  }
  rep(i,0,n) cout<<ans[i]<<" ";
  cout<<endl;
}



Measured memory_bytes: 1104
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> PI;

//セグメントツリー
//初期化時にメモリーアクセス違反おこすと、変なところ書き換えられて思いがけない変数の書き換えが発生する。
class segtree{
	PI a[(1<<21)-1];		//ID,score
	int dep;				//distance from root to leaf

public:
	segtree( int depth, int x ){
		int i;
		dep = depth;
		for( i = 0; i < (1 << dep )-1; i++ )
			a[i] = PI( 0,x );
		
		for( i = (1 << dep )-1; i < (1 << (dep+1))-1; i++ )
			a[i] = PI( i-(1 << dep )+1 ,x );
		//printf("dep = %d\n",dep);
	}

	void add( int index, int num ){
		int x = (1 << dep) + index - 1;
		a[x].second += num;
		
		while( x > 0 ){
			//printf("dep = %d\n",dep);
			int oya = (x-1)/2;
			if( (a[oya*2+1].second > a[oya*2+2].second) || (a[oya*2+1].second == a[oya*2+2].second && a[oya*2+1].first < a[oya*2+2].first) )
				a[oya] = a[oya*2+1];
			else
				a[oya] = a[oya*2+2];

			x = oya;
		}
	}

	//x <= i <= yについて、a[i].secondが最大となるような、a[i]を返す。a[i].secondが同じならa[i].firstが小さいほうを優先する。
	//今回の場合は根しか見なくても良い！
	PI solve( int x=-1,int y=-1,int depth=0,int index=0 )
	{
		if( x==-1 && y==-1 )
			return a[0];

		int left = (1<<depth)-1+(x>>(dep-depth));
		int right = (1<<depth)-1+(y>>(dep-depth));
		
		if( depth > dep )
			return PI(100000000,-1000000001);
		if( index < left || index > right )
			return PI(100000000,-1000000001);
		if( depth == dep || (index >= left && index <= right) )
			return a[index];

		PI L = solve( x,y,depth+1,index*2+1 );
		PI R = solve( x,y,depth+1,index*2+2 );
		if( L.second > R.second || (L.second == R.second && L.first < R.first ) )
			return L;
		return R;
	}
};

int data[1000000];		//テレビに映った時間[ID]を格納

int n,r,l;
int d,t,x;
segtree seg(20,0);

int main()
{
	int i;
	int id = 0,bt = 0;

	cin >> n >> r >> l;
	for( i = 0; i < r;i++ )
	{
		cin >> d >> t >> x;
		data[id] += t-bt;
		d--;

		/*for( int j = 0;j < n;j++ ){
			printf("id=%d score=%d time=%d\n",j+1,seg.solve(j,j).second,data[j]);
		}*/

		seg.add( d, x );
		id = seg.solve().first;
		bt = t;
	}
	data[id] += l-bt;

	PI ans = PI(1,0);	//id,写った時間
	for( i = 0;i < n;i++ ){
		if( ans.second < data[i] || ( ans.first > i+1 ) ){
			ans.first = i+1;
			ans.second = data[i];
		}
	}

	cout << ans.first << endl;
	return 0;
}

Measured memory_bytes: 19584
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll N, Q;
	cin >> N >> Q;
	ll Query[200200];
	ll X[200200];
	for(int i = 0; i < Q; i++){
		cin >> Query[i] >> X[i];
	}
	
	ll Min1 = N;
	ll Min2 = N;
	ll Movable1[200200];
	ll Movable2[200200];
	for(int i = 0; i <= N; i++){
		Movable1[i] = -1;
		Movable2[i] = -1;
	}
	ll ans = 0;
	for(int i = 0; i < Q; i++){
		if(Query[i] == 1){
			if(Movable1[X[i]] > 0){
				ans += Movable1[X[i]];
				//continue;
			}else{
				ans += Min2-2;
			}
			if(X[i] < Min1){
				for(int j = X[i]+1; j < Min1; j++){
					//cout << "a"<< Min2-2 << " " << j << endl;
					Movable1[j] = Min2-2;
				}
			}
			Min1 = min(Min1, X[i]);
		}else{
			if(Movable2[X[i]] > 0){
				ans += Movable2[X[i]];
				//continue;
			}else{
				ans += Min1-2;
			}
			if(X[i] < Min2){
				for(int j = X[i]+1; j < Min2; j++){
					Movable2[j] = Min1-2;
				}
			}
			Min2 = min(Min2, X[i]);
		}
	}
	ans = (N-2) * (N-2) - ans;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 9836
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

const ll MX = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;

vector<ll> as;

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

    bool has_zero = false;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
        if (as[i] == 0) {
            has_zero = true;
        }
    }

    if (has_zero) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for (auto a : as) {
        if (ans > MX / a) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3980
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
    public static void main(String[] args) {
	try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
	    String s = br.readLine();
	    int b = s.length() - s.replaceAll("1","").length();
	    System.out.println(b);
	} catch(IOException e) {
	    e.printStackTrace();
	}
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    int n; cin>>n;
    int A[n];
    for(int i=0;i<n;i++) cin>>A[i];
    int dp[n]={0};
    dp[0]=0; dp[1]=abs(A[1]-A[0]);
    for(int i=2;i<n;i++){
        int op1=abs(A[i]-A[i-1]);
        int op2=abs(A[i]-A[i-2]);
        dp[i]=min(dp[i-1]+op1,dp[i-2]+op2);
    }
    cout<<dp[n-1];
    
}

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

int main() {
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	vector<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];
	
	auto good = [&](long long mask) {
		for (int i = 0; i < n; ++i) {
			vector<int> can(51, false);
			can[a[i]] = true;
			for (int u = 50; u >= 1; --u) if (can[u]) {
				for (int j = 1; j <= 50; ++j) if ((mask >> j) & 1ll) {
					can[u % j] = true;
				}
			}
			if (!can[b[i]]) return false;
		}
		return true;
	};
	
	long long mask = (1ll << 51) - 1;
	if (!good(mask)) return cout << -1 << '\n',0;
	
	for (int i = 50; i >= 0; --i) {
		if (good(mask ^ (1ll << i))) mask ^= (1ll << i);
	}
	cout << mask << '\n';
}

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

#define ll long long int
using namespace std;
void Solve()
{
    ll a, b, x;

    while(cin >> a)
    {
        ll counter = 0;
        cin  >>  b >> x;
        ll up = a  - (a%x);
        ll down = b - (b%x);
        down = ((down - up)/x);
        if(a%x == 0) down++;
        cout << down << '\n';
    }

}

int main()
{
    //int t;
    //cin >> t;
  //  while (t--)
    {
        Solve();
       // cout << '\n';
    }
    return 0;
}



Measured memory_bytes: 3632