akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int h, w;
	char m[101][101];
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cin >> m[j][i];
		}
	}

	for(int i = 0;i < h;i++){
		if(i == 0){
			for(int j = 0;j < w+2;j++){
				cout << "#";
			}
			cout << endl;
		}
		for(int j = 0;j < w;j++){
			if(j == 0) cout << "#";
			cout << m[j][i];
		}
		cout << "#" << endl;
	}

	for(int j = 0;j < w+2;j++){
				cout << "#";
			}
			cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;


int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    bool ans = false;
    rep(i,n)cin>>a[i];
    int f = 0;
    int d = 0;
    int c = 0;
    rep(i,n){
        if(a[i]%4==0){
            f++;
        }
        else if(a[i]%2==0){
            d++;
        }
        else{
            c++;
        }
    }
    if(f>=c){
        ans = true;
    }
    if(f+1==c&&d==0)ans = true;
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
res = 10 ** 9
for a in A:
    if a % 2 == 1:
        print(0)
        exit()
    tmp = 0
    while a % 2 == 0:
        tmp += 1
        a //= 2
    res = min(res, tmp)
print(res)


Measured memory_bytes: 9052
N = int(input())
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

LineScore = [[ 0 for i in range(0, N)] for i in [0, 1]]
LineScore[0][0] = A[0][0]
LineScore[1][N - 1] = A[1][N - 1]

for i in range(1, N):
    LineScore[0][i] = LineScore[0][i - 1] + A[0][i]
    LineScore[1][N - 1 - i] = LineScore[1][N - i] + A[1][N - 1 - i]

Score = max([LineScore[0][i] + LineScore[1][i] for i in range(0, N)])

print(Score)


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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

bool ans = true;

bool solve(){
  // main algorithm
  sort(A, A + N);
  if(A[N-1] - A[0] > 1){
    return false;
  }else if(A[N-1] - A[0] == 1){
    ll x = distance(A, lower_bound(A, A + N, A[N-1]));
    // DUMP(x);
    return N - 2 * A[N-1] + x >= 0 && A[N-1] - x > 0;
  }else{
    return N >= 2 * A[0] || N == A[0] + 1;
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  if(ans) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &A[i]);
  }
  ans = solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	int d,t,s;
	cin >> d >> t >> s;
	
	if(d > t*s){
		cout << "No\n";
	}else{
		cout << "Yes\n";
	}
	
	return 0;
}

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

void solve() {
	int n, q; cin >> n >> q;
	string str; cin >> str;
	vector<int> s(n + 1, 0);
	for (int i = 0; i < n - 1; i++) {
		if (str[i] == 'A' && str[i + 1] == 'C') s[i + 1] = s[i] + 1;
		else s[i + 1] = s[i];
	}

	int l, r;
	rep(i, q) {
		scanf("%d%d", &l, &r);
		l--; r--;
		printf("%d\n", s[r] - s[l]);
	}
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define N 200100

struct edge {int nex,to;}e[N<<1];
int n,m,cnt,he,ta;
char s[N];
int sum[N][2],head[N],q[N],inq[N];

void add(int x,int y) {e[++cnt].to=y; e[cnt].nex=head[x]; head[x]=cnt;}

int x,y;
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=m;i++) {
		scanf("%d%d",&x,&y);
		sum[x][s[y]-'A']++;
		sum[y][s[x]-'A']++;
		add(x,y); add(y,x);
	}
	for (int i=1;i<=n;i++)
		if (!sum[i][0] || !sum[i][1]) {
			q[++ta]=i;
			inq[i]=1;
		}
	
	while (he<ta)
	{
		int x=q[++he];
		for (int i=head[x];i;i=e[i].nex)
		{
			int v=e[i].to;
			if (!inq[v])
				if (--sum[v][s[x]-'A']==0) 
					q[++ta]=v,inq[v]=1;
		}
	}
	
	for (int i=1;i<=n;i++)
		if (!inq[i])
			return puts("Yes"),0;
	return puts("No"),0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  string S;
  cin>>S;
  int t=S.size();
  for(int i=0;i<t;i++){
    if(S.at(i)=='?') S.at(i)='D';
  }
  cout<<S;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll l,r;
    cin >> l >> r;
    if (r-l>=2019 || l%2019>r%2019) cout << 0 << endl;
    else {
        int ans=2018;
        int ll=l%2019,rr=r%2019;
        repr(i,ll,rr+1) {
            repr(j,i+1,rr+1) ans=min(ans,(i*j)%2019);
        }
        cout << ans << endl;
    }

    
    
    return 0;  
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define test() ll tc;cin>>tc;while(tc--)
using namespace std;


