akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n;
int v[MAX];

#define pii pair<int,int>
#define mp make_pair


void solve() {
	cin >> n;
	for(int i=0; i<n; i++) cin >> v[i];
	sort(v, v+n, greater<int>());
	priority_queue<pii> q;
	q.push(mp(v[0], v[0]));
	ll ans = 0ll;
	for(int i=1; i<n; i++) {
		pii p = q.top();
		q.pop();
		int l = p.first;
		int r = p.second;
		ans += min(l, r);
		q.push(mp(min(l, v[i]), max(l, v[i])));
		q.push(mp(min(r, v[i]), max(r, v[i])));
	}
	cout << ans << "\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
#define mod 1000000007
vector<int>gr[100005];
int dp[100005][2];
int dfs(int x,int par,int col)
{
    if(dp[x][col]!=-1)
    return dp[x][col];
    dp[x][col]=1;
    for(int i=0;i<gr[x].size();i++)
    {
        if(gr[x][i]==par)
        continue;
        ll m;
        if(col==0)
        {
            m=dfs(gr[x][i],x,1);
        }
        else
        {
            m=(0LL+dfs(gr[x][i],x,0)+dfs(gr[x][i],x,1)+mod)%mod;
        }
        dp[x][col]=(1LL*dp[x][col]*m)%mod;
    }
    return dp[x][col];
}
int main()
{
    for(int i=0;i<100005;i++)
    {
        dp[i][0]=-1;
        dp[i][1]=-1;
    }
    int n;
    cin>>n;
    int u,v;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v;
        gr[u].pb(v);
        gr[v].pb(u);
    }
    cout<<(0LL+dfs(1,1,0)+dfs(1,1,1)+mod)%mod<<"\n";
    return 0;
}

Measured memory_bytes: 14848
#include<iostream>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(a > b)
  {
      if(a - 1 >= b)
        cout << 2 * a - 1;
      else
        cout << a + b;
  }
  else
    if(a < b)
  {
      if(b - 1 >= a)
        cout << 2 * b - 1;
      else
        cout << a + b;
  }
  else
    cout << a + b;
  return 0;
}

