akhauriyash/Code-Regression huggingface dataset:
S = input()
if S == 'SSS':print(0)
if S == 'SSR':print(1)
if S == 'SRS':print(1)
if S == 'SRR':print(2)
if S == 'RSS':print(1)
if S == 'RSR':print(1)
if S == 'RRS':print(2)
if S == 'RRR':print(3)

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
  
  int n;
  cin>>n;
  
  string s;
  vector<P> v;
  
  int si=-1,gi=-1,flag=0;
  
  for(int i=0;i<n;i++){
    cin>>s;

    int l=0,r=0,cnt=0;
    
    for(int j=0;j<s.size();j++){
      
      if(s[j]=='(')cnt++;
      else{
	if(!cnt)l++;
	else cnt--;
      }

    }
    r=cnt;
    
    if(l||r){
      flag=1;
      v.push_back(P(l,r));

      if(!l)si=v.size()-1;
      if(!r)gi=v.size()-1;
    }
    
  }
  
  vector<bool> used(v.size(),0);
  
  bool ans=true;

  if(si!=-1&&gi!=-1){
    used[si]=used[gi]=true;
    
    int cnt=v.size()-2,L=v[si].second,pL=L;
    
    while(cnt--){
      int maxL=-1,maxl=-1,idx=-1;
      
      for(int i=0;i<v.size();i++){
	if(used[i])continue;

	if(L-v[i].first<0)continue;
		
	if(maxL<L-v[i].first+v[i].second){
	  maxL=L-v[i].first+v[i].second;
	  maxl=v[i].first;
	  idx=i;
	}
	
      }
      
      if(idx==-1){
	ans=false;
	break;
      }

      if(pL>maxL){
	maxL=maxl=idx=-1;
	
	for(int i=0;i<v.size();i++){
	  if(used[i])continue;
	
	  if(L-v[i].first<0)continue;

	  if(maxl<v[i].first){
	    maxL=L-v[i].first+v[i].second;
	    maxl=v[i].first;
	    idx=i;
	  }

	}


      }
      
      L=maxL;
      pL=L;
      
      used[idx]=true;
      
    }
    
    if(ans&&!(L-v[gi].first==0))  ans=false;
    
  }else if(flag)ans=false;
  
  if(!ans)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 3212
#include <stdio.h>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, i;
    cin >> n >> m;
    vi val(n);
    priority_queue <ll> queue;
    for (i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        queue.push(tmp);
    }
    for (i=0;i<m;i++){
        ll v = queue.top() / 2; queue.pop();
        queue.push(v);
    }
    ll sum = 0;
    for (i=0;i<n;i++){
        ll v = queue.top(); queue.pop();
        sum += v;
    }
    cout << sum << endl;
}


Measured memory_bytes: 1784
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


x,n=MAP()
if n==0:
    print(x)
    exit()
a=LI()
l=-1;r=-1
for i in range(101):
    if x-i not in a:
        l=x-i
        break
for i in range(101):
    if x+i not in a:
        r=x+i
        break
if abs(r-x)>=abs(l-x):
    print(l)
else:
    print(r)


Measured memory_bytes: 9352
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, k, s = 0; scanf("%d %d", &n, &k);
  v1i v(n); rep(i, n) scanf("%d", &v[i]);
  map<int, int> m; priority_queue<int> p;
  rep(i, n) m[v[i]]++;
  for(auto q: m) p.push(q.se);
  rep(i, k){
    if(p.empty()) break;
    s += p.top();
    p.pop();
  }
  printf("%d\n", n-s);
  return 0;
}

Measured memory_bytes: 11516
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    long cnt = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j < n;j++){
            if(i*j<n)
                cnt++;
            else
                break;
         }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
            #include <vector>
        	#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
            using namespace std;
            	vector<int >v;
            int main()
            {
            	int n,k,q,freq[100005]={},x,y=0,arr[100005]={};
            	cin>>n>>k>>q;
            	memset(freq,0,sizeof(freq));
            	for(int i=0;i<q;i++){
            		cin>>x;
            		freq[x]++;
            		y++;
            	}

            	for(int i=1;i<=n;i++){
            		if((freq[i]+(k-y))>0)
            			cout<<"Yes"<<endl;
            		else
            			cout<<"No"<<endl;
            	}

            }


Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d %d", $n, $k);

$okashi = array();
for ($i=1; $i <= $n; $i++) {
  $okashi[$i] = 0;
}

