akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N = INT()
    A = LIST()
    count = 0
    for i, a in enumerate(A, start=1):
        if i % 2 == 1 and a % 2 == 1:
            count += 1
    print(count)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
#!/usr/bin/python3
import sys
from collections import Counter
input = lambda: sys.stdin.readline().strip()
n, p = [int(x) for x in input().split()]
s = input()
ans = 0
if p == 2 or p == 5:
    allowed_digits = '24680' if p == 2 else '50'
    for i, c in enumerate(s, start=1):
        if c in allowed_digits:
            ans += i
else:
    count = Counter({0: 1})
    x, e = 0, 1
    for c in reversed(s):
        x = (x + (ord(c) - ord('0')) * e) % p
        e = e * 10 % p
        ans += count[x]
        count[x] += 1

print(ans)


Measured memory_bytes: 9948
N,K=map(int,input().split())
A = list(map(int, input().split()))
i = 0
ans = 1000000000
while i <= N-K:
  d1 = abs(A[i])+(A[i+K-1]-A[i])
  d2 = abs(A[i+K-1])+(A[i+K-1]-A[i])
  ans = min(ans,d1,d2)
  i += 1
print(ans)

Measured memory_bytes: 14384
import sys
n = sys.stdin.readline().rstrip()
n_int = int(n)
if len(n)==1:
    print(n)
elif len(n)==2:
    print(9)
elif len(n)==3:
    print(n_int - 99 + 9)
elif len(n)==4:
    print(909)
elif len(n)==5:
    print(n_int - 9999 + 909)
else:
    print(90909)

Measured memory_bytes: 3060
def calc_sum_of_digits(num):
	ans = 0

	while True:
		if num // 10 == 0:
			ans += num
			break

		ans += num % 10
		num //= 10

	return ans



def main():
	N = int(input())

	sum_of_digits = calc_sum_of_digits(N)

	if N % sum_of_digits == 0:
		print("Yes")
	else:
		print("No")


  
if __name__ == "__main__":
  	main()

Measured memory_bytes: 9184
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int a, b, c;
	while (cin >> a >> b >> c, a || b || c) {
		int n; cin >> n;
		vector<int>i, j, k, ans(a + b + c + 1, 2);
		rep(x, 0, n) {
			int e, f, g, h;
			cin >> e >> f >> g >> h;
			if (h) {
				ans[e] = ans[f] = ans[g] = 1;
			}
			else {
				i.push_back(e);
				j.push_back(f);
				k.push_back(g);
			}
		}
		int m = i.size();
		for (int x = 0; x < m; x++) {
			int p(i[x]), q(j[x]), r(k[x]);
			if (ans[p] == 1 && ans[q] == 1 && ans[r] == 2) {
				ans[r] = 0;
			}
			else if (ans[p] == 1 && ans[q] == 2 && ans[r] == 1) {
				ans[q] = 0;
			}
			else if (ans[p] == 2 && ans[q] == 1 && ans[r] == 1) {
				ans[p] = 0;
			}

		}

		rep(x, 1, ans.size())cout << ans[x] << endl;

	}
	return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
char ch;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>ch;
	if(ch>='A'&&ch<='Z')
		cout<<'A'<<endl;
	else
		cout<<'a'<<endl;
	return 0;
}

Measured memory_bytes: 3648
def main():
    N = int(input())
    *V, = map(int, input().split())
    *C, = map(int, input().split())
    maxi = 0
    for i in range(N):
        if V[i] - C[i] > 0:
            maxi += (V[i] - C[i])
    print(maxi)
main()


Measured memory_bytes: 3060
import sys
import numpy as np

def fft_convolve(f, g):
    """
    数列 (多項式) f, g の畳み込みの計算．上下 15 bitずつ分けて計算することで，
    30 bit以下の整数，長さ 250000 程度の数列での計算が正確に行える．
    """
    fft = np.fft.rfft
    ifft = np.fft.irfft
    Lf = len(f)
    Lg = len(g)
    L = Lf + Lg - 1
    fft_len = 1 << L.bit_length()
    fl = f & (1 << 15) - 1
    fh = f >> 15
    gl = g & (1 << 15) - 1
    gh = g >> 15

    def conv(f, g):
        return ifft(fft(f, fft_len) * fft(g, fft_len))[:L]

    x = conv(fl, gl)
    y = conv(fl + fh, gl + gh)
    z = conv(fh, gh)
    a, b, c = map(lambda x: (x + .5).astype(np.int64), [x, y, z])
    return (a + ((b - a - c) << 15) + (c << 30))


ROOT=2
P=200003
pw=[1]*(P-1)
lg=[-1]*P

for i in range(1,len(pw)):
    pw[i]=ROOT*pw[i-1]%P
for i in range(len(pw)):
    lg[pw[i]]=i

