akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
vector<vector<pi > > F;
vector<vector<pi > > B;
struct UnionFind{
    //ご本体
    vector<ll > tree;
    //高さ
    vector<ll > rank;
    //グループごとのサイズ
    vector<ll > size;
 
    //定義
    UnionFind(ll N) : tree(N), rank(N), size(N){
        for(int i = 0; i < N; i++){
            tree[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
 
    //どの根っこに属しているのか？さかのぼり続ける
    int root(int x){
        if(tree[x] == x){
            return x;
        }
        //経路圧縮
        return tree[x] = root(tree[x]);
    }
 
    //木と木を(高さが低い方に)くっつける
    ll unite(int x, int y){
        int tx = root(x);
        int ty = root(y);
        //xとyの根が同じならくっつけない
        if(tx == ty){
            return 0;
        }
        
        ll s = size[tx] + size[ty];
        ll r = size[tx] * size[ty];
        size[tx] = s;
        size[ty] = s;
 
        //tree[tx] = ty;
        //高くない方にくっつけたい：効果がいまいちわからん
        //下：ランク付けのつもり 
        if(rank[tx] < rank[ty]){
            //小さい方を大きい方
            //txの根が大きい方の根に更新
            tree[tx] = ty; 
        }else{
            tree[ty] = tx;
            //つなげるときに同じ高さだったらつなげた後に高さを＋１する
            if(rank[tx] == rank[ty]){
                rank[tx]++;
            }
        }
 
        return r;
 
    }
 
    //同じ木に属しているか？根っこをさかのぼって調べてみる
    bool same(int x, int y){
        int tx = root(x);
        int ty = root(y);
        if(tx == ty){
            return true;
        }else{
            return false;
        }
    }
    //グループのサイズを返す
    int FindSize(int x){
        return size[root(x)];
    }
 
};
 
int main(){
 
    ll N, M;
    cin >> N >> M;
    //初期化
    UnionFind G(N);

 
    //友達関係
    for(ll i = 0; i < M; i++){
        ll u, v, z;
        ll w = 0;
        cin >> u >> v >> z;
        u--;
        v--;
        G.unite(u, v);
    }

    map<ll, ll> mp;
    for(ll i = 0; i < N; i++){
        mp[G.root(i)]++;
    }

    cout << mp.size() << endl;
 
}

Measured memory_bytes: 8832
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer
import scala.util.control.Breaks
import scala.math.abs

object Main extends App {

  val sc = new Scanner(System.in)
  val a, b, c, k = sc.nextLong()

  val res = (if (a >= k) {
    k
  } else if (a + b >= k) {
    a
  } else {
    a * 1 + ((k - a - b) * -1)
  })

  println(res)
}


Measured memory_bytes: 55312
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B;
    if (A + B >= 10)
        cout << "error" << endl;
    else
        cout << A + B << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<string> s(N, "kkkkkkkkkk");
    for(int i=0; i<N; i++){
        vector<char> m(10);
        for(int k=0; k<10; k++){
        cin >> m[k];
        }
        sort(m.begin(), m.end());
        for(int j=0; j<10; j++){
        s[i][j] = m[j];
        }
    }
    sort(s.begin(), s.end());
    long long int c = 0;
    long long int h = 0;
    for(int i=0; i<N-1; i++){
        if(s[i] == s[i+1]){
            h++;
            if(i == N-2){
                c += h*(h+1)/2;
            }
        }
        else{
            c += h*(h+1)/2;
            h=0;
        }
    }
    cout << c;
}

Measured memory_bytes: 5760
#include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
const int INF=1000000;
int H,W,N,d[1000][1000],ans=0;
int dx[]={-1,0,0,1};
int dy[]={0,-1,1,0};
char m[1000][1000];
pair<int,int> f[11];
int bfs(int sx,int sy,int gx,int gy){
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)d[j][i]=INF;
	queue<P> que;
	que.push(P(sx,sy));
	d[sx][sy]=0;
	while(!que.empty()){
		P p=que.front();que.pop();
		if(p==P(gx,gy))break;
		for(int j=0;j<4;j++){
			int nx=p.first+dx[j];
			int ny=p.second+dy[j];
			if(0<=nx&&nx<W&&0<=ny&&ny<H&&m[nx][ny]!='X'&&d[nx][ny]==INF){
				que.push(P(nx,ny));
				d[nx][ny]=d[p.first][p.second]+1;
			}
		}
	}
	return d[gx][gy];
}
int main()
{
    cin>>H>>W>>N;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++){
			cin>>m[j][i];
			int num=m[j][i]-'0';
			if(m[j][i]=='S')f[0]=P(j,i);
			else if(0<num&&num<=N)f[num]=P(j,i);
		}
	for(int i=0;i<N;i++){
		ans+=bfs(f[i].first,f[i].second,f[i+1].first,f[i+1].second);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6100
#include <iostream>
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
//vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
//vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};

vector<ll> change(string S){
  vector<ll> res;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == '['){
      res.pb(-1);
      continue;
    }
    if(S[i] == ']'){
      res.pb(-2);
      continue;
    }
    int j = i;
    while(S[j+1] != '[' && S[j+1] != ']'){
      j++;
    }
    ll x = 0;
    for(int k = i; k <= j; k++){
      x = x * 10 + S[k] - '0';
    }
    res.pb(x);
    i = j;
  }
  return res;
}


