akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
struct SegTree
{
    private:
        ll n;
        vector<ll> node;
    public:
        SegTree(vector<ll> v){
            node.resize((1LL<<64-__builtin_clzll(v.size()))*2-1,0);//最小値なので残りはINFで埋める
            n=1LL<<64-__builtin_clzll(v.size());
            for(ll i=0; i<v.size(); i++) node[i+n-1] = v[i];//最下段から構築
            for(ll i=n-2; i>=0; i--) node[i] = node[2*i+1]+ node[2*i+2];
        }

    void update(ll x, ll val) {
    x += (n - 1);// 最下段index
    node[x] += val;
    while(x > 0) {
        x = (x - 1) / 2;
        node[x] = node[2*x+1]+ node[2*x+2];
    }
    }

    // 要求区間 [a, b) 中の要素の最小値を答える k := 自分がいるノードのインデックス 対象区間は [l, r) にあたる
    ll getmin(ll a, ll b, ll k=0, ll l=0, ll r=-1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;
    // 要求区間と対象区間が交わらない -> 適当に返す
    if(r <= a || b <= l) return 0;
    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(a <= l && r <= b) return node[k];
    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
    ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
    return vl+ vr;
    }
};
int main()
{
ll n ;
cin >> n ;
vector<ll> v(n);
rep(i, n){
  cin >> v[i];
}
ll lower=0,upper=1e+9;
ll seenow;
bool ok2butan;
while(true){
seenow=(lower+upper)/2;

//todo:seenowに対して処理
vector<ll> s;
s.push_back(0);
rep(i,n){
  if(seenow>=v[i])s.push_back(-1+s[i]);
  else s.push_back(1+s[i]);
}
ll sum=0;
vector<ll> t(200200);
SegTree ss(t);
rep(i,n){
  ss.update(s[i]+100100,1);
  sum+=ss.getmin(0,s[i+1]+100100+1);
}
if(sum<(n*(n+1)+3)/4)ok2butan=true;
else ok2butan=false;
//条件を満たすならok2butan=trueにする

if(ok2butan){
    upper=seenow;
    if(upper==lower+1){ans=seenow;break;}
    }
else {
    lower=seenow;
    if(upper==lower+1){ans=seenow+1;break;}
    }
//cout << seenow << endl;

}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 10184
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false);
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int N;
	cin>>N;
	vec(v,N);
	vin(v);

	sort(all(v));
	dvout(v);
	double ans=v[0];
	rep(i,N-1){
		ans = ((double)v[i+1]+ans)/2;
	}
	
	cout<<ans<<endl;
}
 
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long X){
    if (X - A < 0) cout << NO << '\n';
    else if (X - A <= B) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long X;
    scanf("%lld",&X);
    solve(A, B, X);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m=0;
	char a[1000];
	scanf("%d",&n);
	scanf("%s",&a);
	if(n%2!=0)
	printf("No\n");
	else
	{
		for(int i=0;i<n/2;i++)
		{
			if(a[i]==a[i+n/2])
			m++;
			if(a[i]!=a[i+n/2])
			break;
		}
		if(m==n/2)
		printf("Yes\n");
		else
		printf("No\n");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
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; }

const int mod=1e9+7;

signed main()
{
    int N,K; cin>>N>>K;

    if(N<K){
        cout<<0<<endl;
        return 0;
    }

    vector<vector<int> > S(N+1,vector<int>(K+1));
    S[0][0]=1;

    for(int i=1;i<=N;i++){
        for(int j=1;j<=K;j++){
            S[i][j]=(S[i-1][j-1]+S[i-1][j]*j)%mod;
        }
    }
    cout<<S[N][K]<<endl;
}



Measured memory_bytes: 10772
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void)
{
	string s[100],sd,t;
	cin >> sd >> t;
	int count = 0;

	for(int i=1;i<=sd.length()-t.length()+1;i++)
	{
		bool flag = true;
		for(int j=1;j<=t.length();j++)
		{
			if(sd[i+(j-1)-1]!=t[j-1] && sd[i+(j-1)-1]!='?')flag = false;
		}
		if(flag==true)
		{
			s[count]=sd;
			for(int j=1;j<=t.length();j++)
			{
				s[count][i+(j-1)-1]=t[j-1];
			}
			for(int j=1;j<=sd.length();j++)
			{
				if(s[count][j-1]=='?')
				{
					s[count][j-1]='a';
				}
			}

			count++;
		}
	}

	if(count==0)
	{
		cout << "UNRESTORABLE" << endl;
		return 0;
	}


	string ans = s[0];
	
	for(int i=1;i<=count;i++)
	{
		ans=min(ans,s[i-1]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



int main() {
    //
    int N;
    cin >> N;

    //
    int A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i]--;
    }

    //
    bool is_used[N];
    fill(is_used, is_used+N, false);
    int i = 0, num = 0;
    while(true){
        if(is_used[i]) {
            cout << -1 << endl;
            break;
        }

        is_used[i] = true;
        i = A[i];
        num++;

        if(i == 1){
            cout << num << endl;
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int likeN = 753;
	string s;
	cin >> s;

	int n = s.size();
	int ans = 642;
	rep(i, 0, n - 3 + 1) {
		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
		num = abs(num - likeN);
		ans = min(ans, num);
	}

	cout << ans << endl;

	return 0;
}

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

const int maxn = 104;
const int mod = 998244353, inf = 1000000007;

int a[maxn];
signed main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	LL ans = inf, nsum;
	for (int i = 1; i <= 100; ++i) {
		nsum = 0;
		for (int j = 1; j <= n; ++j) nsum += (i - a[j]) * (i - a[j]);
		ans = std::min(ans, nsum);
	}
	printf("%d", ans);
	return 0;
}

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

#define deb(x) cout << #x << " -> " << x << el 
#define db double
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define pass cout<<"pass\n"
#define vi vector<int>
#define eb emplace_back
#define pb push_back
#define vec vector
#define el "\n"
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define f(i,x,y) for(int i=x;i<y;++i)
#define ff(i,x,y) for(int i=x;i<=y;++i)
#define mem(x) memset(x, 0, sizeof(x))
#define mems(x,y) memset(x, y, sizeof(x))
#define MOD 1000000007
#define MAX 100005

using namespace std;


void solve() {
	int p;
	cin >> p;
	int ans = (p / 500) * 1000;
	p %= 500;
	ans += (p / 5) * 5;
	cout << ans;
}


int main() {
	// clock_t start = clock();
	// freopen("./input.in", "r", stdin);
	int tt = 1;
	// sc(tt);
	while(tt--) {
		solve();
	}
	// clock_t finish = clock();
	// printf("Time taken: %0.9lf sec\n", (double)((finish - start) / CLOCKS_PER_SEC));
 	
	return 0;
}

Measured memory_bytes: 256
t = list(input())

if t[len(t)-1] == "?":
    t[len(t)-1] = "D"

if t[0] == "?":
    if len(t) > 2:
        if t[1] == "P":
            t[0] = "D"
        else:
            t[0] = "P"
    else:
        t[0] = "D"

for i in range(len(t)-2):
    if t[len(t)-2-i] == "?":
        if t[len(t)-1-i] == "P":
            t[len(t)-2-i] = "D"
        else:
            if t[len(t)-3-i] == "?" or t[len(t)-3-i] == "D":
                t[len(t)-2-i] = "P"
            else:
                t[len(t)-2-i] = "D"

ans = ""

for i in range(len(t)):
    ans += t[i]

print(ans)

Measured memory_bytes: 10904
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>


using namespace std;


void rotation_of_Pattern_90(int l, int r, int pattern[100][100], int ans[100][100]){
    for(int i=l; i<r; i++){
        for(int j=l; j<r; j++){
            ans[j][r-i-1]=pattern[i][j];
        }
    }
}


int main(){
    int box[100][100];
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++){
            char temp;
            cin>>temp;
            box[i][j]=(int)temp;
            
        }
    }
    /*
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++){
            cout<<(char)box[i][j];
        }cout<<endl;
    }
     */
    
    cout<<90<<endl;
    int ans[100][100];
    rotation_of_Pattern_90(0, 8, box, ans);
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++){
            cout<<(char)ans[i][j];
        }cout<<endl;
    }
    
    
    cout<<180<<endl;
    int ans2[100][100];
    rotation_of_Pattern_90(0, 8, ans, ans2);
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++){
            cout<<(char)ans2[i][j];
        }cout<<endl;
    }
    
    cout<<270<<endl;
    int ans3[100][100];
    rotation_of_Pattern_90(0, 8, ans2, ans3);
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++){
            cout<<(char)ans3[i][j];
        }cout<<endl;
    }
    
    
    
}

