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

int main()
{
	int n; cin >> n;

	vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i];

	const int N = 100010;

	vector<int> o(N);
	vector<int> e(N);
	int o_maxNum_first = 0;
	int o_maxNum_second = 0;
	int o_maxValue;
	int e_maxNum_first = 0;
	int e_maxNum_second = 0;
	int e_maxValue;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			o[v[i]]++;
		}
		else {
			e[v[i]]++;
		}
	}

	for (int j = 0; j < N; j++) {

		if (o_maxNum_first <= o[j]) {
		
			o_maxNum_second = o_maxNum_first;
			o_maxNum_first = o[j];
			o_maxValue = j;
		
		}
		else if (o_maxNum_second <= o[j] ) {

			o_maxNum_second = o[j];
		}
		
		if (e_maxNum_first <= e[j]) {

			e_maxNum_second = e_maxNum_first;
			e_maxNum_first = e[j];
			e_maxValue = j;

		}	
		else if (e_maxNum_second <= e[j]) {

			e_maxNum_second = e[j];
		}


	}

	int ans;

	if (o_maxValue != e_maxValue) {

		ans = n - o_maxNum_first - e_maxNum_first;

	}
	else { //  o_maxValue == e_maxValue

		ans = min(n - o_maxNum_first - e_maxNum_second, n - e_maxNum_first - o_maxNum_second);

	}

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

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,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);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  ll pret = 0, prex = 0, prey = 0;
  bool ok = true;
  rep(i, 0, n){
    ll t, x, y;
    cin >> t >> x >> y;
    if((t - pret) < abs(x - prex) + abs(y - prey)) ok = false;
    else if((t - pret) % 2 != (abs(x - prex) + abs(y - prey)) % 2) ok  = false;
    prex = x;
    prey = y;
    pret = t;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

const int INF = 1e9;

void print(std::vector<int> readVec){
    int sz = readVec.size();
    for(int i = 0; i < sz; ++i){
        std::cout << readVec.at(i);
        if(sz - 1 == i){
            std::cout << " ";
        }else{
            std::cout << std::endl;;
        }
    }
}
int main(){
    int n;
    std::cin >> n;

    std::vector<int> h(n);
    for(int i = 0; i < n; ++i){
        std::cin >> h.at(i);
    }

    std::vector<int> dp(n, INF);
    dp.at(0) = 0;
    dp.at(1) = std::abs(h.at(1) - h.at(0));
    for(int i = 2; i < n; ++i){
        int first = dp.at(i - 2) + std::abs(h.at(i) - h.at(i - 2));
        int second = dp.at(i - 1) + std::abs(h.at(i) - h.at(i - 1));
        dp.at(i) = std::min(first, second);
    }

    std::cout << dp.at(n - 1) << std::endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

    		 int N = sc.nextInt(); //支払う
    		 int A = sc.nextInt();//1円硬貨


    		 if(N % 500 <= A) {
    			 System.out.println("Yes");
    		 }else {
    			 System.out.println("No");
    		 }

    	}
    }

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int aL=0;
		int bL=0;

		aL = Math.abs(x-a);
		bL = Math.abs(x-b);
		if(aL<bL) {
			System.out.println("A");
		}else {
			System.out.println("B");
		}
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;


int main() {
    string s, t;
	cin >> s >> t;

    vector<vector<int>> dp(3010, vector<int>(3010));
    rep(i, s.size()) rep(j, t.size()) {
        if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
    }

    string ans = "";
    int i = s.size(), j = t.size();
    while (i>0 && j>0) {
        if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else {
            ans += s[i-1];
            i--, j--;
        }
    }
    
    reverse(all(ans));
	cout << ans << endl;
	return 0;
}


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

int A, B;