for ($i=0; $i < $k; $i++) {
  fscanf(STDIN, "%d", $d);
  $as = explode(' ', trim(fgets(STDIN)));
  foreach ($as as $a) {
    $okashi[$a]++;
  }
}

$cnt = 0;
foreach ($okashi as $o) {
  if ($o == 0) {
    $cnt++;
  }
}

echo $cnt;


Measured memory_bytes: 16180
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace at
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            var c = Console.ReadLine();

            var cnt = 0;

            for (int i = 0; i < n; i++)
            {
                if(a[i] == b[i] && b[i] == c[i])
                {
                    cnt = cnt + 0;
                }
                else if(a[i] == c[i] && a[i] != b[i])
                {
                    cnt = cnt + 1;
                }
                else if(a[i] == b[i] && b[i] != c[i])
                {
                    cnt = cnt + 1;
                }
                else if(a[i] != b[i] && b[i] == c[i])
                {
                    cnt = cnt + 1;
                }
                //if(a[i] != b[i] && b[i] != c[i])
                else
                {
                    cnt = cnt + 2;
                }

            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11092
def main():

    N = int(input())
    cnt = 0
    ans = "No"

    for i in range(N):
        D1, D2 = map(int, input().split())
        if D1 == D2:
            cnt = cnt + 1
        else:
            cnt = 0

        if cnt == 3:
            ans = "Yes"

    print(ans)

main()

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ret = 0;
		if(a != 0) {
			long keisu = n/(a+b);
			long mod = n % (a+b);
			ret = a*keisu + (mod>a ? a : mod);
		}
		
		System.out.println(ret);
	}
}


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

using namespace std;

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

const ld EPS = 1e-9;
const ld PI = acos(-1.0);
const int INF = (int)1e9 + 5;
const ll LINF = (ll)1e18 + 5;

bool eq(double a, double b) {
	return fabs(a - b) < EPS;
}

template<class T>
T sqr(const T & x) { return x * x; }

template<class T> 
ll abs(const T & x) { return x < 0 ? -x : x; }

template<class T>
ll myround(const T & x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T> 
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
		os << *it;
		if ((it + 1) != v.end()) os << ", ";
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const pair<P, Q> & p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<class T> 
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

#define all(a) (a).begin(), (a).end()

const int N = 2020;

int n, x;
int startCost[N], cost[N], oldCost[N];

int main() {
	srand(time(0));
#ifdef LOCAL 
	freopen("input.txt", "r", stdin);
#else
#endif

	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		cin >> startCost[i];
		cost[i] = startCost[i];
	}
	
	ll res = LINF;

	for (int s = 0; s <= n; s++) {
		ll cur = 1LL * s * x;
		for (int i = 0; i < n; i++) {
			cur += cost[i];
		}
		res = min(res, cur);
		memcpy(oldCost, cost, sizeof(cost[0]) * n);
		for (int j = 0; j < n; j++) {
			cost[j] = min(oldCost[j], startCost[(j + s + 1) % n]);
		}
	}

	cout << res << endl;

}

Measured memory_bytes: 256
#include <iostream>

