akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>

using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

void precalc() {}

//#define solvsh
//#define multi

#ifdef solvsh

void solve() {

}

#else
typedef vector<int> vi;
#define INF 0x3f3f3f3f
#define FOR(i, n) for(int i = 0; i < n; i++)
template<class T>
T rnd(T l,T r){	//[l,r)
    using D = uniform_int_distribution<T>;
    static random_device rd;
    static mt19937 gen(rd());
    return D(l,r-1)(gen);
}
const int MAXN = 90;

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

    cout << (n + 1)/2;
}

#endif


void multisolve() {
    int t;
    cin >> t;

    while (t--)
        solve();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);
    precalc();

#ifdef multi
    multisolve();
#else
    solve();
#endif

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("2 3");
            WillReturn.Add("1 1");
            WillReturn.Add("3 2");
            //10
            //二人の得票数が 2,3 -> 3,3 -> 6,4 と動くと
            //投票数は10になって、これが最小値です。
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("1 1");
            WillReturn.Add("1 1");
            WillReturn.Add("1 5");
            WillReturn.Add("1 100");
            //101
            //一度画面を見てからもう一度画面を見るまでに
            //一票も入ってないことがありえます。
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5");
            WillReturn.Add("3 10");
            WillReturn.Add("48 17");
            WillReturn.Add("31 199");
            WillReturn.Add("231 23");
            WillReturn.Add("3 2");
            //6930
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        long[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => long.Parse(X)).ToArray();

        long TotalT = 1;
        long TotalA = 1;

        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            long CurrT = wkArr[0];
            long CurrA = wkArr[1];

            //TotalT以上で最小のCurrTの倍数を求める
            long MinBaisuuT = DeriveMinBaisuu(TotalT, CurrT);

            //TotalA以上で最小のCurrAの倍数を求める
            long MinBaisuuA = DeriveMinBaisuu(TotalA, CurrA);

            //倍率を求める
            long BairituT = MinBaisuuT / CurrT;
            long BairituA = MinBaisuuA / CurrA;

            //大きいほうの倍率となる
            long Bairitu = Math.Max(BairituT, BairituA);

            TotalT = CurrT * Bairitu;
            TotalA = CurrA * Bairitu;
        }
        Console.WriteLine(TotalT + TotalA);
    }

    //A,Bを引数として、A以上で最小のBの倍数を求める
    static long DeriveMinBaisuu(long pA, long pB)
    {
        long Syou = pA / pB;
        long Amari = pA % pB;

        return pB * (Syou + Math.Sign(Amari));
    }
}


Measured memory_bytes: 13396
s = gets.chomp
if s.size.odd?
  s = s[0...(s.size / 2)] + s[s.size / 2 + 1...s.size]
end
ans = 0
(s.size / 2).times do |i|
  ans += 1 if s[i] != s[s.size - 1 - i]
end
p ans