///dp[i] is the number of ways the womens in set i can be assigned to the ///first/// j mens
///such that each women gets a men she likes. Note that this may be 00 if no such assignment is possible.









void add_self(int &a,int b)
{
    a+=b;
    if(a>mod)
    {
        a-=mod;
    }
}


int main()
{
    int n;
    scanf("%d",&n);
    vector<vector<int>> can(n,vector<int>(n));
    f(i,0,n)
    {
        f(j,0,n)
        {
            scanf("%d",&can[i][j]);
        }
    }
    ///1<<n=2^n
    vector<int> dp(1<<n);
    dp[0]=1;
    ///mask represent women that aren't yet matched
    ///mask=000 no women is paired,001 means 1st women is paired,010 means 2nd women is paired
    ///a denotes the first mens whom which womens are paired
    ///m2 is mask after women is paired with new men
    f(mask,0,(1<<n)-1)
    {
        //cout<<"mask= "<<mask<<endl;
        int a = __builtin_popcount(mask);
        f(b,0,n)
        {
            //cout<<"a= "<<a<<endl;
            if(can[a][b] && !(mask & (1<<b) ))///if can[a][b] =1 and women is not paired yet
            {
                int m2 = mask | (1<<b); /// m2 is new mask , women is paired
                //cout<<"m2= "<<m2<<endl;
                //dp[m2]+=dp[mask];
                add_self(dp[m2],dp[mask]);///dp[m2]=(dp[m2]+dp[mask])%mod
                //cout<<"dp[m2] = "<<dp[m2]<<endl;
            }
        }

    }
    /*f(i,0,(1<<n))
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/
    cout<<dp[(1<<n)-1];
    return 0;
}



Measured memory_bytes: 11412
#include <stdio.h>
int main(void){
    int N;
    long L[87];
    L[0]=2;
    L[1]=1;
    int i=2;
    scanf("%d",&N);
    while(i<N+1){
        L[i]=L[i-1]+L[i-2];
        i++;
    }
    printf("%ld\n",L[N]);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
count= 0
while(True):
    exist_odd = False
    for i in range(N):
        if(A[i]%2 != 0):
            exist_odd = True
    if(exist_odd == True):
        break
    for i in range(N):
        A[i] /= 2
    count += 1
print(count)


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static int numberOfSwap = 0;

    static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] A =  Console.ReadLine().Split(' ')
                                     .Select(val => int.Parse(val))
                                     .ToArray();
        BubbleSort(ref A, n);
        Console.WriteLine(string.Join(" ", A.Select(val => val.ToString()).ToArray()));
        Console.WriteLine(numberOfSwap);
    }

    static void BubbleSort(ref int[] arr, int n){
        bool flag = true;
        while(flag){
            flag = false;
            for (int i = n - 1; i >= 1 ; i--)
            {
                if(arr[i] < arr[i - 1]){
                    Swap(ref arr, i, i - 1);
                    flag = true;
                }
            }
        }
    }

    static void Swap(ref int[] arr, int index1, int index2){
        int tmp = arr[index1];
        arr[index1] = arr[index2];
        arr[index2] = tmp;
        numberOfSwap++;
    }
}

Measured memory_bytes: 9544
import io, sys, itertools
f = sys.stdin


def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)


n = int(f.readline())
adj =[[(v, c) for v, c in take2(map(int, f.readline().split()[2:]))] for _ in range(n)]
d = [100000 * 100 + 1] * n

d[0] = 0
def search(parent, children):
    global d
    for v, c in children:
        if d[v] > d[parent] + c:
            d[v] = d[parent] + c
            search(v, adj[v])
    
search(0, adj[0])
    
for i in range(n):
    print(i, d[i])

Measured memory_bytes: 7176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
int main() {
	int n, ans = 0, A[101];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	for (int i = 0; i < n; i++)
		ans += A[i];
	sort(A, A + n);

	if (ans % 10 != 0) {
		cout << ans << endl;
		return 0;
	}
	else
		for (int i = 0; i < n; i++)
			if ((ans - A[i]) % 10 != 0) {
				cout << ans - A[i] << endl;
				return 0;
			}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    private void execute() throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] v = sc.nextLine().split(" ");
        ArrayList<Integer> iv = new ArrayList<>();
        for (String sv : v) {
            iv.add(Integer.parseInt(sv));
        }
        Collections.sort(iv);
        double result = iv.remove(0);
        for (int i : iv) {
            result = (result + i) / 2;
        }
        System.out.println(result);
    }

    public static void main(String[] args) {
        try {
            new Main().execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}


Measured memory_bytes: 21716
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef unsigned long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	string s;
	cin >> s;
	string a;
	a.resize(s.size(), 'x');
	cout << a << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve() {
    int N; cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }

    if(a[0]!=0){
        cout<<-1<<endl;
        return;
    }

    ll ans=0ll;
    int cnt=0;
    for (int i = 1; i < N; ++i) {
        if(a[i]>i||a[i]-a[i-1]>1){
            cout<<-1<<endl;
            return;
        }
        if(a[i]==0){
            ans+=cnt;
            cnt=0;
        }else if(a[i]-a[i-1]==1){
            cnt++;
        }else if(a[i]==a[i-1]){
            cnt++;
            ans+=a[i]-1;
        }else if(a[i]<a[i-1]){
            ans+=cnt;
            cnt=a[i];
        }
        //cout<<ans<<" "<<cnt<<endl;
    }
    ans+=cnt;
    cout<<ans<<endl;

}


#define SINGLE
int main() {
#ifdef SINGLE
    solve();
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 4052
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	bool ex = false;
	int a, b;
	cin >> a >> b;
	
	REP(i, 20000){
		if((int)(i * 0.08) == a && (int)(i * 0.1) == b){
			ans = i;
			ex = true;
			break;
		}
	}
	if (ex) cout << ans << endl;
	else cout << "-1" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
t = [0]*n
f = 1
mod = 10**9+7
for i in range(2,n+1):
  fa = 1
  while i > 1:
    fa += 1
    while i % fa == 0:
      i = i//fa
      t[fa-2] += 1

for j in range(n):
  f = f*(t[j]+1)%mod
print(f)

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

int f(int i,string s){
    if(s.at(i)==s.at(i+1) && s.at(i)=='0'){
        s.at(i+1)='1';
        return 1;
    }else if(s.at(i)==s.at(i+1) && s.at(i)=='1'){
        s.at(i+1)='0';
        return 1;
    }
    return 0;
}

string g(int i,string s){
    if(s.at(i)==s.at(i+1) && s.at(i)=='0'){
        s.at(i+1)='1';
        return s;
    }else if(s.at(i)==s.at(i+1) && s.at(i)=='1'){
        s.at(i+1)='0';
        return s;
    }
    return s;
}

int main(){
    string s;
    int count=0;
    cin >> s;
    for(int i=0;i<s.size()-1;i++){
        count+=f(i,s);
        s=g(i,s);
    }
    cout << count;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,k;
bool flag;
int main()
{
    sc2(n,k);
    int tot=0;
    while(n){
        n/=k;
        tot++;
    }
    pf(tot);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>())
#define FR(A, e) for (auto& e : A)
#define SHOW(A) for (auto& e : A) {cout << e << " ";}; cout << endl;
#define within(x,_left,_right) (_left <= x && x <= _right)
#define ALL(A) A.begin(),A.end()
#define pb push_back
#define sz(x) ((int)x.size())
#define fi first
#define se second
using LL = long long;
using db = double;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VL = vector<LL>;
using VVL = vector<VL>;
const LL MOD = 1e9 + 7;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::pair<int, char> PIC;
using std::cin;
using std::vector;
using std::cout;
using std::endl;
// int dx[4] = {1, -1, 0, 0}; // 冯诺依曼型邻居
// int dy[4] = {0, 0, 1, -1};
// int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; // 摩尔型邻居
// int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
// 字符串类:模拟规律 -> Greedy -> dp -> kmp || Automation (注意数据量， 先数学后暴力)
// #include<iomanip> cout << fixed <<  setprecision(k) 输出k位精度


inline int gcd_3(int x, int y, int z) {
	while (y ^= x ^= y ^= x %= y);
	while (z ^= x ^= z ^= x %= z);
	return x;
}

int main() {
	int k;
	cin >> k;
	int ans = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			for (int e = 1; e <= k; ++e) {
				ans += gcd_3(i, j, e);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
//***Bismillahir Rahmanir Rahim***//

//*********************************//
//******Ashraful Haque Toni********//
//********Dept. of CSE,JnU*********//
//email:ashrafulhaquetoni@gmail.com//
//*******contact:01640690531*******//
//*********************************//


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb push_back
#define         mp make_pair
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d%d",&m,&n);
#define         sc2l(m,n) scanf("%I64d%I64d",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

typedef long long ll;


int main()
{
    ash;
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='x')sum++;
    }
    if(sum>=8)cout<<"NO\n";
    else cout<<"YES\n";



    return 0;
}




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

