akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return (a / g) * b;
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    ll H,W,ans;
    cin >> H >> W;
    ans = H*W;
    vector<ll> s(3);
    for (int h = 1; h <= H-1; ++h) {
        s[0] = h*W;
        s[1] = (H-h)*(W/2);
        s[2] = (H*W-s[0]-s[1]);
        sort(s.begin(),s.end());
        ans = min(ans,s[2]-s[0]);

        s[0] = h*W;
        s[1] = (H-h)/2*W;
        s[2] = (H*W-s[0]-s[1]);
        sort(s.begin(),s.end());
        ans = min(ans,s[2]-s[0]);
    }

    swap(H,W);

    for (int h = 1; h <= H-1; ++h) {
        s[0] = h*W;
        s[1] = (H-h)*(W/2);
        s[2] = (H*W-s[0]-s[1]);
        sort(s.begin(),s.end());
        ans = min(ans,s[2]-s[0]);

        s[0] = h*W;
        s[1] = (H-h)/2*W;
        s[2] = (H*W-s[0]-s[1]);
        sort(s.begin(),s.end());
        ans = min(ans,s[2]-s[0]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii ;
const int mod = 1e9 + 7;

ll binPow(ll x, ll y, ll md = mod){
    ll res = 1;
    x %= mod;
    while(y){
        if(y & 1){
            res = (res * x) % mod;
        }
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve(){
        ll a;
        ll b, c;
        char temp;
        cin >> a >> b >> temp >> c;
        cout << a * b + (a * c) / 100 << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 600010
using namespace std;

main(){
    int a,b;
    cin>>a>>b;
    cout<<((a*b%2)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

int N;
ll X;

ll patty[51];
ll bread[51];

ll ans = 0;

void setup() {
	patty[0] = 1, bread[0] = 0;
	for (int i = 1; i <= 50; i++) {
		patty[i] = 1 + patty[i - 1] * 2;
		bread[i] = bread[i - 1] * 2 + 2;
	}
}

void dfs(int level, ll pos) {

	if (pos == patty[level] + bread[level]) {
		ans += patty[level];
		return;
	}
	else if (pos < patty[level] + bread[level] && pos > 2LL + patty[level - 1] + bread[level - 1]) {
		ans += 1LL + patty[level - 1];
		dfs(level - 1, pos - 2LL - patty[level - 1] - bread[level - 1]);
	}
	else if (pos == 2 + patty[level - 1] + bread[level - 1]) {
		ans += 1LL + patty[level - 1];
		return;
	}
	else if (pos > 1LL && pos < 2 + patty[level - 1] + bread[level - 1]) {
		dfs(level - 1, pos - 1LL);
		return;
	}
	else if(pos == 1){
		return;
	}
}

int main() {

	setup();

	cin >> N >> X;

	dfs(N, X);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int isPrime(int x)
{

  int i;

  i = 3;

  if(x==2) return 1;

  if(x<2 || x%2==0) return 0;

  while(i*i<=x){
    if(x%i==0) return 0;
    i += 2;
  }
 
  return 1;

}

int main()
{

  int n, i, x, count;

  count = 0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isPrime(x)==1) count++;
  }

  printf("%d\n",count);

  return 0;

}



Measured memory_bytes: 2104
n, m = map(int, input().split())
s = input()
n += 1

pos = [n - 1]
ind = n - 1
while True:
    tmp = -1
    for i in range(1, m + 1):
        if s[max(ind - i, 0)] == "0":
            tmp = max(ind - i, 0)
    if tmp == -1:
        print(-1)
        exit()
    pos.append(tmp)
    ind = tmp
    if ind == 0:
        break
tmp = pos[::-1]
ans = []
for i in range(len(tmp) - 1):
    ans.append(tmp[i + 1] - tmp[i])
print(*ans)

Measured memory_bytes: 11076
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

map<int,int> fact(int x) {
  map<int,int> ret;
  for(int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      int cnt = 0;
      while(x % i == 0) {
        cnt++;
        x /= i;
      }
      ret[i] = cnt;
    }
  }
  if (x > 1) {
    ret[x] = 1;
  }
  return ret;
}

int main() {
  int N;
  cin >> N;
  map<int,int> S;
  for (int i = 1; i <= N; i++) {
    map<int,int> F = fact(i);
    for(auto e : F) {
      S[e.first] += e.second;
    }
  }

  ll ans = 1;
  for(auto e: S) {
    ans *= e.second + 1;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

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

const int N=2005;
vector<int> G[N],g[N];
int n;
int a[N],used[N];
priority_queue<int> pq;

int GCD(int x,int y){
	if(y==0) return x;
	return GCD(y,x%y);
}

void dfs(int x){
	used[x]=1;
	for(int i=0;i<G[x].size();i++){
		int to=G[x][i];
		if(!used[to]){
			g[x].push_back(to);
			dfs(to);
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(i!=j&&GCD(a[i],a[j])!=1) G[i].push_back(j);
	for(int i=1;i<=n;i++) if(!used[i]){
		dfs(i);
		pq.push(i);
	}
	while(!pq.empty()){
		int x=pq.top();
		pq.pop();
		printf("%d ",a[x]);
		for(int i=0;i<g[x].size();i++) pq.push(g[x][i]);
	}
	puts("");
	return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

pair<int , int> res;

int a[maxn] , n;

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

	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a , a + n);

	int k = lower_bound(a , a + n , a[n - 1] / 2) - a;

	if(k)
	{
		double t = a[n - 1] / 2;

		if(fabs(a[k] - t) > fabs(a[k - 1] - t) || k == n - 1)
			k--;
	}

	cout << a[n - 1] << " " << a[k] << endl;

}







Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

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! {
        m: usize,
        d: usize,
    }
    let mut ans = 0;
    for i in 22..d + 1{
        let d1 = i % 10;
        let d10 = i / 10;
        if d1 < 2{
            continue;
        }
        if d1 * d10 <= m{
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9;

int mp[100];

int nex (char x) {
    int y = x - 'a';
    for (int i = y; i < 26; i++)
        if (mp[i] == 0)
            return i;
    return -1;
}

int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++)
        mp[s[i] - 'a'] ++;

    if (n < 26) {
        cout << s;
        for (int i = 0; i < 26; i++)
            if (mp[i] == 0)
                return cout << char (i + 'a') << endl, 0;
    }
    for (int i = n - 1; i >= 0; i--) {
        if (nex (s[i]) != -1) {
            for (int j = 0; j < i; j++)
                cout << s[j];
            cout << char (nex (s[i]) + 'a') << endl;
            return 0;
        }
        mp[s[i] - 'a'] --;
    }
    cout << -1 << endl;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  cin >> xs;

  int sum = 0;
  for(int& x: xs){
	if(__builtin_popcount(x) == 1) continue;
	sum ^= x^(-x&x);
	x = -x&x;
  }
  RSORT(xs);
  vector<PII> cnt;
  for(int x: xs){
	if(cnt.empty() || cnt.back().FF != x)
	  cnt.EB(x, 1);
	else
	  ++cnt.back().SS;
  }

  int ans = 0;
  for(auto p: cnt){
	if(sum&p.FF){
	  sum ^= p.FF;
	  if(p.SS%2 == 0){
		++ans;
		sum ^= p.FF-1;
	  }
	}
	else if(p.SS%2){
	  ++ans;
	  sum ^= p.FF-1;
	}
  }

  cout << (sum==0?ans:-1) << endl;

  return 0;
}


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

#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	for (int N; cin >> N;) {
		int TT, AA; cin >> TT >> AA;
		rep(i, 1, N) {
			int T, A; cin >> T >> A;
			if (T < TT || A < AA) {
				int a = max(TT / T + (TT%T != 0), AA / A + (AA%A != 0));
				T *= a;
				A *= a;
			}
			TT = T;
			AA = A;
			dump(TT); dump(AA);
		}
		cout << TT + AA << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {

  def main(args: Array[String]) {
    val pqr = StdIn.readLine().split(' ').toList.map(_.toInt)
    val sum = pqr.foldLeft(0)((acc, x) => acc + x)
    val max = pqr.foldLeft(0)((max, x) => if (max < x) x else max)
    println(sum - max)
  }

}


Measured memory_bytes: 27200
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = INT_MAX / 3;
int other[1001], mi[1001][5001], lim[1001];
vi T[1001];

int dfs(int u) {
    int nc = sz(T[u]);
    vector<pii> ch;
    each(v, T[u])ch.emplace_back(lim[v], dfs(v));

    rep(i, nc + 1)rep(j, lim[u] + 1)mi[i][j] = INF;
    mi[0][0] = 0;
    rep(i, sz(T[u])) {
        int x, y;
        tie(x, y) = ch[i];
        if (y == INF)return INF;
        rep(cur, lim[u] + 1) if(mi[i][cur]!=INF){
            if (cur + x <= lim[u])smin(mi[i + 1][cur + x], mi[i][cur] + y);
            if (cur + y <= lim[u])smin(mi[i + 1][cur + y], mi[i][cur] + x);
        }
    }
    int res = INF;
    rep(i, lim[u] + 1)smin(res, mi[nc][i]);

    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    for (int c = 2; c <= N; ++c) {
        int p;
        cin >> p;
        T[p].push_back(c);
    }

    for (int i = 1; i <= N; ++i)cin >> lim[i];

    int res = dfs(1);
    string ans = "POSSIBLE";
    if (res == INF)ans = "IMPOSSIBLE";
    cout << ans << endl;
}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> void show(vector<T>v){rep(i,v.size()-1){cout<<v.at(i)<<" ";}cout<<v.at(v.size()-1)<<endl;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (n / (a + b)) * a + min(n % (a + b), a) << endl;
    return 0;
}

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

#define _ cin.tie(0);ios::sync_with_stdio(false);
using namespace std;

int main(){ _



    string str, tmp;
    while(cin >> str >> tmp){
    reverse(str.begin(), str.end());
    if(str == tmp) cout << "YES" << endl;
    else cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int ave = 0;
		int tmp;
		
		for(int i=0;i<5;i++){
			tmp = scan.nextInt();
			if(tmp < 40){
				tmp = 40;
			}
			ave += tmp;
		}
		System.out.println(ave/5);
	}
}

Measured memory_bytes: 17176
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() - 1;

        int res = 0;
        int[] b = new int[n];
        for(int i=0; i<n; i++) {
            b[i] = sc.nextInt();
        }
        for(int i=0; i<n-1; i++) {
            res += Math.min(b[i], b[i+1]);
        }
        res += b[0] + b[n-1];

        System.out.println(res);
    }

}


Measured memory_bytes: 21844
fun main(args: Array<String>) {
    var (W,a,b) = readLine()!!.split(" ").map(String::toInt)
    if(a<b){
        if(W+a>=b) println(0)
        else println(b -(W+a))
    }
    else{
        if(W+b>=a) println(0)
        else println(a -(W+b))
    }
}


Measured memory_bytes: 37904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<ll> a;
  a = divisor(N);
  
  ll  ans = 1e10;
  for(int i=a.size()-1;i>=0;i--){
    
  //  rep(i,a.size()){
    //    cout << a[i] << endl;
    //    rep(i,a.size()){
    if(N/a[i] > a[i]) break;
    ll tmp=0;
    while(a[i]>0){
      a[i]/=10;
      tmp++;
    }
    ans=min(ans,tmp);
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 768
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;}

vector<int> demical(ll n,int k,int l){
    vector<int> rtn(l);
    REP(i,l){
        rtn[i]=n%k;
        n/=k;
    }
    /*while(n>0){
        rtn.push_back(n%k);
        n/=k;
    }*/
    return rtn;
}

int n;
vector<int> a(3);

int main(){
    cin >> n;
    REP(i,3){
        cin >> a[i];
    }
    vector<int> l(8,1e6);
    REP(i,n){
        cin >> l[i];
    }
    int res = INT_MAX;
    ll f = pow(4,8);
    REP(i,f){
        int cost = 0;
        vector<int> v(4,0);
        vector<int> k = demical(i,4,8);
        REP(j,k.size()){
            v[k[j]]+=l[j];
            if(k[j]!=3)cost+=10;
        }
        REP(j,3){
            cost+=abs(v[j]-a[j]);
        }
        if(v[0]&&v[1]&&v[2]){
            chmin(res,cost);
        }
    }
    put(res-30);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define nl endl
#define tc    \
    ll t;     \
    cin >> t; \
    while (t--)
#define fastio                       \
    ios_base::sync_with_stdio(NULL); \
    cin.tie(NULL);                   \
    cout.tie(NULL);
using namespace std;
int main()
{
    fastio;
   int n,a,b;
   cin>>n>>a>>b;
   if((b-a-1)%2==0)
        cout<<"Borys";
    else
    {
        cout<<"Alice";
    }
    
}

Measured memory_bytes: 3620
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(x,y)=input.split(" ")
    if(x<y){
      "<"
    }else if(x==y){
      "="
    }else{
      ">"
    }
  }
}


Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	double n,d;
	vector<double>a[10];
	cin>>n>>d;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<d;j++){
			ll x;
			cin>>x;
			a[i].push_back(x);
		}
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			double now=0;
			for(ll k=0;k<d;k++){
				now+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
	//	cout << now<<endl;
		ll ans=sqrt(now);
		double ans2=ans*ans;
		if(ans2==now){
			cnt++;
		}			
		}

	}
	cout <<cnt;
	// your code goes here
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<ll> divisors;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      divisors.push_back(i);
      divisors.push_back(N / i);
    }
  }
  ll res = 0;
  for (ll d : divisors) {
    ll m = d - 1;
    if (m == 0) continue;
    if (N / m == N % m) res += m;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }
}

