akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define asc(i,a,n) for (I i=a;i<n;i++)
#define dsc(i,a,n) for (I 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())
#define P auto
typedef vector<long long int> VI;
typedef long long int I;
typedef pair<long long int,long long int> PII;
typedef double D;
typedef set<long long int> OSI;
typedef unordered_set<long long int> USI;
struct node{
  I pre;
  I suf;
  I sum;
  I mxsum;
  I l;
  I r;
};
I rootmax(node tree[],I n,I a[],I m){
  dsc(i,0,n/2){
    I k=(tree[2*i+1].l+tree[2*i+2].r)/2;
    if(k>=m){
      k=0;
    }else{
      k=a[k];
    }
    tree[i].l=tree[2*i+1].l;
    tree[i].r=tree[2*i+2].r;
    tree[i].sum=tree[2*i +1].sum+tree[2*i +2].sum +k;
    tree[i].pre=max(tree[2*i+1].pre,tree[2*i+1].sum+tree[2*i+2].pre+k);
    tree[i].suf=max(tree[2*i+2].suf,tree[2*i+2].sum+tree[2*i+1].suf+k);
    tree[i].mxsum=max(tree[2*i+1].suf+tree[2*i+2].pre+k,max(tree[2*i+1].mxsum,tree[2*i+2].mxsum));
  }
  return tree[0].mxsum;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    I n;
    cin>>n;
    I a[n];
    I sum=0;
    asc(i,0,n){
      cin>>a[i];
      sum+=a[i];
    }
    if(!(n&1)){
      I ev=0;
      asc(i,0,n){
        ev+=a[i];
        i++;
      }
      I mx=0;
      asc(i,3,n){
        if(i&1){
          mx+=a[i];
        }
      }
      mx+=a[0];
      I temp=mx;
      asc(i,3,n-2){
        if(i&1){
          temp-=a[i];
          temp+=a[i-1];
        }
        mx=max(mx,temp);
      }
      mx=max(ev,mx);
      mx=max(sum-ev,mx);
      cout<<mx;
    }else{
      I od=0;
      asc(i,0,n){
        od+=a[i];
        i++;
      }
      I d[n];
      asc(i,0,n){
        if(i%2){
          d[i]=a[i];
        }else{
          d[i]=-a[i];
        }
      }
      I m=n/2;
      m++;
      I sz=pow(2,ceil(log(m)/log(2)));
      node tree[2*sz -1];
      asc(i,0,m){
        tree[sz-1+i].sum=tree[sz-1+i].pre=tree[sz-1+i].suf=tree[sz-1+i].mxsum=d[2*i];
        tree[sz-1+i].l=tree[sz-1+i].r=2*i;
      }
      asc(i,m,sz){
        tree[sz-1+i].sum=tree[sz-1+i].pre=tree[sz-1+i].suf=tree[sz-1+i].mxsum=-1000000001;
        tree[sz-1+i].l=tree[sz-1+i].r=2*i;
      }
      I difsum=rootmax(tree,2*sz-1,d,n);
      cout<<od+difsum;
    }
    return 0;
}