int main() {
  scanf("%d%d", &A, &B);
  if (A < 10 && B < 10) {
    printf("%d\n", A * B);
  } else {
    printf("%d\n", -1);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;
typedef complex<double> xy_t;
xy_t P[110];
int main() {
 int N=0;
 double x, y;
 while (~scanf("%lf,%lf", &x, &y)) {
  P[N++] = xy_t(x, y);
 }
 double sum = 0.0;
 for (int i=0; i+2<N; ++i) {
  xy_t a=P[0], b=P[(i+1)%N], c=P[(i+2)%N];
  double A=abs(a-b), B=abs(b-c), C=abs(c-a);
  double z=(A+B+C)/2;
  sum += sqrt(z*(z-A)*(z-B)*(z-C));
 }
 printf("%.6f\n", abs(sum));
}


Measured memory_bytes: 1256
/* ex 9_1
   yumizmiz */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 1000

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack stk;
    initialize_stack(&stk);

    char input[11], *ptr1;
    char output[11], *ptr2;
    scanf("%s", input);
    ptr1 = input;
    while(*ptr1){
        if(*ptr1 == 'B'){
            if(stk.count>0)
                pop(&stk);
        }else{
            push(&stk, *ptr1);
        }
        ++ptr1;
    }
    ptr2 = &output[stk.count];
    *ptr2 = '\0';
    --ptr2;
    while(stk.count>0){
        *ptr2 = pop(&stk);
        --ptr2;
    }
    printf("%s", output);
    return 0;
}

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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

const int maxn = 1e5+5;

int n;
vector<int> adj[maxn];

int flag[maxn];
int udh = 0;
void dfs(int a,int p,vector<int> &ans){
	ans.pb(a);
	
	for(int b : adj[a])if(b!=p && !flag[b]){
		flag[b] = 1;
		dfs(b,a,ans);
		break;
	}
	
}
int m;
int main(){
	scanf("%d%d",&n,&m);
	
	rep(k,0,m){
		int a,b;
		scanf("%d%d",&a,&b);adj[a].pb(b);adj[b].pb(a);
	}
	
	flag[1] = 1;
	
	vector<int> L,R	;
	L.pb(1);
	flag[1] = 1;
	flag[adj[1][0]] = 1;
	dfs(adj[1][0],1,L);
	if(adj[1].size()>1 && !flag[adj[1].back()]){
		flag[adj[1].back()] = 1;
		dfs(adj[1].back(),1,R);
		printf("%d\n",L.size() + R.size());
		for(auto k = R.rbegin();k!=R.rend();k++)printf("%d ",*k);
	}
	else printf("%d\n",L.size());
	for(int k : L)printf("%d ",k);line;
	
	return 0;
}


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

int main(){
  int n,k,r=0;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    r=max(r,a[i]);
  }
  
  int l=0;
  
  while(l+1<r){
    int i=(l+r)/2;
    long long p=k;
    for(int j=0;j<n;j++) p-=(a[j]-1)/i;
    if(0<=p) r=i;
    else l=i;
  }
  cout << r << endl;
}

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