int main() {
  int N;
  cin >> N;
  
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  
  double ans = v.at(0);
  for (int i = 1; i < N; i++) {
    ans = (ans + v.at(i)) / 2;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>

using namespace std;

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

  int A[n + 1][n + 1];
  for (auto row : A) {
    fill(row, row + n + 1, 0);
  }

  for (string line; getline(cin, line);) {
    istringstream is{line};
    int i, j;
    is >> i;
    int k;
    is >> k; // # of neighbors; don't use
    while (is >> j)
      A[i][j] = 1;
  }

  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < n; ++j) {
      cout << A[i][j] << " ";
    }
    cout << A[i][n] << endl;
  }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc055_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  mint ans = 1;
  repi(i, 1, N + 1) { ans *= i; }

  cout << ans << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;  
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const double eps = 1e-14;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl  
#define DIV 1000000007

int main(){
	ll N,A,B;
	cin >> N >> A >> B;
	vector<int> data;
	for(int i = 0; i < N; i++){
		int temp; cin >> temp;
		data.pb(temp);
	}
	ll ans = 0;
	for(int i = 0; i < N - 1; i++){
		ans += min(A*(data[i+1]-data[i]),B);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if (w >= v) {
    cout <<"NO" << endl;
    return 0;
  }

  if (abs(a-b) <= t * (v-w)) cout << "YES" << endl;
  else cout <<"NO" << endl;

  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, 0, n)
        cin >> v[i];
    if (n%2==0)
    {
        for(int i = n - 1; i >= 0; i -= 2)
            cout << v[i] << " ";
        for(int i = 0; i < n; i += 2)
            cout << v[i] << " ";
    }
    else 
    {
        for(int i = n - 1; i >= 0; i -= 2)
            cout << v[i] << " ";
        for(int i = 1; i < n; i += 2)
            cout << v[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 2944
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val map = mutableMapOf<String, Int>()
    for (i in 1..n) {
        val s = i.toString()
        val l = s.first().toString()
        val r = s.last().toString()
        map[l + r] = (map.get(l + r) ?: 0) + 1
    }
    var ans = 0L
    for (key in map.keys) {
        val num1 = map[key]!!
        val num2 = map.get(key.reversed()) ?: 0
        ans += num1 * num2
    }
    println(ans)
}

Measured memory_bytes: 46388
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

ll n, l, ai[100000], memo[100000];

ll check(ll num) {
  if (memo[num] > 0) return memo[num];
  ll left = num != 0  && ai[num] < ai[num - 1] ? check(num - 1) : 0;
  ll right = num != n - 1 && ai[num] < ai[num + 1]  ? check(num + 1) : 0;
  return memo[num] = max(left, right) + l - ai[num];
}

int main() {
  scanf("%lld%lld", &n, &l);
  for (ll i = 0; i < n; i++) scanf("%lld", &ai[i]), memo[i] = -1;
  ll ans = 0;
  for (ll i = 0; i < n; i++) ans = max(ans, check(i));
  printf("%lld\n", ans);
}



Measured memory_bytes: 5020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		B_ABC solver = new B_ABC();
		solver.solve(1, in, out);
		out.close();
	}

	static class B_ABC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			char[] s = in.next().toCharArray();
			long ans = 0;
			char last = 'B';
			int len = 0;
			for (int i = s.length - 1; i >= 0; i--) {
				if (s[i] == 'A') {
					if (len % 2 == 0) {
						ans += len / 2;
					} else {
						len = 0;
						last = 'B';
					}
					continue;
				}
				if (s[i] == last) {
					len = s[i] == 'C' ? 1 : 0;
				} else {
					++len;
				}
				last = s[i];
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

	}
}



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

