akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};

int main() {
	int N;
	cin >> N;
	map<string, ll>m;
	vector<string>s(N);
	rep(i, N)cin >> s[i];
	rep(i, N)m[s[i]]++;
	cout << "AC" << " x " << m["AC"]<<endl;
	cout << "WA" << " x " << m["WA"]<<endl;
	cout << "TLE" << " x " << m["TLE"]<<endl;
	cout << "RE" << " x " << m["RE"]<<endl;
}
	

Measured memory_bytes: 5236
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

signed main(){
    FASTER;
        int a,b,d;cin>>a>>b>>d;
        cout<<(b/d - (a-1)/d)<<"\n";
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    
    ll n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];
    ll all=0;
    map<ll,ll> m;
    rep(i,n)m[v[i]]++;
    irep(i,m){
        ll t=i->second;
        all+=t*(t-1)/2;
    }
    rep(i,n){
        ll ans=all;
        ll t=m[v[i]];
        ans-=t*(t-1)/2;
        t--;
        ans+=t*(t-1)/2;
        fin(ans);
    }
}


Measured memory_bytes: 11008
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    
    class Program
    {
        const int INF = 1000000009;
        
        static void Dijkstra(int N, int[,] w, List<int>[] g)
        {
            int[] d = new int[N];
            for (int i = 0; i < N; i++) d[i] = INF;
            d[0] = 0;
            bool[] visit = new bool[N];

            while (true)
            {
                int from = -1;
                int mincost = INF;

                for(int i = 0; i < N; i++)
                {
                    if (!visit[i])
                    {
                        if(d[i] < mincost)
                        {
                            from = i;
                            mincost = d[i];
                        }
                    }
                }

                if (from == -1) break;
                visit[from] = true;
                
                foreach(int to in g[from])
                {
                    if (!visit[to])
                    {
                        if(d[from] + w[from, to] < d[to])
                        {
                            d[to] = d[from] + w[from, to];
                        }
                    }
                }
                
            }

            for(int i = 0; i < N; i++)
            {
                Console.WriteLine($"{i} {d[i]}");
            }

            
        }
        

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[,] weight = new int[N, N];
            List<int>[] g = new List<int>[N];
           
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                {
                    weight[i, j] = -1;
                }
            }

            for(int i = 0; i < N; i++)
            {
                g[i] = new List<int>();
                string[] input = Console.ReadLine().Split(' ');
                int from = int.Parse(input[0]);
                int num = int.Parse(input[1]);                
                for(int j = 2; j <= 2 * num; j += 2)
                {
                    int to = int.Parse(input[j]);
                    int w = int.Parse(input[j + 1]);
                    weight[from, to] = w;
                    g[from].Add(to);
                }
            }

            Dijkstra(N, weight, g);
            
        }
    }
}


Measured memory_bytes: 20076
long long s,x,y,n,l;
main(m){
	scanf("%lld",m?&n:&l);
	m?
		y=1<<30,
		x=-y,
		main(0)
	:
	n--?
		s+=l,
		x=l>x?l:x,
		y=l<y?l:y,
		main(0)
	:
	printf("%d %d %lld\n",y,x,s);
}


Measured memory_bytes: 2080
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N,K; cin >> N >> K;
    cout << N-K+1 << endl;
    return 0;
}


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

int main(){
    int n,m,a[10],s,c;
    map<int,int>q;
    cin>>n>>m;
    int flag=1;
    memset(a,-1,sizeof(a));
    while(m--){
        cin>>s>>c;
        if(q.count(s)==0){
            q[s]=c;
            a[s]=c;
        }
        else{
            if(q[s]!=c) flag=0;
        }
    }
    if(a[1]==0 && n>1) flag=0;
    if(flag==0) puts("-1");
    else{
        if(n>1){
            for(int i=1;i<=n;i++){
                if(a[i]==-1 && i==1) cout<<1;
                else if(a[i]==-1 && i>1) cout<<0;
                else cout<<a[i];
            }
        }
        else{
            if(a[1]==-1) cout<<0;
            else cout<<a[1];
        }
    }
    return 0;
}

