akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  string ans = "No";
  if(n%3 == 0) {
    // X,X, ... ,X | Y,Y, ... ,Y | X^Y,X^Y, ... ,X^Y
    if(a[0] == a[n/3-1] && a[n/3] == a[2*n/3-1] && a[2*n/3] == a[n-1] && (a[0]^a[n/3]) == a[2*n/3]) {
      ans = "Yes";
    }
    // 0,0, ... ,0 | x,x, ... ,x
    if(a[0] == 0 && a[0] == a[n/3-1] && a[n/3] == a[n-1]) {
      ans = "Yes";
    }
  } else {
    // 0,0, ... ,0
    if(a[n-1] == 0) {
      ans = "Yes";
    }
  }

  cout << ans << '\n';
  return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n , a , b ;
	cin >> n >> a >> b ;
	int ans = min ( a * n , b );
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200009];
vector<int>pos[26];
pair<int,int>p[100009];
long long tree[200009],ans=0;
int n,odd=-1,cnt=0;
void update(int x) {
	for(;x<n;x|=x+1) tree[x]++;
}
long long query(int x) {
	long long num=0;
	for(;x>=0;x=(x&x+1)-1) num+=tree[x];
	return num;
}
long long sum(int x,int y) {
	return query(y-1)-query(x-1);
}
int main() {
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++) pos[s[i]-'a'].push_back(i);
	for(int i=0;i<26;i++)
		if(pos[i].size()&1)
			if(odd==-1) odd=i;
			else {
				printf("-1\n");
				return 0;
			}
	if(odd!=-1) {
		int mid=pos[odd][pos[odd].size()/2];
		for(int i=0;i<26;i++)
			for(int j=0;j<pos[i].size()/2;j++) {
				if(pos[i][j]>mid) ans++;
				if(pos[i][pos[i].size()-j-1]<mid) ans++;
			}
	}
	for(int i=0;i<26;i++)
		for(int j=0;j<pos[i].size()/2;j++)
			p[cnt++]=make_pair(pos[i][j],pos[i][pos[i].size()-j-1]);
	sort(p,p+cnt);
	for(int i=0;i<cnt;i++) {
		ans+=2*sum(0,p[i].first)+sum(p[i].first,p[i].second);
		update(p[i].second);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int 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;
}

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

	string s;
	cin >> s;
	int cnt = 0;
	REP(i, s.length() / 2) {
		if (s[i] != s[s.length() - 1 - i])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main(){
    long N,M;
    cin>>N>>M;
    long long power = (long long)pow(2,M);
    cout<<(100*(N-M)+1900*M)*power<<endl;
   

}



Measured memory_bytes: 256
char s[10];main(){for(;scanf("%s%s%s",s,s+3,s+6)>2;)
if(s[0]==s[1]&&s[0]==s[2]&&s[0]-'+')printf("%c\n",s[0]);
else if(s[3]==s[4]&&s[3]==s[5]&&s[3]-'+')printf("%c\n",s[3]);
else if(s[6]==s[7]&&s[6]==s[8]&&s[6]-'+')printf("%c\n",s[6]);
else if(s[0]==s[3]&&s[0]==s[6]&&s[0]-'+')printf("%c\n",s[0]);
else if(s[1]==s[4]&&s[1]==s[7]&&s[1]-'+')printf("%c\n",s[1]);
else if(s[2]==s[5]&&s[2]==s[8]&&s[2]-'+')printf("%c\n",s[2]);
else if(s[0]==s[4]&&s[0]==s[8]&&s[0]-'+')printf("%c\n",s[0]);
else if(s[2]==s[4]&&s[2]==s[6]&&s[2]-'+')printf("%c\n",s[2]);
else puts("NA");exit(0);}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010

#define fi first
#define se second
typedef pair <int ,int > par;

template < typename tp > void read ( tp & dig ){
	char ch=getchar();dig=0;int flag=0;
	while(!isdigit(ch)){ if(ch=='-')flag=1;ch=getchar(); }
	while(isdigit(ch))dig=dig*10+ch-'0',ch=getchar();
	if(flag)dig=-dig;
}

set <int > ::iterator it;
set <int > s[maxn];
map <par ,int > mp;
queue <par > que;
int n,fa[maxn];

inline int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}