int main(){
   long long N, K;
   std::cin >> N >> K;

   long long n = N/K;
   if(K%2==1){
      std::cout << n*n*n << std::endl;
   }else{
      long long a = (N+K/2)/K;
      std::cout << n*n*n + a*a*a << std::endl;
   }
   return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {


    string S; cin >> S;
    int ans = 0;
    REP(i, 3){
        if(S[i]=='o')ans++;
    }
    cout << 700 + ans * 100 << endl;
    

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3524
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
typedef long long ll;
#define bay_bay return 0;
#define fori(n) for(int i=0;i<n;++i)
#define for1(n) for(int i=1;i<=n;i+=3)
#define all(v) ((v).begin()), ((v).end())	
#define sz(v) v.size()
#define endl "\n"
constexpr auto EPS = 1e-9;
#define ff fflush(stdout);
const int mod = 1000000007LL;
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif
}
struct day
{
	ll a, b, c;

};
day days[100009];
ll mem[100009][4];
int n;
ll solve(int idx, int ch)
{
	if (idx == n)
	{
		return 0;
	}
	ll &ret = mem[idx][ch];
	if (~ret)
		return ret;
	ret = LLONG_MIN;
	if (ch != 1)
		ret=max(ret, days[idx].a + solve(idx + 1, 1));
	if (ch != 2)
		ret=max(ret, days[idx].b + solve(idx + 1, 2));
	if (ch != 3)
		ret=max(ret, days[idx].c + solve(idx + 1, 3));
	return ret;

}
int main()
{
	//GOAT();
	cin >> n;
	memset(mem, -1,sizeof mem);
	fori(n)
	{
		cin >> days[i].a >> days[i].b >> days[i].c;
	}
	cout << solve(0, 0) << endl;
	
}

Measured memory_bytes: 13568
#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 cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	auto add = []    ( ll a, ll b ) { return ( a + b ) % cMOD; };
	auto sub = []    ( ll a, ll b ) { return ( a + cMOD -b ) % cMOD; };
	auto mul = []    ( ll a, ll b ) { return a * b % cMOD; };

    string s; cin>>s;
    ll len = s.length();

    vector<ll> dpOK( len+1, 0 );
    vector<ll> dpUn( len+1, 0 );
    dpOK[0]=0;dpUn[0]=1;
    REP(i,len)
    {
        if( s[i] == '1' )
        {
            dpOK[i+1] = add( mul( dpOK[i], 3 ), mul( dpUn[i], 1 ) );
            dpUn[i+1] = add( mul( dpOK[i], 0 ), mul( dpUn[i], 2 ) );
        }
        else
        {
            dpOK[i+1] = add( mul( dpOK[i], 3 ), mul( dpUn[i], 0 ) );
            dpUn[i+1] = add( mul( dpOK[i], 0 ), mul( dpUn[i], 1 ) );
        }
    }

    cout << add( mul( dpOK[len], 1 ), mul( dpUn[len], 1 ) ) << endl;
    return 0;
}

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

int main () {
  int N , K;
  cin >> N >> K;
  vector <int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }
  int answer = 0;
  for(int i = 0; i < N; i++){
    if(h.at(i) >= K){
      answer++;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 640
// H - Grid 1 https://atcoder.jp/contests/dp/tasks/dp_h
/* 入力例
3 4
...#
.#..
....
// →出力　3
*/
#include <bits/stdc++.h>
using namespace std;
vector<string> grid;
int mem[1001][1001];
int pathcount(int r, int c) {
    if(mem[r][c] >= 0)
        return mem[r][c];
    if(r == 0 && c == 0) {
        mem[r][c] = 1;
        return mem[r][c];
    } else if(r == 0 && c > 0) {
        if(grid[r][c - 1] == '.')
            mem[r][c] = pathcount(r, c - 1);
        else
            mem[r][c] = 0;
        return mem[r][c];
    } else if(r > 0 && c == 0) {
        if(grid[r - 1][c] == '.')
            mem[r][c] = pathcount(r - 1, c);
        else
            mem[r][c] = 0;
        return mem[r][c];
    } else {
        int temp = 0;
        if(grid[r - 1][c] == '.')
            temp += pathcount(r - 1, c);
        if(grid[r][c - 1] == '.')
            temp += pathcount(r, c - 1);
        mem[r][c] = temp % 1000000007;
        return mem[r][c];
    }
}

int main(void) {
    int H, W;
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        string temp;
        cin >> temp;
        grid.push_back(temp);
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            mem[i][j] = -1;
        }
    }
    cout << pathcount(H - 1, W - 1) << endl;
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define all(v) (v).begin(), (v).end()
using namespace std;
const int N = 1e3 + 5;

void solve()
{
    string s;
    cin >> s;
    ll ans = 0, count = (s[0]=='R');
    for(int i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
            if(s[i]=='R')
                count++;
            else
                count=0;
        }
        else
            ans=max(ans,count),count=(s[i]=='R');

    }
    cout<<max(ans,count);

}


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


    int TESTS = 1;
    // cin >> TESTS;
    while(TESTS--)
    {
        solve();
        cout << endl;

    }
    return 0;
}

