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

int main() {
  int N,M;
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++) {
    cin >> S[i];
  }
  cin >> M;
  vector<string> T(M);
  for(int i=0; i<M; i++) {
    cin >> T[i];
  }
  int ans=0;
  for(int i=0; i<N; i++) {
    int cnt=0;
    for(int j=0; j<N-i; j++) {
      if(S[i]==S[i+j]) {
        cnt++;
      }
    }
    for(int j=0; j<M; j++) {
      if(S[i]==T[j]) {
        cnt--;
      }
    }
    ans=max(ans,cnt);
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    while(cin>>x>>y, x!=0 || y!=0){
        cout<<min(x,y)<<" "<<max(x,y)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
import java.util.*;
public class Main {

	static final long mod = 998244353;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] cat = new int[3*n];
		Arrays.fill(cat, -1);
		LinkedList<Character> st = new LinkedList<>();
		char wait = 0; int op = 0;
		for(int i = 0; i < 3*n; i++){
			if(s[i] == wait){
				cat[i] = 2;
				op--;
				if(op == 0){
					wait = 0;
				}
			}
			else if(st.isEmpty() || st.peek() == s[i]){
				st.addFirst(s[i]);
				cat[i] = 0;
			}
			else{
				char c = st.removeFirst();
				cat[i] = 1;
				wait = wait(c, s[i]);
				op++;
			}
		}
		
		long[] dp = new long[3*n];
		int free = n, opened = 0, middled = 0;
		for(int i = 0; i < 3*n; i++){
			if(cat[i] == 0){
				dp[i] = free; free--; opened++;
			}
			else if(cat[i] == 1){
				dp[i] = opened; opened--; middled++;
			}
			else{
				dp[i] = middled; middled--;
			}
		}
		
		long res = 1;
		for(long val: dp){
			res = (res * val) % mod;
		}
		System.out.println(res);
	}
	static char wait(char a, char b){
		if(a > b){
			char aux = a; a = b; b = aux;
		}
		if(a == 'G' && b == 'R') return 'B';
		if(a == 'B' && b == 'R') return 'G';
		else return 'R';
	}

}


Measured memory_bytes: 35612
s = input()
# + が入る場所の数
num = len(s) - 1
# 合計値
total = 0
# 2のn乗数通りとなる(+を入れる or 入れない)
for i in range(2 ** num):
    # +を入れた式を作成
    formula = s[0]
    for j in range(num):
        # +を入れる場合
        if (i >> j) & 1:
            formula += "+"
        formula += s[j + 1]
    # 式を評価
    total += eval(formula)
print(total)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a << " " << b << " " << 3 * c - a - b << endl << 4 * c - 2 * a - b << " " << c << " " << 2 * a + b - 2 * c << endl << a + b - c << " " << 2 * c - b << " " << 2 * c - a << endl;
	endre;
}


Measured memory_bytes: 256
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
#print("P:\t" + str(P))
#print("Q:\t" + str(Q))

n = [int(x) for x in range(1,N+1)]
itr = list(itertools.permutations(n))
#print("itr" + str(itr))

for i in range(len(itr)):
#    print("======================================")
#    print("i:\t" + str(i))
#    print(itr[i])
    if (list(itr[i]) == P):
        a = i+1
    if (list(itr[i]) == Q):
        b = i+1

#print("a:\t" + str(a))
#print("b:\t" + str(b))

ans = abs(a-b)
print(ans)

Measured memory_bytes: 8052
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[200000];