int main()
{

	read(n);int nn=2*n-2;
	for(int i=1;i<=n;++i)fa[i]=i;
	for(int i=1,x,y;i<=nn;++i){
		read(x);read(y);
		s[x].insert(y),s[y].insert(x);
		++mp[par(x,y)],++mp[par(y,x)];
		if(mp[par(x,y)]==2)que.push(par(x,y));
	}while(!que.empty()){
		par tmp=que.front();que.pop();
		int x=find(tmp.fi),y=find(tmp.se);
		s[x].erase(y),s[y].erase(x);
		if(s[x].size()<s[y].size())swap(x,y);
		for(it=s[y].begin();it!=s[y].end();it++){
			int to=*(it);mp[par(to,y)]=mp[par(y,to)]=0;
			s[to].erase(y),s[to].insert(x);
			++mp[par(to,x)],++mp[par(x,to)];
			if(mp[par(to,x)]==2)que.push(par(to,x));
			s[x].insert(to);
		}fa[y]=x;s[y].clear();
	}int sum=0;
	for(int i=1;i<=n;++i)
		sum+=(find(i)==i);
	if(sum==1)printf("YES\n");
	else printf("NO\n");
	return 0;
	
}


Measured memory_bytes: 57984
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int[,] T, C;
    private int[] P, Q;
    private string[] R;
    private int N, M, K;
    private const int Inf = 1000000000;
    private bool Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        M = int.Parse(line[1]);
        if(N == 0)
        {
            return false;
        }
        T = new int[M, M];
        C = new int[M, M];
        for (int i = 0; i < M; i++)
        {
            for (int j = 0; j < M; j++)
            {
                T[i, j] = Inf;
                C[i, j] = Inf;
            }
        }
        for (int i = 0; i < N; i++)
        {
            line = Console.ReadLine().Split(' ');
            int a = int.Parse(line[0]) - 1;
            int b = int.Parse(line[1]) - 1;
            int cost = int.Parse(line[2]);
            int time = int.Parse(line[3]);
            T[a, b] = Math.Min(T[a, b], time);
            T[b, a] = Math.Min(T[b, a], time);
            C[a, b] = Math.Min(C[a, b], cost);
            C[b, a] = Math.Min(C[b, a], cost);
        }
        K = int.Parse(Console.ReadLine());
        P = new int[K];
        Q = new int[K];
        R = new string[K];
        for (int i = 0; i < K; i++)
        {
            line = Console.ReadLine().Split(' ');
            P[i] = int.Parse(line[0]) - 1;
            Q[i] = int.Parse(line[1]) - 1;
            R[i] = line[2];
        }
        return true;
    }

    public void Solve()
    {
        while (Scan())
        {
            for (int k = 0; k < M; k++)
            {
                for (int i = 0; i < M; i++)
                {
                    for (int j = 0; j < M; j++)
                    {
                        T[i, j] = Math.Min(T[i, j], T[i, k] + T[k, j]);
                        C[i, j] = Math.Min(C[i, j], C[i, k] + C[k, j]);
                    }
                }
            }
            var sb = new StringBuilder();
            for (int i = 0; i < K; i++)
            {
                if (R[i] == "0")
                {
                    sb.AppendLine(C[P[i], Q[i]].ToString());
                }
                else if (R[i] == "1")
                {
                    sb.AppendLine(T[P[i], Q[i]].ToString());
                }

            }
            Console.Write(sb.ToString());
        }
    }
}

Measured memory_bytes: 9484
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する(一部改変).
// hbi1998氏
// https://atcoder.jp/contests/agc038/submissions/7638873
#include <bits/stdc++.h>
using namespace std;
const int N = 220000;