ll solve(vector<ll> T, int first, int end){//[first, end)
  if(end - first == 3){
    return T[first + 1] / 2 + 1;
  }
  vector<ll> xs;
  int s = first + 1;
  int cnt1 = 0, cnt2 = 0;
  for(int i = first+1; i < end-1; i++){
    if(T[i] != -1 && T[i] != -2) continue;
    if(T[i] == -1) cnt1 ++;
    if(T[i] == -2) cnt2 ++;
    if(cnt1 == cnt2){
      xs.pb(solve(T, s, i+1));
      s = i + 1;
    }
  }
  sort(xs.begin(), xs.end());
  ll res = 0;
  rep(i, xs.size() / 2 + 1){
    res += xs[i];
  }
  return res;







}

int main(){
  int N; cin >> N;
  rep(i, N){
    string S; cin >> S;
    vector<ll> T = change(S);
    cout << solve(T, 0, T.size()) << endl;
  }
}



Measured memory_bytes: 3744
H,W,K = map(int,input().split())
Cake = []
for i in range(H):
  temp = str(input())
  temp = list(temp)
  Cake.append(temp)
#print(Cake)

n = 0 #ケーキの番号
ans = [[0]*W for _ in range(H)]
rem = set([])
for i in range(H):
  row = set(Cake[i])
  if "#" not in row: #この列にイチゴがない。
    if i == 0 or i-1 in rem:
      rem.add(i) #上もない。
    else:
      ans[i] = ans[i-1]
  else:
    n += 1
    Flag = True #Trueの間は一個目のイチゴ
    for j in range(W):
      if Flag and Cake[i][j] == "#":
        ans[i][j] = str(n)
        Flag = False
      elif Cake[i][j] == "#":
        n += 1
        ans[i][j] = str(n)
      else:
        ans[i][j] = str(n)
    if rem:
      for t in rem:
        ans[t] = ans[i]
      rem = set([])
#print(ans)
for t in range(H):
  temp = " ".join(ans[t])
  print(temp)
#print(" ".join(ans[i]) for i in range(H))  

Measured memory_bytes: 78232
import heapq as hq
n,m=map(int,input().split())
a=[-int(x) for x in input().split()]
hq.heapify(a)
for i in range(m):
    x=hq.heappop(a)
    x=-x//2
    hq.heappush(a,-x)
 
print(sum(a)*-1)


Measured memory_bytes: 14180
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  vector<pair<ll,ll>> a;
  for(int i=0;i<n;i++){
    ll b;
    cin >>b;
    a.push_back(make_pair(b,i+1));
  }

  sort(a.begin(),a.end());
  for(int i=1;i<n+1;i++){
    if(a[n-1].second==i)cout << a[n-2].first << endl;
    else cout << a[n-1].first << endl;
  }

}

Measured memory_bytes: 7436
$N = gets.to_i
$MOD = 10 ** 9 + 7
$memo = Array.new($N+1) { {} }