Measured memory_bytes: 3516
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	n%=10;
	if(n==3){
		cout<<"bon"<<endl;
	}else if(n==2 || n==4 || n==5 || n==7 || n==9 ){
		cout<<"hon"<<endl;
	}else{
		cout<<"pon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#![allow(unused_imports)]
use num::integer::gcd;
use proconio::*;
use std::collections::VecDeque;
use std::ops::*;

fn main() {
   input! {
      k: usize
   }
   let mut ans = 0;
   for a in 1..=k {
      for b in 1..=k {
         for c in 1..=k {
            ans += gcd(a, gcd(b, c));
         }
      }
   }
   println!("{}", ans);
}


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

struct Node
{
	int number = 0;
	bool isOpen = false;
};

int main()
{
	array<array<Node, 3>, 3> A;
	for (auto &i : A)
	{
		for (auto &node : i)
		{
			int num;
			cin >> num;
			node.number = num;
		}
	}
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (A.at(i).at(j).number == num)
				{
					A.at(i).at(j).isOpen = true;
				}
			}
		}
	}

	for (int i = 0; i < 3; i++)
	{
		int sum = 0;
		for (int j = 0; j < 3; j++)
		{
			sum += A.at(i).at(j).isOpen;
		}
		if (sum == 3)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	for (int i = 0; i < 3; i++)
	{
		int sum = 0;
		for (int j = 0; j < 3; j++)
		{
			sum += A.at(j).at(i).isOpen;
		}
		if (sum == 3)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	{
		int sum = 0;
		for (int i = 0; i < 3; i++)
		{
			sum += A.at(i).at(i).isOpen;
		}
		if (sum == 3)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	{
		int sum = 0;
		for (int i = 0; i < 3; i++)
		{

			sum += A.at(i).at(2-i).isOpen;
		}
		if (sum == 3)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define ll long long
ll n, m,num;

const int  maxn = 1e5+5;
vector<int> G[maxn];

bool vis[maxn];
int f[maxn];

int bfs(int i)
{
    queue<int> que;
    que.push(i);
    vis[i] = true;
    f[i] = 0;
    while(!que.empty())
    {
        int e = que.front();
        que.pop();
        int d = G[e].size();
        for(int i = 0; i < d; i ++)
        {
            int t = G[e][i];
            if(vis[t])
            {
                if(f[t] == f[e]) return 1;
            }
            else
            {
                vis[t] = true;
                f[t] = f[e] == 0 ? 1 : 0;
                que.push(t);
            }
        }
    }
    return 0;
}

int fun()
{
    for(int i = 1; i <= n; i ++)
    {
        if(!vis[i])
        {
            if(bfs(i) == 1) return 1;
        }
    }
    return 0;
}

int main()
{
    scanf("%lld %lld", &n, &m);
    for(int i = 0; i < m; i ++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    memset(vis, false, sizeof(vis));
    if(fun() == 1)
    {
        printf("%lld",n*(n-1)/2-m);
    }
    else
    {
        for(int i=1; i<=n; i++)if(f[i])num++;
        printf("%lld",num*(n-num)-m);
    }
    return 0;
}


Measured memory_bytes: 6272
import itertools
import math
W,H,N  =list(map(int,input().split(" ")))
hoko = [0,W,0,H]
l = 0
r = W
ue = H
sita = 0

for _ in range(N):
    x,y,a=list(map(int, input().split(" ")))

    if a ==1:
      if l < x:
          l = x
    if a == 2:
        if r > x:
            r = x

    if a == 4:
        if ue > y:
            ue = y
    if a == 3:
        if sita < y:
            sita = y

if (r-l) < 0 and (ue-sita) < 0:
    print(0)
else:
    print(max(0,  (r-l) * (ue-sita)   ))

Measured memory_bytes: 38384
#include<iostream>
#include<cstring>
#define mod 998244353
using namespace std;
int n, i, j, ii, k, t, nr, m, sol, jj, x;
char s[305];
int d[305][305][305];
void adauga(int &x, int y){
    x += y;
    if(x >= mod){
        x -= mod;
    }
}
int main(){
    cin>> s + 1;
    cin>> k;
    n = strlen(s + 1);
    s[++n] = '0';
    d[0][0][0] = 1;
    for(i = 1; i <= n; i++){
        if(s[i] == '1'){
            m++;
        }
    }
    for(i = 1; i <= n + 1; i++){
        if(s[i] == '1'){
            nr++;
            continue;
        }
        t++;
        for(j = 0; j <= m; j++){
            for(ii = 0; ii <= m; ii++){
                for(jj = 0; jj <= m; jj++){
                    if(jj >= nr){
                        x = jj - nr;
                        if(j + x <= m && ii + x <= m){
                            adauga(d[t][j + x][ii + x], d[t - 1][j][ii]);
                        }
                    }
                    else{
                        if(nr - jj <= j){
                            x = nr - jj;
                            adauga(d[t][j - x][ii], d[t - 1][j][ii]);
                        }
                    }
                }
            }
        }
        nr = 0;
    }
    for(i = 0; i <= min(m, k); i++){
        adauga(sol, d[t][0][i]);
    }
    cout<< sol;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= n; j++){
      for (int k = 1; k <= n; k++){
        sum += __gcd(i, __gcd(j, k));
      }
    }
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class BUnevenNumbers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int count = 0;
            for (int i = 1; i <= n; i++) {
                if (digits(i) % 2 == 1)
                    count++;
            }
            out.println(count);
        }

        int digits(int n) {
            if (n <= 0) {
                return 0;
            }
            return 1 + digits(n / 10);
        }

    }
}



Measured memory_bytes: 23764
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] C = sc.next().toCharArray();
		int N = C.length;
		sc.close();

		Deque<Character> deque = new ArrayDeque<>();

		int[] score = new int[N];

		// for R
		for (int i = 0; i < N; i++) {
			if (C[i] == 'R') {
				deque.push('R');
			} else {
				int cnt = 0;
				while (!deque.isEmpty()) {
					if (cnt % 2 == 0) {
						score[i - 1]++;
					} else {
						score[i]++;
					}
					cnt++;
					deque.pop();
				}
			}
		}

		// for L
		for (int i = N - 1; i >= 0; i--) {
			if (C[i] == 'L') {
				deque.push('L');
			} else {
				int cnt = 0;
				while (!deque.isEmpty()) {
					if (cnt % 2 == 0) {
						score[i + 1]++;
					} else {
						score[i]++;
					}
					cnt++;
					deque.pop();
				}
			}
		}

		for (int i = 0; i < N; i++) {
			System.out.print(score[i] + " ");
		}
	}
}


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