int main(){
  int A, B;
  cin >> A >> B;

  if(A==1 && B==2 || A==2 && B==1){
    cout << 3 << endl;
  }
  else if(A==1 && B==3 || A==3 && B==1){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}
    
  
  
  
  

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, f[50] = {0};
  cin >> n;
  f[0] = f[1] = 1;
  for(int i = 2; i <= n; i++) f[i] = f[i - 1] + f[i - 2];

  cout << f[n] << endl;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
    int n,kk;cin>>n>>kk;
    ll x[51],y[51];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    ll ans=LINF;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=0;k<n;k++){
                for(int l=k+1;l<n;l++){
                    if(x[i]==x[j]||y[k]==y[l])continue;
                    int c=0;
                    ll yy=max(y[k],y[l]);ll yyy=min(y[k],y[l]);
                    ll xx=max(x[i],x[j]);ll xxx=min(x[i],x[j]);
                    for(int m=0;m<n;m++){
                        if(x[m]>xx||x[m]<xxx)continue;
                        if(y[m]>yy||y[m]<yyy)continue;
                        c++;
                    }
                    if(c>=kk){
                        ll s=(yy-yyy)*(xx-xxx);
                        ans=min(s,ans);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] a) {
	      String line = "";
	      try {
	        BufferedReader stdReader =
	          new BufferedReader(new InputStreamReader(System.in));
	        line = stdReader.readLine();
	        stdReader.close();
	      } catch (Exception e) {
	        e.getStackTrace();
	        System.exit(-1); // ????????°???????????????
	      }
		// TODO ?????????????????????????????????????????????
		int debt = 100000;
		int n = 0;
		n = Integer.parseInt(line);
		for(int i=0;i<n;i++){
			debt = interest(debt);
		}
		System.out.println(debt);
	}

	public static int interest(int n){
		double added;
		added = n * 1.05;
		added = 1000*Math.ceil(added/1000);
		return (int)added;
	}

}