Measured memory_bytes: 256
def main():
	n = int(input())
	h = list(map(int, input().split()))
	def shower(area, l, r):
		min_h = 10**9
		min_pos = 0
		total = 0
		for i in range(l, r):
			if area[i] < min_h:
				min_h = area[i]
				min_pos = i
		for i in range(l, r):
			area[i] -= min_h
		total += min_h
		if l < min_pos:
			total += shower(area, l, min_pos)
		if min_pos+1 < r:
			total += shower(area, min_pos+1, r)
		return total
	total = shower(h, 0, n)
	print(total)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
using System;

namespace AtCoder
{
    public static class AtCoder
    {
        public static void Main()
        {
            decimal a = 100;
            decimal x = decimal.Parse(Console.ReadLine());
            long ans = 1;
            while (true)
            {
                a += (decimal)Math.Floor(a * 0.01m);
                if ((decimal)a >= x) { break; }
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27560
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let w: String = sc.read();
    let mut count = [0; 32];

    for c in w.chars() {
        count[c as usize - 'a' as usize] += 1;
    }
    println!("{}", if count.iter().all(|x| x % 2 == 0) { "Yes" } else { "No" });
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4352
n = int(input())
T = H = 0
for x in range(n):
    t, h = input().split()
    tl = list(t)
    hl = list(h)
    z = min([int(len(tl)),int(len(hl))])
    for k in range(z):
        if ord(tl[k]) > ord(hl[k]):
            T += 3
            break
        elif ord(tl[k]) == ord(hl[k]):
            pass
        else:
            H += 3
            break
    else:
        if len(hl) == len(tl):
            T += 1
            H += 1
        elif z == len(tl):
            H += 3
        else:
            T += 3
print(f"{str(T)} {str(H)}")





Measured memory_bytes: 5616
import sys
n,l=input().split()

n=int(n)
l=int(l)
v=[]
vv=[]
for i in range(1,n+1):
    v.append(abs(l+i-1))
    vv.append(l+i-1)
v.sort()
#print(v)
#print(vv)
ss=sum(vv)
for i in range(1,n+1):
    if abs(l+i-1)==v[0]:
        print(ss-(l+i-1))
        sys.exit()
#print(ss-v[0])


Measured memory_bytes: 3060
import math
s = input()
n = len(s)
a = [0 for i in range(n)]
ct = 0

if s[0] == "R":
    ct += 1

for i in range(1, n):
    if s[i] == "R":
        ct += 1
    else:
        a[i-1] += math.ceil(ct/2)
        a[i] += math.floor(ct/2)
        ct = 0

ct = 0

if s[n-1] == "L":
    ct += 1

for i in range(n-2, -1, -1):
    if s[i] == "L":
        ct += 1
    else:
        a[i] += math.floor(ct/2)
        a[i+1] += math.ceil(ct/2)
        ct = 0

print(*a)

Measured memory_bytes: 6408
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let nums: Vec<char> = read::<String>().chars().collect();
    if (nums[0] == nums[1] && nums[1] == nums[2]) || (nums[1] == nums[2] && nums[2] == nums[2] && nums[2] == nums[3])  {
      println!("Yes");
    } else {
      println!("No");
    }
}


Measured memory_bytes: 4352
using namespace std;
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <ctime>

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //srand(time(NULL));
    int n;
    cin >> n;

    vector<int> v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int tot = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (v[i] == v[j] || v[j] == v[k] || v[i] == v[k]) continue;
                if (v[i] + v[j] > v[k] && v[i] + v[k] > v[j] && v[j] + v[k] > v[i]) tot++;
            }
        }
    }
    cout << tot << endl;



}

Measured memory_bytes: 3640
//tree distfromroot and calcparent
//tenka12016-B
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

typedef struct{
int val;
int node;
}sd;

int sdsortfnc(const void *a,const void *b){
if(((sd*)a)->val > ((sd*)b)->val){return -1;}
if(((sd*)a)->val < ((sd*)b)->val){return 1;}
return 0;
}

typedef struct{
    long long st;
    long long fi;
    long long kr;
}rs;

typedef struct{
    long long st;
    long long kz;
}mkj;

int sortfnc(const void *a,const void *b){
if(((rs*)a)->st == ((rs*)b)->st){return 0;}
if(((rs*)a)->st < ((rs*)b)->st){return -1;}
return 1;
}