Measured memory_bytes: 19508
/*input
9
W 3
B 1
B 4
W 1
B 5
W 9
W 2
B 6
W 5
B 3
W 8
B 9
W 7
B 2
B 8
W 4
W 6
B 7
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define N 4005
#define bit(x,y) ((x>>y)&1LL)
#define loop(x) for(int xv=1; xv<=x; xv++)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
	return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	for (unsigned int i = 0; i < a.size(); i++)
		os << a[i] << (i < a.size() - 1 ? ", " : "");
	os << ']';
	return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	for (typename set<T>::iterator it = a.begin(); it != a.end(); it++) {
		typename set<T>::iterator jt = it;
		os << *it << (++jt != a.end() ? ", " : "");
	}
	os << '}';
	return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &a) {
	os << "{\n";
	for (typename map<T1, T2>::iterator it = a.begin(); it != a.end(); it++) {
		typename map<T1, T2>::iterator jt = it;
		os << "  " << it->first << ": " << it->second << (++jt != a.end() ? ",\n" : "\n");
	}
	os << '}';
	return os;
}
struct data {
	int type, val;
	data(int _type = 0, int _val = 0): type(_type), val(_val) {};
};

int n;
data a[N];
int where[2005][2];
int cntAft[4005][2005][2];
int dp[2005][2005];

int cal(int cnt0, int cnt1) {
	int &ret = dp[cnt0][cnt1];
	if (ret != -1) return ret;
	ret = 1e9;
	if (cnt0 == n && cnt1 == n) {
		ret = 0;
		return ret;
	}
	if (cnt0 != n) {
		int preP = where[cnt0 + 1][0];
		int nowP = preP + cntAft[preP][cnt0][0] + cntAft[preP][cnt1][1];
		ret = min(ret, cal(cnt0 + 1, cnt1) + nowP - preP);
	}
	if (cnt1 != n) {
		int preP = where[cnt1 + 1][1];
		int nowP = preP + cntAft[preP][cnt0][0] + cntAft[preP][cnt1][1];
		ret = min(ret, cal(cnt0, cnt1 + 1) + nowP - preP);
	}
	return ret;
}

void prep() {
	for (int i = 1; i <= 2 * n; i++)
		where[a[i].val][a[i].type] = i;
	for (int val = 1; val <= n; val++) {
		for (int type = 0; type <= 1; type++) {
			for (int i = 2 * n; i >= 1; i--) {
				cntAft[i][val][type] = cntAft[i + 1][val][type];
				if (a[i].val <= val && a[i].type == type) {
					cntAft[i][val][type]++;
				}
			}
		}
		memset(dp, -1, sizeof(dp));
	}
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= 2 * n; i++) {
		char c; cin >> c; int t; cin >> t;
		if (c == 'B') a[i] = data(0, t);
		else a[i] = data(1, t);
	}
	prep();
	cout << cal(0, 0) << endl;
}

Measured memory_bytes: 78976
A, B, C = input().split(" ")
K = int(input())

A, B, C = int(A), int(B), int(C)

for i in range(K):
  if A >= B:
    B = B*2
  elif B >= C:
    C = C*2

  if B > A and C > B:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
struct Point{double x,y;};
void koch(int d,Point p1,Point p2)
{
    if(d==0)
        return;
    double th = M_PI * 60.0 / 180.0;
    Point s,t,u;
    s.x = (2*p1.x +1*p2.x)/3.0;
    s.y = (2*p1.y + 1*p2.y)/3.0;
    t.x = (1*p1.x +2*p2.x)/3.0;
    t.y = (1*p1.y + 2*p2.y)/3.0;
    u.x = (t.x-s.x) *cos(th) -(t.y-s.y) *sin(th) +s.x;
    u.y = (t.x-s.x) *sin(th) +(t.y-s.y) *cos(th) +s.y;

    koch(d-1,p1,s);
    printf("%.8f %.8f\n", s.x,s.y);
    koch(d-1,s,u);
    printf("%.8f %.8f\n", u.x,u.y);
    koch(d-1,u,t);
    printf("%.8f %.8f\n", t.x,t.y);
    koch(d-1,t,p2);
}
int main()
{
    int n;
    cin >>n;
    Point a,b;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    printf("%.8f %.8f\n", a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n", b.x,b.y);
    return 0;
}



Measured memory_bytes: 3192
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N;
V<tuple<string,int,int>> v;


int main(){
    INIT;
    cin >> N;
    REP(i,N) {
        string s;
        int p; cin >> s >> p;
        v.push_back(make_tuple(s,p,i));
    }
    std::sort(ALL(v), [](tuple<string,int,int>& a, tuple<string,int,int>& b) {
        return std::get<1>(a) > std::get<1>(b);
    });
    std::stable_sort(ALL(v), [](tuple<string,int,int> a, tuple<string,int,int> b) {
        return std::get<0>(a) < std::get<0>(b);
    });
    V<int> ans;
    ans.resize(N);
    for(int i = 0; i < N; i++) {
        string s; int a,x;
        std::tie(s,a,x) = v[i];
        cout << x+1 << "\n";
    }
}

Measured memory_bytes: 256
MOD, res = int(1E9 + 7), 0
n = int(input())
a = list(map(int, input().split()))
for i in range(60):
    cnt = 0
    for j in a:
        if j & (1 << i):
            cnt += 1
    res = (res + cnt * (n - cnt) * pow(2, i, MOD)) % MOD
print(res)

Measured memory_bytes: 122808
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int   N   = 3e5 + 1;
const int   mod = (119 << 23) + 1;
int n, a, b, k, f[N], I[N];
int qpow(int c,int exp) {
    int ans = 1;
    while(exp)  {
        if(exp & 1) ans = ans * c % mod;
        c = c * c % mod;    exp >>= 1;
    }
    return ans;
}
signed main()   {
    ios_base::sync_with_stdio(false);   cin.tie(0);
    cin >> n >> a >> b >> k;
    f[0] = 1;
    for(int i = 1 ; i <= n ; ++i)
        f[i] = f[i - 1] * i % mod;
    I[n] = qpow(f[n],mod - 2);
    for(int i = n - 1 ; i >= 0 ; --i)
        I[i] = I[i + 1] * (i + 1) % mod;
    int ans = 0;
    for(int i = 0 ; i <= n ; ++i)   {
        int res = k - a * i;
        if(res < 0) break;
        if(res % b) continue;
        int j = res / b;
        if(j > n)   continue;
        int cur = f[n] * I[i] % mod;
            cur = cur * I[n - i] % mod;
            cur = cur * f[n] % mod;
            cur = cur * I[j] % mod;
            cur = cur * I[n - j] % mod;
        ans = (ans + cur) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>

using namespace std;

int main() {

	int N;
	cin >> N;

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

	int result = 0;
	while (true)
	{
		bool dec = false;
		for (int i = 0; i < vNum.size(); i++)
		{
			if (vNum[i] != 0)
			{
				--vNum[i];
				dec = true;
			}
			else if(dec)
			{
				break;
			}
		}

		if (dec) {
			++result;
		}
		
		bool isContinue = false;
		for (int i = 0; i < vNum.size(); i++)
		{
			if (vNum[i] != 0)
			{
				isContinue = true;
				break;
			}
		}
		if (isContinue) { continue; }
		break;
	};

	cout << result;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N, K;
    ll mi = 1001001001;
    cin >> N >> K;
    vector<ll> h(N);
    rep(i, N) cin >> h[i];
    sort(all(h));
    rep(i, N-K+1){
        mi = min(h[i+K-1]-h[i], mi);
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 3992
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	A := "CODEFESTIVAL2016"
	count := 0
	for i := 0; i < len(A); i++ {
		if S[i] != A[i] {
			count++
		}
	}
	fmt.Println(count)
}



Measured memory_bytes: 640
h,w = map(int, input().split())
s = [list(input()) for i in range(h)]

def solve(h,w):
    for i in range(1, h - 1):
        for j in range(1, w - 1):
            if s[i][j] == "#":
                if s[i - 1][j] == "#":
                    continue
                elif s[i + 1][j] == "#":
                    continue
                elif s[i][j - 1] == "#":
                    continue
                elif s[i][j + 1] == "#":
                    continue
                else:
                    return "No"
    return "Yes"

print(solve(h,w))



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<int> sieve_of_eratosthenes(int n) {
	vector<int> primes(n);
	for (int i = 2; i < n; ++i)
		primes[i] = i;
	for (int i = 2; i*i < n; ++i)
		if (primes[i])
			for (int j = i*i; j < n; j += i)
				primes[j] = 0;
	return primes;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> primes = sieve_of_eratosthenes(1000005);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> B;
	vector<int> C;
	bool f1, f2, f3;
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			f1 = (primes[A[i - 1]] != 0);
		}
		else {
			f1 = false;
		}
		f2 = (primes[A[i]] != 0);
		if (i < N - 1) {
			f3 = (primes[A[i + 1]] != 0);
		}
		else {
			f3 = true;
		}
		if (!f2 && !f3) {
			cout << 0 << endl;
			return 0;
		}
		if (!f1 && !f2) {
			cout << 0 << endl;
			return 0;
		}
		if (f2) {
			if (!f1) {
				B.push_back(A[i]);
				C.push_back(1);
			}
			else if (!f3) {
				B.push_back(A[i]);
				C.push_back(1);
			}
			else {
				B.push_back(A[i]);
				C.push_back(0);
			}

		}
	}
	/*for (int i = 0; i < B.size(); i++) {
		cerr << B[i] << " ";
	}
	cerr << endl;
	for (int i = 0; i < C.size(); i++) {
		cerr << C[i] << " ";
	}
	cerr << endl;*/
	vector<vector<int> > dp((int)B.size() + 1, vector<int>(3, 0));
	dp[0][1] = 1;
	for (int i = 1; i < B.size(); i++) {
		//for (int k = 0; k < 3; k++) {
			if (C[i] == 0) {
				if (i > 0 && B[i] > B[i - 1]) {
					dp[i][1] = dp[i - 1][1];
				}
				if (i <= 1 || B[i] > B[i - 2]) {
					dp[i][1] = (dp[i][1] + dp[i - 1][0]) % MOD;
				}
				dp[i][0] = (dp[i][0] + dp[i - 1][1]) % MOD;
			}
			else {
				if (i > 0 && B[i] > B[i - 1]) {
					dp[i][1] = dp[i - 1][1];
				}
				if (i <= 1 || B[i] > B[i - 2]) {
					dp[i][1] = (dp[i][1] + dp[i - 1][0]) % MOD;
				}
				dp[i][0] = 0;
			}
		//}
	}
	/*for (int i = 0; i < dp.size(); i++) {
		cerr << dp[i][0] << " ";
	}
	cerr << endl;
	for (int i = 0; i < dp.size(); i++) {
		cerr << dp[i][1] << " ";
	}
	cerr << endl;*/
	cout << (dp[B.size() - 1][0] + dp[B.size() - 1][1])%MOD << endl;
}