Measured memory_bytes: 1788
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  const int INF = 1 << 28;

  int N, M;
  while (~scanf("%d %d\n", &N, &M)) {
    if (N == 0 && M == 0)
      break;

    vector<vector<int> > land(N, vector<int>(N, INF)), sea(N, vector<int>(N, INF));
    for (int i = 0; i < N; ++i)
      land[i][i] = sea[i][i] = 0;

    for (int i = 0; i < M; ++i) {
      int x, y, t;
      char s;
      scanf("%d %d %d %c\n", &x, &y, &t, &s);
      --x;
      --y;
      if (s == 'L')
	land[x][y] = land[y][x] = min(land[x][y], t);
      else
	sea[x][y] = sea[y][x] = min(sea[x][y], t); 
    }

    for (int k = 0; k < N; ++k) {
      for (int i = 0; i < N; ++i) {
	for (int j = 0; j < N; ++j) {
	  land[i][j] = min(land[i][j], land[i][k]+land[k][j]);
	  sea[i][j] = min(sea[i][j], sea[i][k]+sea[k][j]);
	}
      }
    }
    
    int R, z1, z2;
    scanf("%d\n", &R);
    scanf("%d", &z1);
    --z1;
    vector<vector<int> > dp(R, vector<int>(N, INF));
    dp[0][z1] = 0;
    for (int i = 0; i < R-1; ++i) {
      scanf("%d", &z2);
      --z2;
      for (int j = 0; j < N; ++j) {
	dp[i+1][j] = min(dp[i+1][j], dp[i][j]+land[z1][z2]);
	for (int k = 0; k < N; ++k) {
	  dp[i+1][k] = min(dp[i+1][k], dp[i][j]+land[z1][j]+sea[j][k]+land[k][z2]);
	}
      }
      z1 = z2;
    }

    int ans = INF;
    for (int i = 0; i < N; ++i)
      ans = min(ans, dp[R-1][i]);
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long N = cin.Long();
			int max = 3500;
			for (int h = 1; h < max; h++) {
				for (int w = 1; w < max; w++) {
					long bo = 4 * h * w - N * w - N * h;
					long shi = N * h * w;
					if (bo != 0 && shi % bo == 0) {
						long n = shi / bo;
						if (n > 0) {
							Console.WriteLine($"{h} {n} {w}");
							return;
						}
					}
				}
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

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

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

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

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

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

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

int main(){
    int n;
    int alice=0,bob=0;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    for(int i=0;i<n;i+=2){
        alice+=a[i];
    }
    for(int j=1;j<n;j+=2){
        bob+=a[j];
    }
    cout << alice-bob << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define srep(i,s,t) for (ll i = s; i < t; ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    ll f[n] = {};
    int flag[n] = {};
    rep(i,n){
        int ma = 0;
        int arg = -1;
        rep(j,n){
            if(flag[j] == 1)continue;
            if(ma < a[j]){
                ma = a[j];
                arg = j;
            }
        }
        f[i] = arg;
        flag[arg] = 1;
    }

    ll dp[n][n+1];
    rep(i,n)rep(j,n+1)dp[i][j] = 0;

    rep(i,n){
        int x = f[i];
        if(i == 0){
            dp[i][0] = a[x] * (n - 1 - x);
            dp[i][1] = a[x] * x;
        }else{
            rep(j,n+1){
                if(j > i + 1)break;
                if(j > 0)dp[i][j] = max(dp[i][j], dp[i-1][j-1] + a[x] * abs(x-(j-1)));
                dp[i][j] = max(dp[i][j], dp[i-1][j] + a[x] * abs(n-1-(i-j)-x));
            }
        }
    }

    /*
    rep(i,n){
        rep(j,n+1)cout << dp[i][j] << ' ';
        cout << endl;
    }
    */

    ll ans = 0;
    rep(j,n+1)ans = max(ans, dp[n-1][j]);
    cout << ans << endl;
    return 0;
}
 
 


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

typedef struct _Node{
	int key;
	struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(void){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(void){
	Node *cur = nil->next;
	int isf = 0;
	while(1){
		if(cur == nil) break;
		if(isf++>0) printf(" ");
		printf("%d",cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t==nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(void){
	deleteNode(nil->next);
}

void deleteLast(void){
	deleteNode(nil->prev);
}

void deletekey(int key){
	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next= x;
	x->prev =nil;	
}

int main(void){
	int key, n, i;
	int size =0;
	int np =0, nd =0;
	char com[20];
	scanf("%d", &n);
	init();
	for(i=0;i<n;i++){
		scanf("%s %d", com, &key);
		if(com[0]=='i'){
			insert(key);
			np++;
			size++;
		}	
		else if(com[0] == 'd'){
			if(strlen(com)>6){
				if(com[6]=='F') deleteFirst();
					else if(com[6]=='L') deleteLast();
			}
			else{
				deletekey(key);
				nd++;
			}
		size--;
		}
	}
	printList();
	return 0;
}


Measured memory_bytes: 32948
#include <bits/stdc++.h>
 
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
 
 
using namespace std;
 
#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9+9;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}
 
//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1
 
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

vvi G(200005);
ll cnt[200005] = {0};
int visited[200005] = {0};

void dfs(int u){
	visited[u] = 1;
	for(auto v:G[u]){
		if(visited[v] == 0){
			cnt[v] += cnt[u];
			dfs(v);
		}
	}
}

int main(){

	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n,q;
    cin>>n>>q;

    for(int i=1;i<=n-1;i++){
    	int a,b;
    	cin>>a>>b;
    	G[a].pb(b);
    	G[b].pb(a);
    }

    for(int i=1;i<=q;i++){
    	int p,x;
    	cin>>p>>x;
    	cnt[p] += x;
    }
    dfs(1);
    for(int i=1;i<=n;i++){
    	cout << cnt[i] << "\n";
    }
}

Measured memory_bytes: 21888
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;

void solve()
{
	int m, k; cin >> m >> k;
	if (k >= (1 << m))
	{
		cout << -1;
		return;
	}
	if (k == 1 and m == 1)
	{
		cout << -1;
		return;
	}
	if(k == 0 and m == 1)
	{
		cout << "0 0 1 1";
		return;
	}
	cout << k << ' ';
	for (int i = 0; i < (1 << m); ++i) {if (i != k) cout << i << ' ';}
	cout << k << ' ';
	for (int i = (1 << m) - 1; i >= 0; --i) {if (i != k) cout << i << ' ';}
	//comment
}

//  ---------------------Template---------------------------
void InputSetup()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
}

int main(void)
{
	auto start = chrono::high_resolution_clock::now();

	InputSetup();
	solve();

	auto finish = chrono::high_resolution_clock::now();
	cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
}
//  ---------------------Template---------------------------

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    if (N % 2 == 0) cout << N << endl;
    else cout << N * 2 << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(input())
K += K
ans = 0
for i in range(1, N):
    if S[i - 1] == S[i]: #同じ時
        ans += 1
    else:
        if K > 0: #ひっくり返せる時
            K -= 1
            ans += 1

print (ans)

Measured memory_bytes: 4084
def comb(n, k):
    if n - k < k:
        k = n - k
    if k == 0:
        return 1
    a = 1
    b = 1
    for i in range(k):
        a *= n - i
        b *= i + 1
    return a // b


N, P = map(int, input().split())
A = list(map(int, input().split()))

odds = sum(a % 2 for a in A)
evens = len(A) - odds

print(sum(comb(odds, i) for i in range(P, odds + 1, 2)) * (2 ** evens))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;




ll mod=1e9+7;
ll dp[2000+4];

vector<pair<ll,ll>>p;

vector<ll> to[100005];
ll inf =1000000007;
int main()
{
  ll n,m;
  cin>>n>>m;
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<ll>dist(n,inf);
  queue<ll> q;
  q.push(0);
  dist[0]=0;
  vector<ll>pre(n,-1);
  while(!q.empty()){
    ll a=q.front();
    q.pop();
    for(ll x:to[a]){
        if(dist[x]!=inf)continue;
        dist[x]=dist[a]+1;
        pre[x]=a;
        q.push(x);
    }
  }
  cout<<"Yes"<<endl;
  Rep(i,n)cout<<++pre[i]<<endl;
 }

 


 

 




Measured memory_bytes: 13732
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)
int32_t main()
{
    double d, t, s;
    cin>>d>>t>>s;
    double time  = d/s;
    if(time <= t)
    cout<<"Yes\n"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    return 0;

}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) {
        int h;
        cin >> h;
        h--;
        H[i] = h;
    }
    bool f = true;
    rep2(i, 1, N) {
        int h = H[i];
        if (H[i - 1] <= h) {
            continue;
        } else if (H[i - 1] - 1 == h) {
            H[i]++;
        }else {
            f = false;
        }
    }
    cout << (f ? "Yes" : "No") << '\n';
}

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


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

// は2の50乗を表す
using ll = long long;
const ll INF = 1LL << 50;

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

    const int NMAX=1000;
    const int MMAX=2000;
    int a[MMAX], b[MMAX];
    ll c[MMAX];

    for(int i=0; i<M; ++i){
        cin >> a[i] >> b[i] >> c[i];
        // 最小化問題と考える
        c[i] = -c[i];    
    }

    // 頂点1の最短距離をdist[1]=0、その他の頂点vの最短距離をdist[v]=∞で初期化
    ll dist[NMAX];

    for(int i=0; i < N; ++i){
        dist[i] = INF;
    }

    dist[0] = 0;
    
    // 最短距離の更新をN-1回繰り返します（経路の長さは最大でN-1であるため）
    for(int loop=0; loop < N-1; ++loop){
        for(int i=0; i<M; ++i){
            if(dist[a[i]-1] == INF) continue;

            if(dist[b[i]-1] > dist[a[i]-1] + c[i]){
                dist[b[i]-1] = dist[a[i]-1] + c[i];
            }
        }
    }

    // 頂点Nの最短距離を表す変数として ans = dist[N]とする。
    ll ans = dist[N-1];

    // 負閉路を検出するための長さNの配列negativeを用意して、falseで初期化する。
    bool negative[NMAX];

    for(int i=0; i<N; ++i){
        negative[i] = false;
    }

   /* 最短距離の更新をN回繰り返す（負閉路の長さは最大でNであるため）。ただし、
      この時更新された頂点biについて、netative[bi]=trueとする。 
      また、netative[ai]がtrueの場合には、netative[bi]をtrueにする。
   */
   for(int loop=0; loop<N; ++loop){
       for(int i=0; i<M; ++i){
           if(dist[a[i]-1] == INF) continue;

           if(dist[b[i]-1] > dist[a[i]-1] + c[i]){
               dist[b[i]-1] = dist[a[i]-1] + c[i];
               negative[b[i] - 1] = true;
           }

           if(negative[a[i]-1] == true){
               negative[b[i]-1] = true;
           }
       }
   }

   if(negative[N-1]){
       cout << "inf" << endl;
   }else{
       cout << -ans << endl;
   }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
ll a[2010];
int n,m;
vector<ll> v;
vector<ll> vv;
ll res=0;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		cin >>a[i];
		if (i) a[i]+=a[i-1];
		v.push_back(a[i]);
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<i;j++)
		    v.push_back(a[i]-a[j]);
	}
	for (int i=60;i>=0;i--)
	{
		/*for (int j=0;j<v.size();j++) cout <<v[j]<<" ";
		cout <<"\n";*/
		ll t=(ll)1<<i;
		vv.clear();
		for (int j=0;j<v.size();j++) if (v[j] & t) vv.push_back(v[j]);
		if (vv.size()>=m) v=vv,res+=t;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 6128
n,k=map(int,input().split())
xs=[0]+list(map(int,input().split()))
from itertools import accumulate
As=list(accumulate(xs))
r = 0
for i in range(k+1):
    for j in range(i, k+1):
        x = i, j-i, k-j
        if j > n:
            continue
        m1 = As[i] + As[n] - As[n-j+i]
        m = m1 - sum(sorted(z for z in (xs[:i]+xs[n-j+i+1:]) if z < 0)[:k-j])
#        if m > r:
#            print(x, m, m1)
        r = max(r, m)
print(r)


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

int main(){
    unsigned int l, r;
    cin >> l >> r;

    if((r-l) > 2019){
        cout << 0 << endl;
        return 0;
    }
    
    l %= 2019;
    r %= 2019;

    if(!(l & r) || l >= r){
        cout << 0 << endl;
    }else{
        int dif;
        dif = 2018;

        for(int i = l; i < r; i++){
            for(int j = i + 1; j <= r; j++){
                if(dif > (i*j)%2019){
                    dif = (i*j)%2019;
                }
            }
        }

        cout << dif << endl;
    }
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let r:i16 = read();
    println!("{}",r*r);

}

Measured memory_bytes: 4352
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
res = INF
for i in range(1,101):
    p = i
    cnt = 0
    for j in range(n):
        cnt += (p-a[j]) ** 2
    res = min(res,cnt)
print(res)

Measured memory_bytes: 65516
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

ll n, m;

ll solve(){
    cin >> n >> m;
    if(abs(n - m) > 1) return 0;
    if(m > n) swap(n, m);

    ll ans = 1;
    for(ll i = 2; i <= m; ++i){
        ans *= i;
        ans %= (1ll * mod);
    }
    ans *= ans;
    ans %= (1ll * mod);
    ans *= (m == n ? 2 : (m + 1));
    return ans % (1ll * mod);
}

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

    cout << solve() << "\n";
    
    return 0;
}


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

using namespace std;

int main()
{
	int n, x;

	while(1)
	{
		cin >> n >> x;

		if (n == 0 && x == 0) break;

		int count = 0;
		for (int i = 1; i <= n - 2; i++)
		{
			for (int j = i + 1; j <=  n - 1; j++)
			{
				int k = x - (i + j);
				if (k > j && k <= n)
				{
					count++;
				}
			}
		}
		cout << count << endl;
	} 
}


Measured memory_bytes: 3096
n, m = map(int, input().split())
ab = [tuple(int(x) for x in input().split()) for _ in range(n)]
cd = [tuple(int(x) for x in input().split()) for _ in range(m)]

for a, b in ab:
    ans = 1
    d = abs(a - cd[0][0]) + abs(b - cd[0][1])
    for i in range(1, m):
        temp_d = abs(a - cd[i][0]) + abs(b - cd[i][1])
        if temp_d < d:
            d = temp_d
            ans = i + 1
    print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stack>
int main(){
  int a=0;
  char t;
  std::string s;
  std::cin>>s;
  std::stack<char> st;
  for(int i=0;i<s.size();++i){
    if(st.size()==0){st.push(s[i]);}
    else{
      t=st.top();
      if(t!=s[i]){a+=2;st.pop();}
      else{st.push(s[i]);}
    }
  }
  std::cout<<a<<"\n";
}
    

Measured memory_bytes: 512
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T> inline bool chmin(T& a, T const b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T const b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(n);
  vector<ll> l(n);
  ll sum = 0;
  rep(i, n){
    cin >> l[i];
    sum += l[i];
  }

  sort(all(l));
  // dump(l);
  // dump(sum);
  // dump(l[n - 1]);
  if(sum > l[n - 1] * 2){
    cout << "Yes";
  }else{
    cout << "No";
  }


}
#endif


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

using namespace std;

const int P = 1e9 + 7;
const int N = 2005;

long long frac[N * N], inv_frac[N * N], f[N][N], Sf[N][N];

inline long long ksm(long long base, long long x) {
    long long res = 1;
    while(x) {
        if(x & 1) res *= base, res %= P;
        x >>= 1, base *= base, base %= P;
    }
    return res;
}

inline long long C(int x, int y) {
    if(x >= y && y >= 0) {
        return frac[x] * inv_frac[y] % P * inv_frac[x - y] % P;
    }
    return 0;
}

inline void init() {
    int n, k;
    cin >> n >> k;
    if(k == 1) {
        printf("1\n");
        return ;
    }
    frac[0] = 1, inv_frac[0] = 1;
    for(int i = 1; i <= n * k; i++) frac[i] = (frac[i - 1] * i) % P, inv_frac[i] = ksm(frac[i], P - 2);


    Sf[1][0] = Sf[1][1] = f[1][1] = 1;

    for(int i = 2; i <= n; i++) {
        for(int j = 1; j <= i; j++) f[i][j] = C(i * k - j - 1, k - 2) * Sf[i - 1][j - 1] % P;
        for(int j = i; j >= 0; j--) Sf[i][j] = (Sf[i][j + 1] + f[i][j]) % P;
    }
/*
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            printf("%lld ", f[i][j]);
        }
        printf("\n");
    }
    printf("\n");
*/
    cout << Sf[n][1] * frac[n] % P << endl;
}

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

Measured memory_bytes: 124288
#include <stdio.h>
#define int long long

signed main(){
	int N, X, Y, tmp, ans;
	scanf("%lld%lld", &N, &X);
	for(ans = N, Y = N - X;;){
		if(X > Y){
			tmp = X;
			X = Y;
			Y = tmp;
		}
		if(Y % X == 0){
			ans += X * (2 * (Y / X) - 1);
			break;
		}
		else{
			ans += X * 2 * (Y / X);
			Y = Y % X;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int dist[110][110];
int n,m;

void warshall_floyed(){
	
	for (int i = 1; i <= n; i++)
    	for (int j = 1; j <= n; j++)
      		for (int k = 1; k <= n; k++)
        		dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
}

int main(){
	
	cin >> n >> m;
	int a[1100],b[1100],c[1100];
	FOR(i,105){
		FOR(j,105){
			if(i==j)dist[i][j]=0;
			else dist[i][j]=MOD;
		}
	}
	FOR(i,m){
		cin >> a[i] >> b[i] >> c[i];
		dist[a[i]][b[i]]=c[i];
		dist[b[i]][a[i]]=c[i];
	}
	int ans=0;
	
	warshall_floyed();
	FOR(i,m){
		if(c[i]>dist[a[i]][b[i]])ans++;
	}
	cout << ans << endl;


}

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

int main() {
	string w;
	cin >> w;

	string a = "Yes";
	for (int i = 0; i < w.size(); i++) {
		char ch = w.at(i);
		int n = count(w.begin(), w.end(), ch);
		if (n % 2 == 1) {
			a = "No";
			break;
		}
	}

	cout << a << endl;
}

Measured memory_bytes: 256
use std::cmp;

const N: usize = 4500;
const W: usize = N * 2 + 1;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let a = sc.chars();
    let b = sc.chars();
    let c = sc.chars();

    let ab = calc(&a, &b);
    let bc = calc(&b, &c);
    let ac = calc(&a, &c);

    let mut ans = a.len() + b.len() + c.len();
    for b_start in 0..W {
        for c_start in 0..W {
            if !ab[b_start] || !ac[c_start] {
                continue;
            }

            let min = cmp::min(cmp::min(b_start, c_start), N);
            let max = cmp::max(cmp::max(b_start + b.len(), c_start + c.len()), N + a.len());
            let length = max - min;

            if b_start < N {
                let right = N - b_start;
                let c_start = c_start + right;
                if bc.len() <= c_start || bc[c_start] {
                    ans = cmp::min(ans, length);
                }
            } else {
                let left = b_start - N;
                if c_start < left || bc[c_start - left] {
                    ans = cmp::min(ans, length);
                }
            }
        }
    }

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

fn calc(a: &Vec<char>, b: &Vec<char>) -> [bool; W] {
    let mut is_ok = [false; W];

    let mut s = ['?'; W];
    for i in 0..a.len() {
        s[i + N] = a[i];
    }

    for b_start in 0..W {
        let mut ok = true;
        for i in 0..b.len() {
            if i + b_start < W {
                if s[i + b_start] != '?' && s[i + b_start] != b[i] && b[i] != '?' {
                    ok = false;
                    break;
                }
            }
        }
        is_ok[b_start] = ok;
    }
    is_ok
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  stringstream ss;
  cin >> n;
  string ans = (n==3 || n==5|| n==7)?"YES":"NO";
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <memory>
#include <utility>

template <class W> class pairing_heap {
  using T = typename W::value_type;

public:
  using value_type = T;

private:
  class node_type;
  using node_ptr = std::unique_ptr<node_type>;
  class node_type {
  public:
    T value;
    node_ptr head;
    node_ptr next;

    node_type(const T value) : value(value), head(), next() {}
  };

  static node_ptr merge(node_ptr x, node_ptr y) {
    if (!x)
      return y;
    if (!y)
      return x;
    if (!W::compare(x->value, y->value))
      std::swap(x, y);
    y->next = std::move(x->head);
    x->head = std::move(y);
    return x;
  }
  static node_ptr merge_list(node_ptr list) {
    if (!list || !list->next)
      return list;
    node_ptr next = std::move(list->next);
    node_ptr rem = std::move(next->next);
    return merge(merge(std::move(list), std::move(next)),
      merge_list(std::move(rem)));
  }

  node_ptr root;

  pairing_heap(node_ptr root) : root(std::move(root)) {}

public:
  pairing_heap() = default;

  bool empty() const { return !root; }
  T top() const {
    assert(!empty());
    return root->value;
  }

  void push(const T x) {
    root = merge(std::move(root), std::make_unique<node_type>(x));
  }
  void pop() {
    assert(!empty());
    root = merge_list(std::move(root->head));
  }

  static pairing_heap meld(pairing_heap x, pairing_heap y) {
    return pairing_heap(merge(std::move(x.root), std::move(y.root)));
  }
};

template <class T> class greater_equal_ordered_set {
public:
  using value_type = T;
  static constexpr bool compare(const T& x, const T& y) noexcept {
    return x >= y;
  }
};

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include<stack>

void solve(const int n, const int q) {
  using heap_type = pairing_heap<greater_equal_ordered_set<int>>;

  std::vector<int> p(n), deg(n, 0);
  for (int i = 1; i != n; i += 1) {
    std::cin >> p[i];
    p[i] -= 1;
    deg[p[i]] += 1;
  }
  std::vector<heap_type> ph(n);
  std::vector<int> time(n, q);
  time[0] = -1;
  for (int i = 0; i != q; i += 1) {
    char c;
    std::cin >> c;
    switch (c) {
    case 'M': {
      int v;
      std::cin >> v;
      v -= 1;
      time[v] = std::min(time[v], i);
    } break;
    case 'Q': {
      int v;
      std::cin >> v;
      v -= 1;
      ph[v].push(i);
    } break;
    }
  }
  std::stack<int> st;
  for (int i = 0; i != n; i += 1) {
    if (deg[i] == 0)
      st.push(i);
  }
  long long ans = 0;
  while (!st.empty()) {
    const int v = st.top();
    st.pop();
    auto& pv = ph[v];
    while (!pv.empty() && time[v] < pv.top()) {
      pv.pop();
      ans += v + 1;
    }
    if (v == 0)
      continue;
    ph[p[v]] = heap_type::meld(std::move(ph[p[v]]), std::move(pv));
    deg[p[v]] -= 1;
    if (deg[p[v]] == 0)
      st.push(p[v]);
  }
  std::cout << ans << std::endl;
}

int main() {
  while (true) {
    int n, q;
    std::cin >> n >> q;
    if (n == 0 && q == 0)
      break;
    solve(n, q);
  }
  return 0;
}


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

typedef long long ll;
ll N, D;
vector<vector<ll>> X;
ll R;

int main() {
  cin >> N >> D;
  X.resize(N);
  for (auto &x : X) x.resize(D);
  for (ll i = 0; i < N; ++i) {
    for (ll k = 0; k < D; ++k) cin >> X[i][k];
  }
  for (ll i = 0; i < N; ++i) {
    for (ll j = i + 1; j < N; ++j) {
      double d2 = 0;
      for (ll k = 0; k < D; ++k) {
        d2 += pow(X[i][k] - X[j][k], 2);
      }
      ll d = sqrt(d2);
      if (ll(d2) == d * d) ++R;
    }
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
ve <ll> parent(1e6+5,0);
void bfs(ll node,ve <ll> adj[],ve<bool> &visit)
{
    queue<ll> q;
    // ve<bool> visit(n+1);
    // ve<ll> dis(n+1);
    visit[node] = true;
    q.push(node);
    while (!q.empty())
    {
        ll s = q.front();
        q.pop();
        // process node s
        for (auto u : adj[s])
        {
            if (visit[u])
                continue;
            visit[u] = true;
            parent[u]=s;
            q.push(u);
        }
    }
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,m;
    cin>>n>>m;
    ve <ll> adj[n+1];
    rep (i,0,m)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    ve <bool> visit(n+1,false);
    bfs(1,adj,visit);
    rep (i,1,n+1)
    {
        if (!visit[i])
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    rep (i,2,n+1)
    {
        cout<<parent[i]<<"\n";
    }
}


Measured memory_bytes: 20060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T; cin >> S >> T;
  int res = 0;
  for(int i = 0; i < 3; ++i) {
  if(S.at(i) == T.at(i)) ++res;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int num1,num2,math1[N],math2[N],i;

void input(void){
    scanf("%d",&num1);
    for(i=0;i<num1;i++)scanf("%d",&math1[i]);
    scanf("%d",&num2);
    for(i=0;i<num2;i++)scanf("%d",&math2[i]);
}

int main(void){
    int left,right,mid,count=0,key;
    input();
    for(i=0;i<num2;i++){
        key = math2[i];
        left = 0;
        right = num1;
      while(left < right){
        mid = (left + right) / 2;
        if(key == math1[mid]){
	         count++;
        	break;
        }
        else if(key < math1[mid])right = mid;
        else left = mid + 1;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2388
#include<iostream>

using namespace std;

int main(void){
 string S;
 int i,sum=0,L;

 cin >>S;
 L = S.length();

  for(i=0; i<L/2; i++){
    if(S[i] != S[L-1-i]) sum++;
  }

 cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        String s = sc.next();
        if(N>=3200) p(s);
        else p("red");
	
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23124
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, h: usize, w: usize, k: usize);
    let mut c: Vec<Vec<bool>> = vec![];
    for _ in 0..h {
        let line = it.next().unwrap();
        c.push(line.chars().map(|x| x == '#').collect())
    }
    let mut ret = 0usize;
    for hs in 0..(1 << h) {
        for ws in 0..(1 << w) {
            let mut count = 0;
            for i in 0..h {
                for j in 0..w {
                    if (hs >> i) & 1 == 0 && (ws >> j) & 1 == 0 && c[i][j] {
                        count += 1;
                    }
                }
            }
            if count == k {
                ret += 1;
            }
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main(){
    long long n,m;
    cin>>n>>m;
    long long a[n];
    long long ans=1;
    long long ok=1;
    for(int i=0;i<n;i++){
	cin>>a[i];
	a[i]/=2;
	ok=ans*a[i];
	ans=__gcd(ans,a[i]);
	ans=ok/ans;
    }
    //cout<<ans<<endl;
    long long ammat=m/ans;
    for(int i=0;i<n;i++){
	if((ans/(a[i]))%2==0){
	    cout<<0;
	    return 0;
	}
    }
    if(ammat%2){
	cout<<ammat/2+1;
    }
    else{
	cout<<ammat/2;
    }
}


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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	char str[100]; cin >> str;
	cout << (strncmp(str, "YAKI", 4) ? "No" : "Yes") << "\n";
	
	return 0;
}


Measured memory_bytes: 3624
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j;
    cin>>a;
    double p[a];
    for(i=0;i<a;i++){
        cin>>p[i];
    }
    double q;
    q=0;
    for(i=0;i<a;i++){
        q=q+1/p[i];
    }
    double ans;
    ans=1/q;
    cout<<setprecision(6)<<ans<<endl;
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int max = int.MinValue, count = 0;
            for (int i = 0; i < N; i++)
            {
                if (H[i] >= max)
                {
                    max = H[i];
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }
}

Measured memory_bytes: 13268
from operator import itemgetter
import sys
input = sys.stdin.readline


class BIT:
    """区間加算、一点取得クエリをそれぞれO(logN)で答えるデータ構造"""
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    info[i] = info[i][0], info[i][1], info[i][1] - info[i][0] + 1
info = sorted(info, key=itemgetter(2))

bit = BIT(m + 1)
l_info = 0
ans = n
for d in range(1, m + 1):
    while True:
        if l_info < n and info[l_info][2] < d:
            l, r, _ = info[l_info]
            bit.add(l, r + 1, 1)
            l_info += 1
            ans -= 1
        else:
            break
    cnt = ans
    for i in range(0, m + 1, d):
        cnt += bit.get_val(i)
    print(cnt)

Measured memory_bytes: 128348