akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair


int n, m, x, y, a[202020];
vi adj[202020];
set<int> p, q;
bool vis[202020];
map<int, int> mp;

void dfs (int s){

if(vis[s])return;
vis[s]=true;

p.insert(s);
q.insert(mp[s]);

for(auto u: adj[s]){
    if(!vis[u])
    dfs(u);
}

}


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n >> m;

rep(i, 1, n){

cin >> a[i] ;
mp[a[i]] = i;

}

rep(i, 1, m){

cin >> x >> y;

adj[x].pb(y);
adj[y].pb(x);

}

int cnt =0;
rep(i, 1, n){

if(vis[i])continue;

dfs(i);

//sort(q.begin(), q.end());

for(auto t: p){
    auto l = q.find(t);
    if(l!=q.end())cnt++;
}

q.clear();
p.clear();

}

cout << cnt << endl;

return 0;}


Measured memory_bytes: 27776
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        int count = int.Parse(Console.ReadLine());
        string line = Console.ReadLine();
        string[] strs = line.Split(' ');
        int[] nums = new int[count];

        int[] array = new int[100002];

        for (int i = 0; i < count; i++)
        {
            nums[i] = int.Parse(strs[i]);
            for (int x = 0; x < 3; x++)
            {
                array[nums[i] + x]++;
            }
        }
        int max = 0;
        for (int i = 0; i < 100002; i++)
        {
            if (array[i] > max)
                max = array[i];
        }

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

Measured memory_bytes: 19296
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  string s;
  cin >> s;

  string ans = "";

  rep(i, s.size()){
    if(s[i] != 'B'){
      ans += s[i];
    } else{
      if(ans.size() > 0){
		ans.pop_back();
      }
    }
  }

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

Measured memory_bytes: 256
def gcd(a, b):
  l = max(a, b)
  s = min(a, b)
  if s == 0:
    return l
  else:
    return gcd(s, l%s)

n = int(input())
A = [0] + list(map(int, input().split())) + [0]
largest = 0
L = [0 for _ in range(n+2)]
R = [0 for _ in range(n+2)]
for i in range(1, n+2):
  L[i] = gcd(A[i], L[i-1])
  R[n-i+1] = gcd(R[n-i+2], A[n-i+1])

print(max(gcd(L[i-1],R[i+1]) for i in range(1, n+1)))