Measured memory_bytes: 23988
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n){
    int d;
    scanf("%d", &d);
    vec[d-1]=i;
  }

  rep(i,n) printf("%ld%c",(long)20000*i+1 , ((i==n-1)?'\n':' '));
  rep(i,n) printf("%ld%c",(long)20000*(n-i)+vec[i]+1 , ((i==n-1)?'\n':' '));

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int m,f,r;
    for(;scanf("%d %d %d",&m,&f,&r),m+f+r != -3;puts("")){
        if(m==-1 || f==-1)
            putchar('F');
        else if(m+f >= 80)
            putchar('A');
        else if(m+f >= 65)
            putchar('B');
        else if(m+f >= 50 || r >= 50)
            putchar('C');
        else if(m+f >= 30)
            putchar('D');
        else
            putchar('F');
    }
    return 0;
}

Measured memory_bytes: 588
#!/bin/bash

awk -M '\
function abs(x){
    x+=0;
    return x > 0 ? x : -x
}
{
    N=$1; K=$2;
    b = N
    do{
        b = N
        N = N>K ? abs(N-int(N/K)*K) : abs(N-K)
    }while(N<b)
    print b
}' 


Measured memory_bytes: 4520
#include<cstdio>
#include<cstring>
long long int gcd(long long int a,long long int b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	int n;
	scanf("%d",&n);
	long long q;
	scanf("%lld",&q);
	long long tt=q;
	for(int i=1;i<n;i++)
	{
		long long k;
		scanf("%lld",&k);	
		tt=tt/gcd(tt,k)*k;
	}
	printf("%lld\n",tt);
	return 0;
}

Measured memory_bytes: 128
h,w=map(int,input().split())
if h%3==0 or w%3==0:
	print(0)
	exit()