Measured memory_bytes: 1168
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func min(a, b, c int) (n int) {
	ns := []int{a, b, c}
	sort.Ints(ns)
	return ns[0]
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func parseFloat(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return
}

func parseInt(s string) (n int) {
	n, _ = strconv.Atoi(s)
	return
}

var count int

func dfs(n int) {

}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := getInt(), getInt()

	d := make([]int, k)
	for i := range d {
		d[i] = getInt()
	}

	for i := n; n < 10000; i++ {
		count := true
		for _, v := range d {
			if strings.Contains(strconv.Itoa(i), strconv.Itoa(v)) {
				count = false
				break
			}
		}
		if count {
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 2176
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
a.sort()
if n % 2 == 0:
    val = 1
    for i in range(0, n-1, 2):
        if a[i] == a[i+1] == val:
            val += 2
            continue
        print(0)
        exit()
if n % 2 == 1:
    if a[0] != 0:
        print(0)
        exit()
    val = 2
    for i in range(1, n-1, 2):
        if a[i] == a[i+1] == val:
            val += 2
            continue
        print(0)
        exit()
ans = 1
for i in range(n//2): ans *= 2
print(ans % mod)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> p(N);
    REP(i, N) cin >> p[i];
    vector<double> q(N), r(N+1, 0.0);
    REP(i, N) q[i] = (1.0+p[i])/2.0;
    REP(i, N) r[i+1] = r[i] + q[i];

    double res = 0.0;
    REP(i, N-K+1){
    	chmax(res, r[i+K] - r[i]);
    }
    printf("%.10f\n", res);
    return 0;
}

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

  int main()
  {
    vector<int> V (5);
    for (int i; i < 5; i++)
    {
      cin >> V.at(i);
      if (V.at(i) == 0)
      {
        cout << i + 1 << endl;
      }
    }
  }
  

Measured memory_bytes: 3596
//Volume0-0027
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	
    	//declare
    	Calendar cl  = Calendar.getInstance();
    	String   ans;
    	int      month,day;

    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		month = sc.nextInt();
    		day   = sc.nextInt();
    		if(month==0){break;}
    		cl.set(2004,--month,day);
    		
    		//calculate
    		ans = "";
    		switch (cl.get(Calendar.DAY_OF_WEEK)){
    			case (Calendar.MONDAY)   :{ans = "Monday";   break;}
    			case (Calendar.TUESDAY)  :{ans = "Tuesday";  break;}
    			case (Calendar.WEDNESDAY):{ans = "Wednesday";break;}
    			case (Calendar.THURSDAY) :{ans = "Thursday"; break;}
    			case (Calendar.FRIDAY)   :{ans = "Friday";   break;}
    			case (Calendar.SATURDAY) :{ans = "Saturday"; break;}
    			case (Calendar.SUNDAY)   :{ans = "Sunday";         }
    		}
    		//output
    		System.out.println(ans);
    	}
    }
}