int main() {
   int n, *l;
   vector<int> v;
   scanf("%d", &n);
   l = new int[2*n];
   for (int i = 0; i < 2*n; ++i) {
      scanf("%d", &l[i]);
      v.push_back(l[i]);
   }
   std::sort(v.begin(), v.end());
   int cnt = 0;
   int total = 0;
   for (auto iter = v.begin(); iter < v.end(); iter++) {
      if ((cnt % 2) == 0) {
         total += *iter;
      }
      cnt++;
   }
   printf("%d\n", total);
}

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

int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int L = A + B, R = C + D;
	cout << (L == R ? "Balanced" : L > R ? "Left" : "Right") << endl;
}


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

const int maxn = 1010, maxm = 5010, oo = 12345678;

int n;
std::vector<int> g[maxn];
int dp[maxm], pd[maxm], x[maxn][2];

void chkmin(int &x, int y) {
	(x > y) && (x = y);
}

void dfs(int u) {
	for (int v: g[u]) {
		dfs(v);
	}
	for (int i = 1; i <= x[u][0]; ++i) {
		dp[i] = oo;
	}
	dp[0] = 0;
	for (int v: g[u]) {
		for (int i = 0; i <= x[u][0]; ++i) {
			pd[i] = oo;
			if(i >= x[v][0]) {
				chkmin(pd[i], dp[i - x[v][0]] + x[v][1]);
			}
			if(i >= x[v][1]) {
				chkmin(pd[i], dp[i - x[v][1]] + x[v][0]);
			}
		}
		memcpy(dp, pd, sizeof(dp[0]) * (x[u][0] + 1));
	}
	x[u][1] = oo;
	for (int i = 0; i <= x[u][0]; ++i) {
		chkmin(x[u][1], dp[i]);
	}
	if(x[u][1] == oo) {
		puts("IMPOSSIBLE");
		exit(0);
	}
//	printf("%d\t%d %d\n", u, x[u][0], x[u][1]);
	return;
}

int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) {
		int p;
		scanf("%d", &p);
		g[p].push_back(i);
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", x[i]);
	}
	dfs(1);
	puts("POSSIBLE");
	return 0;
}

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

using namespace std;

int n,i;
long long a[100005],b[100005];