x=[h,w]
import math
for i in range(1,w):
	p=abs(h*i-(w-i)*(h//2))
	q=abs(h*i-(w-i)*math.ceil((h/2)))
	x.append(max(p,q))
for i in range(1,h):
	p=abs(w*i-(h-i)*(w//2))
	q=abs(w*i-(h-i)*math.ceil((w/2)))
	x.append(max(p,q))
print(min(x))


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

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

int main(){
    string s;
    cin >> s;
    int N = (int)s.size();
    int ans = 0;
    rep(i, N/2){
        if(s[0+i] != s[N-1-i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
    ll ans;
    if(n%min({a,b,c,d,e})==0)ans=n/min({a,b,c,d,e})+4;
    else ans=n/min({a,b,c,d,e})+5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  long int x,y,z;
  scanf("%ld %ld %ld\n",&x,&y,&z);
  long int temp;
  temp=x;
  x=y;
  y=temp;
  temp=x;
  x=z;
  z=temp;
  printf("%ld %ld %ld\n",x,y,z);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int n;
    int b=0;
    int temp=0;
    scanf("%d", &n);
    
    b = n;
    while(b != 0){
        temp += b%10;
        b = b/10;
    }
    
    if(n%temp == 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def main():
    x, k, d = get_ints()
    ax = abs(x)
    tf = k % 2
    if ax < abs(ax-d) and tf == 0:
        print(x)
    elif ax < abs(ax-d):
        print(abs(x-d))
    else:
        tmp_k, mod_d = divmod(ax, d)
        if tmp_k < k:
            ax -= d * tmp_k
            k -= tmp_k
            tf = k % 2
            if tf == 1:
                ax = abs(ax - d)
            print(ax)
        else:
            ax -= d * k
            print(ax)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9212
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	while (cin >> N, N) {
		long double wcost;
		cin >> wcost;
		vector<long double>wgain(N);
		vector<long double>cost(N);
		vector<long double>gain(N);
		vector<long double>goal(N);
		vector<long double>v;
		v.push_back(0);
		long double plusadd = 0;
		long double minusadd = 0;
		long double box = 0;
		priority_queue<pair<long double, long double>,vector<pair<long double, long double>>,greater<pair<long double, long double>>>plusPQ;
		priority_queue<pair<long double, long double>,vector<pair<long double, long double>>,greater<pair<long double, long double>>>minusPQ;
		for (int i = 0; i < N; i++) {
			cin >> wgain[i] >> cost[i] >> gain[i] >> goal[i];
			if (goal[i] > 0) {
				box += goal[i] / gain[i] * cost[i];
			}
			if (wgain[i] > 0 && goal[i] / wgain[i] > 0) {
				v.push_back(goal[i] / wgain[i]);
				plusPQ.push({ goal[i] / wgain[i],wgain[i] / gain[i] * cost[i] });
				plusadd -= wgain[i] / gain[i] * cost[i];
			}
			else if (wgain[i] < 0) {
				if (goal[i] / wgain[i] > 0) {
					v.push_back(goal[i] / wgain[i]);
					minusPQ.push({ goal[i] / wgain[i],-wgain[i] / gain[i] * cost[i] });
				}
				else {
					minusadd -= wgain[i] / gain[i] * cost[i];
				}
			}
		}
		long double ans = box;
		sort(v.begin(), v.end());
		long double bef = 0;
		for (auto i : v) {
			box += plusadd * (i - bef);
			box += minusadd * (i - bef);
			while (!plusPQ.empty() && abs(plusPQ.top().first - i) < EPS) {
				plusadd += plusPQ.top().second;
				plusPQ.pop();
			}
			while (!minusPQ.empty() && abs(minusPQ.top().first - i) < EPS) {
				minusadd += minusPQ.top().second;
				minusPQ.pop();
			}
			box += (i - bef)*wcost;
			ans = min(ans, box);
			bef = i;
		}
		cout << setprecision(20) << ans << endl;
	}
}


Measured memory_bytes: 18024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a[5]; zep(i, 0, 5)cin >> a[i];
	
	ll t = 60*(a[2]-a[0])+(a[3]-a[1]);
	print(t-a[4])
	
	return 0;
}

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

int main(){
  std::string s;
  std::cin >> s;
  for(int i = 0; i < 19; i++){
    if(i != 5 && i != 13) std::cout << s.at(i);
    else std::cout << " ";
  }
  std::cout << std::endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmp=0
ca=[tmp]
for ai in a:
  tmp+=ai
  ca.append(tmp)
r=[]
for i in range(n):
  for j in range(i+1,n+1):
    r.append(ca[j]-ca[i])
x=0
s=set([])
for t in range(40,-1,-1):
  s=set([])
  tmp=0
  for ri in r:
    if (ri>>t)&1:
      tmp+=1
      s.add(ri)
  if tmp>=k:
    x+=pow(2,t)
    m=t
    break
for t in range(m-1,-1,-1):
  tmp=0
  ss=set([])
  for si in s:
    if (si>>t)&1:
      tmp+=1
      ss.add(si)
  if tmp>=k:
    x+=pow(2,t)
    s=ss
print(x)



Measured memory_bytes: 126292
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    vector<vector<int>> graph(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> d(n, -1);
    queue<int> q;
    d[0] = 0;
    q.push(0);

    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (int nv : graph[v]) {
            if (d[nv] != -1)
                continue; // skip if already visited
            d[nv] = v;
            q.push(nv);
        }
    }

    for (int i = 1; i < n; i++) {
        if (d[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << d[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 9664
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(long[]);
    auto N = nx[0];
    auto x = nx[1];
    auto as = readln.split.to!(long[]);
    long r;
    if (as[0] > x) {
        r += as[0] - x;
        as[0] = x;
    }
    foreach (i; 1..N) {
        auto s = as[i-1] + as[i];
        if (s > x) {
            r += s - x;
            as[i] -= s - x;
        }
    }
    writeln(r);
}

Measured memory_bytes: 4348
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
vvi g;
vi ans;
void dfs(int i,int p){
    for(ll x:g[i])if(x!=p){
        ans[x]+=ans[i];dfs(x,i);
    }
}
void solve(){
    ll n,q;cin>>n>>q;
    g=vvi(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    ans=vi(n);
    rep(i,q){
        ll c,d;cin>>c>>d;
        ans[c-1]+=d;
    }
    dfs(0,-1);
    outv(ans);
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 23808
import math



n= int(input())
x=list(map(float,input().split()))
y=list(map(float,input().split()))

d1=0
d2=0
d3=0
dd=0

for i in range(n):
	d1 +=  abs(x[i]-y[i])
	d2 += (abs(x[i]-y[i]))**2
	d3 += (abs(x[i]-y[i]))**3
	if 	dd < abs(x[i]-y[i]):
		dd=abs(x[i]-y[i])

print(d1)
print(d2**0.5)
print(d3**(1/3))
print(dd)





Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	int A, B; cin >> A >> B;
	int ans = -1;
	rep2(i, 1, 1251) {
		
		if (int(i * 0.08) == A && int(i * 0.1) == B) {
			ans = i;	
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);

    int s,w;
    cin >> s >> w;
    if (w<s) cout << "safe" << endl; 
    else cout << "unsafe" << endl; 
    return 0;   
}


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

a=[0]+a+[0]

cost=[abs(a[i]-a[i+1]) for i in range(len(a)-1)]
total=sum(cost)

ans=0
for i in range(n):
    ans = total - cost[i] - cost[i+1] + abs(a[i+2]-a[i])
    print(ans)


Measured memory_bytes: 14048
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))
INF = 1 << 29


def runLength(in_str):
    kukan = 1
    start = 0
    ret = []
    for i in range(1,len(in_str)):
        if in_str[i-1]!=in_str[i]:
            ret.append([in_str[i-1],kukan,start])
            start = i
            kukan=0
        kukan+=1
    ret.append([in_str[-1],kukan,start])
    return ret

N = int_raw()
S= input()
 
def main():
    ans = INF
    numB = [0]
    for c in S:
        numB.append(numB[-1])
        if c=="#":
            numB[-1]+=1
    for i in range(len(S)+1):
        ans = min(ans, numB[i]+ len(S)-i-(numB[-1]-numB[i]))
    return ans

print(main())



Measured memory_bytes: 11524
s = input()
t = input()
for i in range(len(s)-len(t),-1,-1):
  s1 = s[i:i+len(t)]
  for j,k in enumerate(s1):
    if t[j] != k and k != "?":
      break
  else:
    s = s[:i] + t + s[i+len(t):]
    print(s.replace("?","a"))
    exit()
print("UNRESTORABLE")

Measured memory_bytes: 3060