Language: Java

/*
 * :(
 * You taught me so much, I'm not scared anymore
 * 	I have to left go your hands that are holding me
 * 	 Even if I'm alone, I'll go on, even if it hurts
 * 	  I'll never forget the dream, I shared with you
 * 	   I'm glad to be with everyone, I'm glad to have been with everyone
 * 	    But on the morning when I wake up, no one is there
 */
//#define opti
#ifdef opti
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif
#ifndef opti
#pragma GCC optimize("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
//#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
#define double long double
#define pii pair<int,int>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
#define shuffle(a,b) random_shuffle(a,b,rng)
#define deb cout<<"Line: "<<__LINE__<<" pls "
typedef long long ll;
const ll mod=1000000007;
const ll inf=1e18;
//const ll mod=998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powm(ll a, ll b, ll m);

int a[1001],prefa[1001];
void solve()
{
	int n,k;
	cin>>n>>k;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		prefa[i]=prefa[i-1]+a[i];
	}
	int ans=0;
	for(int bit=30; bit>=0; bit--)
	{
		ans=ans+(1<<bit);
		int hol=0;
		for(int i=1; i<=n; i++)
			for(int j=i; j<=n; j++)
			{
				if(((prefa[j]-prefa[i-1])&ans)==ans)
					hol++;
//				cout<<((prefa[j]-prefa[i-1])&ans)<<" "<<ans<<endl;
			}
		if(hol<k)
			ans-=(1<<bit);
	}
	cout<<ans<<endl;
}
signed main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifdef rd
		clock_t clk = clock();
	#endif
	int t=1;
//	cin>>t;
	while(t--)
		solve();
	#ifdef rd
		clk = clock() - clk;
		cout<<endl<<endl<< "Time Elapsed: " << fixed << setprecision(10) << ((double)clk)/CLOCKS_PER_SEC <<endl;
	#endif
	return 0;
}
ll powm(ll a,ll b, ll m)
{
	ll te=1;
	while(b)
	{
		if(b&1)
			te=(te*a)%m;
		a=(a*a)%m;
		b>>=1;
	}
	return te;
}


Compiler output:
Main.java:11: error: illegal character: '#'
#ifdef opti
^
Main.java:12: error: illegal character: '#'
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
^
Main.java:13: error: illegal character: '#'
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
^
Main.java:14: error: illegal character: '#'
#endif
^
Main.java:15: error: illegal character: '#'
#ifndef opti
^
Main.java:16: error: illegal character: '#'
#pragma GCC optimize("O3")
^
Main.java:17: error: illegal character: '#'
#endif
^
Main.java:18: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:20: error: illegal character: '#'
#ifndef rd
^
Main.java:22: error: illegal character: '#'
#endif
^
Main.java:23: error: illegal character: '#'
#define pb push_back
^
Main.java:24: error: illegal character: '#'
#define fi first
^
Main.java:25: error: illegal character: '#'
#define se second
^
Main.java:26: error: illegal character: '#'
#define int long long
^
Main.java:27: error: illegal character: '#'
#define double long double
^
Main.java:28: error: illegal character: '#'
#define pii pair<int,int>
^
Main.java:29: error: illegal character: '#'
#define fr(a,b,c) for(int a=b; a<=c; a++)
^
Main.java:29: error: class, interface, enum, or record expected
#define fr(a,b,c) for(int a=b; a<=c; a++)
                               ^
Main.java:29: error: class, interface, enum, or record expected
#define fr(a,b,c) for(int a=b; a<=c; a++)
                                     ^
Main.java:30: error: illegal character: '#'
#define all(con) con.begin(),con.end()
^
Main.java:31: error: illegal character: '#'
#define shuffle(a,b) random_shuffle(a,b,rng)
^
Main.java:32: error: illegal character: '#'
#define deb cout<<"Line: "<<__LINE__<<" pls "
^
Main.java:34: error: class, interface, enum, or record expected
const ll mod=1000000007;
^
Main.java:35: error: class, interface, enum, or record expected
const ll inf=1e18;
^
Main.java:37: error: unnamed classes are a preview feature and are disabled by default.
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
^
  (use --enable-preview to enable unnamed classes)
Main.java:37: error: <identifier> expected
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
                  ^
Main.java:40: error: class, interface, enum, or record expected
int a[1001],prefa[1001];
^
Main.java:44: error: not a statement
	cin>>n>>k;
	      ^
Main.java:46: error: not a statement
		cin>>a[i];
		   ^
Main.java:64: error: not a statement
	cout<<ans<<endl;
	         ^
Main.java:68: error: not a statement
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	^
Main.java:70: error: illegal character: '#'
	#ifdef rd
	^
Main.java:68: error: ';' expected
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	                                       ^
Main.java:69: error: ')' or ',' expected
	srand(chrono::steady_clock::now().time_since_epoch().count());
	                               ^
Main.java:69: error: ';' expected
	srand(chrono::steady_clock::now().time_since_epoch().count());
	                                                            ^
Main.java:72: error: illegal character: '#'
	#endif
	^
Main.java:75: error: class, interface, enum, or record expected
	while(t--)
	^
Main.java:77: error: illegal character: '#'
	#ifdef rd
	^
Main.java:79: error: class, interface, enum, or record expected
		cout<<endl<<endl<< "Time Elapsed: " << fixed << setprecision(10) << ((double)clk)/CLOCKS_PER_SEC <<endl;
		^
Main.java:80: error: illegal character: '#'
	#endif
	^
Main.java:81: error: class, interface, enum, or record expected
	return 0;
	^
Main.java:82: error: class, interface, enum, or record expected
}
^
Main.java:86: error: class, interface, enum, or record expected
	while(b)
	^
Main.java:90: error: class, interface, enum, or record expected
		a=(a*a)%m;
		^
Main.java:91: error: class, interface, enum, or record expected
		b>>=1;
		^
Main.java:92: error: class, interface, enum, or record expected
	}
	^
Main.java:94: error: class, interface, enum, or record expected
}
^
47 errors