inline long long read(){
	long long s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

int main(){
	int a = read(), b = read(), c = read();
	if (a == b && c != a || a == c && a != b || b == c && a != b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int a[3][3];
int main()
{
	IO;
	For(i,0,3)
	{
		For(j,0,3)cin>>a[i][j];
	}
	int n{};
	cin>>n;
	while(n--)
	{
		int x{};
		cin>>x;
		For(i,0,3)
		{
			For(j,0,3)if(a[i][j]==x)a[i][j]=-1;
		}
	}
	int f{};
	For(i,0,3)
	{
		int ans{},res{};
		For(j,0,3)
		{
			if(a[i][j]==-1)ans++;
		}
		For(k,0,3)
		{
			if(a[k][i]==-1)res++;
		}
		if(ans==3 || res==3){f=1;break;}
	}
	if(f)cout<<"Yes\n";
	else{
		if((a[0][0]==-1 && a[1][1]==-1 && a[2][2]==-1) || (a[0][2]==-1 && a[1][1]==-1 && a[2][0]==-1 ))cout<<"Yes\n";
		else cout<<"No\n";
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

template <class Abel>
class BIT
{
public:
  using F=function<Abel(Abel,Abel)>;
  F f;
  int l;
  vector<Abel> bit;
  Abel m0;
  BIT(int maxidx,F fu,Abel m0):f(fu),l(maxidx),m0(m0)
  {
    bit.assign(l+1,m0);
  }
  void update(int idx,int val)
  {
    idx++;
    while(idx<=l)
    {
      bit[idx]=f(bit[idx],val);
      idx+=idx & -idx;
    }
  }
  int query(int idx)
  {
    int res=m0;
    while(idx>0)
    {
      res=f(bit[idx],res);
      idx-=idx& -idx;
    }
    return res;
  }
};


int mod=1e9+7;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int> s(n);
  rep(i,n)cin>>s[i];

  s.erase(unique(all(s)),s.end());

  int l=s.size();
  map<int,vector<int>> cidx;
  vector<int>tv;
  rep(i,l)
  {
    if(cidx.count(s[i])==0)
    {
      cidx[s[i]]=tv;
    }
    cidx[s[i]].push_back(i);
  }

  BIT<int>bt(l,[](int a,int b){return (a+b)%mod;},0);
  rep(i,l)
  {
    auto nitr=upper_bound(all(cidx[s[i]]),i);
    if(nitr==cidx[s[i]].end())continue;
    bt.update(*nitr,bt.query(i+1)+1);
  }
  cout<<(bt.query(l)+1)%mod<<endl;



  return 0;

}


Measured memory_bytes: 23680
using System;

class E
{
	static void Main() => Console.WriteLine(Find(Console.ReadLine(), int.Parse(Console.ReadLine())));

	static int Find(string n, int k)
	{
		var r = (int)Ncr(n.Length - 1, k) * (int)Math.Pow(9, k);
		r += (n[0] - '0' - 1) * (int)Ncr(n.Length - 1, k - 1) * (int)Math.Pow(9, k - 1);
		if (k == 1)
		{
			r += 1;
		}
		else
		{
			n = n.Remove(0, 1).TrimStart('0');
			if (n != "") r += Find(n, k - 1);
		}
		return r;
	}

	static long Factorial(int n) { for (long x = 1, i = 1; ; x *= ++i) if (i >= n) return x; }
	static long Npr(int n, int r)
	{
		if (n < r) return 0;
		for (long x = 1, i = n - r; ; x *= ++i) if (i >= n) return x;
	}
	static long Ncr(int n, int r) => n < r ? 0 : n - r < r ? Ncr(n, n - r) : Npr(n, r) / Factorial(r);
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
    long long a[10000], n, i, sum =0;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a+n);
    cout << a[0] << " " << a[n-1] << " " << sum << endl;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.rbegin(), a.rend())
using namespace std;

const int m = 1e6, M = 1e9+7;
ll inverse[3*m], fact[3*m], invfact[3*m];

ll nCr(ll n, ll r){
    ll ans = fact[n]*invfact[r]%M;
    return (ans*invfact[n-r]%M); 
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, k, sum = 0; cin>>n>>k;
    vector<ll> h(n);
    loop(n) cin>>h[i];
    if(k>=n) return cout<<0<<"\n", 0;

    sort(h);
    for(ll i = k; i<n; i++){
        sum += h[i];
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int linerSearch(int*,int,int);

int main(){
  int n,S[10000];
  int q,T[10000];
  int i,j,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
    if(linerSearch(S,n,T[j])==2){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}
  
int linerSearch(int *s,int n,int key){
  int i=0;
  s[n]=key;
  while(s[i]!=key){
    i++;
  }
  if(i==n){
    return 1;
  }
  if(i<n)return 2;

}





Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	char A[10], B[10], C[10];
	int flag;
	int lena, lenb, lenc;

	scanf("%s", A);
	scanf("%s", B);
	scanf("%s", C);

	lena=strlen(A);
	lenb=strlen(B);
	lenc=strlen(C);

	flag=1;

	if(A[lena-1] != B[0])
		flag=0;

	if(B[lenb-1] != C[0])
		flag=0;

	if(flag)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;


}

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


using namespace std;

double sq(vector<double> &v){
    
    if(v.size()==2){
        v[0]=v[0]*v[1]/(v[0]+v[1]);
        return v[0];
    }
    if(v.size()==1){
        return v[0];
    }
    else{
    int k=v.size()/3;
    int doneTill=-1;
    while(k--){
        
        
        double k2=v[doneTill+1]*v[doneTill+3]+v[doneTill+2]*v[doneTill+3]+v[doneTill+2]*v[doneTill+1];
        double k1=v[doneTill+2]*v[doneTill+3]*v[doneTill+1];
        v[doneTill+1]=(double)k1/k2;
        v.erase(v.begin()+doneTill+2);
        v.erase(v.begin()+doneTill+2);
        
        doneTill++;
    }
    sq(v);
    }
}

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    vector<double> a(n);
    for(int i=0;i<n;i++){cin>>a[i];}
    cout<<fixed<<setprecision(8)<<sq(a);
    
    return 0;    
}

Measured memory_bytes: 256
def main():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        a = list(map(int, input().split()))
        count = 0
        for j in range(m):
            count += a[j] * b[j]
        count += c
        if count > 0:
            ans += 1
    print(ans)




if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int mod10 = N % 10;

    vector<int> hon_array{2, 4, 5, 7, 9};
    vector<int> pon_array{0, 1, 6, 8};
    vector<int> bon_array{3};

    for (int i = 0; i < (int)hon_array.size(); i++){
        if (mod10 == hon_array[i]){
            cout << "hon" << endl;
            return 0;
        }
    }

    for (int i = 0; i < (int)pon_array.size(); i++){
        if (mod10 == pon_array[i]){
            cout << "pon" << endl;
            return 0;
        }
    }

    for (int i = 0; i < (int)bon_array.size(); i++){
        if (mod10 == bon_array[i]){
            cout << "bon" << endl;
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
void shikhar7s(int cas)
{
    int n,i,ans=0;
    cin>>n;
    string s;
    cin>>s;
    fr(i,n-2)
    {
        if(s[i]=='A')
        {
            if(s[i+1]=='B'&&s[i+2]=='C')
            {
                ans++;
                i+=2;
            }
        }
    }
    cout<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

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

typedef long long ll;

unordered_map<ll, int> umap;

ll binarySearch(ll n, ll l, ll r){

    ll mid, ans=l;
    while(l<r){
        mid = l+ (r-l)/2;
        if(mid*(mid+1)/2<=n){
            ans = mid;
            l = mid+1;
        }
        if(mid*(mid+1)/2>n){
            r=mid;
            ans=mid-1;
        }
    }
    return ans;
}

void primefactors(ll n){
    
    while(n%2==0){
        n=n/2;
        umap[2]++;
    }

    for(ll i=3; i<=sqrtl(n); i=i+2){
        while((n%i)==0){
            umap[i]++;
            n/=i;
        }
    }

    if(n>2){
        umap[n]++;
    }
}

int main(){

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

    ll n;
    cin >> n;

    if(n==1) cout << 0 << '\n';
    else{

        primefactors(n);
        ll count = 0; 

        // for(auto x: umap){
        //     cout << x.first << "->" << x.second << "\n";
        // }

        for(auto x: umap){
            if(x.second==1){
                count++;
                // cout << count << " ";
            }
            else{
                count+=binarySearch(x.second, 1, x.second);
                // cout << count << " ";
            }
        }
        // cout << "\n";
        cout << count << '\n';

    }

    return 0;
}


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

int main () {
    long N, W;
    cin >> N >> W;
    long w[101], v[101];
    for (int i = 0; i < N ; i++) {
        cin >> w[i] >> v[i];
    }
    vector<long> v0, v1, v2, v3;
    for (int i = 0; i < N; i++) {
        if (w[i] == w[0]) {
            v0.push_back(v[i]);
        }
        else if (w[i] == w[0] + 1) {
            v1.push_back(v[i]);
        }
        else if (w[i] == w[0] + 2) {
            v2.push_back(v[i]);
        }
        else {
            v3.push_back(v[i]);
        }
    }
    
    sort(v0.begin(), v0.end(), greater<long>());
    sort(v1.begin(), v1.end(), greater<long>());
    sort(v2.begin(), v2.end(), greater<long>());
    sort(v3.begin(), v3.end(), greater<long>());
    
    int l0 = v0.size();
    int l1 = v1.size();
    int l2 = v2.size();
    int l3 = v3.size();
    
    long sum = 0;
    
    for (int a = 0; a <= l0; a++) {
        for (int b = 0; b <= l1; b++) {
            for (int c = 0; c <= l2; c++) {
                for (int d = 0; d <= l3; d++) {
                    long s = accumulate(v0.begin(), v0.begin() + a, 0) + accumulate(v1.begin(), v1.begin() + b, 0) + accumulate(v2.begin(), v2.begin() + c, 0) + accumulate(v3.begin(), v3.begin() + d, 0);
                    if (w[0] * a + (w[0] + 1) * b + (w[0] + 2) * c + (w[0] + 3) * d <= W and sum < s) {
                        sum = s;
                    }
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 760
#pragma once
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include <iomanip>
#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(vs) (vs).begin(),(vs).end()
#define roundup(A,B) (A)/(B)+((A)%(B)==0?0:1)
#define read(type,name) type name;cin>>name
using namespace std;


/*
	3桁の数字からなる、重複を許す数字列はN^3パターンになる。O(1)
*/
void A() {
	read(int, i);
	cout << i * i * i << endl;
}

/*
 次の数字が連番である場合、追加でスコアが入る。そのため、直前の数字を記憶する必要がある。
 あとは情報を読み込んで配列を走査すればよい。空間量は今回削減できないと思われる。
*/
void B() {
	read(int, n);
	auto dishes = vector<int>(n);
	auto scores = vector<int>(n);
	auto bonus = vector<int>(n - 1);
	rep(i, n) cin >> dishes[i];
	rep(i, n) cin >> scores[i];
	rep(i, n - 1) cin >> bonus[i];
	auto prev = -1;
	int current;
	int result = 0;
	rep(i, n) {
		current = dishes[i];
		result += scores[current - 1];
		if (prev + 1 == current) result += bonus[prev - 1];
		prev = current;
	}
	cout << result << endl;
}

/*
 Bi>=max(Ai,A+1)が必ず満たされる。例えばB0はmax(A0,A1)以上の数字である。逆に言えば、A0とA1は最大でB0ということになる。
 となればA0とA1がともにB0であるとすれば最大である。一方で、B1がB0よりも小さい場合、A1はB1よりも小さくなければならないので
 A1をB0としてはならない。結局、Aiはmin(Bi-1,Bi)というのが最大になる。これを繰り返せばよい。O(n)の解法である。
*/
void C() {
	read(int, n);
	auto B = vector<int>(n - 1);
	rep(i, n - 1) cin >> B[i];
	int prevB = 100000000;
	int currentB;
	auto sum = 0;
	rep(i, n - 1) {
		currentB = B[i];
		sum += min(prevB, currentB);
		prevB = currentB;
	}
	//ラストはB１つで決まる。
	sum += currentB;
	cout << sum << endl;
}


/*											 
 LまたはRが連続する区間を調べ上げる。たとえばLLRRRRRRRRRRRRRRRLLについて、不幸な人間の数は
											 ^　             ^^  
矢印で示した3人である。ここで、Rで構成された区間をflipする。LLLLLLLLLLLLLLLLLLL
不幸な人は2人減ったことになる。ここで増減分はR区間の長さで変化しない。
LLRRLL		->Rの区間が2人以上 := -2
LLRLL		->Rの区間が1人だけ := -2

LとRを交換した状況を考える。

RRLLRR		->Lの区間が2人以上 := -2
RRLRR		->Lの区間が1人だけ := -2

やはり同じである。

またflipする区間が端っこである場合は増減が変化する

 LLRRLL  -> RRRRLL := -1(左端が救われた)
 LLRRLL  -> LLRRRR := -1(右端が不幸になったので2人減らすことはできなかった)
 
 RRLLRR  -> LLLLRR := -1(左端が不幸になったので2人減らすことはできなかった)
 RRLLRR  -> RRLLLL := -1(右端が救われた)


 以上を踏まえれば、端でない区間のflipを繰り返して不幸な人間を2人ずつ減らしていくことが最適な行為である。
 回数が余ってしまった場合は端を修正することでさらに減らすことができる。
 実際flipによって減った区間数が不幸な人間の減少数と一致する
 つまり最終的な幸福数は実はO(1)で求めることができ、必要なのは区間数を調べ上げるO(N)の計算が支配的になる。

 LLRR -> LLLL
 LLRR -> RRRR 
 RRLL -> RRRR
 RRLL -> LLLL

 どうやったって-1にしかならない。ありがたい。

 span数と不幸な人間の数は一意に対応するだろうか。
*/

void D() {
	read(int, n);
	read(int, k);
	int unhappy = 0;
	char prev; char c = '!'; cin >> prev;
	if (prev == 'L')unhappy++;
	for (size_t i = 1; i < n; i++) {
		cin >> c;
		if (c == 'L' && prev == 'R') unhappy += 2;
		prev = c;
	}
	if (c == 'R')unhappy++;//最後の人が右を向いていれば不幸
	for (size_t i = 0; i < k; i++) {
		if (unhappy > 2) unhappy -= 2;
		else if (unhappy == 2)unhappy--;
		else break;
	}
	cout << n - unhappy << endl;
}

int main() { D(); }

void E() {

}
void F() {

}



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

int32_t main()
{
        int n;
        cin>>n;

        vector<int>v;

        int val,temp=n;
        while(temp>26){
            val=temp%26;
            if(val==0)
            {
                v.push_back(26);
                temp=temp/26;
                temp=temp-1;
            }
            else{
                v.push_back(val);
                temp=temp/26;
            }
        }
        v.push_back(temp);
        string ans;
        reverse(v.begin(),v.end());
        for(int i=0;i<v.size();i++){
            char cc='a'+(v[i]-1);
            ans.push_back(cc);
        }
        cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>s,s1,s2;
    s1+=s[0];
    s1+=s[1];
    s2+=s[2];s2+=s[3];
    if(s1>="01"&&s1<="12")x=1;
    if(s2>="01"&&s2<="12")y=1;
    if(x&&y)cout<<"AMBIGUOUS";
    else if(x)cout<<"MMYY";
    else if(y)cout<<"YYMM";
    else cout<<"NA";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
//回答が整数の場合
int ans;
//整数値の入力
int n;
cin >> n;
//行列の入力
int table[n]={};
for (int i = 0; i < n; ++i) {
    cin >> table[i];
}
for (int i = 0; i < n-1; ++i) {
    table[i+1]=__gcd(table[i],table[i+1]);
}

//回答
cout << table[n-1] << endl;
return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>p(n);
    rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    int sum=0,i=0;
    while(1){
        sum+=p[i];
        i++;
        if(i==k)break;
    }
    cout<<sum<<endl;
    

}



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

int main(){
  int a, b, c, d, L, R;
  cin >> a >> b >> c >> d;
  L = a + b;
  R = c + d;
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

int compare_int(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}

int main(){
    int N;
    scanf("%d",&N);
    int A[N+1];
    int i,j,s=0,count=0;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    qsort(A,N,sizeof(int), compare_int);

    for(i=0;i<N-1;i++){
        if(A[i]==A[i+1]){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}
    





Measured memory_bytes: 1788
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String[] Sarr = br.readLine().split(" ");
      int N = Integer.parseInt(Sarr[0]);
      int K = Integer.parseInt(Sarr[1]);
      int H = Integer.parseInt(Sarr[2]);
      String S = br.readLine();
      
      int[] arr1 = new int[K];
      int index = 0;
      for(int i = 0; i < N; i++){
        char c = S.charAt(i);
        if(c == 'o'){
          arr1[index] = i+1;
          i += H;
          index++;
        }
      }
      
      int[] arr2 = new int[K];
      index = K-1;
      for(int i = S.length()-1; i >= 0; i--){
        char c = S.charAt(i);
        if(c == 'o'){
          arr2[index] = i+1;
          i -= H;
          index--;
        }
      }
      for(int i = 0; i < K; i++){
        if(arr1[i] == arr2[i]){
          System.out.println(arr1[i]);
        }
      }
    }catch(Exception e){
    }
  }
}


Measured memory_bytes: 55200
# -*- coding: utf-8 -*-
"""
D - Powerful Discount Tickets
https://atcoder.jp/contests/abc141/tasks/abc141_d

"""
import sys


from heapq import heappop, heappush


def solve(N, M):
    hq = []
    for a in input().split():
        heappush(hq, int(a) * -1)
    for _ in range(M):
        x = heappop(hq)
        x *= -1
        x //= 2
        heappush(hq, -x)
    return sum(hq) * -1


def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s; 
	cin >> s;

    string t=s;
    reverse(t.begin(),t.end());
	int cnt=0;
    for(int i=0; i<=s.size(); ++i){
        if(s[i]!=t[i]) ++cnt;
    }
    cout << cnt/2 << endl;
}

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

int main()
{
	string s;
	cin >> s;
	string b, e;
	b = s[0];
	e = s[s.size() - 1];
	int a = s.size() - 2;
	cout << b << a << e << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,a[100],b,c,n;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=n-1;i>=1;i--){
    printf("%d ",a[i]);
    }
    printf("%d\n",a[0]);
    
    
    return(0);
}


Measured memory_bytes: 2044
data class Xy(val x: Double, val y: Double) {
    constructor(xy: List<Double>): this(xy[0], xy[1])
}
fun main(args: Array<String>) {
    val N = nextInt()
    val XY = Array(N) { Xy(listOfDouble()) }
    val A = IntArray(N)
    var count = 0
    var sum: Double = 0.0
    fun Distance(n: Int, m: Int): Double {
        val dx = Math.abs(XY[n].x - XY[m].x)
        val dy = Math.abs(XY[n].y - XY[m].y)
        return Math.sqrt(dx * dx + dy * dy)
    }
    fun Permutation(n: Int) {
        if (n == N) {
            count += 1
            for (m in 0 until N - 1) {
                sum += Distance(A[m], A[m + 1])
            }
        } else {
            for (m in 0 until N) {
                if (A.slice(0 until n).all { it != m }) {
                    A[n] = m
                    Permutation(n + 1)
                }
            }
        }
    }
    Permutation(0)
    val ans = sum / count
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfDouble() = listOfString().map(String::toDouble)


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

result = 0
for i in range(N):
  t = C
  A = list(map(int, input().split()))
  for j in range(M):
    t += A[j] * B[j]
  if t > 0:
    result += 1
print(result)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int md = 1e9+7;
int n, m, u, v, w;
long long x, ov = 2, eq = 1;
tuple<int, int, int> t[2005];

int p[1005];
long long cost;
void ufini(int n){
	fill(p, p+n, -1);
	cost = 0;
}
int find(int x){return (p[x] < 0 ? x : p[x] = find(p[x]));}
void uni(tuple<int, int, int> t){
	int w, x, y;
	tie(w, x, y) = t;
	x = find(x); y = find(y);
	if(x != y){
		if(x < y) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		cost += w;
	}
}

int main(){
	scanf("%d%d%lld", &n, &m, &x);
	rep(i,m){
		scanf("%d%d%d", &u, &v, &w);
		t[i] = make_tuple(w,u,v);
	}
	sort(t,t+m);
	for(int i = 1; i < m; i++){
		ufini(1005);
		uni(t[i]);
		rep(j,m) if(i!=j) uni(t[j]);
		if(cost > x) (ov *= 2) %= md;
		else if(cost == x) (eq *= 2) %= md;
	}
	printf("%lld\n", (eq-1)*ov%md);
}


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

struct data{
    int pos, mod, num;
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v[n];
    while(m-- > 0){
        int a, b;
        cin >> a >> b;
        v[--a].push_back(--b);
    }
    int s, t;
    cin >> s >> t;
    s--, t--;
    vector<vector<bool>> visit(3, vector<bool>(n, 0));
    queue<data> q;
    q.push(data({s,0,0}));
    while(!q.empty()){
        data d = q.front(); q.pop();
        visit[d.mod][d.pos] = true;
        for(int npos : v[d.pos]){
            int nmod = (d.mod+1)%3;
            int nnum = d.num + (nmod == 0);
            if(npos == t && nmod == 0){
                cout << nnum << endl;
                return 0;
            }
            if(!visit[nmod][npos]){
                visit[nmod][npos] = true;
                q.push(data({npos,nmod,nnum}));
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll lcm(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll gcd(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){

    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool flag = true;
    for (int i=0; i < a + b + 1; ++i) {
        if (i == a) {
            if (s[i] == '-') ;
            else flag = false;
        }
        else {
            if (0 <= (s[i] - '0') && (s[i] - '0') <= 9) ;
            else flag = false;
        }
    }


    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;





}



//              g++ -std=c++1z


Measured memory_bytes: 888
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
void nckinit(ll n,ll md){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=md;
  }
  gya[n]=gyaku(kai[n],md);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=md;
  }
  gya[0]=1;
}
ll nck(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  ret*=gya[k];
  ret%=md;
  return ret;
}
ll npk(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    map<ll,ll> mp;
    ll ans=0;
    ll n,k;cin>>n>>k;
    ll sum=0;
    mp[0]++;
    ll b[n+1];
    b[0]=0;
    rep(i,0,n){
        if(i+1>=k)mp[b[i-k+1]]--;
        ll a;cin>>a;
        sum+=a;
        sum%=k;
        ll u=sum-i-1;
        u+=(i+1)*k;
        u%=k;
        ans+=mp[u];
        mp[u]++;
        b[i+1]=u;
        //cout<<u<<endl;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> X(n), Y(n), P(n);
  rep(i, n) cin >> X[i] >> Y[i] >> P[i];
  vector<vector<ll>> xmin(1<<n, vector<ll>(n)), ymin(1<<n, vector<ll>(n));
  rep(i, 1<<n) {
    rep(j, n) {
      xmin[i][j] = abs(X[j]);
      ymin[i][j] = abs(Y[j]);
    }
    rep(k, n) {
      if((i>>k)&1) {
        rep(j, n) {
          xmin[i][j] = min(abs(X[j]-X[k]), xmin[i][j]);
          ymin[i][j] = min(abs(Y[j]-Y[k]), ymin[i][j]);
        }
      }
    }
  }
  vector<ll> pw(n+1);
  pw[0] = 1;
  rep(i, n) pw[i+1] = pw[i] * 3;
  vector<ll> ans(n+1, longinf);
  auto dfs = [&](auto dfs, int i, ll xb, ll yb) -> void {
    if(i == n) {
      ll cost = 0;
      rep(j, n) cost += P[j] * min(xmin[xb][j], ymin[yb][j]);
      int cnt = __builtin_popcount(xb) + __builtin_popcount(yb);
      if(cnt > n) return;
      ans[cnt] = min(cost, ans[cnt]);
      return;
    }
    dfs(dfs, i+1, xb, yb);
    dfs(dfs, i+1, xb|(1<<i), yb);
    dfs(dfs, i+1, xb, yb|(1<<i));
  };
  dfs(dfs, 0, 0, 0);
  rep(i, n+1) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 12960
using System;

namespace Project
{
    class Program
    {
        static void Main()
        {
            int[] args = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int a = args[0];
            int b = args[1];
            int c = args[2];
            Console.WriteLine((a < c && c < b) || (b < c && c < a) ? "Yes" : "No" );
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (b) - 1;i >=a;--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}


using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

int clamp(int n, int a, int b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

int Fib[100001];

int fib(int N) {
    if (Fib[N] > 0)return Fib[N];
    if (N == 0 || N == 1)return Fib[N] = 1;
    return Fib[N] = (fib(N - 1) + fib(N - 2)) % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;
    vector<int>A(M);
    cin >> A;
    bool can = true;
    REP(i, M - 1) {
        if (A[i + 1] - A[i] == 1)can = false;
    }
    if (!can) {
        cout << 0 << endl;
        return 0;
    }

    if (M == 0) {
        cout << fib(N) << endl;
        return 0;
    }
    A.emplace_back(-1);
    A.emplace_back(N + 1);
    SORT(A);
    ll ans = 1;
    REP(i, M + 1) {
        ans *= fib(A[i + 1] - A[i] - 2);
        ans %= mod;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3712
function Main(input) {
    input = input.split("").map(Number);
    var flag = false;
    for(var i=0;i<2;i++){
        if(flag) break;
        for(var j=0;j<2;j++){
            if(flag) break;
            for(var k=0;k<2;k++){
                var ans = input[0];
                ans += (i==0?"+":"-")
                ans += (input[1]);
                ans += (j==0?"+":"-")
                ans += (input[2]);
                ans += (k==0?"+":"-")
                ans += (input[3]);
                var n;
                eval("if(7 == ("+ans+")){console.log('"+ans+"'+'=7');flag = true;};");
                if(flag) break;
            }
        }
    }
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
read n
read al
a=(`echo $al|tr ' ' '\n'|sort -n`)
cnt=0
for((i=0;i<n;i++));do
	for((j=i+1;j<n;j++));do
		if [ ${a[i]} -lt ${a[j]} ];then
			s=$[${a[i]}+${a[j]}]
			for((k=j+1;k<n;k++));do
				if [ ${a[j]} -lt ${a[k]} -a $s -gt $[${a[k]}] ];then
					cnt=$[cnt+1]
				fi
			done
		fi
	done
done
echo $cnt


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

int a[301][301];
bool use_a[301][301];

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> a[i][j];
        }
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if(a[j][k] > a[j][i] + a[i][k]){
                    cout << "-1" << endl;
                    return 0;
                }

                if(a[j][k] == a[j][i] + a[i][k]  && a[j][i] && a[i][k] > 0){
                    use_a[j][k] = true;
                }
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<=i; j++){
            if(use_a[i][j] == false){
                ans += a[i][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
    uint32 N;
    cin >> N;

    if((N/10==9) || (N%10==9)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return;
}



Measured memory_bytes: 256