def ok(last4)
  4.times do |i|
    t = last4.split(//)
    t[i - 1], t[i] = t[i], t[i - 1] if i >= 1
    return false unless t.join.index('AGC').nil?
  end

  true
end

def dfs(cur, last3)
  return $memo[cur][last3] if $memo[cur].key? last3
  return 1 if cur == $N

  ret = 0
  'ACGT'.each_char do |c|
    if ok(last3 + c)
      ret = (ret + dfs(cur + 1, last3[1..4] + c)) % $MOD
    end
    $memo[cur][last3] = ret
  end
  ret
end


puts dfs(0, 'TTT')

Measured memory_bytes: 4860
//abc177_b.cpp
//Sat Aug 29 20:53:36 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	int ans = INTINF;
	rep(i,s.length()-t.length()+1){
		int tmp = 0;
		rep(j,t.length()){
			if(s[i+j]!=t[j]){
				tmp++;
			}
		}
		ans = min(ans,tmp);
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#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/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	constexpr auto pi = 3.14159265358979;
	double R;
	std::cin >> R;
	std::cout << 2 * R * pi << std::endl;
}

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

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

int main() {
  int N, M; cin >> N >> M;
  vector<vector<long long>> A(N, vector<long long>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) cin >> A.at(i).at(j);
  }
  long long ans = -(1LL << 60);
  for (int i = 0; i < (1 << 3); i++) {
    bitset<3> s(i);
    vector<long long> v;
    for (int j = 0; j < N; j++) {
      long long tmp = 0;
      for (int k = 0; k < 3; k++) {
        if (s.test(k)) tmp += A.at(j).at(k);
        else tmp -= A.at(j).at(k);
      }
      v.push_back(tmp);
    }
    sort(v.begin(), v.end(), greater<long long>());
    long long S = 0;
    for (int j = 0; j < M; j++) S += v.at(j);
    ans = max(ans, S);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,l = map(int, input().split())
As = list(map(int, input().split()))
# 和がl以上のものがあれば、それを残してあとを端から落としていくのでよい
ss = [As[i]+As[i+1] for i in range(n-1)]
# print(ss)
cnt = 0
for i,s in enumerate(ss):
    if s >= l:
        cnt = i + 1
if cnt == 0:
    print("Impossible")
    exit()
print("Possible")
for i in range(1,cnt):
    print(i)
for i in range(n-1, cnt, -1):
    print(i)
print(cnt)

Measured memory_bytes: 19932
n = int(input())
a = list(map(int, input().split()))

c = {}

for i in a:
    c[i] = c.get(i, 0) + 1

ways = 0
for i in c:
    ways += c[i]*(c[i]-1)//2

for k in a:
    ans = ways-c[k]+1
    print(ans)


Measured memory_bytes: 24748
from collections import defaultdict, deque

n, k = map(int, input().split())
a = tuple(map(int, input().split()))
acc = [0]
t = 0
for a_ in a:
    t = (t + a_ - 1) % k
    acc.append(t)

d = defaultdict(int)

ret = 0
count = 0
dq = deque()

for acc_ in acc:
    ret += d[acc_]
    d[acc_] += 1
    dq.append(acc_)
    if len(dq) >= k:
        v = dq.popleft()
        d[v] -= 1
print(ret)


Measured memory_bytes: 122240
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int n;
	std::cin >> n;
	V<std::pair<lnt,lnt> > g,h;
	rep(i,n) {
		int x,y;
		std::cin >> x >> y;
		g.emplace_back(x,y);
	}
	h=g;
	std::sort(all(g),[](std::pair<lnt,lnt> a, std::pair<lnt,lnt> b) {
			return a.first+a.second<b.first+b.second;
			});
	std::sort(all(h),[](std::pair<lnt,lnt> a, std::pair<lnt,lnt> b) {
			return a.first-a.second<b.first-b.second;
			});
	auto diff=[](lnt a, lnt b, lnt c, lnt d) -> lnt {
		return std::abs(a-c)+std::abs(b-d);
	};
	print(std::max(diff(g[0].first,g[0].second,g[n-1].first,g[n-1].second),
				diff(h[0].first,h[0].second,h[n-1].first,h[n-1].second)));
}


Measured memory_bytes: 9508
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d,e,f,l;
int main(){
	cin>>l>>a>>b>>c>>d;
	e=(a+c-1)/c;
	f=(b+d-1)/d;
	cout<<l-max(e,f)<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
void call(int n) {
  int i = 1;
CHECK_NUM:
  int x = i;
  if (x % 3 == 0) {
    cout << " " << i;
    goto END_CHECK_NUM;
  }
INCLUDE3:
  if (x % 10 == 3) {
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if (x) goto INCLUDE3;
END_CHECK_NUM:
  if (++i <= n) goto CHECK_NUM;

  cout << endl;
}
int main() {
  int n;
  cin >> n;
  call(n);
  return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <bitset>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    int cnt[3]={0};
    int i;
    for(i=0; i<n; i++) {
        cnt[str[i]-'a']++;
    }
    sort(cnt+0, cnt+3);
    if(cnt[2]-cnt[0]<=1) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int IN = 1000005;
constexpr int INF = 1e9+5;
constexpr int INI = -1;


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    bool current=0, last1=0, last2=0;
    string ans = "No";
    while(n--){
        int a, b;
        cin >> a >> b;
        if(a == b)
            current = 1;
        else
            current = 0;
        if(current == 1 && last1 == 1 && last2 == 1){
            ans = "Yes";
        }
        last2 = last1;
        last1 = current;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;
long long dpw[MAXN];
long long dpb[MAXN];
vector<int> adj[MAXN];

void dfs(int v, int p = -1){
    dpw[v] = dpb[v] = 1;
    for(int i = 0; i < adj[v].size(); i++){
        int u = adj[v][i];
        if(u != p){
            dfs(u, v);
            dpw[v] = ((dpw[u] + dpb[u]) * dpw[v]) % mod;
            dpb[v] = (dpb[v] * dpw[u]) % mod;
        }
    }
}

int main()
{
    int n;
    cin >> n;
    int u, v;
    for(int i = 0; i < n - 1; i++){
        cin >> u >> v;
        adj[v].push_back(u);
        adj[u].push_back(v);
    }
    dfs(1);
    cout << (dpb[1] + dpw[1]) % mod;
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N;
string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> S;

    map<pair<string, string>, int> cnt;
    rep(msk, 0, 1 << N) {
        string a = "";
        string b = "";
        rep(i, 0, N) {
            if (msk & (1 << i)) a += S[i + N];
            else b += S[i + N];
        }
        cnt[{a, b}]++;
    }

    ll ans = 0;
    rep(msk, 0, 1 << N) {
        string a = "";
        string b = "";
        rep(i, 0, N) {
            if (msk & (1 << i)) a = S[i] + a;
            else b = S[i] + b;
        }
        ans += cnt[{b, a}];
    }
    cout << ans << endl;
}


Measured memory_bytes: 87040
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int r,d,x,a[18];
main(){
    cin>>r>>d>>x;
    a[0]=x;
    for(int i=0;i<10;i++){
        a[i+1]=r*a[i]-d;
        cout<<r*a[i]-d<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
	long long int n,k;
	cin>>n>>k;
	long long int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	vector<long long int> perm;
	for(int i=0;i<n;i++)
	{
		long long int sume=0;
		for(int j=i;j<n;j++)
		{
			sume+=a[j];
			perm.push_back(sume);
		}
	}


	long long int finale = 0;
	for(int i=60;i>=0;i--)
	{
		vector<long long int > temper;
		for(int j=0;j<perm.size();j++)
		{
			if((1LL<<i) & perm[j])
			{
				temper.push_back(perm[j]);
			}
		}
		if(temper.size()>=k)
		{
			perm = temper;
			finale^=(1LL<<i);
		}
	}
	cout<<finale;
	return 0 ;
}


Measured memory_bytes: 6512
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String S = sc.next();

   boolean flg = false;
   int count = 0;
   if(S.charAt(0)!='A') flg = true;
   if(S.charAt(1)=='C') flg = true;
   if(S.charAt(S.length()-1)=='C') flg = true;
   for(int i = 1;i<S.length();i++)
   {
     if(flg) break;
     if(S.charAt(i)=='C') count++;
     else if(Character.isUpperCase(S.charAt(i)))
     {
       flg = true;
     }
   }

   if(count>=2 || count == 0) flg = true;
   
   if(flg) System.out.println("WA");
   else System.out.println("AC");
 }
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
#include <iomanip>
 
#ifdef LOCAL_CODE
	#define DEBUG(x) cerr << "[" << #x << '=' << x << "]" << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int i = (N)-1; i >= 0; i--)
#define REP(i, N) for(int i = 0; i < (int)(N); i++)
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.first >> p.second; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.first << ' ' << p.second; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int n,m;
void solve(istream& cin, ostream& cout) {
	cin >> n;
	int d = n%10;
	set<int> A = {2,4,5,7,9};
	set<int> B = {0,1,6,8};
	if(A.count(d)) cout << "hon";
	else if(B.count(d)) cout << "pon";
	else cout <<"bon";
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define cin std::ios::sync_with_stdio(false);cin
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)
	cout<<"YES"<<endl;
	else 
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define ll long long
using namespace std;
template<typename T> void read(T &x){
	char c=getchar();x=0;int f=1;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;
}
const int N=2e5+7;
ll b,w,n,f[N],g[N],jc[N],inv[N];
ll po(ll x,ll y){
	ll t=1,tt=x;
	while(y){
		if(y&1)t=t*tt%mo;
		tt=tt*tt%mo;y>>=1;
	}return t;
}
void pre(){
	jc[0]=inv[0]=jc[1]=inv[1]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	for(int i=2;i<=n;i++)inv[i]=(mo-mo/i)*inv[mo%i]%mo;
	for(int i=2;i<=n;i++)inv[i]=inv[i-1]*inv[i]%mo;
}
ll c(ll x,ll y){
	if(x<y)return 0;
	return jc[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	read(b);read(w);n=b+w;pre();
	for(int i=1;i<n;i++){
		f[i]=(f[i-1]+c(i-1,b-1)*po(po(2,i),mo-2))%mo;
		g[i]=(g[i-1]+c(i-1,w-1)*po(po(2,i),mo-2))%mo;
	}
	for(int i=1;i<=n;i++)cout<<(1+g[i-1]-f[i-1]+mo)%mo*po(2,mo-2)%mo<<endl;
	return 0;
}

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

using namespace std;


int main(void)
{
	/*
	int a;
	cin>>a;
	
	cout<<"a = "<<a<<endl;
	cout<<"\n"<<endl;
	
	cout<<"--------pre---------"<<endl;
	int i,max;
	max = 100;
	for(i = 0; i < a; i++){
		cout<<"i = "<<i<<endl;
	}
	
	cout<<"-------end----------"<<"\n"<<endl;
	for(i = a; i < max; i++){
		cout<<"i = "<<i<<endl;
	}
	*/
	int k,x;
	cin>>k>>x;
	if(k*500 >= x){
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}




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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string O, E;
    cin >> O;
    cin >> E;

    int N = O.size();

    for(int i = 0; i < N - 1; i++) cout << O[i] << E[i];

    if (N==E.size()) cout << O[N-1] << E[N-1] << endl;
    else cout << O[N-1] << endl;

    return 0;
}

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

const int mo=998244353;
string s;
map <string,int> f,g;

int calcf(string s);
int calcg(string s);

int calcf(string s)
{
	if (s.length()==1)  return s[0]=='0'?1:2;
	if (f.find(s)!=f.end())  return f[s];
	int sum=calcg(s);
	for (int i=1; i<s.length(); i++)
		(sum+=1LL*calcg(s.substr(0,i))*calcf(s.substr(i,s.length()-i))%mo)%=mo;
	return f[s]=sum;
}

int calcg(string s)
{
	if (s.length()==1)  return s[0]=='0'?1:2;
	if (g.find(s)!=g.end())  return g[s];
	int sum=0;
	for (int i=1; i<s.length(); i++)
		if (s.length()%i==0)
			{
				string s2=s.substr(0,i);
				for (int j=0; j<s.length(); j++)
					if (s[j]=='0')  s2[j%i]='0';
				(sum+=calcf(s2))%=mo;
			}
	return g[s]=sum;
}

void work()
{
	cin>>s;
	cout<<calcf(s);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    if(a != 1 && b != 1) OUT(1);
    else if(a != 2 && b != 2) OUT(2);
    else OUT(3);

    return 0;
}

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

typedef long long ll;

const ll INTEG = pow(10,9) + 7;

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> L(N);

  for(int &i:L)
    cin >> i;

  int sum_ = 0;
  int index = N + 1;

  for(int i = 0; i < N; i++){
    sum_ += L[i];
    if(sum_ > X){
      index = i + 1;
      break;
    }
  }

  cout <<index<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

const int MAXN=305;
int n;
char a[MAXN][MAXN],b[MAXN<<1][MAXN<<1],c[MAXN<<1][MAXN<<1];

namespace solve1{
	inline void prepare(){
		for(int i=0;i<n;++i){
			memcpy(b[i],a[i],n);
			memcpy(b[i]+n,b[i],n);
		}
		for(int i=0;i<n;++i)
			memcpy(b[n+i],b[i],n<<1);
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j)
				c[j][i]=a[i][j];
		}
		for(int i=0;i<n;++i)
			memcpy(c[i]+n,c[i],n);
		for(int i=0;i<n;++i)
			memcpy(c[n+i],c[i],n<<1);
	}

	inline bool check(int x,int y){
		for(int i=0;i<n;++i){
			if(memcmp(c[i+y]+x,b[i+x]+y,n)!=0)
				return false;
		}
		return true;
	}

	inline int solve(){
		prepare();
		int ret=0;
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j)
				ret+=check(i,j);
		}
		return ret;
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%s",a[i]);
	printf("%d",solve1::solve());
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
T,A=map(int,input().split())
H = list(map(int,input().split()))
minn = 10**5
min_num=0

for i in range(len(H)):
    if abs(A-(T-H[i]*0.006))<=minn:
        minn = abs(A-(T-H[i]*0.006))
        min_num = i+1
print(min_num)

Measured memory_bytes: 62592
def find(A,x) -> int:
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a

def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx
def examD():
    N = I()
    x = [[] for _ in range(N)]; y = [[] for _ in range(N)]
    for i in range(N):
        a, b = LI()
        x[i] = (a-1,i)
        y[i] = (b-1,i)
    v = [ i for i in range(N)]
    x.sort(); y.sort()
    H = []
    heapify(H)
    for i in range(N - 1):
        x1, j1 = x[i]
        x2, j2 = x[i + 1]
        y1, k1 = y[i]
        y2, k2 = y[i + 1]
        heappush(H, (x2 - x1, j1, j2))
        heappush(H, (y2 - y1, k1, k2))
    ans = 0
#    print(H)
#    print(v)
    while H:
        w, s, t = heappop(H)
        if find(v, s) != find(v, t):
            union(v, s, t)
            ans += w
    print(ans)

import sys
import copy
import bisect
from heapq import *
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 53904
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string S; cin >> S;
    int ans = 753;
    rep(i, S.size() - 2) {
        int A=0;
        rep(j, 3)A += pow(10, 2-j) * (S.at(i + j)-48);
        ans = min(ans, abs(753-A));
    }
    cout << ans << endl;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    string s;
    cin >> s;
    vector<int> count(3, 0);
    for (char c : s) count[c - 'a']++;
    sort(count.rbegin(), count.rend());
    if (count.front() - count.back() <= 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}



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

int main() {

  string input;

  int cnt = 0;

  while( getline( cin, input ) ) {

    bool flag = true;
    for ( int i = 0; i < (input.size()+1)/2; i++ ) {
      if ( input[i] != input[ input.size()-1-i ] ) {
	flag = false;
	break;
      }
    }

    if ( flag ) cnt++;

  }

  cout << cnt << endl;

  return 0;

}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	long long  min = 9223372036854775800;
	
	for (int i = 1; i <= sqrt(n); i++) {
		
		if (n % i == 0) {
			long long  k;
			k = n / i;

			if (((i - 1) + (k - 1) < min))  min = (i - 1) + (k - 1);
			//cout << (i - 1) << " " << (k - 1) << endl;
		}
	}

	cout << min << endl;

	
}



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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
char arr[305][305];
map<int, int> mpr;
map<int, int >mpc;
int ans[305][305];
int main()
{
	int h, w, k;
	cin>>h>>w>>k;
	int curr = 1;
	vector<int> r;
	repn(i, 1, h)
	{
		bool f = true;
		repn(j, 1, w)
		{
			cin>>arr[i][j];
			if(arr[i][j] == '#') 
			{
				mpr[i]++;
				if(f)
				{
					r.pb(i);
					f = false;
				}
				ans[i][j] = curr;
				curr++;
				mpc[j]++;
			}
		}
	}
	curr = 1;
	for(int i: r)
	{
		repn(j, 1, w)
		{
			if(ans[i][j] == 0) ans[i][j] = curr;
			else curr = ans[i][j];
		}
		curr++;
	}
	repn(i, 1, h)
	{
		ll cnt = mpr[i];
		if(cnt == 0)
		{
			auto itr = lower_bound(all(r), i);
			if(itr == r.end()) itr--;
			int k = *itr;
			repn(j, 1, w)
			{
				ans[i][j] = ans[k][j];
			}
		}
	}
	repn(i, 1, h)
	{
		repn(j, 1, w)
			cout<<ans[i][j]<<" ";
		cout<<endl;
	}

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
int main()
{
    string s;
    cin >> s;
    if(s.size() == 2){
        cout << s;
    }
    else {
        reverse(s.begin(), s.end());
        cout << s;
    }
    return 0;
}


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

int main() {
  int n; cin>>n;
  long long X[10][10]={};
  rep(i, 1, n+1) X[i%10][to_string(i)[0]-'0']++;
  long long res=0;
  rep(i, 1, 10) {
    rep(j, 1, 10) {
      res+=X[i][j]*X[j][i];
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
      int ans=i*1.08;
    if(ans==n){
      cout<<i<<endl;
      return(0);
    }
    }
      cout<<":("<<endl;

    return(0);
}

Measured memory_bytes: 256
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
    ll N;
    ll ans = 0;
    cin >> N;
    ll A[N+1];
    ll B[N];
    rep(i,N+1)cin >> A[i];
    rep(i,N)cin >> B[i];
    rep(i,N){
        if(A[i] >= B[i])ans += B[i];
        else{
            if(A[i+1]-B[i]+A[i] >= 0){
                A[i+1] -= B[i]-A[i];
                ans += B[i];
            }else{
                ans += A[i]+A[i+1];
                A[i+1] = 0;
            }

        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
//by Sshwy
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
int pw(int a,int m,int p){
    int res=1;
    while(m)m&1?res=1ll*res*a%p:0,a=1ll*a*a%p,m>>=1;
    return res;
}
const int N=3005;

int n,P;
int c[N][N],s[N][N];

int sig(int x){return 1-2*(x&1);}

int main(){
    cin>>n>>P;
    s[0][0]=c[0][0]=1;
    FOR(i,1,n+1){
        c[i][0]=1;
        FOR(j,1,i){
            c[i][j]=(c[i-1][j-1]+c[i-1][j])%P;
            s[i][j]=(1ll*s[i-1][j]*j%P+s[i-1][j-1])%P;
            //printf("s[%d,%d]=%d\n",i,j,s[i][j]);
            //printf("c[%d,%d]=%d\n",i,j,c[i][j]);
        }
    }

    int ans=0;
    FOR(i,0,n){
        int x=0;
        FOR(k,0,i){
            x=(x+pw(pw(2,n-i,P),k,P)*1ll*s[i+1][k+1]%P)%P;
        }
        x=1ll*x*pw(2,pw(2,n-i,P-1),P)%P*sig(i)*c[n][i]%P;
        //printf("i=%d,x=%d\n",i,x);
        x=(x+P)%P;
        ans=(ans+x)%P;
    }

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


Measured memory_bytes: 69504
s=input()
ans=0
p=0
for i in range(len(s)):
    if s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C':
        p+=1
    else:
        ans=max(ans,p)
        p=0
ans=max(ans,p)
print(ans)

Measured memory_bytes: 38384
use num_integer::lcm;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        t: [usize; n],
    }
    let mut ans = 1;
    for &i in t.iter() {
        ans = lcm(ans, i);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
#include<stdio.h>
int main()
{ 
  int a,b,c,d,e,pos=0;
 scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
 if(a==0)
    printf("1\n");
    else if(b==0)
    printf("2\n");
    else if(c==0)
    printf("3\n");
    else if(d==0)
    printf("4\n");
    else if(e==0)
    printf("5\n");
    
        
    return 0;
    }
 



Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
int main(){
    #define int long long 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(10);
    cout << fixed;
    int a, b, c;
    cin >> c >> a >> b;
    if((b - a )%2 == 0)cout << (b-a)/2 << '\n';
    else {
        //cout << min(c-a,b-1) << '\n';
        //a-1, 1, przez 2;
        int op1 = 0;
        {
            int opa = a, opb = b; 
            opa = 1;
            opb -= a;
            op1 = a;
            op1 += (opb-opa)/2; 
        }
        int op2 = 0;
        {
            int opa = a, opb = b; 
            opa = a + (c-b) + 1;
            opb = c;
            op2 = c-b+1;
            op2 += (opb-opa)/2; 
        }
        cout << min(op1,op2) << '\n';
    }
    //sort(a.begin(), a.end());
    //random_shuffle(a.begin(), a.end());
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll E = C * D / __gcd(C,D);
    ll r = B - (B/C + B/D  - B/E);
    A--;
    ll l = A - (A/C + A/D - A/E);
    cout << r - l << endl;
}


Measured memory_bytes: 256
from itertools import groupby

s = input()
k = int(input())
a = [sum(1 for _ in g) for _, g in groupby(s)]
if len(a) == 1:
  print(len(s) * k // 2)
else:
  ans = sum(x // 2 for x in a) * k
  if s[0] == s[-1] and a[0] & a[-1] & 1:
    ans += k - 1
  print(ans)


Measured memory_bytes: 3060
a,b,c=map(int,input().split())
d=max(a,b,c)
if a%2==0 or b%2==0 or c%2==0:
  print(0)
elif a%2==1 and b%2==1 and c%2==1 and d==a:
  print(b*c)
elif a%2==1 and b%2==1 and c%2==1 and d==b:
  print(a*c)
elif a%2==1 and b%2==1 and c%2==1 and d==c:
  print(b*a)

Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
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};

int main(){
  int in1=1e9, in2=0;
  string s;
  cin >> s;
  rep(i,0,s.size()){
    if(s[i] == 'A'){
      in1 = min(in1, i);
    }
    if(s[i] == 'Z'){
      in2 = max(in2, i);
    }

  }
  cout << in2-in1+1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N; cin >>N;
  cout <<180*(N-2) <<endl;
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
  cin >> N;
  vector<llong> L(N);
  for(int i=0; i<N; ++i) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  for(int i=0; i<N-2; ++i){
    for(int j=i+1; j<N-1; ++j){
      if(L[i]==L[j]) continue;;
      for(int k=j+1; k<N; ++k){
        if(L[j]==L[k]) continue;
        if(L[k]<L[i]+L[j]) ++ans;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll n,m;
    cin>>n>>m;
    vl a(n);
    vl b(n);
    REP(i,n){
        cin>>a[i]>>b[i];
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    ll ans=(m+a[0]-1)/a[0];
    ll now=0;
    REP(i,n){
        now+=b[i];
        chmin(ans,i+1+max(0LL,(m-now+a[0]-1))/a[0]);
    }
    cout<<ans<<endl;;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    string s1, s2, u;
    int n1, n2;
    cin >> s1 >> s2 >> n1 >> n2 >> u;
    if(u == s1)n1--;
    if(u == s2)n2--;
    cout << n1 << " " << n2 << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
using namespace std;


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

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

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

int main(){
	string s;
	cin >> s;
	vector<string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	rep(i, day.size()){
		if(s == day[i]){
			cout << 7 - i << endl;
		}
	}


}

Measured memory_bytes: 256