akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  vector<long long> a(3*N);
  for(long long i=0;i<3*N;i++){cin >> a[i];}
  sort(a.begin(), a.end());
  long long s=0;
  for(long long i=3*N-2;i>=N;i-=2){
    s+=a[i];
  }
  cout << s << endl;
}

Measured memory_bytes: 2560
n=gets.to_i
INF=10010
result=Array.new(INF,0)
for i in 1..n**0.5
    for j in 1..n**0.5
        for k in 1..n**0.5
            v=i**2+j**2+k**2+(i*j)+(j*k)+(i*k)
            if v>n
                break
            end
            result[v-1]+=1
           
        end
    end
    
end

for i in 0..n-1
    p result.shift
end


Measured memory_bytes: 14660
console.log((args=>{
  const [[H,W,D],...tmp] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  const p = Array(H*W+1).fill([]);
  for ( let i = 0; i < H; i++ ) {
    for ( let j = 0; j < W; j++ ) {
      p[tmp[i][j]] = [i,j];
    }
  }
  const s = Array(H*W+1).fill(0);
  for ( let i = 1; i <= D; i++ ) {
    for ( let j = i; j <= H*W-D; j+=D ) {
      s[j+D] = Math.abs( p[j][0] - p[j+D][0] ) + Math.abs( p[j][1] - p[j+D][1] ) + s[j];
    }
  }
  const [Q] = tmp[H];
  let mp = [];
  for ( let i = 0; i < Q; i++ ) {
    const [L,R] = tmp[H+1+i];
    mp.push( s[R] - s[L] );
  }
  return mp.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 82688
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); <-- PUT IN main()/solve()!

using namespace std;


int n;
int ans[405][405]; // state: start,length
int cost[405][405];
class NSlimes {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		f(i,0,n)
		{
			in >> ans[i][0];
			cost[i][0]=0;
		}
		f(j,1,n)
			f(i,0,n-j)
			{
				ans[i][j]=ans[i][0]+ans[i+1][j-1];
				cost[i][j]=cost[i+1][j-1]+ans[i][j];
				f(k,1,j)
				{
					int tempans=ans[i][k]+ans[(i+k+1)][(j-1-k)];
					int tempcost=cost[i][k]+cost[(i+k+1)][(j-1-k)]+tempans;
					if(tempcost<cost[i][j])
					{
						ans[i][j]=tempans;
						cost[i][j]=tempcost;
					}
				}

			}
		out << cost[0][n-1] << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	NSlimes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(void){
    int n; cin >> n;
    vector<int>num(n);
    for(int i=0;i<n;i++) cin >> num[i];
    sort(num.begin(),num.end());
    num.push_back(0);
    int cnt=0,ans=0;
    for(int i=0;i<n;i++){
        if(num[i]==num[i+1]) cnt++;
        else if(++cnt%2!=0) ans++,cnt=0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    H, W, K = map(int, input().split())
    S = list(list(input()) for _ in range(H))
    ans = [[0] * W for _ in range(H)]

    count = 1
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                ans[i][j] = count
                count += 1

    for i in range(H):
        for j in range(1, W):
            if ans[i][j] == 0 and ans[i][j - 1]:
                ans[i][j] = ans[i][j - 1]

    for i in range(H):
        for j in range(W - 1)[::-1]:
            if ans[i][j] == 0 and ans[i][j + 1]:
                ans[i][j] = ans[i][j + 1]

    for i in range(1, H):
        for j in range(W):
            if ans[i][j] == 0 and ans[i - 1][j]:
                ans[i][j] = ans[i - 1][j]

    for i in range(H - 1)[::-1]:
        for j in range(W):
            if ans[i][j] == 0 and ans[i + 1][j]:
                ans[i][j] = ans[i + 1][j]

    for a in ans:
        print(' '.join(map(str, a)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13208
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin >> x;
	cout << x * x * x << endl;
	return 0;
}


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

int main(){
	int A,B;
	cin>>A>>B;

	if (A<6){
		cout<<0<<endl;
	}
	else if(A<13){
		cout<<B/2<<endl;
	}
	else{
		cout<<B<<endl;
	}
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
ans = ''
S = []
for _ in range(n):
    S.append(input())
S_sorted = sorted(list(set(S[0])))

for c in S_sorted:
    count = min(S[i].count(c) for i in range(n))
    ans += c * count

print(ans)



Measured memory_bytes: 3316
N = int(input())
dish = [[0 for _ in range(3)] for _ in range(N)]
Takahashi = []
Aoki = []
for i in range(N):
    dish[i][0],dish[i][1] = [int(x) for x in input().split()]
    dish[i][2] = dish[i][0]+dish[i][1]
dish.sort(key=lambda x:(x[2],x[0],x[1]),reverse=True)
for i in range(N):
    if(i%2==0):
        Takahashi.append(dish[i][0])
    else:
        Aoki.append(dish[i][1])

print(sum(Takahashi)-sum(Aoki))

Measured memory_bytes: 33120
// AOJ ALDS1_1_C Prime Numbers
// 2018.4.27 bal4u

#include <stdio.h>
#include <math.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int main()
{
	int N, i, a, r, ans;

	N = in();
	ans = 0;
	while (N--) {
		a = in();
		if (a == 2) ans++;
		else if (a&1) {
			r = (int)sqrt(a);
			for (i = 3; ; i+=2) {
				if (i > r) { ans++; break; }
				if (a%i == 0) break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
/*
#include<algolithm>
#include<array>
#include<vector>
*/
using namespace std;

typedef double Real;
constexpr Real EPS = 1e-8;

int sign(Real d) {
	if (d>EPS) { return 1; }
	if (d<-EPS) { return -1; }
	return 0;
}

struct Point {
	Real x,y;

	Point(Real x_=0, Real y_=0): x(x_), y(y_) {}

	Point operator+(const Point &p) const {
		return Point(x+p.x,y+p.y);
	}
	Point operator-(const Point &p) const {
		return Point(x-p.x,y-p.y);
	}
	Point operator*(Real s) const {
		return Point(x*s,y*s);
	}
	Point operator/(Real s) const {
		return Point(x/s,y/s);
	}
	Point operator<(const Point &p) const {
		return sign(x - p.x) == -1 || (sign(x - p.x)==0 && sign(y - p.y)==-1);
	}
	Point operator==(const Point &p) const { return sign(x-p.x) == 0 && sign(y - p.y)==0; }

};

istream &operator>>(istream &is, Point &p) {
	return is >> p.x >> p.y;
}
ostream &operator<<(ostream &os, const Point &p) {
	return os << '(' << p.x << ", " << p.y << ')';
}

struct Line : public array<Point, 2> { //??????
	Line(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};

struct Segment : public array<Point, 2> { //??´???
	Segment(const Point &a, const Point &b) { at(0) = a; at(1) = b; }
};

struct Circle {
	Point c;
	Real r;
	Circle(const Point &c_, Real r_): c(c_), r(r_) {}
};

typedef vector<Point> Polygon;




//--- solve ---
Point rotate90(const Point &p) { //???????¨???????
	return Point(-p.y,p.x);
}

Point rotate(const Point &p, Real theta) {
	const Real s = sin(theta), c = cos(theta);
	return Point(c*p.x - s*p.y, s*p.x + c*p.y);
}

Real angle(const Point &p) {
	return atan2(p.y, p.x);
}

Real norm(const Point &p) {
	return p.x * p.x + p.y * p.y;
}

Real abs(const Point &p) {
	return sqrt(norm(p));
}

Real dot(const Point &a, const Point &b) { //??????
	return a.x * b.x + a.y * b.y;
}

Real cross(const Point &a, const Point &b) {
	return a.x * b.y + a.y * b.x;
}

Point project(const Line &l, const Point &p) { //?°???±
	const Point a = p - l[0];
	const Point b = l[1] - l[0];
	return l[0] + b * (dot(a,b) / norm(b));
}

bool intersect(const Line &a, const Line &b) { //
	return sign(cross(a[1]-a[0], b[1]-b[0])) != 0
		|| sign(cross(a[1]-a[0], b[1]-a[0])) == 0;
}

int main() {
	Point p1,p2;
	int q;
	int x,y;

	cout.setf(ios::fixed);
	cout.precision(10);
	cin >> p1.x >> p1.y >> p2.x >> p2.y;
	Line l(p1,p2);
	cin >> q;
	for(int i=0; i < q; i++) {
		Point p;
		cin >> p.x >> p.y;
		Point ans_p = project(l,p);
		cout << ans_p.x << " " << ans_p.y << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n,k;
  cin>>n>>k;
  int x[n];
  for(int i=0;i<n;i++)
    cin>>x[i];
    ll ans=0;
  for(int i=0;i<n;i++)
  {
      int disA=2*x[i];
      int disB=abs(x[i]-k)*2;
      ans+=ll(disA<disB)?disA:disB;
  }
  cout<<ans;

   return 0;
}



Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let x = sc.read();
    if x == 1 {
        println!("{}", 1);
        return ;
    }
    let mut result = 0;
    for b in 2..1001 {
        for _ in 0..10 {
            let mut tmp = b * b;
            if tmp > x {
                continue;
            }
            while tmp * b <= x {
                tmp *= b;
            }
            if tmp <= x {
                result = std::cmp::max(result, tmp);
            }
        }
    }
    println!("{}", result);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題167
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            T = T.Remove(T.Length - 1, 1);

            //Console.WriteLine(T);

            if (S == T)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }


    }
}


Measured memory_bytes: 25740
#include <bits/stdc++.h>
using namespace std;
int main(){
    long double ans, rad, pie=3.14159265359, h, m, a, b;
    cin >> a >> b >> h >> m;
    rad=abs((30*h+0.5*m)-6*m);
    rad/=180;
    ans=(a*a)+(b*b)-(2*a*b*(cos(rad*pie)));
    ans=sqrt(ans);
    cout << fixed << setprecision(15) << ans <<endl;
    return 0;
}

Measured memory_bytes: 4112
/*-- ILSH  --*/

// Multipoll evaluation + Divide and Conquer
// Time ( Iterative ) < Time ( Recursive )

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

typedef long long ll;
typedef double ld;

#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll > 
#define len length 
#define fi first
#define se second
#define dt cout<<"HEre\n";
#define sz(x) (ll)x.size()
const ll inf=1e18+1e17;
const ll mod = 1e9+7;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


void solve(){
	int n;
	cin>>n;
	int arr[n];
	for ( int i=0;i<n;i++)
		cin>>arr[i];
	ll mi=inf;
	for ( int i=-100;i<=100;i++){
		ll val=0;
		for ( int j=0;j<n;j++){
			val=val+( powm(abs(arr[j]-i),2));
		}
		mi=min( val,mi);
	}
	cout<<mi<<'\n';



}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
    //	cout << clock() / double(CLOCKS_PER_SEC) << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int h, w, a, b;
    std::cin >> h >> w >> a >> b;
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < a; j++) std::cout << 0;
        for (int j = a; j < w; j++) std::cout << 1;
        std::cout << std::endl;
    }
    for (int i = b; i < h; i++) {
        for (int j = 0; j < a; j++) std::cout << 1;
        for (int j = a; j < w; j++) std::cout << 0;
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for(int i = 0; 4 * i <= n; i++){
        for(int j = 0; 4 * i + 7 * j <= n; j++){
            if(4 * i + 7 * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
	int N,Q;
	string S;
	cin >>N>>Q>>S;
	vector<int> Li(N,0);
	int count = 0;
	for (int i=1;i<N;i++){
		if(S.at(i-1)=='A' && S.at(i) == 'C'){
			count++;
		}
		Li.at(i)=count;
	}
	int l,r;
	for (int i=0;i<Q;i++){
		cin >> l>>r;
		if(l!=1){
			cout << Li.at(r-1)-Li.at(l-1)<<endl;
		}
		else{
			cout <<Li.at(r-1)<<endl;
		}
		
	}
	return 0;
}




Measured memory_bytes: 1408
#include<iostream>
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;
int f(int a,int b,int x){return (x?(x-1?a*b:a-b):a+b);}int r[4];
int main(){
while(cin>>r[0]>>r[1]>>r[2]>>r[3]&&r[0]){lol(q,99){string z="+-*";
	lol(i,3)lol(j,3)lol(k,3){
		if(f(f(r[0],r[1],i),f(r[2],r[3],k),j)==10){cout<<"("<<r[0]<<z[i]<<r[1]<<")"<<z[j]<<"("<<r[2]<<z[k]<<r[3]<<")\n";goto l;}
		if(f(f(f(r[0],r[1],i),r[2],j),r[3],k)==10){cout<<"(("<<r[0]<<z[i]<<r[1]<<")"<<z[j]<<r[2]<<")"<<z[k]<<r[3]<<"\n";goto l;}
	}if(q%6==5)swap(r[0],r[1]);else if(q%2==1)swap(r[1],r[2]);else swap(r[2],r[3]);
	}cout<<"0"<<endl;l:;
}return 0;}

Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define ll long long
#define u unsigned
#define me(a,x) memset(a,x,sizeof(a))
#define sf scanf
#define pf printf
const int mod=1e9+7;
using namespace std;
int main()
{
	int n,d,i,sum=0;
	sf("%d %d",&n,&d);
	for(i=1;i<=n;i++){
		double x,y;
		sf("%lf %lf",&x,&y);
		double dis=sqrt(x*x+y*y);
		if(dis<=d){
			sum++;
		}
	}
	pf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 3868
def main():
    n = int(input())
    ans = 'No'

    for i in range(1,10):
        for j in range(1,10):
            if (i * j) == n:
                ans = 'Yes'
                break
        else:
            continue
        break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919810893;
const ll MOD = 1000000007;
const ll NUM = 101010;
void chadd(ll &a, const ll &b){a = (a + b) % MOD;}


int main(){

    ll N, K;
    cin >> N >> K;
    ll H[333];
    rep1(i, N)cin >> H[i];
    ll dp[333][333] = {};
    rep(i, 333)rep(j, 333)dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, N + 1)rep(j, K + 1)if(dp[i][j] < INF){
        for(ll k = i + 1; k <= N + 1; k++){
            ll c = max(0LL, H[k] - H[i]);
            ll t = k - i - 1;
            chmin(dp[k][j + t], dp[i][j] + c);
        }
    }
    ll ans = INF;
    for(ll k = 0; k <= K; k++)chmin(ans, dp[N + 1][k]);
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;
const int E = numeric_limits<int>::min();

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> val(N);
    rep(i, N){
        cin >> val[i];
    }

    sort(val.begin(), val.end());
    int cost = 0;
    rep(i, K){
        cost += val[i];
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
	
	public void solve(){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int kakeru;
		kakeru=x*x*x;
		System.out.println(kakeru);
	}
	
	public static void main(String[] args){
		Main obj=new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17152
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[10010],ans=0;
  cin>>n;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    while(a[i]%2==0) {
      a[i]/=2;
      ans++;
    }
  }
  cout<<ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i,n){
    char c;
    cin >> c;
    s[i] = c - '0';
  }
  int ans = 0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        int posI = -1;
        rep(p,n){
          if(s[p] == i){
            posI = p;
            break;
          }
        }
        if(posI == -1) continue;
        int posJ = -1;
        for(int p=posI+1;p<n;p++){
          if(s[p] == j){
            posJ = p;
          	break;
          }
        }
        if(posJ == -1) continue;
        for(int p=posJ+1;p<n;p++){
          if(s[p] == k){
            ans ++;
            break;
          }
        }
      }//k
    }//j
  }//i
  cout << ans << endl;
}

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

using namespace std;

int main(){

    string s;
    int ans = 0;
    
    cin >> s;

    int len = s.length();

    for(int i = 0; i < len / 2; i++){
        if(s[i] != s[len-i-1]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = 1e9;
    for (int i = 0; i <= 2 * max(x, y); i += 2)
    {
        ans = min(ans, a * max(0, (x - i / 2)) + b * max(0, (y - i / 2)) + c * i);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
public class Main {
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    void solve() throws IOException {
    	String s = ns();
    	int k = ni();
    	
    	int n = s.length();
    	
    	char[] c = s.toCharArray();
    	
    	for (int i=0; i<n; i++) {
    		if (k <= 0) break;
    		
    		int m = c[i] - 'a';
    		
    		if (i==n-1) {
    			k %= 26;
    			c[i] = (char)('a' + (m + k) % 26);
    			break;
    		}
    		
    		if (c[i] == 'a' || 26 - m > k) continue;
    		
    		c[i] = 'a';
    		k -= 26 - m;
    	}
    	
    	out.println(String.valueOf(c));
    }
 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 11472
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

int main(){
  
  int N;
  while(cin >> N, N) {
    vector< iP > pos(N + 1);
    pos[0] = iP(0, 0);
    for(int i = 1; i < N; i++) {
      int n, d; cin >> n >> d;
      iP p = pos[n];
      if(d == 0) {
        pos[i].fr = p.fr - 1;
        pos[i].sc = p.sc;
      } else if(d == 1) {
        pos[i].fr = p.fr;
        pos[i].sc = p.sc + 1;
      } else if(d == 2) {
        pos[i].fr = p.fr + 1;
        pos[i].sc = p.sc;
      } else {
        pos[i].fr = p.fr;
        pos[i].sc = p.sc - 1;
      }
    }
    int minx = INF,miny = INF, maxx = -INF, maxy = -INF;
    for(int i = 0; i < N; i++) {
      minx = min(minx, pos[i].fr);
      miny = min(miny, pos[i].sc);
      maxx = max(maxx, pos[i].fr);
      maxy = max(maxy, pos[i].sc);
    }
    cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;
  }
}

Measured memory_bytes: 1192
n,k=[int(_) for _ in input().split()]
d=[]
a=[]
h=[0 for _ in range(n)]
for i in range(k):
    d.append(int(input()))
    a.append([int(_) for _ in input().split()])
for i in range(k):
    for j in range(d[i]):
        h[a[i][j]-1]+=1
print(h.count(0))


Measured memory_bytes: 9192
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 2100000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
  COMinit();
  int x, y;
  cin >> x >> y;
  ll cx = 0, cy = 0;
  ll res;


  while(x > 0 && y > 0){
    if(x > 2*y) break;

    if(x < 2*y){
      x--; y -= 2;
      cy++;
    } else if(x == 2 * y){
      cx = y;
      x = 0; y = 0;
      break;
    }
  }

  if(x != 0 || y != 0) res = 0;
  else
    res = COM(cx+cy, min(cx, cy));
  
  cout << res % MOD << ln;
}
  


Measured memory_bytes: 49408
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

x = i()
a = 0
b = 0
for i in range(-120,120):
	for j in range(-119,119):
		if i**5 - j**5 == x:
			a = i
			b = j
			print(a,b)
			exit()

Measured memory_bytes: 9060
"""
task statement
==============

高橋君は青木君と待ち合わせをしています。
待ち合わせ場所は高橋君の家から D メートル離れた地点であり、待ち合わせの時刻は T 分後です。
高橋君は今から家を出発し、分速 S メートルで待ち合わせ場所までまっすぐ移動します。
待ち合わせに間に合うでしょうか？

io_style
-------
D T S
"""
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    d, t, s = input_int_list()
    if d / s <= t:
        print("Yes")
    else:
        print("No")

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61772
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int w = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        Integer[] y = new Integer[n];
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int minH = 0;
        int maxH = h;
        int minW = 0;
        int maxW = w;

        for (int i = 0; i < n; i++) {
            int operation = a[i];
            if (operation == 1) {
                minW = Math.max(minW, x[i]);
            } else if (operation == 2) {
                maxW = Math.min(maxW, x[i]);
            } else if (operation == 3) {
                minH = Math.max(minH, y[i]);
            } else if (operation == 4) {
                maxH = Math.min(maxH, y[i]);
            }
        }

        int height = Math.max(0, maxH - minH);
        int width = Math.max(0, maxW - minW);

        int result = height * width;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  ll ans=0;
  rep(i,N){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(A[i]==A[j]||A[i]==A[k]||A[j]==A[k]) continue;
        ll ma=max(A[i],max(A[j],A[k]));
        ll sum=A[i]+A[j]+A[k];
        if(ma<sum-ma) ans++;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, va, b, vb, t;
    cin >> a >> va;
    cin >> b >> vb;
    cin >> t;
    b -= a;
    a = 0;
    b = abs(b);
    bool can = va*t >= b + vb*t;
    cout << (can ? "YES" : "NO") << "\n";

    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int r, d, x;
  cin >> r >> d >> x;

  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 256
def solve(init, s):
    ideal = init  # 初期値 黒 or 白
    result = 0  # 塗り替える数
    for color in s:
        if color != ideal:
            result += 1
        ideal ^= 1  # 排他的論理和, 白黒逆になる
    return result


s = input()
s = list(map(int, s))
print(min(solve(0, s), solve(1, s)))


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

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9
int sum(int x){
   int _sum = 0;
   for(int i = 100000;i > 0;i/=10){_sum += x / i;x-=_sum*i;}
   return _sum;
}
int main(){
   int n,a,b;scanf("%d%d%d",&n,&a,&b);
   long int ans=0;
   for(int i = 1;i <= n;i++){
      int _sum = 0;
      int x=i;
      for(int i = 100000;i > 0;i/=10){_sum += x / i;x%=i;}
      if((_sum>=a)&&(_sum<=b)){
         ans+=i;
         //printf("%d\n",i);
      }
   }
   printf("%ld\n",ans);
   return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int n,tk,i,j,sum;

    scanf("%d %d",&n,&tk);

    for(i=0; i<=n; i++)
    {
        for(j=0; j<=n-i; j++)
        {
            sum=10000*i+5000*j+(n-i-j)*1000;

            if(sum==tk)goto xx;
        }
    }
      if(i==n+1)printf("-1 -1 -1\n");

     else  xx:printf("%d %d %d\n",i,j,n-i-j);

     return 0;
}



Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define ff first
#define ss second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define pb emplace_back
#define mp make_pair
#define getchar_unlocked getchar
# define TMP template<typename
#ifdef LOCAL 
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
    
    ~debug() { cerr << endl; }
    template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return * this; }
    template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return * this << range(begin(i), end(i)); }
    template < class c, class b > debug & operator <<(pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }};
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
void in(int &x){
    cin  >> x;
}
#else
inline void in(int &x)
    {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }
inline void uin(ulli &n){
    register ulli c=gc();
    n=0;
    while(c<'0'||c>'9')
    c=gc();
    while(c<='9'&&c>='0'){
    n=n*10+c-'0';
    c=gc();}
}
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
    int n , tmp;
    cin >> n;
    vector<int> a(n);
    fri(i,0,n){
        cin >> tmp;
        a[tmp-1] = i+1;
    }

    fri(i,0,n) cout << a[i] << " ";
}



Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	int n,ans=0;
	cin>>n;
	vector<long long int>a(100000000);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<32;i++){
		for(int j=0;j<n;j++){
			if(a[j]%2==0&&a[j]!=0){
				ans++;
				a[j]=a[j]/2;
			}
			else{
				a[j]=0;
			}
		}
	}
	cout<<ans<<endl;

    return 0;
}

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

int main() {
  
  string S, T;
  
  int A, B;
  
  string U;
  
  cin >> S >> T;
  
  cin >> A >> B;
    
  cin >> U;
    
  if (S == U){
    cout << A - 1 << " " << B << endl;
  }
   else{
     cout << A << " " << B - 1 << endl;
   }
    
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int A,B,C;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    A = sc.nextInt();
    B = sc.nextInt();
    C = sc.nextInt();
    if(B/A>=C){
      System.out.println(C);
    }
    else{
      System.out.println(B/A);
    }
  }
  
}

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

const unsigned WIDTH = 14;
const unsigned HEIGHT = 14;

void trace( int* map , int j, int i ){
	map[ j * HEIGHT + i ] = false;
	if( map[ ( j - 1 ) * HEIGHT + i ] ){
		trace( map, j - 1, i );
	}
	if( map[ j * HEIGHT + ( i + 1 ) ] ){
		trace( map, j, i + 1 );
	}
	if( map[ ( j + 1 ) * HEIGHT + i ] ){
		trace( map, j + 1, i );
	}
	if( map[ j * HEIGHT + ( i - 1 ) ] ){
		trace( map, j, i - 1 );
	}
}


int main(){
	int map[ HEIGHT * WIDTH ] = { false };
	string s;

	while ( cin >> s ){
		for ( int i = 1; i < WIDTH-1; ++i ){
			map[ HEIGHT + i ] = static_cast< int >( s[ i - 1 ] - '0' );
		}
		for ( int j = 2; j < HEIGHT-1; ++j ){
			cin >> s;
			for ( int i = 1; i < WIDTH-1; ++i ){
				map[ j * HEIGHT + i ] = static_cast< int >( s[ i - 1 ] - '0' );
			}
		}

		int cnt = 0;
		for ( int j = 1; j < HEIGHT-1; ++j ){
			for ( int i = 1; i < WIDTH-1; ++i ){
				if( map[ j * HEIGHT + i ] ){
					trace( map, j, i );
					++cnt;
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    string s,t;
    cin >> s;
    cin >> t;
    cout << t <<  s << endl;;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin >> n >> k;
    double a[n + 1];
    for (int i = 1; i < n + 1; i++) cin >> a[i];
    double pre[n + 1];
    pre[0] = 0;

    for (int i = 1; i < n + 1; i++) {
        pre[i] = a[i] * (a[i] + 1) / 2 / a[i];
        pre[i] += pre[i - 1];
    }

    double ans = 0;
    for (int i = k; i < n + 1; i++) {
        ans = max(ans, pre[i] - pre[i - k]);
    }

    cout << ans;


}


Measured memory_bytes: 3840
while True:
  w = 5
  h = input()

  if h == 0: break

  a = []
  for i in range(h):
    a.append(map(int, raw_input().split()))

  flag = True
  ans = 0
  while flag:
    flag = False

    for i in range(h - 1, -1, -1):
      cnts = [1 for _ in range(w)]
      for j in range(w - 1):
        if a[i][j] != -1 and a[i][j] == a[i][j + 1]:
          cnts[j + 1] += cnts[j]
      for j in range(w - 1, -1, -1):
        if a[i][j] != -1 and cnts[j] >= 3:
          ans += a[i][j] * cnts[j]
          for k in range(cnts[j]):
            a[i][j - k] = -1
            flag = True

    flag2 = True
    while flag2:
      flag2 = False
      for i in range(h - 1, 0, -1):
        for j in range(w):
          if a[i][j] == -1 and a[i - 1][j] != -1:
            (a[i][j], a[i - 1][j]) = (a[i - 1][j], a[i][j])
            flag2 = True
            """
    for i in range(h):
      for j in range(w):
        print a[i][j],
      print
    print
            """
  print ans

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    long double a;
    cin >> a;
    cout << 3.14 * a * 2 << endl;

    return 0;
}


Measured memory_bytes: 3792
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  string s; cin >> s;
  cout << s.substr(0, s.length()-8) << endl;
}


Measured memory_bytes: 256
S = list(input())
N = len(S)
if S[:int((N-1)/2)] == list(reversed(S[:int((N-1)/2)]))\
    and S[int((N+1)/2):] == list(reversed(S[int((N+1)/2):]))\
    and S == list(reversed(S)):

    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def max(x:Int,y:Int) = if(x>y) x else y

  def main(args:Array[String]) = {
    val n = readInt
    val b = new ArrayBuffer[Int]

    for(i<-0 until n) {
      val s1 = ' ' + readLine.trim
      val s2 = ' ' + readLine.trim
      val maxN = s1.length
      val maxM = s2.length

      val a = Array.ofDim[Int](maxN,maxM)
      for(i<-1 until maxN) {
        for(j<-1 until maxM) {
          if(s1(i)==s2(j)) {
            a(i)(j) = a(i-1)(j-1)+1
          } else {
            a(i)(j) = max(a(i-1)(j), a(i)(j-1))
          }
        }
      }
      b += a(maxN-1)(maxM-1)
    }
    println(b.mkString("\n"))
  }
}

Measured memory_bytes: 124368
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

template<class T> class BIT {

   public:
      vector<T> bit;
      int SIZE;

      void init(int N, T a) {
         SIZE = N + 1;
         bit.resize(SIZE);
         for (int i = 0; i < SIZE; i++) {
            bit[i] = a;
         }
      }
      // 1-indexed 
      void add(int a, T w) {
         for (int x = a; x <= SIZE; x += x & -x) bit[x] += w;
      }
      
      // [1, a], 1-indexed
      T sum(int a) {
         T ret = 0;
         for (int x = a; x > 0; x -= x & -x) ret += bit[x];
         return ret;
      }

      // [a, b), 1-indexed
      T sum(int a, int b) {
         return sum(b) - sum(a - 1);
      }

      // get k-th number with binary search, k: 0-indexed
      int getk(T k) {
         k++;
         T ret = 0;
         int N = 1;
         while (N < SIZE) N *= 2;
         for (int i = N / 2; i > 0; i /= 2) {
            if (ret + i < SIZE && bit[ret + i] < k) {
               k = k - bit[ret + i];
               ret = ret + i;
            }
         }
         return ret + 1;
      }
};

int main() {   
   int N;
   cin >> N;
   int A[N];
   map<int, int> log; 
   for (int i = 0; i < N; i++) {
      cin >> A[i];
      log[A[i]] = 1;
   }
   int num = 1;
   for (auto& l : log) {
      if(l.second == 0) continue;
      l.second = num;
      num++;
   }
   for (int i = 0; i < N; i++) {
      A[i] = log[A[i]];
   }
   
   BIT<int> bits;
   bits.init(N, 0);
   ll ans = 0;
   for (int i = 0; i < N; i++) {
      ans += i - bits.sum(A[i]);
      bits.add(A[i], 1);
   }
   cout << ans << endl;
   return 0;
}



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

using namespace std;

struct node{
	int x,y;
}peo[100000];

bool cmp(node a , node b){
	if(a.y == b.y){
		return a.x < b.x;
	}
	return a.y < b.y;
}
int main(){
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i ++){
		int a,b;
		scanf("%d%d",&a,&b);
		
		peo[i].x = a - b;
		peo[i].y = a + b;
	}
	
	sort(peo + 1,peo +1 + n,cmp);
	
	int sum = 1;
	
	node now = peo[1];
	for(int i = 2; i <= n; i ++){
		if(peo[i].x >= now.y){
			sum++;
			now = peo[i];
		}
			
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 1024
/***
 *          ___           ___
 *         /\  \         /\  \                                     _____
 *         \:\  \        \:\  \                                   /::\  \       ___           ___
 *          \:\  \        \:\  \                                 /:/\:\  \     /\__\         /\__\
 *      _____\:\  \   ___  \:\  \   ___     ___   ___     ___   /:/ /::\__\   /:/__/        /:/  /
 *     /::::::::\__\ /\  \  \:\__\ /\  \   /\__\ /\  \   /\__\ /:/_/:/\:|__| /::\  \       /:/__/
 *     \:\~~\~~\/__/ \:\  \ /:/  / \:\  \ /:/  / \:\  \ /:/  / \:\/:/ /:/  / \/\:\  \__   /::\  \
 *      \:\  \        \:\  /:/  /   \:\  /:/  /   \:\  /:/  /   \::/_/:/  /   ~~\:\/\__\ /:/\:\  \
 *       \:\  \        \:\/:/  /     \:\/:/  /     \:\/:/  /     \:\/:/  /       \::/  / \/__\:\  \
 *        \:\__\        \::/  /       \::/  /       \::/  /       \::/  /        /:/  /       \:\__\
 *         \/__/         \/__/         \/__/         \/__/         \/__/         \/__/         \/__/
 *
 *      @author      : Dylan Dsouza (dsouzadyn@gmail.com)
 *      @created     : Saturday Feb 16, 2019 22:47:36 IST
 */
#include <bits/stdc++.h>

using namespace std;

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

  

  int A, B;
  cin >> A >> B;
  if (B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll n,a[222222];

ll calc(ll m) {
  ll ans=0;
  rep(i,n) ans+=abs(a[i]-(m+i+1));
  return ans;
}

void Main() {
  R n;
  rep(i,n) R a[i];
  ll l=-MAX,r=MAX;
  rep(t,100) {
    ll m1=(l*2+r)/3,m2=(l+r*2)/3;
    ll d1=calc(m1),d2=calc(m2);
    if(d1>d2) l=m1;
    else r=m2;
  }
  ll ans=MAXL;
  REP(i,-3,3) ans=min(ans,calc(l+i));
  pr(ans);
}

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


Measured memory_bytes: 1792
n = int(input())
lst = list(map(int, input().split()))
lst.insert(0, 0)
lst.append(0)

s = 0
for i in range(len(lst)-1):
    s += abs(lst[i+1]-lst[i])
    
for i in range(1, len(lst)-1):
    a = lst[i-1]
    b = lst[i]
    c = lst[i+1]
    if (b - a > 0 and c - b > 0) or (b - a < 0 and c - b < 0):
        print(s)
    else:
        print(s - abs(b-a) - abs(c-b) + abs(c-a))

Measured memory_bytes: 14172