int main()
{
  int i,n;
  _int64 now1,now2,now,mi,ma;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  now=2;
  if (now%a[n-1]!=0)
  {
    printf("-1\n");
    return 0;
  }
  now1=2;now2=2+a[n-1]-1;
  for (i=n-2;i>=0;i--)
  {
    if (now1%a[i]==0) mi=now1;
    else mi=(now1/a[i]+1)*a[i];
    ma=now2/a[i]*a[i];
    if (ma<mi)
    {
      printf("-1\n");
      return 0;
    }
    now1=mi;now2=ma+a[i]-1;
  }
  cout<<now1<<" "<<now2<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

deque<ll> ans;

int main()
{
	ll m,k;
	ll num[2];
	cin>>m>>k;
	if(k>=(1<<m))
	{
		cout<<-1<<endl;
		return 0;
	}
	if(k==1 && m==1)
	{
		cout<<-1<<endl;
		return 0;
	}
	ans.insert(ans.begin(),k);
	ans.push_back(0LL);
	for(ll i=1;i<(1<<m);i++)
	{
		if(i==k)
			continue;
		ans.insert(ans.begin(),i);
		ans.push_back(i);
	}

	//余ったやつ
	if(k!=0)
	{
		ans.insert(ans.begin(),k);
		ans.push_back(0LL);
	}

	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
int n;
P t[25];
bool solve(){
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=t[i].second;
    if(sum>t[i].first)return false;
  }
  return true;
}
int main(){
  while(cin>>n&&n){
    for(int i=0;i<n;i++)cin>>t[i].second>>t[i].first;
    sort(t,t+n);
    cout<<(solve()?"Yes":"No")<<endl;
  }
  return 0;
}

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

d=[]
for i in range(1,int(M**0.5)+1):
  if M%i==0:
    d.append(i)
    if i**2!=M:
      d.append(M//i)
d.sort(reverse=True)

for i in d:
  if i*N<=M:
    print(i)
    exit()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX_V 1000
#define INF 1<<29
using namespace std;


//  geometry


typedef double D;
typedef complex<D> P;
const D EPS = 1e-9;
#define X real()
#define Y imag()

//  flow


struct edge{int to,cap,rev;};
vector<edge>G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}
void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int>q;
  level[s]=0;
  q.push(s);
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int i=0;i<G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[e.to]<0){
	level[e.to]=level[v]+1;
	q.push(e.to);
      }
    }
  }
}
int dfs(int v,int t,int f){
  if(v==t)return f;
  for(int &i=iter[v];i<G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&level[v]<level[e.to]){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}
int max_flow(int s,int t){
  int flow=0;
  while(1){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,INF))>0){
      flow+=f;
    }
  }
}

void init(){
  r(i,MAX_V)G[i].clear();
  r(i,MAX_V)level[i]=0;
  r(i,MAX_V)iter[i]=0;
}

int n,m;
double xx,yy,vv[101];
double di[101][101];
vector<P>v,vp;

int main(){
  while(cin>>n>>m,n){
    vp.clear();
    v.clear();
    r(i,n){
      cin>>xx>>yy>>vv[i];
      v.push_back(P(xx,yy));
    }
    r(i,m){
      cin>>xx>>yy;
      P pt=P(xx,yy);
      vp.push_back(pt);
    }
    r(i,n)r(j,m)di[i][j]=abs(vp[j]-v[i])/vv[i];
    D l=0,r=1e9;
    r(i,145){
      
      init();
      D mid=(l+r)/2;
      
      r(j,n)r(k,m)if(di[j][k]<=mid){
        add_edge(j+1,k+201,1);
      }
      r(j,n)add_edge(0,j+1,1);
      r(j,m)add_edge(j+201,500,1);

      int ans=max_flow(0,500);

      if(ans==m)r=mid;
      else l=mid;
    }
    printf("%.8f\n",l);
  }
}

Measured memory_bytes: 3448
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)*/

#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <bitset>  // std::bitset<N>
#include <sstream> //stringstream
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
//ここから書き始める

int main(){
	string s;
	cin >> s;
	int x = s.size();
	ll k ; cin >> k;
	ll ans = 0 ;

	int kouki=1;//文字が一種類
	rep(i,s.size()-1){
		if(s[i+1]!=s[i]){
			kouki = 0;
			break;
		}
	}

		//2回繰り返そう
	ll judge = 0;
	if(k==1){
		for(ll i = 1 ; i < s.size();i++){
			if(s[i]==s[i-1]){
				ans++;
				s[i]='A';
			}
		}
	//	che(s,'s');
	}
	else if(s.size()==1){
		ans = k/2;
	}
	else{
		s+=s;
	//	che(s,'s');//これ消す
		ll n = s.size();
	//	che(s,"s1");
		for(ll i = 1 ; i < n;i++){
			if(s[i]==s[i-1]){
				ans++;
				s[i]='A';
			}
		}
	//	che(s,"s2");
		if(ans%2==0){
			ans /= 2;
		}
		else{
			ans++;
			ans /=2;
			judge = 1;
		}
	ans *= k;
	}
	if(judge) ans--;
	if(kouki&&k>=3&&x>=3){
		ans = x*k/2;
	}
	cout<<ans<<endl;
}



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

