akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int MOD=1e9+7;
const int MOD2=998244353;

const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
#define Func3(f,a,b,c) (f)((f)((a),(b)),(c))
#define Func4(f,a,b,c,d) (f)((f)((f)((a),(b)),(c)),(d))

inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}
//ans = accumulate(A, A+N, 0, [](int a, int b) {return gcd(a,b);});

//Eと名のつくのはデバッグ用！
int EintN(ll array[],const ll num){
    for(int i=0;i<num;i++){cerr<<array[i]<<" ";}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {cerr<<array[i][k]<<" ";}
        }
        br;
    }
    br;
    return 0;
}
int Eint(string str,const ll num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}













int prob(){
    ll ans;ans=0;
    ll N;cin>>N;
    ll A[N+1];
    inarray(A, 0, N);A[N]=0;
    
    ll switch_num=1;
    while(switch_num){
        switch_num=0;
        bool exist=false;
        FOR(i, 0, N+1){
            if(A[i]){
                exist=true;
                A[i]--;
            }
            else{
                if(exist){switch_num++;exist=false;}
            }
            
            ans=ans;
        }
        ans+=switch_num;
        
        ans=ans;
    }
    
    OutputAndReturn0(ans);
    return 0;
}


signed main(){
    prob();
    return 0;
}


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

using namespace std;

#define size_t int

int main(int argc, char const *argv[]) {
  int D;
  scanf("%d", &D);
  printf("Christmas ");
  for (size_t i = 0; i < 25 - D; i++) {
    printf("Eve ");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, u, k, v, t, x;
    cin >> n;
    int d[n];

    vector<int> c[n];

    for (int i = 0; i < n; i++)
    {
        d[i] = 1000;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            c[i].push_back(v - 1);
        }
    }
    d[0] = 0;
    t = 0;
    vector<int> search_list;
    for (auto itr = c[0].begin(); itr != c[0].end(); itr++)
    {
        search_list.push_back(*itr);
    }
    while (!search_list.empty())
    {
        t++;
        vector<int> new_search_list;
        for (auto itr = search_list.begin(); itr != search_list.end(); itr++)
        {
            x = *itr;
            if (d[x] == 1000)
            {
                d[x] = t;
                for (auto itr2 = c[x].begin(); itr2 != c[x].end(); itr2++)
                {
                    new_search_list.push_back(*itr2);
                }
            }
        }
        search_list.clear();
        for (auto itr = new_search_list.begin(); itr != new_search_list.end(); itr++)
        {
            search_list.push_back(*itr);
        }
    }

    for (int i = 0; i < n; i++)
        cout << i + 1 << " " << ((d[i] == 1000) ? -1 : d[i]) << endl;
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


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

using namespace std;

long long N;

int main() {

    cin >> N;
    long long temp = N;
    int K = 0;
    int c;
    while (N) {
        K += 1;
        c = N % 10;
        N /= 10;
    }
    if (temp == (c + 1) * pow(10, K-1) - 1) 
        cout << c + 9 * (K - 1) << '\n';
    else
        cout << (c - 1) + 9 * (K - 1) << '\n';

}


Measured memory_bytes: 256
import math
N, K = map(int, input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, K + 1):
    b = combinations_count(K - 1, i - 1)
    if i > N - K + 1:
        r = 0
    else:
        r = combinations_count(N - K + 1, i)
        
    print((b * r) % (10 **9 + 7))

Measured memory_bytes: 71384
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int  X=sc.nextInt();
  if (X==1) {
    System.out.println(0);

  }else{
    System.out.println(1);
  }
}
}


