akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

ll spow(int a,int n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n%2 == 0) return spow(a,n/2)*spow(a,n/2);
  else return a*spow(a,n/2)*spow(a,n/2);
}

int main(){
  ll n,k;
  cin >> n >> k;
  if(k%2) cout << spow(n/k,3) << endl;
  else cout << spow(n/k,3) + spow(2*n/k - n/k,3) << endl;
}


Measured memory_bytes: 256
s = input()
t = input()

len_s = len(s)
len_t = len(t)

dp = [[0] * (len_t+1) for _ in range(len_s+1)]

for i in range(len_s):
    for j in range(len_t):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

i = len_s
j = len_t
res = ""
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res += s[i-1]
        i -= 1
        j -= 1

print(res[::-1])


Measured memory_bytes: 113500
#include <iostream>

int main()
{
    int S;
    int h, m , s;

    std::cin >> S;

    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;

    std::cout << h << ":" << m << ":" << s << "\n";

    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=505;
int f[N][N];
struct info{
	int l,r;
}a[N];
bool cmp(info x,info y){
	return x.l==y.l?x.r<y.r:x.l<y.l;
}
int main(){
	int m=read(),mo=read(),n=0;
	For(i,0,2*m-1){
		int L=0,R=0;
		for(int j=2*m-1;j>=0&&j*j+i*i>=m*m;j--) L=j;
		for(int j=0;j<=2*m-1&&j*j+i*i<=4*m*m;j++) R=j;
		R++;
		if(L==0) swap(L,R);
		a[++n]=(info){L,R};
	}
	sort(a+1,a+n+1,cmp);
	// For(i,0,n-1) cout<<a[i].l<<" "<<a[i].r<<endl;
	int ans=0;
	For(k,0,m){
		memset(f,0,sizeof(f));
		f[0][0]=1;
		int cnt1=0,cnt2=0;
		For(i,1,n){
			For(j,0,k) if(f[i-1][j]){
				if(a[i].r==0){
					f[i][j]=(f[i][j]+(ll)f[i-1][j]*(a[i].l-j-cnt1))%mo;
				}else{
					if(j<k) f[i][j+1]=(f[i][j+1]+(ll)f[i-1][j]*(a[i].l-j-cnt1))%mo;
					f[i][j]=(f[i][j]+(ll)f[i-1][j]*(a[i].r-m-k-(cnt2-j)))%mo;
				}
			}
			if(a[i].r==0) cnt1++;
			else cnt2++;
		}
		if(k%2) ans=(ans+mo-f[n][k])%mo;
		else ans=(ans+f[n][k])%mo;
	}
	cout<<ans;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll cnt[100];

int main() {
	int n;
	scanf("%d", &n);
	for (int i=1 ; i<=n ; i++) {
		int j = i;
		int l = i%10;
		int f;
		while (j) {
			f = j;
			j/=10;
		}
		//cout <<f<<l<<endl;
		cnt[f*10+l]++;
	}
	ll sol = 0;
	for (int i=0 ; i<100 ; i++) {
		int f = i/10;
		int l = i%10;
		sol += cnt[f*10+l]*cnt[l*10+f];
	}
	printf("%lld\n", sol);
	return 0;
}

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

int main(void)
{
    int Num;
    cin >> Num;
    bool Flag_Divide = false;
    for(int i =1; i<=9; i++)
    {
        if(Num % i == 0)
        {
            int b = Num/i;
            if(b >= 1 && b <= 9)
            {
                Flag_Divide = true;
            }
        }
        if(Flag_Divide == true)
        {
            break;
        }
    }

    // print
    if(Flag_Divide)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString("\n");
      println(solve(input).trim());
    }
  }

  def solve(input:String):String={
    input.foldLeft(0){(s, c) => s + c.toString.toInt}.toString
  }

  val tests=List("""101""" -> """2""",
    """000""" -> """0""");

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

struct Prime {
  int n;
  vector<int> pri;
  Prime() : n(0) {}
  Prime(int n) : n(n) {
    vector<bool> f(n, true);
    f[0] = f[1] = false;
    for (int i = 2; i < n; i++) {
      if (!f[i]) continue;
      pri.push_back(i);
      for (int j = i * 2; j < n; j += i) {
        f[j] = false;
      }
    }
  }
  bool is(int x) {
    if (n > x) {
      return binary_search(pri.begin(), pri.end(), x);
    }
    if (x < 2) return 0;
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0) return false;
    }
    return true;
  }
  map<int, int> factor(int k) {
    map<int, int> so;
    for (auto p : pri) {
      while (k % p == 0) k /= p, so[p]++;
    }
    if (k != 1) so[k] = 1;
    return so;
  }
};