int main()
{
	string s;
	int a = 0;
	cin >> s;
	int i = s.length();
	for (int x = 0 ; x < (i+1)/2; x++) {
		if (s.substr(x, 1)!=s.substr(i-x-1,1)) {
			a++;
		}
	}
	cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int N = 4;
int rec[25][25][25][25];

int solve(int a, int b, int c, int d) {
    if(rec[a][b][c][d] >= 0) return rec[a][b][c][d];
    int &val = rec[a][b][c][d];

    for(int bit=1; bit<(1<<N); bit++) {
        if((bit >> 0 & 1) and a == 0) continue;
        if((bit >> 1 & 1) and b == 0) continue;
        if((bit >> 2 & 1) and c == 0) continue;
        if((bit >> 3 & 1) and d == 0) continue;

        int na = a, nb = b, nc = c, nd = d;
        if(bit >> 0 & 1) na--;
        if(bit >> 1 & 1) nb--;
        if(bit >> 2 & 1) nc--;
        if(bit >> 3 & 1) nd--;

        if(solve(na, nb, nc, nd) == 0) return val = 1;
    }
    return val = 0;
}
 
signed main() {
    /*
    // int N; cin >> N;
    fill(rec[0][0][0], rec[21][0][0], -1);

    const int MAX = 10;
    for(int i=0; i<MAX; i++) {
        for(int j=i; j<MAX; j++) {
            for(int k=j; k<MAX; k++) {
                for(int l=k; l<MAX; l++) {
                    solve(i, j, k, l);
                    if(rec[i][j][k][l] == 1) {
                        fprintf(stderr, "win: %2lld %2lld %2lld %2lld\n", i, j, k, l);
                    }
                    if(rec[i][j][k][l] == 0) {
                        fprintf(stderr, "lose: %2lld %2lld %2lld %2lld\n", i, j, k, l);
                    }
                }
            }
        }
    }
    */

    int N; cin >> N;
    for(int i=0; i<N; i++) {
        int val; cin >> val;
        if(val % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 256
X, N = (int(i) for i in input().split())
p = [int(i) for i in input().split()]

res = -1
min = 300
for x in reversed(range(X - 110, X + 110)):
    if x not in p:
        if min >= abs(X - x):
            min = abs(X - x)
            res = x

print(res)


Measured memory_bytes: 61764
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int t=sc.nextInt();
    int[] cost=new int[n];
    int[] time=new int[n];
    int ans=10000;
    for(int i=0;i<n;i++) {
      cost[i]=sc.nextInt();
      time[i]=sc.nextInt();
      if(time[i]<=t) {
        if(cost[i]<ans){
          ans=cost[i];
        }
      }
    }
    if(ans==10000) {
      System.out.println("TLE");
    } else {
      System.out.println(ans);
    }
  }
}


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

int main()
{
  string s;
  vector<queue<char>> vq(3);
  for (int i = 0; i < 3; i++)
  {
    cin >> s;
    for (int j = 0; j < s.size(); j++)
      vq.at(i).push(s[j]);
  }
  char turn = 0;
  while (true)
  {
    char nxt_turn = vq[turn].front() - 'a';
    vq[turn].pop();
    turn = nxt_turn;
    if (vq[turn].empty())
      break;
  }
  cout << (char)('A' + turn) << endl;
}


Measured memory_bytes: 3540
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var k = int.Parse(input.ReadLine());

        var li = new List<long>();
        var tmp = new List<long>();

        for (int i = 1; i <= 9; i++) {
            li.Add(i);
            tmp.Add(i);
        }


        var keta = 1;

        while (true) {
            keta++;
            var tmp2 = new List<long>();
            foreach (var x in tmp) {
                long lastnum = x % 10L;
                tmp2.Add(x * 10 + lastnum);
                //Debug.WriteLine(x * 10 + lastnum);
                if (lastnum < 9) {
                    tmp2.Add(x * 10L + lastnum + 1L);
                    //Debug.WriteLine(x * 10 + lastnum + 1);
                }
                if (lastnum > 0) {
                    tmp2.Add(x * 10L + lastnum - 1L);
                    //Debug.WriteLine(x * 10 + lastnum + 1);
                }
            }
            li.AddRange(tmp2);
            if (li.Count >= k) break;
            tmp = tmp2;
        }

        li.Sort();
        return li[k-1];
    }

    static long Pow(long x, long n) {
        long ans = 1;
        while (n > 0) {
            if (n % 2 == 1) {
                ans = ans * x;
            }
            x = x * x;
            n /= 2;
        }
        return ans;
    }
}