Measured memory_bytes: 35580
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	p := make([]int, n)
	ex := make([]float64, n+1)
	for i := 0; i < n; i++ {
		p[i] = nextInt()
		ex[i+1] = float64(1+p[i]) * float64(p[i]) / 2.0 / float64(p[i])
	}

	for i := 0; i < n; i++ {
		ex[i+1] += ex[i]
	}

	ans := 0.0

	for t := 0; t <= n; t++ {
		f := t - k
		if f < 0 {
			f = 0
		}
		tmp := ex[t] - ex[f]
		if tmp > ans {
			ans = tmp
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
string s[11000];
char tp[12];
int main() {
	int n;
	scanf("%d ",&n);
	char c[12];
	for(int i=0;i<n;i++) {
		scanf("%s ",c);
		s[i] = c;
	}
	int tot = 0;
	int pr=0,su=0,bo=0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<s[i].size()-1;j++) {
			if(s[i][j] == 'A' && s[i][j+1] == 'B') {tot++;}
		}
		int st = 0;
		if(s[i][0] == 'B') {st |= 2;pr++;}
		if(s[i][s[i].size()-1] == 'A') {st |= 1;su++;}
		if(st == 3) {pr--;su--;bo++;}
	}
	if(bo > 0) {
		tot += bo-1;
		if(su > 0) {tot++;su--;}
		if(pr > 0) {tot++;pr--;}
	}
	tot += min(pr,su);
	printf("%d\n",tot);
}


Measured memory_bytes: 1024
loop {
    n, a, b, c, x = gets.split.map &:to_i
    break if n == 0
    target = gets.split.map &:to_i

    i = 0   
    10001.times {
        target.shift if target[0] == x
        break if target.empty?
        x = (a * x + b) % c 
        i += 1
    }   
    puts i > 10000 ? -1 : i 
}

Measured memory_bytes: 6104
function check(x){
if(x%4!=0)return false;
if(x%400==0)return true;
if(x%100==0)return false;
return true;
}
 
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
   if(Arr[i]=="0 0")break;
   if(i!=0)console.log("");
   var a=(Arr[i].split(" "))[0]-0;
   var b=(Arr[i].split(" "))[1]-0;
   var arr=[];
   for(var j=a;j<=b;j++){
      if(check(j))arr.push(j);
   }
   if(arr.length==0)console.log("NA");
   if(arr.length!=0)arr.forEach(function(v){console.log(v);});
}

Measured memory_bytes: 17900
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

/* // approach 1 - O(N*H)
ll getMaxBeauty(vector<int> heights, vector<ll> beauties, int n) {
	ll res=0;
	int maxHeight = *max_element(heights.begin(),heights.end());
	vector<ll> dp(n+1,0);
	for(int i=1;i<=maxHeight;i++) {
		for(int j=1;j<=n;j++) {
			if(heights[j-1]<=i && heights[j-1]>i-1) {
				dp[j]=max({dp[j],dp[j-1],dp[j-1]+beauties[j-1]});
			} else {
				dp[j]=max(dp[j],dp[j-1]);
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	res=dp[n];
	return res;
}
*/

/*
//approach 2 - O(N^2)
ll getMaxBeauty(vector<int> heights, vector<ll> beauties, int n) {
	ll res=0;
	vector<int> sortedHeights=heights;
	sort(sortedHeights.begin(),sortedHeights.end());
	vector<ll> dp(n+1,0);
	for(int i:sortedHeights) {
		for(int j=1;j<=n;j++) {
			if(heights[j-1]<=i && heights[j-1]>i-1) {
				dp[j]=max({dp[j],dp[j-1],dp[j-1]+beauties[j-1]});
			} else {
				dp[j]=max(dp[j],dp[j-1]);
			}
		}
	}
	res=dp[n];
	return res;
}
*/

ll getMaxBeauty(vector<int> heights,vector<ll> beauties,int n) {
	ll res=0;
	int base=1;
	while(base<=n)base<<=2;
	vector<ll> sgmntTree(base*2,0);
	vector<ll> dp(n+1,0);
	for(int i=0;i<n;i++) {
		int x=heights[i]+base;
		ll best=0;
		while(x>1) {
			if(x%2==1) {
				best=max(best,sgmntTree[x-1]);
			}
			x>>=1;
		}
		dp[heights[i]]=best+beauties[i];
		for(int j=base+heights[i];j>0;j>>=1) {
			sgmntTree[j]=max(sgmntTree[j],dp[heights[i]]);
		}
	}
	for(int i=0;i<=n;i++) res=max(res,dp[i]);
	return res;
}