Measured memory_bytes: 3592
//A
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int M, d;
bool used[102];
int main() {
    M = read(), d = read(); int ans = 0;
    for (reg int m = 1; m <= M; m++) {
        memset(used, 0, sizeof(used));
        for (int i = 2; i <= sqrt(m); i++) {
            if (m % i == 0) {
                if (i + 10 * (m / i) <= d && i < 10 && (m / i) < 10) used[i + 10 * (m / i)] = true;
                if (m / i + 10 * i <= d && i < 10 && (m / i) < 10) used[m / i + 10 * i] = true;
            }
        }
        for (reg int i = 1; i <= d; i++) ans += used[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        String s = stdIn.next();
        char[] cs = s.toCharArray();

        int l = 0;
        int r = n-1;
        int cnt = 0;
        while(l < r){
            if(cs[l] != 'W'){
                l++;
            }
            if(cs[r] != 'R'){
                r--;
            }
            if(l < r && cs[l] == 'W' && cs[r] == 'R'){
                cs[l] = 'R';
                cs[r] = 'W';
                cnt++;
                l++;
                r--;
            }
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 40776
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h){
        print("Yes")
    }
    else{
        print("No")
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, curt = 0, curx = 0, cury = 0, t, x, y;
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> t >> x >> y;
		if (t - curt < abs(x-curx)+abs(y-cury) || (abs(x-curx) + abs(y-cury) + t - curt)%2!=0){
			cout << "No\n";
			return 0;
		}
		curt = t;
		curx = x;
		cury = y;
	}
	cout << "Yes\n";
	cout << flush;
	for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 256
l = [list(map(int, input().split()))]
i = 0
while (1):
    a, b, c = map(int,l[i])
    if (a % 2 == 1 or b % 2 == 1 or c % 2 == 1):
        print(i)
        break
    t = [b / 2 + c / 2, c / 2 + a / 2, a / 2 + b / 2]
    if (t in l):
        print(-1)
        break
    l.append(t)
    i+=1


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

int main(){
  string s; cin>>s;
  vector<int> ve,vo;
  
  int a=0;
  for(auto c:s){
    if(a%2==0){
      ve.push_back(c);
    } else {
      vo.push_back(c);
    }
    a++;
  }
  int ne0 = count(ve.begin(),ve.end(),'0');
  int ne1 = count(ve.begin(),ve.end(),'1');
  int no0 = count(vo.begin(),vo.end(),'0');
  int no1 = count(vo.begin(),vo.end(),'1');

  int ans = min(ne0+no1,ne1+no0);
  cout<<ans<<endl;
  return 0;
}

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

int main(void){
	int start_1 = 0;
  	int start_0 = 0;
  	std::string str;
  	std::cin >> str;
  	bool trans = true;
  	for(int i = 0; i < str.size(); ++i){
    	if(trans){
          if(str[i] == '0') ++start_1;
          if(str[i] == '1') ++start_0;
        }
      	else{
          if(str[i] == '1') ++start_1;
          if(str[i] == '0') ++start_0;
        }
      	trans = !trans;
    }
  
  	start_0 < start_1 ? std::cout << start_0 : std::cout << start_1;
  	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

ll n;
ll h[MAX_N];

int main() {

  ll cmax = -1;
  ll nh;
  ll cnt = 0;

  cin >> n;
  rep(i, n) cin >> h[i];

  nh = h[0];

  for(int i=1; i<n; ++i) {
    if(nh>=h[i]) {
      ++cnt;
    }
    else {
      cmax = max(cmax, cnt);
      cnt = 0;
    }
    nh = h[i];
  }

  cmax = max(cmax, cnt);

  cout << cmax << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  long long set = n /(a+b);
  long long nokori = n  - set * (a+b);
  long long nokorib;
  nokorib = ((nokori>a)? a:nokori);
  long long brue = set*a + nokorib;
  cout << brue << "\n";
  return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    a = set([int(input()) for _ in range(m)])

    ansls = [0]*(n+1)
    big = 10**9 + 7

    if 0 not in a:
        ansls[0] = 1
    if 1 not in a:
        ansls[1] = 1

    for i in range(2, n+1):
        if i not in a:
            ansls[i] = (ansls[i-2] + ansls[i-1])%(10**9 + 7)
    
    print(ansls[-1])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 13168
#include <stdio.h>
#define N 100
#define M 100
#define L 100
int main(void)
{
	int n, m, l, i, j, k;
	int A[N][M];
	int B[M][L];
	long long C[N][L]={{0}};
	scanf("%d%d%d", &n, &m, &l);
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
		scanf("%d", &A[i][j]);
		}
	}
	for(i=0; i<m; i++){
		for(j=0; j<l; j++){
		scanf("%d", &B[i][j]);
		}
	}
	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			for(k=0; k<m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
			printf("%lld", C[i][j]);
			if(j < l-1){
				printf(" ");
			}else{
				puts("");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 780
until (n = $<.gets.to_i).zero?
  dolls = n.times.map {$<.gets.split.map(&:to_i)}
  m = $<.gets.to_i
  dolls += m.times.map {$<.gets.split.map(&:to_i)}
  dolls.sort! {|a, b| (b[0] <=> a[0]).nonzero? || b[1] <=> a[1]}
  
  longest = Array.new(n + m, 0)
  
  (0..n + m - 2).each do |i|
    (i + 1...n + m).each do |j|
      if dolls[i][0] > dolls[j][0] and dolls[i][1] > dolls[j][1]
        if (a = longest[i] + 1) > longest[j]
          longest[j] = a
        end
      end
    end
  end
  puts longest.last + 1
end


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

int main() {
  int n, k;
  cin >> n >> k;

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  for (int i = k; i < n; i++) {
    if (a[i - k] < a[i]) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
}


Measured memory_bytes: 4836
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.map!(to!size_t), n = rd[0], m = rd[1], l = rd[2];
  auto aij = n.iota.map!(_ => readln.split.map!(to!long)).array;
  auto bij = m.iota.map!(_ => readln.split.map!(to!long)).array;

  auto cij = new long[][](n, l);
  foreach (i; 0..n)
    foreach (j; 0..l)
      cij[i][j] = m.iota.map!(k => aij[i][k] * bij[k][j]).sum;

  cij.each!(ci => ci.map!(to!string).join(" ").writeln);
}

Measured memory_bytes: 3660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

//var dp []int = make([]int, n)

//func fib(n int) int {
//	dp[0] = 0
//	dp[1] = 1
//	for i := 2; i <= n; i++ {
//		dp[i] = dp[i-1] + dp[i-2]
//	}
//	return dp[n]
//}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	a := nextInt()
	b := nextInt()
	diff := a - b*2
	if diff > 0 {
	} else {
		diff = 0
	}
	fmt.Fprint(out, diff)

	//	var dp []int = make([]int, n)
	//	sort.Ints(ns)
	//	for i := 0; i < n-1; i++ {
	//		dp[i] = ns[i] * ns[i+1]
	//	}
	//	fmt.Fprint(out, dp[k-1])
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	vector<vector<int>> arr(n, vector<int>(3));
  	for(int i = 0;i<n;i++){
      cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
  	vector<vector<int>> dp(n, vector<int>(3));
	dp[0][0] = arr[0][0];
  	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];
  	
  	for(int i=1;i<n;i++){
    	for(int j=0;j<3;j++){
        	for(int k =0;k<3;k++){
            	if(j==k) continue;
                 dp[i][j] = max(dp[i][j], dp[i-1][k] + arr[i][j]);
            }
        }
    }
  	int ans = -1;
    for(int j=0;j<3;j++){
    	ans = max(ans, dp[n-1][j]);
    }
	cout<<ans<<endl;
}
	

Measured memory_bytes: 13628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s1 ,s2 , s ;
    cin>>s1>>s2;
    vector<char>v;
    long long a;
    long long n1=s1.size() , n2=s2.size();
    a=max(n1,n2);
    for (int i=0 ; i<a ; ++i)
    {
        if (i<n2)
        {
            cout<<s1[i]<<s2[i];
        }
        else
        {
            cout<<s1[i];
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,m,ans,X,Y,K,ff,col;
long long vis[200005];
long long tot,head[200005],nx[800005],to[800005];
void jia(long long aa,long long bb)
{
	tot++;
	nx[tot]=head[aa];
	to[tot]=bb;
	head[aa]=tot;
	return;
}
void dfs(int rt)
{
	vis[rt]=col;
	if(rt<=n&&vis[rt+n]==col) ff=1;
	else if(rt>n&&vis[rt-n]==col) ff=1;
	for(int i=head[rt];i;i=nx[i])
	{
		int yy=to[i];
		if(vis[yy]) continue;
		dfs(yy);
	}
	return;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		int x=read(),y=read();
		jia(x,y+n);jia(y+n,x);
		jia(y,x+n);jia(x+n,y);
	}
	for(int i=1;i<=n*2;++i) if(!vis[i])
	{
		ff=0;++col;dfs(i);
		if(!head[i]) K++;
		else if(!ff) X++;
		else Y++;
	}
	X/=2;K/=2;
	write(X*(2*X+Y)+Y*(X+Y)+K*2*n-K*K);
	return 0;
}

Measured memory_bytes: 17664
n,m = map(int,input().split())
M = [0]*m
for i in range(n):
    K = list(map(int,input().split()))
    for j in range(1,K[0]+1):
        M[K[j] - 1] += 1

cnt = 0
for i in range(m):
    if M[i] >= n:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i;
  char s[101];
  cin >> s;
  for(i = 0; s[i]!='\0'; i++)
  {
    if( ((s[i] == 'R') && (i%2==1)) || ((s[i] == 'L') && (i%2==0)) )
      break;
  }
  if (s[i] == '\0')
    cout << "Yes";
  else
    cout << "No";
}

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

ll gcd(ll a, ll b){
  if(b > a) return gcd(b, a);
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  ll T; cin >> T;
  
  for(ll t = 0; t < T; t++){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    if((a < b)||(d < b)) {
      cout << "No" << endl;
      continue;
    }
    if(c > b){
      cout << "Yes" << endl;
      continue;
    }
    if(d > b){
      ll g = gcd(d, b);
      ll tmp = b - g + (a % g);
      if(tmp <= c) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
    if(d == b){
      if(a % b <= c) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
}

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

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define endl '\n'

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size() + 1;
	vector<int> ar(n);
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '<') {
			ar[i + 1] = ar[i] + 1;
		}
	}
	for (int i = s.size() - 1; i >= 0; --i) {
		if (s[i] == '>') {
			ar[i] = max(ar[i], ar[i + 1] + 1);
		}
	}
	ll sm = 0;
	for (int v: ar) {
		sm += v;
	}
	cout << sm << endl;
}


Measured memory_bytes: 2844
x[]={1,2,1,2,1,4,1,4},o[]={0,2,6,4,1,3,7,5},a[8];
main(i,j,v,V,m,t){for(;;){
for(i=0;i<8;i++)if(scanf("%d",a+i)==-1)exit(0);
v=99999999,V=0;
for(i=0;i<8;i++){for(m=j=0;j<8;j++)t=a[j]-x[(o[i]+j)%8],m+=t<0?0:t;if(m<v)v=m,V=o[i];}
for(j=0;j<8;j++)printf(j<7?"%d ":"%d\n",x[(V+j)%8]);
}}

Measured memory_bytes: 600
n = int(input())
lst = []
for _ in range(n):
    a = int(input())
    lst.append([[int(i) for i in input().split()] for _ in range(a)])
m = 0
for i in range(2 ** n):
    a = True
    for j in range(n):
        if i >> j & 1:
            for x, y in lst[j]:
                if (i >> (x - 1) & 1) != y:
                    a = False
                    break
    if a:
        m = max(m, bin(i).count('1'))
print(m)


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

int seica(ll a, ll b){
	ll tmp = a ^ b;
	int ret = 0;
	REP(i, 20){
		if(tmp & (1 << i))ret++;
	}
	return ret;
}

void out(vector<int> v){
	cout << "YES" << endl;
	REP(i, v.size()){
		cout << v[i];
		if(i != v.size() - 1)cout << " ";
	}
	cout << endl;
}

vector<int> dfs(int s, int g, int mask, int n){
	if(n == 1){
		return {s, g};
	}
	
	REP(i, 20){
		if(!(mask & (1<<i)))continue;
		int a = s & (1<<i);
		int b = g & (1<<i);
		if(a == b)continue;
		int nmask = mask ^ (1<<i);
		REP(j, 20){
			if(!(nmask & (1<<j)))continue;
			int tmp = (s & nmask) ^ (1<<j);
			auto l = dfs(s & nmask, tmp, nmask, n - 1); 
			auto r = dfs(tmp, g & nmask, nmask, n - 1); 
			vector<int> ret;
			REP(k, l.size())ret.PB(l[k] | (s & (1<<i)));
			REP(k, r.size())ret.PB(r[k] | (g & (1<<i)));
			return ret;
		}
	}	
}

int main(){
	
	ll n, a, b;cin >> n >> a >> b;
		
	if(seica(a, b) % 2 == 0){
		cout << "NO" << endl;
		return 0;
	}
	
	out(dfs(a, b, (1<<n)-1, n));
	
	return 0;
}


Measured memory_bytes: 1628
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n, p;
    cin >> n >> p;

    string s;
    cin >> s;

    reverse(all(s));
    if(p != 5 && p != 2){
        map<ll,ll> mp;
        ll now = 0;
        ll ten = 1;
        mp[0]++;
        rep(i, n){
            now += (s[i] - '0') * ten;
            now %= p;
            ten *= 10;
            ten %= p;
            mp[now % p]++;
        }
        ll ans = 0;
        for(auto &i : mp){
            if(i.second > 1) ans += nCr(i.second, 2LL);
        }
        cout << ans << endl;
    } else if(p == 2){
        ll ans = 0;
        rep(i, n){
            if((s[i] - '0') % 2 == 0){
                ans += (n - i);
            }
        }
        cout << ans << endl;
    } else if(p == 5){
        ll ans = 0;
        rep(i, n){
            if(s[i] == '0' || s[i] == '5'){
                ans += (n - i);
            }
        }
        cout << ans << endl;
    }
} 

Measured memory_bytes: 2692
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map { it.toLong() }
    fun calc(x: Long): Long{
        return when {
            x <= 0L -> 0L
            x % 2 == 1L -> if((x + 1) / 2 % 2 == 0L) 0L else 1L
            else -> calc(x - 1) xor x
        }
    }

    println(calc(A - 1) xor calc(B))
}

Measured memory_bytes: 37904
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
char c[10][10];
int l[10],r[10];
int aaa[114514];
signed main(){
	ic(n) ic(a) ic(b)
	a=a+b;
	int bb=0; 
	sc(s)
	rep(0,i,n){
		if(s[i]=='a'&&a>0){
			a-=1;
			aaa[i]=1;
		}	
		if(s[i]=='b'&&a>0&&bb<b){
			a-=1;
			bb++;
			aaa[i]=1;
		}	
	}
	rep(0,i,n){
		if(aaa[i]==1)c("Yes")
		else c("No")
	}		
}	


Measured memory_bytes: 1664
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a = inp[0]
b = inp[0]
if(a>b)
  puts "GREATER"
elsif(a<b)
  puts "LESS"
else
  puts "EQUAL"
end


Measured memory_bytes: 2044
#intの場合


huga = list(map(int, input().split()))

if huga[0] == 0:
    print(1)
if huga[1] == 0:
    print(2)
if huga[2] == 0:
    print(3)
if huga[3] == 0:
    print(4)
if huga[4] == 0:
    print(5)


Measured memory_bytes: 9084
#include <iostream>
#include <cstring>
using namespace std;
 
int main(){
int  n;
int m;
cin>>n;
if (n%2==0)
{
  m=n/2;
}
else m=n/2+1;
double p;
double q;
p=m;
q=n;

cout <<p/q;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp.split('')
ans = 0
num = 0
s.length.times do |x|
  if s[x] == 'I'
    num += 1
  elsif s[x] == 'D'
    num -= 1
  end
  ans = [ans,num].max
end

puts ans

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <string>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint c[200005];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> c[i];
	sort(c+1, c+n+1);
	reverse(c+1, c+n+1);
	
	
	llint inv4 = modpow(4, mod-2);
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		ans += inv4 * (i+1) % mod * c[i] % mod;
		ans %= mod;
	}
	ans *= modpow(2, 2*n), ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
long long h, ans;
long long hp(long long n){
    if(n == 1){
        return 1;
    }
    else{
        return (hp(n / 2)) * 2 + 1;
    }
}
void solve(){
    ans = hp(h);
    cout << ans << endl;
}
int main(){
    cin >> h;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,x,S=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x;
    if(x<K-x)S+=x;
    else S+=K-x;
  }
  cout<<S*2<<endl;
}

Measured memory_bytes: 384
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("story.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 2e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

ll cnt[nn];

int main()
{
	fast();
	//File();
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		cnt[arr[i]]++;
	}
	ll res = 0;
	for (int i = 1; i <= n; i++)
		res += cnt[i] * (cnt[i] - 1) / 2LL;
	for (int i = 0; i < n; i++)
	{
		cout << res - cnt[arr[i]] + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3968
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = new char[n];
        c = sc.next().toCharArray();
        int left = 0, right = n - 1;
        int res = 0;
        while(left < right) {
            if (c[left] == 'R') {
                left++;
                continue;
            }
            while(right > left && c[right] == 'W')
                right--;
            if(right > left)
                res++;
            left++;
            right--;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 41064
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef pair<ll,pair<ll,ll> > p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
const int MAX = 510000;

ll fac[MAX],finv[MAX],inv[MAX];
//http://drken1215.hatenablog.com/entry/2018/06/08/210000
//テーブルを作る前処理　O(n)
//pが素数でなくてはならない
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
//二項係数計算
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    vector<int> V;
    //前処理
    COMinit();
    int N;
    ll M;
    cin>>N>>M;
    for(ll i=2;i<=100000;i++){
        if(M%i==0){
            int count=0;
            while(M%i==0){
                count++;
                M/=i;
            }
            V.push_back(count);
        }
    }
    if(M!=1) V.push_back(1);
    ll ans=1;
    for(int i=0;i<(int)V.size();i++){
        ans*=COM(N+V[i]-1,V[i]);
        ans%=MOD;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 12160
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    string s;cin>>s;
    cout << "ABC" + s << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3608
def print_rec(H, W):
    print('#' * W)
    for _ in range(H-2):
        print('#' + '.' * (W-2) + '#')
    print('#' * W)

if __name__ == '__main__':
    input_buf = []
    while True:
        H, W = map(int, input().split())
        if (H, W) == (0, 0):
            break
        input_buf.append((H, W))
    for H, W in input_buf:
        print_rec(H, W)
        print()



Measured memory_bytes: 5624
#include <stdio.h>

#define PutChar(c) ; *p = (char)(c); ++p;

#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)

int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);

int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;

int main(void) {
	int i;
	int n;

	fread(str, 1, STR_SIZE, stdin);
	
	n = getNum();
	for (i = 1; i <= n; ++i) {
		A[i] = getNum();
	}
	
	CountingSort(A, B, MAX_Ai, n);
	
	p = str;
	--n;
	for (i = 1; i <= n; ++i) {
		putNum(B[i]);
		PutChar(' ');
	}
	putNum(B[i]);
	PutChar('\0');
	
	puts(str);
	
	return 0;
}

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	}
	++p;
	return n;
}

void putNum(int n) {
	int d;
	if (n < 10) {
		PutChar('0' + n);
		return;
	}
	d = n / 10;
	if (d) putNum(d);
	PutChar('0' + (n - (d * 10)));
}

void CountingSort(int A[], int B[], int k, int len) {
	int i;
	int C[MAX_Ai] = { 0 };
	for (i = 1; i <= len; ++i) {
		++C[A[i]];
	}
	for (i = 1; i <= k; ++i) {
		C[i] += C[i - 1];
	}
	for (i = 1; i <= len; ++i) {
		B[C[A[i]]] = A[i];
		--C[A[i]];
	}
}

Measured memory_bytes: 25648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static final boolean TEST = false;

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		System.out.println(solve(a));
		in.close();
	}

	private static long solve(int[] a) {
		long ans = 0;
		int chk = 0;
		int e = 0;
		for (int s = 0; s < a.length; s++) {
			for (; e < a.length; e++) {
				if ((chk & a[e]) > 0)
					break;
				chk |= a[e];
			}
			ans += (e - s);
			chk ^= a[s];
		}
		return ans;
	}
}


Measured memory_bytes: 83520
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    string S;
    cin >> N >> S;
    string abc = "ABC";
    ll ans = 0;
    for (ll i = 0; i + 3 <= S.size(); i++) {
        string subs = S.substr(i, 3);
        ans += (subs == abc);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def parseSpaceDivideIntArgs(arg):
    tmpArr = arg.split()
    ret = []
    for s in tmpArr:
        ret.append(int(s))
    return ret


def getArr2SpaceDivideStr(arg):
    ret = ""
    isFirst = True
    for s in arg:
        if not isFirst:
            ret += ' '
        else:
            isFirst = False
        ret += str(s)
    return ret


instr = input()
# instr = "10000 1000 100"

instrSpl = parseSpaceDivideIntArgs(instr)
instrSpl.sort()

print(getArr2SpaceDivideStr(instrSpl))



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
	//入力
	int n,ans;
  	cin >> n;
  	vector<int> N(n),C(n);
	ans = 0;
  	for(int k=0;k<n;k++) cin >> N.at(k);
  	for(int j=0;j<n;j++) cin >> C.at(j);
	
	//処理
	for (int i = 0; i < n; i++) {
		if (N.at(i) - C.at(i) > 0) ans += N.at(i) - C.at(i);
	}
	//出力
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int H,W,i,j;

while(1){
scanf("%d %d",&H, &W);

if(H == 0 && W == 0)break;

for ( i = 0; i < H; i++ ){
    for ( j = 0; j < W; j++ ){
        printf("#");
    }
    printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2040
a,b,c,x,y = list(map(int,input().split()))
output = 10000000000
if x > y:
  tmp = (y * min(a+b,c*2)) + ((x-y) * min(a,c*2))
  if output > tmp:
    output = tmp
else:
  tmp = (x * min(a+b,c*2)) + ((y-x) * min(b,c*2))
  if output > tmp:
    output = tmp

print(output)

Measured memory_bytes: 61876
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

s = input()

if s=='ARC':
    print('ABC')
else:
    print('ARC')

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<long long> a(n+1,0ll);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)a[i]+=a[i-1];
    vector<long long> v;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            v.push_back(a[j]-a[i]);
        }
    }
    //1e6個の数列が与えられるのでこの中からk個選んでsubsetをつくりそのANDを最大化する
    //上から貪欲にそのbitを立てられるか調べる
    long long res=0;
    for(long long b=60;b>=0;b--){
        vector<long long> vv;
        long long now=(1ll<<b);
        for(auto it:v)if(it&now)vv.push_back(it);
        if(vv.size()>=k){
            //cout<<b<<endl;
            res+=1ll<<b;
            v=vv;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6384
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <utility>

constexpr long double pi = std::acos(-1.0L);

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

  printf("%.20Lf\n", 2.0L*r*pi);
}


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

int main(){

	int count = 0;
	string needle = "";
	string word = "";
	cin >> needle;
	while (cin >> word, word != "END_OF_TEXT"){
		for (int i = 0; i < (int)word.size(); i++)
			word[i] = tolower(word[i]);
		if (word == needle){
			count++;
		}

	}

	cout << count << endl;
	return 0;

}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,x,y,i,j;
    i=0;
    j=0;
    cin>>t;
    while(t--)
    {
        cin>>x>>y;
        if(x==y)
            i++;
        else
            i=0;
            if(i==3)
                j=1;
    }
    if(j==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;

int N, M;
ll A[MAX];

ll solve() {
    priority_queue<ll> q;
    REP (i, N) q.push(A[i]);
    REP (m, M) {
        ll v = q.top(); q.pop();
        q.push(v/2);
    }
    ll ans = 0;
    while (!q.empty()) {
        ans += q.top(); q.pop();
    }
    return ans;
}

int main() {
    cin >> N >> M;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 2168
from collections import deque

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

if m % 2:
    print(-1)
    exit()

adj = [[] for _ in range(n + 1)]
for a, b in ab:
    adj[a].append(b)
    adj[b].append(a)

s = 1
dq = deque([s])
d = [-1] * (n + 1)
d[s] = 0
p = [-1] * (n + 1)
order = []
while dq:
    u = dq.popleft()
    order.append(u)
    for v in adj[u]:
        if d[v] == -1:
            d[v] = d[u] + 1
            p[v] = u
            dq.append(v)

out = [0] * (n + 1)
ans = []
for a, b in ab:
    if p[a] == b or p[b] == a:
        continue
    ans.append((a, b))
    out[a] ^= 1

for v in order[1:][::-1]:
    u = p[v]
    if out[v]:
        ans.append((v, u))
        out[v] ^= 1
    else:
        ans.append((u, v))
        out[u] ^= 1

for u, v in ans:
    print(u, v)


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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const ll MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

const ll MAX = 10000000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool check(ll x, ll y)
{
    ll amariX = x % 3;
    ll amariY = y % 3;
    if (amariX == 1 && amariY == 2)
    {
        return true;
    }
    if (amariX == 2 && amariY == 1)
    {
        return true;
    }
    if (amariX == 0 && amariY == 0)
    {
        return true;
    }
    return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll x, y;
    cin >> x >> y;
    if (!check(x, y))
    {
        cout << 0 << endl;
        return 0;
    }
    ll X, Y;
    X = (-x + 2 * y) / 3;
    Y = (2 * x - y) / 3;
    cout << COM(X + Y, X) << endl;
}


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

int main(){
	int n ;
	int a[101] ;

	cin >> n ; //1?????????????????????????????????
	//2?????????????????????????????????
	for( int i=1 ; i<=n ; i++ ){
		cin >> a[i] ;
		
	}
	//???????????¨???
	for( int i=n ; i>=1 ; i-- ){
		cout << a[i] ;
		
		if(i!=1){ cout << " " ; }
		
	}
	cout << endl ;
	
	return 0;
	 }
	

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 1e6+10;

int ns, nt;

vector<int> v[N];
vector<int> vis;

//Complexity is O(n)
vector<int> z_function(string &s, int n) {
   vector<int> z(n);
   for (int i=1, l=0, r=0; i<n; ++i) {
      if (i <= r) {
         z[i] = min(r-i+1, z[i-l]);
      }
      while (i+z[i]<n && s[z[i]] == s[i+z[i]]) {
         ++z[i];
      }
      if (i+z[i]-1 > r) {
         l = i, r = i+z[i]-1;
      }
   }

   for (int i = nt+1; i < n; ++i)
   {
      if(z[i] == nt){
         vis[(i-(nt+1))%ns] = 1;
      }
   }

   return z;
}

int indeg[N];
vector<int> topo; //Stores lexicographically smallest toposort
vector<int> g[N];

bool toposort(int n, int max_lim) //Returns 1 if there exists a toposort, 0 if there is a cycle
{  
   priority_queue<int, vector<int>, greater<int> > pq;
   for(int i=0;i<n;i++){
      for(auto &it:g[i])
         indeg[it]++;
   }
   for(int i=0;i<n;i++)
   {
      if(!indeg[i])
         pq.push(i);
   }
   while(!pq.empty())
   {
      int u=pq.top();
      pq.pop();
      topo.push_back(u);
      for(auto &v:g[u])
      {
         indeg[v]--;
         if(!indeg[v])
            pq.push(v);
      }
   }
   if(sz(topo) != max_lim)
      return 0;
   return 1;
}

int dp[N];

int go(int s){
   int &ans = dp[s];
   if(ans != -1)
      return ans;

   ans = 1;
   for(auto i: g[s]){
      smax(ans, go(i) + 1);
   }

   return ans;
}

void solve(){

   string s, t;
   cin >> s >> t;
   ns = sz(s), nt = sz(t);

   while(sz(s) <= ns + nt){
      s += s;
   }

   int n = sz(s);
   vis.resize(ns);

   string pt = t + '#' + s;
   z_function(pt, sz(pt));

   for (int i = 0; i < ns; ++i)
   {
      if(vis[i] and vis[(i+nt)%ns]){
         g[i].pb((i+nt)%ns);
         v[(i+nt)%ns].pb(i);
      }
   }

   bool bad = 1;
   for(auto i: vis)
      bad &= i == 0;

   if(bad){
      cout<<0;
      exit(0);
   }

   if(!toposort(ns, ns)){
      cout<<-1;
      exit(0);
   }

   // vector<int> dp(n, 1);
   reverse(topo.begin(), topo.end());

   memset(dp, -1, sizeof dp);

   int ans = 0;
   for (int i = 0; i < sz(topo); ++i)
   {
      smax(ans, go(i));
   }
   // for(auto i: topo){
   //    for(auto par: v[i]){
   //       smax(dp[par], dp[i] + 1);
   //    }
   // }

   // int ans = 0;
   // for(auto i: dp)
   //    smax(ans, i);

   cout<<ans;
}

int32_t main(){_

   solve();   

   return 0;
}

Measured memory_bytes: 109420
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
temp=[0]*(m-1)
for i in range(m-1):
  temp[i]=x[i+1]-x[i]
temp.sort()
if n>=m:
  print(0)
else:
  print(sum(temp[0:m-n]))

Measured memory_bytes: 13960
def alds11a
    n = gets.chomp.to_i
    an = gets.chomp.split(/\s/).map{|x| x.to_i}

    for i in 1..(n-1)
        puts an.join(' ')
        v = an[i]
        j = i - 1
        while j >= 0 and an[j] > v
            an[j+1] = an[j]
            j -= 1
        end
        an[j+1] = v
    end

    puts an.join(' ')
end

alds11a


Measured memory_bytes: 6892
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

vector<int> parse() {
  int n, x;
  cin >> n;
  vector<int> A;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    A.push_back(x);
  }
  return A;
}

int main() {
  auto A = parse();
  auto B = parse();
  vector<int> C(A.size() + B.size());
  auto last = set_union(A.begin(), A.end(), B.begin(), B.end(), C.begin());
  for (auto it = C.begin(); it != last; ++it)
    cout << *it << endl;
}



Measured memory_bytes: 5896
H, W = map(int, input().split())
if H == 1 or W == 1:
    ans = 1
else:
    if H % 2:
        if W % 2:
            ans = ((H // 2 + 1) * (W // 2 + 1)) + ((H // 2) * (W // 2))
        else:
            ans = ((H // 2 + 1) + (H // 2)) * (W // 2)
    else:
        ans = H / 2 * W
print(int(ans))


Measured memory_bytes: 2940