akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
    long long int ans = 0;
    long long int n;
    cin >> n;
    long long int arr[n];
    for (int i = 0; i < n;i++) {
        cin >> arr[i];
    }
    long long int sum[n] = {0};
    sum[0] = arr[0] % 1000000007;
    for (int i = 1; i < n;i++) {
        sum[i] = (arr[i] % 1000000007 + sum[i - 1] % 1000000007) % 1000000007;
        sum[i] = sum[i] % 1000000007;
    }
    /*for (int i = 0; i < n;i++) {
        cout << sum[i] << " ";
    }*/
    //cout << endl;
    for (int i = 0; i < n;i++) {
        //cout << i << " " << arr[i] << " " << sum[n - 1] - sum[i] ;
        long long int temp = sum[n - 1] - sum[i];
        if (temp < 0)   temp += 1000000007;
        
        ans = (ans % 1000000007 + (arr[i] % 1000000007 * (temp) % 1000000007 ) % 1000000007) % 1000000007;
        ans = ans % 1000000007;
        //cout << " " << ans << endl;
    }
    cout << ans % 1000000007 << endl;
	return 0;
}


Measured memory_bytes: 6756
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		sc.close();
		System.out.println(Math.min(P+Q, Math.min(Q+R, R+P)));

	}
}


Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size()-1; i++){
		if(s[i]=='A'&&s[i+1]=='C'){
			cout << "Yes" << endl;
			exit(0);
		}
		if(s[i]=='a'&&s[i+1]=='c'){
			cout << "Yes" << endl;
			exit(0);
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		char grade;
		while (true)
		{
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();

			if (m == -1 && f == -1 && r == -1)
			{
				break;
			}

			if (m == -1 || f == -1 || m + f < 30)
			{
				System.out.println("F");
			}
			else if (30 <= m + f && m + f < 50)
			{
				if (r >= 50)
				{
					System.out.println("C");
				}
				else
				{
					System.out.println("D");
				}
			}
			else if (50 <= m + f && m + f < 65)
			{
				System.out.println("C");
			}
			else if (65 <= m + f && m + f < 80)
			{
				System.out.println("B");
			}
			else
			{
				System.out.println("A");
			}
		}
	}
}



Measured memory_bytes: 26368
#include <stdio.h>
 
int main(void) {
 
	int A, P, Pie;
 
	scanf("%d%d", &A, &P);
 
	if (A < 0) {
		printf("eroor\n");
	}
	else if (100 < P) {
		printf("エラー\n");
	}
	else {
		Pie = (A * 3 + P) / 2;
		printf("%d\n", Pie);
	}
 
 
	return 0;
 
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <numeric>
#include <utility>
#include <set>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<double> A(N);
  for(int i =0;i<N;i++){
    cin >> A[i];
    A[i] = 1/A[i];
  }
  double sum = 0;
  for(auto e: A){
    sum += e;
  }
  cout << 1/sum << endl;
  
  return 0;
}


