akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string n;
VI num;
ll ans;

int main()
{
    cin>>n;

    num.push_back(0);
    REPALL(i,n) {
        num.push_back(n[i] - '0');
    }
    RREPALL(i,num) {
        if (num[i] <= 4) {
            ans += num[i];
        } else if (num[i] == 5) {
            ans += num[i];
            if (i != 0 && num[i-1] > 4)
                num[i-1]++;
        } else {
            ans += 10 - num[i];
            if (i != 0)
                num[i-1]++;
            else
                cerr<<"error"<<endl;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 7676
# @Author: Amit Dwivedi
# @Date:   2019-12-22 11:55:43
# @Last Modified by:   Amit Dwivedi
# @Last Modified time: 2019-12-22 12:04:16
ll= lambda : list(map(int,input().split()))
testcases=1
# testcases=int(input())
for testcase in range(testcases):
	[n] = ll()
	s,t = input().split()
	for i in range(n):
		print(s[i],t[i],sep = "",end = "")

Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,int> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
 
int n;
int i,j;
double x,y;
double a[101],b[101];
int cou[101];
double kyo;
double ima;
int look;
 
int main(){
	cin>>n;
	memset(cou,0,sizeof(cou));
	for(i=0;i<n;i++){
		cin>>x>>y;
		a[i]=x*1.000;
		b[i]=y*1.000;
	}
	double xx,yy;
	for(i=0;i<2000000;i++){
		ima = INF;
		xx=sin(i*7.000000/Pi);
		yy=cos(i*7.000000/Pi);
		for(j=0;j<n;j++){
			kyo  =-a[j]*xx - b[j] * yy ;
			if(kyo<ima){
				ima = kyo;
				look = j;
			}
		}
		cou[look] += 1;
 
	}
	for(i=0;i<n;i++){
		cout<< fixed << setprecision(16) <<(double)cou[i]*1.00000000/2000000<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, m, a[101], r, sum;

int main()
{
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 1; i <= n; i++)
    if (4 * m * a[i] >= sum)
      r++;
  if (r >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> x(n);
	vector<ll> s(n);
	REP(i,n) cin >> x[i] >> s[i];
	ll ans = 0;
	REP(i,n) ans = max(ans, s[i]);
	priority_queue<ll> q;
	q.push(0);
	ll sum = 0;
	REP(i,n) {
		q.push(x[i] - x[0] - sum);
		sum += s[i];
		ans = max(ans, sum - (x[i] - x[0]) + q.top());
	}
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a <= d && b >= c) cout << min(b,d) - max(a,c) << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a-b>c)
    cout<<0;
  else
  cout<<c-a+b;
}

Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_must_use)]

fn solve(src: &str) -> String {
    use std::fmt::Write;
    let mut buf = String::new();
    let mut sc = Scanner::from_str(&src);

    let n: usize = sc.read();
    let k: usize = sc.read();
    let h: Vec<usize> = sc.vec(n);

    let mut ans = 0;
    for &h in h.iter() {
        if h >= k {
            ans += 1;
        }
    }

    write!(&mut buf, "{}", ans);

    buf
}

#[test]
fn test() {
    assert_eq!(solve(r"4 150
150 140 100 200"),r"2");
assert_eq!(solve(r"1 500
499"),r"0");
assert_eq!(solve(r"5 1
100 200 300 400 500"),r"5");
}

fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf);
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes());
}

struct Scanner<I>{
    src: I
}

impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner { src: src.split_whitespace() }
    }
}

impl<'a, I> Scanner<I> where I: std::iter::Iterator<Item = &'a str>{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 4352
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
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 REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, x;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>x;
    if(x==1||x==2*n-1){
        return no,0;
    }
    vector<int> ans(2*n-1);
    ans[n-2]=2*n-1;
    ans[n-1]=x;
    ans[n]=1;
    int k=2*n-2;
    for(int i=n+1;i<2*n-1;i++){
        if(k==x){
            k--;
            ans[i]=k;
            k--;
        }
        else{
            ans[i]=k;
            k--;
        }
    }
    for(int i=0;i<n-2;i++){
        if(k==x){
            k--;
            ans[i]=k;
            k--;
        }
        else{
            ans[i]=k;
            k--;
        }
    }
    yes;
    for(int i=0;i<2*n-1;i++){
        cout<<ans[i]<<"\n";
    }
}



Measured memory_bytes: 2304
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  let tmp = ``
  const N = lines[0]
  const Hn = lines[1].split(` `).map(H => +H)
  const obj = { N, Hn }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, Hn } = parseLines(lines)

  let pos = 0
  let tmp = 0
  for(let i = 0; i < N; i++) {
    if (Hn[i] >= Hn[i + 1]) {
      tmp++
    } else {
      if (pos < tmp) {
        pos = tmp
      }
      tmp = 0
    }
  }
  return `${pos}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 27596
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),k=s.nextInt();
		int[][] a=new int[n][2];
		for(int i=0;i<n;i++){
			a[i][0]=i+1;
			a[i][1]=s.nextInt();
		}
		List<Integer> r=new ArrayList<>();

		int prev=-1;

		for(int q=0;q<k+1;q++){
			Arrays.sort(a,(x,y)->y[1]-x[1]);
			int t=0;
			for(int i=0;i<n;i++){
				if(a[i][0]!=prev){
					if(a[i][1]<=0){
						System.out.println(-1);
						return;
					}
					a[i][1]--;
					r.add(t=a[i][0]);
				}
			}
			prev=t;
		}
		System.out.println((n-1)*(k+1)+1);
		System.out.println(r.toString().replaceAll("[^0-9 ]",""));
	}
}

Measured memory_bytes: 28628
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

long long A[200000];
long long cum_sum[200001];
map <long long, long long> cum_sum_count;
int main(){
   int N;
   cin >> N;
   for(int i = 0; i < N; i++){
       cin >> A[i];
   }
   cum_sum[0] = 0;
   for(int i = 0; i < N; i++){
       cum_sum[i + 1] = A[i] + cum_sum[i];
   }

   for(int i = 0; i < N + 1; i++){
       if(cum_sum_count.find(cum_sum[i]) == cum_sum_count.end()){
           cum_sum_count[cum_sum[i]] = 1;
       } else {
           cum_sum_count[cum_sum[i]] ++;
       }
   }

   long long ans = 0;

    for(auto it = cum_sum_count.begin(); it != cum_sum_count.end(); it++){
        ans += it->second * (it->second - 1) / 2;
    }

    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {
    public Main () {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        boolean four = false;

        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        for (String i: s) {
            if (i.equals("Y"))
                four = true;
        }

        if (four) {
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }


    public static void main (String[] args) {
        new Main();
    }

}


Measured memory_bytes: 21588
/*input
2
1
2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
ll a[maxn];

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	int cnt=0;
	REP(i,n) if(a[i]%2) cnt++;
	if(cnt) cout<<"first\n";
	else cout<<"second\n";

	return 0;
}


Measured memory_bytes: 1024
// Matrix Chain Multiplication
#include <stdio.h>

#define MAX 100
#define INF 999999999

int M[MAX+1][MAX+1], P[MAX+1];

// 小さいほうを返す //
int min(int x, int y){
  if(x < y)return x;
  else return y;
}

// 動的計画法による連鎖行列積最適解 //
// かけ算の総回数の最小値を求める //
int matrixChainMultiplication(int n){
  int i, j, k, l, q;

  //n = plength;
  
  for(i=1; i <= n; i++){
    M[i][i] = 0;
  }
  for(l=2; l <= n; l++){
    for(i=1; i <= n-l+1; i++){
      j = i + l - 1;
      M[i][j] = INF;
      for(k=i; k < j; k++){
        q = M[i][k] + M[k+1][j] + P[i-1] * P[k] * P[j];
        M[i][j] = min(M[i][j], q);
      }
    }
  }
  return M[1][n];
}

int main(){
  int i, n;
  scanf("%d", &n);
  for(i=1; i <= n; i++){
    scanf("%d%d", &P[i-1], &P[i]);
  }
  printf("%d\n", matrixChainMultiplication(n));
  return 0;
}



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

using namespace std;

string s1;
char s2[110];
char s3[500];
int main()
{
    cin >> s1;
    cin >> s2;
    s1 += s1;
    for(int i = 0;i<s1.size();i++){
        s3[i] = s1[i];
    }
    int len2 = strlen(s2);
    if(strstr(s3,s2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> march(5, 0);
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s[0] == 'M')
        {
            march[0]++;
        }
        else if (s[0] == 'A')
        {
            march[1]++;
        }
        else if (s[0] == 'R')
        {
            march[2]++;
        }
        else if (s[0] == 'C')
        {
            march[3]++;
        }
        else if (s[0] == 'H')
        {
            march[4]++;
        }
    }
    long long ans = 0LL;
    for (int bit = 0; bit < (1 << 5); bit++)
    {
        int co = 0;
        for (int i = 0; i < 5; i++)
        {
            if (bit & (1 << i))
            {
                co++;
            }
        }
        long long temp = 1LL;
        if (co == 3)
        {
            for (int i = 0; i < 5; i++)
            {
                if (bit & (1 << i))
                {
                    temp *= march[i];
                }
            }
            ans += temp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
board = []
for i in range(h):
  board += [input()]

result = True

def check(i, j):
  if board[i][j] == '.':
    return True
  
  if i == 0:
    if j == 0:
      if board[i][j + 1] == '.' and board[i + 1][j] == '.':
        return False
    elif j == w - 1:
      if board[i][j - 1] == '.' and board[i + 1][j] == '.':
        return False
    else:
      if board[i][j - 1] == '.' and board[i][j + 1] == '.' and board[i + 1][j] == '.':
        return False
  elif i == h - 1:
    if j == 0:
      if board[i][j + 1] == '.' and board[i - 1][j] == '.':
        return False
    elif j == w - 1:
      if board[i][j - 1] == '.' and board[i - 1][j] == '.':
        return False
    else:
      if board[i][j - 1] == '.' and board[i][j + 1] == '.' and board[i - 1][j] == '.':
        return False
  else:
    if j == 0:
      if board[i][j + 1] == '.' and board[i - 1][j] == '.' and board[i + 1][j] == '.':
        return False
    elif j == w - 1:
      if board[i][j - 1] == '.' and board[i - 1][j] == '.' and board[i + 1][j] == '.':
        return False
    else:
      if board[i][j - 1] == '.' and board[i][j + 1] == '.' and board[i - 1][j] == '.' and board[i + 1][j] == '.':
        return False

  return True

for i in range(h):
  for j in range(w):
    result = check(i, j)
    if not result:
      break
  if not result:
    break

if result:
  print("Yes")
else:
  print("No")
  


Measured memory_bytes: 3188
#include<cstdio>
using namespace std;

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 n,q;
	int S[10000+1],T;
	int i,j,same=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&T);
		if(linearSearch(S,n,T)) same++;
	}
	
	printf("%d\n",same);
	return 0;
}

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

using namespace std;
using ll = long long;


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

    ll N, M;
    cin >> N >> M;

    ll ans = 0;
    if (N==1 && M==1) ans = 1;
    else if (N==1 || M==1) ans = N*M-2;
    else ans = N*M-(N*2+M*2-4);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n,m;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():

    mod = 1000000007
    n, k = map(int, input().split())

    fact1 = [0] * (n + 1)  # 1/P!
    fact1[0] = 1

    for i in range(1, n + 1):
        fact1[i] = (fact1[i - 1] * i) % mod

    fact2 = [0] * (n + 1)  # P!
    fact2[n] = pow(fact1[n], mod-2, mod)

    for i in range(n, 0, -1):
        fact2[i - 1] = (fact2[i] * i) % mod

    def cmb2(n, r, mod):
        if r < 0 or r > n:
            return 0
        return fact1[n] * fact2[n - r] * fact2[r] % mod

    ans = 0
    for i in range(min(n - 1, k) + 1):
        ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
        ans %= mod
    print(ans)


main()


Measured memory_bytes: 19296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef unsigned int UINT;
using namespace std;

//wが美しい文字列ならば Yes を、それ以外の場合は No を出力せよ

int main(void) {
    map<char, int>  counts;
    string S;
    cin >> S;
    for (auto c : S) {
        counts[c]++;
    }
    bool beutiful = true;
    for (auto count : counts) {
        if (count.second % 2 == 1) {
            beutiful = false;
            break;
        }
    }

    if (beutiful)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
const int T = 86400;
const double eps = 1e-9;
 
int main(void){
    double L;
    for(int n; cin >> n >> L, n;){
        vector<tuple<int, int, double>> in(n);
        for(auto & e : in){
            int s, t; double u; cin >> s >> t >> u;
            e = tie(s, t, u);
        }
 
        double lb = 0.0, ub = 1e6;
        rep(loop, 100){
            double mid = (lb + ub) / 2.0;
 
            vector<double> ls(2);
            double rest = L;
            bool ok = true;
            [&]{
                rep(_, 2){
                    int curt = 0;
                    for(auto & e : in){
                        int s, t; double u; tie(s, t, u) = e;
 
                        rest = min(rest + (s - curt) * mid, L);
                        curt = s;
 
                        rest = min(rest + (t - curt) * (mid - u), L);
                        curt = t;
 
                        if(rest < 0){
                            ok = false;
                            return;
                        }
                    }
                    rest = min(rest + (T - curt) * mid, L);
 
                    ls[_] = rest;
                }
            }();
 
            if(ok and abs(ls[0] - ls[1]) < eps){
                ub = mid;
            }
            else {
                lb = mid;
            }
        }
 
        printf("%.12f\n", ub);
    }
 
    return 0;
}

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

const int INF=1e9;

int main(){
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);*/

	int n;cin>>n;
	vector<int> a(n),dp(n,INF);
	for(int i=0;i<n;i++)cin>>a[i];
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j:{i+1,i+2}){
			if(j<n)dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n-1];

    /*#ifndef ONLINE_JUDGE
    	cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main(void){
    int n, ans=0;
    std::cin >> n;

    for (int i=0; i<50001; ++i){
        if (i * 108 / 100 == n){
            ans = i;
        }
    }

    if (ans == 0){
        std::cout << ":(" << std::endl;
    } else {
        std::cout << ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3552
def nCr(n, r):
  ret = 1
  for i in range(r):
    ret *= n - i
  for i in range(r):
    ret /= i + 1
  return ret

(n, m, r) = map(int, raw_input().split())

N = r - m * n

if N < 0:
  print 0
else:
  print nCr(N + n - 1, n - 1)

Measured memory_bytes: 4572
var lines = []; var result = 0; var ans = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = Number(lines[0]);
    var S = lines[1].split("");

    for (var i = 0; i < N; i++) {
        var alphabet_before = Array(26).fill(0)
        var alphabet_after = Array(26).fill(0)

        for (var j = 0; j < i; j++) { alphabet_before[S[j].charCodeAt(0) - 97]++ }
        for (var j = i; j < N; j++) { alphabet_after[S[j].charCodeAt(0) - 97]++ }

        for (var j = 0; j < 26; j++) {
            if (0 < alphabet_before[j] && 0 < alphabet_after[j]) { result++; }
        }
        ans = Math.max(ans, result);
        result = 0;
    }
    console.log(ans);
});

Measured memory_bytes: 7756
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
    }

    if (a + b) % 2 == 1 {
        print!("IMPOSSIBLE");
        return;
    }

    print!("{}", (a + b) / 2)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int W, H; cin >> W >> H;
  vector<P> a(W + H);
  for (int i = 0; i < W + H; i++) {
    int x; cin >> x;
    a[i] = {x, (i < W)};
  }
  sort(begin(a), end(a));
  ll ans {};
  int c[2] { W + 1, H + 1 };
  for (auto x : a) {
    ans += (ll)x.first * c[x.second];
    c[!x.second]--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
long long n, a, x, z, C=2500, d[2][5005];
int main() {
	int i, j;
	scanf("%lld%lld", &n, &a);
	d[0][C] = 1;
	for(i=0; i<n; i++) {
		scanf("%lld", &x);
		x -= a;
		z = !z;
		for(j=0; j<=5000; j++) d[z][j] = 0;
		for(j=0; j<=2*C; j++) {
			if(d[!z][j]) {
				d[z][j] += d[!z][j];
				d[z][j+x] += d[!z][j];
			}
		}
	}
	printf("%lld", d[z][C]-1);
}

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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vvi G(n);
  rep(i,n){
    string s;cin>>s;
    rep(j, i+1, n){
      if (s[j]=='1') {
        G[i].pb(j);
        G[j].pb(i);
      }
    }
  }
  dump(G);

  int ans = -1;
  rep(sv, n){
    stack<int> st;
    int k = 1;
    st.push(sv);
    bool valid = true;
    vi level(n, -1);
    level[sv] = 1;

    while(true){
      k++;
      dump(sv, k);

      stack<int> nst;
      while(!st.empty()){
        int v = st.top();st.pop();
        each(to, G[v]){
          if (level[to]==-1){
            nst.push(to);
            level[to] = k;
          }
          else if (level[to]==k or level[to]==k-2){
          }
          else{
            dump(to, k, level[to], level);
            valid = false;
          }
        }
      }
      if (!valid) break;

      if (nst.empty()) break;
      else{
        st = nst;
      }
    }
    dump(level);
    // rep(i,n){
    //   each(j, G[i]){
    //     if (level[i]-level[j]!=1 and level[i]-level[j]!=-1)
    //       valid = false;
    //   }
    // }
    if (valid) chmax(ans, k-1);
  }
  cout << ans << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    ll K, X, Y; cin >> K >> X >> Y;
    if (K % 2 == 0 && (abs(X) + abs(Y)) % 2 == 1) {
        cout << -1 << endl; return 0;
    }

    ll curX = 0, curY = 0;

    ll ans = (abs(X) + abs(Y) +K-1)/K;
    if (ans == 1 && (abs(X)+abs(Y)) != K) ans++;
    while ((ans*K-abs(X)-abs(Y))%2 != 0) ans++;

    ll waste = ans*K; waste -= (abs(X)+abs(Y)); waste /= 2;
    cout << ans << endl;
    bool loX = abs(X) < abs(Y);
    while (waste > 0) {
        if (loX && X >= 0) {
            curX -= min(waste, K);
        } else if (loX) {
            curX += min(waste, K);
        } else if (Y >= 0) {
            curY -= min(waste, K);
        } else {
            curY += min(waste, K);
        }
        ll leftover = K - min(waste, K);
        //cout << leftover << endl;
        if (loX) {
            //adjust Y
            if (curY < Y) {
                curY += leftover;
            } else {
                curY -= leftover;
            }
        } else {
            if (curX < X) {
                curX += leftover;
            } else curX -= leftover;
        }

        waste -= min(waste, K);
        cout << curX << " " << curY << endl;
        loX = abs(X-curX) < abs(Y-curY);
    }

    while (curX != X || curY != Y) {
        ll rem = K;
        if (curX != X) {
            ll todo = min(K, abs(X-curX));
            if (curX < X) {
                curX += todo;
            } else {
                curX -= todo;
            }
            rem -= todo;
        }
        if (curY != Y) {
            ll todo = min(rem, abs(Y-curY));
            if (curY < Y) {
                curY += todo;
            } else curY -= todo;
        }

        cout << curX << " " << curY << endl;
    }



    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
int n;
string s;
vector<char> ans(100005);

void tyosa() {
    REPN(i, 1, n) {
        if(ans[i] == 'S') {
            if(s[i] == 'o') ans[(i+1)%n] = ans[i-1];
            else ans[(i+1)%n] = ans[i-1] == 'S' ? 'W' : 'S';
        } else {
            if(s[i] == 'x') ans[(i+1)%n] = ans[i-1];
            else ans[(i+1)%n] = ans[i-1] == 'S' ? 'W' : 'S';                
        }
    }
}

bool hantei() {
    if(s[0] == 'o') {
        if(ans[0] == 'S') {
            if(ans[n-1] == ans[1]) {
                return true;
            }
        } else {
            if(ans[n-1] != ans[1]) {
                return true;
            }            
        }
    } else {
        if(ans[0] == 'S') {
            if(ans[n-1] != ans[1]) {
                return true;
            }
        } else {
            if(ans[n-1] == ans[1]) {
                return true;
            }            
        }        
    }

    return false;
}

int main(){
    cin >> n >> s;
    char zenkai;

    /* 羊、羊 */
    ans[0] = 'S';
    zenkai = 'S';
    ans[1] = 'S';
    tyosa();
    if(zenkai == ans[0]) {
        if(hantei()) {
            REP(i, n) cout << ans[i];
            cout << endl;
            return 0;
        }
    }

    /* 羊、狼 */
    ans[0] = 'S';
    zenkai = 'S';
    ans[1] = 'W';
    tyosa();
    if(zenkai == ans[0]) {
        if(hantei()) {
            REP(i, n) cout << ans[i];
            cout << endl;
            return 0;
        }
    }

    /* 狼、羊 */
    ans[0] = 'W';
    zenkai = 'W';
    ans[1] = 'S';
    tyosa();
    if(zenkai == ans[0]) {
        if(hantei()) {
            REP(i, n) cout << ans[i];
            cout << endl;
            return 0;
        }
    }

    /* 狼、狼 */
    ans[0] = 'W';
    zenkai = 'W';
    ans[1] = 'W';
    tyosa();
    if(zenkai == ans[0]) {
        if(hantei()) {
            REP(i, n) cout << ans[i];
            cout << endl;
            return 0;
        }
    }    

    cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        /*xとyの最大公約数はyとx%yの最大公約数と同じなのでx%y==0になるまで入れ替えればyが最大公約数となる*/
        while(x%y!=0){
            int tmp = x%y; //tmpに一時的にx%yを格納し入れ替え
            x = y;
            y = tmp;
        }
        System.out.println(y);
    }
}


Measured memory_bytes: 26176
#include <cstdio>
    #include <vector>
     
    using namespace std;
     
    const int N = 1000005;
     
    int n;
    vector<int> g[N];
     
    int Dfs(int x, int fat) {
      int s = 0, r = 0;
      for (int i = 0; i < g[x].size(); ++i) {
        int v = g[x][i];
        if (v == fat) continue;
        int d = Dfs(v, x);
        r += d;
        if (!d) {
          if (!s) s = 1; else ++r;
        }
      }
      return r;
    }
     
    int main() {
      scanf("%d", &n);
      for (int i = 1, x, y; i < n; ++i) {
        scanf("%d%d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
      }
      for (int i = 0; i < n; ++i) {
        if (g[i].size() > 2) {
          printf("%d\n", Dfs(i, -1));
          return 0;
        }
      }
      printf("1\n");
      return 0;
    }

Measured memory_bytes: 31104
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47476
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(2e6+5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
vi fact(mxn,1);
ll powe(ll x,ll y){
	ll s=1;while(y){
		if(y%2) s=(s*x)%mod;
		y/=2;x=(x*x)%mod;
	}return s;
}ll ncr(ll n,ll r){
	ll den=(powe(fact[r],mod-2)*powe(fact[n-r],mod-2))%mod;
	return (fact[n]*den)%mod;
}
int main(){fast;
	int k;string s;cin>>k>>s;
	int n=s.size()+k,i;
	for(i=1;i<=n;i++) fact[i]=(fact[i-1]*i)%mod;
	ll c=powe(26,n);for(i=0;i<(int)s.size();i++){
		ll x=(powe(25,n-i)*ncr(n,i))%mod;
		c=(c-x+mod)%mod;
	}cout<<c<<endl;
}


Measured memory_bytes: 19944
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <map>
using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<lli> xs, ys;
    vector<lli> a(n),b(n),c(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
        xs.push_back(a[i]);
        xs.push_back(b[i]);
        ys.push_back(c[i]);
    }
    vector<lli> d(m),e(m),f(m);
    for(int i=0; i<m; i++){
        cin >> d[i] >> e[i] >> f[i];
        xs.push_back(d[i]);
        ys.push_back(e[i]);
        ys.push_back(f[i]);
    }

    xs.push_back(0);
    ys.push_back(0);
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    map<lli, lli> xconv;
    for(int i=0; i<(int)xs.size(); i++){
        xconv[xs[i]] = i;
    }
    map<lli, lli> yconv;
    for(int i=0; i<(int)ys.size(); i++){
        yconv[ys[i]] = i;
    }
    vector<vector<int>> grid(xs.size()*2+3, vector<int>(ys.size()*2+3, 0));
    for(int i=0; i<n; i++){
        int y = 2*yconv[c[i]] +1;
        int xfrom = 2*xconv[a[i]] +1;
        int xto = 2*xconv[b[i]] +1;
        for(int x=xfrom; x<=xto; x++){
            grid[x][y] = 1;
        }
    }
    for(int i=0; i<m; i++){
        int x = 2*xconv[d[i]]+1;
        int yfrom = 2*yconv[e[i]]+1;
        int yto = 2*yconv[f[i]]+1;
        for(int y=yfrom; y<=yto; y++){
            grid[x][y] = 1;
        }
    }

    queue<pii> wait;
    wait.push(pii(2*xconv[0]+1, 2*yconv[0]+1));
    while(!wait.empty()){
        int x = wait.front().first;
        int y = wait.front().second;
        wait.pop();
        for(int d=0; d<4; d++){
            int nx = x+dx[d];
            int ny = y+dy[d];
            if(nx<0 or nx>=(int)grid.size()) continue;
            if(ny<0 or ny>=(int)grid[0].size()) continue;
            if(grid[nx][ny] == 0){
                grid[nx][ny] = 2;
                wait.push(pii(nx,ny));
            }
        }
    }
    if(grid[0][0] == 2){
        cout << "INF" << endl;
        return 0;
    }

    lli ans = 0;
    for(int i=0; i<(int)xs.size()-1; i++){
        lli w = xs[i+1]-xs[i];
        for(int j=0; j<(int)ys.size()-1; j++){
            lli h = ys[j+1]-ys[j];
            if(grid[2*i+2][2*j+2]==2){
                ans += w*h;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 144772
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>

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

using namespace std;

string f(string s) {
  string r;
  for(char c:s){
    if('a' <= c && c <= 'z')
      r += c + 'A' - 'a';
    else if ('A' <= c && c <= 'Z')
      r += c;
  }
  return r;
}

int main() {
  string s;
  getline(cin, s);
  while(cin) {
    s = f(s);
    int n = s.size();
    int dp[1024][1024];
    REP(i,n)
      REP(j,n){
        if (i==j)
          dp[i][i] = 1;
        else
          dp[i][j] = 0;
      }
    for(int i = n - 1; i >= 0; --i) {
      for(int j = i+1; j < n; ++j) {
        if (j==i+1) {
          if(s[i] == s[j]) dp[i][j] = 1;
        } else {
          if (dp[i+1][j-1] && s[i] == s[j]) dp[i][j] = 1;
        }
      }
    }
    vector<int> palind(n*2, 0);
    REP(i,n){
      for(int j = i+2; j < n; ++j) {
        if (dp[i][j] == 1) {
          palind[i+j] = max(palind[i+j] ,j - i + 1);
        }
      }
    }
    set<string> invalid;
    set<string> res;
    REP(i,n*2){
      if (palind[i]) {
        int st = (i - palind[i] + 1) / 2;
        string str = s.substr(st, palind[i]);
        if (invalid.find(str) == end(invalid)) {
          res.insert(s.substr(st, palind[i]));
          for (int j = 1; j * 2 < palind[i]; ++j) {
            string sub = str.substr(j, palind[i] - j * 2);
            invalid.insert(sub);
            if (res.find(sub) != end(res)) {
              res.erase(sub);
            }
          }
        }
      }
    }
    int cnt = 0;
    for(const string& str : res) {
      if(cnt) cout << ' ';
      cout << str;
      ++cnt;
    }
    cout << endl;
    getline(cin, s);
  }
  return 0;
}

Measured memory_bytes: 4320
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  long long N;
  std::cin >> N;
  std::string ans;
  long long pow = 26;
  long long x = 0;
  int cnt = 1;
  while(x + pow < N)
  {
    x += pow;
    pow *= 26;
    ++cnt;
  }
  N -= x + 1;
  pow = 1;
  for(int i = 0; i < cnt; ++i)
  {
    ans.push_back((N/pow) % 26 + 'a');
    pow *= 26;
  }
  std::reverse(ans.begin(), ans.end());
  std::cout << ans << std::endl;
  return 0;
}



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

int main(){

    int N;
    int M;
    cin >> N;
    cin >> M;

    int max = 100000;
    int min = 0;
    int temp1 = 0;
    int temp2 = 0;
    int result = 0;
    for(int i = 0; i < M; i++){

        cin >> temp1;
        cin >> temp2;

        if(min < temp1){
            min = temp1;
        }
        if(max > temp2){
            max = temp2;
        }

    }

    if (max >= min){
        result = max - min + 1;
    }else{
        result = 0;
    }

    cout << result << "\n";

}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1092
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

#define ll long long
#define loop(x, start, end) for(int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)

#define left(x) (x * 2)
#define right(x) (x * 2 + 1)
#define parent(x) (x / 2)
#define max3(x, y, z) (max(x, max(y, z)))

class PriorityQueue {
public:
    PriorityQueue() {
        vec.push_back(-99999);
        size = 0;
    }
    
    void insert(int key) {
        size++;
        if (size >= vec.size()) {
            vec.push_back(key);
        } else {
            vec[size] = key;
        }
        
        int index = size;
        int p = parent(index);
        while (index > 1 && vec[p] < vec[index]) {
            swap(vec[p], vec[index]);
            index = p;
            p = parent(index);
        }
    }
    
    int extract() {
        int _max = vec[1];
        vec[1] = vec[size];
        maxHeapify(1);
        size--;
        return _max;
    }
    
    void print() {
        loop(i, 1, size+1) cout << " " << vec[i];
        cout << endl;
    }
    
private:    
    vector<int> vec;
    int size;
    
    void maxHeapify(int index) {
        int last = size;
        int l = left(index);
        int r = right(index);
        int largest;
        if (l <= last && vec[l] > vec[index]) largest = l;
        else largest = index;
        if (r <= last && vec[r] > vec[largest]) largest = r;
        
        if (largest != index) {
            swap(vec[largest], vec[index]);
            maxHeapify(largest);
        }
    }
};


int main(void){
    int x;
    PriorityQueue pq;
    string op = "no op";
    
    while (op[2] != 'd') {
        cin >> op;
        if (op[2] == 's') {
            // insert
            cin >> x;
            pq.insert(x);
        }
        else if (op[2] == 't') {
            // extract
            cout << pq.extract() << endl;
        }
    }
    return 0;
}



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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  double l;
  cin >> l;
  double w, h, n;
  w = l/3;
  h = l/3;
  n = l/3;
  printf("%.12f", w*h*n);
  return 0;
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
//const int INF = INT64_MAX;
const int INF = INT_MAX;

template<typename T> inline constexpr auto sqr(T x) { return (x) * (x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b)*(1|((a - b)>>(8*sizeof(int))));}

signed main()
{
	int X;
	cin >> X;

	int num500 = X / 500;
	X -= 500 * num500;

	int num5 = X / 5;
	int grad = 1000 * num500 + 5 * num5;

	COL(grad);

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] Args){
        Scanner input = new Scanner(System.in);
        int a, b;
        a = input.nextInt();
        b = input.nextInt();
        input.nextLine();
        if(a / 10 != 0 || b / 10 != 0){
            System.out.println(-1);
        }
        else{
            System.out.println(a*b);
        }
    }
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9)
	  cout << a * b << endl;
  else
  	  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256