Measured memory_bytes: 3644
/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				push_back(z)
#define ff					/first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
//#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}

void start(){
      #ifndef ONLINE_JUDGE 
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}

void solve()
{
 	 ll n;cin>>n;
 	 string s;cin>>s;
 	 ll cnt=0;
 	 rep0(i,n){
 	 	cnt++;
 	 	ll pos=i+1;
 	 	while(s[i]==s[pos]){
 	 		pos++;
		  }
		  i=pos-1;
	  }
	  cout << cnt << nl;
}

int main() {
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";

		  solve();
	//}
	
	return 0;
}


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

using namespace std;

typedef  double ld;

const int maxA = 200000;

vector<int> a;
bool dp[20][maxA+1]; // dp[i][j]: j???i???????????§?????????
bool check(ld th, int b, int n) {
	return abs(a[n]-b) <= a[n]*th;
}
bool check(ld th) {
	int N = a.size();
	fill(dp[0], dp[20], false);
	for (int b0 = 1; b0 <= maxA; ++b0) {
		dp[0][b0] = check(th, b0, 0);
	}
	for (int i = 1; i < a.size(); ++i) {
		for (int j = 1; j <= maxA; ++j) {
			if (dp[i-1][j]) {
				for (int k = j; k <= maxA; k += j) {
					if (check(th, k, i)) {
						dp[i][k] = true;
					}
				}
			}
		}
	}
	for (int j = 1; j <= maxA; ++j) {
		if (dp[N-1][j]) return true;
	}
	return false;
}