Measured memory_bytes: 14488
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
void build(){

}
LL n , x;
void init(){
  n = getint();
  x = getint();
}
void solve(){
  LL ans = 0;
  ans = n; n -= x;
  while( x && n ){
    if( n == x ){
      ans += n; break;
    }
    if( n < x ){
      ans += 2 * ( x / n ) * n;
      if( ( x / n ) * n == x )
        ans -= n;
      x %= n;
    }else{
      ans += 2 * ( n / x ) * x;
      if( ( n / x ) * x == n )
        ans -= x;
      n %= x;
    }
  }
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

ll power(ll n, ll p, ll mod) {
    ll ans = 1;
    while (p > 0) {
        if (p & 1) ans = ans * n % mod;
        n = n * n % mod;
        p >>= 1;
    }
    return ans;
}

int main() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int N; string X; cin >> N >> X;

    ll popcount = 0;
    for (auto c : X) if (c == '1') popcount++;

    ll base1 = 0, base2 = 0;
    for (auto c : X) {
        int n = c - '0';
        base1 = 2 * base1 + n;
        base1 %= (popcount + 1);

        if (popcount > 1) {
            base2 = 2 * base2 + n;
            base2 %= (popcount - 1);
        }
    }

    REP(i, 0, N) {
        ll num, ans = 1;
        if (X[i] == '0') {
            num = (base1 + power(2, N - i - 1, popcount + 1)) % (popcount + 1);
        } else  {
            if (popcount == 1) {
                cout << 0 << endl;
                continue;
            }
            num = ((popcount - 1) + base2 - power(2, N - i - 1, popcount - 1)) % (popcount - 1);
        }

        while (num) {
            num %= __builtin_popcount(num);
            ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3736
#include<stdio.h>
#include<stdlib.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

	unsigned short *A, *B;

	int n, i, max;
	scanf("%d", &n);

	A = (unsigned short*)malloc(sizeof(short) * n + 1);
	B = (unsigned short*)malloc(sizeof(short) * n + 1);

	max = (1<<30)*-1;
	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		max = MAX(max, A[i+1]);
	}

	int C[max+1] = {0};

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	free(A);
	free(B);
	return 0;
}



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

int main() {
  int n,k;
  cin>>n>>k;
  int ans=0;
  while(n>0){
      //ans+= to_string(n%k);
      n=n/k;
      ans++;
  }
  cout<<ans;
  return 0;
}

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

int main(){
  int n;
  bool ans=false;
  cin >> n;
  for(int i=1;i<=9;i++){
    if(n%i==0){
      if(n/i<=9){
        ans=true;
        break;
      }
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

int main(){

	lli x;
	cin>>x;

	lli flag[1100];
	REP(i,0,1100)flag[i]=0;

	flag[1]=1;

	for(lli i=2;i<=1100;i++){
		lli now=i*i;
		while(now<1100){
			flag[now]=1;
			now*=i;
		}
	}

	lli ans=0;
	for(lli i=0;i<=x;i++){
		if(flag[i]==1)ans  = max(ans,i);
	}

	cout<<ans<<endl;

	return 0;
}


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

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

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

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

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

	llong ret = mpow(n, m/2);
	ret = ret * ret % mod;
	if (m & 1) ret = ret * n % mod;

	return ret;
}

int main() {
	llong x, y;
	cin >> x >> y;

	llong n, m;

	n = 2 * y - x;
	if (n % 3 != 0 || n < 0) {
		cout << 0 << endl;
		return 0;
	}
	n /= 3;

	m = x - n;
	if (m % 2 != 0 || m < 0) {
		cout << 0 << endl;
		return 0;
	}
	m /= 2;

	llong ret = 1;
	for (int i = 1; i <= n + m; ++i) {
		ret = ret * i % mod;
		if (i <= n) {
			ret = ret * mpow(i, mod-2) % mod;
		}
		if (i <= m) {
			ret = ret * mpow(i, mod-2) % mod;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    string str;
    cin>>str;
    int dp[n][2];
    if(str[0] == '.'){
        dp[0][0] = 0;
        dp[0][1] = 1;
    }else{
        dp[0][0] = 1;
        dp[0][1] = 0;
    }
    
    for(int i=1;i<n;i++){
        if(str[i] == '.'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = 1 + min(dp[i-1][0],dp[i-1][1]);
        }else{
            dp[i][0] = 1 + dp[i-1][0];
            dp[i][1] = min(dp[i-1][0],dp[i-1][1]);
        }
    }
    cout<<min(dp[n-1][0],dp[n-1][1])<<"\n";
    return 0;
}


Measured memory_bytes: 2180
#[allow(dead_code)]
fn main() {
    let (n, m, x) = i::u3();
    let mut c = Vec::new();
    let mut a = Vec::new();
    for _i in 0..n {
        c.push(i::u());
        a.push(i::uv(m));
    }

    let case = 1 << n;
    let mut ans = std::usize::MAX;
    'case: for i in 0..case {
        let mut argo = vec![0; m];
        let mut cost = 0;
        for j in 0..n {
            if i >> j & 1 == 0 {
                continue;
            }
            cost += c[j];
            for k in 0..m {
                argo[k] += a[j][k];
            }
        }
        for k in 0..m {
            if argo[k] < x {
                continue 'case;
            }
        }
        ans = min(ans, cost);
    }
    if ans == std::usize::MAX {
        println!("{}", -1);
        return;
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2132
#include<iostream>
#include<algorithm>
using namespace std;
bool compare(pair<int,int> a,pair<int,int> b){
	return a.first < b.first;
}
int main() {
	int n, t;
	cin >> n >> t;
	pair<int, int> a[10000];
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
	sort(a, a + n,compare);
	int i;
	for (i = 0; i < n; i++) {
		if (a[i].second <= t) {
			cout << a[i].first << endl;
			return 0;
		}
	}
	cout << "TLE" << endl;
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3

import math

def rnd(n):
    return math.ceil(n / 10) * 10

if __name__ == '__main__':
    meal = [int(input()) for _ in range(5)]
    ans = 0
    for i in meal:
        if i % 10 == 0:
            ans += i
            meal.remove(i)
    m = sorted(meal, key=lambda x: x % 10, reverse=True)
    for i in m[:-1]:
        ans += rnd(i)
    ans += m[-1]

    print(ans)

Measured memory_bytes: 3064
from scipy.misc import comb

def c(a, b):
    return comb(a, b, exact=True)

n, k = map(int, input().split())
MOD = 10**9+7
memo = 0
for i in range(1, k+1):
    print((c(n-k+1, i) * c(k-1, i-1)) % MOD)


Measured memory_bytes: 13512
#include <stdio.h>
#include <math.h>
 
int main(void)
{
  double i, j, n; 
  double result;
  
  scanf("%lf", &n);
  result = 2 *n * 3.141592;
  
  printf("%.10lf\n", result);
  return 0;
}

Measured memory_bytes: 1748
s = int(input())
a_list = []
a = s
a_list.append(a)
for i in range(2,1000000):
  if a%2 == 0:
    a = a/2
  else:
    a = 3*a+1
  if a not in a_list:
    a_list.append(a)
  else:
    print(i)
    break

Measured memory_bytes: 2940
# coding: utf-8
# Your code here!

import math

def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = map(int, input().split())
print(combinations_count(N,2) + combinations_count(M,2))

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;


const int MOD = 100000;

int N, M, S;
int dp[50][3005];
int main() {
	while (cin >> N >> M >> S, N) {
		for (int n = 0; n <= N*N; n++) {
			for (int s = 0; s <= S; s++) {
				dp[n][s] = 0;
			}
		}

		dp[0][0] = 1;
		for (int m = 1; m <= M; m++) {
			for (int n = N*N; n >= 1; n--) {
				for (int s = m; s <= S; s++) {
					dp[n][s] += dp[n - 1][s - m] % MOD;
					dp[n][s] %= MOD;
				}
			}
		}

		cout << dp[N*N][S] << endl;

	}

	return 0;
}



Measured memory_bytes: 3668
a = int(input())
b = list(map(int, input().split()))
b = sorted(b, reverse=True)
c = []
d = []
for i in range(1, len(b)):
    if i-1 not in d:
        if b[i] == b[i-1]:
            c.append(b[i])
            d.append(i)
        if len(c) == 2:
            print(c[0] * c[1])
            exit()
print(0)


Measured memory_bytes: 14252
class BIT:
    def __init__(self,n):
        self.size=n
        self.tree=[0]*-~n
    def sum(self,i):
        s=0
        while i:
            s+=self.tree[i]
            i-=i&-i
        return s
    def add(self,i,x):
        while i<=self.size:
            self.tree[i]+=x
            i+=i&-i
n,*a=map(int,open(0).read().split())
m=n*-~n//2+1>>1
ng=max(a)+1
ok=0
while ng-ok>1:
    mid=(ok+ng)//2
    b=BIT(n-~n)
    c=n+1
    s=0
    b.add(c,1)
    for t in a:
        c+=1if t>=mid else-1
        s+=b.sum(c)
        b.add(c,1)
    if s>=m:ok=mid
    else:ng=mid
print(ok)

Measured memory_bytes: 102140
#include <iostream>

using namespace std;
typedef long long ll;

#define max_i 100
#define max_j 10000
int dp[max_i+1][max_j+1];

void solve(){
  int n,m;
  int v[max_i+1],w[max_i+1];

  std::cin >> n>>m;
  for (int i = 0; i < n; i++) {
    /* code */
    std::cin >> v[i]>>w[i];
  }
  for (int i = 0; i < n; i++) {
    for(int j = 0;j<=m;j++){
      if(j<w[i]){
        dp[i+1][j] = dp[i][j];
      }else{
        dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }
    }
  }

  std::cout << dp[n][m] << '\n';
}

int main(){
  solve();
return 0;
}



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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = abs(a[i] - x);
  }
  int ans = a[0];
  for (int i = 1; i < n; i++) {
    ans = gcd(ans, a[i]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<queue>
#include<utility>
#include<vector>
using namespace std;
int V,E,R,S[500010],T[500010],D[500010];
int C[100010];
int const inf=10000*100000+100;
typedef pair<int,int>P;
priority_queue<P,vector<P>,greater<P> > Q;
struct list{
    int d,t;
};
vector<list> edges[500010];
int main(){
    cin>>V>>E>>R;
    for(int i=0;i<E;++i){
        cin>>S[i]>>T[i]>>D[i];
        list L;
        L.d=D[i];
        L.t=T[i];
        edges[S[i]].push_back(L);
    }
    for(int j=0;j<V;++j){
        if(j==R){
            C[j]=0;
        }
        else C[j]=inf;
    }
    Q.push(P(0,R));
    while(!Q.empty()){
        P n=Q.top();
        Q.pop();
        int m1=n.first;//distance
        int m2=n.second;//To...
        if(C[m2]<m1)continue;
        for(int i=0;i<edges[m2].size();++i){
            list L=edges[m2][i];
            if(C[L.t]>C[m2]+L.d){
                C[L.t]=C[m2]+L.d;
                Q.push(P(C[L.t],L.t));
            }
        }
    }
    for(int i=0;i<V;++i){
        if(C[i]==inf)cout<<"INF"<<endl;
        else cout<<C[i]<<endl;
    }
}

Measured memory_bytes: 28100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
using namespace std;
bool f(string s)
{
    int n = s.size();
    if(s[0] == '0' || s[n-1] == '1')
    {
        return 1;
    }
    for(int i = 0; i < n-1; i++)
    {
        if(s[i] != s[n-2-i])
            return 1;
    }
    int x = 0;
    for(int i = 1; i < n; i++)
    {
        printf("%d %d\n", x+1, i+1);
        if(s[i-1] == '1')
            x = i;
    }
    return 0;
}
int main()
{
    string s;
    while(cin >> s)
    {
        if(f(s))
            printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#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() {
    int a,b;
    cin>>a>>b;
    int ans=a+b;
    if (ans>=24) ans-=24;
    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;

int main() {
  int N;  cin >> N;
  
  vector<int> vec(N);
  rep(i, N) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  double value = vec.at(0);
  for (int i = 1; i < N; i++) value = (value + vec.at(i)) / 2;
  
  printf("%.10f\n", value);
  return 0;
}


Measured memory_bytes: 256
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    readb(n, W) 
    int v[n+1], w[n+1];

    fori (i, 1, n) cin >> w[i] >> v[i];

    int V = 1000*n;
    int dp[1000*n + 1];
    dp[0] = 0;

    fori (i, 1, V) dp[i] = INF;

    fori (i, 1, n)
    {
        ford (j, V, 0) 
            if(j - v[i] >= 0) dp[j] = min(dp[j], w[i] + dp[j - v[i]]);
    }

    ford (i, V, 0) if(dp[i] <= W) {print(i) return 0;}

    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i= 0; i < N; i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += l.at(l.size()-1);
    l.pop_back();
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1e5;

int n,Vr,Vc;
long long ans;

struct MERGESET{
	int fa[4*N+3],cntx[4*N+3],cnty[4*N+3];
	void Init(int Vn){
		for(int i=1;i<=Vn;i++){
			fa[i]=i;
			if(i<=n) cntx[i]=1,cnty[i]=0;
			else cntx[i]=0,cnty[i]=1;
		}
	}
	int FindFa(int x){return fa[x]=fa[x]==x? x:FindFa(fa[x]);}
	void Merge(int x,int y){
		int fx=FindFa(x),fy=FindFa(y);
		if(fx==fy) return;
		fa[fx]=fy;
		cntx[fy]+=cntx[fx];cntx[fx]=0;
		cnty[fy]+=cnty[fx];cnty[fx]=0;
	}
}mgset;

struct NODE{int x,y,val;}nod[N+3];
bool cmpNODE(NODE Ca,NODE Cb){return Ca.val>Cb.val;}

int main(){
	scanf("%d%d%d",&n,&Vr,&Vc);
	mgset.Init(n+Vr+Vc);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&nod[i].x,&nod[i].y,&nod[i].val);
	sort(nod+1,nod+1+n,cmpNODE);
	for(int i=1;i<=n;i++){
		int x=nod[i].x,y=nod[i].y;
		int fx=mgset.FindFa(x+n),fy=mgset.FindFa(y+n+Vr);
		int cntx,cnty;
		if(fx==fy) cntx=mgset.cntx[fx],cnty=mgset.cnty[fx];
		else cntx=mgset.cntx[fx]+mgset.cntx[fy],cnty=mgset.cnty[fx]+mgset.cnty[fy];
		if(cntx+1>cnty) continue;
		ans+=nod[i].val;
		mgset.Merge(i,x+n);
		mgset.Merge(x+n,y+n+Vr);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5504
d=list(map(int,input().split()))
xy = [map(int, input().split()) for _ in range(int(d[0]))]
x, y = [list(i) for i in zip(*xy)]
n=0
for a in range(0,int(d[0])):
    if int(x[a])*int(x[a])+int(y[a])*int(y[a])<=int(d[1])*int(d[1]):
        n+=1
print(n)

Measured memory_bytes: 116716
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int n, m;
    if (scanf("%d%d", &n, &m) < 2) return 0;

    printf("%d\n", (n - 1) * (m - 1));
    return 0;
}


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

int main() {
  int64_t x, f;
  std::cin >> x;
  const auto y = x;
  f = 0;

  while (x != 0) {
    f += x % 10;
    x /= 10;
  }

  if (y % f == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll n;
string s;

int main(void) {
    cin >> n;
    ll t = 1, num = 26, c = 1;
    while (1) {
        t += num;
        if (t>n) {
            t -= num;
            break;
        }
        num *= 26;
        c++;
    }
    n = n-t;
    rep(i, 0, c) s += 'a';

    int d = c-1;
    while (n>0) {
        ll r = n%26;
        s[d] = r + 'a';
        d--;
        n = (n-r)/26;
    }


    cout << s << "\n";
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define int long long
#define rep(i,x) for (int i = 0; i < x; ++i)

int rui[100010];
int arui[100010];

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

    int asum = 0;

    vector<int> a(N);

    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        asum += (a[i] >= 0 ? a[i] : 0);
        rui[i+1] = a[i];
        arui[i+1] = (a[i] >= 0 ? a[i] : 0);
        if (i) {
            rui[i+1] += rui[i];
            arui[i+1] += arui[i];
        }
    }

    int ma = 0;

    for (int i = 0; i <= N - K; ++i) {
        int v = asum - (arui[i + K] - arui[i]);
        int vv = rui[i + K] - rui[i];
        if (vv > 0) v += vv;
        //cout << "i = " << i << ", v = " << v << endl;
        ma = max(ma, v);
    }
    cout << ma << endl;
}


Measured memory_bytes: 2560
object Main {
    def main(args : Array[String]) : Unit = {
        solve()
    }

    def solve() : Unit = {
        val sc = new java.util.Scanner(System.in)
        var N = sc.nextInt
        var A = List.fill(N)(sc.nextInt)
        thumbnail(A,N)
    }

    def getAvarage(A : List[Int], N : Int) : Double = {
        return A.sum.toDouble / N
    }

    def thumbnail(A : List[Int], N: Int) : Unit = {
        var avg = getAvarage(A, N)
        var dif = (0 until N).map(i => (A(i) - avg).abs)
        println(dif.indexOf(dif.min))
    } 
}

Measured memory_bytes: 27340
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

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

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n;cin>>n;
  vi v(n);
  rep(i,n) cin >>v[i];
  sort(all(v));
  double ave =v[0];
  f(i,1,n) ave = (ave +v[i])/2;
  

  
  pri(ave);
}
  


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

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

    vector<int> value(n), weight(n);
    for (auto i = 0; i < n; i++) cin >> value[i] >> weight[i];

    vector<vector<int>> dp(n, vector<int>(w + 1, 0));
    for (auto i = 0; i + weight[0] <= w; i++) {
        dp[0][i + weight[0]] = dp[0][i] + value[0];
    }
    for (auto i = 1; i < n; i++) {
        for (auto j = 0; j <= w; j++) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j]);
            if(j + weight[i] <= w) {
                dp[i][j + weight[i]] = max(dp[i - 1][j + weight[i]], dp[i][j] + value[i]);
            }
        }
//        for (auto j = 0; j < n; j++) {
//            for (auto k = 0; k <= w; k++) {
//                cout << dp[j][k] << " ";
//            }
//            cout << endl;
//        }
    }

    cout << dp[n - 1][w] << endl;

    return 0;
}


Measured memory_bytes: 6844
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=1e5+5;
int n,id[N],fa[N],siz[N]; ll a[N]; map<ll,int> mp;
bool cmp(int x,int y){ return a[x]>a[y]; }
int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%lld",&a[i]);
		mp[a[i]]=i; id[i]=i; siz[i]=1;
	}
	sort(id+1,id+1+n,cmp);
	//rep(i,1,n) cout<<id[i]<<" ";
	//cout<<endl;
	rep (i,1,n-1){
		int x=id[i];
		fa[x]=mp[a[x]-n+2*siz[x]];
		//cout<<x<<" "<<fa[x]<<endl;
		if (!fa[x]) return puts("-1"),0;
		siz[fa[x]]+=siz[x];
	}
	rep (i,1,n-1) a[id[n]]-=siz[id[i]];
	if (a[id[n]]) return puts("-1"),0;
	rep (i,1,n-1) printf("%d %d\n",id[i],fa[id[i]]);
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N,K; cin >> N >> K;

    ll A[200005];

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

    ll dist[200005];
    memset(dist,-1,sizeof(dist));
    ll now = 1;
    dist[1] = 0;
    ll nd = 0;

    map<ll,ll> mp;

    mp[0] = 1;

    while(true){
        nd++;
        now = A[now];
        if(dist[now] != -1) break;
        dist[now] = nd;
        if(nd == K){
            cout << now << endl;
            return 0;
        }
        mp[nd] = now;
    } 

    //cout << now << " " << nd << endl;

    ll rem = K-nd;
    rem %= nd-dist[now];

    //cout << rem << endl;

    cout << mp[dist[now]+rem] << endl;

    return 0;

}

Measured memory_bytes: 16724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,N) for(int i=0;i<N;++i)
using namespace std;
typedef long long int ll;

ll mod=998244353;

ll power(ll a,ll b){
  ll res=1;
  rep(i,b){
    res*=a;
    res%=mod;
  }
  return res;
}

int main() {
  int N;
  cin>>N;
  
  vector<int> b(N);
  rep(i,N){
    int d;
    cin>>d;
    
    if(i==0 && d!=0){
      cout<<0<<endl;
      return 0;
    }
    
    ++b[d];
  }
  
  ll ans=1;
  if(b[0]!=1){
    ans=0;
  }
  else{
    rep(i,N-1){
      ans*=power(b[i],b[i+1]);
      ans%=mod;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int a,b;
    cin >> a >> b;
    if (a == b) cout << a << endl;
    else {
        if (abs(b - a) & 1) {
            cout << "IMPOSSIBLE" << endl;
        } else {
            cout << abs(a-b) / 2 + min(a,b) << endl;
        }
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())

answer = ''

for i in range(40):
    if N % (2**(i + 1)) != 0:
        N -= (-2)**i
        answer = '1' + answer
    else:
        answer = '0' + answer
while len(answer) > 1 and answer[0] == '0':
    answer = answer[1:]

print(answer)


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

int main()
{
    int n,a;
    cin >> n >> a;
  	if (n % 500 > a)
    {
    	cout << "No" << endl;
    }
  	else
    {
    	cout << "Yes" << endl;
    }
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

class Dice {
public:
	int top, face[6];
	void East() {
		top = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = top;
	}
	void West() {
		top = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = top;
	}
	void North() {
		top = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = top;
	}
	void South() {
		top = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = top;
	}
};


int main() {
	int i, j, k, l, q, x, y, w;
	Dice dice, DICE;
	for (i = 0; i < 6; i++)
		cin >> dice.face[i];
	for (i = 0; i < 6; i++)
		cin >> DICE.face[i];
		for (i = 0; i < 6; i++){
			if (i == 4) dice.North();
			else if (i == 5) {
				dice.South();
				dice.South();
			}
			else dice.East();
			for (j = 0; j < 4; j++){
				k = dice.face[1];
				dice.face[1] = dice.face[2];
				dice.face[2] = dice.face[4];
				dice.face[4] = dice.face[3];
				dice.face[3] = k;
				if (dice.face[0] == DICE.face[0] && dice.face[1] == DICE.face[1] && dice.face[2] == DICE.face[2] && dice.face[3] == DICE.face[3] && dice.face[4] == DICE.face[4] && dice.face[5] && DICE.face[5]){
					cout << "Yes" << endl;
					goto end;
				}
			}
		}
		cout << "No" << endl;
	end:;
	}

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

using namespace std;


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		int d = floor(log10(i)) + 1;
		if (d % 2 == 1) {
			++ans;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int N;
long long h[100010];
long long dp[100010];

int main() {
    int N, K;
    cin >> N >> K;
    rep(i, 0, N) cin >> h[i];

    rep(i, 0, N) dp[i] = INF;

    dp[0] = 0;
    rep(i, 0, N) {
        rep(r, 1, K+1) { chmin(dp[i + r], dp[i] + abs(h[i + r] - h[i])); }
    }

    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int a[200000];
int main(){
  int k,n;
  cin>>k>>n;
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  int ans=a[n-1]-a[0];
  for(int i=1;i<n;++i){
    int res=a[i]+k-a[i-1];
    if(res<ans) ans=res;
  }
  for(int i=0;i<n;++i){
    int res=a[i]+k-a[i+1];
    if(res<ans) ans=res;
  }
    
  cout<<ans;
    
  
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 2005;
int L[N], R[N], num[N];
vector<int> adj[N];
string type;
void dfs(int s, int p = 0){
	num[s] = type[s - 1] == '1';
	R[s] = 0;
	int maxL = 0;
	int sm = 0;
	for(int v : adj[s]) if(v != p){
		dfs(v, s);
		R[s] += R[v] + num[v];
		num[s] += num[v];
		maxL = max(maxL, L[v] + num[v]);
	}

	for(int v : adj[s]) if(v != p){
		sm += min(R[v] + num[v], maxL);
	}

	if(2 * maxL > sm){
		L[s] = 2 * maxL - sm;
	} else L[s] = R[s] % 2;
	assert(L[s] <= R[s]);
	assert((R[s] - L[s]) % 2 == 0);
	// if(type == "0010110") cout << s << " " << L[s] << " " << R[s] << endl;
	// trace(s, num[s], L[s], R[s], maxL, sm);
}

int main(){
	int n; cin >> n;
	cin >> type;
	for(int i = 1; i < n; i++){
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	const int INF = 1 << 30;
	int ans = INF;
	// dfs(2);
	for(int r = 1; r <= n; r++){
		dfs(r);
		// trace(r, L[r], R[r]);
		if(L[r] == 0){
			ans = min(ans, R[r] / 2);
		}
	}
	cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 3924
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int M,D,ans;
int main()
{
	scanf("%d%d",&M,&D);
	for(int d=22;d<=D;d++){
		int a=d%10,b=d/10;
		if(a*b<=M&&a>=2&&b>=2)ans++;
	}
	printf("%d",ans);
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)

LL n, k, a[1000], s[1001];
vector<LL> v;

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) { s[i + 1] = s[i] + a[i]; }
	
	inc1(i, n) {
	inc(j, i) {
		v.PB(s[i] - s[j]);
	}
	}
	
	LL ans = 0;
	dec(i, 42) {
		int c = 0;
		inc(j, v.size()) { if(bit(v[j], i)) { c++; } }
		if(c >= k) {
			ans |= (1LL << i);
			inc(j, v.size()) { if(! bit(v[j], i)) { v[j] = 0; } }
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(void){
   
 int data[3];
 for(int i=0;i<3;i++){
     cin >> data[i];
 }
 
 sort(data,data+3);
 
 cout << data[0] * data[1] /2 <<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const ld PI=abs(acos(-1));
int n;

int main(){
	cin >> n;
	
	int pos,tmp;
	REP(i,0,1e9){
		if(n<=i*(i+1)/2){
			pos=i,tmp=n-(ll)i*(ll)(i+1)/2;
			break;
		}
	}
	
	
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func comp(a, b byte) string {
	if a < b {
		return "<"
	} else if a == b {
		return "="
	} else {
		return ">"
	}
}

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	fmt.Println(comp(a[0], b[0]))
}


Measured memory_bytes: 512
i = int(input())

for x in range(1, i + 1) :
    tmpX = int(x // 10)
    isFinish = False

    if x % 3 == 0 :
        print(' {}'.format(x), end = '')
    elif (x % 10 == 3) :
        print(' {}'.format(x), end = '')
    elif tmpX % 10 == 3 :
        print(' {}'.format(x), end = '')
    elif tmpX != 0 :
        tmpX //= 10
        while tmpX != 0 and (not isFinish) :
            if tmpX % 10 == 3 :
                print(' {}'.format(x), end = '')
                isFinish = True
            tmpX //= 10
print()


Measured memory_bytes: 5868
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> r, g, b;
  rep(i,n)
  {
    if (s[i] == 'R')
      r.push_back(i);
    else if (s[i] == 'G')
      g.push_back(i);
    else if (s[i] == 'B')
      b.push_back(i);
  }
  ll ans = 0;
  rep(i,r.size())
  {
    //R-G-B
    auto Itg = upper_bound(ALL(g), r[i]);
    while (Itg != g.end()) {
      int dif = *Itg - r[i];
      ans += b.end() - upper_bound(ALL(b), *Itg);
      if (binary_search(ALL(b), *Itg + dif)) {
        ans--;
      }
      Itg++;
    }
    //R-B-G
    auto Itb = upper_bound(ALL(b), r[i]);
    while (Itb != b.end()) {
      int dif = *Itb - r[i];
      ans += g.end() - upper_bound(ALL(g), *Itb);
      if (binary_search(ALL(g), *Itb + dif)) {
        ans--;
      }
      Itb++;
    }
  }
  rep(i,b.size())
  {
    //B-G-R
    auto Itg = upper_bound(ALL(g), b[i]);
    while (Itg != g.end()) {
      int dif = *Itg - b[i];
      ans += r.end() - upper_bound(ALL(r), *Itg);
      if (binary_search(ALL(r), *Itg + dif)) {
        ans--;
      }
      Itg++;
    }
    //B-R-G
    auto Itr = upper_bound(ALL(r), b[i]);
    while (Itr != r.end()) {
      int dif = *Itr - b[i];
      ans += g.end() - upper_bound(ALL(g), *Itr);
      if (binary_search(ALL(g), *Itr + dif)) {
        ans--;
      }
      Itr++;
    }
  }
  rep(i,g.size())
  {
    //G-B-R
    auto Itb = upper_bound(ALL(b), g[i]);
    while (Itb != b.end()) {
      int dif = *Itb - g[i];
      ans += r.end() - upper_bound(ALL(r), *Itb);
      if (binary_search(ALL(r), *Itb + dif)) {
        ans--;
      }
      Itb++;
    }
    //G-R-B
    auto Itr = upper_bound(ALL(r), g[i]);
    while (Itr != r.end()) {
      int dif = *Itr - g[i];
      ans += b.end() - upper_bound(ALL(b), *Itr);
      if (binary_search(ALL(b), *Itr + dif)) {
        ans--;
      }
      Itr++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 3644
mod = 998244353
N = int(input())
X = []
for _ in range(N):
    x, d = map(int, input().split())
    X.append((x, x + d))

X = sorted(X, key = lambda x: x[0])
L = [(0, -(10**9+1), 10**9+1)]
P = [-1] * (N+1)
for i, (x, y) in enumerate(X):
    while L[-1][2] <= y:
        if L[-1][2] > x and P[i+1] < 0:
            P[i+1] = L[-1][0]
        L.pop()
    if P[i+1] < 0:
        P[i+1] = L[-1][0]
    L.append((i+1, x, y))

C = [[] for _ in range(N+1)]
for i, p in enumerate(P):
    if p >= 0:
        C[p].append(i)

Y = [1] * (N+1)
for i in range(N+1)[::-1]:
    s = 1
    for j in C[i]:
        s = s * (Y[j] + 1) % mod
    Y[i] = s

print(Y[0])

Measured memory_bytes: 102564
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import heapq

def main():
    H, W, M = map(int, readline().split())
    m = map(int,read().split())
    hw = list(zip(m,m))

    row_bombers = [0] * (H+1)
    col_bombers = [0] * (W+1)

    for (h, w) in hw:
        row_bombers[h] += 1
        col_bombers[w] += 1

    row_max = max(row_bombers)
    col_max = max(col_bombers)

    max_rows = [i for i in range(H+1) if row_bombers[i] == row_max]
    max_cols = [i for i in range(W+1) if col_bombers[i] == col_max]

    ans = row_max + col_max
    
    num_empty_cells_in_kouho = len(max_rows) * len(max_cols)
    for (h, w) in hw:
        if row_bombers[h] == row_max and col_bombers[w] == col_max:
            num_empty_cells_in_kouho -= 1

    if num_empty_cells_in_kouho == 0:
        ans -= 1
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 163816
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string T;
    cin >> T;
    REP(i, T.length()) {
        if(T[i] == '?') T[i] = 'D';
    }
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 200005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

i64 a[200005] ;
vector <i64> v ;

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld",&n) ;

    for(i=1 ; i<=n ; i++) scanf("%lld",&a[i]) ;

    i64 last  = 0 , ans =0LL ;
    v.pb(0LL) ;
    for(i=1 ; i<=n ; i++)
    {
        i64 Xor = 0 ,sum = 0 ;
        if( a[i]==0 )
        {
            last++ ;
            ans += last ;
            continue ;
        }
        v.pb(i) ;
        j = (i64)v.size() - 1 ;
        last = 0LL ;
        while( j>0 )
        {
            Xor = (Xor^a[v[j] ]) ; sum+= a[ v[j] ] ;
        //    printf("%lld %lld %lld\n",i,Xor,sum) ;
            if( Xor != sum ) break ;
            else last += v[j]-v[j-1] ;
            j-- ;
        }
       // printf("%lld\n",j) ;
        ans += last ;
    }

    printf("%lld\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 3956
//g++ test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;

string str;
int hug = 0;

int main(){
	cin >> str;

	for(int i=0;i<str.length()/2;i++){
		if(str[i]!=str[str.length()-i-1]) hug++;
	}

	cout << hug;
	return 0;
}

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

int main(){
	int n,m,l;	cin>>n>>m>>l;
	long long int a[n][m],b[m][l],c[n][l];
	memset(c,0,sizeof(c));
	rep(i,n){
		rep(j,m){
			cin>>a[i][j];
		}
	}
	rep(i,m){
		rep(j,l){
			cin>>b[i][j];
		}
	}
	rep(i,n){
		rep(j,l){
			rep(k,m){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	rep(i,n){
		rep(j,l-1){
			cout<<c[i][j]<<" ";
		}
		cout<<c[i][l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1404