int a[N];

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    int ans = 1;
    set<int> s;
    for(int i = 1; i < k; i++) s.insert(a[i]);
    for(int i = 1; i + k - 1 < n; i++){
        if (!(a[i - 1] < *s.begin() && *s.rbegin() < a[i + k - 1])) ans++;
        s.erase(a[i]);
        s.insert(a[i + k - 1]);
    }
    int cnt = 1, rlt = 0;
    for(int i = 0; i < n - 1; i++){
        if(cnt == k)        rlt++;
        if(a[i + 1] > a[i]) cnt++;
        else                cnt = 1;
    }
    if(cnt == k) rlt++;
    if(rlt)      ans -= rlt - 1;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 10368
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] a=new int[N];
		for(int i=0; i<N; i++) {
			a[i]=sc.nextInt();
		}

		Arrays.sort(a);

		System.out.println(a[N-1]-a[0]);
	}

}

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

bool cmp(ll a,ll b){
  return a>b;
}

int main(){
  ll n;cin >> n;
  std::cout << std::fixed;
  std::cout << std::setprecision(10);
//  vector<double> v(n);
//  for(ll i=0;i<n;i++) cin >> v[i];
  vector<double> dp(n+1,0);
  dp[0] = 1;
  for(ll i=1;i<=n;i++){
    double p;cin >> p;
    for(ll j=i;j>=0;j--){
      if(j==0) dp[j] =dp[j]*(1-p);
      else dp[j] = dp[j-1]*p + dp[j]*(1-p);
    }
  }
  double ans = 0;
  for(ll i=1;i<=n;i++){
    if(i > n-i){
      ans += dp[i];
    }
  }
  cout << ans << endl;
  cin.get();cin.get();
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>
using namespace std;
int eight_queen[8];
int final = 0;
 
bool check(int row, int value) {
    int data;
    for (int i = 0; i < 8; i++) {
        if (eight_queen[i] != -1) {
            data = eight_queen[i];
            if (value == data) return false;
            if ((value + row) == (data + i)) return false;
            if ((value - row) == (data - i)) return false;
        }
    }
    return true;
}
 
void print() {
    for (int j = 0; j < 8; j++) {
        for (int i = 0; i < 8; i++) {
            if (i == eight_queen[j])
                cout << "Q";
            else
                cout << ".";
        }
        cout << endl;
    }
}
 
void solution(int row) {
    if (row > 7) {
        print();
        return;
    }
 
    if (eight_queen[row] != -1 ) solution(row + 1);
    else {
        for (int index = 0; index < 8; index++) {    
            if (check(row, index)) {
                eight_queen[row] = index;
                solution(row + 1);
                eight_queen[row] = -1;
            }
        }
    }
}
 
 
 
int main() {
    int n;
    cin >> n;
    int row, index;
    memset(eight_queen, -1, sizeof(eight_queen));
    for (int i = 0; i < n; i++) {
        cin >> row >> index;
        eight_queen[row] = index;
    }
    solution(0);
    return 0;
}

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

int main(void){
    string s;
    stack<char> c;
    bool w=false;
    getline(cin,s);
    if(s.length()==0){
        cout<<"Cat"<<endl;
        return 0;
    }
    for (int i = 0; i < s.length(); ++i) {
        if(s[i]=='m'&&w){
            cout<<"Rabbit"<<endl;
            return 0;
        }
        if(s[i]=='m')c.push('m');
        if(s[i]=='e'){
            if(c.empty()){
                cout<<"Rabbit"<<endl;
                return 0;
            }
            if(c.top()=='m'){
                c.pop();
                c.push('e');
                w=false;
            }
            else {
                cout<<"Rabbit"<<endl;
                return 0;
            }
        }
        if(s[i]=='w'){
            if(c.empty()){
                cout<<"Rabbit"<<endl;
                return 0;
            }
            if(c.top()=='e'){
                c.pop();
                w=true;
            }
            else {
                cout<<"Rabbit"<<endl;
                return 0;
            }
        }
    }
    if(c.empty()) {
        cout << "Cat" << endl;
    }
    else cout<<"Rabbit"<<endl;
    return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/range/numeric.hpp>

#ifdef _MSC_FULL_VER
#include"randomizer.hpp"
#include"debug_print.hpp"
#endif

#include<cstdlib>
#include<ctime>

namespace lib
{
	template<class T>using pair = std::pair<T, T>;
	template<class T>constexpr T pow(T base, std::uint64_t p)
	{
		T ret = T(1);
		for (std::uint64_t i = 0; i <= 63; ++i)
		{
			if (((1ull << i) & p) != 0)
			{
				ret *= base;
			}
			base *= base;
		}
		return ret;
	}
	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

	struct union_find
	{
		std::vector<int> upper;
		union_find(std::size_t size):upper(size, -1) {}

		int group(int index)
		{
			if (upper[index] == -1)
			{
				return index;
			}
			else
			{
				return upper[index] = group(upper[index]);
			}
		}

		bool merge(int x, int y)
		{
			auto gx = group(x);
			auto gy = group(y);
			if (gx != gy)
			{
				upper[gx] = gy;
				return true;
			}
			return false;
		}

		auto get()
		{
			std::map<int, std::set<int>> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret[group(i)].emplace(i);
			}
			return ret;
		}

		auto tops()
		{
			std::set<int> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret.emplace(group(i));
			}
			return ret;
		}

		bool is_same_group(int x, int y)
		{
			return group(x) == group(y);
		}
	};
}