int main() {
	int N; cin >> N; a.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	ld l = 0, r = 1e10;
	for (int t = 0; t < 100; ++t) {
		ld m = (l + r) / 2;
		if ( check(m) ) {
			r = m;
		}
		else {
			l = m;
		}
	}
	assert(check(r));
	cout << fixed << setprecision(10) << r << endl;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100005
#define INF 1000000000000000000
using Graph=vector<vector<int>>;

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> X(M),Y(M),Z(M);
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    cin>>X.at(i)>>Y.at(i)>>Z.at(i);
    X.at(i)--;
    Y.at(i)--;
    G.at(X.at(i)).push_back(Y.at(i));
    G.at(Y.at(i)).push_back(X.at(i));
  }

  vector<bool> know(N,false);
  int ans=0;
  for(int i=0;i<N;i++){
    if(know.at(i)){
      continue;
    }
    ans++;
    queue<int> q;
    q.push(i);
    know.at(i)=true;
    while(!q.empty()){
      int v=q.front();
      for(auto nv:G.at(v)){
        if(know.at(nv)){
          continue;
        }
        know.at(nv)=true;
        q.push(nv);
      }
      q.pop();
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7672
N = gets.to_i
STORE_OPENS = N.times.map{
  gets.split.join.to_i(2)
}
POINTS = N.times.map{
  gets.split.map(&:to_i)
}

N_MATCHES = Array.new(2**10){|i|
  i.to_s(2).chars.count("1")
}

ans = -Float::INFINITY
for i in 1...(2**10)
  pt = N.times.map{|k|
    n_matches = N_MATCHES[i & STORE_OPENS[k]]
    POINTS[k][n_matches]
  }.inject(:+)
  ans = pt if pt > ans
end
p ans


Measured memory_bytes: 2812
S = int(input())
mod = 10 ** 9 + 7
dp = [0] * (S + 1)
dp[0] = 1
for i in range(1, S + 1):
    for j in range(0, i - 3 + 1):
        dp[i] += dp[j]
        dp[i] %= mod
print(dp[S])


Measured memory_bytes: 9196
s = list(map(str,input()))
from collections import Counter
l = Counter(s)
abc = [l["a"],l["b"],l["c"]]
mx = max(abc)
mi = min(abc)
md = sum(abc)-mx-mi
if mx-mi == 1 or mx-mi == 0:
  print("YES")
else:
  print("NO")

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    int len = s.size() - 2;
    for (int i = len; i >= 0; i -= 2) {
      bool f = true;
      rep(j, i / 2) {
        if (s[j] != s[j + i / 2]) f = false;
      }
      if (f) {
        cout << i << '\n';
        return 0;
      }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 201
int main(void)
{
    char n[MAX], nn[MAX]; 
    int m, h, i, j;
    int len;
    while(scanf("%s", n), n[0] != '-'){
        len = strlen(n);
        scanf("%d", &m);
        for(i=0; i<m; i++){
            scanf("%d", &h);
            for(j=0; j<len-h; j++){
                nn[j] = n[h+j];
            }
            for(j=len-h; j<len; j++){
                nn[j] = n[j-(len-h)];
            }
            for(j=0; j<len; j++){
                n[j] = nn[j];
            }
        }
        printf("%s\n", n);
    }
    return 0;
}

Measured memory_bytes: 2596
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    vector<long long> A;
    cin >> N;
    A.resize(N);
    for(long long i=0; i<N; i++){
        long long input;
        cin >> input;
        A[i] = input;
    }

    vector<long long> B;
    B.resize(N);
    for(long long i=0; i<N; i++){
        B[i] = A[i] - i;
    }

    sort(B.begin(), B.end());

    long long ans = 0;
    for(long long i=0; i<N; i++){
        ans += abs(B[i] - B[N/2]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> tree(N, 0);
  for(int i=0; i<N; i++){
    int h;
    cin >> h;
    tree[i]=h;
  }
  stable_sort(tree.begin(), tree.end());
  int ans=1e9;
  for(int i=0; i<=N-K; i++){
    int a=tree[i], b=tree[i+K-1];
    ans=min(ans, b-a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
const main = stdin => {
  const input = stdin.trim().split('\n')

  const [A, B] = input[0].split(' ').map(x => parseInt(x))
  if (A % 2 !== B % 2) {
    console.log('IMPOSSIBLE')
    return
  }

  console.log((A + B) / 2)
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

int main() {
  int n,d,c=0;
  double x1,y1,b;
  cin >> n >> d;
  
  vector<double> x(n);
  vector<double> y(n);
  vector<double> a(n);
  for(int i; i<n;i++){
    cin >> x.at(i) >> y.at(i);
    x1 = x.at(i) * x.at(i);
    y1 = y.at(i) * y.at(i);
    a.at(i) = sqrt(x1 + y1) ;
  }
  sort(a.begin(), a.end());
  b = -1;
  for(int i; i<n;i++){
      b = a.at(i);
      if(a.at(i) <= d) c++;
  }
  cout << c;
}


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

//  fastIO
#define endl "\n"

// types
#define ll long long

// vectors 
#define vec_i std::vec<int>

// vectors operations
#define pb push_back
#define eb emplace_back
#define size(a) ((int)(a.size()))

// useful math
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a) >= (0)? (a):(-a)) 


ll gcd(ll a, ll b) {
    while(b != 0) {
        ll r = a % b;
        a = b;
        b = r;
    }   
    return a;
}

using namespace std;

int main() {
    string s;
    int n,k;

    cin >> n;
    cin >> s;
    cin >> k;

    for(int i = 0; i < n; i++) {
        if((s[i] != s[k-1]) ) cout << '*';
        else cout << s[i];
    }
    cout << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define forr(i,x,y) for(int i=x;i< y;i++)
#define sci(x) int x; cin>>x;
#define scii(x,y) int x,y; cin>>x>>y;
#define sciii(x,y,z) int x,y,z; cin>>x>>y>>z;
#define tc(x) sci(x); while(x--)
int main(){
    string s1,s2;
    cin>>s1>>s2;
    int ans=0;
    for(int i=0;i<s1.length();i++){
        if(s1[i]!=s2[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3916
let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let build_max_heap (t : int array) h =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= h && t.(l) > t.(i) then l else i in
    let m = if r <= h && t.(r) > t.(m) then r else m in
    if i = m then ()
    else
      let tmp = t.(i) in
      t.(i) <- t.(m);
      t.(m) <- tmp;
      max_heapify m in
  for i = parent h downto 1 do
    max_heapify i
  done

let () =
  let h = read_int () in
  let t = Array.make (h + 1) 0 in
  for i = 1 to h do
    t.(i) <- Scanf.scanf "%d " (fun i -> i)
  done;
  build_max_heap t h;
  for i = 1 to h do
    print_string " "; print_int t.(i)
  done;
  print_newline ()

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

using namespace std;
#define fast	ios::sync_with_stdio(0);cin.tie(0);
#define ll 		long long int
#define INF     1e18L
#define precision(x)	fixed << setprecision(x)
const ll mod = 1e9 + 7;

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


ll powm(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * 1LL * a) % mod;
		b >>= 1LL;
		a = (a * 1LL * a) % mod;
	}
	return res;
}
const int N = 2e5 + 5;
const int M = 2005;

//--------------------------------------------------------------------------------------------------------------------------//

void solve() {
	int n; cin >> n;

	for (int i = 0; i < n; i++) {
		cout << "ACL";
	}

}

int main() {
	fast
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int tc = 1;
	// cin >> tc;

	int _ = 0;
	while (_++ < tc) {
		solve();
	}

	return 0;
}






Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<queue>
#include<vector>
#include<stdlib.h>
#pragma warning(disable : 4996)
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAX_N = 20010;
struct edge
{
	int to, cost, val;
	edge(){}
	edge(int a, int b, int c) {
		to = a, cost = b, val = c;
	}
};

typedef pair<int, int> P;
vector<edge> G[MAX_N];
int dis[MAX_N], value[MAX_N];
void dijkstra(int s) {
	fill(dis, dis + MAX_N, inf);
	fill(value, value + MAX_N, inf);
	priority_queue<P, vector<P>, greater<P> > que;
	dis[s] = 0;
	que.push(P(0, s));
	while (!que.empty())
	{
		P p = que.top();
		que.pop();
		int v = p.second;
		if (dis[v] < p.first) continue;
		for (unsigned int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (dis[e.to] > dis[v] + e.cost) {
				value[e.to] = e.val;
				dis[e.to] = dis[v] + e.cost;
				que.push(P(dis[e.to], e.to));
			}
			else if (dis[e.to] == dis[v] + e.cost) {
				value[e.to] = min(value[e.to], e.val);
			}
		}
	}

}
int main() {
	int n, m, a, b, c, d;
	while (scanf("%d%d",&n,&m)!=-1)
	{
		if (n == 0 && m == 0)
			break;
		for (int i = 0; i < MAX_N; i++)
			G[i].clear();
		for (int i = 0; i < m; i++) {
			scanf("%d%d%d%d", &a, &b, &c, &d);
			G[a].push_back(edge(b, c, d));
			G[b].push_back(edge(a, c, d));
		}
		dijkstra(1);
		int ans = 0;
		for (int i = 2; i <= n; i++)
			ans += value[i];
		printf("%d\n", ans);
	}
	
	return 0;
}




Measured memory_bytes: 5428
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

ll modpow(ll a, ll b, ll m = mod) {
  ll r = 1;
  while (b > 0) {
    if (b & 1) r = (r * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return r;
}

ll modinv(ll x, ll m = mod) {
  ll b = m;
  ll u = 1;
  ll v = 0;
  ll tmp;
  while (b) {
    ll t = x / b;
    x -= t * b;
    tmp = x;
    x = b;
    b = tmp;
    u -= t * v;
    tmp = u;
    u = v;
    v = tmp;
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

  ll n, k;
  cin >> n >> k;

  vector<ll> factorial(400000);
  factorial[0] = 1;
  for (int i = 1; i < 400000; i++) {
    factorial[i] = (factorial[i-1] * i) % mod;
  }

  vector<ll> ncr_box(n+1);
  ncr_box[0] = 1;
  for (int i = 1; i <= n; i++) {
    ncr_box[i] = (factorial[n] * modinv((factorial[i] * factorial[n-i]) % mod)) % mod;
  }

  vector<ll> ncr_human(n+1);
  ncr_human[0] = 0;
  for (int i = 1; i <= n; i++) {
    ncr_human[i] = (((factorial[(n-1)] * modinv((factorial[(i-1)] * factorial[(n-1)-(i-1)]) % mod)) % mod) * ncr_box[i]) % mod;
  }

  ll ans = 0;
  for (int i = n; i > max(0LL, n-k-1); i--) {
    ans = (ans + ncr_human[i]) % mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static bool[] seen;
        static bool[,] map;
        static int n;
        static void Main(string[] args)
        {
            int[] nm = ReadLine().Split(' ').Select(int.Parse).ToArray();
            n = nm[0];
            int m = nm[1];
            map = new bool[n,n];
            seen = new bool[n];
            var ls = new List<MyClass>();
            for (int i = 0; i < m; i++)
            {
                int[] ab = ReadLine().Split(' ').Select(int.Parse).ToArray();
                int a = ab[0] - 1;
                int b = ab[1] - 1;
                ls.Add(new MyClass(a, b));
                map[a, b] = true;
                map[b, a] = true;
            }
            DFS(0);
            int ans = 0;
            for (int i = 0; i < m; i++)
            {
                seen = new bool[n];
                map[ls[i].a, ls[i].b] = false;
                map[ls[i].b, ls[i].a] = false;

                if (i == 0) DFS(1);
                else DFS(0);

                if (seen.Count(x => x == true) != n)
                {
                    ans++;
                }

                map[ls[i].a, ls[i].b] = true;
                map[ls[i].b, ls[i].a] = true;
            }
            WriteLine(ans);
        }

        static void DFS(int v)
        {
            seen[v] = true;
            for (int v2 = 0; v2 < n; v2++)
            {
                if (map[v, v2] == false) continue;
                if (seen[v2] == true) continue;
                DFS(v2);
            }
        }
    }

    class MyClass
    {
        public MyClass(int a, int b)
        {
            this.a = a;
            this.b = b;
        }

        public int a { get; set; }
        public int b { get; set; }
    }
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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 (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, K;
lint arr[1000], sums[1001];
bool flag[1100000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> K;
	REP(i, N) {
		cin >> arr[i];
	}
	sums[0] = 0;
	REP(i, N) {
		sums[i + 1] = sums[i] + arr[i];
	}
	vector<lint> vec;
	REP(i, N) {
		FOR(j, i + 1, N + 1) {
			vec.push_back(sums[j] - sums[i]);
		}
	}
	lint ans = 0;
	IREP(i, 41) {
		lint cnt = 0;
		REP(j, SZ(vec)) {
			if (flag[j]) continue;
			if ((vec[j] >> i) % 2 == 1) cnt++;
		}
		if (cnt >= K) {
			ans += (1ll << i);
			REP(j, SZ(vec)) {
				if ((vec[j] >> i) % 2 == 0) flag[j] = true;
			}
		}
	}
	cout << ans << endl;
}


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

v dp(10001, 1001001001);

//個数制限なしナップサック問題
int main(){
    int h,n;
    cin >>h>>n;
    
    v a(n), b(n);
    rep(i,n)cin >> a[i] >> b[i];
    
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int x=0; x<h; x++){
            int nx = min(h,x+a[i]);
            dp[nx] = min(dp[nx], dp[x]+b[i]);
        }
    }
    
    cout << dp[h] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
ll n,s;
ll f(ll b,ll n)
{
	if(n<b)return n;
	return f(b,n/b)+(n%b);
}
ll solve()
{
	for(ll i=2;i*i<=n;++i)
		if(f(i,n)==s)return i;
	if(n<s)return -1;
	if(n==s)return n+1;
	ll now=n-s,ans=1e12,k,b,r,mn=sqrt(n);
	for(ll i=1;i*i<=now;++i)
	{
		if(now%i==0)
		{
			k=now/i,b=i+1,r=n-k*b;
			if(0<=r&&r<b&&b>mn)ans=min(ans,b);
			k=i,b=now/i+1,r=n-k*b;
			if(0<=r&&r<b&&b>mn)ans=min(ans,b);
		}
	}
	if(ans==1e12)return -1;
	return ans;
}
int main()
{
	scanf("%lld%lld",&n,&s);
	printf("%lld\n",solve()); 
	return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){	
	
	string s;
	cin >> s;
	if(s.size()%2!=0){
		reverse(s.begin(),s.end());
	}
	cout << s << endl;	
	
	return 0;
}


Measured memory_bytes: 3600
class Node:
	def __init__(self):
		self.parent = -1
		self.type = "internal node"
		self.sibling = -1
		self.degree = 2
		self.height = 0
		self.left = -1
		self.right = -1
		self.depth = 0

def setDepth(id, depth):
	global T
	T[id].depth = depth
	left = T[id].left
	right = T[id].right
	if left != -1:
		setDepth(left, depth + 1)
	if right != -1:
		setDepth(right, depth + 1)


def setHeight(H: int, u: int):
	global T
	h1 = 0
	h2 = 0
	if T[u].right != -1:
		h1 = setHeight(H, T[u].right) + 1
	if T[u].left != -1:
		h2 = setHeight(H, T[u].left) + 1
	height = max(h1, h2)
	T[u].height = height
	return height


if __name__ == "__main__":
	n = int(input())
	T = []
	for _ in range(n):
		T.append(Node())
	for _ in range(n):
		id, left, right = map(int, input().split())
		T[id].left = left
		T[id].right = right
		if left != -1:
			T[left].sibling = right
			T[left].parent = id
		if right != -1:
			T[right].sibling = left
			T[right].parent = id
	
	for i in range(n):
		if T[i].left == -1:
			T[i].degree -= 1
		if T[i].right == -1:
			T[i].degree -= 1
		if T[i].left == -1 and T[i].right == -1:
			T[i].type = "leaf"
		if T[i].parent == -1:
			root_id = i
			T[i].type = "root"

	setDepth(root_id, 0)
	setHeight(0, root_id)

	for i in range(n):
		node = T[i]
		print(f"node {i}: parent = {node.parent}, sibling = {node.sibling}, degree = {node.degree}, depth = {node.depth}, height = {node.height}, {node.type}")


Measured memory_bytes: 5632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647;
const long long int llINF = 9223372036854775807;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  vl A;
  string S;
  cin >> S;
  ll lose = 0;
  REP(i, S.size()) {
    if (S[i] == 'x')
      lose++;
  }
  if (lose <= 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
program digit_sum
  implicit none
  integer(8), parameter :: md = 1000000007_8
  character(10000) :: k
  integer :: d, n, i, j, l, x = 0, y = 1, t, m = 0
  integer(8) :: dp(0:1,0:100,0:1) = 0_8
  read(*,*) k
  read(*,*) d
  n = len_trim(k)
  dp(0,0,1) = 1_8
  do i = 1, n
    t = ichar(k(i:i))-48
    dp(y,:,:) = 0_8
    dp(y,mod(m+t,d),1) = dp(x,m,1)
    do j = 0, d-1
      do l = 0, t-1
        dp(y,mod(j+l,d),0) = mod(dp(y,mod(j+l,d),0)+dp(x,j,0)+dp(x,j,1),md)
      end do
      do l = t, 9
        dp(y,mod(j+l,d),0) = mod(dp(y,mod(j+l,d),0)+dp(x,j,0),md)
      end do
    end do
    m = mod(m+t,d)
    x = xor(x,1)
    y = xor(y,1)
  end do
  write(*,'(i0)') modulo(dp(x,0,0)+dp(x,0,1)-1_8,md)
end program digit_sum

Measured memory_bytes: 256
<?php
trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$c = array_count_values($a);
$x[] = 0;
foreach($c as $key => $val){
if($val > 1){
if($val > 3){
$x[] = $key;
}
$x[] = $key;
}
}
$n = count($x);
if($c < 3){
echo 0;
}else{
rsort($x);
echo $x[0] * $x[1];
}

Measured memory_bytes: 35292