Measured memory_bytes: 20704
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
#include <algorithm>

#define REP(i, a, b) for (int i=a; i <b; i++)

using namespace std;

typedef long long ll;
typedef vector< int > vi;

int main() {
    int n;
    scanf("%d", &n);

    vector< long long > a(n);

    REP(i, 0, n) {
        scanf("%d", &a[i]);
    }

    long long ans = 100000000;
    int x, y;
    REP(i, 0, n) {
        x = a[i];
        y = 0;
        while ((x % 2) == 0) {
            x = x >> 1;
            y++;
        }

        if (ans >= y) {
            ans = y;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

S = list(rs())
W = [0] * len(S)
for i in range(len(S)):
    if S[i] == 'W':
        W[i] = 1
W = np.array(W[::-1])
W_cum = W.cumsum()[::-1]
W_cum = W_cum.tolist()
answer = 0
for i in range(len(S)):
    if S[i] == 'B':
        answer += W_cum[i]

print(answer)

Measured memory_bytes: 24588
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	int m, d; cin >> m >> d;
	int ans = 0;
	rep1(i, m)rep1(j, d)
	{
		int d1 = j % 10;
		int d10 = j / 10;
		if (d1>=2 && d10 >=2 && i == d1 * d10)ans++;
	}
	co(ans);
	return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>): Unit {
    val (a, b) = readLine()!!.trim().split(' ').map(String::toInt)
    val n = readLine()!!.trim().toInt()
    val array = Array(n){val (f, t) = readLine()!!.trim().split(' ').map(String::toInt)
        f until t
    }
    println(
            if (array.any{it.contains(a) || it.contains(b - 1) || (a until b).contains(it.start)}) 1 else 0
    )
}


Measured memory_bytes: 27308
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  map<ll,ll> m;
  ll ans = 0;
  rep(i,n){
    ll d = in();
    ans += m[i-d];
    ++m[d+i];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

set<int> a;

int main()
{
	int s;
	cin >> s;
	
	a.insert(s);
	
	int prosli;
	prosli = s;
	for(int i = 2;;i++)
	{
		if(prosli % 2 == 0)
		{
			prosli /= 2;
		}
		else
		{
			prosli *= 3;
			prosli++;
		}
		
		if (a.find(prosli) != a.end())
		{
			cout << i;
			return 0;
		}
		
		a.insert(prosli);
	}
	
	
}


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

int main() {
    string s;
    cin >> s;
    set<char> st;
    for (int i = 0; i < (int)s.size(); i++) {
        st.insert(s.at(i));
    }
    for (int i = 0; i < 26; i++) {
        if (st.count('a' + i) == 0) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

using int64 = long long;

const int64 kIndecies[][3] = {
  {0,1,2}, {0,1,3}, {0,1,4}, {0,2,3}, {0,2,4},
  {0,3,4}, {1,2,3}, {1,2,4}, {1,3,4}, {2,3,4}};

int main() {
  int n;
  cin >> n;
  vector<int64> march(5, 0);
  for (int i = 0; i < n; ++i) {
    string name;
    cin >> name;
    switch (name[0]) {
    case 'M': ++march[0]; break;
    case 'A': ++march[1]; break;
    case 'R': ++march[2]; break;
    case 'C': ++march[3]; break;
    case 'H': ++march[4]; break;
    }
  }

  int64 res = 0;
  for (auto index : kIndecies) {
    res += march[index[0]] * march[index[1]] * march[index[2]];
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

void inputData(int *R, int *N)
{
	scanf("%d", N);
	for (int i = 0; i < *N; i++)
	{
		scanf("%d", &R[i]);
	}
}

void traceData(int *R, int N)
{
	int i;
	for (i = 0; i < (N - 1); i++)
	{
		printf("%d ", R[i]);
	}
	printf("%d\n", R[i]);
}

int bubbleSort(int *R, int N)
{
	int swappingCount = 0;

	for(int i=0; i<(N-1); i++)
	{
		for (int j = N - 1; j > i; j--)
		{
			if (R[j - 1] > R[j])
			{
				int temp = R[j];
				R[j] = R[j - 1];
				R[j - 1] = temp;
				swappingCount++;
			}
		}
	}
	return swappingCount;
}

int main(void)
{
	int R[MAX], N;
	inputData(R, &N);
	int t = bubbleSort(R, N);
	traceData(R, N);
	printf("%d\n", t);
	return 0;
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll left=0, right=0;
    ll tmp=0,ans=0;
    while(left<n){
        //if(left>right)right=left;
        while(right<n && tmp+a[right]==(tmp^a[right])){
            //cout<<(tmp^a[right])<<endl;
          	tmp+=a[right]; right++;
        }
        ans+=right-left;
        tmp-=a[left];
        left++;
      	//cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
vector<vector<int>> graph;
vector<int> ans, val;
ll n, m;
void bfs(int k, vector<int>& vis){
    queue<int> q;
    q.push(k);
    while(!q.empty()){
        int node = q.front();
        q.pop();
        for(int it : graph[node]){
            if(!vis[it]){
                val[it] = val[node]+1;
                ans[it] = node;
                vis[it] = 1;
                q.push(it);
            }
        }
    }
    for(int i = 1; i <= n; i++)
        if(!vis[i]){
            cout<<"No";
            exit(0);
        }
}
void solve(){
    // ll n, m;
    cin>>n>>m;
    graph.resize(n+1);
    for(int i = 0; i < m; i++){
        int fst, snd;
        cin>>fst>>snd;
        graph[fst].push_back(snd);
        graph[snd].push_back(fst);
    }
    val.resize(n+1);
    ans.resize(n+1);
    vector<int> vis(n+1, 0);
    val[1] = 0;
    bfs(1, vis);
    cout<<"Yes\n";
    for(int i = 2; i <= n; i++)
        cout<<ans[i]<<"\n";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 10960
/*________________________Bismillahir Rahmanir Rahim___________________
|                                                                      |
|                    /\     |     | |\    |     /\     |-------        |
|                   /  \    |     | | \   |    /  \    |               |
|                  /----\   |-----| |  \  |   /----\   |-----          |
|                 /      \  |     | |   \ |  /      \  |               |
|                /        \ |     | |    \| /        \ |               |
|                     14th batch CSE , ID : 12008029                   |
|                     Comilla University                               |
|                     Email : sheikhahnafshifat@gmail.com              |
|______________________________________________________________________*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
using namespace std;
#define ll                      long long
#define MAX                     1000007
#define pb(x)                   push_back(x)
#define mp(x,y)                 make_pair(x,y)
#define vii                     vector<int>
#define vll                     vector<long long>
#define vp                      vector<pair<ll, ll> >
#define v_min(a)                *min_element(a.begin(),a.end())
#define v_max(a)                *max_element(a.begin(),a.end())
#define v_sum(a)                accumulate(a.begin(),a.end(),0)
#define un(a)                   a.erase(unique(a.begin(),a.end()),a.end())
#define SORT(a)                 sort(a.begin(),a.end())
#define AHNAF                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define YES                     cout<<"Yes"<<endl
#define NO                      cout<<"No"<<endl
#define testcase(t)             int t;cin>>t;while(t--)
#define reverse(a)              reverse(a.begin(),a.end())
#define ff                      first
#define ss                      second
#define print(a)                for(auto it: a) cout<<it<<" "
#define all(a)                  a.begin(),a.end()
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    AHNAF;
    long double r,ans;cin>>r;
    ans=3.14159265358979323846*r*2;
    cout<<fixed<<setprecision(20);
    cout<<ans<<endl;
}



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	std::vector<int> r;
	for (int i = 0; i < 30; i++) if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0) r.push_back(i);
	int n = ri();
	if (n == 3) {
		std::cout << "2 5 63" << std::endl;
		return 0;
	}
	std::deque<int> res;
	for (int i = 0; i + 1 < n; i++) res.push_back(i / r.size() * 30 + r[i % r.size()]);
	res.pop_front();
	int64_t sum = std::accumulate(res.begin(), res.end(), 0LL);
	bool b_flag = false;
	for (int i = 0; i < (int) r.size(); i++) {
		for (int j = 0; j < i; j++) {
			if (!((r[i] + r[j] + sum) % 30)) {
				int base = (res.back() + 30) / 30 * 30;
				res.push_back(base + r[j]);
				res.push_back(base + r[i]);
				b_flag = true;
				break;
			}
		}
		if (b_flag) break;
	}
	assert(res.size() == n);
	for (auto i : res) std::cout << i << " ";
	std::cout << std::endl;
	
	return 0;
}


Measured memory_bytes: 384
import kotlin.math.*

fun int() = readLine()!!.toInt()
fun list() = readLine()!!.split(" ").map {it.toInt()}

fun main() {
	val n = int()
	val a = list().toIntArray()

	var r = 0L
	for(i in 1 until n) {
		r += max(0,a[i-1]-a[i])
		a[i] = max(a[i-1],a[i])
	}
	println(r)
}


Measured memory_bytes: 65200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  map<string, int> mp;
  int ans = 0;
  for (int i=0; i<N; i++){
    string s;
    cin >> s;
    auto itr = mp.find(s);
    if( itr == mp.end() ) {
      ans++ ;
      mp[s] = 1;
    }
  }
  cout << ans << endl;
}

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

int main() {
  string s;
  cin>>s;
  
  int n;
  n=s.size();
  
  vector<int> a(n+1,0);
  for(int i=0; i<n; i++) a[n-1-i]=(int)s.at(i)-48;
  
  int count=0;
  
  for(int i=0; i<=n; i++){
    if(a[i] <= 4) count=count+a[i];
    
    else if(a[i] == 5){
      if(a[i+1] >= 5){
      count=count+10-a[i];
      a[i+1]=a[i+1]+1;
      }
      else count=count+a[i];
    }
    
    else{
      count=count+10-a[i];
      a[i+1]=a[i+1]+1;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 5380
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<Integer, Integer> even = new HashMap<>();
    Map<Integer, Integer> odd = new HashMap<>();
    for (int i = 0; i < n; i++) {
      int v = sc.nextInt();
      if (i % 2 == 0) {
        even.put(v, even.getOrDefault(v, 0) + 1);
      } else {
        odd.put(v, odd.getOrDefault(v, 0) + 1);
      }
    }
    
    int[][] evenSorted = sortMapByValue(even);
    int[][] oddSorted = sortMapByValue(odd);
    
    if (evenSorted[0][0] != oddSorted[0][0]) {
      int ans = 0;
      for (int i = 1; i < evenSorted.length; i++) {
        ans += evenSorted[i][1];
      }
      for (int i = 1; i < oddSorted.length; i++) {
        ans += oddSorted[i][1];
      }
      System.out.println(ans);
      return;
    }

    // use evenSorted[0][0]
    int ans1 = 0;
    for (int i = 1; i < evenSorted.length; i++)  {
      ans1 += evenSorted[i][1];
    }
    for (int i = 0; i < oddSorted.length; i++) {
      if (i == 1) {
        // skip
        continue;
      }
      ans1 += oddSorted[i][1];
    }

    // use oddSorted[0][0]
    int ans2 = 0;
    for (int i = 0; i < evenSorted.length; i++) {
      if (i == 1)  {
        // skip
        continue;
      }
      ans2 += evenSorted[i][1];
    }
    for (int i = 1; i < oddSorted.length; i++) {
      ans2 += oddSorted[i][1];
    }
    
    System.out.println(Math.min(ans1, ans2));
  }
  
  private static int[][] sortMapByValue(Map<Integer, Integer> map) {
    int[][] ret = new int[map.size()][2];
    int i = 0;
    for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
      ret[i][0] = entry.getKey();
      ret[i][1] = entry.getValue();
      i++;
    }
    Arrays.sort(ret, (a, b) -> b[1] - a[1]);
    
    return ret;
  }
}

Measured memory_bytes: 64540
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
p = list(li())

cnt = 0
i = 0
while i < n-1:
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
        
    i += 1

        
if p[-1] == n:
    p[-1], p[-2] = p[-2], p[-1]
    cnt += 1
    
print(cnt)

Measured memory_bytes: 14068
fn main() {
    let n:usize = read();
    let mut a:Vec<i64> = read_vec();
    let mut b:Vec<i64> = read_vec();

    let mut ans = kill(&mut a[0],&mut b[0]);
    for t in 1..n+1 {
        for h in t-1..t+1 {
            if h < n {
                ans += kill(&mut a[t], &mut b[h]);
            }
        }
    }

    println!("{}",ans);
}

fn kill(a:&mut i64,b:&mut i64) -> i64{
    let k = std::cmp::min(*a,*b);
    *a -= k; *b -= k; k
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}

fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 9972
from collections import defaultdict

def prime_factor(n):
    d = defaultdict(int)
    for i in range(2, n + 1):
        if i * i > n:
            break

        while n % i == 0:
            d[i] += 1
            n //= i

    if n != 1:
        d[n] += 1

    return d


N = int(input())
d = prime_factor(N)
ans = 0
for v in d.values():
    i = 1
    res = 0
    while res + i <= v:
        res += i
        i += 1
    ans += i - 1

print(ans)


Measured memory_bytes: 66016
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC099.B
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            var a = sc.Nextint ();
            var b = sc.Nextint ();
            var diff = b - a;
            var h = 0;
            for (int i = 1; i < diff; i++)
            {
                h += i;
            }
            var snowh = h - a;
            Console.WriteLine (snowh);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

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

int main() {
	int N, M;
	cin >> N >> M;
	if (2<= abs(N-M)) {
		cout << 0<<endl;
		return 0;
	}
	long long ans = 1;
	for (long long i = 1;i<=M;++i) {
		ans *= i;
		ans %= 1000000007;
	}
	for (long long i = 1;i<=N;++i) {
		ans *= i;
		ans %= 1000000007;
	}
	if (N==M) {
		ans *= 2;
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 4;i++){
        if(s[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	if(b==1)
	{
	    cout<<0;
	    return 0;
	}
	for(ll bor=1;;bor++)
	{
	    ll sockets=bor*a-(bor-1);
	    if(sockets>=b)
	    {
	        cout<<bor;
	        return 0;
	    }
	}
    return 0;
}


//252908XL

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main() {
  string S;
  cin >>  S;
  int ans=0;
  int lenth=0;
  vector<int> l;

  rep(i,S.size()){
    if(S[i]=='A' ||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      lenth++;
    }else{
      lenth=0;
    }
    l.push_back(lenth);
  }
  sort(ALL(l));

  cout << l[l.size()-1];
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include<stack>
#include<queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007


using namespace std;

void solve()
{
    int N;
    cin >> N;

    map<int, int> hash;
    for (int i = 1; i < N; i++)
    {
        int x;
        cin >> x;
        hash[x]++;
    }

    for (int i = 1; i <= N; i++)
    {
        cout << hash[i] << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}



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

ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool maximize
){
    while(lo < hi){
        if(maximize){
            const ll mid = (lo + hi + 1) / 2;
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            ll mid = (lo + hi) / 2;
            if(mid == hi){ mid--; }
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    const ll maxval = ll(1e18) + 1;
    const ll minval = - maxval;

    ll ans = ::binary_search(
        minval, maxval,
        [&](ll x){
            ll count = 0;
            REP(i, n){
                ll tmp = 0;
                if(a.at(i) == 0){
                    if(x > 0){
                        tmp = n - 1 - i;
                    }
                }else if(a.at(i) > 0){
                    ll y;
                    if(x >= 0){
                        y = (x + a.at(i) - 1) / a.at(i);
                    }else{
                        y = - abs(x) / a.at(i);
                    }
                    const auto it_start = a.begin() + i + 1;
                    tmp = lower_bound(it_start, a.end(), y) - it_start;
                }else{
                    assert(a.at(i) < 0);
                    ll y;
                    if(x >= 0){
                        y = - (x + abs(a.at(i)) - 1) / abs(a.at(i));
                    }else{
                        y = abs(x) / abs(a.at(i));
                    }
                    const auto it_start = a.begin() + i + 1;
                    tmp = a.end() - upper_bound(it_start, a.end(), y);
                }
                count += tmp;
            }
            return count < k;
        },
        true
    );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n,m;
    
    while(cin>>n>>m){
        if(n==0 && m==0)break;
        
        int data[200]={};
        rep(i,n){
            rep(j,m){
                int x;
                cin>>x;
                data[j]+=x;
            }
        }
        
        int num[200]={};
        rep(i,m)num[i]=i;
        
        rep(i,m){
            for(int j=m-1;j>i;j--){
                if(data[j]>data[j-1]){
                    swap(data[j],data[j-1]);
                    swap(num[j],num[j-1]);
                }
            }
        }
        rep(i,m){
            cout<<num[i]+1;
            if(i!=m-1)cout<<" ";
        }
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline

# from collections import deque

def linput(_t=int):
    return list(map(_t, input().split()))

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():

    K = int(input())
    S = input().rstrip()

    # res = 0
    # print(N)

    if K >= len(S):
        res = S
    else:
        res = S[:K] + "..."

    print(res)
    # print(("No","Yes")[res%2])



main()


Measured memory_bytes: 61748
#include<bits/stdc++.h>
using namespace std;
long long ans;
int n,m,i,j,t,k,s,a[200005];
char st[200005];

int main()
{
	scanf("%s",st+1);
	n=strlen(st+1);
	for (i=1;i<=n;++i) a[i]=st[i]-'A';
	ans=0;t=1;
	for (i=1;i<=n-1;++i)
	{
		if (a[i]==1&&a[i+1]==2)
		{
			ans+=i-1-t+1;t=t+2;
			if (a[i-2]==0&&i>2) a[i]=0;
			if (a[i-1]==0&&i>1)a[i+1]=0;
		}else if (a[i]!=0) t=i+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int arr[MAX];
int res;
int n, m;

void printMap(int map[][10000]){
    rep(i, n){
        rep(j,m){
            if(j)cout << " ";
            cout << map[i][j];
        }
        cout << endl;
    }
}

void Solve(int map[][10000]){
    int sum = 0;
    rep(i, m){
        int a = 0;//0
        int b = 0;
        rep(j, n){
            if(map[j][i]){
                b++;
            }
            else{
                a++;
            }
        }
        sum += max(a, b);
    }
    res = max(res, sum);
}

void cirMap(int map[][10000], int index){
    if(index == n){
        
        Solve(map);
        return;
    }
    cirMap(map, index+1);
    rep(i, m){
        if(map[index][i]){
            map[index][i] =0;
        }
        else{
            map[index][i] =1;
        }
    }
    cirMap(map, index+1);
}



int main(int argc, const char * argv[]) {
    // input from txt
    /////////
    //write//
    /////////
    
    while(1){
        cin >> n >> m;
        if(n == 0 && m == 0)break;
        int map[10][10000];
        rep(i, n){
            rep(j, m){
                cin >> map[i][j];
            }
        }
        
        cirMap(map, 0);
        
        cout << res << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,answer=0,i;
  cin >> N;
  vector<int> masu(N);
  for (i=0;i<N;i++){
    cin >> masu[i];
  }
  for (i=0;i<N;i++){
    if(i%2==0){
      if(masu[i]%2==1){
        answer++;
      }
    }
  }
  cout <<answer;
  }

Measured memory_bytes: 3584
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void name(TreeMap<String, Integer> trr, Object[] keys) {
		int max = trr.get(keys[0]);
		for (int count = 1; count < keys.length; count++) {
			if(trr.get(keys[count]) > max) max = trr.get(keys[count]);
		}
		getKey(trr, max);
	}
	
	public static void getKey(TreeMap<String, Integer> trr, Integer value) {
		for (String key : trr.keySet()) {
			if(value.equals(trr.get(key))) {
				System.out.println(key);
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt(); scan.nextLine();
		TreeMap<String, Integer> trr = new TreeMap<>();
		for (int count = 0; count < t; count++) {
			String s = scan.nextLine();
			if(trr.containsKey(s)) trr.put(s, trr.get(s) + 1);
			else trr.put(s, 1);
		}
		name(trr, trr.keySet().toArray());
		scan.close();
	}

}


Measured memory_bytes: 79904