namespace out
{
	namespace detail
	{
		template<class>struct void_out
		{
			typedef void type;
		};
		template<class T>auto write(std::ostream& ost, T const& val)
			->typename void_out<decltype(ost << val)>::type
		{
			ost << val;
		}
		template<class T, class... Ts>void write(std::ostream& ost, T const& val, Ts const&... nexts)
		{
			write(ost, val);
			ost << " ";
			write(ost, nexts...);
		}
	}
	void write_line()
	{
		std::cout << std::endl;
	}
	template<class...Ts>void write_line(Ts const&... args)
	{
		detail::write(std::cout, args...);
		write_line();
	}
	template<class Range>void write_range(Range const& rng)
	{
		for (auto const& v : rng)
		{
			write_line(v);
		}
	}
}

namespace adaptor = boost::adaptors;

void Main()
{
	std::string str;
	std::cin >> str;
	std::string target = "keyence";
	int f = 0;
	int b = 0;
	for (; f < 7 && str[f] == target[f]; ++f);
	auto r = boost::reverse(str);
	auto tr = boost::reverse(target);
	for (; b < 7 && r[b] == tr[b]; ++b);
	if (f + b >= 7)
	{
		out::write_line("YES");
	}
	else
	{
		out::write_line("NO");
	}
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int N = 233333,mo=1e9+7;
char S[N];int n,f[N],s[N],qz[N],b[N],res,ok[N];vector<int> a[3];
void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}

int main(){
	scanf("%s",S+1);n=strlen(S+1);rep(i,1,n)s[i]=S[i]-'a'+1;
	rep(i,1,n)qz[i]=(qz[i-1]+s[i])%3,a[qz[i]].push_back(i);f[0]=1;
	for(int i=n,j=n+1;i>=0;i--){if(s[i]==s[i+1])j=i+1;b[i]=j;}
	rep(i,1,n)ok[i]=b[i]<=n&&(qz[n]-qz[i-1])%3;ok[n]=1;
	if(b[1]>n){puts("1");return 0;}
	rep(i,0,n-1)rep(j,1,2){
		if(s[i+1]==j)add(f[i+1],f[i]);
		else if(SZ(a[(qz[i]+j)%3])&&b[i+1]<=a[(qz[i]+j)%3].back()){//RE
			int k=*lower_bound(a[(qz[i]+j)%3].begin(),a[(qz[i]+j)%3].end(),b[i+1]);
			if(k<=n)add(f[k],f[i]);
		}
	}
//	rep(i,0,n)printf("%d:%d\n",i,f[i]);
	res=0;rep(i,1,n)if((qz[n]-qz[i])%3==0)add(res,f[i]);
	printf("%d",res);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int A,B,C,D; cin >> A >> B >> C >> D;

	if(A+B > C+D) cout << "Left" << endl;
	else if(A+B == C+D) cout << "Balanced" << endl;
	else cout << "Right" << endl;

	return 0;

}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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 Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  ll ans=0;
  string str=to_string(n);
  vector<char> c;
  rep(i,str.size()) c.push_back(str[i]);
  rep(i,1LL<<(Len(n)-1)){
    ll tmp=str[0]-'0';
    rep(j,Len(n)-1){
      if(i&(1<<j)){
        ans+=tmp;
        tmp=str[j+1]-'0';
      }else{
        tmp*=10;
        ll tmp2=str[j+1]-'0';
        tmp+=tmp2;
      }
    }
    ans+=tmp;
  }
  cout<<ans<<endl;
}

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