Measured memory_bytes: 888
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define repl(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const ll N=(ll)(1e6+1);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
ll inv(int x){return binpow(x, MOD - 2);}
ll divide(ll x, ll y){return mul(x, inv(y));}
ll fact[N];
void precalc(){fact[0] = 1;for(ll i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
ll C(ll n, ll k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================
//ll dp[1024][1024];
int main()
{

ll x,k,d;
cin>>x>>k>>d;
ll step=abs(x)/d;
ll ans=0;
//cout<<step<<endl;

if (step>k)
{
     ans=abs(x)-(k*d);
   // cout<<ans<<endl;
}
else
{
    k-=step;
   // cout<<k<<endl;
    if (k%2==0)
    {
         ans=abs(x)-(step*d);
            //if (x>0)
    }
    else
    {
         ans=abs(x)-((step+1)*(d));
    }
}
cout<<abs(ans);
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    for (int i = 0; i < n - m + 1; i++) {
        for (int j = 0; j < n - m + 1; j++) {
            bool flag = true;
            for (int k = 0; k < m; k++) {
                if (a[i + k].substr(j, m) != b[k]) flag = false;
            }
            if (flag) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

class State{
public:
  int a,b,c,d;
  State(int a,int b,int c,int d):a(a),b(b),c(c),d(d){};
};

int h,w;
int table[51][51],memo[51][51][51][51];
int Y[4]={-1,0,1,0};
int X[4]={0,1,0,-1};

bool in(int a,int b){
  if(a<0 || b<0 || h<=a || w<=b)return false;
  return true;
}

void init(){
  for(int i=0;i<51;i++)
    for(int j=0;j<51;j++)
      for(int k=0;k<51;k++)
	for(int l=0;l<51;l++)memo[i][j][k][l]=inf;
}

int main()
{
  int a,b,c,d;
  while(1){
    cin>>w>>h;
    if(h+w==0)break;
    cin>>b>>a>>d>>c;
    a--;b--;c--;d--;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>table[i][j];
    init();

    queue<State> q;
    q.push(State(a,b,c,d));
    memo[a][b][c][d]=0;

    int ans=inf;
    while(!q.empty()){
      State u=q.front();
      q.pop();

      if(u.a==u.c && u.b==u.d){
	ans=min(memo[u.a][u.b][u.c][u.d],ans);
        continue;
      }

      if(memo[u.a][u.b][u.c][u.d]>=100)continue;

      for(int i=0;i<4;i++){
	int A=u.a+Y[i],B=u.b+X[i],C=u.c+Y[(i+2)%4],D=u.d+X[(i+2)%4];
	if(table[A][B] || !in(A,B)){
	  A=u.a;
	  B=u.b;
	}
	if(table[C][D] || !in(C,D)){
	  C=u.c;
	  D=u.d;
	}
	if(memo[A][B][C][D]>memo[u.a][u.b][u.c][u.d]+1){
	  q.push(State(A,B,C,D));
	  memo[A][B][C][D]=memo[u.a][u.b][u.c][u.d]+1;
	}
      }
    }
    if(ans>=100)cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 28556
n,h = map(int,input().split())
a_li = []
b_li = []
for _ in range(n):
    a,b = map(int,input().split())
    a_li.append(a)
    b_li.append(b)
count = 0
ma = max(a_li)
b_li.sort(reverse=True)
for b in b_li:
    if b < ma:
        break
    count+=1
    h -= b
    if h<=0:
        print(count)
        exit()
import math
tmp = math.ceil(h/ma)
print(count+tmp)

Measured memory_bytes: 61528
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n = list(input())

if n.count("x") < 8:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3564
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll F[2100010];

ll Mul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
ll square(ll x) {
	return (x * x) % mod;
}

ll power(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

ll Div(ll a, ll b) {
	return Mul(a, power(b, mod - 2));
}
ll P(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

ll C(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	ll ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}

ll c[200010];
int main()
{
	fact();
	ll n, a, b;
	cin >> n >> a >> b;
	if (n == 2) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = power(2, n) - 1 + mod * 2;
	c[0] = 1;
	for (int i = 1; i < 200010; i++) {
		c[i] = Mul(c[i - 1],n - i + 1);
		c[i] = Div(c[i], i);
	}
	ans -= c[a] + c[b];
	cout << ans % mod << endl;
}


Measured memory_bytes: 18304
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

void solve(){
	ll N,W;
	cin>>N>>W;

	ll w[N],v[N];
	ll i;
	rep(i,N)
	{
		cin>>w[i]>>v[i];
	}

	ll dp[N+1][W+1];
	memset(dp,0,sizeof(dp));
	ll j;

	fr(i,1,N)
	{
		fr(j,1,W){
			dp[i][j]=dp[i-1][j];
			if(j-w[i-1]>=0)
			{
				dp[i][j]=max(dp[i][j],v[i-1]+dp[i-1][j-w[i-1]]);
			}
		}
	}
	cout<<dp[N][W];
}

int main(){
	//fio();
	fast

	solve();
	return 0;
}

Measured memory_bytes: 79232
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
struct ver{
  ll x,y;
  ver(ll x,ll y){
      this->x=x,this->y=y;
  }
  bool operator<(const ver&key)const{
      return this->x>key.x;
  }  
};
vector<ver> v;
vector<ll> t;
ll n,m,a[200010],cs[200010];
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i]; sort(a,a+n,greater<ll>());
  for(int i=0;i<m;i++){
      ll x,y;cin>>y>>x;
      v.push_back(ver(x,y));
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++){
      while(t.size()<=n){
	  if(v[i].y==0)break;
	  v[i].y--;
	  t.push_back(v[i].x);
      }
  }
  while(t.size()<=n)t.push_back(0);
  cs[0]=0; for(int i=0;i<n;i++)cs[i+1]=cs[i]+t[i];
  ll ans=cs[n],sum=0;
  for(int i=0;i<n;i++){
      sum+=a[i];
      ans=max(ans,sum+cs[n-i-1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5232
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N,M,cnt=0;
    float ave=0;
    cin >> N >> M;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        ave += A[i];
    }
    ave /= 4*M;
    for(int i=0;i<N;i++){
        if(A[i]>=ave){
            cnt++;
        }
    }
    if(cnt >= M){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

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

const int Maxn = 100005;
int n, cnt, head[Maxn], f[Maxn], g[Maxn];
bool vis[Maxn][2];
struct edg
{
	int nxt, to, w;
} edge[20 * Maxn];
void add(int x, int y, int w)
{
	edge[++cnt] = (edg){head[x], y, w};
	head[x] = cnt;
}
struct sta
{
	int u, w;
	bool type;
	bool operator < (const sta &tmp) const
	{
		return w > tmp.w;
	}
};
priority_queue <sta> Pr;
void dijkstra(void)
{
	memset(f, 0x3f, sizeof(f));
	memset(g, 0x3f, sizeof(g));
	g[0] = 0;
	Pr.push((sta){0, 0, true});
	while (!Pr.empty())
	{
		sta now = Pr.top();
		Pr.pop();
		if (vis[now.u][now.type]) continue;
		vis[now.u][now.type] = true;
		for (int i = head[now.u]; i; i = edge[i].nxt)
		{
			int to = edge[i].to, tmp_w = (now.type ? g[now.u] : f[now.u]) + edge[i].w;
			if (tmp_w && f[to] > tmp_w)
			{
				f[to] = tmp_w;
				Pr.push((sta){to, f[to], false});
			}
			if (g[to] > tmp_w)
			{
				g[to] = tmp_w;
				Pr.push((sta){to, g[to], true});
			}
		}
	}
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= 9; j++)
			add(i, (10 * i + j) % n, j);
	dijkstra();
	printf("%d", f[0]);
	return 0;
}
	

Measured memory_bytes: 22568
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin>>n;
    set<int> s;
    rep(i,n){
        int a;
        cin>>a;
        auto itr=s.find(a);
        if(itr==s.end()){
            s.insert(a);
        }else{
            s.erase(a);
        }
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 4864
N = int(input())
S = [int(input()) for i in range(N)]

ans = sum(S)
S.sort()

for s in S:
  if ans%10 == 0 and s%10 != 0:
    ans = ans - s
    break

if ans%10 != 0:
  print(ans)
else:
  print(0)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void a(){
    char a[100], b[100], c[100];

    scanf("%s %s %s",a,b,c);
    int n1 = strlen(a);
    int n2 = strlen(b);
    if (a[n1-1] == b[0] && b[n2-1] == c[0]) {
        printf("%s\n","YES" );
    }else{
        printf("%s\n","NO" );
    }
}

int main(int argc, char const *argv[]) {
    a();
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define vll vector<ll>
#define G vector<vll >
#define gg vector<int>
#define F first
#define S second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define RFOR(i,a,b) for(int i=a;i>=b;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define rll read_ll();
#define gc getchar
#define pc putchar
typedef long long ll;
template<class T> inline T lcm(T a,T b){
        return a/gcd(a,b)*b;
}
template<typename T>
void debug(T first) {
    cout << first << "\n";
}
template<typename T, typename... Args>
void debug(T first, Args... args) {
    cout << first << " ";
    debug(args...);
}


ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}

vector<vector<bool> >sums;
int n,k; 
vector<bool> bits(ll val) {
	vector<bool> ret;
	for(ll i = 0; i < 41; i++) {
		if((val&(1LL<<i))>0) {
			ret.pb(1);
		} else ret.pb(0);
	}
	// while(ret.back()=='0') ret.pop_back();
	// reverse(all(ret));
	return ret;
}


ll conv(vector<bool>&val) {
	ll c = 0;
	// reverse(all(val));
	FOR(i,0,40) {
		if(val[i])
		c += (1LL<<i);
	}
	// reverse(val);
	return c;
}
void deb(int pos) {
	cout<<pos<<" [";
	for(auto val:sums) {
		cout<<conv(val)<<",";
	}
	cout<<"]";cout<<endl;
}
void deb1(int pos) {
	cout<<pos<<" [";
	for(auto val:sums) {
		for(auto v : val) cout<<v;
			cout<<",";
	}
	cout<<"]";cout<<endl;
}




int main()
{
	cin>>n>>k;
	vector<ll>a(n+1), prefixsum(n+1);
	FOR(i,1,n) cin>>a[i];
	prefixsum[0] = 0;
	FOR(i,1,n) prefixsum[i] = prefixsum[i-1] + a[i];
	FOR(i,0,n-1) {
		FOR(j,1,n-i) {
			sums.pb(bits(prefixsum[j+i]-prefixsum[j-1]));
		}
	}
	// for(auto val : sums) {
	// 	for(auto v : val) cout<<v;
	// 		cout<<endl;
	// }
	RFOR(h,40,0) {
		vector<vector<bool> > nsums;
		// deb(h);
		for(auto v : sums) {
			if(v[h])
				nsums.pb(v);
		}
		if(nsums.size()>=k) sums = nsums;
	}
	// for(auto val : sums) {
	// 	for(auto v : val) cout<<v;
	// 		cout<<endl;
	// }
	ll ans = (1LL<<41)-1;
	for(auto v : sums) {
		ans = ans&conv(v);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 45188
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;


int main(void){
	ios::sync_with_stdio(false);
	long i, j, k, count, alpha, beta, count1;
	long L, R;
	cin >> L >> R;
	k = R / 2019;
	alpha = L - 2019 * k;
	beta = R - 2019 * k;
	count = 2020;
	if (L <= 2019 * k) {
		count = 0;
		cout << count;
	}
	else {
		for (i = alpha; i < beta; i++) {
			for (j = alpha + 1; j <= beta; j++) {
				if (count > (i*j) % 2019) {
					count = (i*j) % 2019;
				}
			}
		}
		cout << count;
	}
	return 0;
}

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

typedef long long ll;

#define faster() ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) (x).begin(), (x).end()

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const double eps = 1e-9;

bool check(int n)
{
	int a = n % 10;
	n /= 10;
	int c = n % 10;
	n /= 10;
	return (a == c && c == n);
}
int main()
{
	faster();
	int n;
	cin >> n;
	for (int i = n; i <= 999; i++)
		if (check(i))
			return cout << i, 0;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{   
    static int arr[]=new int[100008];
    static int dp[]=new int[100008];
    public static int getAns(int arr[],int index,int n)
      {
          if(index>=n)return 0;
          if(dp[index]!=-1)return dp[index];
          int a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
          if(index+1<=n)
             a=Math.abs(arr[index+1]-arr[index])+getAns(arr,index+1,n);
          if(index+2<=n)
            b=Math.abs(arr[index+2]-arr[index])+getAns(arr,index+2,n);
          return dp[index]=Math.min(a,b);
      }
	public static void main(String[] args)throws IOException {
		FastReader kb=new FastReader();
        int n=kb.nextInt();
        Arrays.fill(dp,-1);
        for(int i=1;i<=n;i++)
	     {
	         arr[i]=kb.nextInt();
	     }
	    System.out.println(getAns(arr,1,n));
	}
	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: 46724
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

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

int main(){
  int n;
  cin >> n;
  vector<long> t(n);
  rep(i,n) cin >> t.at(i);
  long t1 = t.at(0);
  rep(i,n-1){
    long t2 = t.at(i+1);
    long g = gcd(t1,t2);
    t2 /= g;
    t1 *= t2;
  }
  cout << t1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX1 100000
#define MAX2 50000


int binary(int p[], int N1, int key){
	int left=0;
	int right=N1;
	
	for(;left<right;){
		int mid=(left+right)/2;
		if(p[mid]==key){
			return mid;
		}else if(key<p[mid]){
			right=mid;
		}else{
			left=mid+1;
		}
	}
	
	return -1;
}

int main(void){
	
	int N1,N2,key;
	int p[MAX1];
	int cnt=0;
	
	scanf("%d",&N1);
	
	for(int i=0;i<N1;i++){
		scanf("%d",&p[i]);
	}
	
	scanf("%d",&N2);
	
	for(int i=0;i<N2;i++){
		scanf("%d",&key);
		
		int ans=binary(p,N1,key);
		if(ans!=-1){
			cnt++;
		}
	}
	
	printf("%d\n",cnt);
	
	
	return 0;
	
}


Measured memory_bytes: 2192
import collections

n=int(input())
a=list(map(int,input().split()))

c=collections.Counter(a)
s=0

for i in c.values():
  s+=i*(i-1)//2 #ボールを抜かない場合に2つのボールを選ぶ方法の数

for j in a:
  f=c[j]
  print(s-(f-1)) #下記メモ参照

'''
複数個のボールから1個のボールが抜かれる場合、i*(i-1)//2が(i-1)*(i-2)//2となる。

i*(i-1)//2-(i-1)*(i-2)//2
=i-1

よって、2つのボールを選ぶ方法が(i-1)だけ減る。
'''

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int H, W; cin >> H >> W;
	int h, w; cin >> h >> w;
	cout << (H-h)*(W-w) << endl;
	return 0;
}

Measured memory_bytes: 3584
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        M:usize,
        ABC:[(Usize1,Usize1,isize);M]
    }

    let INF = 1000000;
    let mut D = vec![vec![INF;N];N];

    for i in 0..N{
        D[i][i] = 0;
    }
    for &(a,b,c) in &ABC{
        D[a][b] = c;
        D[b][a] = c;
    }

    for k in 0..N{
        for i in 0..N{
            for j in 0..N{
                D[i][j] = min(D[i][j],D[i][k]+D[k][j]);
            }
        }
    }

    let ans = ABC.iter().filter(|&&(a,b,c)| D[a][b] != c).count();
    println!("{}",ans);
}


Measured memory_bytes: 2228
#include <stdio.h>
int a[3000], b[3000];
int h[3000], j[3000];
int main(void) {
	int e;
	for (e = 1; e < 3000; e++) {
		h[e] = j[e] = 0;
		a[e] = b[e] = 0;
	}
	int i = 1;
	int k = 1;
	while (1) {
		scanf("%d%d", &a[i], &b[i]);
		if (a[i] == 0 && b[i] == 0) break;
		if (a[i] <= b[i]) {
			h[i] = a[i];
			j[i] = b[i];
		}
		else {
			j[i] = a[i];
			h[i] = b[i];
		}
		i++;
	}
	while (k < i) {
		printf("%d %d\n", h[k], j[k]);
		k++;
	}
	return 0;
}

Measured memory_bytes: 644
#include<iostream>
using namespace std;
int main(){
  int num;
  int a,b,c;
  bool ke[999]={false};
  int i;
  cin>>num;
  for(i=0;i<num;i++){
    cin>>a>>b>>c;
    if(a*a+b*b==c*c) ke[i]=true;
    else if(a*a+c*c==b*b) ke[i]=true;
    else if(b*b+c*c==a*a) ke[i]=true;
  }
  for(i=0;i<num;i++){
    if(ke[i]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int main(){
 int X, Y, Z, K;
 cin >> X >> Y >> Z >> K;
 vector<long long> xx(X), yy(Y), zz(Z);
 for(int i=0; i<X; ++i) cin >> xx[i]; sort(all(xx), greater<long long>());
 for(int i=0; i<Y; ++i) cin >> yy[i]; sort(all(yy), greater<long long>());
 for(int i=0; i<Z; ++i) cin >> zz[i]; sort(all(zz), greater<long long>());
 
 vector<long long> res;
 for(int i=0; i<X; ++i){
   for(int j=0; j<Y; ++j){
     for(int k=0; k<Z; ++k){
       if((i+1)*(j+1)*(k+1) > K)
         break;
       res.push_back(xx[i]+yy[j]+zz[k]);
     }
   } 
 }
 sort(all(res), greater<long long>());
 for(int i=0; i<K; ++i)
   cout << res[i] << "\n";
 return 0;
}


Measured memory_bytes: 1404
import java.util.ArrayList;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double n = sc.nextInt();
    double sum = 0;
    ArrayList<Integer> b = new ArrayList<Integer>();
    for (int i = 0; i < n; i++) {
      int c = sc.nextInt();
      sum += c;
      b.add(c);
    }
    double avg = Math.round(sum / n);
    int r = 0;
    for (int i = 0; i < n; i++) {
      r += Math.pow((b.get(i) - avg), 2);
    }
    System.out.println(r);
    sc.close();
  }
}


Measured memory_bytes: 35992
#include<iostream>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>=400 && x<=599)
    cout<<"8"<<endl;
  else if(x>=600 && x<=799)
    cout<<"7"<<endl;
    else if(x>= 800&& x<=999)
    cout<<"6"<<endl;
    else if(x>= 1000&& x<=1199)
    cout<<"5"<<endl;
    else if(x>= 1200&& x<=1399)
    cout<<"4"<<endl;
    else if(x>=1400 && x<=1599)
    cout<<"3"<<endl;
      else if(x>=1600 && x<=1799)
    cout<<"2"<<endl;
     else if(x>=1800 && x<=1999)
    cout<<"1"<<endl;
}

Measured memory_bytes: 3104
package FenwickTree;
sub new{
	return bless[(0)x$_[1]],$_[0];
}
sub add{
	my$self=shift;
	my($p,$x)=@_;
	$p++;
	while($p<=@{$self}){
		$self->[$p-1]+=$x;
		$p+=$p&-$p;
	}
}
sub sum{
	my$self=shift;
	return$self->prefixsum($_[1])-$self->prefixsum($_[0]);
}
sub prefixsum{
	my($self,$r)=@_;
	my$s=0;
	while($r>0){
		$s+=$self->[$r-1];
		$r-=$r&-$r;
	}
	return$s;
}
package main;
my($N,$Q)=split$",<>;
my$fenwicktree=FenwickTree->new($N);
my@a=split$",<>;
for$i(0..$#a){
	$fenwicktree->add($i,$a[$i]);
}
for(1..$Q){
	my($t,$a,$b)=split$",<>;
	if($t==0){
		$fenwicktree->add($a,$b);
	}
	else{
		print$fenwicktree->sum($a,$b),$/;
	}
}


Measured memory_bytes: 68776
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  int n=s.size();
  if(s[0]=='A'){
    for(int i=2;i<=n-2;i++){
      if(s[i]=='C'){
        for(int j=0;j<n;j++){
          if(j==0 || j==i)continue;
          if(s[j]>'z' || s[j]<'a'){
            P("WA");
            return 0;
          }
        }
        P("AC");
        return 0;
      }
    }
  }
  P("WA");
  return 0;
}


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

const ll MOD = 1000000007;

int main(){
    int n,m; cin >> n >> m;
    if(n == m) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

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

using namespace std;

typedef long long int ll;

vector < ll > a;
ll n, m, v, p;

bool check(ll x){
  if(x < p) return true;
  ll cnt = m;
  cnt += (p - 1) * m;
  cnt += (n - x - 1) * m;
  for(int i = p - 1; i < x; i++){
    if(a[x] + m - a[i] < 0) return false;
    cnt += (a[x] + m - a[i]);
  }
  if(cnt >= m * v) return true;
  return false;
}

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

  cin >> n >> m >> v >> p;
  a.resize(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end(), greater < ll > ());

  ll lo = 0, hi = n - 1, ans = LLONG_MIN;
  while(lo <= hi){
    ll mid = (hi - lo) / 2 + lo;
    if(check(mid)){
      lo = mid + 1;
      ans = max(ans, mid);
    }else{
      hi = mid - 1;
    }
  }

  cout << ans + 1 << endl;
}


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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 2999+5;



dbl p[N];

dbl dp[N][N];

int main() {


    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }

    dp[1][1] = p[1];
    dp[1][0] = 1.0-p[1];

    for(int i = 2; i <= n; i++){
        for(int h = 0; h <= i; h++){
            if(h == i){
                // throw this heads
                dp[i][h] = dp[i-1][h-1]* p[i];
            }
            else if(h == 0){
                // throw this tails
                dp[i][0] = dp[i-1][0]* (1.0 - p[i]);
            } else {
                dp[i][h] = dp[i-1][h-1] * p[i] + dp[i-1][h] * (1-p[i]);
            }
        }
    }

    dbl res = 0;
    for(int h = 0; h <= n; h++){
        int t = n-h;
        if(t < h){
            res += dp[n][h];
        }
    }

    printf("%.15Lf\n",res);


    return 0;
}


Measured memory_bytes: 139264
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int n,color[100000];
vector<int> adj[100000],path;
bool vis[100000];
bool dfs(int u){
    if(u==n-1){
        path.push_back(u);
        return 1;
    }
    vis[u]=1;
    bool ret=0;
    for(auto v:adj[u]){
        if(!vis[v])ret|=dfs(v);
    }
    if(ret)path.push_back(u);
    return ret;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0);
    reverse(path.begin(),path.end());
    memset((color),-1,sizeof(color));
    for(int i=0,j=path.size()-1,k=0;i<=j;k^=1){
        if(!k)color[path[i++]]=0;
        else color[path[j--]]=1;
    }
    for(int i=0;i<2;i++){
        queue<int> q;
        for(int j=0;j<n;j++){
            if(color[j]==i)q.push(j);
        }
        while(!q.empty()){
            int u=q.front();
            q.pop();
            for(auto v:adj[u]){
                if(color[v]==-1){
                    color[v]=i;
                    q.push(v);
                }
            }
        }
    }
    int fennec=0,snuke=0;
    for(int i=0;i<n;i++){
        if(color[i]==0)fennec++;
        else snuke++;
    }
    if(fennec<=snuke)puts("Snuke");
    else puts("Fennec");
    return 0;
}

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


int main(){


    int n, t;

    int f = 0;
   

    cin >> n;


    for( t = n ; 0 < t ; t = t / 10 ){

         f += t % 10;

         }


    if( n % f == 0 ) cout << "Yes" << endl;

    else cout << "No" << endl;


    return 0;

    }

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char a[102],b[102];
    int i,j,n;
    scanf("%s %s",a,b);
    for (i = 0;;i++) {
        if(a[i] == '\0') break;
    }
    for (j = 0;;j++) {
        if (b[j] == '\0') break;
    }
    if (i > j) {
        printf("GREATER\n");
    } else if (j > i) {
        printf("LESS\n");
    } else {
        for(i = 0;i <= j;i++) {
            if (a[i] > b[i]) {
                printf("GREATER\n");
                break;
            } else if (b[i] > a[i]) {
                printf("LESS\n");
                break;
            } else {
                if(i == j) {
                    printf("EQUAL\n");
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int t = sc.nextInt();
        HashMap<String, Integer> hmap = new HashMap<>();
        while (t-- > 0) {
            String verdict = sc.next();
            hmap.put(verdict, hmap.getOrDefault(verdict, 0) + 1);
        }
        System.out.println("AC x " + (hmap.get("AC") == null ? 0 : hmap.get("AC")));
        System.out.println("WA x " + (hmap.get("WA") == null ? 0 : hmap.get("WA")));
        System.out.println("TLE x " + (hmap.get("TLE") == null ? 0 : hmap.get("TLE")));
        System.out.println("RE x " + (hmap.get("RE") == null ? 0 : hmap.get("RE")));
    }

    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: 49164
#include <bits/stdc++.h>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    int bom[h][w];
    char c;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c;
            bom[i][j] = (c == '#' ? -1 : 0);
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (bom[i][j] == -1) {
                for (int k = i-1; k <= i+1; k++) {
                    for (int l = j-1; l <= j+1; l++) {
                        if ((0 <= k && k < h) && (0 <= l && l < w)) {
                            if (bom[k][l] != -1) bom[k][l]++;
                        }
                    }
                }
            }
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (bom[i][j] == -1) {
                cout << '#';
            } else {
                cout << bom[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}


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

int N;
int max_1, max_2;
vector<int> A;

int main(void) {
	cin >> N;
	A.resize(N);

	max_1 = max_2 = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] > max_1) {
			max_2 = max_1;
			max_1 = A[i];
		}
		else if (A[i] > max_2)
			max_2 = A[i];
	}

	for (int i = 0; i < N; ++i) {
		int ans = max_1;
		if (A[i] == max_1)
			ans = max_2;
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 2432
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int res = 1000;
  REP(i,s.size()-2) {
    int a = stoi(s.substr(i,3));
    res = min(res,abs(753 - a));
  }
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
string s;
string ans;
int main() {
	cin >> n;
	int cont = 0;
	while (cont < n) {
		cin >> s;
		sort(s.begin(), s.end());
		if (cont == 0) {
			ans = s;
			cont++;
			continue;
		}
		string t="";
		int i = 0, j = 0;
		while (i < ans.length() && j < s.length()) {
			if (ans[i] == s[j]) {
				t += ans[i];
				i++;
				j++;
			}
			else if (ans[i] > s[j]) {
				j++;
			}
			else {
				i++;
			}
		}
		ans = t;
		cont++;
	}
	cout << ans << endl;
}

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

int main() {
    string s,res;
    int temp;
    int ans=10000;
    cin>>s;
    for (int i=0; i<s.size()-2; i++) {
        res=s.substr(i,3);
        temp=stoi(res);
        ans=min(abs(temp-753),ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
using ll = int; using namespace std;

#ifndef __GNUC__
string text =
R"X(105)X";
stringstream iss{text};
#endif

ll cnt;
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	ll N; iss >> N;
	for (ll i = 3; i <= N; i += 2) {
		ll cnt8{0};
		for (ll j = 1; j <= i; ++j) {
			if (i % j == 0) ++cnt8;
		}
		if (cnt8 == 8) ++cnt;
	}
	cout << cnt << "\n";
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    int l;
    cin >> l;

    double x = double(l) / 3.0;
    printf("%.7f\n", x * x * x);

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }
    if (n < 3) println(0)
    else {
        var a = 0
        for(i in 0 until n){
            for (j in i + 1 until n){
                for (k in j + 1 until n){
                    if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
                        if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j] )
                        {
                            a += 1
                        }
                    }
                }
            }
        }
        println(a)
    }
}


Measured memory_bytes: 38728
import java.util.*;
import java.io.*;

/*
   AtCoder contest
   coder : yoichidon
 */


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] X = new int[M];
        for(int m=0; m<M; m++) X[m]=sc.nextInt();
        Arrays.sort(X);
        int[] dX = new int[M-1];
        for(int m=0; m<M-1; m++) dX[m] = X[m+1]-X[m];
        Arrays.sort(dX);
        long ans = 0;
        for(int i=0; i<M-N; i++) ans += dX[i];
        System.out.println(ans);

    }
}


Measured memory_bytes: 50140
#include <stdio.h>
 
int main(void) {
  long long int number, max, min;
  long long int i, n;
    long long int sum = 0;
    scanf("%lld",&n);
    scanf("%lld",&number);
    max = number;
    min = number;
    sum += number;
    for(i = 1; i < n; i++ ) {
        scanf("%lld",&number);
        sum += number;
        if(number > max) {
            max = number;
        }
        if(number < min) {
            min = number;
        }
    }
    printf("%lld %lld %lld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 600
using System;

namespace ABC124
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            var res = (a==b) ? (a+b) : ((a>b) ? (a*2-1) : (b*2-1));

            Console.WriteLine(res.ToString());
        }
    }
}

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


int main() {
  ll n,k,q; cin >> n >> k >> q;
  vector<ll> a(q); rep(i,q)cin >> a[i];
  vector<ll>point(n,0);
  rep(i,q)point[a[i] - 1]++;
  rep(i,n){
    if(q - point[i] < k)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(int k)
{
    int S[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    printf("%d\n", S[k - 1]);
}

int
main(int argc, char *argv[])
{
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    int K;
    scanf("%d", &K);
    solver(K);
    return 0;
}

Measured memory_bytes: 128
from math import hypot
def dijkstra(s):
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0

    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True

        for j in range(n):
            d[j] = min(d[j], d[v] + cost[v][j])
    return d


sx, sy, gx, gy = map(int,input().split())
n = int(input())
edge = [(sx, sy, 0)]

for i in range(n):
    x, y, r = map(int,input().split())
    edge.append((x,y,r))
edge.append((gx, gy, 0))

cost = [[0] * (n + 2) for _ in range(n + 2)]
for j, (k1, k2, k3) in enumerate(edge):
    for l, (m1, m2, m3) in enumerate(edge):
        if j == l:
            continue
        else:
            cost[j][l] = max(hypot(k1 - m1, k2 - m2) - k3 - m3, 0)
n += 2

res = dijkstra(0)
print(res[-1])


Measured memory_bytes: 77148
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>
#include <string>
#include <numeric>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a;
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputDoubleArray(a,N) double a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  //input
  inputInt3(A,B,C);
  
  if(C-(A-B)>=0){cout << C-(A-B) << endl;}
  else{cout << 0 << endl;}
  
  return 0;
}

Measured memory_bytes: 256