int main() {
	int n=0;
	cin>>n;
	vector<int> heights(n,0);
	vector<ll> beauties(n,0);
	for(int i=0;i<n;i++) cin>>heights[i];
	for(int i=0;i<n;i++) cin>>beauties[i];
	cout<<getMaxBeauty(heights,beauties,n)<<endl;
	return 0;
}

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

int main() {
    ll x;
    cin >> x;
    ll bank = 100;
    int ans = 0;
    while (bank < x) {
        bank += ll(bank / 100);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    string s;
    cin >> s;
    if(s.substr(2,1) == s.substr(3,1) &&s.substr(4,1) == s.substr(5,1))
        cout << "Yes" <<endl;
    else
        cout << "No" <<endl; 
}

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

using namespace std;

int main(void) {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector <int> x(N + 1), y(M + 1);
  for(int i = 1; i <= N; i++) {
    cin >> x[i];
  }
  for(int i = 1; i <= M; i++) {
    cin >> y[i];
  }

  for(int Z = X + 1; Z <= Y; Z++) {
    bool tmp = true;
    for(int j = 1; j <= N; j++) {
      if(!(x[j] < Z)) {
	tmp = false;
      }
    }
    for(int j = 1; j <= M; j++) {
      if(!(y[j] >= Z)) {
	tmp = false;
      }
    }
    if(tmp) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

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

int main() {

	string S, T;
	int A, B;
	string U;

	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if (S == U) {
		A = A - 1;
	}
	else {
		B = B - 1;
	}

	cout << A <<" "<< B << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; typedef long long  ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
const ll M = ll(1e9 + 7);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/***********************************************************************/
ll dp[105][100005];
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll n, w;
    cin >> n >> w;
    vector<ll> value, weight;
    for (ll i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        weight.push_back(x);
        value.push_back(y);
    }
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= w; j++)
        {
            if (weight[i - 1] <= j)
                dp[i][j] = max(value[i - 1] + dp[i - 1][j - weight[i - 1]], dp[i - 1][j]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][w];
}

Measured memory_bytes: 79360
s = gets.chomp

available_words = { 'dream' => 5, 'dreamer' => 7, 'erase' => 5, 'eraser' => 6 }

while !s.empty?
    find = false
    last = s.size
    available_words.each do |word, index|
        if word == s.slice(last - index, last)
            find = true
            s.slice!(last - index, last)
        end
    end
    break unless find
end

puts s.empty? ? 'YES' : 'NO'


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<bool>>data(h,vector<bool>(w,false));
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      char a;
      cin >> a;
      if(a == '#') data[i][j] = true;
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(!data[i][j]) continue;
      if(i > 0)if(data[i-1][j]) continue;
      if(i < h-1)if(data[i+1][j]) continue;
      if(j > 0)if(data[i][j-1]) continue;
      if(j < w-1)if(data[i][j+1]) continue;
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int h, m, s;
			s = Integer.parseInt(line);

			h = s / 3600;
			s %= 3600;
			m = s / 60;
			s %= 60;
			System.out.format("%d:%d:%d\n", h, m, s);
		}
	}
}

Measured memory_bytes: 16972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 9...1 = (9,1) 1...9 = (1,9)として、N以下のiを全て(先頭の桁、末尾の桁)
のペアとし、ペアの個数をカウントし、各々のiのペアの個数とその相方のペアの個数の積の和を取る
*/

