akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;

#define mp make_pair
#define pb push_back
#define f first
#define s second 
#define MOD 10000000009
#define HASH 134762

ll n, a;

int main()
{
	ll res=0;
	cin>>n;
	while(n--)
		cin>>a, res+=a-1;
	cout<<res<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func check(e error) {
	if e != nil {
		log.Fatalf("error: %v", e)
	}
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	firstInputs := strings.Split(stdin.Text(), " ")
	N, err := strconv.Atoi(firstInputs[0])
	check(err)
	T, err := strconv.Atoi(firstInputs[1])
	check(err)

	min := 1001
	for i := 1; i <= N; i++ {
		stdin.Scan()
		inputs := strings.Split(stdin.Text(), " ")
		cost, err := strconv.Atoi(inputs[0])
		check(err)
		time, err := strconv.Atoi(inputs[1])
		check(err)

		if time <= T {
			if cost < min {
				min = cost
			}
		}
	}

	if min == 1001 {
		fmt.Println("TLE")
	} else {
		fmt.Println(min)
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{

  ll n; cin >> n;
  ll a = 1e9;
  ll x1 = a;
  ll x2 = a - n%a;
  ll y1 = 1;
  ll y2 = n/a + 1;
  if(n == 1e18){
    x1 = a;
    x2 = 0;
    y1 = 0;
    y2 = a;
  }
  cout <<"0 0 "<< x1<< " " << y1 << " " << x2 << " " << y2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int f(long long l) {
	int r = 0;
	while (l) {
		r += l % 10;
		l /= 10;
	}
	return r;
}
int main() {
	long long n; cin >> n;
	if (!(n%f(n)))cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
from numpy import*
from scipy.sparse import*
_,*s=open(0)
s=array([list(map(int,t[:-1]))for t in s])
g=csr_matrix(s)
m=csgraph.floyd_warshall(g)
i=m[0]%2<1
j=i^True
print(all(s[i][:,i]==0)*all(s[j][:,j]==0)*int(m.max()+1)or-1)

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

using namespace std;

class BIT {
private:
  
  vector<int> bit;
  int size;
  
public:
  
  BIT(int n) : size(n)
  {
    bit.resize(n+1);
  }
  
  int sum(int i) {
    int s = 0;
    while(i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  
  void add(int i, int x) {
    while(i <= size) {
      bit[i] += x;
      i += i & -i;
    }
  }
  
};

int main() {
  int n, q;
  int com, x, y;
  cin >> n >> q;
  BIT b(n);
  while(q--) {
    cin >> com >> x >> y;
    if(com == 0) {
      b.add(x, y);
    }
    else {
      cout << b.sum(y) - b.sum(x-1) << endl;
    }
  }
  return 0;
}

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

using namespace std;

int main(){
    
    std::vector <int> list(3);
    cin >> list.at(0) >> list.at(1) >> list.at(2); 
    
    std::sort(list.begin(), list.end());

    cout <<  list.at(0) << " " << list.at(1) << " " << list.at(2) << endl;
    
    return 0;
}


Measured memory_bytes: 3144
#include <iostream>

int main(){
	int H,W;
	std::cin>>H>>W;

	std::string grid[60];
	for(int i=0;i<H;++i)std::cin>>grid[i];

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

	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			if(grid[i][j] == '#'){
				bool paintable = false;
				for(int k=0;k<4;++k){
					if(i+dy[k] >= 0 && i+dy[k] <= H &&
						j+dx[k] >= 0 && j+dx[k] <= W){
						char tempDot = grid[i+dy[k]][j+dx[k]];
						if(tempDot == '#')paintable = true;
					}
				}
				if(!paintable){
					std::cout<<"No";
					return 0;
				}
			}
		}
	}
	std::cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int n,a,b;
    cin >> n >> a >> b;
    cout << ((n+a-1)/a)*b;
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	int vis[10];
	memset(vis,0,sizeof(vis));
	cin>>n;
	char s;
	int x=2*n;
    while(x--)
	{
		s=getchar();
		if(s=='G')
		   vis[1]=1;
		if(s=='W')
		   vis[2]=1;
		if(s=='P')
		   vis[3]=1;
		if(s=='Y')
		   vis[4]=1;
    }
	for(int i=1;i<=4;i++)
	{
		if(vis[i]==0)
		{
			cout<<"Three"<<endl;
			return 0;
		}
	}
	cout<<"Four"<<endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max({a,b,c})-min({a,b,c})<<endl;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, C, K;
int T[100010];

int main() {
	cin >> N >> C >> K;
	rep(i, N) cin >> T[i];
	sort(T, T + N);

	int ret = 0;
	int cur = 0;
	int la = -1;

	rep(i, N) {
		if (la != -1 && la + K < T[i]) {
			++ret;
			cur = 1;
			la = T[i];
		} else {
			if (la == -1) {
				la = T[i];
			}
			++cur;
		}

		if (cur == C) {
			++ret;
			la = -1;
			cur = 0;
		}
	}

	if (cur > 0) ++ret;
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int cnt0[101010],cnt1[101010];
int ma1[101010],ma2[101010];
int main()
{
	int n,x,ans=0;
	scanf("%d",&n);
	memset(cnt0,0,sizeof(cnt0));
	memset(cnt1,0,sizeof(cnt1));
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(i&1)
			cnt1[x]++;
		else
			cnt0[x]++;
	}
	ma1[0]=0;
	ma2[100001]=0;
	for(int i=1;i<=100000;i++)
		ma1[i]=max(ma1[i-1],cnt1[i]);
	for(int i=100000;i>=1;i--)
		ma2[i]=max(ma2[i+1],cnt1[i]);
	for(int i=1;i<=100000;i++)
		ans=max(ans,cnt0[i]+max(ma1[i-1],ma2[i+1]));
	printf("%d",n-ans);
	return 0;
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 r, g, b, n;
    cin >> r >> g >> b >> n;

    i64 ans = 0;
    for (i64 i = 0; r * i <= n; i++) {
        for (i64 j = 0; r * i + g * j <= n; j++) {
            if ((n - r * i - g * j) % b == 0) ans++;
        }
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	char pic[103][103];
	int h, w; cin >> h >> w;
	for (int i = 0; i < h + 2; i++)
		for (int j = 0; j < w + 2; j++){
			if (i == 0 || j == 0)pic[i][j] = '#';
			else if (i == h + 1 || j == w + 1)pic[i][j] = '#';
			else cin >> pic[i][j];
		}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) cout << pic[i][j];
		cout << endl;
	}
	char c; cin >> c;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

int min(int a, int b){
    return a < b ? a : b;
}

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    if (tail == LEN) tail = 1;
    else tail++;
}

P dequeue(){
    P x = Q[head];
    if (head == LEN) head = 1;
    else head++;
    return x;
}

int main(){
    int elaps = 0, c, i, q;
    P u;
    scanf("%d%d", &n, &q);
    for (i = 1; i <= n; i++) scanf("%s%d", Q[i].name, &Q[i].t);
    head = 1;
    tail = n + 1;
    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else {
            printf("%s %d\n",u.name, elaps);
        }
    }
    return 0;
}


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

int main(){
  char b;
  cin >> b;
  if(b == 'A') cout << 'T' << endl;
  if(b == 'T') cout << 'A' << endl;
  if(b == 'G') cout << 'C' << endl;
  if(b == 'C') cout << 'G' << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

signed main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll start, end;
    if(n % 2){
        /* n が奇数 */
        start = n-1;
        end = n-2;
        for(int i = start; i >= 0; i -= 2){
            cout << a[i] << " ";
        }
        for(int i = 1; i <= end; i += 2){
            cout << a[i] << " ";
        }
    }else{
        /* 偶数 */
        start = n-1;
        end = n-2;
        for(int i = start; i >= 1; i -= 2){
            cout << a[i] << " ";
        }
        for(int i = 0; i <= end; i += 2){
            cout << a[i] << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 4836
#include<math.h>
#include <iostream>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD = 1e9 + 7;

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

	if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << endl;

	}
	else if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << endl;
	}
	else if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
繋がり先と, エッジ番号を持っておけばいい


*/
int main(){
  int N;cin>>N;
  vector<vector<pair<int,int>>>A(N);
  for(int i=0;i<N-1;i++){
    int a,b;cin>>a>>b;
    A[a-1].push_back(pair<int,int>(b-1,i));
    A[b-1].push_back(pair<int,int>(a-1,i));
  }
  int M=0,mpos=-1;
  for(int i=0;i<N;i++){M=(M>A[i].size()?M:A[i].size());mpos=i;}
  cout<<M<<endl;
  
  vector<int>cols(N-1,0);
  queue<pair<int,int>>q;q.push(pair<int,int>(mpos,0));//ノードと, どの色で繋がったのか
  while(q.size()){
    pair<int,int> f=q.front();q.pop();
    int c=1;
    for(int i=0;i<A[f.first].size();i++){
      if(cols[A[f.first][i].second]==0){
        if(c==f.second)c=(c%M)+1;
        cols[A[f.first][i].second]=c;
        q.push(pair<int,int>(A[f.first][i].first,c));
        c=(c%M)+1;
      }
      
    }
  }
  for(int i=0;i<N-1;i++)cout<<cols[i]<<endl;
  
}





Measured memory_bytes: 7040
# -*- coding: utf-8 -*-

N = int(input())
L = list(map(int,input().split()))

L_set = list(set(L))
L_set.sort()
N_set = len(L_set)

L_count = [0] * N_set
for i in range( N_set ):
  L_count[i] = L.count( L_set[i] )

#print(L_set)
#print(L_count)

ans = 0

for i in range( N_set-2 ):
  for j in range( i+1, N_set-1 ):
    for k in range( j+1, N_set ):
      
      if ( L_set[i]+L_set[j] > L_set[k] ):
        ans += L_count[i]*L_count[j]*L_count[k]

print(ans)
    

Measured memory_bytes: 9196
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>

using namespace std;

bool dayinmonth(int month, int day){
    if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10|| month == 12){
        if(day == 31) return true;
        else return false;
    }
    else if(month == 4 || month == 6 || month == 9 || month == 11){
        if(day == 30) return true;
        else return false;
    }
    else if(month == 2){
        if(day == 28) return true;
        else return false;
    }
}

int main(){
    int a, b, c, d;
    cin >> a; cin >> b; cin >> c; cin >> d;
    if(dayinmonth(a, b)) cout << 1;
    else cout << 0;
    return 0;
}

Measured memory_bytes: 384
while True:
    H, W = map(int, input().split(' '))
    if H == W == 0:
        break
    edge = ['#'*W]
    middle = ['#'+'.'*(W-2)+'#']
    box = []
    box.append(edge)
    for i in range(H-2):
        box.append(middle)
    box.append(edge)
    
    for items in box:
        print(items[0])
    print('')


Measured memory_bytes: 5612
N, M = map(int, input().split())
MOD = 1000000007

if N == 1:
    print(1)
    exit()

A = [int(input()) for _ in range(M)]
A = set(A)

lst = [0] * (N + 1)
lst[0] = 1

if 1 not in A:
    lst[1] = 1


for i in range(2, N + 1):
    if i in A:
        lst[i] = 0
        continue

    lst[i] = lst[i - 1] % MOD + lst[i - 2] % MOD

print(lst[-1] % MOD)



Measured memory_bytes: 13216
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	while (1) {
		sum++;
		if (pow(3, sum) >= n) {
			break;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int flag=0,t=0;
	if(s[0]=='A'){
		int i;
		for(i=2;i<s.length()-1;i++){
			if(s[i]=='C'){
				t++;
			}
		}
		if(t!=1){
			flag=1;
		}
		for(i=1;i<s.length();i++){
			if(s[i]>='A'&&s[i]<='Z'&&s[i]!='C'){
				flag=1;
			}
		}
	}else{
		flag=1;
	}
	if(flag==1){
		cout<<"WA"<<endl;
	}else{
		cout<<"AC"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  while (cin >> N, N) {
    int X[N], Y[N], x, y, M, l, G[N], D[2], t = N;
    for (int i = 0; i < N; ++i) {
      cin >> x >> y;
      X[i] = x;
      Y[i] = y;
      G[i] = 1;
    }
    cin >> M;
    string d;
    x = 10;
    y = 10;
    for (int i = 0; i < M; ++i) {
      cin >> d >> l;
      if (d == "N") {
	D[0] = 0;
	D[1] = 1;
      } else if (d == "S") {
	D[0] = 0;
	D[1] = -1;
      } else if (d == "E") {
	D[0] = 1;
	D[1] = 0;
      } else {
	D[0] = -1;
	D[1] = 0;
      }
      for (int j = 0; j < N; ++j) {
	if (G[j] && ((x <= X[j] && X[j] <= x + D[0]*l) || (x >= X[j] && X[j] >= x + D[0]*l)) && ((y <= Y[j] && Y[j] <= y + D[1]*l) || (y >= Y[j] && Y[j] >= y + D[1]*l))) {
	  --t;
	  G[j] = 0;
	}
      }
      x += D[0]*l;
      y += D[1]*l;
    }
    if (t) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << - a.at(N/2 - 1) + a.at(N/2) << endl;
}

Measured memory_bytes: 1024
an=[int(input()) for _ in range(5)]

best = 10**9
import itertools
for pan in itertools.permutations(an):
    s = 0
    for i in range(4):
        q,m=divmod(pan[i],10)
        if m>0:
            q += 1
        s += q*10
    s += pan[4]
    if s < best:
        best = s
print(best)


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

int main(void){
    int n;
    int t, a;
    cin >> n >> t >> a;
    
    int input;
    int dif;
    int idx;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        if(i == 1){
            dif = abs((t * 1000 - input * 6) - a * 1000);
            idx = 1;
        }else{
            if(abs((t * 1000 - input * 6) - a * 1000) < dif){
                dif = abs((t * 1000 - input * 6) - a * 1000);
                idx = i;
            }
        }
    }
    
    cout << idx << endl;
    
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
ret = 0
(n+1).times do |i|
  if((1 <= i) && (i <= 9))
    ret += 1;
  elsif((100 <= i) && (i <= 999))
    ret += 1;
  elsif((10000 <= i) && (i <= 99999))
    ret += 1;
  end
end
puts ret


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


int N, K; 
vector<int> A;
bool ok(int x){
  vector<int> v(N+1, 0);
  REP(i, N){
    v[i+1] = A[i]%x;
  }
  sort(ALL(v));

  REP(i, N) v[i+1] += v[i];

  REP(i, N){
    if(v[i] <= K && (N-(i+1))*x-(v[N]-v[i+1]) <= K) return true;
  }
  return false;
}

signed main() {
  cin >> N >> K;

  A.resize(N);
  REP(i, N) cin >> A[i];

  int sum = 0;
  REP(i, N) sum += A[i];

  int ans = 0;
  for(int i = 1; i*i <= sum; i++){
    if(sum%i == 0){
      if(ok(i)) chmax(ans, i);
      if(ok(sum/i)) chmax(ans, sum/i);
    }
  }

  cout << ans << "\n";

  return 0;
}

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

// ll extended_gcd(ll a, ll b, ll &x, ll &y)
// {
//     if(a==0)
//     {
//         x = 0;
//         y = 1;
//         return b;
//     }
    
//     ll x1,y1;
//     ll g = extended_gcd(b%a, a, x1, y1);
    
//     x = y1-(b/a)*x1;
//     y = x1;
//     return g;
// }

// ll powe(ll x,ll n) {
//   if(x==0) return 0;
//   if(n==0) return 1;
//   ll val = powe(x,n/2);
//   if(n%2) return (((val*val)%N)*x)%N;
//   return (val*val)%N;
// }

// ll comb(ll n, ll k) { 
//     if(k==0) return 1;
//     if(k==n) return 1;
//     return (((mods[n]*invmods[n-k])%N)*invmods[k])%N;
// }

// ll cofac(vector<vector<ll> > &adj) {
//   ll tot = 1, idx;
//   ll res = 1;

//   for(ll i=1;i<adj.size();i++) {
//     idx = i;

//     while(idx<adj.size() && !adj[idx][i])
//       idx++;

//     if(idx==adj.size())
//       return 0;

//     if(idx!=i) {
//       swap(adj[i],adj[idx]);
//       if((idx-i)%2)
//         res = -res;
//     }

//     vector<ll> temp(adj[i].begin(),adj[i].end());

//     ll val = temp[i];
//     for(ll j=i+1;j<adj.size();j++) {
//       ll ids[b] = adj[j][i];

//       for(ll k=i+1;k<adj.size();k++) {
//         adj[j][k] = ((val*adj[j][k])%N - (ids[b]*temp[k])%N + 2*N)%N;
//       }

//       tot = (tot*val)%N;
//     } 
//   }

//   for(ll i=1;i<adj.size();i++)
//     res = (res * adj[i][i])%N;
  
//   ll x,y;
//   extended_gcd(tot,N,x,y);
//   // cout<<(res*x)%N<<endl;
//   return (2*N+(res*x)%N)%N;
// }




int main() {

  ll c = 0;
  ll n;
  string s;
  cin>>n>>s;

  ll perm = 1;
  for(ll i=1;i<=n;i++) {
    perm = (perm*i)%N;
  }
  ll res = 1;

  for(int i=0;i<2*n;i++) {
    if(s[i]=='B') {
      if(c%2){
        res = (res*c)%N;
        c--;
      }
      else
        c++;
    }
    else {
      if((c%2)==0) {
        res = (res*c)%N;
        c--;
      }
      else
        c++;
    }
  }

  if(c!=0){
    cout<<0<<endl;
    return 0;
  }

  res = (res*perm)%N;
  cout<<res<<endl;
  return 0;
} 


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
pair<lli, lli> a[100000];
int main() {
  cin >> n >> m;
  for (lli i=0; i<n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  lli ans = 0;
  sort(&a[0], &a[n]);
  for (lli i=0, r=m; r>0; ) {
    ans += a[i].first * min(a[i].second, r);
    r-=a[i].second;
    ++i;
  }
  cout << ans << '\n';
  return 0;
}



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

int main()
{
	int n, m;
	int point[1000 + 10] = {0};
	vector<int> sec;

	int sum;

	int i, j;

	while (cin >> n >> m, n != 0 && m != 0)
	{
		sec.clear();
		sum = 0;
		for (i = 1; i <= n; i++)
		{
			cin >> point[i];
		}

		for (i = 0; i <= n; i++)
		{
			for (j = i; j <= n; j++)
			{
				sec.push_back(point[i]+point[j]);
			}
		} 

		sort(sec.begin(), sec.end());

		j = sec.size()-1;
		for (i = 0; i <= sec.size() - 1; i++)
		{
			//cout <<"A"<< j << " " <<i << endl;
			while (sec[i] + sec[j] > m && j > 0) j--;
			if (j == 0 && sec[i] + sec[j] > m) j--;

			//cout << "c " << j << endl;
			if (j < 0) break;

			//cout << "B" << sec[i] << " " << sec[j] << endl;

			sum = max(sum, sec[i] + sec[j]);
		}

		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 4960
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    set<int> S{-2, -1, N, N + 1};
    vi id(N + 1);
    rep(i, N) {
        int a;
        cin >> a;
        id[a] = i;
    }
    ll ans = 0;
    for (int i = N; i >= 1; --i) {
        auto it = S.lower_bound(id[i]);
        int d = *++it, c = *--it, b = *--it, a = *--it;
        ll cnt = 0;
        if (b >= 0) cnt += (b - a)*(c - id[i]);
        if (c < N) cnt += (d - c)*(id[i] - b);
        ans += cnt * i;
        S.insert(id[i]);
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;
const int MAXN = 1000;
const int MAXK = 4;
int dp[MAXN][MAXK][2];

int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  int n = s.length();
  dp[0][0][0] = 1;

  rep(i, n) rep(j, 4) rep(k, 2)  {
    int c = s[i] - '0';
    
    rep(l, 10) {
      int ni = i + 1, nj = j, nk = k;

      if (l != 0) nj++;
      if (nj > K) continue;

      if (k == 0) {
        if (l < c) nk = 1;
        else if (l > c) break;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
}

Measured memory_bytes: 3628
from collections import defaultdict, Counter
H, W, N = map(int, input().split())
L = []
for _ in range(N):
    a, b = map(int, input().split())
    L.append([a, b])

# 黒いマスからスタートして右下の3 * ３グリッドマスにたどり着きたい場合はこう！
d = defaultdict()
for i in range(N):
    for sx in range(3):
        for sy in range(3):
            if 3 <= L[i][0] + sx <= H and 3 <= L[i][1] + sy <= W:
                if (L[i][0] + sx, L[i][1] + sy) not in d:
                    d[(L[i][0] + sx, L[i][1] + sy)] = 1
                else:
                    d[(L[i][0] + sx, L[i][1] + sy)] += 1

# print(d)
c = Counter(d.values())
ans = [0 for _ in range(10)]

for k, v in c.items():
    if v > 0:
        ans[k] = v

ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

for i in ans:
    print(i)


Measured memory_bytes: 179588
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if(s=="AAA"
    ||s=="BBB"){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
            }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    string a, b, c;
    scan(a);
    scan(b);
    scan(c);

    int ans;

    foreach (i ; 0 .. n) {
        if (a[i] == b[i] && b[i] == c[i]) {

        }
        else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
            ans++;
        }
        else {
            ans += 2;
        }
    }

    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long n;
long long gcd(long long x,long long y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=3500;i++)
	{
		for(int j=i;j<=3500;j++)
		{
			long long g=gcd(i*j,i+j);
			long long z=(i+j)/g,m=i*j/g;
			long long gg=gcd(m,n);
			long long fst=4LL*m/gg-z*n/gg;
			if(fst<=0)continue;
			long long snd=m*n/gg;
			if(snd%fst==0)
			{
				printf("%d %d %d",i,j,snd/fst);
				return 0;
			}
		}
	}
	return 0;
} 

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

int main()
{
    const int MAX_N = 600;
    int n, m;
    std::cin >> n >> m;

    struct Room
    {
        std::vector<int> next;
        double e = 0.0;
        double p = 0.0;
    };
    Room *r = new Room[n];

    int *s = new int[m];
    int *t = new int[m];

    for (int i = 0; i < m; ++i)
    {
        std::cin >> s[i] >> t[i];
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (i == s[j] - 1)
            {
                r[i].next.push_back(t[j] - 1);
            }
        }
    }

    for (int i = n - 2; i >= 0; --i)
    {
        for (int j = 0; j < r[i].next.size(); ++j)
        {
            r[i].e += r[r[i].next[j]].e;
        }
        r[i].e /= (double)(r[i].next.size());
        r[i].e += 1.0;
    }

    r[0].p = 1.0;
    for (int i = 0; i < n - 1; ++i)
    {
        for (int j = 0; j < r[i].next.size(); ++j)
        {
            r[r[i].next[j]].p += r[i].p / (double)r[i].next.size();
        }
    }

    double max = 0.0;
    for (int i = 0; i < n - 1; ++i)
    {
        if (r[i].next.size() > 1)
        {
            double sum = 0.0;
            for (int j = 0; j < r[i].next.size(); ++j)
            {
                sum += r[r[i].next[j]].e;
            }

            for (int j = 0; j < r[i].next.size(); ++j)
            {
                double exp = r[i].p * (r[i].e - 1.0 - (sum - r[r[i].next[j]].e) / (double)(r[i].next.size() - 1));
                if (exp > max)
                {
                    max = exp;
                }
            }
        }
    }

    std::cout << std::setprecision(20) << r[0].e - max << std::endl;

    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int a,b;
	cin >> a >> b;
	int x= (a+b);
	if(x%2==0)
		cout << x/2 << endl;
	else
		cout << "IMPOSSIBLE" << endl;
}


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

int main() {
	int A,B,C,X;
	int i,j,k,count=0;
	cin>>A>>B>>C>>X;
	for(i=0;i<=A;i++){
		for(j=0;j<=B;j++){
			for(k=0;k<=C;k++){
				if((500*i+100*j+50*k)==X)count++;
			}
		}
	}
	
	cout<<count<<endl;
}


Measured memory_bytes: 256
<?php
$s = fgets(STDIN);
$p = fgets(STDIN);

$s_chars = preg_split('//', trim($s), -1, PREG_SPLIT_NO_EMPTY);
$p_chars = preg_split('//', trim($p), -1, PREG_SPLIT_NO_EMPTY);

$result = 'No';

for ($i = 0; $i < count($s_chars); $i++) {
    $matches = true;

    for ($j = 0; $j < count($p_chars); $j++) {
        $pos = ($i + $j) % count($s_chars);

        if ($s_chars[$pos] !== $p_chars[$j]) {
            $matches = false;
            break;
        }
    }

    if ($matches) {
        $result = 'Yes';
        break;
    }
}

echo "$result\n";

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,k;
  cin >> n >> k;
  vector<P> s(n);
  rep(i,n){ cin>>s[i].S>>s[i].F; }
  sort(s.rbegin(),s.rend());
  ll ans=0;
  priority_queue<int,vector<int>,greater<int>> q;//daburi
  vector<bool> type(mx,false);
  ll cnt=0;
  
  for(int i=0; i<k; i++){
    ans += s[i].F;
    if(!type[s[i].S]){ cnt++; type[s[i].S]=true; }else{ q.push(s[i].F); }
  }
  ans += cnt*cnt;

  ll tmp=ans;
  for(int i=k; i<n; i++){
    if(cnt>=k){ break; }
    if(type[s[i].S]){ continue; }
    type[s[i].S]=true;
    tmp = tmp+(cnt+1)*(cnt+1)-cnt*cnt+s[i].F-q.top();
    ans = max(ans,tmp);
    cnt++;
    q.pop();
  }  
  
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 1408
using System;
using System.IO;
using System.Collections.Generic;

namespace AtCoder {
    public class Program {
        public static void Main() {
            string S = Console.ReadLine();
            int[] Ns = new int[4];
            for (int i = 0; i < 4; i++) {
                Ns[i] = S[i] - '0';
            }
            bool[] Operator = new bool[3];
            for (int i = 0; i < 2; i++) {
                Operator[0] = (i == 0);
                for (int j = 0; j < 2; j++) {
                    Operator[1] = (j == 0);
                    for (int k = 0; k < 2; k++) {
                        Operator[2] = (k == 0);
                        if (Calc(Operator, Ns) == 7) {
                            Print(Operator, Ns);
                            return;
                        }
                    }
                }
            }
        }

        static int Calc(bool[] b,int[] Ns) {
            int sum = Ns[0];
            for (int i = 0; i < 3; i++) {
                sum += (b[i]) ? Ns[i + 1] : -Ns[i + 1];
            }
            return sum;
        }
        static void Print(bool[] b, int[] Ns) {
            string s = Ns[0].ToString();
            for (int i = 0; i < 3; i++) {
                s += (b[i]) ? "+" + Ns[i + 1].ToString() : "-" + Ns[i + 1].ToString();
            }
            Console.WriteLine(s + "=7");
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
const int N = 1e4 + 4;
const int CNT = 6e4 + 4;
const int inf = 1e9;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
int n, cnt, a[CNT], to[CNT], idx[CNT];
int dfn[CNT], pre[CNT], dfs_clock, belong[CNT], total, stack[CNT], stn;
int id[CNT << 2];
int tot, first[CNT], next[CNT * 60], end[CNT * 60];
inline void AddEdge(int x, int y) {
	next[++tot] = first[x], first[x] = tot, end[tot] = y;
}
void build(int k, int l, int r) {
	id[k] = ++cnt;
	if (l == r) {
		AddEdge(id[k], idx[l]);
		return;
	}
	
	int mid = l + r >> 1;
	build(k << 1, l, mid), AddEdge(id[k], id[k << 1]);
	build((k << 1) | 1, mid + 1, r), AddEdge(id[k], id[(k << 1) | 1]);
}
void add(int k, int l, int r, int x, int y, int z) {
	if (x <= l && r <= y) {
		AddEdge(z, id[k]);
		return;
	}
	
	int mid = l + r >> 1;
	if (x <= mid) add(k << 1, l, mid, x, y, z);
	if (y > mid) add((k << 1) | 1, mid + 1, r, x, y, z);
	return;
}
void Dfs(int x) {
	dfn[x] = pre[x] = ++dfs_clock, stack[++stn] = x;
	for (int k = first[x], v; v = end[k], k; k = next[k]) 
		if (!dfn[v]) Dfs(v), pre[x] = std :: min(pre[x], pre[v]);
		else 
			if (!belong[v]) pre[x] = std :: min(pre[x], dfn[v]);
		
	if (dfn[x] == pre[x]) {
		++total;
		while (stack[stn] != x) 
			belong[stack[stn--]] = total;
		belong[stack[stn--]] = total;
	}
}
bool check(int x) {
	cnt = n * 2, tot = 0, dfs_clock = total = stn = 0;
	std :: memset(first, 0, sizeof(first));
	
	build(1, 1, n * 2);
	
	for (int i = 1, l = 1, r = 1; i <= n * 2; ++i) {
		while (l < i && a[idx[l]] + x <= a[idx[i]]) ++l;
		while (r < n * 2 && a[idx[r + 1]] < a[idx[i]] + x) ++r;
		if (l < i) add(1, 1, n * 2, l, i - 1, to[idx[i]]);
		if (i < r) add(1, 1, n * 2, i + 1, r, to[idx[i]]);
	}
	
	std :: memset(dfn, 0, sizeof(dfn));
	std :: memset(belong, 0, sizeof(belong));
	
	for (int i = 1; i <= cnt; ++i) if (!dfn[i]) Dfs(i);
	for (int i = 1; i <= n; ++i) 
		if (belong[i * 2] == belong[i * 2 - 1]) return false;
	
	return true;
}
inline bool cmp(const int &x, const int &y) {
	return a[x] < a[y];
}
int main() {
	n = Get();
	for (int i = 1; i <= n * 2; ++i) a[i] = Get(), idx[i] = i;
	for (int i = 1; i <= n; ++i, cnt += 2) 
		to[cnt + 1] = cnt + 2, to[cnt + 2] = cnt + 1; 
	
	std :: sort(idx + 1, idx + n * 2 + 1, cmp);
	
	int l = 0, r = inf, ans = 0;
	while (l <= r) {
		int mid = l + r >> 1;
		if (check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 16640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n;cin>>n;
    string s;cin>>s;
    if(count(all(s),'R')>count(all(s),'B'))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	int n;
	cin >> n;
	if (65 <= n && n <= 90) cout << "1" << endl;
	else if (97 <= n && n <= 122) cout << "2" << endl;
	else cout << "0" << endl;
	return 0;
}


Measured memory_bytes: 3096
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();

        long g = gcd(A, B);
        long ans = (A/g) * (B/g) * g;
        System.out.println(ans);
    }

    static long gcd(long a, long b){
        return b == 0 ? a : gcd(b,a % b); 
    }
}

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

namespace ABC136D
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int N = S.Length;

            int[] ans = new int[N];

            int groupRIndex = -1;
            int groupLIndex = -1;
            int[] rNum = new int[2];
            int[] lNum = new int[2];
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'R') rNum[i % 2]++;
                else if (S[i] == 'L') lNum[i % 2]++;

                if (S[i] == 'R' && S[i + 1] == 'L')
                {
                    //切り替わり
                    groupRIndex = i;
                    groupLIndex = i + 1;
                }
                else if (i == N - 1 || S[i] == 'L' && S[i + 1] == 'R')
                {
                    //精算
                    if (groupRIndex % 2 == 0)
                    {
                        ans[groupRIndex] = rNum[0] + lNum[0];
                        ans[groupLIndex] = rNum[1] + lNum[1];
                    }
                    else
                    {
                        ans[groupRIndex] = rNum[1] + lNum[1];
                        ans[groupLIndex] = rNum[0] + lNum[0];
                    }

                    //リセット
                    groupRIndex = -1;
                    groupLIndex = -1;
                    rNum = new int[2];
                    lNum = new int[2];
                }

            }

            Console.WriteLine(string.Join(" ", ans));
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 15500
#include<iostream>
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

int main(void)
{
    int n, u, v, k, a[101][101]={0}, adj[101];

    cin >> n;
    rep(i,n){
        cin >> u >> k;
        rep(i,k){
            cin >> v;
            a[u][v] = 1;
        }
    }

    rep(i,n){
        rep(j,n){ cout << a[i+1][j+1]; if(j != n-1) cout << ' ';}
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3144
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
        a = 14;
    }
    if (b == 1) {
        b = 14;
    }
    if (a == b) {
        cout << "Draw\n";
        return;
    }
    if (a > b) {
        cout << "Alice\n";
        return;
    }
    if (a < b) {
        cout << "Bob\n";
        return;
    }

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[200007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    int mn=1e9;
    int ans=0;
    for(int i=1;i<=n;++i){
        mn=min(mn,a[i]);
        if(mn>=a[i])
            ++ans;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1024
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

x_list.sort()
y_list.sort()

for z in range(X+1, Y):
    if x_list[-1] < z <= y_list[0]:
        print("No War")
        exit()
print("War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int H, W, M;
    cin >> H >> W >> M;
    map<int, int> w_cnt;
    map<int, vector<int>>  h_cnt;
    for (int i = 0; i < M; i++) {
        int h, w;
        cin >> h >> w;
        h--; w--;
        w_cnt[w]++;
        h_cnt[h].push_back(w);
    }

    set<int> w_max;
    int max_v = 0;
    for (auto tmp : w_cnt) {
        chmax(max_v, tmp.second);
    }
    for (auto tmp : w_cnt) {
        if (tmp.second == max_v) {
            w_max.emplace(tmp.first);
        } 
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        int cnt = h_cnt[i].size();
        vector<int> save;
        for (auto tmp : h_cnt[i]) {
            if (w_max.find(tmp) == w_max.end()) continue;
            save.push_back(tmp);
            w_max.erase(tmp);
        }
        if (w_max.empty()) {
            chmax(ans, cnt + max_v - 1);
        } else {
            chmax(ans, cnt + max_v);
        }

        for (auto tmp : save) {
            w_max.emplace(tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 64552
#include<bits/stdc++.h>
#define For(i, j, k) for(int i = j; i <= k; ++i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') p = -1; c = getchar(); }
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return x *= p;
}

inline void File() {
#ifndef ONLINE_JUDGE
	freopen("ARC059A.in", "r", stdin);
	freopen("ARC059A.out", "w", stdout);
#endif
}

const int N = 1e2 + 10, inf = 0x3f3f3f3f;
int A[N], n, l = inf, r = -inf;

int main() {
	n = read();
	For(i, 1, n) {
		A[i] = read();
		l = min(l, A[i]);
		r = max(r, A[i]);
	}
	
	int ans = inf;
	For(bas, l, r) {
		int res = 0;
		For(i, 1, n) res += (A[i] - bas) * (A[i] - bas);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{

 int w;
 int h;
 int x;
 int y;
 int r;
 string answer;

 cin >> w >> h >> x >> y >> r;

 if ( ( x + r ) > w) {
   answer = "No";
 } else if ( ( y + r ) > h ) {
   answer = "No";
 } else if ( x < r ) {
   answer = "No";
 } else if ( y < r ) {
   answer = "No";
 } else {
   answer = "Yes";
 }

 cout << answer << endl;

}

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

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 long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

  rep(i, n){
    int t = 0;
    REP(j, i, n-2){
      if(t < s[j]) t = s[j];
      else if(t%f[j] == 0);
      else t = t+f[j]-t%f[j];
      t+= c[j];
    }
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
	scanf("%d",&n);
	cin>>s;
	if((s.size())>n) {
		for(int i=0;i<n;i++)
		    printf("%c",s[i]);
		printf("...");
	}
	else
	    cout<<s;
}

Measured memory_bytes: 3764
#include <stdio.h>
 
#define PutChar(c) ; *p = (char)(c); ++p;
 
#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)
 
int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);
 
int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;
 
int main(void) {
    register int i;
    int n;
 
    fread(str, 1, STR_SIZE, stdin);
     
    n = getNum();
    for (i = 1; i <= n; ++i) {
        A[i] = getNum();
    }
     
    CountingSort(A, B, MAX_Ai, n);
     
    p = str;
    --n;
    for (i = 1; i <= n; ++i) {
        putNum(B[i]);
        PutChar(' ');
    }
    putNum(B[i]);
    PutChar('\0');
     
    puts(str);
     
    return 0;
}
 
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}
 
void putNum(int n) {
    int d;
    if (n < 10) {
        PutChar('0' + n);
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    PutChar('0' + (n - (d * 10)));
}
 
void CountingSort(int A[], int B[], int k, int len) {
    int C[MAX_Ai] = { 0 };
    int i, j;
    for (j = 1; j <= len; ++j) {
        ++C[A[j]];
    }
    for (i = 1; i <= k; ++i) {
        C[i] += C[i - 1];
    }
    for (j = len; j > 0; --j) {
        B[C[A[j]]] = A[j];
        --C[A[j]];
    }
}

Measured memory_bytes: 25652