int main(){
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	scanf("%d%d", &a[i], &b[i]);
	
	long long res = 0;
	
	for(i = n - 1; i >= 0; i--){
		long long now = a[i] + res;
		if(now % b[i] != 0){
			long long newval = (long long)((now / b[i]) + 1LL) * b[i];
			res += newval - now;
		}
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
map<int,int>g,g1;
int main()
{
  //flash;
  int n;
  cin>>n;
  ll sum=0;
  for (int i = 0; i < n; ++i)
  {
    ll yo;
    cin>>yo;
    g[yo]++;
    sum+=yo;
  }
  int q;
  cin>>q;
  while(q--){
    ll val,val1;
    cin>>val>>val1;
    sum-=g[val]*val;
    sum+=g[val]*val1;
    g[val1]+=g[val];
    g.erase(val);
    cout<<sum<<'\n';
  }
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 6460
#include <bits/stdc++.h>
using namespace std;
string a, b;
long long dp[25];
map<string, int> mp;
class fastio {
public:
    fastio() {
        ios_base::sync_with_stdio(false);
        cout.tie(nullptr);
        cin.tie(nullptr);
    }
} __fastio;
int fact(int n) {
  if(n == 0) return dp[n] = 1;
  return dp[n] = n * fact(n-1);
}
void solve() {
  fact(15);
  //for(int i=0; i<=10; i++) cout << dp[i] << endl;
  int n; cin >> n;
  for(int i=0; i<n; i++){
    string s; cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  long long ans = 0;
  for(auto it : mp) {
    long long k = it.second;
    /*
    if(k >= 2) {
      //cout << "dp[" << n << "]" << " == " << dp[n] << endl;
      //cout << "dp[" << n-2 << "]" << " == " << dp[n-2] << endl;
      //cout << "dp[" << "2" << "]" << " == " << dp[2] << endl;
      ans += (dp[k] / (dp[k-2] * dp[2]));
      //cout << ans << endl;
    }
    */
    ans += (k*(k-1))/2;
  }
  cout << ans << endl;
}
int main() {
  __fastio;
  solve();
  return 0;
}


Measured memory_bytes: 11264
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[][][] warshall=new long[11][11][11];
        int h=sc.nextInt();
        int w=sc.nextInt();
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                warshall[0][i][j]=sc.nextInt();
            }
        }
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    warshall[i+1][j][k]=Math.min(warshall[i][j][k],warshall[i][j][i]+warshall[i][i][k]);
                }
            }
        }
        long ans=0;
        int tmp;
        for(int i=0;i<h*w;i++){
            tmp=sc.nextInt();
            if(tmp>=0)ans+=warshall[10][tmp][1];
        }
        System.out.println(ans);
    }
}


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

