akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(std::string S, std::string T, long long A, long long B, std::string U){
  if(U == S) cout << A-1 << " " << B << endl;
  if(U == T) cout << A << " " << B-1 << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  std::string U;
  std::cin >> U;
  solve(S, T, A, B, U);
  return 0;
}


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

int main(){
  int N,a,b,c,d;
  cin >> N;
  
  a = N / 1000;
  b = N / 100 - a * 10;
  c = N / 10 - N / 100 * 10;
  d = N - (a * 1000 + b * 100 + c * 10);
  
  if(a == b && b == c){
    cout << "Yes" << endl;
  }
  else if(b == c && c == d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
inline bool 
operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
vector<int> 
string_to_vector_int(const string& input){vector<int> out(input.length());rep(i,input.length()){out[i] = (int)(input[i]-'0');} return out;}
template<class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(cmap.begin(),cmap.end(),[&cmap](T x){cmap[x]++;}); return cmap; }
map<int,int> 
count_same_elements(const vector<int>& v){map<int,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }

template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
tryple_map(const vector<A>& v,const function<B(A,A,A)>& func){vector<B> v_(v.size()-2);rep(i,v.size()-2){ v_[i]=func(v[i+2],v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const B& (*func)(A)){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,B (*func)(A,A)){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
tryple_map(const vector<A>& v,B (*func)(A,A,A)){vector<B> v_(v.size()-2);rep(i,v.size()-2){ v_[i]=func(v[i+2],v[i+1],v[i]); }return v_;}

int twosame(int a,int b){return a==b;}
int tryple_same(int a,int b,int c){return a==b and b==c;}
int integer_sumnation(int a,int b){return a+b;}

ll n,k,a,b,c,d,x;
vector<ll>v;
string s;
void input(){
    cin>>a>>b;
}
void src(){
    cout<<(a+b+1)/2;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int cnt=0;
	for (int i=0;i<N-2;i++) {
		if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int linearSearch(int A[], int n, int key)
{
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i - n;
}

int main()
{
    int i, n, A[10000 + 1], q, key, sum;

    sum = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (linearSearch(A, n, key)) {
            sum++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 2052
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
//#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    cout<<n*n*n<<endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>

using namespace std;
using ll = long long int;

int main(void){
    
   int n,d;
   cin>>n>>d;
   int ans =  n/(d*2+1);

   if(n%(d*2+1)==0) cout<<ans<<endl;
   else cout<< n/(d*2+1)+1 <<endl;


    

    return 0;

}

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

int main () {
  string s;
  cin >> s;
  rep(i, s.size()) {
    if(i % 2 == 0) cout << s[i];
  }
  cout << endl;
  return 0;
}


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

int main(){
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    double a=(double)w*(double)h/2.0;
    cout<<a<<endl;
    if(2*x==w && 2*y==h) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>

using namespace std;

long long N,a,b,i,j,k,M,sumA,sumB;



int main()
{
 
  cin >> N;
  vector<pair<long long,long long>> A(N);
  
  for(i=0;i<N;i++)
  {
    cin >> a >> b ;
    A[i]=make_pair(b,a);
  }

  sort(A.begin(),A.end());
  j=0;
  k=0;
  sumA=0;
  sumB=0;
  
  for(i=0;i<N && k==0;i++)
  {
    b=A[i].first;
    sumA+=A[i].second;
    if(sumA > b)
    {
      k=1;
    }
  }
    
  if(k==0)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }


}

Measured memory_bytes: 3328
import itertools

n = int(input())

C = [0, 1, 2, 3, 4]

march = [0]*5
for i in range(n):
    a = input()
    if a[0] == "M":
        march[0] += 1
    elif a[0] == "A":
        march[1] += 1
    elif a[0] == "R":
        march[2] += 1
    elif a[0] == "C":
        march[3] += 1
    elif a[0] == "H":
        march[4] += 1
 
tst = list(itertools.combinations(C,3))

ans = 0
for i in range(10):
    ans += march[tst[i][0]] * march[tst[i][1]] * march[tst[i][2]]

print(ans)

Measured memory_bytes: 9244
#include <iostream>

using namespace std;

int main(void)
{
  int  n;
  int *a, *b;
  int sum = 0;
  
  cin >> n;
  a = new int[n];
  b = new int[n-1];
  
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }
  
  a[0] = b[0];
  
  for (int i = 0; i < n - 2; i++) {
    if (b[i] < b[i+1]) {
      a[i+1] = b[i];
    } else {
      a[i+1] = b[i+1];
    }
  }
  
  a[n-1] = b[n-2];
  
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

for i in range(2019):
    cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)

print(cnt)



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

int main(){
 int K;
 cin>>K;
  if(K==1){
   cout<<"ACL"<<endl;
  }
  else if(K==2){
   cout<<"ACLACL"<<endl;
  }
  if(K==3){
   cout<<"ACLACLACL"<<endl;
  }
  if(K==4){
   cout<<"ACLACLACLACL"<<endl;
  }
  if(K==5){
   cout<<"ACLACLACLACLACL"<<endl;
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    string S;
    cin >> N >> S;
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		boolean judge = true;
		for (int i=0; i<N; i++){
			int A = sc.nextInt();
			if (A % 2 == 0){
				if ((A % 3 == 0 || A % 5 ==0) == false){
					judge = false;
					break;
				}
			}
		}
		if (judge){
			System.out.println("APPROVED");
		} else {
			System.out.println("DENIED");
		}

	}
}

Measured memory_bytes: 23508
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    def f(n):
        return ((1<<n)-(1-2*(n&1)))//3
    def k(x,n):
        return f(n)*s+(1-2*(n&1))*x
    a = LI()
    if a[0]%2 or a[1]%2 or a[2]%2:
        print(0)
        return
    if a[0] == a[1] == a[2]:
        print(-1)
        return
    s = sum(a)
    ans = 10**5
    for i in range(3):
        l = 0
        r = 10**5+1
        while r-l > 1:
            m = (l+r)>>1
            ka = k(a[i],m)
            if ka&((1<<m)-1) == 0:
                l = m
            else:
                r = m
        ans = min(ans, l)
    print(ans)
    return
#B
def B():
    n,m = LI()
    f = [0]*n
    for i in range(m):
        a,b = LI()
        f[a-1] ^= 1
        f[b-1] ^= 1
    if all([not f[i]%2 for i in range(n)]):
        print("YES")
    else:
        print("NO")
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 48732
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 60) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<ll> V(N);
    rep(i,0,N)cin >> V[i];
    vector<ll> accum(N+1);
    rep(i,0,N)accum[i+1] = accum[i] + V[i];
    ll sum = accum[N];
    ll mini = INF;
    rep(i,0,N){
        ll a = sum - accum[i];
        ll b = accum[i];
        mini = min(mini, abs(a - b));
    }
    cout << mini << endl;
}

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

using Graph=vector<vector<int>>;

int main()
{
    int N; cin>>N;
    Graph G(N);
    vector<int> par(N,-1),sib(N,-1);
    for(int i=0;i<N;i++){
        int u,a,b; cin>>u>>a>>b;
        if(a!=-1){
            par[a]=u; sib[a]=b;
            G[u].push_back(a);
        }
        if(b!=-1){
            par[b]=u; sib[b]=a;
            G[u].push_back(b);
        }
    }

    vector<int> depth(N),height(N);
    function<int(int)> dfs=[&](int v)
    {
        for(int u:G[v]){
            depth[u]=depth[v]+1;
            height[v]=max(height[v],dfs(u)+1);
        }
        return height[v];
    };
    
    for(int i=0;i<N;i++) if(par[i]==-1) dfs(i);

    for(int i=0;i<N;i++){
        string type;
        if(par[i]==-1) type="root";
        else if(G[i].size()==0) type="leaf";
        else type="internal node";

        printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,par[i],sib[i],(int)G[i].size());
        printf("depth = %d, height = %d, %s\n",depth[i],height[i],type.c_str());
    }
    return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
#endif

  char a;
  cin>>a;
  cout<<char(a+1)<<endl;
  return 0;
}

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

int main() {
  int N;
  int ans = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;++i){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int h = N/2;
  ans = vec.at(h) - vec.at(h-1);
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  cout << n << ':';
  int sqrt_n = sqrt(n);
  for (int i = 2; i <= sqrt_n; ++i) {
    while (n % i == 0) {
      cout << ' ' << i;
      n /= i;
    }
  }
  if (n != 1)
    cout << ' ' << n;
  cout << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	if(a[n-1]<k){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	int x = gcd(a[0],a[1]);
	for(int i=2;i<n;i++){
		x = gcd(x,a[i]);
	}
	bool flag = 0;
	for(int i=0;i<n;i++){
		if(a[i]<k)continue;
		if(a[i]==k){
			flag = 1;
			break;
		}
		if((k-a[i])%x==0){
			flag = 1;
			break;
		}
	}
	if(flag){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;
  cin >> a >> b;
  ll n=b-a;
  cout << n*(n-1)/2-a << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  cin>>n;
  int arr[n];
  int brr[n];
  int crr[n-1];
  for ( int i=0;i<n;i++)
    cin>>arr[i];
  int total=0;
  
  for ( int i=0;i<n;i++)
  {
    int aa;
    cin>>aa;
    total+=aa;
  }
  for ( int i=0;i<n-1;i++)
  {
    cin>>crr[i];
  }
  for ( int i=1;i<n;i++)
  {
    if ( arr[i]==arr[i-1]+1)
      total+=crr[arr[i-1]-1];
}
  cout<<total<<'\n';
}

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

int lcs(string s1,string s2,vector<vector<int>>& dp)
{
	for(int i = 1; i <= s1.length(); i++)
	{
		for(int j = 1; j <= s2.length(); j++)
		{
			if(s1[i-1] == s2[j-1])
			{
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
		}
	}	return dp[s1.length()][s2.length()];

}

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

	string s1,s2;
	cin>>s1>>s2;

	vector<vector<int>> dp(s1.size()+1,vector<int>(s2.size() + 1,0));
	int count = lcs(s1,s2,dp);
	string s = "";
	int i = s1.length(),j = s2.length();
	while(i > 0 && j > 0)
	{
		if(dp[i-1][j-1] + 1 == dp[i][j] && dp[i-1][j] + 1 == dp[i][j] && dp[i][j-1] + 1 == dp[i][j])
		{
			i--,j--;
			s = s1[i] + s;
		}
		else if(dp[i][j-1] > dp[i-1][j])
		{
			j--;
		}
		else
		{
			i--;
		}
	}
	cout<<s<<endl;
	return 0;

}

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

int main() {
  int n; cin >> n;
  int count = 0;
  map <string, int> mp;
  rep(i,n) {
    string s; cin >> s;
    mp[s]++;
  }
  
  for (auto P : mp) {
    if (P.second > 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
    
}

Measured memory_bytes: 19232
class UnionFindTree():
    def __init__(self, n):
        #親の番号
        self.par = list(range(n))

    def root(self, x):
        #木の根を求める
        if self.par[x] == x:#自分が根ノードなら
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        #結合する
        self.par[y] = x

    def same(self, x, y):
        #xとyが同じ集合に属するか
        #return 1 if self.root(x) == self.root(y) else 0
        #print(x,self.root(x), " : ", y,self.root(y))
        print(1) if self.root(x) == self.root(y) else print(0)

def querying(queries, uft):
    for query in queries:
        if query[0] == 0:#unite
            uft.unite(query[1], query[2])
        else:
            uft.same(query[1], query[2])
        #print(uft.par)
if __name__ == '__main__':
    n, q = map(int, input().split())
    queries = [list(map(int, input().split())) for i in range(q)]
    #instant UnionFindTree
    uft = UnionFindTree(n)
    #Querying
    querying(queries, uft)



Measured memory_bytes: 24684
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define MAX 1000001
bool p[MAX];

int main(){
  memset(p, true, sizeof(p));
  p[0] = p[1] = false;
  for(int i = 0 ; i*i < MAX ; i++){
    if(p[i]){
      for(int j = 2*i ; j < MAX ; j += i){
	p[j] = false;
      }
    }
  }

  int N, P;
  while(cin >> N >> P){
    if(N == -1 && P == -1) break;
    vector<int> prime;
    
    for(int i = N+1 ; prime.size() < 100 ; i++){
      if(p[i]) prime.push_back(i);
    }
    vector<int> C;
    for(int a = 0 ; a < prime.size() ; a++){
      for(int b = a ; b < prime.size() ; b++){
	C.push_back(prime[a]+prime[b]);
      }
    }
    sort(C.begin(), C.end());
    
    //vector<int>::iterator it = unique(C.begin(), C.end());
    //C.erase(it, C.end());
    cout << C[P-1] << endl;
   
  }
  return 0;
}

    
    

Measured memory_bytes: 2256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi dp(n+1,0);
    rep(i,n){
        dp[i+1] = max(dp[i+1],dp[i]);
        if(i < n-1)dp[i+2] = max(dp[i+2],dp[i] + (s[i] != s[i+1]));
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 30030;

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) for (int k = 0; k < 10; k++) {
        bool A = false, B = false, C = false;
        for (int s = 0; s < N; s++) {
            int now = S[s]-'0';
            if (!A && !B && !C && now == i) {
                A = true;
            }
            else if (A && !B && !C && now == j) {
                B = true;
            }
            else if (A && B && !C && now == k) {
                C = true;
            }
        }
        
        if (A && B && C) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll len = s.length();
    ll tmp = 0, ans = 0, x = 1;
    map<ll, ll> mp;
    mp[0] = 1;

    rep(i, 0, len)
    {
        tmp = (tmp + x * (s[len - 1 - i] - '0')) % 2019;
        ans += mp[tmp % 2019];
        mp[tmp % 2019]++;
        x = x * 10 % 2019;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <algorithm>
/*
Lがベクトルのとき
sort(L.begin(), L.end()); → 1, 2, 3,...の順に
sort(L.begin(), L.end(), greater<int>()); →..., 3, 2, 1の順に
*/

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }

    sort(L.begin(), L.end(), greater<int>());

    int sum = 0;
    for(int i = 1; i < N; i++){
        sum += L[i];
    }

    if (L[0] < sum) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    int H, W;
    cin>>H>>W;
    vector<string> S(H);
    for (string &s: S)
        cin>>s;

    vector<vector<vector<int>>> C(4, vector<vector<int>>(H, vector<int>(W)));
    for (int y=0; y<H; y++)
    {
        C[0][y][0] = S[y][0]=='#' ? -1 : 0;
        for (int x=1; x<W; x++)
            C[0][y][x] = S[y][x]=='#' ? -1 : C[0][y][x-1]+1;
    }
    for (int y=0; y<H; y++)
    {
        C[1][y][W-1] = S[y][W-1]=='#' ? -1 : 0;
        for (int x=W-2; x>=0; x--)
            C[1][y][x] = S[y][x]=='#' ? -1 : C[1][y][x+1]+1;
    }
    for (int x=0; x<W; x++)
    {
        C[2][0][x] = S[0][x]=='#' ? -1 : 0;
        for (int y=1; y<H; y++)
            C[2][y][x] = S[y][x]=='#' ? -1 : C[2][y-1][x]+1;
    }
    for (int x=0; x<W; x++)
    {
        C[3][H-1][x] = S[H-1][x]=='#' ? -1 : 0;
        for (int y=H-2; y>=0; y--)
            C[3][y][x] = S[y][x]=='#' ? -1 : C[3][y+1][x]+1;
    }
    int ans = 0;
    for (int y=0; y<H; y++)
        for (int x=0; x<W; x++)
            if (S[y][x]=='.')
                ans = max(ans, C[0][y][x]+C[1][y][x]+C[2][y][x]+C[3][y][x]+1);
    cout<<ans<<endl;
}


Measured memory_bytes: 84864
#include "bits/stdc++.h"

using namespace std;

const int ATOZ = 26;

int satisfaction(int d, int prev_v, const vector<int>& c, const vector<vector<int> >& s, const vector<int>& t, map<int, int>& last) {
    int v = prev_v + s[d][t[d]];
    last[t[d]] = d;
    for (int i = 0; i < ATOZ; ++i) {
        v -= c[i] * (d - last[i]);
    }
    return v;
}

void reset(map<int, int>& last) {
    last.clear();
    for (int i = 0; i < ATOZ; ++i) {
        last[i] = -1;
    }
}

int finalSatisfaction(const vector<int>& c, const vector<vector<int> >& s, const vector<int>& t) {
    map<int, int> last;
    reset(last);
    int v = 0;
    for (int d = 0; d < s.size(); ++d) {
        v = satisfaction(d, v, c, s, t, last);
    }
    return v;
}

void Main() {
    int D;
    cin >> D;
    vector<int> c(ATOZ, 0);
    for (int i = 0; i < ATOZ; ++i) {
        cin >> c[i];
    }
    vector<vector<int> > s(D, vector<int>(ATOZ, 0));
    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < ATOZ; ++j) {
            cin >> s[i][j];
        }
    }
    //vector<vector<int> > s_index(D, vector<int>(ATOZ, 0));
    //for (int d = 0; d < D; ++d) {
    //    vector<int> stemp = s[d];
    //    for (int i = 0; i < ATOZ; ++i) {
    //        s_index[d][i] = distance(stemp.begin(), max_element(stemp.begin(), stemp.end()));
    //    }
    //}

    vector<int> t(D, 0);
    for (int d = 0; d < D; ++d) {
        //auto maxIt = max_element(s[d].begin(), s[d].end());
        //t[d] = 1 + distance(s[d].begin(), maxIt);
        //cout << t[d] << endl;
        cout << 1 << endl;
    }

    //for (int i = 0; i < 10; ++i) {
    //    t[d]
    //    finalSatisfaction
    //}
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3680
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    if(s.size()>t.size()){
        cout<<"GREATER"<<"\n";
    }
    else if(s.size()<t.size()){
        cout<<"LESS"<<"\n";
    }
    else if(s==t){
        cout<<"EQUAL"<<"\n";
    }
    else{
        rep(i,s.size()){
            if(s[i]!=t[i]){
                int ss=s[i]-'0';
                int tt=t[i]-'0';
                if(ss>tt){
                    cout << "GREATER"
                         << "\n";
                }
                else{
                    cout << "LESS"
                         << "\n";
                }
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
def dijkstra(n):
    inf = 10 ** 6 + 1
    dist = [0] + [inf] * (n - 1)
    visited = [False] * n

    while not all(visited):
        dmin = inf
        for i, (d, v) in enumerate(zip(dist, visited)):
            if dmin > d and not v:
                dmin, u = d, i
        visited[u] = True
        for (v, c) in edge[u]:
            if dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
    return dist

n = int(input())
edge = [[]] * n
for _ in range(n):
    l = list(map(int, input().split()))
    edge[l[0]] = (e for e in zip(l[2::2], l[3::2]))
for i, c in enumerate(dijkstra(n)):
    print(i, c)

Measured memory_bytes: 7904
import fractions

n,*t=map(int,open(0).read().split())

if n==1:
    print(t[0])
else:
    g=fractions.gcd(t[0],t[1])
    l=t[0]*t[1]//g

    for i in range(2,n):
        l=t[i]*l//fractions.gcd(l,t[i])
        g=fractions.gcd(l,t[i])

    print(l)

Measured memory_bytes: 77492
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

bool isprime(int n){
    for(int i = 2; i*i < n; i++){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}


int main()
{
    int x;
    cin >> x;
    while(1){
        if(isprime(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,k; cin >> n >> k;
  int a[n];
  rep(i,0,n){
    cin >> a[i];
    if(i>=k){
      if(a[i]>a[i-k]) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
}





Measured memory_bytes: 4424
l = list(map(int,input().split()))
a = l[0]
b = l[1]
c = l[2]
d = l[3]

while a > 0 and c > 0:
    c -= b
    if c <= 0:
        ans = "Yes"
        break
    a -= d
    if a <= 0:
        ans = "No"
        break
print(ans)        
    


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

const int MAXN = 111;
int T[MAXN];

int main() {
	int N;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		int p, x;
		cin >> p >> x;
		--p;
		int ans = sum - T[p] + x;
		cout << ans << endl;
	}
	return 0;
}


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

typedef long long ll;


int main () {
	int N, M, X;
	int C[12], A[12][12];
	int sum[12] = {0};
	int max = 0;
	cin >> N >> M >> X;
	for (int i=0; i<N; i++) {
		cin >> C[i];
		for (int m=0; m<M; m++) {
			cin >> A[i][m];
			sum[m] += A[i][m];
		}
		max += C[i];
	}
	for (int m=0; m<M; m++) {
		if (sum[m] < X) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int bit=0; bit<(1<<N); bit++) {
		int tmp = 0;
		for (int m=0; m<M; m++)
			sum[m] = 0;
		for (int i=0; i<N; i++) {
			if (bit & (1<<i)) {
				for (int m=0; m<M; m++)
					sum[m] += A[i][m];
				tmp += C[i];
			}
		}
		bool f = true;
		for (int m=0; m<M; m++) {
			if (sum[m] < X)
				f = false;
		}
		if (f && tmp<max) {
			max = tmp;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> A(N+1,0);
    for(ll i=1;i<=N;i++){
        cin>>A[i]
    ;}
    ll ans=1;

    //初めてついた日
    vector<ll> firs(N+1,-1);
    firs[1]=0;
    for(ll i=1;i<=K;i++){
        ans=A[ans];
        if(firs[ans]!=-1){
            i+=(i-firs[ans])*((K-i)/(i-firs[ans]));
        }
        else firs[ans]=i
    ;}
    cout<<ans<<endl;

    
    return 0;
}


Measured memory_bytes: 6424
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		System.out.println(Math.min(A, B)  + " " + Math.max(0,(A+ B - N)));
	}
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> vx(n), vy(m);
  for (int i = 0; i < n; ++i) {
    cin >> vx[i];
  }
  
  for (int i = 0; i < m; ++i) {
    cin >> vy[i];
  }
  
  int max_x = *max_element(vx.begin(), vx.end());
  int min_y = *min_element(vy.begin(), vy.end());
  bool ans = false;
  for (int i = x + 1; i <= y; i++) {
    if (max_x < i && min_y >= i) {
      ans = true;
      break;
    }
  }
  
  if (ans) {
    cout << "No War\n";
  } else {
    cout << "War\n"; 
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll ac=0;
    ll tle=0;
    ll wa=0;
    ll re=0;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin>>s;
        if(s=="AC"){
            ac++;
        }
        else if(s=="RE"){
            re++;
        }
        else if(s=="TLE"){
            tle++;
        }
        else{
            wa++;
        }
    }

    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
inline int dig(long long k){
	int res = 0;
	while(k != 0){
		res += k % 10;
		k /= 10ll;
	}
	return res;
}

main(){
	long long n , tmp ;
	int cnt = 0 ,last_dig = 0 , ans = 0;
	cin >> n;
	tmp = n;
	while(tmp != 0){
		last_dig = tmp % 10;
		tmp /= 10ll;
		cnt++;
	}
	
	for(int i = 0 ; i <= 100 ; i++){
		ans = max(ans , dig(max<long long>(n - i , 0)));
	}
	ans = max(last_dig - 1 + (cnt - 1) * 9 , ans);
	cout << ans ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define fordebug int hoge;cin>>hoge;
int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0) break;
    int x[1500],y[1500];
    lp(i,n) cin>>x[i];
    lp(i,m) cin>>y[i];
    vector<int> xsum(1500001,0),ysum(1500001,0);
    for(int i=0;i<n;i++){
      int sum=0;
      for(int j=i;j<n;j++){
	sum+=x[j];
	xsum[sum]++;
      }
    }
    for(int i=0;i<m;i++){
      int sum=0;
      for(int j=i;j<m;j++){
	sum+=y[j];
	ysum[sum]++;
      }
    }
    int ans=0;
    lp(i,1500001){
      ans+=xsum[i]*ysum[i];
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 14584
#include <stdio.h>
#include<string.h>
int main(void){
char a[101],b[101];
scanf("%s%s",a,b);
int t=0;
for(int i=0;i<strlen(a);i++){
    int x=1;
    for(int j=0;j<strlen(b);j++){
        if(a[(i+j)%strlen(a)]!=b[j])
        x=0;
    }
    if(x)
    t=1;
}
printf(t?"Yes\n":"No\n");

    return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
#define INF 1<<64
#define rep(a,b) for(int a=0;a<b;a++)
#define int long long int

using namespace std;

int n,kcost,cost,kiji,ans;
int piza[1003];
///?????????????????§????????????
int much_pizza(int m, int kal, int num){
    if(num>n)return kal/(m*cost+kcost);
    else{
       return max(much_pizza(m+1,kal+piza[num],num+1),much_pizza(m,kal,num+1));
    }
}

signed main(){
    cin >> n >> kcost >> cost >> kiji;
    rep(i,n){
        cin >> piza[i];
    }
    ans=kiji;
    int now=0,before=0;
    sort(piza,piza+n);
    for(int i=n-1,j=1;i>0,j<=n;i--,j++){
        ans+=piza[i];
        now=ans/(j*cost+kcost);
        if(now<before){
        break;
        }
        before=now;
    }
    ///?????????sort(piza.begin(),piza.end(),greater<int>());
    cout << before << endl;
return 0;
}

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

typedef long double ld;

const int Maxn = 10;

int n;
int x[Maxn], y[Maxn];
ld res;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &x[i], &y[i]);
        for (int j = 0; j < i; j++)
            res += sqrt(ld(x[i] - x[j]) * (x[i] - x[j]) +
                        ld(y[i] - y[j]) * (y[i] - y[j]));
    }
    res *= 2; res /= n;
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


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

int main() {
	ll H;
	cin >> H;

	int t = 0;
	ll ans = 0;
	ll pow = 1;
	while (H > 0) {
		H = H / 2;
		ans += pow;
		pow *= 2;
	}

	cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, k;
	cin >> n >> k;

	cout << k * (int)pow((k-1), n-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    int64_t ans = 0;
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] == 'g') {
            ans++;
        }
        else {
            ans--;
        }
    }

    std::cout << ans / 2 << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
	char c;
	
	while(scanf("%c",&c))
	{
		if(c==10)
		break;
		if(c>=97&&c<=122)
		printf("%c",c-32);
		else
		printf("%c",c);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

vector<ll> k;

#define binary_search_vector k

bool binary_search_solve(ll index, ll key){
  if(binary_search_vector[index] >= key) return true;
  else return false;
}

bool isOK(ll index, ll key) {
    if (binary_search_vector[index] > key) return true;
    else return false;
}

int binary_search(ll key) {
    int ng = -1; 
    int ok = (int) binary_search_vector.size(); 

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

//
void solve(long long N, std::vector<long long> L){
    sort(all(L));
    k=L;
    ll cnt=0;
    for(ll i=N-1;i>=0;i--){
        for(ll j=i-1;j>=0;j--){
            cnt+=max((ll)0,j-binary_search(L[i]-L[j]));
        }
    }
    op(cnt)
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long A,B,C,S,l[3];
  cin >> A >> B >> C;
  if(A%2 == 0 || B%2 == 0 || C%2 == 0){
    S=0;
  }
  else{
    l[0]=A;
    l[1]=B;
    l[2]=C;
    sort(l, l+3);
    S=l[0]*l[1];
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  const Int n=4;
  Int d[n][n];
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++) d[i][j]=10000*(i!=j);
  
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    d[a][b]=1;
    d[b][a]=1;    
  }
  for(Int k=0;k<n;k++)
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
        chmin(d[i][j],d[i][k]+d[k][j]);

  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      if(d[i][j]==3){
        cout<<"YES"<<endl;
        return 0;
      }
  cout<<"NO"<<endl;
  return 0;
}


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

vector<int> a(10), b(10);

int main()
{
    for (int i = 0; i < 10; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < 10; i++)
    {
        cin >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    cout << a[7] + a[8] + a[9] << " " << b[7] + b[8] + b[9] << endl;
}


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

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

  int ans=0;
  for(int i=1; i<=n; i+=2){
    int c=0;
    for(int j=1; j<=n; j++){
      if(i%j==0) c++;
    }
    if(c==8) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring> 
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	if(t==1) 
		cout<<"0"<<endl;
	else if(t==0) 
		cout<<"1"<<endl;	
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
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--)

typedef long long ll;

int dp[1010][2]={};

int main(void){
	const int n=10;
	int a[n];
	int m;
	cin >> m;
	while (m--){
		REP(i,n) cin >> a[i];
		int x=0,y=0;
		bool f=1;
		REP(i,n){
			if (a[i]<x && a[i]<y){
				f=0;
				break;
			}
			else if (a[i]<y)
				x=a[i];
			else if (a[i]<x)
				y=a[i];
			else{
				if (x<y)
					y=a[i];
				else
					x=a[i];
			}
		}
		if (f)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

	}

	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
 
int main(void){
    unsigned long long n;
    scanf("%llu",&n);
    long long tmp,i = 1;
    while(i * i <= n){
        if(!(n % i))tmp = i;
        i++;
    }
    printf("%lld",(tmp - 1) + ((n / tmp) - 1));
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <utility>
#include <string>

using namespace std;

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

int main(){
    int n,tmp,maxN,minN;
    vector<int> ans;
    int tmpd;
    string num1,num2;
    while(1){
        cin>>n;
        if(n==0)break;
        tmpd=0;maxN=0;minN=1001;
        for(int i=0;i<n;i++){
            cin>>tmp;
            maxN = max(maxN,tmp);
            minN = min(minN,tmp);
            tmpd += tmp;
        }
        ans.push_back((tmpd-minN-maxN)/(n-2));

    }
    for(int i = 0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3008