void makemkj(rs g[],mkj x[],long long n){
    long long i,ms=0,nst=g[0].st;
    for(i=1;i<n;i++){
        if(g[i].st!=g[i-1].st){
            x[nst].kz=i-ms;
            x[nst].st=ms;
            nst=g[i].st;ms=i;
        }
    }
    x[nst].kz=n-ms;
    x[nst].st=ms;
}

int dist[524288],par[524288];
void dfs(int t,int l,int bp,rs g[],mkj x[]){
  int i;
  if(dist[t]<=l){return;}
  dist[t]=l;
  par[t]=bp;
  for(i=x[t].st;i<x[t].st+x[t].kz;i++){
    dfs(g[i].fi,l+1,t,g,x);
  }
}

int main(void){
    int i,j,n,m,k,a,b,c,h,w,r=0,l,t;
    int res=0,num[524288];
    int v[524288],p[524288];
    int arr[524288],ac;
    rs g[524288];
    mkj x[524288];
    sd dat[524288];
    scanf("%d",&n);
    for(i=2;i<=n;i++){
      scanf("%d",&a);
      g[2*i-4].st=i;
      g[2*i-4].fi=a;
      g[2*i-4].kr=1;
      g[2*i-3].st=a;
      g[2*i-3].fi=i;
      g[2*i-3].kr=1;
    }
    qsort(g,2*(n-1),sizeof(g[0]),sortfnc);
    makemkj(g,x,2*(n-1));
    for(i=0;i<=n;i++){
      dist[i]=inf;
      num[i]=-1;
    }
    dfs(1,0,0,g,x);
    for(i=1;i<=n;i++){
      dat[i-1].node=i;
      dat[i-1].val=dist[i];
    }
    qsort(dat,n,sizeof(dat[0]),sdsortfnc);
    for(i=0;i<n;i++){
      w=dat[i].node;
      if(num[w]!=-1){continue;}
      ac=0;
      for(j=x[w].st;j<x[w].st+x[w].kz;j++){
        if(num[g[j].fi]==-1){continue;}
        arr[ac]=num[g[j].fi];
        ac++;
      }
      if(ac==0){
        num[w]=0;
        continue;
      }
      t=-inf;
      qsort(arr,ac,sizeof(int),sortfnckj);
      for(j=0;j<ac;j++){
        t=max(t,arr[j]+j+1);
      }
      num[w]=t;
    }
    printf("%d\n",num[1]);
    return 0;
}


Measured memory_bytes: 27372
#include <iostream>
#include <cmath>
#include <list>
using namespace std;
static const double pi = 3.141592653589793;

int main(int argc, char const *argv[]) {
  int N;
  string S;
  cin >> N;
  cin >> S;
  list<char> lst;
  // listに転写
  for(int i=0; i<S.length(); i++) {
    lst.push_back(S[i]);
  }
  list<char>::iterator itr = lst.begin();
  while(true){
    char a = *itr;
    list<char>::iterator prev_itr = itr;
    ++itr;
    if(itr==lst.end()) {
      break;
    }
    if(a==*itr) {
      lst.erase(itr);
      itr = prev_itr;
    }
  }
  cout << lst.size();
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
return 0;
}


Measured memory_bytes: 256
l = list(map(int, input().split()))
li =  list(map(int, input().split()))

g = []
for i in range(l[1]):
    a, b = map(int, input().split())
    if li[a-1] == li[b-1]:
        g += [a, b]
    if li[a-1] > li[b-1]:
        g += [b]
    else:
        g += [a]

g = set(g)
r = l[0] - len(g)
print(r)