int main() {
    int A[3][3] = {};
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    int b[N] = {};
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if(A[i][j] == b[k]) A[i][j] = 0;
            }
        }  
    }
    bool tf = 0;
    for (int i = 0; i < 3; i++)
        {
            if(A[i][0] + A[i][1] + A[i][2] == 0) tf = 1;
        }
    for (int i = 0; i < 3; i++)
        {
            if(A[0][i] + A[1][i] + A[2][i] == 0) tf = 1;
        }
    if(A[0][0] + A[1][1] + A[2][2] == 0) tf = 1;
    if(A[0][2] + A[1][1] + A[0][2] == 0) tf = 1;
    if(tf){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,m;
int main(void){
    cin>>n>>m;
    for(int i=0;i<=n;i++){
        if(i*2+4*(n-i)==m){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	mp := map[byte]byte{}
	pm := map[byte]byte{}
	for i := 0; i < len(s); i++ {
		if v, ok := mp[s[i]]; ok {
			if v != t[i] {
				fmt.Println("No")
				return
			}
		} else {
			mp[s[i]] = t[i]
		}
		if v, ok := pm[t[i]]; ok {
			if v != s[i] {
				fmt.Println("No")
				return
			}
		} else {
			pm[t[i]] = s[i]
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    ll n,m;
    cin >> n>> m;
    if(n>m){
        swap(n,m);
    }
    if(n==1){
        if(m==1){
            cout<<1<<endl;
        }else{
            cout<<m-2<<endl;
        }  
    }else{ 
        cout<<(n-2)*(m-2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var L = a[0] + a[1];
        var r = a[2] + a[3];
        var ret = "Balanced";
        if (L > r) ret = "Left";
        else if (L < r) ret = "Right";
        Console.WriteLine(ret);
    }
}

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

int main(){
    int N, K; cin >> N >> K;
    int count=0;
    vector<vector<int>> G(N);
    int m = (N-2) * (N-1) / 2;
    if(K>m) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 1; i < N; i++) G[0].push_back(i);

    int n = m - K;
    int cnt = 0;
    for (int i = 1; i < N-1; i++){
        if(cnt >= n) break;
        for (int j = i+1; j < N; j++)
        {   
            if(cnt >= n) break;
            G[i].push_back(j);
            cnt++;
        }
    } 
    cout << N -1 + n << endl;
    for (int i = 0; i < G.size(); i++)
    {
        for (int j = 0; j < G[i].size(); j++)
        {
            cout << i+1 << " " << G[i][j]+1 << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

#define N 1400

ll get(ll a)
{
    ll ans = 0;
    while(a>0)
    {
        if(a&1)
            ans++;
        a>>=1;    
    }
    return ans;
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll powa[20];
   powa[0] = 1;
   for(ll i=1;i<20;i++)
        powa[i] = powa[i-1]*2;
   
   vector<pair<ll,ll>> hold[n];
   for(ll i=0;i<n;i++)
   {
       ll s;
       cin>>s;
       
       while(s--)
       {
           ll a,b;
           cin>>a>>b;
           hold[i].pb(mp(a,b));
       }
   }
   
   ll ans = 0;
   ll lim = (1ll<<(n));
   for(ll i=0;i<lim;i++)
   {
       ll arr1[n];
       for(ll j=0;j<n;j++)
       {
           if(powa[j]&i)
                arr1[j] = 1;
           else arr1[j] = 0;        
       }
       bool pos = 1;
       for(ll j=0;j<n;j++)
       {
           if(arr1[j])
           {
               for(auto it = hold[j].begin();it!=hold[j].end();it++)
               {
                   if((it->second ^ arr1[it->first - 1])!=0)
                        pos = 0;
               }
           }
       }
       
       if(pos)
            ans = max(ans, get(i));
   }
   
   cout<<ans;
           
}  
   

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int W, H;
char field[32][32];
bool used[32][32];

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

void dfs(int x, int y) {
    used[x][y] = true;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] != '#' && used[nx][ny] == false) {
            dfs(nx, ny);
        }
    }
}

int main(void) {
    while (1) {
        cin >> W >> H;
        for (int i = 0; i < 32; i++)
            for (int j = 0; j < 32; j++)
                used[i][j] = false;
        if (W == 0 && H == 0) break;
        int sx, sy;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> field[i][j];
                if (field[i][j] == '@') {
                    sx = i; sy = j;
                }
            }
        }
        used[sx][sy] = true;
        dfs(sx, sy);
        int ret = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (used[i][j]) ret++;
            }
        }
        cout << ret << endl;
    }
    return 0;
}

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

// マクロ //
#define rep(v,times) for(int v = 0; v < (int)(times); v++)
#define req(v,first,endplus1) for(int v = first; v < (int)(endplus1); v++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

template<class T, class Q> double distance(T a, Q b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy8[8] = { 0,1,1,1,0,-1,-1,-1 };

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N;
    cin >> N;


    cout << N + N * N + N * N * N;



}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int n,m,k;
int i,j;
int rec[100][101];
int ck[100];
typedef struct{
	char name[101];
	int price;
}item;
item it[100];
int min(int a,int b){return a<b?a:b;}
int main(){
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		for(i=0;i<n;i++)scanf("%s %d",it[i].name,&it[i].price);
		scanf("%d",&m);
		for(i=0;i<m;i++)ck[i]=0;
		for(i=0;i<m;i++){
			char s[101];
			scanf("%s",s);
			for(j=0;j<n;j++)if(strcmp(s,it[j].name)==0){
				rec[i][ck[i]++]=j;
				break;
			}
			scanf("%d",&k);
			for(j=0;j<k;j++){
				scanf("%s",s);
				for(int l=0;l<n;l++)if(strcmp(s,it[l].name)==0){
					rec[i][ck[i]++]=l;
				}
			}
		}
		int res;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				res=0;
				for(int l=1;l<ck[j];l++)res+=it[rec[j][l]].price;
				it[rec[j][0]].price=min(it[rec[j][0]].price,res);
			}
		}
		char ans[101];
		scanf("%s",ans);
		for(i=0;i<n;i++)if(strcmp(ans,it[i].name)==0)break;
		printf("%d\n",it[i].price);
	}
}

Measured memory_bytes: 1060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