N=int(input())
A=np.array([int(x) for x in input().split()],dtype=np.int64)
B=[0]*P
for a in A:
    if a==0:
        continue
    B[lg[a]]+=1
B=np.array(B,dtype=np.int64)
C=fft_convolve(B,B)
ans=0
for a in A:
    ans-=a*a%P
for i in range(len(C)):
    ans+=C[i]*pw[i%(P-1)]
ans//=2
print(ans)


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<p> v(q);
  for (int i = 0; i < q; i++) {
    cin >> v[i].first >> v[i].second;
  }
  vector<int> sum(n, 0);
  bool flag = false;
  int count = 0;
  for (int i = 0; i < n; i++){
    if(flag && s[i] == 'C'){
      flag = false;
      count++;
    }else if(s[i] == 'A'){
      flag = true;
    }else{
      flag = false;
    }
    sum[i] = count;
  }

  for (int i = 0; i < q; i++) {
    int l = v[i].first - 1;
    int r = v[i].second - 1;
    cout << sum[r] - sum[l] << endl;
  }
}


Measured memory_bytes: 2256
<?php
const MOD = 10 ** 9 + 7;
// 入力
fscanf(STDIN, '%s', $pass);

for ($i = 0; $i < strlen($pass) - 1; $i++) { 
    if ($pass[$i] === $pass[$i + 1]) {
        echo 'Bad'.PHP_EOL;
        exit();
    }
}
echo 'Good'.PHP_EOL;

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<pll> a(n);
  REP(i,n){
    ll ai;
    cin >> ai;
    a[i] = make_pair(i+1,ai);
  }
  sort(a.begin(),a.end(),[](pll n,pll m){return n.second<m.second;});
  REP(i,n){
    cout << a[i].first << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
int a[maxn];
vector<int> pos;
int good;
void go() {
    int len = pos.size();
    int l=-1,r=-1;
//    for(int i=0;i<len;i++) printf("%d ",pos[i]);
//    printf("\n");
    for(int i=0;i<len-1;i++) {
        if(pos[i]+1==pos[i+1]) {
            l = i;
            break;
        }
    }
    for(int i=len-1;i>=1;i--) {
        if(pos[i-1]+1==pos[i]) {
            r = i;
            break;
        }
    }
//    printf("\tl = %d r = %d\n",l,r);
    if(l==-1 && r==-1) {
        if(pos.size()==(n+1)/2) good = 1;
    }
    else {
        int pos1, pos2;
        if(l==0) pos1 = pos[0];
        else pos1 = (pos[0] + pos[l])/2;
        if(r==len-1) pos2 = pos[len-1];
        else pos2 = (pos[r] + pos[len-1])/2;
        good |= (pos1<=(n+1)/2 && (n+1)/2<=pos2);
    }
    pos.clear();
}
bool check(int val) {
    good = 0;
    int con = 0;
    for(int i=1;i<=n;i++) {
        if(a[i]>=val) {
            pos.push_back(i);
            con = 0;
        }
        else {
            ++con;
            if(con==2) go();
        }
    }
    go();
    return good;
}
int main() {
    scanf("%d",&n); n = n*2-1;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int l=1, r=n, mid, res=-1;
    while(l<=r) {
        mid = (l+r)/2;
        if(check(mid)) {
            res = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    printf("%d",res);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  string S, T; cin >> S >> T;
  
  string dest;
  for(int i=0; i<N; i++){
    dest += S[i];
    dest += T[i];
  }
  cout << dest;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    vector<int> num(301, 0);
    num[0] = 1;
    for(int i=1; i<=17; ++i){
        for(int j=0; j<300; ++j){
            int k = i*i + j;
            if(k <= 300)
                num[k] += num[j];
        }
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;
        cout << num[n] << endl;
    }
}

Measured memory_bytes: 0
import collections

n = int(input())
s = [sorted(input()) for i in range(n)]
s_ = [0 for i in range(n)]
alpha = 'abcdefghijklmnopqrstuvwxyz'
ans = []
for i in range(n):
    s_[i] = collections.Counter(s[i])
for i in alpha:
    tmp = 50
    for j in range(n):
        tmp = min(s_[j][i],tmp)
    if tmp > 0:
        ans.append(i*tmp)
print(''.join(map(str,ans)))

Measured memory_bytes: 3444
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

def resolve():
    n, k = LI()

    if n >= k:
        ans = 0
        for i in range(k):
            ans += (-1) ** i * combMod(k, k - i, MOD) * pow(k - i, n, MOD)
            ans %= MOD
    else:
        ans = 0

    print(ans)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6820
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main() {
  int counter = 0;
  string str;
  std::string ss [3];
  cin >> str;
  
  for (int i = 0; i < (int)str.size(); i++) {
    if (str[i] == '1') {
      counter++;
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = 10**9 +7
def fact(n):
  ret = 1
  for i in range(1, n + 1):
    ret *= i
  return ret
def com(n, r):
  if n - r < r: r = n - r
  ret = 1
  for i in range(n-r+1, n+1):
    ret *= i
    #ret %= p
  for j in range(1, r+1):
    ret //= j
  return ret# % p
for i in range(1,k+1):
  if n-k+1 >= i:
    print(com(n-k+1, i) * com(k-1, i-1) % p)
  else:
    print(0)

Measured memory_bytes: 45020
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	vi a(n);
	rep(i,0,n) cin >> a[i];
	sort(all(a));
	int res = 0;
	rep(i,0,k) {
		res += a[i];
	}
	cout << res << endl;
}

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

int main(){
    int n; cin>>n;
    vector<int> h(n);

    for(int i=0; i<n; i++)cin>>h[i];

    int count=0;   

    while(1){
        int i=0,ma = 0;

        for(int j=0; j<n; j++)ma = max(h[j],ma);

        if(ma == 0) break;

        while(i < n){
            if(h[i] == 0) i++;
            else{
                while(i<n && h[i] > 0){
                    h[i]--;
                    i++;
                }
                count++;
            }
        }

    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 2000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
int go[10][2],f[N][10]; char c[N];
int main()
{	go[0][0]=1; go[0][1]=2;
	go[1][0]=5; go[1][1]=0;
	go[5][0]=1; go[5][1]=1;
	go[2][0]=3; go[2][1]=4;
	go[3][0]=6; go[3][1]=2;
	go[6][0]=3; go[6][1]=3;
	go[4][0]=4; go[4][1]=4;
	scanf("%s",c+1); int n=strlen(c+1); f[0][0]=1;
	for(rint i=0;i<=n;i++)
	for(rint j=0;j<=6;j++)
	if(c[i+1]=='?') (f[i+1][go[j][0]]+=f[i][j])%=mod,(f[i+1][go[j][1]]+=f[i][j])%=mod;
	else (f[i+1][go[j][c[i+1]-'0']]+=f[i][j])%=mod;
	cout<<(f[n][2]+f[n][4])%mod;
	return 0;
}


Measured memory_bytes: 12928
#include<stdio.h>

int main()
{
  char s[100],t,u[10];
  int a;
  int i;
  a=0;
  scanf("%s",s);
  for(i=1;i<=100;i++){
    if(s[i+1]>0){
      a++;
    } else{
      t=s[i];
      break;
    }
  }
  
  printf("%c",s[0]);
  printf("%d",a);
  printf("%c",t);
  return 0;     
}


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

int main(){
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp = 0;
		if (a[i] == b[i]) tmp++;
		if (a[i] == c[i]) tmp++;
		if (b[i] == c[i]) tmp++;
		if (tmp == 3) ans += 0;
		else if (tmp == 1) ans += 1;
		else ans += 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

static inline void MainTask() {
  uint64_t N;
  cin >> N;
  uint64_t res = N * (N - 1) / 2;
  cout << res << endl;
}
int main() {
  MainTask();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m;
    while(cin >> n,n){
        cin >> m;
        int ans = 0;
        for(int i = n; i <= m; i++){
            int t = i;
            while(t % 2 == 0)t /= 2;
            while(t % 3 == 0)t /= 3;
            while(t % 5 == 0)t /= 5;
            if(t == 1)ans++;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int dp[100];
	for (int i = 0; i < 100; ++i) {
		dp[i] = 1e9;
	}
	dp[0] = 0;
	for (int i = 0; i <= 50; ++i) {
		dp[i + 2] = min(dp[i + 2], dp[i] + 380);
		dp[i + 3] = min(dp[i + 3], dp[i] + 550);
		dp[i + 5] = min(dp[i + 5], dp[i] + 850);
		dp[i + 10] = min(dp[i + 10], dp[i] + 380 * 4);
		dp[i + 12] = min(dp[i + 12], dp[i] + 1870);
		dp[i + 15] = min(dp[i + 15], dp[i] + 2244);
	}
	while (1) {
		int N; cin >> N;
		if (!N)break;
		N /= 100;
		cout << dp[N] << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
#include <stack>
using namespace std;
const int N=1e3;
int k[N];
int main()
{

   int a,b,c;
   int ans;
   scanf("%d %d %d",&a,&b,&c);
   int cnt=0;
  for(int i=1;i<=min(a,b);i++)
  {
      if(a%i==0&&b%i==0)
      {
          k[++cnt]=i;
      }
  }
  sort(k+1,k+1+cnt,greater<int >());
  printf("%d\n",k[c]);


   return 0;
}


Measured memory_bytes: 256
S = [int(i) for i in input()]
if(len(S)%2==0):
    s_01 = [0,1]*int((len(S)/2))
    s_10 = [1,0]*int((len(S)/2))
    acc_01 = sum([i==j for i,j in zip(S,s_01)])
    acc_10 = sum([i==j for i,j in zip(S,s_10)])
    print(min(len(S)-acc_01, len(S)-acc_10))
else:
    s_01 = [0,1]*int((len(S)/2))
    s_01.append(0)
    s_10 = [1,0]*int((len(S)/2))
    s_10.append(1)
    acc_01 = sum([i==j for i,j in zip(S,s_01)])
    acc_10 = sum([i==j for i,j in zip(S,s_10)])
    print(min(len(S)-acc_01, len(S)-acc_10))

Measured memory_bytes: 6300
function Zalgo(s)
	N=length(s)
	ret=zeros(Int,N)
	ret[1]=N
	i=1
	j=0
	while i<N
		while i+j<N&&s[j+1]==s[i+j+1]
			j+=1
		end
		ret[i+1]=j
		if j==0
			i+=1
			continue
		end
		k=1
		while i+k<N&&k+ret[k+1]<j
			ret[i+k+1]=ret[k+1]
			k+=1
		end
		i+=k
		j-=k
	end
	ret
end
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	B=map(x->parse(Int,x),split(readline()))
	a=zeros(Int,3N)
	for i=1:N
		a[i]=B[i]$B[mod1(i+1,N)]
		a[i+N]=a[i+2N]=A[i]$A[mod1(i+1,N)]
	end
	L=Zalgo(a)
	for k=1:N
		if L[k+N]>=N
			println("$(k-1) $(A[k]$B[1])")
		end
	end
end
main()

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

int main(){
  int N,L; cin >> N >> L;
  int aji=N*(L-1)+N*(N+1)/2;
  if(L<=0&&L+N-1>=0) cout << aji << endl;
  else if(L+N-1<0) cout << aji-(L+N-1) << endl;
  else cout << aji-L << endl;
  
}

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

int main() {
	int n;
	int count=0;
	cin >> n;
	int a[n],b[n];
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		count += b[i]-a[i]+1;  
	}
	cout << count << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> g(3*N);
    for (int i = 0; i < 3*N; ++i) {
        cin >> g[i];
    }
    SORT(g);
    ll ans = 0;
    int temp = 0;
    for (int i = 3*N-2; i >= 0; i-=2) {
        ans += g[i];
        temp++;
        if (temp == N)break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
  /* 配列の要素を交換する */
void Swap(double x[], int i, int j){
    int temp;
    temp = x[i];
    x[i] = x[j];
   x[j]=temp;
}

void QSort(double d[],int n){
  for(int i=0;i<n;i++){
    for(int s=n-1;s>i;s--){
    if(d[s-1]>d[s]){
      Swap(d,s-1,s);
    }
    }
  }
}
       


int main(){
  int n;
  double count=0.0;
  scanf("%d",&n);
  double d[n];
  for(int i=0;i<n;i++){
    scanf("%lf",&d[i]);
  }
  QSort(d,n); 
  count=d[0];
  for(int i=1;i<n;i++){
    count=(count+d[i])/2;
  }
  printf("%lf",count);
}
  
  
  
  
  
  
   
  
  
      
      
      

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

int main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  int n=s.size();
  for(int i=0;i<min(k,n);i++){
    if(s[i]=='1'){
      if(i+1==k){
        cout<<1<<endl;
        return 0;
      }
    }else {
      cout<<s[i]<<endl;
      return 0;
    }
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string A,B; cin>>A>>B;
	if(A.sz>B.sz) cout<<"GREATER";
	else if(A.sz<B.sz) cout<<"LESS";
	else{
		rep(i,A.sz){
			if(A[i]>B[i]){
				cout<<"GREATER";
				return 0;
			}
			else if(A[i]<B[i]){
				cout<<"LESS";
				return 0;
			}
		}
		cout<<"EQUAL";
	}
}

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

int main(void){
    int n;
    cin >> n;
    double ans = 0;
    vector<double> M(n);
    vector<string> S(n);
    for (int i = 0; i < n; i++){
        cin >> M.at(i) >> S.at(i);
        if(S.at(i)=="JPY")
            ans += M.at(i);
            else if(S.at(i)=="BTC")
                ans += M.at(i) * 380000.0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, nx[200005][70], ans = 1;
ll k;
int main(){
	scanf("%d%lld", &n, &k);
	rep(i,n) scanf("%d", nx[i+1]);
	rep(i,70) rep(j,n) nx[j+1][i+1] = nx[nx[j+1][i]][i];
	for(int i=0; k; i++, k/=2) if(k&1) ans = nx[ans][i];
	printf("%d\n", ans);
}

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

int main(){
  int n, d;
  cin >> n >> d;
  
  if(n % (2 * d + 1) == 0){
    cout << n / (2 * d + 1) << endl;
  }
  else{
    cout << n / (2 * d + 1) + 1 << endl;
  }
}

Measured memory_bytes: 256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <iterator>

#define all(x) x.begin(), x.end()
#define MOD 998244353
const unsigned int M = 1000000007;
const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;
#define MAX 50
using namespace std;
void printString(ll n)
{
    ll arr[10000];
    ll i = 0;


    while (n) {
        arr[i] = n % 26;
        n = n / 26;
        i++;
    }


    for (ll j = 0; j < i - 1; j++) {
        if (arr[j] <= 0) {
            arr[j] += 26;
            arr[j + 1] = arr[j + 1] - 1;
        }
    }

    for (ll j = i; j >= 0; j--) {
        if (arr[j] > 0)
            cout << char('A' + arr[j] - 1+32);
    }


}
void solve(){
   ll n;
   cin>>n;
   printString(n);

}


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

    int T = 1;
    solve();

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
signed main(){
  string S;
  cin>>S;
  reverse(S.begin(),S.end());
  int N=S.size();
  vector<vector<int>> A(N+1,vector<int>(13,0));
  A[0][0]=1;
  for(int i=1,k=1;i<=N;i++,k=k*10%13){
    if(S[i-1]!='?'){
      int n=(S[i-1]-'0')*k%13;
      for(int j=0;j<13;j++)
        A[i][(j+n)%13]=(A[i][(j+n)%13]+A[i-1][j])%mod;
    }else{
      for(int n=0;n<10;n++)
        for(int j=0;j<13;j++)
          A[i][(j+n*k)%13]=(A[i][(j+n*k)%13]+A[i-1][j])%mod;
    }
  }
  cout<<A[N][5]<<endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<ll> h;
  ll tmp;
  rep(i,n) {
    cin >> tmp;
    h.push_back(tmp);
  }
  sort(h.begin(),h.end());
  rep(i,k) h.pop_back();
  int size = h.size();
  ll count = 0;
  rep(i,size) count += h[i];
  cout << count;
  
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
string funkcija(string s,string k,int n)
{
	string ss=k;
	for(int i=2;i<s.size()-1;i++)
	{
		if(ss[i]=='S')
		{
			if(s[i]=='o')
				ss+=ss[i-1];
			else
			{
				if(ss[i-1]=='S')
					ss+='W';
				else
					ss+='S';
			}
		}
		else
		{
			if(s[i]=='x')
				ss+=ss[i-1];
			else
			{
				if(ss[i-1]=='S')
					ss+='W';
				else
					ss+='S';
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		int p=i-1;
			int m=i+1;
			if(p<0)
				p=n-1;
			if(m>=n)
				m=0;
		if(ss[i]=='S')
		{
			
			if(s[i]=='o')
			{
				if(ss[p]!=ss[m])
					return "0";
			}
			else
			{
				if(ss[p]==ss[m])
					return "0";
			}
		}
		else
		{
			if(s[i]=='o')
			{
				if(ss[p]==ss[m])
					return "0";
			}
			else
			{
				if(ss[p]!=ss[m])
					return "0";
			}
		}
	}
	return ss;
}
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<(1<<3);i++)
	{
		string ss="";
		for(int j=0;j<3;j++)
		{
			if(i&(1<<j))
				ss+='S';
			else
				ss+='W';
		}
		if(ss[1]=='S')
		{
			if(s[1]=='o')
			{
				if(ss[0]==ss[2])
				{
					if(funkcija(s,ss,n)!="0")
					{
						cout<<funkcija(s,ss,n)<<endl;
						return 0;
					}
				}
			}
			else
			{
				if(ss[0]!=ss[2])
				{
					if(funkcija(s,ss,n)!="0")
					{
						cout<<funkcija(s,ss,n)<<endl;
						return 0;
					}
				}
			}
		}
		else
		{
			if(s[1]=='o')
			{
				if(ss[0]!=ss[2])
				{
					if(funkcija(s,ss,n)!="0")
					{
						cout<<funkcija(s,ss,n)<<endl;
						return 0;
					}
				}
			}
			else
			{
				if(ss[0]==ss[2])
				{
					if(funkcija(s,ss,n)!="0")
					{
						cout<<funkcija(s,ss,n)<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 832
N=int(input())
K=-1
for k in range(2,2+int((2*N)**0.5)):
    if k*(k-1)==2*N:
        K=k
if K==-1:
    print("No")
else:
    print("Yes")
    print(K)
    ans=[[] for i in range(K)]
    now=1
    for i in range(K-1):
        for j in range(i+1,K):
            ans[i].append(now)
            ans[j].append(now)
            now+=1
    for L in ans:
        print(str(len(L))+" "+" ".join(map(str,L)))

Measured memory_bytes: 9076
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e5;

int main() {
    int m, n; cin >> n >> m;
    vector<int> sum(n, 0);
    for (int i = 1; i < n; i++) {
        int dist; cin >> dist;
        sum[i] = sum[i - 1] + dist;
    }
    int ans = 0, pos = 0;
    for (int i = 0; i < m; i++) {
        int a; cin >> a;
        if (a > 0) ans = (ans + sum[pos + a] - sum[pos]) % MOD;
        else ans = (ans + sum[pos] - sum[pos + a]) % MOD;
        pos += a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
void sort(int *x, int left, int right){
  int pivot,left_hold,right_hold;
  
  left_hold = left;
  right_hold = right;
  pivot = x[left];
  while(left < right){
    while((x[right]>=pivot)&&(left<right))
      right--;
    if(left!=right){
      x[left] = x[right];
      left++;
    }
    while((x[left]<=pivot)&&(left<right))
      left++;
    if(left!=right){
      x[right]=x[left];
      right--;
    }
  }
  x[left] = pivot;
  pivot = left;
  left = left_hold;
  right = right_hold;
  if(left<pivot)
    sort(x,left,pivot-1);
  if(right>pivot)
    sort(x,pivot+1,right);
}
main(){
  int N,N1,S=0;
  scanf("%d",&N);
  N1=N;
  do{
    S += N%10;
    N/=10;
  }while(N!=0);
  if(N1%S==0)
    printf("Yes\n");
  else
    printf("No\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int dp[1000001];
void init()
{
	memset(dp,0x7f7f7f7f,sizeof(dp));
	dp[1]=1;
	int i=6;
	while(i<=n){
		dp[i]=1;
		i*=6;
	}
	i=9;
	while(i<=n){
		dp[i]=1;
		i*=9;
	}
}
int main()
{
	scanf("%d",&n);
	init();
	for(int i=1;i<=n;i++) 
	{
		if(dp[i]<2139062143)continue;
		dp[i]=min(dp[i],dp[i-1]+1);
		int j=6;
		while(i-j>=1){
			dp[i]=min(dp[i],dp[i-j]+1);
			j*=6;
		}
		j=9;
		while(i-j>=1){
			dp[i]=min(dp[i],dp[i-j]+1);
			j*=9;
		}
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4096
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      k: usize,
    }

    for i in 0..n+1 {
        for j in 0..m+1 {
            let black = m*i + n*j - 2*i*j;
            if black == k {
                return puts!("{}\n", "Yes");
            }
        }
    }
    puts!("{}\n", "No");
}


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

int N;
int A;
int B;

int main() {
  cin >> N >> A >> B;
  int sum = 0;

  for (int i = 1; i <= N; i++) {
    int num = i;
    int sumOfEachDigit = 0;
    while (num != 0) {
      sumOfEachDigit += (num % 10);
      num /= 10;
    }

    if (A <= sumOfEachDigit && sumOfEachDigit <= B) {
      sum += i;
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();

        List<Integer> smalls = new ArrayList<>();
        List<Integer> larges = new ArrayList<>();
        List<Integer> sames = new ArrayList<>();
        int min = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int data = scanner.nextInt();
            int remain = data - a;
            if (remain > 0) {
                max += remain;
                larges.add(remain);
            } else if (remain < 0) {
                min += remain;
                smalls.add(-remain);
            } else {
                sames.add(remain);
            }
        }
        BigDecimal sameB = new BigDecimal(1);
        for (int i = 1; i <= sames.size(); i++) {
            sameB = sameB.add(count(sames.size(), i));
        }
        BigDecimal result = new BigDecimal(0);
        result = result.add(sameB).subtract(new BigDecimal(1));

        max = Math.min(max, -min);
        BigDecimal[][] cache2 = new BigDecimal[50][max + 1];
        BigDecimal[][] cache3 = new BigDecimal[50][max + 1];
        for (int i = 1; i <= max; i++) {
            BigDecimal r = find(larges, 0, i, cache2);
            if (r.compareTo(new BigDecimal(0)) == 0) {
                continue;
            }
            BigDecimal r2 = find(smalls, 0, i, cache3);
            if (r2.compareTo(new BigDecimal(0)) == 0) {
                continue;
            }
            result = result.add(r.multiply(r2).multiply(sameB));
        }

        System.out.println(result);

    }

    static BigDecimal[][] cache = new BigDecimal[51][51];

    private static BigDecimal find(List<Integer> datas, int index, int target, BigDecimal[][] cache) {
        if (target == 0) {
            return new BigDecimal(1);
        }
        if (datas.size() == index) {
            return new BigDecimal(0);
        }
        if (cache[index][target] != null) {
            return cache[index][target];
        }

        BigDecimal r = new BigDecimal(0);
        Integer integer = datas.get(index);
        if (target - integer >= 0) {
            BigDecimal rr = find(datas, index + 1, target - integer, cache).add(
                    find(datas, index + 1, target, cache));
            cache[index][target] = rr;
            return rr;
        } else {
            BigDecimal rr = find(datas, index + 1, target, cache);
            cache[index][target] = rr;
            return rr;
        }
    }

    private static BigDecimal count(int c1, int c2) {
        int c3 = c1 - c2;
        c2 = Math.min(c2, c3);
        if (cache[c1][c2] != null) {
            return cache[c1][c2];
        }
        BigDecimal r = new BigDecimal(1);
        for (int i = 0; i < c2; i++) {
            r = r.multiply(new BigDecimal(c1 - i));
        }
        for (int i = 0; i < c2; i++) {
            r = r.divide(new BigDecimal(c2 - i));
        }
        return r;
    }
}

Measured memory_bytes: 12748
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const ll Mod = (ll)1e9 + 7;
ll addMod (ll a, ll b) { return (a + b) % Mod; }
ll addTo (ll& a, ll b) { return a = (a + b) % Mod; }
ll mulMod (ll a, ll b) { return (a * b) % Mod; }
ll mulTo (ll& a, ll b) { return a = (a * b) % Mod; }
ll binExp (ll a, ll b) {
	ll res = 1, x = a;
	while (b) {
		if (b & 1) mulTo(res, x);
		mulTo(x, x);
		b >>= 1;
	}
	return res;
}

const int N = 200010;
ll n, c[N];

ll calc (int i) {
	ll res = mulMod(c[i], binExp(2, n - i));
	ll t = addMod(mulMod(i - 1, binExp(2, i - 2)), binExp(2, i - 1));
	return mulMod(res, t);
}

int main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &c[i]);
	sort(c + 1, c + n + 1);
	reverse(c + 1, c + n + 1);
	ll ans = mulMod(c[1], binExp(2, n - 1));
	for (int i = 2; i <= n; i++) addTo(ans, calc(i));
	mulTo(ans, binExp(2, n));
	printf("%lld\n", ans);
}



Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#define MAX 100
#define WHILE 0
#define GRAY 1
#define BLACK 2
#define INFTY -1
//flooat inf=INFINITY;
int inf=(1<<21);
int n,a[MAX][MAX];

int prim(){
  int i,u,v,mincost,sum=0;
  int color[MAX],d[MAX];

  for(i=0;i<n;i++){
    d[i]=inf;
    color[i]=WHILE;
  }
  d[0]=0;
  while(1){
    mincost=inf;
    u=-1;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==inf) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && a[u][v]!=inf){
	if(d[v]>(d[u]+a[u][v])){
	  d[v]=a[u][v]+d[u];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INFTY)printf("-1\n");
    else printf("%d\n",d[i]);
  }

  return sum;
}

int main(){
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=inf;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      a[u][v]=c;
    }
  }
  
  prim();
  return 0;
}
    



Measured memory_bytes: 2060
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep (i, N) cin >> A[i];
  vector<ll> acc(N+1);
  acc[0] = 0;
  rep (i, N) acc[i+1] = acc[i] + A[i];

  vector<ll> nums;
  for (ll i = 1; i < N + 1; i++) for (ll j = 0; j < i; j++) nums.push_back(acc[i] - acc[j]);

  for (auto it: nums) cerr << it << " ";
  cerr << endl;

  ll max_num = 0;
  for (auto it: nums) max_num = max(max_num, it);

  ll foo = 1;
  while (foo < max_num) foo *= 2;

  cerr << "max_num: " << max_num << ", foo: " << foo << endl;

  while (foo) {
    ll count = 0;
    for (auto it: nums) if (it & foo) count++;
    if (count >= K) {
      vector<ll> next_nums;
      for (auto it: nums) if (it & foo) next_nums.push_back(it);
      nums = next_nums;
    }
    foo /= 2;
  }

  ll ans = nums[0];
  rep (i, K) ans = ans & nums[i];
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 6512
//containing t test cases
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
//#define int long long
using namespace std;
//typedef vector<int>vi ;
typedef vector<ll>vi ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
int main()
{
	fast;
	ll test=1;
	//cin>>test;
	while(test--)
	{
		ll k;
		string s;
		cin>>k>>s;
		if(k>=s.size())
			cout<<s;
		else
		{
			string s1=s.substr(0,k);
			cout<<s1<<"...";
		}
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main() {
    int A, B; cin >> A >> B;
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
        ans += max(A, B);
        if (A > B) A--;
        else B--;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

             
        
int main() {
			   fast
            //    #ifndef ONLINE_JUDGE
            //    freopen("input.txt","r",stdin);
            //    freopen("output.txt","w",stdout);
            //    #endif
               
                   double r;
                   cin>>r;
                   double ans=2.0 *r*3.14159;
                   cout<<fixed<<setprecision(4)<<ans;
                

                return 0;
            }


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  if(s=="Sunny"){
    puts("Cloudy");
  }else if (s=="Cloudy"){
    puts("Rainy");
  }else{
    puts("Sunny");

  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
//istringstream iss(sentence);
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
  
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;

map<pair<long long, long long>, pair<int, int> >  fam;

long long modpow(long long x, long long n) { 
  if (n == 0) return 1LL%mod; 
  long long u = modpow(x,n/2LL); 
 
  u = (long long)(u*u)%mod; 
  if (n%2LL == 1) u = (long long)(u*x)%mod; 
  return u;
}

int main(){
    prep();
    int n;
    cin >> n;
    long long zeroleft = 0;
    long long zeroright = 0;
    int just0 = 0;
    for (int i=0; i<n; i++){
        long long a, b;
        cin >> a >> b;
        
        if (a == 0 && b == 0) just0++;
        else if (a == 0) zeroleft++;
        else if (b == 0) zeroright++;
        else{
            long long gcdd = __gcd(abs(a), abs(b));
            a /= gcdd;
            b /= gcdd;
            int odd = ((a < 0)+(b < 0))%2;
            if (odd == 0) fam[{abs(a), abs(b)}].first++;
            else fam[{abs(b), abs(a)}].second++;
        }
    }
    long long res = mymod(modpow(2, zeroleft)+modpow(2, zeroright)-1);
    for (pair<pair<long long, long long>, pair<int, int> > p : fam){
       long long oddrev = p.second.first;
        long long evrev = p.second.second;
        res *= mymod(modpow(2, oddrev)+modpow(2, evrev)-1);
        res = mymod(res);
    }
    
    
    //cout << zeroleft << " " << zeroright << endl;
    cout << mymod(res-1+just0);
}

Measured memory_bytes: 16028
import sys
input = sys.stdin.readline
# 振るの最強の剣の振ったダメージより強い投げるものを投げ続け、なくなったら振り続け、それを投げるよりも体力が減った段階で投げる
# フル強さが最強なのが複数あったら投げる強さが一番弱いやつを使う
n, h = map(int, input().split())
swords = []
for i in range(n):
    li = list(map(int, input().split()))
    li.insert(0, i)
    tu = tuple(li)
    swords.append(tu)
# 振るのが最強、投げるのはその中で最弱
sorted_by_slash = sorted(swords, key=lambda tu: (tu[1], -tu[2]))
max_slash = sorted_by_slash[len(sorted_by_slash) - 1]
sorted_by_throw = sorted(swords, key=lambda tu: tu[2])
sorted_by_throw.reverse()
hp = h
ans = 0
slash_damage = max_slash[1]
slash_id = max_slash[0]
for s in sorted_by_throw:
    throw_damage = s[2]
    id = s[0]
    # 振ると便利なやつは後にとっておく
    # TODO: 投げるだけで片のつく敵は投げた方が良い
    if slash_id == id:
        continue
    if slash_damage > throw_damage:
        break
    ans += 1
    hp -= throw_damage
    if hp <= 0:
        print(ans)
        exit()
# 振って最強の武器を投げた時の分を最後に投げる分を最初に計算しておく
ans += 1
hp -= max_slash[2]
if hp <= 0:
    print(ans)
    exit()

ans += ((hp - 1) // slash_damage) + 1

print(ans)


Measured memory_bytes: 33076
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  a, b, ticket ,f=1000000,s=1000000; 
    cin >> a >> b >> ticket ; 
    vi  A(a),B(b);
    for (int &i: A) {
        cin>>i; 
        f = min(f,i);
    }
    for (int &i: B) {
        cin>>i; 
        s = min(s,i);
    }
    int ans=1000000;
    while (ticket--){
        int a,b,c;
        cin >> a >> b >> c ; 
        a--,b--;
        ans = min(A[a]+B[b]-c,ans);
    }
    cout << min(ans,f+s) << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4792
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  int n,k;
  int count=1;
  
  cin>>n>>k;
  
  while(n/k>0)
  {
    n=n/k;
    count++;
  }
  
  cout<<count<<endl;

  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            if (s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D') {
                cnt++;
            }
        }
        else {
                if (s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D') {
                cnt++;
                
            }
        }
    
    }
    if (cnt == s.size()) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 String a = sc.next();
		 int count = 0;
		 int compare = 0;
		 String[] aArray = new String[a.length()];

		 for(int i = 0; i < a.length() ; i++){
			 aArray[i] = String.valueOf(a.charAt(i));

			 if(aArray[i].equals("A") || aArray[i].equals("T") || aArray[i].equals("G") || aArray[i].equals("C")){
				 count= count + 1 ;
			 }
			 else{
				 if(compare < count){
					 compare = count;
					 count = 0;
				 }
				 else{
					 count = 0;
				 }

			 }
		 }
		 if(compare < count){
			 compare = count;
		 }
		 System.out.println(compare);
	}
}


Measured memory_bytes: 23120