akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(void)
{
int x,y;
cin>>x;
cin>>y;
int num[x+1][y+1];
for(int i=0;i<x;i++)
{
int sum1=0;
	for(int j=0;j<y;j++)
	{
	cin>>num[i][j];
	sum1+=num[i][j];
	
	}
	
	num[i][y]=sum1;
}
for(int i=0;i<y+1;i++)
{
int sum2=0;
	for(int j=0;j<x;j++)
	{
	sum2+=num[j][i];
	}
	num[x][i]=sum2;
}
for(int i=0;i<x+1;i++)
{
	for(int j=0;j<y+1;j++)
	{
	if(j==y)cout<<num[i][j];
	else if(j!=y)cout<<num[i][j]<<" ";
	}
	cout<<endl;
}
return 0;
}

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

int main() {
  int n,m;cin>>n>>m;
  vector<pair<int,int>> pr(m);
  rep(i,m){
    int s,c;cin>>s>>c;
    s--;
    pr[i]=make_pair(s,c);
  }
  rep(i,1000){
    bool ans=true;
    string a=to_string(i);
    int keta=a.size();
    if(n!=keta)continue;
    rep(j,m){
      if(a[pr[j].first]!=(char)('0'+pr[j].second))ans=false;
    }
    if(ans){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    ll maxp=INT_MIN;
    ll minp=INT_MAX;
    ll maxs=INT_MIN;
    ll mins=INT_MAX;

    ll x,y;
    ll ans=0;
    while (n--) {
        cin>>x>>y;
        maxp=__max(maxp,x+y);
        minp=__min(minp,x+y);
        maxs=__max(maxs,x-y);
        mins=__min(mins,x-y);
        ans=__max(maxp-minp,maxs-mins);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(){
 int q;
 double x;
 double a;

 while(1)
 {

  scanf("%d",&q);
  if(q==-1)break;
  x = q/2.0;
  while(1){
   a=(x*x*x-q)/(3*x*x);
   x=x-a;
   if( (x*x*x-q)<0.00001*q && (x*x*x-q)>0.00001*q*(-1) ){printf("%.8lf\n",x);break;}
  }
 }

return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int h,w,k, ans = 0;
vector<string> map;
vector<int> isRed;

void convert(int black){
	vector<string> cur = map;
	for(int i=0;i<h;i++){
		if(isRed[i]){
			for(int j=0;j<w;j++){
				if(cur[i][j] == '#'){
					black --;
					cur[i][j] = '.';
				}
			}
		}
	}
	for(int i=h;i<isRed.size();i++){
		if(isRed[i]){
			for(int j=0;j<h;j++){
				if(cur[j][i-h] == '#'){
					black--;
					cur[j][i-h] = '.';
				}
			}
		}
	}
	if(black == k) ans++;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int black = 0; cin>>h>>w>>k;
	map = vector<string>(h);
	for(int i=0;i<h;i++){
		cin>>map[i];
		for(int j=0;j<w;j++){
			if(map[i][j] == '#') black++;
		}
	}
	for(int i=0;i<h+w;i++){
		isRed = vector<int>(h + w);	
		for(int j=0;j<i;j++) isRed[j] = 1;
		do{
			convert(black);	
		}while(prev_permutation(isRed.begin(), isRed.end()));
	}
	cout<<ans;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) clog<<#x<<": "<<x<<endl
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define pb push_back
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define in insert
#define se second
#define mkp make_pair
#define fr(i,n) for(i = 0 ; i < n ; i++)
#define  test int t; cin>>t; while(t--)
int main()
{
    int a,b,m,i,n,j,k;
    cin>>a>>b;
    int x,y;
    x = ((a*(1/0.08))+0.5);
    y = b*10;
    //cout<<"x = "<<x<<" "<<y<<endl;
    if(x==y)
        cout<<x;
    else
    {
        j = y*(0.08);
        i  = x*0.1;
        //cout<<i<<" "<<j<<endl;
        if(j==a)
            cout<<y;
        else if(i==b)
            cout<<x;
        else
            cout<<-1;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int t = sc.nextInt();
    for(int i = 0; i < t; i++) {
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextLong();
      long d = sc.nextLong();
      long g = gcd(b, d);
      long s = b - g + (a % g);
      if(b > a) {
        System.out.println("No");
      } else if(b > d) {
        System.out.println("No");
      } else if(c >= b) {
        System.out.println("Yes");
      } else {
        if(s > (c % b)) {
          System.out.println("No");
        } else {
          System.out.println("Yes");
        }
      }
    }
  }

  public static long gcd(long x, long y) {
    if(y == 0) return x;
    return gcd(y, x % y);
  }
}

Measured memory_bytes: 25044
n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
b=[list(input()) for i in range(m)]
if a==b:
    print('Yes')
    exit()
for i in range(n-m):
    for j in range(n-m):
        cnt=0
        for k in range(m):
            if a[j+k][i:i+m]==b[k]:
                cnt+=1
        if cnt==m:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
ll a,v,b,w,t;
int main(){
	cin>>a>>v>>b>>w>>t;
	if(w>=v){
		cout<<"NO";
		return 0;
	}
	if((a+v*t>=b+w*t&&a<b)||(b-w*t>=a-v*t&&a>b)){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
	return 0;
}


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

int N;
long X;
long p[51] = {};
long s[51] = {};

long f(int N, long X)
{
  if (N == 0)
    return 1;
  else if (X == 1)
    return 0;
  else if (X <= s[N - 1] + 1)
    return f(N - 1, X - 1);
  else if (X == s[N - 1] + 2)
    return f(N - 1, X - 2) + 1;
  else if (X <= 2 * s[N - 1] + 2)
    return p[N - 1] + 1 + f(N - 1, X - s[N - 1] - 2);
  else
    return p[N];
}

int main()
{
  cin >> N >> X;
  p[0] = 1;
  s[0] = 1;
  for (int i = 1; i <= N; i++)
  {
    p[i] = 2 * p[i - 1] + 1;
    s[i] = 2 * s[i - 1] + 3;
  }
  cout << f(N, X) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
long long stuff[401][401];
long long sums[401][401];
int main ()
{
  prep();
  int n, c;
  cin >> n >> c;
  int a[n];
  int b[n];
  for (int i=0; i<n; i++){
      cin >> a[i];
  }
  for (int i=0; i<n; i++){
      cin >> b[i];
  }
 
  for (int i=1; i<=400; i++){
      sums[i][0] = 1;
      for (int j=1; j<=400; j++){
          sums[i][j] = (sums[i][j-1]*i)%mod;
      }
  }
  for (int i=1; i<=400; i++){
      for (int j=0; j<=400; j++){
          sums[i][j] = (sums[i][j]+sums[i-1][j])%mod;
      }
  }
  stuff[n][0] = 1;
  for (int i=n-1; i>=0; i--){
      for (int j=0; j<=c; j++){
          // make the jth one
          for (int k=0; k<=j; k++){
              stuff[i][j] = (stuff[i][j]+(sums[b[i]][k]-sums[a[i]-1][k]+mod)*stuff[i+1][j-k])%mod;
          }
      }
  }
 
  cout << stuff[0][c];
  return 0; 
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<long long> sum(n, 0);
	sum[0] = a[0];
	// 累積和使う
	for (int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + a[i];
	}
	// sum[i] == sum[j]となったときはa[i+1]からa[j]までの和が0となる
	// よって等しい和の数を求める　同じ和が2つの場合は2-1=1、3つの場合は3-1=2
	// mapを使う mapは平衡2分木でlognで操作を行える
	// さらにmap[i]でiをkeyとして保温し、valueは0が勝手に代入される
	// map意外と便利！！！！
	map<long long, long long> mp;

	mp[0] = 1;
	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += mp[sum[i]];
		mp[sum[i]]++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 15872
using System;

namespace ConsoleApplicationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int height, weight;
            string[] str = new string[2];

            while (true)
            {
                str = Console.ReadLine().Split(' ');
                height = int.Parse(str[0]);
                weight = int.Parse(str[1]);

                if (0 == height && 0 == weight) break;

                for (int i = 0; i < height; i++)
                {
                    for (int j = 0; j < weight; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }

}

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

int main()
{
  int N,M,P,X,S,i,m;
  while(cin>>N>>M>>P,N||M||P){
    S=0;
    for(i=0;i<N;i++){
      cin>>X;
      S+=X*100;
      if(i==M-1)m=X*100;
    }
    S*=100-P;
    if(m)cout<<(int)((double)S/m)<<endl;
    else puts("0");
  }
}

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

using namespace std;

typedef long long ll;

class Number {
public:
	int num2;
};
class DSLK {
public:
	Number *x;
	int num;
	DSLK *next;
};

void Solves();
int main() {
	Solves();

	/*
	fstream file;

	file.open("spoj.inp", ios::out | ios::binary);

	int n = 2;
	DSLK *ds = new DSLK();
	DSLK *temp = ds;
	for (int i = 0; i < n; i++) {
		temp->x = new Number();
		temp->num = i;
		temp->x->num2 = i * 10;
		if (i < n - 1) {
			temp->next = new DSLK();
		}
		temp = temp->next;
	}
	file.write((char*)&ds, sizeof(DSLK));
	cout << sizeof(DSLK);
	file.close();

	file.open("spoj.inp", ios::in | ios::binary);

	DSLK *doc = new DSLK();
	file.read((char*)&doc, sizeof(DSLK));
	temp = doc;
	while (temp != NULL) {
		cout << temp->num << endl;
		temp = temp->next;
	}

	file.close();

	DSLK *prev=NULL;
	DSLK *nodeDel;
	temp = ds;
	for (int i = 0; i < n; i++) {
		if (temp->next->num == n- 1) {
			prev = temp;
			temp = temp->next->next;
			break;
		}
		prev = temp;
		temp = temp->next;
	}
	nodeDel = prev->next;
	prev->next = temp;
	delete nodeDel;

	temp = ds;

	
/*	temp = ds;
	ds = temp->next;
	delete temp;
	
	temp = ds;

	while (temp != NULL) {
		cout << temp->num << " ";
		temp = temp->next;
	}
	*/
	return 0;
}

void Solves() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (c >= a&&c <= b) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
import sys
import itertools


class EndLoop(Exception):
    pass


def solv(numbers):
    try:
        for n in itertools.permutations(numbers, 4):
            for e in merge(n):
                 for expr in expressions(e):
                     answer = eval(expr)
                     if answer == 10:
#                         print expr + ' = ' + str(answer)
                         print expr
                         raise EndLoop
        else:
            print '0'
    except EndLoop:
        pass


def merge(n):
    op = '+-*'
    for i in op:
        for j in op:
            for k in op:
                yield (n[0], i, n[1], j, n[2], k, n[3])


def expressions(e):
    exprs = []
    exprs.append('(' + ' '.join(e) + ')')
    exprs.append('((' + e[0] + ' ' + e[1] + ' ' + e[2] + ') ' + e[3] + ' ' + e[4] + ' ' + e[5] + ' ' + e[6] + ')')
    exprs.append('(' + e[0] + ' ' + e[1] + ' (' + e[2] + ' ' + e[3] + ' ' + e[4] + ') ' + e[5] + ' ' + e[6] + ')')
    exprs.append('(' + e[0] + ' ' + e[1] + ' ' + e[2] + ' ' + e[3] + ' (' + e[4] + ' ' + e[5] + ' ' + e[6] + '))')
    exprs.append('(((' + e[0] + ' ' + e[1] + ' ' + e[2] + ') ' + e[3] + ' ' + e[4] + ') ' + e[5] + ' ' + e[6] + ')')
    exprs.append('((' + e[0] + ' ' + e[1] + ' (' + e[2] + ' ' + e[3] + ' ' + e[4] + ')) ' + e[5] + ' ' + e[6] + ')')
    exprs.append('(' + e[0] + ' ' + e[1] + ' ((' + e[2] + ' ' + e[3] + ' ' + e[4] + ') ' + e[5] + ' ' + e[6] + '))')
    exprs.append('(' + e[0] + ' ' + e[1] + ' (' + e[2] + ' ' + e[3] + ' (' + e[4] + ' ' + e[5] + ' ' + e[6] + ')))')
    exprs.append('((' + e[0] + ' ' + e[1] + ' ' + e[2] + ') ' + e[3] + ' (' + e[4] + ' ' + e[5] + ' ' + e[6] + '))')
    return exprs

for line in sys.stdin:
    numbers = line.rstrip('\n').split(' ')
    if numbers == ['0', '0', '0', '0']:
        exit()
    else:
        solv(numbers)

Measured memory_bytes: 4432
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int,ins()))
def lin(): return list(input())
def iin(): return map(int,ins())

s = input()
for i,j in enumerate(s):
    if j == 'U' or j == 'D':
        continue
    elif (j == 'R' and i%2==1) or (j == 'L' and i%2==0):
        print('No')
        break
else:
    print('Yes')

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

int main() {
    int n;
    cin >> n;
    while (n--) {
        int field[5][5];
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> field[i][j];
            }
        }
        int max = 0;
        for (int y = 0; y < 5; y++) {
            for (int x = 0; x < 5; x++) {
                if (field[y][x] == 0) {
                    continue;
                }
                int w = 5 - x, h = 5 - y;
                for (int nx = x + 1; nx < 5; nx++) {
                    if (field[y][nx] == 0) {
                        w = nx - x;
                        break;
                    }
                }
                for (int ny = y + 1; ny < 5; ny++) {
                    if (field[ny][x] == 0) {
                        h = ny - y;
                        break;
                    }
                }
                for (int dy = 0; dy < h; dy++) {
                    for (int dx = 0 ; dx < w; dx++) {
                        bool isRectangle = true;
                        for (int ny = y; ny <= y + dy; ny++) {
                            for (int nx = x; nx <= x + dx; nx++) {
                                if (field[ny][nx] == 0) {
                                    isRectangle = false;
                                    break;
                                }
                            }
                        }
                        if (isRectangle && max < (dy + 1) * (dx + 1)) {
                            max = (dy + 1) * (dx + 1);
                        }
                    }

                }
            }
        }
        cout << max << endl;
    }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int N;
vector<int64_t> A;

int main() {
  cin >> N;
  A.resize(N); cin >> A;
  rep(i, N) {
    A[i] -= i;
  }
  sort(all(A));
  auto m = A[A.size()/2];
  int64_t sum = 0;
  rep(i, N) {
    sum += abs(A[i] - m);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

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

using namespace std;
typedef long long ll;
const int INF = INT_MAX / 4;

const int max_a = 1e6;


class BIT
{
public:
  vector<int> bit;
  int size;

  BIT(int size)
    : bit(vector<int>(size + 1, 0)), size(size)
  {}

  int sum(int i) {
    int r = 0;
    while (i > 0) {
      r += bit[i];
      i -= (i & -i);
    }
    return r;
  }

  void add(int i, int x) {
    while (i <= size) {
      bit[i] += x;
      i += (i & -i);
    }
  }
};


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

  while(1) {
    int N;
    cin >> N;
    if (N == 0) return 0;

    int a[N];
    REP(i, N) cin >> a[i];
    BIT bit(max_a);
    int ans = 0;
    REP(i, N) {
      ans += i - bit.sum(a[i]);
      bit.add(a[i], 1);
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 7064
#include <iostream>

using namespace std;

int max_index(int n[], int size) {
    int idx = 0;
    for (int i = 0; i < size; ++i) {
        if (n[idx] < n[i])
            idx = i;
    }
    return idx;
}

int main() {
    int n[3];
    for (int i = 0; i < 3; ++i)
        cin >> n[i];
    int k;
    cin >> k;

    for (int i = 0; i < k; ++i) {
        int m = max_index(n, 3);
        n[m] *= 2;
    }

    int sum = 0;
    for (int i = 0; i < 3; ++i)
        sum += n[i];
    cout << sum << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
int main() {
    int N;
    cin >> N;
    vector<double> A(N);
    rep(i,N) {
        cin >> A[i];
    }
    double over=0.0;
    rep(i,N) over+=1/A[i];
    cout << 1/over << endl;
    return 0;
}

Measured memory_bytes: 256
let fn1: string -> int =
  Seq.distinct >> Seq.length

let fn2: string -> int =
  fun s ->
    [0..(s.Length - 1)]
    |> Seq.fold (fun m i ->
      let m2 =
        match Map.tryFind s.[i] m with
        | Some _ -> m
        | _ -> m.Add (s.[i], fn1 s.[(i + 1)..])
      // printfn "fn2: %d %A %A" i s.[i] m2
      m2
    ) Map.empty
    |> Seq.sumBy (fun x -> x.Value)

let fn3: string -> int =
  fun s ->
    [0..(s.Length - 1)]
    |> Seq.fold (fun m i ->
      let m2 =
        match Map.tryFind s.[i] m with
        | Some _ -> m
        | _ -> m.Add (s.[i], fn2 s.[(i + 1)..])
      // printfn "fn3: %d %A %A" i s.[i] m2
      m2
    ) Map.empty
    |> Seq.sumBy (fun x -> x.Value)

stdin.ReadLine()
|> ignore
|> fun () -> stdin.ReadLine()
|> fn3
|> printfn "%d"


Measured memory_bytes: 30156
#include<bits/stdc++.h>
using namespace std;
long long n,k,m,a[25001],b[401],dp1[25001][401],dp2[25001][401],mod=1e9+7;
inline long long read()
{
    long long sum=0,x=1;
    char ch=getchar();
    while (ch<'0'||ch>'9')
	{
        if (ch=='-')
		  x=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9')
	{
        sum=sum*10+ch-'0';
        ch=getchar();
    }
    return sum*x;
}
inline void write(long long x)
{
    if (x<0)
	{
        putchar('-');
        x=-x;
    }
    if (x>9)
      write(x/10);
    putchar(x%10+'0');  
    return;
}
inline long long dfs(long long x,long long y)
{
    long long s=1;
    while (y>0)
    {
        if (y%2==1)
		  s=s*x%mod;
        x=x*x%mod;
		y/=2;
    }
    return s;
}
inline long long sr(long long x)
{
    long long s=1;
    for (register long long i=1;i<=x;++i)
	  s=s*i%mod;
    return s;
}
int main()
{
    n=read();k=read();m=read();
    for (register long long i=1;i<=m;++i)
	  a[i]=read();
    long long mx=0,xx=0,ans=(n-m+1)*dfs(k,n-m)%mod;
    for (register long long i=1;i<=m;++i)
    {
        xx=min(xx+1,i-b[a[i]]);
        b[a[i]]=i;
		mx=max(mx,xx);
    }
    if (mx==k)
	{
	    write(ans);
		return 0;
	}
    if (mx==m)
    {
        dp1[0][0]=1;
        for (register long long i=1;i<=n;++i)
        {
            long long s=0,t=0;
            for (register long long j=k-1;j>0;--j)
            {
                s=(s+dp1[i-1][j])%mod;
                t=(t+dp2[i-1][j])%mod;
                dp1[i][j]=(dp1[i][j]+dp1[i-1][j-1]*(k-j+1)%mod)%mod;
                dp2[i][j]=(dp2[i][j]+dp2[i-1][j-1]*(k-j+1)%mod)%mod;
                dp1[i][j]=(dp1[i][j]+s)%mod;
                dp2[i][j]=(dp2[i][j]+t)%mod;
                if (j>=m)
				  dp2[i][j]=(dp2[i][j]+dp1[i][j])%mod;
            }
        }
        long long w=0;
        for (register long long i=1;i<=k;++i)
		  w=(w+dp2[n][i])%mod;
        w=w*sr(k-m)%mod*dfs(sr(k),mod-2)%mod;
        write((ans-w+mod)%mod);
    }else
    {
        long long u=0,v=0;
        memset(b,0,sizeof(b));
        for (register long long i=1;i<=m;++i)
          if (!b[a[i]])
		  {
			++u;
			b[a[i]]=1;
		  }else
		    break;
        memset(b,0,sizeof(b));
        for (register long long i=m;i>0;--i)
          if (!b[a[i]])
		  {
			++v;
			b[a[i]]=1;
		  }else
		    break;
        dp1[0][u]=dp2[0][v]=1;
        for (register long long i=1;i<=n;++i)
        {
            long long s=0,t=0;
            for (register long long j=k-1;j>0;--j)
            {
                s=(s+dp1[i-1][j])%mod;
                t=(t+dp2[i-1][j])%mod;
                dp1[i][j]=(dp1[i][j]+dp1[i-1][j-1]*(k-j+1)%mod)%mod;
                dp2[i][j]=(dp2[i][j]+dp2[i-1][j-1]*(k-j+1)%mod)%mod;
                dp1[i][j]=(dp1[i][j]+s)%mod;
                dp2[i][j]=(dp2[i][j]+t)%mod;
            }
        }
        for (register long long i=0;i+m<=n;++i)
        {
            long long s=0,t=0;
            for (register long long j=1;j<k;++j)
		    {
			    s=(s+dp1[i][j])%mod;
			    t=(t+dp2[n-m-i][j])%mod;
		    }
            ans=(ans-s*t%mod+mod)%mod;
        }
        write(ans);
    }
    return 0;
}

Measured memory_bytes: 160332
n, k = map(int, input().split())

ans = 0

l = [0] * (n+2)
minv = 0
maxv = n

#print(l)
for i in range(1, n+2):
  #print(i)
  l[i] = maxv - minv + 1
  minv += i
  maxv += (n-i)

for i in range(k, n+2):
  ans = (ans + l[i]) % (10**9 + 7)

print(ans)

Measured memory_bytes: 65900
#include <cstring>
#include <iostream>
#include <queue>

using namespace std;

int H, W, N;
char map[1024][1024];
int dist[1024][1024];
int factories[10];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

int bfs(int from, int to)
{
    queue<int> q;
    q.push(from);
    dist[from / W][from % W] = 0;
    int fx = to % W;
    int fy = to / W;
        
    while (!q.empty())
    {
        int x = q.front() % W;
        int y = q.front() / W;
        q.pop();
        if (x == fx && y == fy)
        {
            return dist[fy][fx];
        }
        for (int d = 0; d < 4; ++d)
        {
            int nx = x + dx[d];
            int ny = y + dy[d];
            if (0 <= nx && nx < W && 0 <= ny && ny < H &&
                map[ny][nx] != 'X' && dist[ny][nx] == -1)
            {
                q.push(ny * W + nx);
                dist[ny][nx] = dist[y][x] + 1;
            }
        }
    }
    
}

void solve()
{
    int result = 0;
    for (int i = 0; i < N; ++i)
    {
        memset(dist, -1, sizeof dist);
        result += bfs(factories[i], factories[i + 1]);
    }
    cout << result << endl;
}

int main()
{
    cin >> H >> W >> N;
    for (int h = 0; h < H; ++h)
    {
        for (int w = 0; w < W; ++w)
        {
            cin >> map[h][w];
            if (isdigit(map[h][w]))
            {
                factories[map[h][w] - '0'] = h * W + w;
            }
            if (map[h][w] == 'S')
            {
                factories[0] = h * W + w;
            }
        }
    }
	solve();
    return 0;
}

Measured memory_bytes: 8208
#include <iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)//最大公約数
{
  if (a % b == 0)
  {
    return(b);
  }
  else
  {
    return(gcd(b, a % b));
  }
}

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

int main()
{
  ll a, b;
  cin >> a >> b;
  
  cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))

ans = 0

def dfs(n, visited):
    global ans
    visited.append(n)
    if len(visited) == N:
        ans += 1
    else:
        for i in l[n-1]:
            if i not in visited:
                dfs(i, visited)
    visited.remove(n)

l = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    l[a-1].append(b)
    l[b-1].append(a) 

dfs(1, [])
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        
        List<Integer> nums2 = new ArrayList<Integer>();
        if (n % 2 == 0) {
            for (int i = n - 1; i >= 1; i -= 2) {
                nums2.add(nums[i]);
            }
            for (int i = 0; i <= n - 2; i += 2) {
                nums2.add(nums[i]);
            }
        } else {
            for (int i = n - 1; i >= 0; i -= 2) {
                nums2.add(nums[i]);
            }
            for (int i = 1; i <= n - 2; i += 2) {
                nums2.add(nums[i]);
            }
        }
        
        for (int i = 0; i < n; i++) {
            System.out.print(nums2.get(i));
            
            if (i != n - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
// #define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  map<string, int> smap;
  
  REP(i, N) {
    string s;
    cin >> s;
    smap[s] += 1;
  }
  
  int M;
  cin >> M;
  map<string, int> tmap;
  
  REP(i, M) {
    string t;
    cin >> t;
    tmap[t] += 1;
  }
  
  int res = 0;
  
  auto begin = smap.begin(), end = smap.end();
  for (auto iter = begin; iter != end; iter++) {
    // first: key, second: value
    auto key = iter->first;
    auto val = iter->second;
    
    int res2 = val - tmap[key];
    if (res2 > res) {
      res = res2;
    }
  }
  
  cout << res;
}

Measured memory_bytes: 256
// Ballazt
//0a..brute force
//0b..greedy
//1..memorizatton of some sort	remember something cleverly
//2..sort
//3..binary search	keep check a particular solution
//4..dp				repeating strucutre,limited choices
//5..dfs/bfs		matrix with obstacles
//6..correlate to graph in some way		each state is a point
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"


int main()

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

	
	
	
	ll n,m;
	cin>>n>>m;

	vector<pair<ll,ll>> heights;
	heights.push_back(make_pair(-1,-1));
	for(int i=1;i<=n;i++)
	{
		ll h;
		cin>>h;
		heights.push_back(make_pair(h,0));


	}

	// for(int i=1;i<=n;i++)
	// {
	// 	cout<<" heights ";
	// 	cout<<heights[i].first<<" "<<heights[i].second<<endl;


	// }


	vector<pair<ll,ll>> road;



	for(int i=1;i<=m;i++)
	{
		ll r1,r2;

		cin>>r1>>r2;

		if(heights[r1].first>heights[r2].second)
		{

			heights[r2].second=heights[r1].first;
		}

		if(heights[r2].first>heights[r1].second)
		{
			heights[r1].second=heights[r2].first;
		}


		road.push_back(make_pair(r1,r2));

	}

	ll count1=0;
	for(int i=1;i<=n;i++)
	{
		if(heights[i].first>heights[i].second)
			 count1++;

	}

	// ll count=0;
	// for(int i=1;i<=n;i++)
	// {
	// 	if(!conn[i]) count++;
	// }

	cout<<count1<<endl;


	//cout<<"end of loop";
	return 0;
	
}

Measured memory_bytes: 7888
N,K,Q=map(int,input().split())
ans=[K]*N
if K>Q:
  for i in range(N):
    print('Yes')
else:
  for i in range(Q):
    A=int(input())
    ans[A-1]+=1
  for i in ans:
    i-=Q
    if i<=0:
      print('No')
    else:
      print('Yes')



Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    string s;cin >> s;
    int n = s.length();
    int c = 0;
    for (int i = 0; i < n/2; i++) {
        if(s[i] != s[n - 1 - i]) c++;
    }
    cout << c << endl;
    return 0;
}


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

int main() {
  string ans;
  int D, T, S;
  cin >> D >> T >> S;
  if (D > T * S) {
    ans = "No";
  } else {
    ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
int dp[2050];
const int mod=1e9+7;
int main(){
    int n;
    cin>>n;
    dp[0]=1;
    for(int i=3;i<=n;++i)
        for(int j=3;j<=i;++j){
            dp[i]+=dp[i-j];
            if(dp[i]>=mod)dp[i]-=mod;
        }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 3468
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
ll gcd(ll a, ll b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll A, B;

int main() {
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}


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

#define ll long long
const int MOD = 1e9+7;
ll mod(ll x) {
	return (x%MOD + MOD) %MOD;
}
ll mul(ll a,ll b) {
	return mod(mod(a) * mod(b));
}

ll bs(vector<ll> &v,ll l,ll r,ll key) {
	//cout << low << " " << high << endl;
	while (r - l > 1) { 
	       int m = l + (r - l) / 2; 
	       if (v[m] >= key) 
	           r = m; 
	       else
	           l = m; 
	   } 
	 
	return (v[r] > key)?l:r; 
}
int main() {
	int n,m,k;
	cin >> n >> m >> k;
	vector<ll> a(n+1);
	vector<ll> b(m+1);
	ll sum = 0;
	for(int i = 1;i <= n;i++) {
		cin >> a[i];
		a[i] += sum;
		sum = a[i];
	}
	sum = 0;
	for(int i = 1;i<=m;i++) {
		cin >> b[i];
		b[i] += sum;
		sum = b[i];
	}
	ll j = m;
	ll result = 0;
	for(int i = 0; i <=n && a[i] <= k ;i++)
	{
		j = bs(b,0,j,(k-a[i]));
		if(j == -1) break;
		result = max(result,i+j);
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    vec A(N); readv(A);
    map<int, int> m;
    REP(i, N) m[-A[i]] += 1;

    int ans = 0;
    for(Pii p: m){
        int x = -p.first;
        int n = 1;
        while(n <= x) n = (n << 1);
        int y = n - x;
        if(x == y) ans += m[-x] / 2;
        else if(x > y){
            int u = min(m[-x], m[-y]);
            if(u > 0){
                ans += u;
                m[-y] -= u;
            }
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 87040
from itertools import accumulate
n = int(input())
s = list(input())
for i in range(n):
    if s[i] == "#":
        s[i] = 1
    else:
        s[i] = 0
cs = [0] + list(accumulate(s))
m = n
for i in range(n+1):
    num = cs[i] + (n-i)-(cs[n]-cs[i])
    m = min(m,num)
print(m)

Measured memory_bytes: 14368
import java.util.*;
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int i,j;
    for(i=0;i<s.length();i++) {
      if (s.charAt(i)=='A') break;
      }
    for(j=s.length()-1;j>=0;j--) {
      if(s.charAt(j)=='Z') break;
    }    
    System.out.println(j-i+1);
    
  }
}


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

using namespace std;
#define LL long long
LL a[1005],b[1005],c[1005];

vector <LL> ans;

int main()
{
    LL x,y,z,k;
    while(cin>>x>>y>>z>>k)
    {
        for(int i=0;i<x;i++)
            cin>>a[i];
        for(int i=0;i<y;i++)
            cin>>b[i];
        for(int i=0;i<z;i++)
            cin>>c[i];
        sort(a,a+x,greater<LL>());
        sort(b,b+y,greater<LL>());
        sort(c,c+z,greater<LL>());
        for(int i=0;i<x;i++)
        {
            for(int j=0;j<y;j++)
            {
                for(int l=0;l<z;l++)
                {
                    if((i+1)*(j+1)*(l+1)<=k)
                        ans.push_back(a[i]+b[j]+c[l]);
                    else break;
                }
            }
        }
        sort(ans.begin(),ans.end(),greater<LL>());
        for(int i=0;i<k;i++)
        {
            cout<<ans[i]<<endl;
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  if (N%3 != 0) {
    for (int i=0; i<N; i++) {
      if (A[i] != 0) {
        break;
      }
      if (i == N-1) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
    return 0;
  }
  
  sort(A.begin(),A.end());
  
  int a1 = A[0];
  int a2 = A[N/3];
  int a3 = A[N/3 * 2];
  int ap = a1 ^ a2;
  
  if (ap != a3) {
    cout << "No" << endl;
    return 0;
  }
  for (int i=0; i<N/3; i++) {
    if (A[i] != a1) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i=N/3; i<N/3 * 2; i++) {
    if (A[i] != a2) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i=N/3 * 2; i<N; i++) {
    if (A[i] != a3) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int amount = s.nextInt();
		int[] nums = new int[amount];
		int total = 0;
		for(int i = 0; i < amount; i++) {
			nums[i] = s.nextInt();
		}
		for(int i = 0; i < amount; i++) {
			for(int j = 1+i; j < amount; j++) {
				total += nums[i] * nums[j];
			}
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
long long  n,arr[100009],Dp[100009];
int k;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    for(int i=2;i<=n;i++)
    {
        Dp[i]=Dp[i-1]+abs(arr[i]-arr[i-1]);
        for(int j=1;j<=k;j++)if(i-j>0)
            Dp[i]=min(Dp[i-j]+abs(arr[i-j]-arr[i]),Dp[i]);

    }
    cout<<Dp[n];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  vector<ll> vec=divisor(M);
  reverse(ALL(vec));
  REP(i,vec.size()){
    if(M/vec.at(i)>=N){
      cout << vec.at(i) << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007 
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
template <typename T>
#define all(v) v.begin(),v.end()
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
 
    x = x % p;
    while (y > 0)
    {
 
        if (y & 1)
            res = (res * x) % p;
 
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;//cin>>tc; 
    while (tc--)
    {
      int n;
      cin>>n;
      int a=n/500;
      a*=1000;
      n%=500;
      n/=5;
      a+=n*5;
      cout<<a<<endl;

    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if (a == 1){
        if(b == 2){
            cout << 3;
        }
        if(b == 3){
            cout << 2;
        }
    }
    if (a == 2){
        if(b == 1){
            cout << 3;
        }
        if (b==3){
            cout << 1;
        }
    }
    if (a == 3){
        if (b == 1){
            cout << 2;
        }
        if(b==2){
            cout << 1;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 INF = 1e18;

//エラトステネスの篩
std::vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main(){
    int n;
    cin >> n;
    vector<int>ans;
    sieve(56000);
    int now = 11;
    while(ans.size()!=n){
        if(IsPrime[now]){
            ans.push_back(now);
        }
        now += 10;
    }
    rep(i,n){
        cout << ans[i] << endl;
    }

    return 0;
}


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

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

    string S; cin >> S;

    vector<int> m(S.size());

    int r = 0, l = 0;
    int i = 0, j = 0;
    while (j < S.size()) {
        for (i = j ; S[i] == 'R'; i++) r++;
        for (j = i ; S[j] == 'L'; j++) l++;
        m[i]   = l - l / 2 + r / 2;
        m[i-1] = l / 2 + r - r / 2;
        r = l = 0;
    }

    for (auto x:m) cout << x << " ";
    cout << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int,string> pis;


#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int N;
    cin >> N;
    vector<pis> ps(N);
    set<string> vs;
    REP(i,N){
        string s;
        int p;
        cin >> s >> p;
        vs.insert(s);
        ps[i]=pis(p,s);
    }
    // sort(all(ps));
    vector<string> svec(vs.begin(), vs.end());
    // sort(all(setvec));
    // reverse(all(setvec));

    for(int i=0;i<svec.size();i++){
        string tmps  = svec[i];
        vector<pii> tmpv;
        for(int j=0;j<N;j++){
            if(tmps==ps[j].second){
                tmpv.push_back(pii(ps[j].first,j+1));
            }
        }
        sort(all(tmpv));
        reverse(all(tmpv));
        for(int j=0;j<tmpv.size();j++){
            cout << tmpv[j].second << endl;
        }
    }
}



Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int n; cin >> n;
    map<int, int> as;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        as[a]++;
    }
    int acc = 0, ans = 0;
    for(auto p : as){
        acc += p.second - 1;
        ans++;
    }
    cout << ans - acc % 2 << '\n';
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>
struct Point{
	double x,y;
};

void koch(int n, Point a, Point b)
{
	if(n==0) return;
	Point s,t,u;
	double th = M_PI * 60 / 180;

	s.x = (2 * a.x + 1 * b.x) / 3;
	s.y = (2 * a.y + 1 * b.y) / 3;
	t.x = (1 * a.x + 2 * b.x) / 3;
	t.y = (1 * a.y + 2 * b.y) / 3;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n-1, a, s);
	printf("%.8f %.8f\n",s.x, s.y);
	koch(n-1, s, u);
	printf("%.8f %.8f\n",u.x, u.y);
	koch(n-1, u, t);
	printf("%.8f %.8f\n",t.x, t.y);
	koch(n-1, t, b);
}


int main()
{
	int n;
	scanf("%d",&n);
	Point a,b;
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	
	printf("%.8f %.8f\n",a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n",b.x, b.y);
	
	return 0;
}

Measured memory_bytes: 2664
#include<stdio.h>

static const char* test[4]= {"AC","WA","TLE","RE"};

int main(){
	int n; scanf("%d", &n);
	int s[100005];
	int testcnt[4] = {0,0,0,0};
	while(n != 0){
		char temp[3]; scanf("%s", temp);
		if(temp[0] == 'A') testcnt[0]++;
		else if(temp[0] =='W')testcnt[1]++;
		else if(temp[0] == 'T') testcnt[2]++;
		else testcnt[3]++;
		n--;
	}
	
	for(int i = 0; i<4;i++){
		printf("%s x %d\n", test[i], testcnt[i]);
	}
	
	return 0;
}

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

int main(){
    ll n,k;
    cin>>n>>k;
    if(k>(n-1)*(n-2)/2){
        cout<<"-1"<<endl;
        return 0;
    }
    cout<<n-1+(n-1)*(n-2)/2-k<<endl;
    for(ll i=2;i<=n;i++){
        cout<<1<<" "<<i<<endl;
    }
    ll cnt=0;
    for(ll i=2;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            cnt++;
            if((n-1)*(n-2)/2-k>=cnt)cout<<i<<" "<<j<<endl;
        }
    }
}


Measured memory_bytes: 256
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1

bool = false
for(i=1; i<=9; i++) {
    d = N/i
    if (d <= 9 && d == ~~d) {
        bool = true
        break;
    }
}
console.log(bool ? 'Yes' : 'No')


Measured memory_bytes: 21064
n,y=map(int,input().split())
flag=0
for i in range(n+1):
    for j in range(n+1-i):
        x=10000*i+5000*j+1000*(n-i-j)
        if x==y:
            flag=1
            res=(i,j,n-i-j)
if flag==0:
    print(-1,-1,-1)
else:
    print(res[0],res[1],res[2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            long double d,t,s;
            cin>>d>>t>>s;
            if(d/s<=t) cout<<"Yes";
            else cout<<"No";
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3820
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;cin>>a>>b>>c;
    if(c>=a&&c<=b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256