Measured memory_bytes: 15440
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pow10(n) stoll("1"+string(n,'0'))
int main(){
  int n,cnt1=0,cnt2=0;
  cin>>n;
  char c;
  string s,t,a,b;
  for(int i=0;i<n;i++)
  {
    cin>>c;
    s+=c;
  }
  for(int i=0;i<n;i++)
  {
    cin>>c;
    t+=c;
  }
  for(int i=1;i<=n;i++)
  {
    string h=to_string(i);
    a+=h;
  }
  for(int i=1;i<=n;i++)
  {
    string h=to_string(i);
    b+=h;
  }
  while(a!=s)
  {
    cnt1++;
    next_permutation(a.begin(),a.end());
  }
  while(b!=t)
  {
    cnt2++;
    next_permutation(b.begin(),b.end());
  }
  cout<<abs(cnt1-cnt2);

}



Measured memory_bytes: 256
def main():
    a,v = map(int,input().split())
    b,w = map(int,input().split())
    t = int(input())

    if v == w:
        print('NO')
        return 0
    if v-w < 0:
        print('NO')
        return 0
    if abs(b-a)/(v-w) <= t:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61708
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b, c;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        solve();
    }

    void solve() {
        if (a == 7 && b == 5 && c == 5) {
            System.out.println("YES");
        } else if (a == 5 && b == 7 && c == 5) {
            System.out.println("YES");
        } else if (a == 5 && b == 5 && c == 7){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    ll ans = 0;
    repd(i, 1, N) {
        if (a[i - 1] + a[i] > x) {
            int diff = (a[i - 1] + a[i]) - x;
            if (diff > a[i]) {
                a[i - 1] -= diff - a[i];
                a[i] = 0;
            }
            else {
                a[i] -= diff;
            }
            ans += diff;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    long long int N, div, ans;
    cin >> N;

    ans = N;

    for (int i = 1; i <= sqrt(N); i++) {
        div = N % i;
        if (div == 0) {
            if (i == 1) {
                ans = min(ans, N - 1);
            }
            else {
                ans = min(ans, i + N / i - 2);
            }
        }
    }
    
    cout << ans;

    return 0;

}



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

int main()
{

        int tmp = 0;
        vector<int> a;
        while (1) {

                cin >> tmp;
                if (tmp == 0) {

                        break;
                }
                a.push_back(tmp);
        }
        int n = a.size();
        for (int i = 0; i < n; ++i) {
                cout << "Case " << i+1 << ": " << a[i] << endl;
        }
}



Measured memory_bytes: 3188
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))

    val Array(x, y) = in.readLine().split("\\s+").map(_.toInt)

    out.println(x + y / 2)
    out.flush()
  }
}