main()
{
    int n,k,c; cin>>n>>k>>c;
    string s; cin>>s;
    vector<int> l(k),r(k);
    for(int i=0,j=0,z=0;i<n and z<k;++i)
    {
        if(i<j or s[i]=='x') continue;
        l[z++]=i;
        j=i+1+c;
    }
    reverse(begin(s), end(s));
    for(int i=0,j=0,z=0;i<n and z<k;++i)
    {
        if(i<j or s[i]=='x') continue;
        r[z++]=i;
        j=i+c+1;
    }
    reverse(begin(s), end(s));
    reverse(begin(r), end(r));
    for(int &e: r) e=n-1-e;
    for(int i=0; i<k; ++i)
    {
        if(l[i]==r[i]) cout << l[i]+1 << "\n";
    }
}

Measured memory_bytes: 3332
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int X = scan.nextInt();
        List<Book> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int C = scan.nextInt();
            int[] m = new int[M];
            for (int j = 0; j < M; j++) {
                m[j] = scan.nextInt();
            }
            list.add(new Book(C, m));
        }
        long ans = Long.MAX_VALUE;
        long limit = pow(2, N);
        for (int i = 0; i < limit; i++) {
            int[] p = new int[M];
            int index = 0;
            int current = i;
            long cost = 0;
            while (0 < current) {
                if (current % 2 == 1) {
                    Book b = list.get(index);
                    int[] m = b.m;
                    cost += b.C;
                    for (int j = 0; j < M; j++) {
                        p[j] += m[j];
                    }
                }
                index += 1;
                current /= 2;
            }
            boolean found = false;
            for (int j = 0; j < M && !found; j++) {
                if (p[j] < X) {
                    found = true;
                }
            }
            if (!found) {
                ans = Math.min(ans, cost);
            }
        }
        if (ans == Long.MAX_VALUE) {
            System.out.println(-1);
            return;
        }
        System.out.println(ans);
    }
    private long pow(int base, int count) {
        if (count == 0) {
            return 1;
        }
        if (count % 2 == 1) {
            return base * pow(base, count-1);
        }
        long x = pow(base, count/2);
        return x * x;
    }
    class Book {
        int C;
        int[] m;
        Book(int C, int[] m) {
            this.C = C;
            this.m = m;
        }
    }
}



Measured memory_bytes: 37752
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long n;
  cin >> n;
  long x = 800 * n;
  long y = 200 * (n / 15);
  cout << x - y << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main(){
  int A,B;
  cin>>A>>B;
  for(int i=0;i<3;i++){
    if(A==i+1)
      continue;
    else if(B==i+1)
      continue;
    else{
      cout<<i+1<<endl;
      break;
    }
  }
}

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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 3123

int n;
ll vals[MAXN];
ll dp[MAXN][MAXN];
int vis[MAXN][MAXN];

ll solve(int l, int r)
{
    if (l > r)
        return 0;

    if (vis[l][r])
        return dp[l][r];
    vis[l][r] = 1;

    return dp[l][r] = max(vals[l] - solve(l + 1, r), vals[r] - solve(l, r - 1));
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &vals[i]);
    }
    
    printf("%lld\n", solve(0, n - 1));
}

Measured memory_bytes: 113024
#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;
}

int main(void) {
    int N, X, T;
    cin >> N >> X >> T;
    cout << (N + X - 1) / X * T << endl;
    return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
before_num = -1
for a in A:
  if before_num + 1 == a:
    ans += C[a-2]
  ans += B[a-1]
  
  before_num = a
  
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

constexpr int MOD = 2019;

int main(){
    string S;
    read(S);
    int N = S.size();
    vector<int> sum(N);
    sum[N - 1] = S[N - 1] - '0';
    int d = 10;
    for(int i = N - 2; i >= 0; i--){
        sum[i] = (sum[i + 1] + (S[i] - '0') * d) % MOD;
        d = d * 10 % MOD;
    }
    int ans = 0;
    map<int, int> mp;
    mp[0]++;
    for(int i = 0; i < N; i++){
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 4380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication18 {//b54
    class Program {
        static void Main(string[] args) {

   
            int x = int.Parse(Console.ReadLine());

            var result = Method(x);
            if(result == false) {
                Console.WriteLine("ABC");
            } else {
                Console.WriteLine("ARC");
            }
           
        }
        private static bool Method(int x) {

           
            if (x <1200) {
                return false;
            } else {
                
               return true;
            }
        }
    }
}

Measured memory_bytes: 11092