int main() {

	int A,B;
	cin >> A>>B;
	int bag=0;

	for(int i =0;i<2;i++){
		if (A>B){
			bag += A;
			A =A-1;
		}
		else{
			bag += B;
			B =B-1;
        }
	}
	cout << bag << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int q[2000000];
void swap(int i, int j){

  int tmp;

  tmp=q[i];
  q[i]=q[j];
  q[j]=tmp;

}//swap

int main(){
  int k,s=0;
  int i,pr,l, r;
  char A[2];
  while(1){
    scanf("%s%d",A,&k);
    if(A[0]=='i'){
      i=s;
      q[i]=k;
      while(i>0 && q[i]>q[pr=(i-1)/2]){
          swap(i,pr);
          i=pr;
        }
        ++s;
    }
    else if(A[1]=='n')break;
    else{
      printf("%d\n",q[0]);

      q[i=0]=q[--s];
      --q[s];
      while((l=i*2+1)<s){
        if((r=l+1)<s && q[r] > q[l])l=r;
        if(q[i]<q[l])swap(i,l);
        i=l;
      }
    }
  }
  return 0;
}//main

Measured memory_bytes: 4692
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod =998244353;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}

//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	COMinit();
	int n, m, k,ans=0;
	cin >> n >> m >> k;
	for(int i=0; i<=k; i++) {
		ans += ((COM(n - 1, i) * m) % mod) * modpow(m - 1, n - i - 1);
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 15592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
#define fout cout << fixed << setprecision(20)
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll LINF = 1e18;
// const ll MOD = 1e9 + 7;
const ll MOD = 1234567;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
/*
bool dfs(int now, int c, vector<vector<int>>& g, vector<int>& color) {
    color[now] = c;
    for (int nxt : g[now]) {
        if (color[nxt] == c) return false;
        if (color[nxt] == -1 && !dfs(nxt, c ^ 1, g, color)) return false;
    }
    return true;
}*/
int main() {
    vector<vector<vector<int>>> ans(4);
    vector<int> cnt(501);
    ans[2] = {{0, 1}, {1, 0}}, cnt[2] = 1;
    ans[3] = {{0, 1, 2}, {1, 0, 1}, {2, 1, 0}}, cnt[3] = 2;

    vector<vector<int>> g;
    vector<int> color;
    for (int m = 4; m <= 500; m++) {
        auto v = make_vec<int>(m, m);
        vector<int> w;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                if (max(i, j) < m / 2) {
                    v[i][j] = ans[m / 2][i][j];
                } else if (min(i, j) >= m / 2) {
                    v[i][j] = ans[m - m / 2][i - m / 2][j - m / 2];
                } else {
                    v[i][j] = max(cnt[m / 2], cnt[m - m / 2]) + 1;
                }
                if (i < j) w.push_back(v[i][j]);
            }
        }
        ans.push_back(v);
        cnt[m] = max(cnt[m / 2], cnt[m - m / 2]) + 1;
        /*
        bool ok = 1;
        for (int x = 1; x <= cnt[m]; x++) {
            g.clear();
            g.resize(m);
            rep(i, m) rep(j, m) {
                if (v[i][j] == x) g[i].push_back(j);
            }
            color.assign(m, -1);
            rep(i, m) {
                if (color[i] == -1) ok &= dfs(i, 0, g, color);
            }
        }
        cout << m << ":" << (ok ? "OK" : "NG") << endl;
        */
    }
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            cout << ans[n][i][j] << " \n"[j == n - 1];
        }
    }
}


Measured memory_bytes: 170420
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > p(n);
  r(i, n) { 
    int a;
    cin >> a;
    p.at(i)=make_pair(a, i);
  }
  sort(p.begin(), p.end());
  r(i, n) cout << p.at(i).second+1 << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swap(数値交換)
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　（A＋B）÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
	int r;
	cin >> r;
	cout << 3 * r * r << rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