int main() {
 int N;
 cin >> N;
 string S = to_string(N);
 //int k = S.size();//Nの桁数
 
 ll ans = 0;

 map<P,int> pair_kazu;//key = P,value = Pの個数
 for(int i = 1;i<=N;i++){
     string s = to_string(i);
     int c = (int)s[0]-49+1;//先頭の桁
     int d = (int)s[s.size()-1]-49+1;//末尾の桁
     //cout << c << " " << d << endl;
     P p = make_pair(c,d);
     pair_kazu[p]++;
 }

 for(int i = 1;i<=N;i++){
     string s = to_string(i);
     int c = (int)s[0]-49+1;//先頭の桁
     int d = (int)s[s.size()-1]-49+1;//末尾の桁
     //P p = make_pair(c,d);
     P q = make_pair(d,c);
     ans += pair_kazu[q];
 }
 cout << ans << endl;

 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}

int main(){
  ll h, w;
  cin >> h >> w;

  if(h == 1 || w == 1) cout << 1 << endl;
  else cout << (h*w+1)/2 << endl;

  return 0;
}

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

int main()
{
    int h, w;
    std::cin >> h >> w;

    std::vector<std::string> a(h);
    for (int i = 0; i < h; i++) {
        std::cin >> a[i];
    }

    int y = 0, x = 0;
    for (int i = 0; i < h - 1; i++) {
        for (int j = 0; j < w - 1; j++) {
            if (a[i + 1][j] == '#' && a[i][j + 1] == '#') {
                std::cout << "Impossible" << std::endl;
                return 0;
            }
        }
    }

    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            if (a[i - 1][j] == '#' && a[i][j - 1] == '#') {
                std::cout << "Impossible" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Possible" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    char S[N][N+1];
    for (int i=0; i<N; ++i) {
        cin >> S[i];
    }
    int count = 0;
    for (int i=0; i<N; ++i) {
        bool flg = true;
        for (int j=0; j<N; ++j) {
            for (int k=0; k<N; ++k) {
                if (S[(j+i)%N][k] != S[(k+i)%N][j]) {
                    flg = false;
                    break;
                }
            }
            if (!flg) break;
        }
        if (flg) {
            count += N;
        }
    }
    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 888
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

vector<int> Zalgo(const string &S) {
	int N = (int)S.size();
	vector<int> res(N);
	res[0] = N;
	int i = 1, j = 0;
	while (i < N) {
		while (i + j < N && S[j] == S[i + j]) ++j;
		res[i] = j;
		if (j == 0) { ++i; continue; }
		int k = 1;
		while (i + k < N && k + res[k] < j) res[i + k] = res[k], ++k;
		i += k, j -= k;
	}
	return res;
}

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

	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	rep(i, 0, N)
	{
		string SS = S.substr(i);
		auto pv = Zalgo(SS);
		rep(j, 0, SZ(pv))
		{
			chmax(ans, min(j, pv[j]));
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    constexpr long MOD = 1000000007;
    size_t N;
    long A, B;
    cin >> N >> A >> B;
    vector<long> dpA(N + 1), dpB(N + 1), val(N + 1);
    val[0] = numeric_limits<long>::min();
    long nA = 0, nB = 0, lA = 0, lB = 0;
    dpA[0] = dpB[0] = 1;
    for(long i = 0; i < N; ++i){
        cin >> val[i + 1];
        while(nA < i && val[nA + 1] + A <= val[i + 1])++nA;
        while(nB < i && val[nB + 1] + B <= val[i + 1])++nB;
        dpA[i + 1] = i ? ((nA == i) * dpA[i] + (lB <= nA) * dpB[min(nA + 1, i)]) % MOD : 1;
        dpB[i + 1] = i ? ((nB == i) * dpB[i] + (lA <= nB) * dpA[min(nB + 1, i)]) % MOD : 1;
        if(val[i + 1] < val[i] + A)lA = i;
        if(val[i + 1] < val[i] + B)lB = i;
    }
    cout << (dpA[N] + dpB[N]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
  int N;
  cin>>N;
  int count=0;
  for(int i=0;i<N;i++){
     int a;cin>>a;
     if(a%2>0){count++;}
  }
  if(count%2!=0){cout<<"NO"<<endl;}
  else{cout<<"YES"<<endl;}
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>
#include<map>
#include<utility>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define vecl vector<long>
#define vecll vector<long long>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {

	int N;
	cin >> N;
	cout << N * N * N << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 0;
		for(int i = 0 ; i < 4 ; i++) {
			if(s.charAt(i) == '+') ans++;
			else ans--;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import bisect as bi
n, m = map(int, input().split())
work = [tuple(map(int, input().split())) for _ in range(n)]
work.sort(key = lambda x: (x[1], -x[0]), reverse = True)
ava = list(range(0, m+1))
money = 0
for a, b in work:
    if a > m:
        continue
    l = bi.bisect_left(ava, a)
    if l >= len(ava):
        continue
    del ava[l]
    money += b
print(money)

Measured memory_bytes: 27608
local n, q = io.read("*n", "*n", "*l")
local s = io.read()
local t = {}
for i = 1, n do t[i] = s:sub(i, i):byte() end
local target, way = {}, {}
for i = 1, q do
  local strt, strway = io.read():match("(%w) (%w)")
  target[i] = strt:byte()
  way[i] = strway == "R"
end
local function solve(x)
  local result = 0
  for i = 1, q do
    if t[x] == target[i] then
      if way[i] then
        if x < n then x = x + 1
        else result = 1 break
        end
      else
        if 1 < x then x = x - 1
        else result = -1 break
        end
      end
    end
  end
  return result
end
local leftok = n + 1
if 0 <= solve(n) then
  leftok = n
  if 0 <= solve(1) then
    leftok = 1
  else
    local leftng = 1
    while 1 < leftok - leftng do
      local leftmid = (leftok + leftng) // 2
      if 0 <= solve(leftmid) then
        leftok = leftmid
      else
        leftng = leftmid
      end
    end
  end
end
local rightok = 0
if solve(1) <= 0 then
  rightok = 1
  if solve(n) <= 0 then
    rightok = n
  else
    local rightng = n
    while 1 < rightng - rightok do
      local rightmid = (rightng + rightok) // 2
      if solve(rightmid) <= 0 then
        rightok = rightmid
      else
        rightng = rightmid
      end
    end
  end
end
print(math.max(0, rightok - leftok + 1))


Measured memory_bytes: 13192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int L,R,d;
cin >> L>>R>>d;

if (L%d==0){
cout<< ((R/d)-(L/d)+1) << endl;
}
else {
cout<< ((R/d)-(L/d))<<endl;
}    
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    char a;
    cin >> a;
    if((int)a < (int)'a'){
        cout << 'A' << endl;
    }else {
        cout << 'a' << endl;
    }
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	ll K, A, B;
	cin >> K >> A >> B;
	if (A<=B) {
		if (A>=K) {
			ce(1)
		}
		else {
			ce(-1)
		}
	}
	else {
		ll left = 0, right = K/(A-B)+1;
		ll mid;
		while(right-left>1){
			mid = (left + right)/2;
			if (A*mid-B*(mid-1)>=K) {
				right = mid;
			}
			else {
				left = mid;
			}
		}
		ce(right+right-1)
	}

    return 0;
}



Measured memory_bytes: 256
use std::io::Read;
use std::vec::Vec;
use std::char;

macro_rules! get {
    // 1行 1数値を取得する。
    ($t: ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};
}

fn main() {
    let input: String = get!(String);
    let mut nums: Vec<u32> = Vec::new();
    for i in input.as_str().chars(){
        match i.to_digit(10) {
            Some(x) => nums.push(x),
            None => (),
        };
    }

    let mut sum = 0;
    for item in nums{
        sum += item;
    }

    println!("{}", sum)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int n;
  while(cin >> n){
    vector<LLI> a(n+1), b(n); cin >> a >> b;

    LLI ans = 0;

    REP(i,n){
      if(a[i] >= b[i]){
        ans += b[i];
        a[i] -= b[i];
        b[i] = 0;
      }else{
        ans += a[i];
        b[i] -= a[i];
        a[i] = 0;
      }

      if(a[i+1] >= b[i]){
        ans += b[i];
        a[i+1] -= b[i];
        b[i] = 0;
      }else{
        ans += a[i+1];
        b[i] -= a[i+1];
        a[i+1] = 0;
      }
    }

    //join(cerr, ALL(a));
    //join(cerr, ALL(b));
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 2019;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long L, long long R)
{

    ll ans = INT16_MAX;
    if (R - L + 1 >= 2019)
    {
        cout << 0 << endl;
    }
    else
    {
        for (ll i = L; i <= R; i++)
        {
            for (ll j = L; j <= R; j++)
            {
                if (i < j)
                {
                    ans = min((i * j) % MOD, ans);
                }
                else
                {
                    continue;
                }
            }
        }
        cout << ans << endl;
    }
}

int main()
{
    long long L;
    scanf("%lld", &L);
    long long R;
    scanf("%lld", &R);
    solve(L, R);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

struct point{
    double x;
    double y;
};

void koch(int n, point a, point b){
    if(n==0) return;

    point s,t,u;
    double th = M_PI * 60.0/180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) /3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) /3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) /3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) /3.0;
    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.0;
    a.y = 0.0;
    b.x = 100.0;
    b.y = 0.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: 2716
s = input().split()
N, A, B = int(s[0]), int(s[1]), int(s[2])


def calc_rst(N, L):
    if int(N % L) > A:
        return A
    else:
        return int(N % L)


def solve(N, A, B, L=A+B):
    return (int(N / L) * A) + calc_rst(N, L)


print(solve(N, A, B))


Measured memory_bytes: 38608
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;

    const int ans = n + n * n + n * n * n;
    cout << ans << endl;
}


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

using namespace std;

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

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int x = 0;
	int ma = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
		} else if (s[i] == 'D') {
			x--;
		}
		if (ma < x) {
			ma = x;
		}
	}
	
	cout << ma << endl;
	
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<ios>
using namespace std;
template<int N>
struct ans{
	int a[N];
	constexpr ans():a(){
		for(int i=1;i<N;i++){
			a[i]=(i%10==i/10000&&i/1000%10==i/10%10)+a[i-1];
		}
	}
};
constexpr auto a=ans<100000>();
int in[2],i,c;
main(){
	for(;(c=getchar_unlocked())>10;){
		if(c==32)i++;
		else in[i]=in[i]*10+c-48;
	}
	printf("%d",a.a[in[1]]-a.a[in[0]-1]);
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
	ll n,m,p[100000],a[100000],b[100000],c[100000],f[100001];
	scanf("%lld %lld",&n,&m);
	for(ll i=0;i<m;i++){
		scanf("%lld",p+i);
		p[i]--;
	}
	for(ll i=0;i<n;i++) scanf("%lld %lld %lld",a+i,b+i,c+i);
	fill(f,f+n,0);
	ll pos = p[0];
	for(ll i=1;i<m;i++){
		if(p[i]>pos){
			f[pos]++;
			f[p[i]]--;
		}else{
			f[pos]--;
			f[p[i]]++;
		}
		pos = p[i];
	}
	for(ll i=0;i<n;i++) f[i+1] += f[i];
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ans += min(f[i]*a[i],c[i]+f[i]*b[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6608
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    cin >> n;
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    int m;
    cin >> m;
    ll b[m] = {};
    rep(i,m){
        scanf("%lld",&b[i]);
    }
    sort(a,a+n);
    sort(b,b+m);
    int count = 0;

    rep(i,n){
        if(count==m)break;
        if(a[i]==b[count])count++;
    }
    if(count==m)yn;

    return 0;
}
 
 


Measured memory_bytes: 3328
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (_, a, b) = scan!(usize, usize, usize);
    let mut vs = scan!(i64;;);
    vs.sort_by_key(|v| -v);

    let ans = vs.iter().take(a).sum::<i64>() as f64 / a as f64;

    println!("{}", ans);

    let mut comb = vec![vec![0i64; 51]; 51];
    for i in 0..comb.len() {
        for j in 0..i + 1 {
            comb[i][j] = if j == 0 || j == i {
                1
            } else {
                comb[i - 1][j - 1] + comb[i - 1][j]
            }
        }
    }

    let n = vs[a - 1];
    let same = vs.iter().filter(|&v| *v == n).count();
    if vs[0] == n {
        let mut sum: i64 = 0;
        for i in a..b + 1 {
            if vs[i - 1] != n {
                break;
            }
            sum += comb[same][i];
        }
        println!("{}", sum);
    } else {
        let cn = vs.iter().take(a).filter(|&v| *v == n).count() as usize;
        println!("{}", comb[same][cn]);
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		long[] dp = new long[h+1];
		
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		for (int i=1;i<=h;i++) {
			dp[i]=Long.MAX_VALUE;
			for (int j=0;j<n;j++) {
				if(i-a[j]>=0) {
					dp[i]=Math.min(dp[i-a[j]]+b[j], dp[i]);
				} else {
					dp[i]=Math.min(b[j],dp[i]);
				}
			}
		}
		System.out.println(dp[h]);
	}
	
	
	
	
	
}




Measured memory_bytes: 27460
#include<iostream>
#include<cstdio>
#include<string>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;   
typedef unsigned long long ull;
inline long long read()//inline 加速读入
{
	long long x=0;char c=getchar();//x代表返回值，c代表读取的字符
	while (c<'0'||c>'9') c=getchar();//读取所有非数部分
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();//如果读取的字符为数，加入返回值
	return x;
}
 inline void write(ll x)
 {
     char F[200];
      int tmp=x>0?x:-x ;
    if(x<0)putchar('-') ;
    int cnt=0 ;
       while(tmp>0)
       {
            F[cnt++]=tmp%10+'0';
            tmp/=10;
       }
       while(cnt>0)putchar(F[--cnt]) ;
 }
int NOf1(int n) 
{

	int c=0;
	for(int i = 0; i < 32; ++i){
		if(n & 1)
			++c;
		n >>= 1;
	}
	return c;
}
const int N=200005;
int n,l;
ll ans,sum,a[N];
int main()
{
    scanf("%d",&n);l=1;
    for (int i=1;i<=n;i++) 
    {
        scanf("%lld",&a[i]);
        while ((sum^a[i])!=sum+a[i]) sum^=a[l++];
       ans+=i-l+1;sum^=a[i];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
F = []
P = []
for i in range(N):
    F.append(list(map(int, input().split())))
for i in range(N):
    P.append(list(map(int, input().split())))

TIME = 10
prof_cand = []

for bit in range(1,1<<TIME):
    onBiz = []
    with_n = []
    for t in range(TIME):
        if bit & (1<<t):
            onBiz.append(1)
        else:
            onBiz.append(0)
            
    for n in range(N):
        with_n.append(sum([F[n][i]*onBiz[i] for i in range(TIME)]))
    
    prof = sum([P[i][with_n[i]] for i in range(N)])
    prof_cand.append(prof)
    
print(max(prof_cand))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	double n;
	cin>>n;
	n*=3.1415926535;
	n*=2;
	printf("%.9f",n);
	// your code goes here
	return 0;
}


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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

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

    // TC
    {
        string s,t;
        cin>>s>>t;
        ll cnt=0;
        loop(i,0,s.size()) {
            if(s[i]!=t[i])
                cnt++;
        }
        cout<<cnt<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,k,ans;
int main()
{
	cin>>a>>b>>c>>k;
	if(k>=a)
	{
		ans+=a;
		k-=a;
	}
	else 
	{
		cout<<k;
		return 0;
	}
	if(k>=b)
	{
		k-=b;
	}
	else k=0;
	if(k>=c)
	{
		ans-=c;
		k-=c;
	}
	else ans-=k;
	cout<<ans;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;
#define N 1000005
ll pr[1000005];
void seive()
{
    ll i,j;
    for(i=0;i<=1000000;i++)
        pr[i]=i;
    for(i=2;i*i<=1000000;i++)
    {
        if(pr[i]==i)
        {
        for(j=i*i;j<=1000000;j+=i)
        {
            if(pr[j]==j)
                pr[j]=i;
        }
        }
    }

}
ll expo(ll b,ll e)
{
    if(e==0)
        return 1;
    if(e%2==0)
        return expo((b*b)%hell,e/2);
    else
        return (b*expo((b*b)%hell,e/2))%hell;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
        seive();
       ll n,m,i;
       cin>>n;
       ll arr[n+1];
       for(i=0;i<n;i++)
        cin>>arr[i];
        map<ll,ll> cnt;
        map<ll,ll>::iterator it;
       for(i=0;i<n;i++)
       {
           ll x=arr[i];
           map<ll,ll> temp;
           while(x>1)
           {
               ll fac=pr[x];
               temp[fac]++;
               x/=fac;
           }

           for(it=temp.begin();it!=temp.end();it++)
            {
                ll a=it->first;
                ll c=it->second;
                cnt[a]=max(cnt[a],c);
            }
       }
       ll lcm=1;
       for(it=cnt.begin();it!=cnt.end();it++)
       {
           ll p=expo(it->first,it->second);
           lcm=(lcm*p)%hell;
       }
       ll ans=0;
       for(i=0;i<n;i++)
       {
           ll inv=expo(arr[i],hell-2);
           ll a=(lcm*inv)%hell;
           ans=(ans+a)%hell;
       }
       cout<<ans;
    }
}


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

string s;
int ans;
int main() {
	cin >> s;
	if (s == "RRR")
		ans = 3;
	else if (s == "RRS" || s == "SRR")
		ans = 2;
	else if (s == "SSS")
		ans = 0;
	else
		ans = 1;
	cout << ans << endl;
}


Measured memory_bytes: 3624
def q2():
    A = []
    for i in range(3):
        A.append([int(a) for a in input().split()])

    m = [[0,0,0],[0,0,0],[0,0,0]]

    N = int(input())
    for i in range(N):
        b = int(input())
        for row, a in enumerate(A):
            if b in a:
                found = a.index(b)
                m[row][found] = 1
                break

    if ((m[0][0] == 1 and m[0][1] == 1 and m[0][2] == 1) or
        (m[1][0] == 1 and m[1][1] == 1 and m[1][2] == 1) or
        (m[2][0] == 1 and m[2][1] == 1 and m[2][2] == 1) or
        (m[0][0] == 1 and m[1][0] == 1 and m[2][0] == 1) or
        (m[0][1] == 1 and m[1][1] == 1 and m[2][1] == 1) or
        (m[0][2] == 1 and m[1][2] == 1 and m[2][2] == 1) or
        (m[0][0] == 1 and m[1][1] == 1 and m[2][2] == 1) or
        (m[0][2] == 1 and m[1][1] == 1 and m[2][0] == 1)):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    q2()


Measured memory_bytes: 38256
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    val len = s.count()
    var count = 0
    for(i in 1..((len/2).toInt() + len%2)){
        if(s[i-1] != s[len - i]) count++ 
    }
    for(i in 1..(((len-1)/4).toInt() + ((len-1)/2)%2)){
        if(s[i-1] != s[(len - 1)/2 - i]) count++
    }
    for(i in (len + 3)/2..(len/2) + len%2){
        if(s[i-1] != s[len + (len + 3)/2 - i - 1]) count++
    }
    if(count == 0) println("Yes")
    else println("No")
}

Measured memory_bytes: 31964