Measured memory_bytes: 20112
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
T = [a, b, c, d, e]
A = []
max_tt = 0
for i in range(len(T)):
  if T[i]%10 == 0:
    t = T[i]
  else:
    t = (T[i]//10 + 1) * 10
  A.append(t)
  tt = t - T[i]
  if max_tt < tt:
    max_tt = tt
print(sum(A)-max_tt)

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int count=0;
    int mini=n+1;
    for(int i=0;i<n;i++){
        mini=min(mini,p[i]);
        if(p[i]==mini) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3988
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a * 500 + b * 100 + c * 50 == X:
                ans += 1
print(ans)

Measured memory_bytes: 9136
N,K=map(int,input().split())
a=[int(i) for i in input().split()]
S=[0]
for i in range(N):
  S.append(S[i]+a[i])
C=[]
for i in range(1,N+1):
  for j in range(i):
    C.append(S[i]-S[j])
for k in range(50)[::-1]:
  List=[]
  for c in C:
    if c&(1<<k)!=0:
      List.append(c)
  if len(List)>=K:
    C=List[::]
C.sort(reverse=True)
ans=2**50-1
for i in range(K):
  ans&=C[i]
print(ans)
    
    


Measured memory_bytes: 74992
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

ll t1,t2,a1,a2,b1,b2,d1,d2;

int main(){
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	d1 = (a1 - b1)*t1;
	d2 = (a2 - b2)*t2;
	DBPRT(d1);DBPRT(d2);
	if((d1>0&&d2>0) || (d1<0 && d2<0)) PRT("0");
	else{
		if(d1 == -d2) PRT("infinity");
		else{
			if(d1<0) {d1 = -d1;d2 = -d2;}
			if(-d2<d1) PRT(0);
			else{
				ll st = d1 - (d1 + d2 + d1);
				ll res = 0;
				if(d1 % st == 0) res = d1/st*2;
				else res = (d1/st+1) * 2 - 1;
				PRT(res);
			}
		}
	}
	return 0;
}







Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nk = ReadLongArray();
            var n = nk[0];
            var k = nk[1];
            var a = ReadLongArray().OrderByDescending(v => v).ToArray();
            var ans = n;
            long sum = 0;
            for (int i = 0; i < a.Length; i++)
            {
                if (sum + a[i] < k)
                {
                    sum += a[i];
                }
                else
                {
                    ans = Math.Min(ans, n - i - 1);
                }
            }
            Console.WriteLine($"{ans}");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13792
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

string S;
int num[10];
int ans = 999;

int main()
{
	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		num[i] = S[i] - 48;
	}

	for (int i = 0; i < S.size() - 2; i++)
	{
		int number = 100 * num[i] + 10 * num[i + 1] + num[i + 2];
		ans = min(ans, abs(number - 753));
	}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
import sys
import bisect

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

N = int(input())

A = list(map(int, input().split()))
T = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    T[a - 1].append(b - 1)
    T[b - 1].append(a - 1)

F = [-1 for _ in range(N)]
F[0] = 1
INF = 10 ** 9
dp = [INF for _ in range(N + 1)]
dp[0] = A[0]


def dfs(s):
    for d in T[s]:
        if F[d] == -1:
            t = bisect.bisect_left(dp, A[d])
            p = dp[t]
            dp[t] = A[d]
            F[d] = bisect.bisect_left(dp, INF)
            dfs(d)
            dp[t] = p


dfs(0)

print("\n".join(map(str, F)))


Measured memory_bytes: 355780
from sys import stdin
from collections import deque
H,W = [int(x) for x in stdin.readline().rstrip().split()]
grid = [input() for i in range(H)]

visited = [[False for i in range(W)] for i in range(H)]
visit_p = deque()
ans = 0

search_p = []
for h,i in enumerate(grid):
    for w, j in enumerate(i):
        if j != "#":
            search_p.append((h, w, 0))

for p in search_p:
    visited[p[0]][p[1]] = True
    visit_p.append(p)
    while visit_p:
        nh,nw,num = visit_p.popleft()

        for dh,dw in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
            if not (0 <= nh+dh < H) or not (0 <= nw+dw < W):
                # 範囲外
                continue

            if visited[nh+dh][nw+dw] or grid[nh+dh][nw+dw] == '#':
                # 壁または訪問済み
                continue

            visit_p.append((nh+dh,nw+dw,num+1))
            visited[nh+dh][nw+dw] = True
            ans = max(ans,num+1)
    visited = [[False for i in range(W)] for i in range(H)]
print(ans)

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

int n;
string sample;
int ans = 0;
int main()
{
  cin >> n >> sample;
  for(int i = 0; i < n; i++){
    
    //chap1
    string s;
    vector<int> first, second;
    cin >> s;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == sample[0])
	first.push_back(j);
      if(s[j] == sample[1])
	second.push_back(j);
    }

    //chap2
    for(int j = 0; j < first.size(); j++)
      for(int k = 0; k < second.size(); k++)
	if(first[j] < second[k]){
	  
	  bool flag = false;
	  int diff = second[k] - first[j];
	  for(int l = 2, now = second[k] + diff; l < sample.size() && now < s.size(); l++, now += diff){
	    if(s[now] != sample[l])
	      break;
	    if(l == sample.size() - 1){
	      flag = true;
	      break;
	    }
	  }

	  if(flag){
	    ans++;
	    goto end;
	  }
	}

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

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

using namespace std;
using ll = long long;

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

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

  if (n > 81) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 9; i >= 1; --i) {
    if (n % i == 0) {
      n /= i;
      break;
    }
  }
  if (n <= 9)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <algorithm>

const int N = 200000 + 10;

int n;

class DSU {
 public:
  int anc[N];
  void clear(int n) {
    for (int i = 1; i <= n; ++i) anc[i] = i;
  }
  int find(int x) { return anc[x] == x ? x : (anc[x] = find(anc[x])); }
  inline void meld(int x, int y) {anc[find(x)] = find(y); }
} dsu[2];

int main() {
  int k, l;
  scanf("%d%d%d", &n, &k, &l);
  dsu[0].clear(n);
  dsu[1].clear(n);
  while (k--) {
    int a, b;
    scanf("%d%d", &a, &b);
    dsu[0].meld(a, b);
  }
  while (l--) {
    int a, b;
    scanf("%d%d", &a, &b);
    dsu[1].meld(a, b);
  }
  std::map<std::pair<int, int>, int> cnt;
  for (int i = 1; i <= n; ++i) ++cnt[std::make_pair(dsu[0].find(i), dsu[1].find(i))];
  for (int i = 1; i <= n; ++i) printf("%d ", cnt[std::make_pair(dsu[0].find(i), dsu[1].find(i))]);
  return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>
#include<math.h>
//using namespace std;
int main ()
{  long long a,b,n;
   scanf("%lld %lld %lld",&a,&b,&n);
   long long sum=0;
    long long i=1;
    if(n<b)
      sum=(a*n)/b;
    else
      sum=(a*(b-1))/b;
   printf("%lld",sum);
   return 0;
}

Measured memory_bytes: 1696
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> a;
  if (n >= 10) {
    Cout(a);
  } else {
    ans = a + 100 * (10 - n);
    Cout(ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define llu unsigned long long int
#define pb push_back
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// K-th smallest
// cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
// NO OF ELEMENTS < X
// cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;
// define mod 1000000007
// #define v vector<ll>
#define vv vector<vector<ll>>
#define sz(x) (ll) x.size()
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define noo     \
    {           \
        no();   \
        return; \
    }
void pv(vector<ll> arr, ll size)
{
    for (ll i = 0; i < size; i++)
    {
        cout << arr[i] << ' ';
    }
}
void yes()
{
    cout << "YES\n";
}
void no()
{
    cout << "NO\n";
    // cout << -1 <<endl;
}
void yesno(int f)
{
    if (f)
        yes();
    else
        no();
}
void gv(vector<ll> &arr)
{
    ll size = arr.size();
    for (ll i = 0; i < size; i++)
    {
        cin >> arr[i];
    }
}
class DSU
{
    vector<ll> par;
    vector<ll> rank;

public:
    ll Find(ll v)
    {
        if (par[v] != v)
            par[v] = Find(par[v]);
        return par[v];
    }
    void Union(ll v, ll u)
    {
        ll vroot = Find(v);
        ll uroot = Find(u);
        if (rank[vroot] < rank[uroot])
        {
            par[vroot] = uroot;
        }
        else if (rank[uroot] < rank[vroot])
        {
            par[uroot] = vroot;
        }
        else
        {
            par[uroot] = vroot;
            rank[vroot]++;
        }
    }
    DSU(ll n)
    {
        for (ll i = 0; i <= n; i++)
        {
            par.push_back(i);
            rank.push_back(1);
        }
    }
};
void solve()
{
    ll n, m, q;
    cin >> q;
    n = 100000, m = 100000;
    DSU d(n + m);
    //vector<ll> arr(n);
    for (ll i = 0; i < q; i++)
    {
        ll x, y;
        cin >> x >> y;
        d.Union(x - 1, n + y - 1);
    }
    map<ll, ll> st1, st2;
    for (ll i = 0; i < n; i++)
    {
        st1[d.Find(i)]++;
    }
    for (ll i = n; i <= n + m - 1; i++)
    {
        st2[d.Find(i)]++;
    }
    ll ans = 0;
    for (auto it : st1)
    {
        if (st2.find(it.first) != st2.end())
        {
            ans += it.second * st2[it.first];
        }
    }
    if (ans > 0)
        cout << ans - q;
    else
    {
        cout << ans;
    }
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // ll t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 15844
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,m,x,y,z,s;
    lli i,j;
    cin>>n>>m;
    s=10000*n-m;
    rep(i,0,n+1){
        rep(j,0,n-i+1){
            if(s==i*5000+j*9000){
                y=i;
                z=j;
                x=n-y-z;
//                cout<<x<<" "<<y<<" "<<z<<" "<<x*10000+y*5000+z*1000<<"円"<<endl;
                break;
            }
        }
        if(m==x*10000+y*5000+z*1000){
            break;
        }
    }
    if(m!=x*10000+y*5000+z*1000){
        x=-1;
        y=-1;
        z=-1;
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
}


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

using ll = long long int;
using P = std::pair<int, int>;

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

int d[110][4][2];

int g(char ch)
{
    return atoi(&ch);
}

int main()
{
    std::string s;
    std::cin >> s;
    int k;
    std::cin >> k;

    rep(i, s.size())
        d[i][0][0] = 1;

    d[0][1][1] = 1;
    d[0][1][0] = g(s[0]) - 1;

    for (int i = 1; i < s.size(); ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            d[i][j][0] = 9 * d[i - 1][j - 1][0] + d[i - 1][j][0];
            if (g(s[i]) > 0)
            {
                d[i][j][0] += (g(s[i]) - 1) * d[i - 1][j - 1][1] + d[i - 1][j][1];
            }
            d[i][j][1] = g(s[i]) ? d[i - 1][j - 1][1] : d[i - 1][j][1];
        }
    }

    std::cerr << d[s.size() - 1][k][1] << std::endl;

    std::cout
        << d[s.size() - 1][k][0] + d[s.size() - 1][k][1] << std::endl;
    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

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

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    cin >> c;
    
    int ans = 0;
    rep(_w, w - 1) {
        int a = _w, b = _w + 1;
        vector<vector<int>> cnt(h * 2 + 1, vector<int>(h + 1));
        rep(i, h) rep(j, h) if (c[i][a] == c[j][b]) cnt[i - j + h][max(i, j)]++;
        rep(i, h * 2) rep(j, h - 1) cnt[i][j + 1] += cnt[i][j];
        
        const int INF = 1000000000;
        vector<vector<int>> dp(h + 1, vector<int>(h + 1, INF));
        dp[0][0] = 0;
        rep(i, h + 1) rep(j, h + 1) {
            if (i + 1 <= h) chmin(dp[i + 1][j], dp[i][j] + cnt[i - j + h][max(h - i - 1, h - j - 1)]);
            if (j + 1 <= h) chmin(dp[i][j + 1], dp[i][j] + cnt[i - j + h][max(h - i - 1, h - j - 1)]);
        }
        ans += dp[h][h];
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll A, B, C; cin >> A >> B >> C;
  if(A % 2 == 1 && B % 2 == 1 && C % 2 == 1) {
    cout << min(A * B, min(A * C, B * C)) << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

#ifdef LOCAL
clock_t timer = clock();
#endif

int dp[3005][3005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string a, b;
	cin >> a >> b;
	for(int i = 1; i <= a.size(); i++){
		for(int j = 1; j <= b.size(); j++){
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if(a[i - 1] == b[j - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
		}
	}
	int x = a.size();
	int y = b.size();
	string ans = " ";
	while(x && y){
		if(a[x - 1] == b[y - 1]){
			ans += a[x - 1];
			x--;
			y--;
		}
		else if(dp[x - 1][y] > dp[x][y - 1]){
			x--;
		}
		else{
			y--;
		}

	}
	reverse(all(ans));
	cout << ans << endl;
#ifdef LOCAL
        cout << "Total Time: " << (double)(clock() - timer) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#define println(msg) cout << msg << endl
#define yes_or_no(flag) if (flag) { println("Yes"); } else { println("No"); }

int main() {
  // 入力
  int N;
  cin >> N;
  
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  
  // 計算
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (i == j || j == k || k == i) continue; // 同じ辺は選べない
        if (i > j || j > k) continue; // 重複カウントを防ぐ
        
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
          vector<int> v(3);
          v.at(0) = L[i];
          v.at(1) = L[j];
          v.at(2) = L[k];
          sort(v.begin(), v.end());
          if ((v.at(0) + v.at(1)) > v.at(2)) {
            count++;
          }
        }
      }
    }
  }
  
  // 出力
  println(count);
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int N, K; cin >> N >> K;
    vector<int> a(N+1);
    repr(i, 1, N+1) cin >> a[i];

    vector<vector<ll>> dp(N+5, vector<ll>(K+5, 0));
    dp[0][0]=1;

    vector<ll> cum(K+5, 0);
    repr(i, 1, N+1){
        cum[0]=dp[i-1][0];
        repr(j, 1, K+1) { cum[j]=cum[j-1]+dp[i-1][j]; chmod(cum[j]); }
        rep(j, K+1){
            int t=max(0, j-a[i]);
            dp[i][j]=cum[j]-(t==0? 0:cum[t-1]);
            chmod(dp[i][j]);
        }
    }
    cout << dp[N][K] << endl;
    
    return 0;
}


Measured memory_bytes: 83328
#include <iostream>
using namespace std;
#define N 1000000

int f(int n){
  if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  int a[N];
  cin >> a[0];
  int ans = 0;
  
  while(1){
    ans++;
    a[ans] = a[ans - 1] % 2 == 0 ? a[ans - 1] / 2 : 3 * a[ans - 1] + 1;
    for(int i = 0; i < ans; i++){
      if(a[i] == a[ans]){
	cout << ans + 1 << endl;
	return 0;
      }
    }
  }
  return 0;
}


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

int main() {
	long long int n,k,total=0;
	cin >> n >> k;
	for(long long int i=k;i<n+1;i++)
	{total += ((2*n*i-i*i+i*3)/2)-((i*i+i)/2)+1;}
   total += 1;
    cout << total%1000000007;
  
}


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

int my(int i,int j)
{
	if (j==1)
	{
		return i;
	}
	int ans=my(i,j/2);
	if (j%2==0)
	{
		return ans*ans;
	}
	else
	{
		return ans*ans*i;
	}
}

int main(int argc, char const *argv[])
{
	int x;
	cin>>x;
	int ans=1;
	for (int i = 2; i <= x; ++i)
	{
		int j=2;
		while (my(i,j)<=x)
		{
			ans=max(ans,my(i,j));
			++j;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k, s;
	cin >> n >> k >> s;

	vector<int> seq(n);
	for (int i = 0; i < k; ++i) {
		seq[i] = s;
	}

	for (int i = k; i < n; ++i) {
		seq[i] = (s + 1) % 1000000000;
	}

	cout << seq;

	return 0;

}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	int n,l;
	cin >> n >> l;
	
	vector<int> a(n);
	int all=0;
	for(int i=0;i<n;i++)
	{
		a[i]=l+i;
		all+=a[i];
	}

	int ans=0;
	int dis=10000000;
	for(int i=0;i<n;i++)
	{
		int tmp=0;
		for(int j=0;j<n;j++)
		{
			if(i==j)continue;
			else
				tmp+=a[j];
		}
		if(abs(all-tmp)<dis)
		{
			dis=abs(all-tmp);
			ans=tmp;
		}


	}
	cout << ans << endl;


	




}

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

int main(){
    int N;
    cin >> N;
    vector<int> x_list(N);
    vector<int> y_list(N);
    for (int i = 0; i < N; i++){
        int x,y;
        cin >> x >> y;
        x_list.at(i) = x;
        y_list.at(i) = y;
    }
    vector<int> round(N);
    for(int i = 0; i < N; i++){
        round.at(i) = i+1;
    }
    
    int k = 0;
    double sum = 0;
    do{
        for (int i = 0; i < N-1; i++){
            int j;
            j = round.at(i);
            int j_next;
            j_next = round.at(i+1);
            int64_t dist_2;
            dist_2 = pow(x_list.at(j-1)-x_list.at(j_next-1), 2) + pow(y_list.at(j-1)-y_list.at(j_next-1), 2);
            sum += sqrt(dist_2); 
        }
        k++;
    } while(next_permutation(round.begin(), round.end()));
    cout << fixed << setprecision(6);
    cout << sum/k << endl;
}

Measured memory_bytes: 256