akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}


void solve()
{
    ll n;cin>>n;
    if(n<=1){
        print(0)
        return;
    }
    ll ans=1;
    ans%=mod;
    ans=(power(10,n));
    ans-=power(9,n);
    ans=(ans+mod)%mod;
    ans-=power(9,n);
    ans=(ans+mod)%mod;
    ans+=power(8,n);
    ans=(ans+mod)%mod;


    ans%=mod;
    print(ans)
}

int main()
{
    //fastio;
   // test
    solve();
}


Measured memory_bytes: 3636
#include<iostream>

using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)

int main(){
  int a, b;
  cin >> a >> b;
  int ans= -a;

  for(int i=1; i< b-a; ++i) ans += i;
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio> 
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100010
ll ans = 0;
int t;
struct {
	int x; ll s;
}a[N];
void ct(int l, int r, int o) {
	if(a[l].x >= t) {
		ans += a[r].x - t;
		return;
	}
	if(a[r].x <= t) {
		ans += t - a[l].x;
		return;
	}
	if(a[l].s >= a[r].s) {
		a[l].s += a[r].s;
		if(o != 0) ans += a[r].x - a[l].x;
		ct(l, r - 1, 0);
	}
	else {
		a[r].s += a[l].s;
		if(o != 1) ans += a[r].x - a[l].x;
		ct(l + 1, r, 1);
	}
}
int main() {
	int n, i;
	scanf("%d%d", &n, &t);
	for(i = 1; i <= n; i++) scanf("%d%lld", &a[i].x, &a[i].s);
	ct(1, n, -1);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3264
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int k;
    cin>>k;
    int o=0,e=0;
    rep(i,1,k+1){
        if(i%2==1)o++;
        else e++;
    }
    cout<<o*e<<endl;
    return 0;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long val[100001];
long long expo(long long b, int e){
    if(e==0){
        return 1LL;
    }
    if(e==1){
        return b;
    }
    if((e&1)==0){
        return expo((b*b)%mod,e/2);
    }
    else{
        long long ret = b*expo(b,e-1);
        ret %= mod;
        return ret;
    }
}
long long get(int len){
    if(len<=100000){
        return val[len];
    }
    return (expo(10LL,len-1)*9LL)%mod;
}
int main(){
    val[0] = 0LL;
    long long ten = 1LL;
    for(int i = 1; i<=100000; i++){
        val[i] = (ten*9LL)%mod;
        ten *= 10LL;
        ten %= mod;
    }
    int nxt = 1;
    int po = 0;
    int s;
    cin >> s;
    long long ans = 0LL;
    for(int i = 1;;i++){
        if(i==nxt){
            po++;
            nxt *= 10;
        }
        if(po==8){
            break;
        }
        int rem = nxt-i;
        if(po*rem>=s){
            if(s%po==0){
                ans++;
            }
        }
        else{
            int ts = s-po*rem;
            int p = po+1;
            while(val[p]*p<ts){
                ts-=val[p]*p;
                p++;
            }
            if(ts%p==0){
                ans++;
            }
        }
    }
    for(int l = 1;;l++){
        int beg = s/l;
        if(beg<8){
            break;
        }
        if(beg==7 && s%l==0){
            if(val[7]>=l){
                ans += (get(beg)-(long long)l+1LL)%mod;
                ans += mod;
                ans %= mod;
            }
        }
        else if(s%l==0){
            ans += (get(beg)-(long long)l+1LL)%mod;
            ans += mod;
            ans %= mod;
        }
        else{
            ans++;
        }
    }
    cout << ans << endl;
}

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

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

  if (N<=2){
    cout << 0 << endl;
  }
  else {
    if (N%2==0){
      ans = N/2-1;
    }
    else {
      ans = (N+1)/2-1;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 0;
    vector<int> sum(2001);
    rep(i, n){
        sum[a[i]]++;
    }

    int half = powM(2, MOD - 2);

    vector<int> cnt(2001);
    for(int i = n - 1; i >= 0; i--){
        cnt[a[i]]++;
        for(int j = 1; j < a[i]; j++){
            int last = (cnt[j] + sum[j] * (k - 1) % MOD) % MOD;
            ans += (cnt[j] + last) % MOD * k % MOD * half % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

ll H;
ll ans = 1;

int main(){
	cin >> H;

	while( H != 0 ){
		H = (H>>1);
		ans = (ans<<1);
	}

	ans--;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	}
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec a(N);
    REP(i,0,N) cin >> a[i];

    vec csum(N+1, 0);
    REP(i,1,N+1) csum[i] = csum[i-1] + a[i-1];

    ll m = INF;
    REP(i,1,N) m = MIN(m,abs(csum[i]*2-csum[N]));
    PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
char s[6010];
basic_string <char> ans[6010];
int q[6010], head, tail, n;
basic_string <int> a, b;
int pos[6010], choose[6010];
int main() {
    scanf("%d%s", &n, s + 1);
    n <<= 1;
    for (int i = 1; i <= n; i++) (s[i] == 'a' ? a : b).push_back(i);
    for (int i = 0; i < n / 2; i++) pos[a[i]] = b[i], pos[b[i]] = a[i];
    int cnt = 0, nxt = n + 1;
    for (int i = n; i > 0; i--) {
        cnt += s[i] == 'a' ? 1 : -1;
        if (cnt) continue;
        ans[i] = ans[nxt];
        memset(choose, 0, sizeof choose);
        head = 1, tail = 0;
        for (int j = i; j < nxt; j++) {
            if (s[j] == 'a') {
                if (choose[j]) {
                    basic_string <char> now = "";
                    for (int k = i; k < nxt; k++) {
                        if(s[k] == 'a' && (choose[k] || k > pos[q[tail]])) now += "a";
                        if(s[k] == 'b' && (choose[k] || k > j)) now += "b";
                    }
                    // cerr << now << endl;
                    ans[i] = max(ans[i], now + ans[nxt]);
                    head++;
                    choose[j] = choose[pos[j]] = 0;
                }
                continue;
            }
            if(pos[j] < j) continue;
            q[++tail] = j, choose[j] = choose[pos[j]] = 1;
        }
        if (tail == 0) {
            memset(choose, 0, sizeof choose);
            for (int j = i; j < nxt; j++) {
                if (s[j] == 'a') {
                    choose[j] = choose[pos[j]] = 1;
                    basic_string <char> now = "";
                    for (int k = i; k <= pos[j]; k++) if(choose[k]) now += s[k];
                    ans[i] = max(ans[i], now + ans[nxt]);
                    j = pos[j];
                }
            }
        }
        nxt = i;
    }
    return cout << ans[1] << endl, 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long po = 0;
    for (int i = 1; i <= N; i++){
        if ((i%3)!=0 && (i%5)!=0 ){
             po = po + i;
        }
    }
    cout << po;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

 
 int main() {
     int a,b,c,d,e,k;
     cin >> a >> b >> c >> d >> e >> k;
     if (b-a<=k && c-a<=k && d-a<=k && e-a<=k && c-b<=k && d-b<=k && e-b<=k && d-c<=k && e-c<=k && e-d<=k){
            cout << "Yay!" << endl;
     }
     else{
         cout << ":(" << endl;
     }
 }

Measured memory_bytes: 256
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
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(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, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] odd = new int[100001];
            int[] even = new int[100001];
            for (int i = 0; i < n / 2; i++) {
                even[in.nextInt()]++;
                odd[in.nextInt()]++;
            }
            int oddmax = -1;
            int oddsmax = -1;
            int oddmaxi = 0;
            int evenmax = -1;
            int evensmax = -1;
            int evenmaxi = 0;
            for (int i = 1; i <= 100000; i++) {
                if (odd[i] > oddmax) {
                    oddsmax = oddmax;
                    oddmax = odd[i];
                    oddmaxi = i;
                } else if (odd[i] > oddsmax) {
                    oddsmax = odd[i];
                }
                if (even[i] > evenmax) {
                    evensmax = evenmax;
                    evenmax = even[i];
                    evenmaxi = i;
                } else if (even[i] > evensmax) {
                    evensmax = even[i];
                }
            }
            if (oddmaxi != evenmaxi) {
                out.println(n - oddmax - evenmax);
            } else {
                out.println(Math.min(n - oddsmax - evenmax, n - oddmax - evensmax));
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 35940
package main

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

var sc = bufio.NewScanner(os.Stdin)

const NIL = -1

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

type Tree struct {
	parent int
	left   int
	right  int
}
type Trees []Tree

func main() {
	var depth int
	var id, key int
	var tree [100000]int
	sc.Split(bufio.ScanWords)
	n := nextInt()

	A := make(Trees, n)

	for i := 0; i < n; i++ {
		A[i].parent = NIL
		A[i].left = NIL
		A[i].right = NIL
	}
	for i := 0; i < n; i++ {
		id = nextInt()
		key = nextInt()
		for j := 0; j < key; j++ {
			tree[j] = nextInt()
			if j == 0 {
				A[tree[0]].parent = id
				A[id].left = tree[0]
			} else {
				A[tree[j]].parent = id
				A[tree[j-1]].right = tree[j]
			}
		}
	}
	for i := 0; i < n; i++ {
		fmt.Printf("node %d: parent = %d, ", i, A[i].parent)
		num := i
		for A[num].parent != NIL {
			depth++
			num = A[num].parent
		}
		fmt.Printf("depth = %d, ", depth)
		depth = 0
		if A[i].parent == NIL && A[i].left == NIL {
			fmt.Println("root, []")
		} else if A[i].parent == NIL && A[i].left != NIL {
			fmt.Printf("root, [%d", A[i].left)
			for j := A[A[i].left].right; j != NIL; j = A[j].right {
				fmt.Printf(", %d", j)
			}
			fmt.Printf("]\n")
		} else if A[i].left != NIL {
			fmt.Printf("internal node, [%d", A[i].left)
			for j := A[A[i].left].right; j != NIL; j = A[j].right {
				fmt.Printf(", %d", j)
			}
			fmt.Printf("]\n")
		} else {
			fmt.Println("leaf, []")
		}
	}
}



Measured memory_bytes: 6972
N=input()
S=raw_input()
L=[0]

for i,x in enumerate(S):
	if x=="#":
		L.append( L[-1]+1 )
	else:
		L.append( L[-1] )
			

ans=float("inf")
for i in range(N+1):
	b=L[i]	# black on left
	w=N-i-(L[-1]-L[i])
	ans=min(ans , b+w)

print ans

Measured memory_bytes: 46364
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e5,mo=1e9+7;

char s[N]; 
int n;
ll gs[N];

int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	fo(i,1,n){
		++gs[s[i]];
	}
	ll ans=1;
	fo(i,1,160)ans=ans*(gs[i]+1)%mo;
	ans=(ans+mo-1)%mo;
	cout<<ans;
}

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

int n;
int _left[25];
int _right[25];
int root_id;
vector<int> pre, in, post;

void input() {
	cin >> n;
	
	bool is_root[25];
	int i;
	for (i = 0; i < n; i++) is_root[i] = true;
	for (i = 0; i < n; i++) {
		int id;
		cin >> id;
		cin >> _left[id] >> _right[id];
		if (_left[id] >= 0) {  is_root[_left[id]] = false; }
		if (_right[id] >= 0) { is_root[_right[id]] = false; }
	}
	for (i = 0; i < n; i++) {
		if (is_root[i]) {
			root_id = i;
			break;
		}
	}
}

void dfs(int v) {
	pre.push_back(v);
	if (_left[v] != -1) dfs(_left[v]);
	in.push_back(v);
	if (_right[v] != -1) dfs(_right[v]);
	post.push_back(v);
}

int main() {
	input();
	dfs(root_id);
	
	cout << "Preorder" << endl << " ";
	for (int i = 0; i < pre.size(); i++) {
		cout << pre[i];
		if (i + 1 < pre.size()) cout << " ";
	}
	cout << endl;
	
	cout << "Inorder" << endl << " ";
	for (int i = 0; i < in.size(); i++) {
		cout << in[i];
		if (i + 1 < in.size()) cout << " ";
	}
	cout << endl;
	
	cout << "Postorder" << endl << " ";
	for (int i = 0; i < post.size(); i++) {
		cout << post[i];
		if (i + 1 < post.size()) cout << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

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

	set<int> ac;
	map<int, int> wa;

	for( int i = 0; i < M; ++i ) {
		int p;
		string S;
		cin >> p >> S;

		if( S == "AC" ) {
			ac.insert( p );
		}
		else if( ac.count( p ) == 0 ) {
			wa[p] += 1;
		}
	}

	int wasum = 0;
	for( auto& v: wa ) {
		if( ac.count( v.first ) ) { wasum += v.second; }
	}

	cout << ac.size() << ' ' << wasum << endl;

	return 0;
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
//   cout<<std::setprecision(12)<<

bool chk(string s){
  int i = 0,j = s.size()-1;

  while(i<j)
  {
      if(s[i] == s[j])i++,j--;
      else return false;
  }
  return true;
}

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

    int i,j,k,l,m,n;

    n = s.size();

    if(!chk(s) || !chk(s.substr(0,(n-1)/2)) || !chk(s.substr((n+3)/2-1,n)))cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
import sys
import math

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

turu = A[0] * 2
min_leg = A[1] - turu
kame = min_leg / 2
Ans = A[0] - kame

f, i = math.modf(Ans)
if f != 0.0:
    print("No")
    exit()

if Ans < 0 or Ans > A[0]:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	string str;
	cin >> str;
	for (int i = 1; i < str.length(); i++) {
		if (str[i] == str[i - 1]) {
			cout << i << " " << i+1 << endl;
			return 0;
		}
	}
	for (int i = 2; i < str.length(); i++) {
		if (str[i] == str[i - 2]) {
			cout << i - 1 << " " << i+1 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
N = int(input())
F = [[0 for _ in range(10)] for _ in range(N)]
P = [[0 for _ in range(10)] for _ in range(N)]

for i in range(N) :
    F[i] = list(map(int, input().split()))
for i in range(N) :
    P[i] = list(map(int, input().split()))

ans = -float('inf')
for mask in range(1, 2**10) :
    profit = 0
    for shop in range(N) :
        count = 0
        for time in range(10) :
            if (mask & (1 << time) != 0) and F[shop][time] == 1 :
                count += 1
        profit += P[shop][count]
    ans = max(ans, profit)

print(ans)

Measured memory_bytes: 3188
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n,m = map(int,input().split())
S = []
k = []
for i in range(m):
    s = input().split()
    k.append(int(s[0]))
    d = []
    for j in range(1,len(s)):
        d.append(int(s[j]))
    S.append(d)
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    li = [False]*n
    flag = 0
    for j in range(n):
        if (i>>j)&1:
            li[n-j-1] = True
    for j in range(m):
        cnt = 0
        for l in range(k[j]):
            if li[S[j][l]-1]:
                cnt += 1
        if cnt%2 == p[j]:
            flag = 1
        else:
            flag = 0
            break
    if flag == 1:
        ans += 1
print(ans)

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
struct query{
    char type;
    int p , flag;
};
int par[100001];
void init(int n){
    par[1] = 1;
    for(int i = 2;i <= n;i++){
        std::cin >> par[i];
    }
}
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}
void unite(int x , int y){
    par[x] = y;
}
int main(){
    int n , q;
    while(std::cin >> n >> q){
        if(n == 0 && q == 0){
            break;
        }
        init(n);

        std::vector<query> vec;
        for(int i = 0;i < q;i++){
            query q1;
            std::cin >> q1.type >> q1.p;
            if(q1.type == 'M'){
                q1.flag = par[q1.p];
                par[q1.p] = q1.p;
            }
            vec.push_back(q1);
        }

        long long int sum = 0;
        for(int i = q - 1;i >= 0;i--){
            if(vec[i].type == 'Q'){
                sum += (long long int)find(vec[i].p);
            }else{
                unite(vec[i].p , vec[i].flag);
            }
        }
        std::cout << sum << "\n";
    }
}


Measured memory_bytes: 5840
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

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

    pair<int, int> ans(-1, -1);
    if (S[0] == S[1]) ans = mp(1, 2);
    if (S.size() > 2) {
        rep(i, 2, S.size()) {
            if (S[i - 1] == S[i]) ans = mp(i, i + 1);
            else if (S[i - 2] == S[i]) ans = mp(i - 1, i + 1);
        }
    }

    cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 512
n, k = map(int, input().split())
mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]
for i in range(2, n+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod%i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

def comb(n, r):
    if r<0 or r>n:
        return 0
    return g1[n] * g2[r] * g2[n-r] % mod

for i in range(1, k+1):
    if i > n-k+1:
        print(0)
    else:
        ans = comb(k-1, i-1) * comb(n-k+1, i)
        print(ans%mod)

Measured memory_bytes: 3572
N, M, X, Y = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

Z = sorted(x, reverse=True)[0] + 1
if Z <= sorted(y)[0] and X < Z <= Y:
  print('No War')
else:
  print('War')

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int N;
int ans;
int u,v;

struct edge{int to,cost;};
int V;
vector<edge> G[200000]; // MAX_V
int dtaka[200000]; // MAX_V
int dao[200000];
void dijkstrat(int S){
  priority_queue<pint,vector<pint>,greater<pint>> que;
  fill(dtaka,dtaka+V,INF);
  dtaka[S]=0;
  que.push(pint(0,S));
  while(!que.empty()){
    pint p=que.top();
    que.pop();
    int v=p.second;
    if(dtaka[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(dtaka[e.to]>dtaka[v]+e.cost){
        dtaka[e.to]=dtaka[v]+e.cost;
        que.push(pint(dtaka[e.to],e.to));
      }
    }
  }
}
void dijkstrao(int S){
  priority_queue<pint,vector<pint>,greater<pint>> que;
  fill(dao,dao+V,INF);
  dao[S]=0;
  que.push(pint(0,S));
  while(!que.empty()){
    pint p=que.top();
    que.pop();
    int v=p.second;
    if(dao[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(dao[e.to]>dao[v]+e.cost){
        dao[e.to]=dao[v]+e.cost;
        que.push(pint(dao[e.to],e.to));
      }
    }
  }
}


int main(void){
    cin >> N >> u >> v;
    V=N;
    u--,v--;
    rep(i,N-1){
        int x,y;
        cin >> x >> y;
        x--,y--;
        edge in;
        in.to=y,in.cost=1;
        G[x].push_back(in);
        in.to=x;
        G[y].push_back(in);
    }
    dijkstrat(u);
    dijkstrao(v);
    rep(i,N) if(dao[i]>dtaka[i]) ans=max(ans,dao[i]);
    cout << ans-1 << endl;
}

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

int main(){
    int N;
    cin>>N;
    double T,A;
    cin>>T>>A;
    double H[10000];
    double MIN=1e9;
    int n;
    for(int i=1;i<=N;i++){
        cin>>H[i];
        if(MIN>abs(T-H[i]*0.006-A)){
            MIN=abs(T-H[i]*0.006-A);
            n=i;
        }
    }
    cout<<n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, W;
    cin >> N >> W;
    vll w(N), v(N);
    auto dp = make_v<ll>(N + 1, 1000 * N + 1); //dp[i][j] := i番目までの品物で価値jにするために必要な重さの最小値
    fill_v(dp, INT_MAX);
    rep(i, N)
    {
        cin >> w[i] >> v[i];
        dp[i][0] = 0;
    }
    rep(i, N)
    {
        rep(j, 1000 * N + 1)
        {
            if (j - v[i] >= 0)
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    ll ans = 0;
    rep(j, 1000 * N + 1)
    {
        if (dp[N][j] <= W)
        {
            ans = j;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> Pii;

int main() {
    int H, W, N; cin >> H >> W >> N;
    int sr, sc; cin >> sr >> sc;
    string S, T; cin >> S >> T;
    
    Pii thor = Pii(0, 0), tver = Pii(0, 0);
    Pii ahor = Pii(0, 0), aver = Pii(0, 0);

    for (int i = 0; i < N; i++) {
        if (S[i] == 'L') thor.first--;
        if (S[i] == 'R') thor.second++;
        if (S[i] == 'U') tver.first--;
        if (S[i] == 'D') tver.second++;

        
        if (thor.first + ahor.second + sc < 1 || W < ahor.first + thor.second + sc) {
            cout << "NO" << endl;
            return 0;
        }
        
        if (tver.first + aver.second + sr < 1 || H < aver.first + tver.second + sr) {
            cout << "NO" << endl;
            return 0;
        }

        if (T[i] == 'L') ahor.first--;
        if (T[i] == 'R') ahor.second++;
        if (T[i] == 'U') aver.first--;
        if (T[i] == 'D') aver.second++;

        if (W < thor.first + ahor.second + sc) ahor.second = W - ahor.first - sc;
        if (ahor.first + thor.second + sc < 1) ahor.first = 1 - sc - thor.second;

        if (H < tver.first + aver.second + sr) aver.second = H - aver.first - sr;
        if (aver.first + tver.second + sr < 1) aver.first = 1 - sr - tver.second;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
#include<math.h>
#define ll long long 
int main(){
  ll n,i,a,b,c;
  ll min; 
  scanf("%lld",&n);
  min=n;
  for(i=2;i<=sqrt(n);i++)
    if(n%i==0){
      a=i;
      b=n/i;
      if(min>a+b-2)
	min=a+b-2;
    }
  if(min!=n)
    printf("%lld\n",min);
  else 
    printf("%lld\n",n-1);

   
  return 0;}


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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    string s;
    cin>>s;
    int k;
    cin>>k;
    int n = sz(s);
    set<string> se;
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            string t = s.substr(j , i);
            se.insert(t);
        }
    }
    for(int i = 1; i < k; i++){
        se.erase(*se.begin());
    }
    string ans = *se.begin();
    cout<<ans;

}

Measured memory_bytes: 4820
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	S := next()
	memo := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		memo[i] = math.MinInt32
	}

	counts := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		dist := calcDist(memo, S, i)
		dir := 1
		if S[i] == 'L' {
			dir = -1
		}
		if Abs(dist)%2 == 0 {
			counts[i+dist]++
		} else {
			counts[i+dist+dir]++
		}
	}

	for i := 0; i < len(counts)-1; i++ {
		fmt.Printf("%d ", counts[i])
	}
	fmt.Printf("%d\n", counts[len(counts)-1])
}

// S[i]がループする位置までのプラス方向の距離
func calcDist(memo []int, S string, i int) int {
	if memo[i] != math.MinInt32 {
		return memo[i]
	}

	dir := 1
	if S[i] == 'L' {
		dir = -1
	}
	if S[i] != S[i+dir] {
		memo[i] = 0
		return memo[i]
	}
	memo[i] = dir + calcDist(memo, S, i+dir)
	return memo[i]
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 17920
let cnt = ref 0

let insertion_sort n ?(gap=1) a =
  for i=gap to n-1 do
    let v = a.(i) in
    let j = ref (i - gap) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+gap) <- a.(!j);
      j := !j - gap;
      incr cnt;
    done;
    a.(!j+gap) <- v
  done;
  a

let shell_sort array n =
  let rec gen_gaps = function
      [] -> gen_gaps [1]
    | h::t when h > n -> t
    | h::_ as l -> gen_gaps ((float_of_int h |> ( *. ) 2.25 |> int_of_float) ::l) in
  let gaps = if n > 701 then gen_gaps [701;301;132;57;23;10;4;1]
    else List.filter ((>=) n) [701;301;132;57;23;10;4;1] in
  let m = List.length gaps in
  let rec loop a = function
      [] -> a
    | h::t -> loop (insertion_sort n ~gap:h a) t in
  let a = loop array gaps in
  Printf.printf "%d\n" m;
  Array.iteri
    (fun i x -> Printf.printf (if i=m-1 then "%d\n" else "%d ") x)
    (Array.of_list gaps);
  Printf.printf "%d\n" !cnt;
  a

let () =
  let n = read_int () in
  let rec read a = function
      i when i = n -> a
    | i -> a.(i) <- (read_int ());
      read a (i+1) in
  let a = read (Array.make n 0) 0 in
  Array.iter (Printf.printf "%d\n") (shell_sort a n)

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

int main() {
  int N;
  string op; 
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >>op;
    if (op =="Y"){
      cout << "Four" <<endl;
      break;
    }
    else if (i==(N-1)) {
      cout << "Three" <<endl;
    }
  }
}


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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    if(str[3] == str[2] && str[5] == str[4]){
        cout << "Yes" << endl;
    }    else{
        cout <<"No" <<endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const ll mod=998244353;
const int N=401;
int n;
int h[N];
ll dp[2][N][N][3];//height, left, no. of columns require rook, 0=row dont have rook, 1= row have rook,2=row have rook and require rook on all rows below
ll dp2[N];
void knap1(int c,int z,int nl,int nr){//sum of O(n*(nr-nl+1)) = O(n^3)
	int p=c^1;
	int nx=nr-nl+1;
	for(int x=n; x>=0 ;x--){
		dp2[x]=dp2[x]*(dp[p][nl][0][0]+dp[p][nl][0][1])%mod;
		for(int y=1; y<=min(x,nx) ;y++){
			dp2[x]=(dp2[x]+dp2[x-y]*(dp[p][nl][y][0]+dp[p][nl][y][1]))%mod;
		}
	}
}
void knap2(int c,int z,int nl,int nr){//sum of O(n*(nr-nl+1)) = O(n^3)
	int p=c^1;
	int nx=nr-nl+1;
	//cout << p << ' ' << nl << ' ' << dp[p][nl][0][0] << ' ' << dp[p][nl][0][2] << endl;
	for(int x=n; x>=0 ;x--){
		dp2[x]=dp2[x]*(dp[p][nl][0][0]+dp[p][nl][0][2])%mod;
		for(int y=1; y<=min(x,nx) ;y++){
			dp2[x]=(dp2[x]+dp2[x-y]*(dp[p][nl][y][0]+dp[p][nl][y][2]))%mod;
		}
	}
}
ll C[N][N];
ll p2[N];
void estatic(){
	p2[0]=1;C[0][0]=1;
	for(int i=1; i<=n ;i++){
		C[i][0]=1;
		p2[i]=p2[i-1]*2%mod;
		for(int j=1; j<=i ;j++){
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;estatic();
	for(int i=1; i<=n ;i++){
		cin >> h[i];
	}
	for(int i=n; i>=1 ;i--){
		int c=i&1;
		int p=c^1;
		for(int j=0; j<=n ;j++){
			for(int k=0; k<=n ;k++){
				for(int l=0; l<3 ;l++) dp[c][j][k][l]=0;
			}
		}
		for(int j=1; j<=n ;j++){
			if(h[j]<i) continue;
			int l=j,r=j;
			while(r<n && h[r+1]>=i) r++;
			j=r;
			int ptr=l;
			int len=r-l+1;
			int free=len;
			for(int k=0; k<=len ;k++) dp2[k]=0;
			dp2[0]=1;
			for(int x=l; x<=r ;x++){
				if(h[x]<i+1) continue;
				int nl=x,nr=x;
				while(nr<r && h[nr+1]>=i+1) nr++;
				x=nr;
				knap1(c,ptr,nl,nr);
				free-=nr-nl+1;
			}
			//cal dp[...][0]
			for(int k=len; k>=0 ;k--){
				if(k>=free) dp2[k]=dp2[k-free];
				else dp2[k]=0;
				dp[c][l][k][0]=(dp[c][l][k][0]+dp2[k])%mod;
			}
			//dp2[k] = k columns require rook
			//cal dp[...][1]
			for(int nx=len; nx>=0 ;nx--){
				ll cmg=p2[len-nx]-1;
				dp[c][l][nx][1]=(dp[c][l][nx][1]+dp2[nx]*cmg)%mod;
				for(int px=nx+1; px<=len ;px++){
					ll mg=p2[len-px]*C[px][px-nx]%mod;
					dp[c][l][nx][1]=(dp[c][l][nx][1]+dp2[px]*mg)%mod;
				}
			}
			for(int k=0; k<=len ;k++) dp2[k]=0;
			dp2[0]=1;
			for(int x=l; x<=r ;x++){
				if(h[x]<i+1) continue;
				int nl=x,nr=x;
				while(nr<r && h[nr+1]>=i+1) nr++;
				x=nr;
				knap2(c,ptr,nl,nr);
			}
			//cal dp[...][2]
			for(int nx=len; nx>=0 ;nx--){
				ll cmg=p2[len-nx]-1;
				dp[c][l][nx][2]=(dp[c][l][nx][2]+dp2[nx]*cmg)%mod;
				for(int px=nx+1; px<=len ;px++){
					ll mg=p2[len-px]*C[px][px-nx]%mod;
					dp[c][l][nx][2]=(dp[c][l][nx][2]+dp2[px]*mg)%mod;
				}
			}/*
			for(int  k=0; k<=len ;k++){
				cout << dp[c][l][k][0] << ' ';
			}
			cout << endl;
			for(int  k=0; k<=len ;k++){
				cout << dp[c][l][k][1] << ' ';
			}
			cout << endl;
			for(int  k=0; k<=len ;k++){
				cout << dp[c][l][k][2] << ' ';
			}
			cout << endl;*/
		}
	}
	cout << (dp[1][1][0][0]+dp[1][1][0][2])%mod << '\n';
}

Measured memory_bytes: 12512
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

struct TCoordinate
{
	double x;
	double y;
};

TCoordinate GetCenterPoint(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return {x, y};
}

double GetRadius(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TCoordinate P1, P2, P3;
		cin >> P1.x >> P1.y >> P2.x >> P2.y >> P3.x >> P3.y;
		TCoordinate CenterPoint = GetCenterPoint(P1, P2, P3);
		double Radius = GetRadius(P1, P2, P3);
		cout << fixed << setprecision(3) << CenterPoint.x << ' ' << CenterPoint.y << ' ' << Radius << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso
  #ifndef ONLINE_JUDGE
  //ffe
  #endif
  int a[10010];
 ll n,k; cin >> n >> k;
 for(int i=0;i<n;i++) {
  cin >> a[i];
 }

 sort(a,a+n);

 int sum=0;
 for(int i=0;i<k;i++) {
  sum +=a[i];
 }

 cout << sum << endl;
}

Measured memory_bytes: 3668
<?php

fscanf(STDIN, "%d", $in_n);
$in_a = trim(fgets(STDIN));
$arr_a = explode(" ", $in_a);
rsort($arr_a);
//var_dump($arr_a);
if($arr_a[$in_n - 1] == 0){
    $ans = 0;
}else{
    $ans = 1;
    foreach ($arr_a as $value){
        $ans *= (int)$value;
        if($ans > pow(10 , 18)){
            $ans = -1;
            break;
        }
    }
}

echo "$ans\n";


Measured memory_bytes: 25720
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;

    int ans = N*N*N;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  string s;
  cin>>s;

  if(s<="2019/04/30"){
    cout<<"Heisei"<<endl;
  }else{
    cout<<"TBD"<<endl;
  }


}

Measured memory_bytes: 256
import itertools
N=int(input())
ptuple=tuple(map(int,input().split()))
qtuple=tuple(map(int,input().split()))
permlist=list(itertools.permutations(range(1,N+1)))

pindex=0
qindex=0
for i,perm in enumerate(permlist):
  if ptuple==perm:
    pindex=i
  if qtuple==perm:
    qindex=i
    
print(abs(pindex-qindex))


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

int main()
{
  int t, n, k, x[100000], A[100000-1];
  cin >> t;
  for(int i=0;i<t;i++)
    {
      cin >> n >> k;
      for(int i=0;i<n;i++)
	cin >> x[i];
      for(int i=0;i<n-1;i++)
	A[i] = x[i+1]-x[i];
      sort(A, A+n-1);
      int sum=0;
      for(int i=0;i<n-k;i++)
	sum += A[i];
      cout << sum << endl;
    }
}


Measured memory_bytes: 3872
class P
  def initialize(str)
    tmp = str.split(" ")
    @name = tmp[0]
    @time = tmp[1].to_i
  end

  def decrease_time(value)
    @time -= value
  end

  attr_reader :name, :time
end

n, q = gets.split(" ").map(&:to_i)
ps = (1..n).map { P.new gets }
elapsed = 0
loop do
  p = ps.shift
  p.decrease_time(q)
  if p.time <= 0
    elapsed += q + p.time
    puts "#{p.name} #{elapsed}"
  else
    elapsed += q
    ps.push p
  end
  break if ps.size == 0
end

Measured memory_bytes: 14676