akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter outWriter = new BufferedWriter(new OutputStreamWriter(System.out));
		String finalOutput = "";
		String line;
		int count = 0;
		int sum = 0;
		line = inReader.readLine();
		char[] tmp = line.toCharArray();
		
		finalOutput += tmp[0];
		finalOutput += tmp[1];

		finalOutput += tmp[2];
		finalOutput += tmp[3];

		finalOutput += " ";
		for(int i = 4; i < tmp.length; i ++)
			finalOutput += tmp[i];
		System.out.println(finalOutput);
}
}

Measured memory_bytes: 8148
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n];
  int mi = 2e9;
  long long ans = 0, neg = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mi = min(mi, abs(arr[i]));
    ans += abs(arr[i]);
    neg += (arr[i] < 0);
  }
  if (neg & 1) {
    ans -= 2 * mi;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p )
{
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v )
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu ()
{
    cerr << endl;
}

template <typename T>
void faltu( T a[], int n )
{
    for(int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

void f()
{

    int c,t,N,T,mn=INT_MAX;
    cin>>N>>T;
    pii p[N];
    for(int i=0; i<N; i++)
    {
        cin>>c>>t;
        p[i].F=t;
        p[i].S=c;
    }
    sort(p,p+N);
    for(int i=0; i<N; i++)
    {
        if(p[i].F<=T)
        {
            mn=min(mn,p[i].S);
        }
    }
    if(mn==INT_MAX)
        cout<<"TLE\n";
    else
        cout<<mn<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3636
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
def main():
    N = int(input())
    ans = 10e+12 
    max_sq = int(math.sqrt(N)+1)
    for i in range(1, max_sq):
        if N % i == 0:
            j = N // i
            ans = min(ans, i+j-2)
    print(ans)
main()



Measured memory_bytes: 70124
n,p = map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

l = factorization(p)
ans = 1
for i in l:
    if i[1] >= n:
        ans *= i[0]**(i[1]//n)
print(ans)




Measured memory_bytes: 63108
//Pranet Verma
#include <bits/stdc++.h>
using namespace std;
int a[101001];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	int state = 0;
	int ans = 1;
	for (int i = 1; i < n; ++i) {
		if (a[i] == a[i - 1]) {
			continue;
		}
		else if (a[i] > a[i - 1]) {
			if (state == 1) {
				
			}
			else if (state == 0) {
				state = 1;
			}
			else {
				++ans;
				state = 0;
			}
		}
		else {
			if (state == -1) {

			}
			else if (state == 0) {
				state = -1;
			}
			else {
				++ans;
				state = 0;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());

            var maxV = 1;
            for(var i = 2; i * i <= x; i++){
                var y = i * i;
                while(y <= x){
                    maxV = Math.Max(maxV, y);
                    y *= i;
                }
            }

            Console.WriteLine(maxV);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==7&&b==5&&c==5||b==7&&a==5&&c==5||c==7&&a==5&&b==5)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int w,h,x,y,r,chec=1;
    cin>>w>>h>>x>>y>>r;
    if(x<r || y<r || x>(w-r) || y>(h-r))
        chec=0;
    if(chec==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

int bound(ll i, ll N, ll K, const vector<vector<ll>> db) {
    int ok = -1, ng = 60;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (i + db[mid][i%N] <= N * K) ok = mid;
        else ng = mid;
    }
    return ok;
}

void solve() {
    ll N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i=0; i<N; ++i) cin >> a[i];

    vector<vector<ll>> db(60, vector<ll>(N));
    map<int, pair<int, int>> mp;
    for (int i=0; i<N; ++i) {
        if (mp.count(a[i])) {
            auto &p = mp[a[i]];
            db[0][p.first] = i - p.first + 1;
            p.first = i;
        } else {
            mp[a[i]] = make_pair(i, i);
        }
    }
    for (auto p : mp) db[0][p.second.first] = N + p.second.second - p.second.first + 1;
    for (int i=1; i<60; ++i) {
        for (int j=0; j<N; ++j) {
            if (db[i-1][j] == LINF) db[i][j] = LINF;
            else db[i][j] = min(LINF, db[i-1][j] + db[i-1][(j+db[i-1][j])%N]);
        }
    }

    ll cur = 0;
    for (int i=59; i>=0; --i) if (cur + db[i][cur%N] <= N * K) cur += db[i][cur%N];
    vector<int> res;
    while (cur < N * K) {
        if (cur + db[0][cur%N] <= N * K) {
            cur += db[0][cur%N];
        } else {
            res.push_back(a[cur%N]);
            ++cur;
        }
    }
    for (int i=0; i<(int)res.size(); ++i) {
        cout << res[i];
        if (i == (int)res.size()-1) cout << '\n';
        else cout << ' ';
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 112164
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	double h, max=0, min=100000;

	while(scanf("%lf", &h) != EOF){
		if(max < h)
			max = h;
		if(min > h)
			min = h;
	}
	printf("%.1f\n", max - min);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    stack<int> s;
    string t;
    getline(cin,t);
    string k;
    for(char c:t){
        if(c==' '){
            if(!k.empty()){
                s.push(stoi(k));
            }
            k="";continue;
        }
        if(c=='+'){
            int a=s.top();s.pop();
            int b=s.top();s.pop();
            s.push(a+b);
        }
        else if(c=='-'){
            int a=s.top();s.pop();
            int b=s.top();s.pop();
            s.push(b-a);
        }
        else if(c=='*'){
            int a=s.top();s.pop();
            int b=s.top();s.pop();
            s.push(a*b);
        }
        else{
            k+=c;
        }
    }
    cout << s.top() << endl;
}



Measured memory_bytes: 3192
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
class Radix {
private:
    const char* s;
    int a[128];
public:
    Radix(const char* s = "0123456789ABCDEF") : s(s) {
        int i;
        for(i = 0; s[i]; ++i)
            a[(int)s[i]] = i;
    }
    std::string to(long long p, int q) {
        int i;
        if(!p)
            return "0";
        char t[64] = { };
        for(i = 62; p; --i) {
            t[i] = s[p % q];
            p /= q;
        }
        return std::string(t + i + 1);
    }
    std::string to(const std::string& t, int p, int q) {
        return to(to(t, p), q);
    }
    long long to(const std::string& t, int p) {
        int i;
        long long sm = a[(int)t[0]];
        for(i = 1; i < (int)t.length(); ++i)
            sm = sm * p + a[(int)t[i]];
        return sm;
    }
};
signed main(){
    int n;cin>>n;
    Radix r;
    int i=0;
    int cnt=0;
    while(1){
        i++;
        string s=r.to(i,4);
        int ans[4]={};
        rep(i,0,4)ans[i]=false;
        int num=0;
        rep(i,0,s.size()){
            ans[s[i]-'0']=true;
            if(s[i]=='1')num=num*10+3;
            if(s[i]=='2')num=num*10+5;
            if(s[i]=='3')num=num*10+7;
        }
        if(ans[0])continue;
        if(num>n)break;
        if(ans[1]==true&&ans[2]==true&&ans[3]==true){
            cnt++;
        }
    }
    cout<<cnt<<endl;return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
import bisect
for i in range(N-2):
    
    for j in range(i+1,N-1):
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L,a+b)
        l = bisect.bisect_left(L,b-a)
        ans += k-max(j+1,l)
print(ans)


Measured memory_bytes: 46172
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
//abc165b

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll ans=0;
    ll a=100;
    while(true){
        a=(a*1.01);
        ans++;
        if(a>=x){
            break;
        }
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{
	public static int[] copy(int[] a){
		int[] result = new int[a.length];
		for(int i = 0; i < a.length; i++){
			result[i] = a[i];
		}
		return result;
	}
	 
	public static int[] arrange(int[] a, int start, int end){
		int[] result = new int[a.length+start-end];
		for(int i = 0; i < start; i++){
			result[i] = a[i];
		}
		for(int i = start; i < result.length; i++){
			result[i] = a[i+end-start];
		}
		return result;
	}
		
	public static int[] vanish(int[] a){
		int key = a[0];
		int count = 1;
		for(int i = 1; i < a.length; i++){
			if( a[i] == key ){
				count++;
				if( i == a.length-1 && count >= 4){
					a = arrange(a, i+1-count, i+1);
				}
			} else {
				key = a[i];
				if( count >= 4 ){
					a = arrange(a, i-count, i);
					i = 0;
					key = a[0];
				}
				count = 1;
			}
		}
		return a;
	}
	
	public static int solve(int[] a){
		int[] x = copy(a);
		x[0] = x[1];
		x = vanish(x);
		int min = x.length;
		for(int i = 1; i < a.length-1; i++){		
			if( a[i] != a[i-1] || a[i] != a[i+1] ){
				if( a[i] != a[i-1] ){
					int[] y = copy(a);
					y[i] = y[i-1];
					y = vanish(y);
					if( y.length < min ){
						min = y.length;
					}
				} 
				if( a[i] != a[i+1] ){
					int[] y = copy(a);
					y[i] = y[i+1];
					y = vanish(y);
					if( y.length < min ){
						min = y.length;
					}
				}
			}
		}
		x = copy(a);
		x[x.length-2] = x[x.length-1];
		x = vanish(x);
		if( x.length < min ){
			min = x.length;
		}
		
		return min;
	}

	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		int[] M = new int[100];
		int N = stdIn.nextInt();
		int index = 0;
		while( N != 0 ){
			int[] c = new int[N];
			for(int i = 0; i < N; i++){
				c[i] = stdIn.nextInt();
			}
			M[index] = solve(c);
			index++;
			N = stdIn.nextInt();
		}
		
		for(int i = 0; i < index; i++){
			System.out.println(M[i]);
		}
	}
}

Measured memory_bytes: 16000
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::*;

#[allow(unused_macros)]
macro_rules! echo {
    ($ x : expr ) => {
        println!("{}", $x);
    };
}

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        S: Chars,
    }
    let mut ans =0;
    let mut tmp = 0;
    for i in 0..3 {
        if S[i] == 'R' {
            tmp += 1;
        } else {
            ans = if tmp > ans { tmp } else { ans };
            tmp = 0;
        }
    }
    ans = if tmp > ans { tmp } else { ans };
    echo!(ans);
}


Measured memory_bytes: 2200
N,Q = gets.split.map(&:to_i)
bk = (N-2)**2
bb = [0]*(N-1),[0]*(N-1)
ii = [0,0]
Q.times{
	b,x = gets.split.map(&:to_i).then{|b,x| [b-1,N-x] }
	y = x < ii[b] ? bb[b][x] : ii[b-1]
	bk -= N-2-y
	if ii[b] < x
		bb[b].fill(y,ii[b]+1..x)
		ii[b] = x
	end
}
p bk


Measured memory_bytes: 17392
def expect(n):
        return (n+1)/2

nk = input().split()
N = int(nk[0])
K = int(nk[1])
p = input().split()

tmp = 0
for i in range (K):
    tmp += expect(int(p[i]))

tmpMax = tmp

for i in range(N - K):
    tmp -= expect(int(p[i]))
    tmp += expect(int(p[i+K]))
    tmpMax = max(tmpMax, tmp)

print(tmpMax)



Measured memory_bytes: 24804
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans;
    if (a >= 13) ans = b;
    else if (a <= 5) ans = 0;
    else ans = b / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define ld long double
const int Nmax = 1000 + 5;
int a[Nmax], n;

ld sum, x;

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        sum += 1.0 / a[i];
    }

    cout << 1.0 / sum;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d",&n);
	int s[13],h[13],clo[13],dia[13];
    for(i=0;i<13;i++){
        s[i] = 0;
        h[i] = 0;
        clo[i] = 0;
        dia[i] = 0;
    }
    for(i=0;i<n;i++){
        char v;
        int x;
        char dummy;
        scanf("%c",&dummy);
        scanf("%c %d",&v,&x);
        if(v == 'S'){
            s[x-1] = 1;
        }else if(v == 'H'){
            h[x-1] = 1;
        }else if(v == 'C'){
            clo[x-1] = 1;
        }else if(v == 'D'){
            dia[x-1] = 1;
        }
    }
    for(i=0;i<13;i++){
        if(s[i] == 0){
            printf("S %d\n",i+1);
        }
    }    
    for(i=0;i<13;i++){
        if(h[i] == 0){
            printf("H %d\n",i+1);
        }
    }
    for(i=0;i<13;i++){
        if(clo[i] == 0){
            printf("C %d\n",i+1);
        }
    }
    for(i=0;i<13;i++){
    	if(dia[i] == 0){
    		printf("D %d\n",i+1);
    	}
    }
    return 0;
}


Measured memory_bytes: 2100
n = int(input())
sum = 0
if n//10!=0:
  sum+=9
  if n//1000!=0:
    sum+=900
    if n//100000!=0:
      sum+=90000
    elif n//10000!=0:
      sum+=n-9999
  elif n//100!=0:
    sum+=n-99
else:
  sum+=n
print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int left[] = {1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,1};

    for(;;){
        string s;
        cin >> s;
        if(s == "#")
            return 0;

        int n = s.size();
        int ret = 0;
        for(int i=1; i<n; ++i){
            if(left[s[i]-'a'] != left[s[i-1]-'a'])
                ++ ret;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
ll x,f[2005];
int main()
{
    rep(i,-1000,1000)f[i+1000]=(i<=0)?1ll*i*i*i*i*i:-f[1000-i];
    cin>>x;
    rep(i,1,1000)rep(j,-1000,1000){if(f[i+1000]-f[j+1000]==x){pf2(i,j);return 0;}}
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e18;
	const ll MOD = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	
	signed main(){
		IOS;
		ll q;
		cin >> q;
		REP(i, q){
			string s, t;
			cin >> s >> t;
			int n = s.size();
			int m = t.size();
			vec<vec<ll>> dp(n + 1,vec<ll>(m + 1,0));
			REP(i, n)REP(j, m){
				if(s[i] == t[j])dp[i + 1][j + 1] = dp[i][j] + 1;
				else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			}
			dump(dp[n][m]);
		}
	}


Measured memory_bytes: 10832
def resolve():
    N = int(input())
    ps = list(map(int, input().split(" ")))
    cnt = 0
    for i in range(1, N-1):
        if (ps[i-1] < ps[i] and ps[i] < ps[i+1]) or (ps[i-1] > ps[i] and ps[i] > ps[i+1]):
            cnt += 1
    print(cnt)
    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38384
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

S = input()
ls = len(S)
S += "      "
dp = [False for i in range(len(S)+10)]
dp[0]=True
for i in range(len(S)+1):
    if S[i:i+5]=='dream' or S[i:i+5]=='erase':
        dp[i+5]=dp[i]
    if S[i:i+7]=='dreamer':
        dp[i+7]=dp[i]
    if S[i:i+6]=='eraser' :
        dp[i+6]=dp[i]
print('YES' if dp[ls]==True else 'NO')


Measured memory_bytes: 66412
pn n xs ys = (**(1/(fromInteger n))) . fromInteger . foldr ((+) . (\(x,y) -> (abs (x-y))^n)) 0 $ zip xs ys
p1 xs ys = pn 1 xs ys
p2 xs ys = pn 2 xs ys
p3 xs ys = pn 3 xs ys
pI xs ys = maximum $ zipWith (\x y -> abs (x-y)) xs ys

main = do
  _ <- getLine
  xs <- fmap (map read . words) getLine
  ys <- fmap (map read . words) getLine


  print $ p1 xs ys
  print $ p2 xs ys
  print $ p3 xs ys
  print $ pI xs ys


Measured memory_bytes: 4396
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


bool solve(LL n, vector<LL>& s){
    multiset<LL> cand(s.begin(), s.end());
    multiset<LL> used;
    LL v = *cand.begin();
    used.insert(v);
    cand.erase(v);
    for(LL i = 0; i < n; ++i){
        //cerr << "i=" << i << endl;
        vector<LL> tmp(used.begin(), used.end());
        for(LL v: tmp){
            auto it = cand.lower_bound(v+1);
            if(it == cand.end()) return false;
            //cerr << v << ", " << *it << endl;
            used.insert(*it);
            cand.erase(it);
        }
    }
    return true;
}

int main(){
    LL n;
    cin >> n;
    vector<LL> s(1LL<<n);
    for(LL i = 0; i < (1LL<<n); ++i){
        cin >> s[i];
        s[i] *= -1;
    }
    if(solve(n, s)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 15732
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=15;
char s[N];
int main(){
	scanf("%s",s+1);
	fp(i,1,4)putchar(s[i]);
	putchar(' ');
	fp(i,5,12)putchar(s[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
from collections import deque

N,M = map(int, input().split())

AB = [list(map(int, input().split())) for _ in range(M)]

G = {i:[] for i in range(N+1)}
for a,b in AB:
    G[a].append(b)
    G[b].append(a)
    
parent = [0]*(N+1)
parent[0]==-1
parent[1]==-1
q = deque()
q.append(1)
while len(q)>0:
    room = q.popleft()
    child = G[room]
    
    for i in child:
        if parent[i] == 0:
            parent[i] = room
            q.append(i)
    
    
if min(parent[2:])==0:
    print('No')
else:
    print('Yes')
    for i in parent[2:]:
        print(i)

Measured memory_bytes: 66072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	int n, m;
	ll int cost = 0LL;
	pair<int, int> tmp;
	priority_queue<pair<int, int>> drink;
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> tmp.first >> tmp.second;
		tmp.first *= -1;
		drink.push(tmp);
	}

	
	while (1) {
		if (m <= drink.top().second) {
			cost -= (ll int)drink.top().first * (ll int)m;
			break;
		}
		m -= drink.top().second;
		cost -= (ll int)drink.top().first * (ll int)drink.top().second;
		drink.pop();
	}

	printf("%lld", cost);
	
	return 0;
}

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

static const int INFTY = 2000000000;

int main() {
	int n, last;
	cin >> n;
	int p[n + 1];
	int m[n + 1][n + 1];
	for (int i = 0; i < n; i++) {
		cin >> p[i] >> last;
	}
	p[n] = last;

	for (int i = 1; i <= n; i++) {
			m[i][i] = 0;
	}

	for (int l = 2; l <= n; l++) { //????±???¨?????????????????°
		for (int i = 1; i <= n - l + 1; i++) { //????±???????????????????
			int j = i + l - 1;
			m[i][j] = INFTY;
			for (int k = i; k < j; k++) { //???
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}

	cout << m[1][n] << endl;
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

void func(void);
void back(int,int,char,int);

char tizu[102][102];
int flg[102][102];
int n,m;
int f;

int main(void)
{
	scanf("%d %d",&n,&m);
	while(!(n==0 && m==0))	{
		func();
		scanf("%d %d",&n,&m);
	}
	return 0;
}
void func(void)
{
	int i,j,cnt;
	char buf[101];
	for(j=0;j<n+2;j++)	{
		tizu[0][j]='.';
		tizu[m+1][j]='.';
	}
	for(i=1;i<m+1;i++)	{
		scanf("%s",buf);
		tizu[i][0]='.';
		tizu[i][n+1]='.';
		for(j=1;j<n+1;j++)	{
			tizu[i][j]=buf[j-1];
		}
	}
	for(i=0;i<m+2;i++)	{
		for(j=0;j<n+2;j++)	{
			flg[i][j]=-1;
		}
	}
	cnt=0;	f=0;
	while(1)	{
		if(cnt==0)	{
			flg[0][0]=cnt;
			back(0,0,'.',0);
			if(f==1)	break;
		}
		else {
			for(i=0;i<m+2;i++)	{
				for(j=0;j<n+2;j++)	{
					if(flg[i][j]==cnt-1 && tizu[i][j]=='#')	{
						back(i,j,'.',cnt);
					}
				}
			}
			if(f==1)	break;
		}
		for(i=0;i<m+2;i++)	{
			for(j=0;j<n+2;j++)	{
				if(flg[i][j]==cnt && tizu[i][j]=='.')	{
					back(i,j,'#',cnt);
				}
			}
		}
		if(f==1)	{
			cnt++;
			break;		
		}
		cnt++;
	}
	printf("%d\n",cnt);
}
void back(int y,int x,char c,int cnt)
{
	int i,j,k;
	int xx,yy;
	int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
	
	for(k=0;k<4;k++)	{
		xx=x+dx[k];	yy=y+dy[k];
		if(yy>=0 && yy<m+2 && xx>=0 && xx<n+2 && flg[yy][xx]==-1 )	{
			if(tizu[yy][xx]=='&')	{
				flg[yy][xx]=cnt;
				f=1;
			}
			if(tizu[yy][xx]==c)	{
				flg[yy][xx]=cnt;
				back(yy,xx,c,cnt);
			}
		}
	}
}


Measured memory_bytes: 1108
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n,a,b;
char s[100005];
int main(void){
	scanf("%d%d%d",&n,&a,&b);
	int sa=0,sb=0;
	
	scanf("%s",s);
	rep(i,n){
		bool ok=false;
		if(s[i]=='a'){
			if(sa+sb<a+b){
				sa++; ok=true;
			}
		}
		else if(s[i]=='b'){
			if(sa+sb<a+b && sb<b){
				sb++; ok=true;
			}
		}
		printf("%s\n",ok?"Yes":"No");
	}
			
	return 0;
}






Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  string U=S+T.at(S.size());
    if(T==U){
     cout << "Yes" <<endl; 
    }
  else{
   cout << "No" <<endl;
  }
}

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

int main() {
    ll k,n,a[200010],big=0;
    cin >> k >> n;
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n-1;i++){
        ll hoge = a[i+1] - a[i];
        big = max(hoge,big);
    }
    ll hoge = k - a[n-1] + a[0];

    big = max(hoge,big);

    cout << k - big << endl;
}

Measured memory_bytes: 1792
import sys
  
def dfs(i, t, l, a, b):
   t += 1
   a[i] = t
   for j in l[i]:
      if not a[j-1]:
         t = dfs(j-1, t, l, a, b)
   t += 1
   b[i] = t
   return t
  
  
n = input()
l=[]
for i in range(n):
   l.append([int(s) for s in sys.stdin.readline().split()[2:]])
a = [0] * n
b = [0] * n
t = 0
for i in xrange(n):
   if not a[i]:
      t = dfs(i, t, l, a, b)
  
for i in xrange(n):
   print i+1, a[i], b[i] 

Measured memory_bytes: 6496
#pragma warning(disable:4996)
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

struct Info {
	int x, y, h;
};
bool operator > (const Info& l, const Info& r) {
	return l.h > r.h;
}

int main(void) {
	int N;
	cin >> N;
	vec<Info> info(N);
	REP(i, N) {
		int x, y, h;
		cin >> x >> y >> h;
		info[i] = { x, y, h };
	}
	sort(ALL(info), greater<Info>());
	for (int Cx = 0; Cx <= 100; ++Cx) {
		for (int Cy = 0; Cy <= 100; ++Cy) {
			int H0 = abs(info[0].x - Cx) + abs(info[0].y - Cy) + info[0].h;
			bool good = true;
			for (int i = 1; i < N; ++i) {
				int d = abs(info[i].x - Cx) + abs(info[i].y - Cy);
				if (info[i].h > 0) {
					int H = d + info[i].h;
					if (H0 != H) {
						good = false;
						break;
					}
				}
				else {
					if (H0 > d) {
						good = false;
						break;
					}
				}
			}
			if (good) {
				cout << Cx << " " << Cy << " " << H0 << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if (b*c >=a){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

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

class P
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int res = 0;
        for (int i = 0; i <= a; i++)
        {
            for (int j = 0; j <= b; j++)
            {
                for (int k = 0 ; k <= c; k++)
                {
                    if (i * 500 + j * 100 + k * 50 == x) res++;
                }
            }
        }
        Console.WriteLine(res);
    }
}

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

int main(){
    double l;
    cin >> l;
    double ans = pow(l/3.0, 3.0);
     cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll a[200001],s,ans;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n,l=1;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		while((s^a[i])!=s+a[i]) s^=a[l++];
		ans+=i-l+1;
		s^=a[i];
	}
	cout<<ans;
}

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

int main()
{
  char b;
  scanf("%c",&b);
  if(b=='A')
    printf("T\n");
  else if(b=='T')
    printf("A\n");
  else if(b=='C')
    printf("G\n");
  else 
    printf("C\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
	char c;
	ll w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	ll ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
int n,k;
int f[5000005];
int a[5000005];
int sum[5000005];
void insert(int k,int l,int r,int w,int v)
{
//	cout<<k<<endl;
	sum[k]=max(sum[k],v);
	if(l==r)
	{
		return ;
	}
	int mid=l+r>>1;
	if(w<=mid)
	{
		insert(k<<1,l,mid,w,v);
	}
	else insert(k<<1|1,mid+1,r,w,v);
}
int ask(int k,int l,int r,int x,int y)
{
	if(r<x||y<l)return 0;
	if(x<=l&&r<=y)
	{
		return sum[k];
	}
	int mid=l+r>>1;
	int ans=0;
	ans=max(ask(k<<1,l,mid,x,y),ask(k<<1|1,mid+1,r,x,y));
	return ans;
}
int main(){
	n=read();
	k=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		f[i]=ask(1,0,600000,max(0,a[i]-k),a[i]+k)+1;
		insert(1,0,600000,a[i],f[i]);
		ans=max(ans,f[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10084
#include<bits/stdc++.h>
using namespace std;
int n,m,x;
vector<int> c;
vector<vector<int> > a;
int ans = 1e9;
void solve(vector<int> &skills,int i, int cost){

	if(i==n){
		int pos = 1;
		for(int j =0;j<m;j++){
			if(skills[j]<x)
				pos = 0;
		}
		if(pos){
			ans = min(ans,cost);
		}
		return;
	}
	// cout << i  << " " << cost << endl;
	for(int j =0;j<m;j++){
		skills[j]+=a[i][j];
		// cout << skills[j] << " ";
	// }cout << endl;
	}
	solve(skills,i+1,cost+c[i]);
	
	for(int j =0;j<m;j++){
		skills[j]-=a[i][j];
		// cout << skills[j] << " ";

	// }cout << endl;
	}
	solve(skills,i+1,cost);
}


int main(){

	cin >> n >> m >> x;
	c=  vector<int> (n);
	a = vector<vector<int> > (n);
	for(int i =0;i<n;i++){
		cin >> c[i];
		for(int j =0;j<m;j++){
			int y;
			cin >> y;
			a[i].push_back(y);
		}
	}
	vector<int> skills(m,0);
	solve(skills, 0 , 0);

	if(ans == 1e9){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
char a[105],b[210];
int k,ans,tag;
signed main(){
	scanf("%s",a+1);
	k=read();
	int len=strlen(a+1);
	int res=0;
	for(int i=1;i<len;i++){
		if(a[i]!=a[i+1]) tag=1;
		if(a[i]==a[i+1]) res++;
		if(a[i]==a[i+1]&&a[i]==a[i+2]) i++;
	}
	if(tag==0) {
		cout<<(len*k)/2;
		return 0;
	}
	for(int i=1;i<=len*2;i++) if(i<=len)b[i]=a[i];else b[i]=a[i-len];
	int ress=0;
	for(int i=1;i<len*2;i++){
		if(b[i]==b[i+1]) ress++;
		if(b[i]==b[i+1]&&b[i]==b[i+2]) i++;
	}
	if(ress==res*2) ans=k*res;
	else ans=k*res+k-1;
	cout<<ans<<endl;
}
/*
aaaaa
3

7
*/

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) b[a[i]-1]=i+1;
    for(i=0;i<n;i++) printf("%d ",b[i]);
    return 0;
}


Measured memory_bytes: 1536
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.Arrays;
import java.util.Scanner;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
    	int data[];
    	int n,m;
    	void update(int i,int x){
    		i += n - 1;
    		data[i] = x;
    		while(i > 0){
    			i = (i - 1)/2;
    			data[i] = Math.min(data[i*2+1],data[i*2+2]);
    		}
    	}
    	int query(int a,int b,int k,int l,int r){
    		if(r <= a || b <= l)return Integer.MAX_VALUE;
    		if(a <= l && r <= b)return data[k];
    		else{
    			int vl = query(a,b,k*2+1,l,(l+r)/2);
    			int vr = query(a,b,k*2+2,(l+r)/2,r);
    			return Math.min(vl,vr);
    		}
    	}
    	void doIt(){
    		int num = sc.nextInt();
    		m = sc.nextInt();
    		n = 1;
    		while(n < num)n <<= 1;
//    		System.out.println(n);
    		data = new int [n*2 - 1];
    		Arrays.fill(data,Integer.MAX_VALUE);
    		for(int i = 0;i < m;i++){
    			int com = sc.nextInt();
    			int x = sc.nextInt();
    			int y = sc.nextInt();
    			if(com == 0)update(x,y);
    			else System.out.println(query(x,y+1,0,0,n));
    		}
    	}
    }
}

Measured memory_bytes: 103716
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 100000
using namespace std;

int main(){
  int k;  cin >> k;
  cout << ((k/2) * ((k+1)/2)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a_sum, a1, a2, a3, a4;
    int b_sum, b1, b2, b3, b4;

    scanf("%d %d %d %d", &a1, &a2, &a3, &a4);
    scanf("%d %d %d %d", &b1, &b2, &b3, &b4);

    a_sum = a1 + a2 + a3 + a4;
    b_sum = b1 + b2 + b3 + b4;

    printf("%d\n", (a_sum>b_sum)?a_sum:b_sum);
}

Measured memory_bytes: 1020
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int T = sc.nextInt();
			P[] ps = new P[N];
			for (int i = 0; i < N; ++i) {
				ArrayList<Integer> period = new ArrayList<Integer>();
				while (true) {
					int t = sc.nextInt();
					if (t == 0) break;
					period.add(t);
				}
				ps[i] = new P(i, period);
			}
			int ans = 0;
			ArrayDeque<P> wait = new ArrayDeque<P>();
			P charge = null;
			for (int i = 0; i < T; ++i) {
				ans += wait.size();
				for (int j = 0; j < N; ++j) {
					P p = ps[j];
					if (p.stage % 2 == 0) {
						p.spend++;
						if (p.spend == p.period[p.stage]) {
							p.spend = 0;
							p.stage++;
							wait.add(p);
						}
					}
				}
				if (charge != null) {
					charge.spend++;
					if (charge.spend == charge.period[charge.stage]) {
						charge.spend = 0;
						charge.stage++;
						if (charge.stage == charge.period.length) charge.stage = 0;
						charge = null;
					}
				}
				if (charge == null && !wait.isEmpty()) {
					charge = wait.poll();
				}
			}
			System.out.println(ans);
		}
	}

	static class P {
		int id;
		int[] period;
		int stage = 0;
		int spend = 0;

		P(int id, ArrayList<Integer> per) {
			this.id = id;
			this.period = new int[per.size()];
			for (int i = 0; i < per.size(); ++i) {
				this.period[i] = per.get(i);
			}
		}
	}

}

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

int main() {
    string s;
    cin >> s;
    char bef;
    bool ret = false;
    for(int i = 0; i < s.size();i++){
        if (bef == s.at(i)){
            ret = true;
        }
        bef = s.at(i);
    }

    cout << (ret ? "Bad" : "Good") << endl;
}

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

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



Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100
#define INF 5000

#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[MAX][MAX];
int n;

int prim() {
  int u, min, sum;
  int d[MAX], p[MAX], color[MAX];
  int i;

  for (i = 0; i < n; i++) {
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1) {
    min = INF;
    u = -1;
    for (i = 0; i < n; i++) {
      if (min > d[i] && color[i] != BLACK) {
        u = i;
        min = d[i];
      }
    }
    if (u == -1) break;
    color[u] = BLACK;
    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && M[u][i] != INF) {
        if (d[i] > M[u][i]) {
          d[i] = M[u][i];
          p[i] = u;
          color[i] = GRAY;
        }
      }
    }
  }

  sum = 0;
  for (i = 0; i < n; i++) {
    if (p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}

int main() {
  int i, j, input;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &input);
      M[i][j] = (input == -1) ? INF : input;
    }
  }

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

  return 0;
}



Measured memory_bytes: 1996
const MAX_P: usize = 100_000;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();

    if n <= 5 {
        let t = vec![2, 3, 5, 7, 11];
        for i in 0..n {
            print!("{} ", t[i]);
        }
        println!();
        return;
    }

    let mut is_prime = vec![true; MAX_P];
    for p in 3..MAX_P {
        if !is_prime[p] {
            continue;
        }
        for i in 2..(MAX_P / p) {
            is_prime[p * i] = false;
        }
    }

    let mut ans = Vec::new();
    let mut cur = 7;
    loop {
        ans.push(cur);
        if ans.len() == n {
            break;
        }
        cur += 10;
        while !is_prime[cur] {
            cur += 10;
        }
    }

    for &p in &ans {
        print!("{} ", p);
    }
    println!();
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

double p[6], q[6];

inline double sq(double x) {
    return x * x;
}

double getVal(double P) {
    double ans = 0;
    for(int i = 0; i < 6; ++i) {
        if(P * p[i] > (1 - P) * q[i])
            ans += P * p[i];
        else
            ans += (1 - P) * q[i];
    }

    return ans;
}

int main() {

    for(int i = 0; i < 6; ++i) {
        scanf("%lf", &p[i]);
        p[i] /= 100.0;
    }

    for(int i = 0; i < 6; ++i) {
        scanf("%lf", &q[i]);
        q[i] /= 100.0;
    }

    double left = 0, right = 1, mid1, mid2;
    double sol = 1;

    for(int i = 0; i < 100; ++i) {
        mid1 = left + (right - left) / 3;
        mid2 = right - (right - left) / 3;

        double val1 = getVal(mid1), val2 = getVal(mid2);
        sol = min(sol, val1);
        sol = min(sol, val2);

        if(val1 < val2) right = mid2;
        else left = mid1;
    }

    printf("%.20f\n", sol);

    return 0;
}

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

int main() {
	int i,A, B;
	char S[12];
	bool fill = true;

	cin >> A >> B;
	
	for (i = 0; i < A; ++i) {
		cin >> S[i];
		if (S[i] == '-') fill = false;
	}
	cin >> S[A];
	if (S[A] != '-') fill = false;
	++i;
	for (; i < A + B + 1; ++i) {
		cin >> S[i];
		if (S[i] == '-') fill = false;
	}

	if (fill) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
[<EntryPointAttribute>]
let main _ =
    let len = System.Console.ReadLine() |> fun s -> System.Int32.Parse(s)
    let input = System.Console.ReadLine()
    if len % 2 = 0 then
        let at = len / 2 - 1
        if input.[0..at] = input.[at+1..len-1] then
            printfn "Yes"
        else
            printfn "No"
    else
        printfn "No"
    0

Measured memory_bytes: 11484