void solve() {
  auto primes = Prime(200000).pri;
  int x;
  cin >> x;
  each(p, primes) {
    if (p >= x) {
      cout << p << endl;
      return;
    }
  }
}


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

int main(){
	int graph[100][100] = {};
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int now,m;
		cin >> now >> m;
		for(int j = 0;j < m;j++) {
			int t;
			cin >> t;
			graph[now - 1][t - 1] = 1;
		}
	}
	for(int i = 0;i < n;i++){
		cout << graph[i][0];
		for(int j = 1;j < n;j++){
			cout << " " << graph[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

# Input
s = [input() for i in range(2)]
HN = (list(s[0].split()))
A = (list(s[1].split()))

# Proccess
sum_a = 0
for i in range(int(HN[1])):
  sum_a = sum_a +int(A[i])
  
# Output							
if int(sum_a) >= int(HN[0]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 10712
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース

*/
//main.cpp----------------------------
#define max_n 200000

void solve();

ll a, b;

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

  solve();

  return 0;
}

void solve() {

  if(b%a==0) {
    cout << a+b << endl;
  }else {
    cout << b-a << endl;
  }
}


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

struct L {
  int a, b, c;
  L(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {}
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<L> ln(n), lm(m);
  map<int, int> mpx, mpy;
  mpx[0] = 0, mpy[0] = 0;
  rep(i, n) {
    int a, b, c;
    cin >> a >> b >> c;
    ln[i] = L(a, b, c);
    mpx[a] = 0, mpx[b] = 0, mpy[c] = 0;
  }
  rep(i, m) {
    int a, b, c;
    cin >> c >> a >> b;
    lm[i] = L(a, b, c);
    mpy[a] = 0, mpy[b] = 0, mpx[c] = 0;
  }
  vector<int> xs, ys;
  for (auto &it : mpx) {
    it.second = xs.size();
    xs.push_back(it.first);
  }
  for (auto &it : mpy) {
    it.second = ys.size();
    ys.push_back(it.first);
  }
  int w = xs.size() * 2;
  int h = ys.size() * 2;
  vector<vector<int>> board(h, vector<int>(w));
  for (auto l : ln) {
    for (int i = mpx[l.a] * 2; i <= mpx[l.b] * 2; i++)
      board[mpy[l.c] * 2][i] = -1;
  }
  for (auto l : lm) {
    for (int i = mpy[l.a] * 2; i <= mpy[l.b] * 2; i++)
      board[i][mpx[l.c] * 2] = -1;
  }
  queue<pair<int, int>> bfs;
  int x = mpx[0] * 2, y = mpy[0] * 2;
  board[y][x] = 1;
  int dx[] = {-1, 0, 1, 0};
  int dy[] = {0, 1, 0, -1};
  bfs.push(make_pair(x, y));
  bool inf = false;
  while (!bfs.empty()) {
    x = bfs.front().first;
    y = bfs.front().second;
    bfs.pop();
    if (x <= 0 || w - 1 <= x || y <= 0 || h - 1 <= y) {
      inf = true;
      break;
    }
    rep(i, 4) {
      int xx = x + dx[i], yy = y + dy[i];
      if (board[yy][xx] != 0) continue;
      board[yy][xx] = 1;
      bfs.push(make_pair(xx, yy));
    }
  }
  if (inf) {
    cout << "INF" << endl;
    return 0;
  }
  ll sum = 0;
  for (int j = 1; j < h; j += 2)
    for (int i = 1; i < w; i += 2)
      if (board[j][i] == 1)
        sum += (ll)(xs[(i + 1) / 2] - xs[(i - 1) / 2]) * (ll)(ys[(j + 1) / 2] - ys[(j - 1) / 2]);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 144488
#include<stdio.h>
int main(){
	int n,m,i,j,k,blue,bloot=0;
	int a[101][101],b[101],c=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&a[i][j]);
	for(k=0;k<m;k++)scanf("%d",&b[k]);
	for(i=0;i<n;i++){
		c=0;
		for(j=0;j<m;j++){
			c=c+a[i][j]*b[j];
		}
		printf("%d\n",c);
	}
	return 0;
}



Measured memory_bytes: 2104
# tige????????????????????????

def left(i):return  2 * i + 1
def right(i):return  2 * i + 2
def max_heapify(a, i):
    l = left(i)
    r = right(i)
    largest = l if  l < len(a) and a[l] > a[i] else i
    largest = r if  r < len(a) and a[r] > a[largest] else largest
     
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest)
         
def build_max_heap(a):
    for i in range(len(a) // 2, -1, -1):
        max_heapify(a, i)
n = int(input())
heap = list(map(int, input().split()))
build_max_heap(heap)
print('', *heap)

Measured memory_bytes: 66028
cnt = 0
po = 1
n,m = map(int,input().split())
ans = [0 for i in range(n)]


  
sc = [list(map(int,input().split())) for i in range(m)]
for i in sc:
  if((ans[i[0]-1] != 0 and ans[i[0]-1] != i[1] ) or (i[0] == 1 and i[1] == 0 and n != 1)):
    print(-1)
    exit()
  else:	
    ans[i[0]-1] = i[1]
if(m == 0 and n > 1):
  ans[0] = 1
elif(ans[0] == 0 and n != 1):
  ans[0] = 1
for i in range(n-1,-1,-1):
  cnt += ans[i] * po
  po *= 10
print(cnt)

Measured memory_bytes: 3064
#include <iostream>

int main(){
  	long long int num;
  	std::cin >> num;
  	int flag = num % 10;
  	if(flag == 3){
      	std::cout << "bon\n";
    }else if(flag == 0 || flag == 1 || flag == 6 || flag == 8){
      	std::cout << "pon\n";
    }else{
      	std::cout << "hon\n";
    }
  	return 0;
}

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

using namespace std;

const int maxn = 2010,mod = 998244353;
char s[maxn];
int num1[maxn],num2[maxn],n,f[maxn][maxn],c[maxn][maxn],ans;

int main()
{
    scanf("%s",s + 1);
    n = strlen(s + 1);
    c[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        c[i][0] = 1;
        for (int j = 1; j <= i; j++)
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
    for (int i = 1; i <= n; i++)
    {
        num1[i] = num1[i - 1];
        num2[i] = num2[i - 1];
        if (s[i] == '0')
            num1[i] += 2;
        if (s[i] == '1')
            num1[i]++,num2[i]++;
        if (s[i] == '2')
            num2[i] += 2;
    }
    f[0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (f[i][j])
            {
                if (j + 1 <= num1[i + 1])
                    f[i + 1][j + 1] = (f[i + 1][j + 1] + f[i][j]) % mod;
                if (i + 1 - j <= num2[i + 1])
                    (f[i + 1][j] += f[i][j]) %= mod;
            }
    for (int i = 0; i <= num1[n]; i++)
        ans = (ans + 1LL * f[n][i] * c[n][num1[n] - i] % mod) % mod;
    printf("%d\n",ans);

    return 0;
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int  n;

main() {
    cin >> n;
    ct(800*n-n/15*200)
}




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

constexpr int64_t MOD = 1e9 + 7;
array<int64_t, 100'010> fac;

int main() {
    fac[0] = 1;
    for (int i = 0; i+1 < 100'010; i++) fac[i+1] = fac[i] * (i+1) % MOD;
    int64_t n, m;
    cin >> n >> m;
    int ans = 0, a = abs(n-m);
    if (a <= 1) {
        ans = fac[n] * fac[m] % MOD;
        if (a == 0) ans = ans * 2 % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
//マージソートのプログラム
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
int cnt;

void merge(vector<int> &a,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    vector<int> L(n1+1),R(n2+1);
    for(int i=0;i<n1;i++)L[i]=a[left+i];
    for(int i=0;i<n2;i++)R[i]=a[mid+i];
    int i=0,j=0;
    L[n1]=2000000000,R[n2]=2000000000;
    for(int k=left;k<right;k++){
        cnt++;
        if(L[i]<=R[j]){
            a[k]=L[i];
            i++;
        }else{
            a[k]=R[j];
            j++;
        }
    }
}

void mergesort(vector<int> &a,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(a,left,mid);
        mergesort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main(){
    int n;
    cnt=0;
    cin>>n;
    vector<int> vec(n);
    vec_input(vec);
    mergesort(vec,0,n);
    vec_output(vec);
    cout<<cnt<<endl;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long K, long long N, std::vector<long long> A){
    i64 d = K - A[N - 1] + A[0];
    rep(i, N - 1){
        d = max(d, A[i + 1] - A[i]);
    }
    cout << K - d << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, a, b;
int ans = 0;
/**********************************************/

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

    ans = min(n * a, b);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll dp[101][100010], v[100010], w[100010];

ll solve(ll pos, ll we){
  if(pos < 0) return 0;
  ll &r = dp[pos][we];
  if(r >= 0) return r;
  r = solve(pos-1,we);
  if(w[pos] <= we) r = max(r, v[pos] + solve(pos-1,we-w[pos]));
  return r;
}

int main(){FIN;
  memset(dp,-1,sizeof(dp));
  ll n,W;
  cin >> n >> W;
  fore(i,0,n) cin >> w[i] >> v[i];
  cout << solve(n-1, W) << "\n";
}

Measured memory_bytes: 79232
#include<stdio.h>
 
 int n,m;
 int p,c;
 int s[50],dist[50];
  
  int main(){
	  int i,j;
	  while(1){
	  scanf("%d%d",&n,&m);
	  if( !n && !m )
		  break;
	  for(i=0;i<n;i++){
		  s[i]=n-i;
	  }
	  for(i=0;i<m;i++){
		  scanf("%d%d",&p,&c);
		  p--;
		   
		   for(j=0;j<c;j++){
			   dist[j] = s[j+p];
		   }
		   for(j=p-1;j>=0;j--){
			   s[j+c] = s[j];
		   }
		   for(j=0;j<c;j++){
			   s[j] = dist[j];
		   }
		  /* for(j=0;j<n;j++){
			   printf("s[%d] = %d\n",j,s[j]);
		   }*/
	  }
	  printf("%d\n",s[0]);
	  }
	  return 0;
 }

Measured memory_bytes: 600
S = list(input())

A = int(S[0]) * 10 + int(S[1])
B = int(S[2]) * 10 + int(S[3])

if A > 0 and A <= 12:
    res_A = True
else:
    res_A = False

if B > 0 and B <= 12:
    res_B = True
else:
    res_B = False

if res_A and res_B:
    print("AMBIGUOUS")
elif res_A:
    print("MMYY")
elif res_B:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int distance = sc.nextInt();
        long x,y;
        int count = 0;

        for (int i = 0; i < num; i++) {
            x = sc.nextInt();
            y = sc.nextInt();
            if (Math.sqrt(x * x + y * y) <= distance) {
                count++;
            }
        }
        sc.close();
        System.out.println(count);
    }
}


Measured memory_bytes: 59700
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

num_l=[1 for i in range(n)]
bit_l=[1]+[0 for i in range(n-1)]

for x,y in l:
  x-=1
  y-=1

  if bit_l[x]==1:
    bit_l[y]=1
    if num_l[x]==1:
      bit_l[x]=0
  num_l[x]-=1
  num_l[y]+=1

print(bit_l.count(1))

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

int main(){
   int a, b, c;
   cin >> a >> b >> c;
   int d = a + b + c;
   if(d >= 22) cout << "bust" << endl;
   else cout << "win" << endl;
}

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

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

    long long PN[1005] = {};
    long long mod = 1000000007;
    // N!を素因数分解したとき、p^xの項が出てきたら、PN[p] = x % mod

    for (int n = 2; n <= N; n++)
    {
        int m = n;
        for (int i = 2; i <= pow(m, 0.5); i++)
        {
            while (m % i == 0)
            {
                m /= i;
                PN[i]++;
            }
        }
        if (m != 1)
        {
            PN[m]++;
        }
    }

    /*
    cout << N << "! = ";
    for (int i = 2; i <= N; i++)
    {
        cout << " + " << i << "^" << PN[i];
    }
    cout << endl;
    return 0;
    */

    long long ans = 1;
    for (int n = 2; n <= N; n++)
    {
        ans *= (PN[n] + 1);
        ans %= mod;
    }

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

Measured memory_bytes: 640
from collections import defaultdict

N = int(input())
C = [int(input())]
for _ in range(N - 1) :
  c = int(input())
  if c != C[-1] :
    C.append(c)

mod = 10 ** 9 + 7

ret = 1
dp = defaultdict(int)
for c in C :
  tmp = dp[c]
  dp[c] += ret
  ret += tmp
  dp[c] %= mod
  ret %= mod

print(ret)

Measured memory_bytes: 80728
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  double A, B;
  cin >> A >> B;
  double Amin = A / 0.08;
  double Amax = (A + 1) / 0.08;
  double Bmin = B / 0.1;
  double Bmax = (B + 1) / 0.1;
  if(Amax <= Bmin || Bmax <= Amin) {
    cout << -1 << endl;
  }
  else {
    cout << i64(std::ceil(std::max(Amin, Bmin))) << endl;
  }
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	vector<ll> V(100000, 0);

	ll res{1};
	REP(i, N)
	{
		ll &t = A[i];

		if (t == 0)
		{
			(res *= (3-V[t])) %= MOD;
			++V[t];
		}
		else
		{
			(res *= (V[t-1] - V[t])) %= MOD;
			++V[t];
		}
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 1792
N=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(N):
  C=input()
  if C=="AC":
    AC+=1
  elif C=="WA":
    WA+=1
  elif C=="TLE":
    TLE+=1
  elif C=="RE":
    RE+=1
print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))

Measured memory_bytes: 9116
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = [c for c in S()]
    t = [c for c in S()]
    sl = len(s)
    tl = len(t)
    rr = [[0] * (tl) for _ in range(sl)]
    for i in range(sl):
        for j in range(tl):
            if s[i] == t[j]:
                if i > 0 and j > 0:
                    rr[i][j] = rr[i-1][j-1] + 1
                else:
                    rr[i][j] = 1
                continue

            m = 0
            if i > 0:
                m = rr[i-1][j]
            if j > 0 and m < rr[i][j-1]:
                m = rr[i][j-1]
            rr[i][j] = m

    i = sl-1
    j = tl-1
    r = []
    while i >= 0 and j >= 0:
        if s[i] == t[j]:
            r.append(s[i])
            i -= 1
            j -= 1
            continue
        if rr[i][j] == 0:
            break
        if i > 0 and rr[i-1][j] == rr[i][j]:
            i -= 1
        else:
            j -= 1

    return ''.join(r[::-1])


print(main())


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ll N; ll K; cin >> N >> K;
    ll over = N*(N-1)/2 - K + 1; //上からover番目は何か、という問題で、over以上の数は少なくともover個ある
    ll not_pos = 0;
    ll neg = 0;
    ll A[N]; rep(i, N){ cin >> A[i]; if(A[i] <= 0) not_pos++; if(A[i] < 0) neg++;}
    sort(A, A+N);
    //非正整数はnot_pos*(N-not_pos)個ある
    ll ok, ng, m;
    //prod[M]を,昇順に積を並べたものとする (M = N(N-1)/2)
    //積がkey以上となるようなペアがK個以上ある -> ok = key
    if(K <= not_pos*(N-not_pos)){
        //答えは非正整数
        //A[0]からA[not_pos-1]までが非正整数
        ok = -1000000000000000000;
        ng = 1;
    }
    else{
        //答えは非負整数(0かもしれない. not_pos*(N-not_pos) <= (積が0以下となるペアの数))
        //ex) N = 4, K = 5, A = {-1, 0, 1, 2}のとき 2*2 <= 5
        ok = 0;
        ng = 1000000000000000001;
    }
    m = (ok+ng)/2;
    over *= 2;
    while(abs(ok-ng) > 1){
        ll acc = 0;
        //O(NlogN)でmを超すようなペアの数を数える
        //A[i] < 0 のとき ok2 = -1, ng2 = Nとして探索, ok2+1を足す (0 <= i <= ok2なら1引く)
        //A[i] = 0のとき m <= 0ならacc += N-1, m > 0ならpass
        //A[i] > 0のとき ok2 = N, ng2 = -1として探索, N-ok2を足す (ok2 <= i <= N-1なら1引く)
        rep(i, N){
            ll ok_2, ng_2, m_2;
            if(A[i] == 0){
                if(m <= 0) acc += N-1;
                continue;
            }
            else if(A[i] > 0){
                ok_2 = N; ng_2 = -1;
            }
            else{
                ok_2 = -1; ng_2 = N;
            }
            m_2 = ((ok_2 + ng_2) >> 1);
            while(abs(ok_2 - ng_2) > 1){
                if(A[i]*A[m_2] >= m) ok_2 = m_2;
                else ng_2 = m_2;
                m_2 = ((ok_2 + ng_2) >> 1);
            }
            if(A[i] < 0){
                if(i <= ok_2) acc--;
                acc += ok_2+1;
            }
            else{
                if(ok_2 <= i) acc--;
                acc += N-ok_2;
            }
        }
        //この手法は(A[i],A[j])と(A[j],A[i])を区別している(ダブルカウントしている)ので閾値はKでなく2Kになる
        //mを超えるペアの数がacc個ある
        //それがKより大きいなら,K
        if(acc >= over) ok = m;
        else ng = m;
        m = ((ok+ng) >> 1);
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
primes = {}
for p in map(int, '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97'.split()):
    primes[p] = 0
factors = {}
for p in primes.keys():
    factors[p] = 0
for i in range(1, N + 1):
    while i > 1:
        for p in primes:
            while i % p == 0:
                factors[p] = factors.get(p, 0)+1
                i //= p
fact3, fact5, fact15, fact25, fact75 = 0, 0, 0, 0, 0
for k, v in factors.items():
    if v >= 74:
        fact75 += 1
    if v >= 24:
        fact25 += 1
    if v >= 14:
        fact15 += 1
    if v >= 4:
        fact5 += 1
    if v >= 2:
        fact3 += 1
print(fact75 + fact25 * (fact3 - 1) + fact15 *
      (fact5 - 1) + fact5 * (fact5 - 1) * (fact3 - 2) // 2)


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1000000007;

int mod(int x){
	return x % MOD;
}

int main(void)
{
    IOS
    int n,l;cin >> n>>l;

    int ans = 0;
    if (l < 0 && n > -l) {
        FOR(i,l,l+n) ans += i;
    } else if (l>=0) {
        FOR(i,l+1,l+n) ans += i;
    } else {
        FOR(i,l,l+n-1) ans += i;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() { 
    long n; 
    cin>>n;
    long result[] = {0, 0, 0, 0};
    for (long i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        if(tmp=="AC"){
            result[0]++;
        }else if(tmp=="WA"){
            result[1]++;
        }else if(tmp=="TLE"){
            result[2]++;
        }else if(tmp=="RE"){
            result[3]++;
        }
    }

    cout << "AC x " << result[0] << endl;
    cout << "WA x " << result[1] << endl;
    cout << "TLE x " << result[2] << endl;
    cout << "RE x " << result[3] << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N=55,M=105,mod=1e9+7; 
int n,m,k,t,ti,x,y,ans=1;
int nxt[M<<1],head[N],adj[M<<1],dfn[N],low[N];
int top,sum,se[N],sv[N],scc[N],p[M<<1],ip[M<<1],inv[M<<1];
pair<int,int> s[N];
vector<int> g[N];
void push(int u,int v)
{
	nxt[++t]=head[u];
	head[u]=t;
	adj[t]=v;
}
void tarjan(int u,int fa)
{
	dfn[u]=low[u]=++ti;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=adj[i];
		if(v==fa)continue;
		if(!dfn[v])
		{
			s[++top]=make_pair(u,v);
			tarjan(v,u);
			low[u]=min(low[u],low[v]);
			if(dfn[u]<=low[v])
			{
				sum++;
				while(1)
				{
					int x=s[top].first,y=s[top].second;
					se[sum]++;
					if(scc[x]!=sum)scc[x]=sum,sv[sum]++,g[sum].push_back(x);
					if(scc[y]!=sum)scc[y]=sum,sv[sum]++,g[sum].push_back(y);
					top--;
					if(x==u && y==v)break;
				}
			}
		}
		else if(dfn[v]<dfn[u])s[++top]=make_pair(u,v),low[u]=min(low[u],dfn[v]);
	}
}
int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
int C(int n,int m){return 1ll*p[n]*ip[m]%mod*ip[n-m]%mod;}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x,&y),push(x,y),push(y,x);
	for(int i=1;i<=n;i++)
		if(!dfn[i])tarjan(i,0);
	p[0]=ip[0]=1;
	p[1]=ip[1]=inv[1]=1;
	for(int i=2;i<=m+k;i++)
	{
		p[i]=1ll*p[i-1]*i%mod;
		inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
		ip[i]=1ll*ip[i-1]*inv[i]%mod;
	}
	for(int i=1;i<=sum;i++)
	{
		if(se[i]==1)ans=1ll*ans*k%mod;
		else if(se[i]==sv[i])
		{
			int ss=0;
			for(int j=1;j<=se[i];j++)
				ss=(ss+ksm(k,__gcd(j,se[i])))%mod;
			ss=1ll*ss*inv[se[i]]%mod;
			ans=1ll*ans*ss%mod;
		}
		else ans=1ll*ans*C(se[i]+k-1,k-1)%mod;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
use proconio::input;

use std::cmp::*;
// use std::collections::*;
use proconio::marker::Chars;

fn main() {
    input! {
        h:usize,
        w:usize,
        C:[String;h]
    }
    for s in C {
        println!("{}\n{}", s, s);
    }
}


Measured memory_bytes: 2208
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cerr << i << " "; cerr << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	LL n, m; cin >> n >> m;
	VL a(n); rep(i, n)cin >> a[i];

	VL ru(n + 1);
	ru[0] = 0; rep(i, n)ru[i + 1] = ru[i] + a[i];

	map<LL, LL> ma;
	rep(i, n + 1) {
		ma[ru[i] % m]++;
	}

	LL ans = 0;
	for (auto p : ma) {
		ans += p.second*(p.second - 1) / 2;
	}
	Cout(ans);
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll a; cin >> a;
	long double b; cin >> b;
	ll ans=a*b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>


int main() {

    std::string S;
    std::cin >> S;

    std::vector<char> acceptable = {'A', 'C', 'G', 'T'};

    int m = 0;

    for (int i = 0; i < S.length(); ++i) {
        int cnt = 0;
        for (int j = i; j < S.length(); ++j) {
            bool ok = false;
            for (int k = 0; k < acceptable.size(); ++k) {
                if (S[j] == acceptable[k]) {
                    cnt += 1;
                    ok = true;
                }
            }
            if (!ok) {
                break;
            }
        }

        if (m < cnt) {
            m = cnt;
        }
    }

    std::cout << m << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val arr: Array[Int] = Array.fill(N)(sc.nextInt())

    var cnt = 0
    for((x, i) <- arr.zipWithIndex) {
      var minj = i
      for(j <- i until arr.length) {
        if(arr(minj) > arr(j)) minj = j
      }
      if(i != minj) cnt += 1
      val t = arr(i); arr(i) = arr(minj); arr(minj) = t  // swap
    }
    println(arr.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 45112
n,m=map(int,input().split())
l=[0]*(m+1)
for u in range(n):
    d=list(map(int,input().split()))
    for i in range(1,d[0]+1):
        l[d[i]]+=1
c=0
for i in range(1,m+1):
    if(l[i]==n):
        c=c+1
print(c)


Measured memory_bytes: 62340
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

int x[1001], n;
vector<int> child[1001];

int up[1001];
int dd[2][5001];

void dfs(int u) {
	if (child[u].empty()) {
		up[u] = 0;
		return;
	}
	for (int i = 0; i < child[u].size(); i++)
		dfs(child[u][i]);
	dd[1][0] = 0;
	int from = 1, to = 0;
	for (int i = 0; i < child[u].size(); i++) {
		int w1 = up[child[u][i]], w2 = x[child[u][i]];
		for (int j = 0; j <= x[u]; j++) {
			dd[to][j] = (1 << 29);
			if (j >= w1 && dd[to][j] > dd[from][j - w1] + w2) dd[to][j] = dd[from][j - w1] + w2;
			if (j >= w2 && dd[to][j] > dd[from][j - w2] + w1) dd[to][j] = dd[from][j - w2] + w1;
		}
		from ^= 1; to ^= 1;
	}
	int ret = (1 << 29);
	for (int j = 0; j <= x[u]; j++) if (dd[from][j] < ret) ret = dd[from][j];
	up[u] = ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		int p;
		scanf("%d", &p);
		child[p].push_back(i);
	}
	for (int i = 1; i <= n; i++)
		scanf("%d", &x[i]);
	dfs(1);
	if (up[1] == (1 << 29)) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())
a = list(map(int, input().split()))
mask = 1 << 40

while mask > k:
    mask >>= 1

x = 0
while True:
    bit_count = 0
    for aa in a:
        if aa & mask > 0:
            bit_count += 1
    if n > bit_count * 2 and x + mask <= k:
        x += mask
    if mask <= 1:
        break
    mask >>= 1

ans = 0
for aa in a:
    ans += aa ^ x
print(ans)


Measured memory_bytes: 14708
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
def dfs(N,X):
    # Lv.0
    if N == 0:
        # 調べる数が残っていれば : 1
        if X > 0:
            return 1
        # 残ってなければ : 0
        else:
            return 0
    # Lv.1以上
    else:
        # 下側の Lv.n-1 までの場合
        if X <= 1 + T[N-1]:
            return dfs(N-1,X-1)
        # 真ん中のパティまでの場合
        elif X == 1 + T[N-1] + 1:
            return P[N-1] + 1
        # 上側の Lv.n-1 までの場合
        else:
            return P[N-1] + 1 + dfs(N-1,X-2-T[N-1])

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,X = map(int,input().split())

# 事前計算
# T[i] : Lv i バーガーの層数
# P[i] : Lv i バーガーのパティ数
T,P = [0]*(N+1),[0]*(N+1)
T[0],P[0] = 1,1
for i in range(N):
    T[i+1] = T[i]*2 + 3
    P[i+1] = P[i]*2 + 1

print(dfs(N,X))

Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-


class UnionFind():
    """ UnionFindはグループの分割はできないことに注意 """
    def __init__(self, n):
        """
            n: 要素数
            parents: 親を示す、-1の場合、自身の親がいない(頂点)であることを示す
        """
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        親の要素が何かを調べる
        同じ要素であれば、同じグループに所属することを示す
        探索しながら、親を頂点につなぎ直すことで、効率的にまとめることができる
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        xとyの所属するグループをまとめる
        """
        x = self.find(x)
        y = self.find(y)

        # 同じ親だった場合、既にグループはまとまっているので処理を終了する
        if x == y:
            return

        # 浅い方を深い方に繋ぐようにする
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def most_depth_root(self):
        return -min(self.parents)


N, M = map(int, input().split())

union_find = UnionFind(N)
for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    union_find.union(x, y)

print(union_find.most_depth_root())

Measured memory_bytes: 79872
let m = 9999973

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let to_x = Array.make 128 0

let to_key s =
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(to_x.(Char.code s.[i]))) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  to_x.(Char.code 'A') <- 1;
  to_x.(Char.code 'C') <- 2;
  to_x.(Char.code 'G') <- 3;
  to_x.(Char.code 'T') <- 4;
  let n = read_int () in
  let t = Array.make m "\000" in
  let rec doit i =
    if i < n then begin
      begin match split (read_line ()) ' ' with
      | ["insert"; s] -> insert s t
      | ["find"; s] -> print_endline (if find s t then "yes" else "no")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 92056
#include<stdio.h>
int main(void){
    int a,b,c,ab,bc,ca;
    scanf("%d %d %d",&a,&b,&c);
    ab=a+b;
    bc=b+c;
    ca=c+a;
    if(ab<bc && ab<ca){
        printf("%d\n",ab);
    }else if(bc<ca){
        printf("%d\n",bc);
    }else{
        printf("%d\n",ca);
    }
    return 0;
}



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

int main(){
std :: string str;
int i, counter;
cin >> str;
counter = 0;
if(str.size() !=0){
    for(i = 0; i < str.size()-1;i++){
      if(str[i] !=str[i+1]){
        counter++;
        }
    }
}
cout << counter;
return 0;
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

const int VMAX = 100;

long long int dist[VMAX][VMAX];

void wf_run(int V) {
	for (int k = 0; k < V; ++k) {
		for (int i = 0; i < V; ++i) {
			if (dist[i][k] == INF) {
				continue;
			}
			for (int j = 0; j < V; ++j) {
				if (dist[k][j] == INF) {
					continue;
				}
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
}

bool has_negcycle(int V) {
    for (int i = 0; i < V; ++i) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}
void init(int V) {
    for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
            dist[i][j] = (i == j ? 0 : INF);
        }
    }
}

signed main() {
	string s;
	cin >> s;
	for (size_t i = 0; i < s.size(); i++) {
		if (s[i] == ',') {
			s[i] = ' ';
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 256
n,k,q=map(int,input().split())
arr=list(map(int,input().split()))
ans=10**18
for val in arr:
  tmp=[]
  vals=[]
  for i in range(n):
    if arr[i]>=val:
      tmp.append(arr[i])
    else:
      if len(tmp)>=k:
        tmp=sorted(tmp)
        vals.extend(tmp[:len(tmp)-k+1])
      tmp=[]
  if len(tmp)>=k:
    tmp=sorted(tmp)
    vals.extend(tmp[:len(tmp)-k+1])
  if len(vals)<q:
    continue
  else:
    vals=sorted(vals)
    ans=min(ans,vals[q-1]-vals[0])
print(ans)

Measured memory_bytes: 3188
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn consume_num(target: u64,num: u64) -> u64 {
    if target <= num {return 1};
    if target % num != 0 {
        target / num + 1
    } else {
        target / num
    }
}

fn main() {
    input!(
        n: u64,
        a: u64,
        b: u64,
        c: u64,
        d: u64,
        e: u64,
    );

    let min = vec![a,b,c,d,e].iter().fold(a,|acm,current| if acm < *current {acm} else {*current});
    let (count,_) = vec![a,b,c,d,e].iter().fold((0,0),|(count,delay),current| {
            let count = count + consume_num(n - (count - delay) * min,*current);
            (count,delay + 1)
        }
    );
    println!("{:?}",count);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    int n,i,co = 0;
    char s[100];
    scanf("%d", &n);
    scanf("%s", s);
    for(i = 0;i < n;i ++){
        if(s[i] == 'A'){
            if(s[i + 1] == 'B'){
                if(s[i + 2] == 'C'){
                    co ++;
                }
            }
        }
    }
    printf("%d\n", co);
    return 0;
}

Measured memory_bytes: 128
/**OOO**/
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mems(x,y) memset(x,y,sizeof(x))
#define pf printf
#define sc scanf
using namespace std;


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

    ll n,y,a,b,c;
    cin>>n>>y;

    if(y%10000==0 && y/10000==n)cout<<y/10000<<" "<<0<<" "<<0<<endl;
    else if(y%5000==0 && y/5000==n)cout<<0<<" "<<y/5000<<" "<<0<<endl;
    else if(y%1000==0 && y/1000==n)cout<<0<<" "<<0<<" "<<y/1000<<endl;
    else{

        for(int i=0;i<=n;i++){
            a=10000*i;
            for(int j=0;j<=n-i;j++){
                b=5000*j;
                for(int k=0;k<=n-i-j;k++){
                    c=1000*k;
                    if(a+b+c==y && i+j+k==n){
                        cout<<i<<" "<<j<<" "<<k<<endl;
                        return 0;
                    }
                }
            }
        }
        cout<<-1<<" "<<-1<<" "<<-1<<endl;
    }

return 0;
}


Measured memory_bytes: 256