S = input()
N = len(S)

ans = 0
for d in range(1 << (N - 1)):
    ret = 0
    T = S[0]
    for i, s in enumerate(S[1:]):
        if (d & (1 << i)) > 0 and len(T) > 0:
            ret += int(T)
            T = ''
        T += s
    if len(T) > 0:
        ret += int(T)
    ans += ret
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int cnt[maxn],n;

int main()
{
	fastIO;
	cin >> n;
	rep(i,2,n + 1) {
		int x; cin >> x;
		cnt[x]++;
	}	
	rep(i,1,n + 1) cout << cnt[i] << endl;
	return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h> 
#include <vector> 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
#define pb push_back
#define popb pop_back
#define si size()
#define sof sizeof()
#define be begin()
#define en end()
#define all(v) v.be,v.en
#define le length()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define ump unordered_map
#define forr(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define maxe *max_element
#define mine *min_element
#define hii ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
#define o(a) cout<<a<<" "
#define ol(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
#define mod 998244353
using namespace std;
int main() 
{ 
    string s;
    cin >>s;
   string f=s.substr(0,(s.si-1)/2);
   string r=s;
   reverse(all(r));
   string re=r.substr(0,(s.si-1)/2);
   string h=re,gh=f;
   reverse(all(re));
   reverse(all(gh));
   
   if(h==re&&gh==f&&r==s&&s.si%2==1){
       cout<<"Yes\n";
   }else{
       cout<<"No\n";
   }
    
	return 0; 
} 


Measured memory_bytes: 256
N = int(input())
Shop_info =[list(map(int, input().split())) for _ in range(N)]
Earn = [list(map(int, input().split())) for _ in range(N)]
ans = - float('inf')
for i in range(1,2**10):
    Open = [0] * N
    ansi = 0
    for j in range(10):
        if (i >> j) & 1 == 1:
            for k in range(N):
                if Shop_info[k][j]:
                    Open[k] += 1
    for x, o in enumerate(Open):
        ansi += Earn[x][o]
    ans = max(ans, ansi)
print(ans)

Measured memory_bytes: 42348
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
const int INF=0x3f3f3f3f;
int n,k,tot,a[maxn],pos[maxn],deg[maxn],ans[maxn];
set<int> L,R;
vector<int> e[maxn];
priority_queue<int> q;
void toposort() 
{
    for (int i=1;i<=n;i++)
        if (deg[i]==0) q.push(-i);
    while (!q.empty()) 
    {
        int x=-q.top(); q.pop();
        a[++tot]=x;
        for (int i=0;i<e[x].size();i++) 
        {
            int y=e[x][i];
            if (--deg[y]==0) q.push(-y);
        }
    }    
}

int Min[maxn<<2];
void build(int rt,int l,int r) 
{
    Min[rt]=INF;
    if (l==r) return;
    int mid=l+r>>1;
    build(rt<<1,l,mid); build(rt<<1|1,mid+1,r);
}

void update(int rt,int l,int r,int q,int v) 
{
    if (l==r) { Min[rt]=min(Min[rt],v); return; }
    int mid=l+r>>1;
    if (q<=mid) update(rt<<1,l,mid,q,v);
    if (q>mid) update(rt<<1|1,mid+1,r,q,v); 
    Min[rt]=min(Min[rt<<1],Min[rt<<1|1]);
}

int query(int rt,int l,int r,int ql,int qr) {
    if (ql<=l && r<=qr) return Min[rt];
    int mid=l+r>>1;
    int ans=INF;
    if (ql<=mid) ans=min(ans,query(rt<<1,l,mid,ql,qr));
    if (qr>mid) ans=min(ans,query(rt<<1|1,mid+1,r,ql,qr));
    return ans; 
}

int main()
{
    cin>>n>>k;
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++) pos[a[i]]=i;
    build(1,1,n);
    for (int i=n;i;i--) 
    {
        int t1=query(1,1,n,max(1,pos[i]-k+1),pos[i]);
        if (t1<=n) e[pos[i]].push_back(pos[t1]),deg[pos[t1]]++;
        int t2=query(1,1,n,pos[i],min(n,pos[i]+k-1));
        if (t2<=n) e[pos[i]].push_back(pos[t2]),deg[pos[t2]]++;
        update(1,1,n,pos[i],i);
    }
    toposort();
    for (int i=1;i<=n;i++) ans[a[i]]=i; 
    for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 43208
#include<stdio.h>

int main(){
  int a, b;
  int temp;
  int i;

  for(i = 0; i < 10000; i++){
    scanf("%d %d", &a, &b);

    if(a == 0 && b == 0) break;

    if(a > b){
      temp = a;
      a = b;
      b = temp;
    }

    printf("%d %d\n", a , b);
  }

  return 0;
}



Measured memory_bytes: 2032
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if((a < c &&  c < b) || (b < c && c < a)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

struct Data{

  int s_cnt,e_cnt;
  int s_time[500],e_time[500];
  
};

int main(){
  
  int N,M;
  int r,q,t,n,m,m2,s;
  int t_s,t_e;
  int table[1000];
  
  while(1){
    
    cin >>N>>M;
    if(N==0 && M==0)break;
    
    vector<Data> student(M+1);
    
    for(int i=0 ; i < M+1 ; i++){
      student[i].s_cnt=0;
      student[i].e_cnt=0;
    }
    
    cin >>r;
    for(int i=0 ; i < r ; i++){
      cin >>t>>n>>m>>s;
      if(s == 1){
	student[m].s_time[student[m].s_cnt]=t;
	student[m].s_cnt++;
      }else{
	student[m].e_time[student[m].e_cnt]=t;
	student[m].e_cnt++;
      }
    }
    
    cin >>q;
    for(int i=0 ; i < q ; i++){
      cin >>t_s>>t_e>>m2;
      for(int j=0 ; j < 1000 ; j++)table[j]=0;
      for(int j=0 ; j < student[m2].s_cnt ; j++){
	for(int k=student[m2].s_time[j]-540 ; k < student[m2].e_time[j]-540 ; k++){
	  table[k]=1;
	}
      }
      int sum=0;
      for(int j=t_s-540 ; j < t_e-540  ; j++)sum+=table[j];
      cout <<sum<<endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 58084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,ans;
    cin >> n;
    if(n%1000 == 0)
        cout << "0" << endl;
    else
    {
        k = n%1000;
        ans = 1000 - k;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,M,K,P,A,B,C,N,X;

    long double x;

    string S,T;

    ll ans=0;
    ll count=0;
    ll flag=0;
    ll temp=0;

    vector<ll>  aa,cc, hh, ff;
    vector< vector<ll> >  bb;
    map<ll,ll> m;

    cin >>N>>K;
    rep(i,N){
        cin>>temp;
        aa.push_back(temp);
    }
    cc.push_back(0);
    temp=0;
    m[0]=1;
    rep(i,K){
        temp=aa[temp]-1;
        if(m[temp]==1){
            repr(j,0,cc.size()){
                if(cc[j]==temp){
                    //cout<<"A"<<i<<"B"<<j<<endl;
                    ans=cc[j+  (((K-i)%(i-j+1))-1+i-j+1)%(i-j+1) ] ;
                    cout<< ans+1<< endl;
                    return 0;
                }
            }
        }
        cc.push_back(temp);
        m[temp]=1;
    }

    cout<<temp+1<<endl;


    return 0;
}

Measured memory_bytes: 16036
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
using ld=long double;
int a,b,c,d,e,f,k,n,m,h,w,ans,cnt;
char C;
string s,t,u;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
#define L(n) for(int i=0;i<n;i++)
#define V(n) vector<int> v(n)
#define XXX cout<<ans<<endl;
void yy(bool a){
  cout<<(a?"Yes":"No")<<endl;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int l=-LINF,r=LINF;//lが答え
  while(r-l>1){
    int mid=(r+l)>>1;
    int tmp=0;//mid以下がK個以上あればtmpは答えより大きいのでr=tmp
    for(int i=0;i<n;i++){
      if(v[i]>0){
        if(v[0]*v[i]>mid)continue;
        int ll=0,rr=n;//llはmid以下
        while(rr-ll>1){
          int m=(rr+ll)>>1;
          if(v[i]*v[m]>mid)rr=m;
          else ll=m;
        }
        tmp+=rr;
        if(v[i]*v[i]<=mid)tmp--;
      }
      if(v[i]==0){
        if(mid>=0)tmp+=n-1;
      }
      if(v[i]<0){
        if(v[n-1]*v[i]>mid)continue;
        int ll=-1,rr=n-1;//rrはmid以下
        while(rr-ll>1){
          int m=(rr+ll)>>1;
          if(v[i]*v[m]>mid)ll=m;
          else rr=m;
        }
        tmp+=n-rr;
        if(v[i]*v[i]<=mid)tmp--;
      }
    }
    if(tmp>=k*2)r=mid;
    else l=mid;
  }
  cout<<l+1<<endl;
}


Measured memory_bytes: 4704
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    int K, S;
    cin >> K >> S;
    ll ans = 0;
    REP(i, K+1)REP(j, K+1){
        int k = S - i - j;
        if(0 <= k && k <= K) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	ll n;
	cin >> n;
	ll answer = n - 1;
	for(ll i = 1; i * i <= n; ++i)
		if(n % i == 0)
			answer = min(answer, i + n / i - 2);
	cout << answer << '\n';
}

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

int main()
{
  string s;
  cin >> s;
  
  int n = s.size();
  int flag = 0;
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n-1-i]){
      flag = 1;
    }
  }
  
  for(int i = 0; i < ((n-1)/2)/2; i++){
    if(s[i] != s[(n-1)/2-1-i]){
      flag = 1;
    }
  }
  
  for(int i = (n+3)/2-1; i < n; i++){
    if(s[i] != s[n-i-1]){
      flag = 1;
    }
  }
  
  if(flag == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

bool checkShou(vector<ll> v){
  ll n = v.size();
  bool sysflag = true;

  REP(i, n-1){
    if(v[i] > v[i+1])
      sysflag = false;
  }

  return sysflag;

}

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

  ll n;
  cin >> n;

  vector<ll> p(n);
  REP(i, n)
    cin >> p[i];

  if(checkShou(p)){
    cout << "YES" << endl;
    return 0;
  }

  REP(i, n){
    for(int j = i; j < n; j++){
      ll tmp = p[i];
      p[i] = p[j];
      p[j] = tmp;
      if(checkShou(p)){
        cout << "YES" << endl;
        return 0;
      }
      tmp = p[i];
      p[i] = p[j];
      p[j] = tmp;
    }
  }
  cout << "NO" << endl;
  
  
}


Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))
res = 0
MOD = int(1e9 + 7)
bit = 0
for n in range(60):
    b1, b0 = 0, 0
    for i in range(len(X)):
       if X[i] & (1 << bit):
           b1 += 1
       else:
           b0 += 1
    res += (b1 * b0 * (1 << bit))
    res = res % MOD
    bit += 1
print(res)

Measured memory_bytes: 122808
#include <cstdio>
#include <string>
#include <queue>
#define ll long long
#define N 100050
using namespace std;
int n,m;
ll ans;
priority_queue<int> q;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1,x;i<=n;i++)
		scanf("%d",&x),q.push(x);
	for(int i=1;i<=m;i++){
		int x=q.top(); q.pop(); q.push(x/2);
	}
	while(!q.empty()){
		ans+=q.top(); q.pop();
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(){
    ll a,b,k;cin>>a>>b>>k;
    ll c1=min(a,k);
    a-=c1;
    k-=c1;
    ll c2=min(b,k);
    b-=c2;
    cout<<a<<" "<<b<<endl;
}

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


Measured memory_bytes: 256
use proconio::{fastout, input};

const C: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];

#[fastout]
fn main() {
    input! {mut in_n: i128};
    let mut cs = Vec::new();

    in_n -= 1;

    loop {
        cs.push(C[(in_n % 26) as usize]);
        in_n = (in_n / 26) - 1;

        if in_n < 0 {
            break;
        }
    }

    for c in cs.iter().rev() {
        print!("{}", c);
    }
    println!();
}


Measured memory_bytes: 2148