Measured memory_bytes: 27196
n = input()
if len(n)==1:
    print(n)
    exit()
for i in range(1, len(n)):
    if n[i] != "9":
        print(9 * (len(n) - 1) + int(n[0]) - 1)
        exit()
print(9 * (len(n) - 1) + int(n[0]))


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

int main() {
  int n, k; cin>>n>>k;
  vector<long long> a(n), b, c;
  for (int i = 0; i < n; i++) cin>>a[i];
  for (int i = 0; i < n; i++) {
    long long cur = 0;
    for (int j = i; j < n; j++) {
      cur += a[j];
      b.emplace_back(cur);
    }
  }

  long long ans = 0;
  for (int i = 41; i >= 0; i--) {
    int cnt = 0;
    c.clear();
    for (int j = 0; j < b.size(); j++) {
      if (b[j] & (1LL<<i)) {
        ++cnt;
        c.emplace_back(b[j]);
      }
    }
    if (cnt >= k) {
      ans |= (1LL<<i);
      swap(b, c);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6132
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vector<char> buf;
  auto dfs = [&](auto &self, int i, int x) -> void {
    if (i == N) {
      string tmp;
      for (char c : buf) tmp += c;
      cout << tmp << endl;
      return;
    }
    rep(y, 0, min(26ll, x + 1)) {
      buf.pb('a' + y);
      self(self, i + 1, max(x, y + 1));
      buf.pop_back();
    }
  };
  buf.pb('a');
  dfs(dfs, 1, 1);
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define INF 1e9
#define EPS 1e-5
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORN(a,m,n) for(int a=0;a<m;a+=n)
#define REP(a,m,n) for(int a=m;a<n;a++)
#define REPN(a,m,n,p) for(int a=m;a<n;a+=p)
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdfopen(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define ifopen(a) freopen(a,"r",stdin);
#define ofopen(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
using namespace std;

bool isp(ll n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return 0;
	}
	return 1;
}
int main(){
	int n;
	vector<int> v,w;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.pb(x);
		w.pb(x);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		int x=w[i];
		if(v[v.size()-1]==x)cout<<v[v.size()-2]<<endl;
		else cout<<v[v.size()-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3436
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fir first
#define sec second
#define pb push_back
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 int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	vector<int> S[20];
	vector<int> P(20);
	rep(i,m){
		int k;
		cin >> k;
		rep(j,k){
			int s;
			cin >> s;
			S[i].push_back(s-1);
		}
	}
	rep(i,m) cin >> P[i];
	for (int bit = 0; bit < (1<<n); bit++) {
		bool flag = true;
		int swit = bit;
		rep(i,m){
			int on = 0;
			for(auto v : S[i]) if(swit & (1<<v)) on++;
			if(on % 2 != P[i]) flag = false;
		}
		if(flag) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
while True:
	n, a, b, c, x = map(int, input().split())
	if (n, a, b, c, x) == (0, 0, 0, 0, 0):
		break
	y = list(map(int, input().split()))

	count = -1
	i = 0
	while i < len(y):
		if y[i] == x:
			i += 1
		x = (a * x + b) % c
		count += 1
		if (10000 < count):
			count = -1
			break
	print(count)

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

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N);
  for (ll &e : L) {
    cin >> e;
  }
  sort(L.begin(),L.end());
  
  ll tri = 0;
  for (ll i = 0; i < N-2; i++) {
    for (ll j = i+1; j < N-1; j++) {
      auto itr = lower_bound(L.begin(), L.end(), L[i]+L[j]);
      itr--;
      tri += distance(L.begin()+j, itr);
    }
  }
  cout << tri << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N,L;
	cin >> N;
	int Max = 0, sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> L;
		sum += L;
		Max = max(Max, L);
	}
	if (sum - Max > Max)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

llong mod_pow(llong n, llong m) {
	if (m == 1) return n;

	llong ret = mod_pow(n, m / 2);
	return ret * ret % mod * ((m&1)?n:1) % mod;
}

int main() {
	llong N, K;
	vector<llong> A;

	cin >> N >> K;
	A.resize(N);
	for (auto &in: A) {
		cin >> in;
	}
	sort(ALL(A));

	vector<llong> ue(N+1, 1), sita(N+1, 1);
	for (int i = 1; i <= N; ++i) {
		ue[i] = ue[i - 1] * i % mod;
		sita[i] = mod_pow(ue[i], mod - 2);
	}

	llong ret = 0;
	for (int i = 0; i < N; ++i) {
		// min
		if (i <= N - K) {
			llong comb = ue[N - i - 1] * sita[K - 1] % mod * sita[(N - i - 1) - (K - 1)] % mod;
			ret = (mod + ret - A[i] * comb) % mod;
		}

		// max
		if (i >= K - 1) {
			llong comb = ue[i] * sita[K - 1] % mod * sita[i - (K - 1)] % mod;
			ret = (ret + A[i] * comb) % mod;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 2560
n =  int(input())

mark = ["S","H","C","D"]

card = [1] * 52

while ( n > 0 ):
    (m,mn)  =  map(str,input().split())
    j = 0
    while (j < 4):
        if (m == mark[j]):
            break
        j = j +1
    card [(int(mn) -1 ) + j*13] = 0
    n = n -1

for i in range (0,52):
    if ( card[i] == 1 ):
        print (mark[i//13], (i % 13) +1)


Measured memory_bytes: 5600
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,m,k;cin>>n>>m>>k;
  vector<ll> A(n), B(m);
  rep(i,n){
    cin>>A[i];
  }
  rep(i,m){
    cin>>B[i];
  }
  int a = 0, b = 0;
  ll sum = 0;
  rep(i,n){
    if(sum + A[a] <= k){
      sum += A[a];
      a++;
    }
  }
  while(b < m && sum + B[b] <= k){
    sum += B[b];
    b++;
  }
  ll ans = a + b;
  while(true){
    a--;
    if(a == -1) break;
    sum -= A[a];
    while(b < m && sum + B[b] <= k){
      sum += B[b];
      b++;
    }
    chmax(ans, a+b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6360
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            //var primes = new int[100100100];
            //for (int i = 0; i < 100100100; i++)
            //{

            //}


            var N = IO.RInt;
            var dis = new long[N + 1];

            for (int num = 2; num <= N; num++)
            {
                var wk_num = num;
                for (int i = 2; i <= num; i++)
                {
                    while (wk_num % i == 0)
                    {
                        dis[i]++;
                        wk_num /= i;
                    }
                }
            }

            long ans = 1;
            for (int i = 0; i < N + 1; i++)
            {
                ans = Mod.Multi(ans, dis[i] + 1);
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 17624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, 0, n) {
		int x;
		cin >> x;
		while (x % 2 == 0) {
			x /= 2;
			ans++;
		}
	}
	cout << ans << endl;
}

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

char Orc[102][102];

void DFS(char fru, int x, int y){
    if(Orc[x][y]!=fru)
        return;
    Orc[x][y] = '.';

    DFS(fru, x+1, y  );
    DFS(fru, x  , y+1);
    DFS(fru, x-1, y  );
    DFS(fru, x  , y-1);
}

int main(){
    int H,W;
    while(true){
        cin >> H >> W;
        if(H==0&&W==0)
            break;
        for(int y=1;y<=H;y++){
            for(int x=1;x<=W;x++)
                cin >> Orc[x][y];
        }

        int cnt = 0;
        for(int y=1;y<=H;y++){
            for(int x=1;x<=W;x++){
                if(Orc[x][y]!='.'){
                    cnt++;
                    DFS(Orc[x][y], x, y);
                }
            }
        }

        cout << cnt << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

string to_bin_str(int n, int t){
	string str;
	while (n > 0) {
		str.push_back('0' + (n&1));
		n >>= 1;
	}
	str.resize(t,'0');
	reverse(str.begin(),str.end());
	return str;
}

int main(int argc, char const *argv[]) {
	int n,m;
	std::cin >> n >> m;

	std::vector<std::vector<int>> switchs(m);
	for (size_t i = 0; i < m; i++) {
		int k;
		std::cin >> k;
		for (size_t it = 0; it < k; it++) {
			int s;
			std::cin >> s;
			s--;
			switchs[i].push_back(s);
		}
	}
	std::vector<int> onbit(m);
	for (size_t i = 0; i < m; i++) {
		std::cin >> onbit[i];
	}

	int ans = 0;
	for (size_t ib = 0; ib < pow(2,n); ib++) {
		bool flag = true;
		// 2bitに変換
		string str = to_bin_str(ib,n);
		// std::cout << str << '\n';
		std::vector<bool> onswitch(n);
		for (size_t i = 0; i < str.size(); i++) {
			onswitch[i] = str[i] - '0';
		}
		// for (size_t i = 0; i < onswitch.size(); i++) {
		// 	std::cout << onswitch[i] << ',';
		// }
		// std::cout << '\n';

		for (size_t is = 0; is < switchs.size(); is++) {
			int oncount = 0;
			for (size_t js = 0; js < switchs[is].size(); js++) {
				if (onswitch[switchs[is][js]]) {
					oncount++;
				}
			}
			if (oncount % 2 != onbit[is]) {
				flag = false;
				break;
			}
		}

		if (flag) {
			ans++;
		}
	}

	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
const int MV = 100100;

int main() {
  int N,W;
  cin >> N >> W;
  vi we(N),va(N);
  rep(i,N) {
    cin >> we[i] >> va[i];
  }
  v(ll) dp(MV,LINF);
  dp[0] = 0;
  rep(i,N) {
    v(ll) nextdp(MV);
    ll w = we[i];
    ll val = va[i];
    rep(x,MV) {
      if(x-val >= 0) {
        nextdp[x] = min(dp[x],dp[x-val]+ w);
      } else {
        nextdp[x] = dp[x];
      }
    }
    dp = nextdp;
  }
  drep(i,MV) {
    if(dp[i] <= W) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

const int MOD = 1000000007;

using ll = long long;

int add(int x, int y) { return ((x += y) >= MOD) ? x - MOD : x; }
int sub(int x, int y) { return add(x, MOD - y); }
int mult(int x, int y) { return ll(x) * y % MOD; }
int pw(int x, int y) {
   int ans = 1;
   for (; y > 0; y >>= 1, x = mult(x, x)) if (y & 1) ans = mult(ans, x);
   return ans;
}

int main() {
   ios_base::sync_with_stdio(false);
   int N, K;
   cin >> N >> K;
   vector<int> divs;
   for (int i = 1; i * i <= N; ++i) {
      if (N % i == 0) {
         divs.emplace_back(i);
         if (i * i < N) divs.emplace_back(N / i);
      }
   }
   sort(divs.begin(), divs.end());
   int M = divs.size();
   vector<int> dp(M);
   int ans = 0;
   for (int i = 0; i < M; ++i) {
      int z = divs[i];
      dp[i] = pw(K, (z + 1) / 2);
      for (int j = 0; j < i; ++j) {
         if (divs[i] % divs[j] == 0) {
            dp[i] = sub(dp[i], dp[j]);
         }
      }
      ans = add(ans, mult(dp[i], (z % 2) ? z : z / 2));
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N,T = map(int, input().split())

cNtN = [[0] * 2 for i in range(N)]
for i in range(N):
    cNtN[i][0], cNtN[i][1] = map(int, input().split())

for i in range(N):
    if cNtN[i][1] > T:
        cNtN[i][0] = float('inf')

min_c = float('inf')
for i in range(len(cNtN)):
    min_c = min(min_c, cNtN[i][0])

if min_c == float('inf'):
    print('TLE')
else:
    print(min_c)

Measured memory_bytes: 3064
# abc075_c.py

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N, M = map(int,input().split())
glaph = []
for i in range(M):
    A, B = map(int,input().split())
    glaph.append((A,B))

cnt = 0
for i in range(M):
    unionfind = UnionFind(N)
    for j,v in enumerate(glaph):
        x,y = v
        if i==j:
            continue
        unionfind.Unite(x,y)
    if unionfind.Count(1) < N:
        cnt += 1
print(cnt)


Measured memory_bytes: 9260
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int dep[MAXN];
int n,k,fa[MAXN],ans;
bool vis[MAXN];
vector<int> a[MAXN];
int dfs(int x,int f){
	vis[x]=1;
	for(int i=0;i<a[x].size();i++){
		int	u=a[x][i];
		dep[x]=max(dep[x],dfs(u,x));
	}
	if((f==0||dep[x]==k-1)&&x!=1&&f!=1){
		ans++;
		return 0;
	}
	dep[x]++;
	return dep[x];
}
int main(){
	SF("%d%d",&n,&k);	
	for(int i=1;i<=n;i++){
		SF("%d",&fa[i]);
		if(i!=1)
			a[fa[i]].push_back(i);
	}
	if(fa[1]!=1){
		ans++;
		fa[1]=1;
	}
	for(int i=1;i<=n;i++)
		if(vis[i]==0)
			dfs(i,0);
	PF("%d",ans);
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

class Maxflow{
public:
	struct Edge{
		int e;
		ll c, f; 
		Edge(){}
		Edge(int e, ll c, ll f):e(e), c(c), f(f){}
	};
	static const int MAXE = 500005;
	static const int MAXV = 500005;
	vector<int> G[MAXV];
	Edge E[MAXE*2];
	int dist[MAXV], cur[MAXV];
	int sz = 0;

	void clear(int N){
		for(int i = 0; i <= N; i++) G[i].clear();
		sz = 0;
	}

	void add(int s, int e, ll c){
		E[sz] = Edge(e, c, 0); G[s].push_back(sz); sz++;
		E[sz] = Edge(s, c, c); G[e].push_back(sz); sz++;
	}

	int BFS(int s, int e, int N){
		for(int i = 0; i <= N; i++) dist[i] = 0;
		queue<int> Q;
		Q.push(s); dist[s] = 1;
		while(Q.size()){
			int p = Q.front(); Q.pop();
			for(int cc : G[p]){
				Edge c = E[cc];
				if( c.c > c.f && dist[c.e] == 0 ){
					dist[c.e] = dist[p] + 1;
					Q.push(c.e);
				}
			}
		}
		return dist[e];
	}

	ll dfs(int s, int e, ll f){
		if( s == e ) return f;
		for(; cur[s] < G[s].size(); cur[s]++){
			int d = G[s][cur[s]];
			Edge c = E[d];
			if( c.c > c.f && dist[c.e] == dist[s] + 1){
				ll t = dfs(c.e, e, min(f, c.c - c.f));
				if( t ){
					E[d].f += t;
					E[d^1].f -= t;
					return t;
				}
			}
		}
		return 0;
	}

	ll run(int s, int e, int N){
		ll ans = 0, c;
		while(BFS(s, e, N) != 0){
			for(int i = 0; i <= N; i++) cur[i] = 0;
			while((c = dfs(s, e, 1e18)) != 0) ans += c;
		}
		return ans;
	}
}flow;

const int MX = 200005;
const int MM = 1000000007;

int N;
int D[MX];

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	int S = N+1, E = N+2;
	ll ans = 0;
	for(int i = 1; i <= N; i++){
		if( D[i] > 0 ) flow.add(i, E, D[i]), ans += D[i];
		else flow.add(S, i, -D[i]);
	}
	for(int i = 1; i <= N; i++){
		for(int j = i+1; j <= N; j++){
			if( j%i == 0 ) flow.add(i, j, 1e18);
		}
	}
	ans -= flow.run(S, E, E);
	printf("%lld\n", ans);
}	


Measured memory_bytes: 17920
//
// Created by kuribohkute on 20/04/2019.
//
#include <iostream>
using namespace std;
#define mp make_pair
#define X first
#define Y second
int main () {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 1) {
        cout << "IMPOSSIBLE";
        return 0;
    }
    cout << (a + b) / 2;
    return 0;
}


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    // cout << "a = " << a << endl;
    while (k && a >= b) {
        b <<= 1;
        k--;
    }
    // cout << "b = " << b << endl;
    while (k && b >= c) {
        c <<= 1;
        k--;
    }
    // cout << "c = " << c << endl;

    if ((b > a) && (c > b)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3668
x,y=gets.chomp.split(' ').map(&:to_i)
def gcd(a,b)
  if b==0
    return a
  end
  gcd(b,a%b)
end

g = gcd(x,y)
ans = 1
2.upto((g**0.5).floor) do |i|
  if g%i==0
    ans += 1
  end
  while g%i==0
    g /= i
  end
end

if g!=1
  ans += 1
end
puts ans

Measured memory_bytes: 1788
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
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)*}
    };
}
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)*}
    };
}
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")
    };
}


fn main() {
    input! {
        s: chars
    }

    if s[2] == s[3] && s[5] == s[4] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352