Measured memory_bytes: 16636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            if (N <= 20) {
                for (int i = 0; i < N; i++) {
                    out.println(i);
                    out.flush();
                    String S = in.next();
                    if (S.equals("Vacant")) return;
                }
            }
            int[] chair = new int[N];
            out.println(0);
            out.flush();
            String S1 = in.next();
            if (S1.equals("Vacant")) return;
            chair[0] = 1;
            int l = -1, r = N;
            while (Math.abs(r - l) > 1) {
                int mid = (l + r) / 2;
                out.println(mid);
                out.flush();
                String S = in.next();
                if (S.equals("Vacant")) return;
                chair[mid] = mid % 2 == 0 && S.equals(S1) || mid % 2 != 0 && !S.equals(S1) ? 1 : 2;
                boolean f = chair[mid] == chair[0];
                if (f) {
                    l = mid;
                } else {
                    r = mid;
                }
            }
            out.println(r);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24004
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    p d;
    int cnt=0;
    rep(i,n){
        cin>>d.first>>d.second;
        if(d.first==d.second){
            cnt++;
            if(cnt==3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else{
            cnt=0;
        }
    }
    cout<<"No"<<endl;
    

    return 0;
}

Measured memory_bytes: 3652
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int a;
int b;

void input() {
  cin >> a >> b;
}

void solve() {
  string s = to_string(a) + to_string(b);

  int c = stoi(s.c_str());
  int d = sqrt(c);

  string ans = "No";

  if (d * d == c)
    ans = "Yes";

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

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

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3688
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int N;

	cin >> N;

	int A[N][3];

	int id = 0;
	for(int i =0; i< N;i++){
		cin >> A[i][0] >> A[i][1] >> A[i][2];
		if(A[i][2] != 0){
			id = i;
		}
	}

	int t1, t2, t3;
	t1 = A[id][0];
	t2 = A[id][1];
	t3 = A[id][2];

	A[id][0] = A[0][0];
	A[id][1] = A[0][1];
	A[id][2] = A[0][2];

	A[0][0] = t1;
	A[0][1] = t2;
	A[0][2] = t3;

	for(int i = 0; i <= 100 ; i++){
		for(int j = 0; j <= 100 ; j++){
				bool ok = true;
				int h = abs(A[0][0] - i) + abs(A[0][1] - j) + A[0][2];
				for(int k = 1; k<N; k++){
						if(A[k][2] != max(h - abs(A[k][0] - i) - abs(A[k][1] - j), 0)){
							ok = false;
							break;
						}
				}
				if(ok == false) continue;

				cout << i << " " << j << " " << h << endl;
				return 0;
		}
	}

	return 0;
}


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

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

int main () {
	int k;
  	cin >> k;
    int ans = 0;
  	for (int i=1;i<=k;i++) {
    	for (int j=1;j<=k;j++) {
        	for (int l=1;l<=k;l++) {
              int c;
              if (i < j) c = gcd(j,i);
              else c = gcd(i,j);
			  if (c < l) ans += gcd(l,c);
              else ans += gcd(c, l);
            }
        }
    }
  cout << ans << endl;
  	
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		boolean flag = false;
		for(int i = 1; i <=3; i++) {
			if(A * B * i % 2 == 1) {
				flag = true;
			}
		}
		if(flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22228
N=int(input())
a=list(map(int, input().split()))
cnt=[0]*N

for i in range(N):
    cnt[a[i]-1]+=1

c_sum=0
for i in range(N):
    c_sum+=(cnt[i]*(cnt[i]-1))//2

for i in range(N):
    k=(cnt[a[i]-1])*(cnt[a[i]-1]-1) //2
    l=(cnt[a[i]-1]-1)*(cnt[a[i]-1]-2) //2
    d=k-l
    print(c_sum-d)

Measured memory_bytes: 25716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int w[n];
  for(int i=0;i<n;i++)cin >> w[i];

  int minn = 1<<30;
  int summ[n];
  summ[0] = w[0];
  for(int i=1;i<n;i++){
    summ[i] = summ[i-1] + w[i];
  }
  for(int i=0;i<n-1;i++){
    int tmp = abs(summ[n-1]-2*summ[i]);
    if(tmp<minn)minn=tmp;
  }
  cout << minn << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define PI 3.14159265359

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double a, b, h, m; cin >> a >> b >> h >> m;
    double a1 = 0.5*(m + 60*h);
    double a2 = m*6;
    double diff= min(abs(a2-a1), 360 - abs(a2-a1));
    // cout << a1 << " " << a2 << " " << diff << endl;
    double csq = a*a + b*b - 2*a*b*cos(diff * PI / 180);
    cout << fixed << setprecision(10) << sqrtl(csq) << endl;

    return 0;
}

Measured memory_bytes: 4180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans;
int main(){
	scanf("%lld",&n);
	printf("%lld",(n-1)/2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
int a[111111],n,m,b[111111],ans;
main(){
  cin>>n>>m;
  r(i,n)scanf("%d",&a[i+1]);
  priority_queue<P>q;
  r(i,n)q.push(P(a[i+1],i+1));
  r(i,n){
    P p=q.top();q.pop();
    b[p.second]=m-a[p.second]+max(b[p.second-1],b[p.second+1]);
  }
  r(i,n)ans=max(b[i+1],ans);
  cout<<ans<<endl;
}

Measured memory_bytes: 4820
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;


vector<long long int> arr;

int main() {
    int a;
    int b;
    cin >> a >> b;
    int res = 0;

    if (a == 1) {
        res += 300000;
    } else if (a == 3) {
        res += 100000;
    } else if (a == 2) {
        res += 200000;
    }
    if (b == 1) {
        res += 300000;
    } else if (b == 2) {
        res += 200000;
    }
    else if (b == 3) {
        res += 100000;
    }
    if(a==b && a==1){
        res+=400000;
    }
    cout<<res;
    return 0;
}

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

int main() {
    int N,l,r;
    int S=0;
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> l >> r;
        S+=(r-l+1);
    }
    cout << S << endl;
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	bs := NewBufScanner(in)
	bw := NewBufWriter(out)
	defer bw.w.Flush()
	k := bs.IntScan()
	sum := 0
	for n1 := 1; n1 <= k; n1++ {
		for n2 := n1; n2 <= k; n2++ {
			for n3 := n2; n3 <= k; n3++ {
				val := gcd(gcd(n1, n2), n3)
				if n1 == n2 && n2 == n3 {
					sum += val
				} else if n1 == n2 || n2 == n3 {
					sum += val * 3
				} else {
					sum += val * 6
				}
			}
		}
	}

	bw.Printf("%v", sum)
}

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

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  vector<int> DP(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  if (K >= N)
  {
    cout << abs(H.at(N - 1) - H.at(0)) << endl;
    return 0;
  }
  for (int i = 0; i < K; i++)
  {
    DP.at(i) = abs(H.at(i) - H.at(0));
  }
  for (int i = K; i < N; i++)
  {
    int dp;
    for (int k = 1; k <= K; k++)
    {
      if (k == 1)
      {
        dp = DP.at(i - k) + abs(H.at(i) - H.at(i - k));
      }
      else
      {
        dp = min(dp, DP.at(i - k) + abs(H.at(i) - H.at(i - k)));
      }
    }
    DP.at(i) = dp;
  }
  cout << DP.at(N - 1) << endl;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  cout << max(max(a+b, a-b), a*b) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class B_172_MinorChange
    {
        public static void Main(string[] args)
        {
            // 文字列の入力
            string s = Console.ReadLine();
            string r = Console.ReadLine();

            char[] sList = s.ToCharArray();
            char[] rList = r.ToCharArray();
            int result = 0;

            for (int i = 0; i < sList.Length ; i++)
            {
                if (sList[i].Equals(rList[i]) == false)
                { 
                    result++;
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28228
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

const ll MOD=1000000007;

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

  vector<ll> p2(N+1,0);
  p2[0]=1;
  for(int i=1;i<N+1;i++){
    p2[i]=p2[i-1]*2%MOD; 
  }

  map<pair<ll,ll>,ll> m;
  for(int i=0;i<N;i++){
    ll a,b; cin >> a >> b;
    if(a==0 && b==0){
      m[make_pair<ll,ll>(0,0)]++;
      continue;
    }
    if(a==0){
      m[make_pair<ll,ll>(0,1)]++;
      continue;
    }
    if(b==0){
      m[make_pair<ll,ll>(1,0)]++;
      continue;
    }
    
    ll ta=abs(a),tb=abs(b);
    while(ta!=0){
      tb%=ta; swap(ta,tb);
    }
    a/=tb; b/=tb;
    if(a<0){a*=-1; b*=-1;}
    //cout << "#" << a <<" "<< b << endl;
    m[make_pair(a,b)]++;
  }

  //for(auto mi:m) cout << "##" << mi.first.first << "," << mi.first.second << " " << mi.second << endl;

  ll ans=1;
  for(auto &mi:m){
    if(mi.first.first==0 && mi.first.second==0) continue;
    pair<ll,ll> tmp;
    if(mi.first.second>0){
      tmp.first=mi.first.second; tmp.second=-mi.first.first;
    }else{
      tmp.first=-mi.first.second; tmp.second=mi.first.first;
    }

    //cout << "**" << mi.first.first << "," << mi.first.second << " " << tmp.first << "," << tmp.second << endl;

    ll ansi=0;
    ansi+=p2[m[tmp]];
    ansi+=p2[mi.second];
    ans*=ansi-1;
    ans%=MOD;
    m[tmp]=0;
    mi.second=0;
  }

  cout << ((ans-1+m[make_pair<ll,ll>(0,0)])%MOD+MOD)%MOD << endl;

  return 0;
}


Measured memory_bytes: 29696
numInt = int(input())
inputNum = list(map(int, input().split()))
evenList = []

for i in range(numInt):
  if inputNum[i] % 2 == 0:
    evenList.append(inputNum[i])
  
  length = len(evenList)
 # print(evenList)

flag = True

for i in range(length):
  if evenList[i] % 3 != 0 and evenList[i] % 5 != 0:
    flag = False 
    break

if flag:
  print('APPROVED')
else:
  print('DENIED')

# Maybe use a string? 

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

int main(){

  int n;
  int p[56];
  int i,j;
  int x;
  int cnt = 0;

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

  for(i = 1;i <= n;i++){
    if(p[i] != i) cnt++;
  }

  if(cnt > 2) printf("NO\n");

  else printf("YES\n");

  return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {

    ll h;
    cin >> h;

    ll n;
    cin >> n;
    rep(i, n) {
        ll a;
        cin >> a;
        h -= a;
    }
    if (h <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<ll>red(a);
	vector<ll>green(b);
	vector<ll>no(c);
	for(int i=0; i<a; i++)
	 cin>>red[i];
	sort(red.rbegin(),red.rend());
	for(int i=0; i<b; i++)
	 cin>>green[i];
	sort(green.rbegin(),green.rend());
    for(int i=0; i<c; i++)
	 cin>>no[i];
	vector<ll>pos;
	for(int i=0; i<min(a,x); i++)
	{
		pos.push_back(red[i]);
	}
	for(int i=0; i<min(b,y); i++)
	 pos.push_back(green[i]);
	for(int i=0; i<c; i++)
	 pos.push_back(no[i]);
	sort(pos.rbegin(),pos.rend());
	ll sum=0;
	for(int i=0; i<x+y; i++)
	 sum+=pos[i];
	cout<<sum;
	return 0;	
	
}

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

int main()
{
	long double a,b,c;
	cin>>a>>b>>c;
	
	if(a+b+2.0*sqrt(a*b)<c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

def nCr(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N,A,B = map(int,input().split())

v = list(map(int,input().split()))

minlis = []
maxlis = []

v.sort()

for i in range(N):

    if i < N-A:
        minlis.append(v[i])

    else:
        maxlis.append(v[i])


ave = sum(maxlis) / A
print (ave)


x = min(maxlis)

xinmax = 0
xinmin = 0

for i in minlis:
    if i == x:
        xinmin += 1

for i in maxlis:
    if i == x:
        xinmax += 1

if ave == x and xinmin != 0:

    ans = 0

    for i in range(xinmax + xinmin - A + 1):

        i += A
        if i > B:
            break

        ans += nCr(xinmin+xinmax,i)

    print (ans)

else:

    print (nCr(xinmin+xinmax,xinmax))

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

using namespace std;
#define ll long long


int main() {
    int n;
    cin >> n;
    int a[n];
    for (auto &i: a) cin >> i;
    auto *p = unique(a, a + n);
    for (int i = 0; i < p - a; i++) cout << a[i] << " \n"[i == p - a - 1];
    return 0;
}


Measured memory_bytes: 3492
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, A;

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

  int n = N % 500;
  if (n <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
const double EPS = 1e-8, INF = 1e12, PI = 2 * acos(0.0);
typedef complex<double> P;
namespace std {
    bool operator < (const P& a, const P& b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } 
    bool operator == (const P& a, const P& b) { return abs(real(a) - real(b)) < EPS && abs(imag(a) - imag(b)) < EPS; }
    P operator / (const P& a, const double& b) { return P(real(a) / b, imag(a) / b); }
    P operator * (const P& a, const double& b) { return P(real(a) * b, imag(a) * b); }
}
double argument(const P &a, const P &b) { // argument for A->B[-PI,PI]
    double ax = real(a), ay = imag(a), bx = real(b), by = imag(b);
    return atan2(by - ay, bx - ax);
}

int N;
//---------------------------------------------------------------------------------------------------
void _main()
{
    cin >> N;
    vector<P> v;
    rep(i, 0, N)
    {
        int x, y;
        cin >> x >> y;
        if(x != 0 or y != 0) {
            v.push_back(P(x, y));
        }
    }

    sort(all(v), [&](P a, P b) { return argument(P(0, 0), a) < argument(P(0, 0), b); });

    double ans = 0;
    int n = v.size();
    rep(i, 0, n) {
        double x = 0, y = 0;
        rep(j, 0, n) {
            auto p = v[(i + j) % n];
            x += real(p);
            y += imag(p);

            chmax(ans, sqrt(x * x + y * y));
        }
    }
    printf("%.10f\n", ans);
}

Measured memory_bytes: 4144
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

const int MAX_L = 3010;
int dp[MAX_L][MAX_L];

int main()
{
    string s, t;
    cin >> s >> t;
    REP(i, MAX_L) REP(j, MAX_L) dp[i][j] = 0;
    REP(i, s.size())
    {
        REP(j, t.size())
        {
            updateMax(dp[i + 1][j + 1], dp[i + 1][j]);
            updateMax(dp[i + 1][j + 1], dp[i][j + 1]);
            if (s[i] == t[j])
            {
                updateMax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
        }
    }
    string ans;
    int i = s.size();
    int j = t.size();
    while (i > 0 && j > 0)
    {
        if (dp[i][j] == dp[i - 1][j])
        {
            --i;
        }
        else if (dp[i][j] == dp[i][j - 1])
        {
            --j;
        }
        else
        {
            ans = s[i - 1] + ans;
            --i;
            --j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35840
#include<bits/stdc++.h>
using namespace std;
bool palin(int n){
  bool flag=false;
if((n%10==n/10000)&&((n%100-n%10)/10==(n/1000)-(n/10000)*10)){flag=true;}
   return flag;
   }
int main(){
int a,b;
cin >> a>>b;
  int cnt=0;
for(int i=a;i<=b;i++){
if(palin(i))cnt++;}
  cout << cnt <<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    char c;
    std::cin >> c;
    switch (c)
    {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
        std::cout << "vowel\n";
        break;
    default:
        std::cout << "consonant\n";
        break;
    }
    return 0;
}


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

const int MAXn = 200 + 10, MAXs = 1e5 + 10, MOD = 1e9 + 7;

long long dp[MAXn][MAXs], n, x, ar[MAXn];


int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	sort(ar, ar + n);	
	for (int i = 0; i < MAXs; i++)
		dp[0][i] = i % ar[0];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < MAXs; j++)
			dp[i][j] = (((dp[i-1][j] * i) % MOD) + dp[i-1][j % ar[i]]) % MOD;
	}
	cout << dp[n-1][x];
}

Measured memory_bytes: 157952
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define int long long
#define elif else if
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
signed main(){
  long double a ;
  cin >> a;
  a = a / 3;
  cout << setprecision(15) << a * a * a << "\n";
  return 0;
}
  
  

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

typedef struct point{
	int a,b,c,d;
	point(int aa,int bb,int cc, int dd){
		a=aa;b=bb;c=cc;d=dd;
	}
} point;

int n,m,q;
vector<point> p;
int best = 0;

void calc(vector<int> ls){
	int res=0;
	for(auto pp: p){
		if(ls[pp.b] - ls[pp.a] == pp.c)res += pp.d;
	}
	best = max(best, res);
}

void dfs(vector<int> ls, int pos){
	if(pos==n){
		calc(ls);
	}else{
		int x = (pos==0?1:ls[pos-1]);
		repi(i, x, m+1){
			ls[pos] = i;
			dfs(ls, pos+1);
		}
	}
}


int main()
{
	cin>>n>>m>>q;
	rep(i,q){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;b--;
		p.push_back(point(a,b,c,d));
	}

	vector<int> ls(n,0);

	dfs(ls, 0);

	cout<<best<<endl;
	return 0;
}

Measured memory_bytes: 3632
import sys

sys.setrecursionlimit(1000000)


# The class of range query on a Tree
class RQT:
    # The initialization of node
    def __init__(self, num):
        self.num = num
        self.weight = [0] * (num + 1)

    # weight add operation
    def add(self, v, w):
        if v == 0:
            return 0
        while v <= self.num:
            self.weight[v] += w
            v += (-v) & v

    # weight sum operation
    def getSum(self, u):
        temp = 0
        while u > 0:
            temp += self.weight[u]
            u -= (-u) & u
        return temp


N = int(input())
left = [0] * N
right = [0] * N
# use set to construct the tree
Tree = [set(map(int, input().split()[1:])) for i in range(N)]

# use DFS to search the target node
def DFS(count, source):
    count += 1
    left[source] = count
    for item in Tree[source]:
        count = DFS(count, item)
    count += 1
    right[source] = count
    return count


Object = RQT(DFS(1, 0))

# read the operation code
Q = int(input())
for i in range(Q):
    alist = list(map(int, input().split()))
    if not alist[0]:
        Object.add(left[alist[1]], alist[2])
        Object.add(right[alist[1]], -alist[2])
    else:
        print(Object.getSum(right[alist[1]] - 1))


Measured memory_bytes: 143716
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>

using namespace std;

int main(){
        int n,t,a;
        double h[1010];
        int keeph,ans=0;
        cin>>n>>t>>a;
        for(int i=0; i<n; i++){
                cin>>keeph;
                h[i]=t-keeph*0.006;
        }

        for(int i=1; i<n; i++){
                if(fabs(a-h[ans])>fabs(a-h[i])) ans=i;
        }
        cout<<ans+1<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nax = 1e9+7;
#define fo(i,a,b) for(int i = int(a); i <= int(b); i++)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int d, t, s;
    cin >> d >> t >> s;
    if(s * t >= d) {
        cout << "Yes\n";
    }
    else cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,x,y,maxv,minv,p;
	long long s;
	cin>>a>>b>>c>>x>>y;
	maxv=max(x,y);minv=min(x,y);
	if(minv==x) 
		p=b;
	else
		p=a;
	s=min(a*x+b*y,min(2*maxv*c,2*minv*c+p*int(fabs(x-y))));
	cout<<s<<endl;
	return 0;
}

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

class Dice{
    public:
    
        std::array<int, 6> num;
    
        Dice(){};
    
        void rollN(){
            int t = num[0];
            num[0] = num[1];
            num[1] = num[5];
            num[5] = num[4];
            num[4] = t;
        }
        void rollE(){
            int t = num[0];
            num[0] = num[3];
            num[3] = num[5];
            num[5] = num[2];
            num[2] = t;
        }
        void rollS(){
            int t = num[0];
            num[0] = num[4];
            num[4] = num[5];
            num[5] = num[1];
            num[1] = t;
        }
        void rollW(){
            int t = num[0];
            num[0] = num[2];
            num[2] = num[5];
            num[5] = num[3];
            num[3] = t;
        }
        void rollR(){
            int t = num[1];
            num[1] = num[3];
            num[3] = num[4];
            num[4] = num[2];
            num[2] = t;
        }
        void rollL(){
            int t = num[1];
            num[1] = num[2];
            num[2] = num[4];
            num[4] = num[3];
            num[3] = t;
        }
};

int main(){
    
    Dice dice;
    int n = 6;
    std::array <int, 6> org_dice;
    for(int i=0; i<6; i++) std::cin >> org_dice[i];
    
    int q = 0;
    std::cin >> q;
    
    int top=-1, front=-1, right=-1;
    while(q--){
        for(int i=0; i<6; i++) dice.num[i] = org_dice[i];
        std::cin >> top >> front;
        auto itposTop = std::find(dice.num.begin(), dice.num.end(), top);
        int posTop = itposTop - dice.num.begin();
        if(posTop == 1){
            dice.rollN();
        }else if(posTop == 2){
            dice.rollW();
        }else if(posTop == 3){
            dice.rollE();
        }else if(posTop == 4){
            dice.rollS();
        }else if(posTop == 5){
            dice.rollN();
            dice.rollN();
        }
      
        auto itposFront = std::find(dice.num.begin(), dice.num.end(), front);
        int posFront = itposFront - dice.num.begin();
      
        if(posFront == 1) 
        	right = dice.num[2];
        if(posFront == 2)
            right = dice.num[4];
        if(posFront == 4)
            right = dice.num[3];
        if(posFront == 3)
            right = dice.num[1];
        std::cout << right << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3100