akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Topic03
{
    class ALDS1_3_B
    {
        static void Main(string[] args)
        {
            int[] init = ReadLine().Split()
                .Select(n => int.Parse(n)).ToArray();
            int N = init[0];
            int Q = init[1];

            Queue<Process> process = new Queue<Process>();
            for (int i = 0; i < N; i++)
            {
                string[] input = ReadLine().Split().ToArray();
                process.Enqueue(
                    new Process(input[0], int.Parse(input[1]))
                );
            }

            int result = 0;
            while (process.Count > 0)
            {
                Process curProcess = process.Dequeue();
                int leftTime = curProcess.Time;
                if (leftTime <= Q)
                {
                    result += leftTime;
                    WriteLine("{0} {1}", curProcess.Name, result);
                }
                else
                {
                    leftTime -= Q;
                    result += Q;
                    process.Enqueue(
                        new Process(curProcess.Name, leftTime)
                    );
                }
            }

            ReadKey();
        }
    }

    internal class Process
    {
        internal string Name {get;}
        internal int Time {get;}

        internal Process(string name, int time)
        {
            Name = name;
            Time = time;
        }
    }
}


Measured memory_bytes: 25504
n,k = map(int,input().split())
d = list(map(int,input().split()))

for i in range(1000000):
    if i < n:
        continue
    i1 = str(i)
    flag = True
    for j in range(len(i1)):
        if not flag:
            break
        i2 = int(i1[j])
        if i2 in d:
            flag = False
    if not flag:
        continue
    print(i)
    break


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

int main(){
    string S;
    cin>>S;
    int length = S.length();
    // cout<<length<<endl;
    // int a = S.at(0)-'0';
    // cout<<a<<endl;
    int tmp = 0;
    for(int i=0;i<length;i++){
        int a = S.at(i) - '0';
        tmp += a;
        tmp = tmp%9;
    }
    if(tmp == 0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3724
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

def solve():
    N, K = mapint()
    As = list(mapint())
    mod = 10**9+7
    pos = []
    neg = []
    for a in As:
        if a>=0:
            pos.append(a)
        else:
            neg.append(a)

    pos.sort(reverse=True)
    neg.sort()
    lenp = len(pos)
    lenn = len(neg)
    if not pos and K%2==1:
        ans = 1
        for i, n in enumerate(neg[::-1]):
            ans *= n
            ans %= mod
            if i==K-1:
                break
        return ans
    if lenp+lenn==K and (K-lenp)%2==1:
        ans = 1
        pos.extend(neg)
        pos.sort(reverse=True)
        for i, p in enumerate(pos):
            ans *= p
            ans %= mod
            if i==K-1:
                break
        return ans
    ans = 1
    pcnt = 0
    ncnt = 0
    for i in range(K//2):
        if pcnt*2+1>=lenp:
            ans *= neg[ncnt*2]*neg[ncnt*2+1]
            ans %= mod
            ncnt += 1
        elif ncnt*2+1>=lenn:
            ans *= pos[pcnt*2]*pos[pcnt*2+1]
            ans %= mod
            pcnt += 1
        elif pos[pcnt*2]*pos[pcnt*2+1]>neg[ncnt*2]*neg[ncnt*2+1]:
            ans *= pos[pcnt*2]*pos[pcnt*2+1]
            ans %= mod
            pcnt += 1
        else:
            ans *= neg[ncnt*2]*neg[ncnt*2+1]
            ans %= mod
            ncnt += 1
    if K%2==1:
        ans *= pos[pcnt*2]
        ans %= mod
    return ans

print(solve())

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

int main()
{
  int N;
  int D;
  cin >> N >> D;
  
  int E=2*D+1;
  int ans=N/E;
  if(ans*E!=N)
    ans = ans + 1;
  
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
# import bisect
# import copy
from fractions import gcd


# import math
# import numpy as np
# from collections import Counter, deque
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import sys
sys.setrecursionlimit(10**9)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    # A[0:i]の最大公約数
    L=[0]*N
    for i in range(1,N):
        L[i]=gcd(L[i - 1], A[i - 1])

    # A[i:]の最大公約数
    R=[0]*(N+1)
    for i in reversed(range(N)):
        R[i]=gcd(R[i + 1], A[i])


    maxgcd = 0
    for i in range(N):
        maxgcd = max(maxgcd, gcd(L[i], R[i + 1]))

    print(maxgcd)


resolve()

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

int main(){
	int h, n;
	int a = 0;
	cin >> h >> n;
	rep(i, n){
		int kari;
		cin >> kari;
		a += kari;
	}

	if(h <= a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll X;
  cin >> X;
  ll gohyaku = X / 500;
  ll go = (X - gohyaku * 500) / 5;
  COUT(gohyaku * 1000 + go * 5);
  return 0;
}

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

using namespace std;

typedef long long lint;

int N;
lint A[201010];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  lint res = 0;
  if (A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N - 1; i++) {
    if (A[i] + 1 < A[i + 1]) {
      res = -1;
      break;
    }

    if (A[i] + 1 == A[i + 1]) {
      res++;
    } else {
      res += A[i + 1];
    }
  }

  cout << res << endl;

  return 0;
}

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

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

	vector<int> a(n);
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		a.pb(x);
		a.pb(x);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

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

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6268
A, B = map(int, input().split())

g = [["#"]*100 for _ in range(50)] + [["."]*100 for _ in range(50)]

for i in range(A-1):
    x, y = (i%50)*2, (i//50)*2
    g[y][x] = "."
for i in range(B-1):
    x, y = (i%50)*2, 51+(i//50)*2
    g[y][x] = "#"

print(100, 100)
for g_i in g:
    print("".join(g_i))

Measured memory_bytes: 3064
using System;

namespace A___November_30
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var m1 = int.Parse (input[0]);
            var d1 = int.Parse (input[1]);
            input = Console.ReadLine ().Split (' ');
            var m2 = int.Parse (input[0]);
            var d2 = int.Parse (input[1]);
            if (d2 == 1)
            {
                Console.WriteLine (1);
            }
            else
            {
                Console.WriteLine (0);
            }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	ll n;
	int p;
	ll cnt0=0,cnt1=0;
	int a;
	cin >> n>>p;
	rep(i,n){
		cin >> a;
		if (a%2){
			cnt1++;
		}
	}
	cnt0 = n - cnt1;
	//p==1
//	cout << cnt0 << " " << cnt1 << endl;
	ll ans = (ll)pow(2.0, n-1);
	if(cnt1==0) {
		if(p) {
			cout << "0" << endl;
		}
		else {
			cout << (ll)pow(2.0,n) << endl;
		}
	}
	else {
	cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i+1] == a[i] + 1:
        ans += c[a[i]-1]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;

int calc(string t){
	t=t.substr(1,t.size()-1);
	if(t[0]!='['){
		return atoi(t.c_str())/2+1;
	}
	int st=0;
	int co=0;
	vector<int> yy;
	for(int i=0;i<t.size();i++){
		if(t[i]=='[')co++;
		if(t[i]==']')co--;
		if(co==0){
			yy.push_back(calc(t.substr(st,i-st+1)));
			st=i+1;
		}
	}
	sort(yy.begin(),yy.end());
	int ans=0;
	for(int i=0;i<yy.size()/2+1;i++){
		ans+=yy[i];
	}
	return ans;
}
int main(){
	cin>>n;
	REP(i,n){
		string t;
		cin>>t;
		cout<<calc(t)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	vector<int> l(n + 1), r(n + 1);
	int now = 0;
	rep(i, n) {
		if (s[i] == '<')
			now++;
		else
			now = 0;
		l[i + 1] = now;
	}
	now = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>')
			now++;
		else
			now = 0;
		r[i] = now;
	}
	ll ans = 0;
	rep(i, n + 1) ans += max(l[i], r[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7672
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	VI A(N), F(N);
	REP(i, N)cin >> A[i];
	REP(i, N)cin >> F[i];
	SORT(A);
	rSORT(F);

	

	int L = 0, R = A[N - 1] * F[0];
	int T;
	int ans = LLINF;
	while (R >= L) {
		if (T == L + (R - L) / 2) {
			//cout << T << endl;
			
			break;
		}
		int M = L + (R - L) / 2;
		T = M;
		VI tmp;
		REP(i, N) {
			tmp.push_back(M / F[i]);
		}
		SORT(tmp);
		int cnt = 0;
		REP(i, N) {
			cnt += max(A[i] - tmp[i], 0LL);
		}
		//cout << M <<" "<<cnt<<" "<<L<<" "<<R<< endl;
		
		if (cnt > K) {
			L = M + 1;
		}
		else if (cnt <= K) {
			R = M - 1;
			ans = min(ans, M);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 7060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	char a,b,c;
	while(scanf("%c%c%c",&a,&c,&b)!=EOF){
		getchar();
		if(a>b) printf(">\n");
		else if(a<b) printf("<\n");
		else printf("=\n");
	}
	return 0;	
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;



void main() {
    string s;
    scan(s);
    int k;
    scan(k);

    string[] set;
    int n = s.length.to!int;

    foreach (i ; 0 .. n) {
        foreach (j ; i + 1 .. i + k + 1) {
            set ~= s[i .. min(j, $)];
        }
    }

    set.sort();

    debug {
        writeln(set);
    }

    auto ans = set.uniq.drop(k-1).front;
    writeln(ans);
}







































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 2428
#include<stdio.h>
#include<string.h>

int main()
{
	char str[1000];
	char operation[10];
	int operation_number = 0;
	int a = 0,b = 0, i = 0;
	char p[1000],tmp;
	scanf("%s",str);
	scanf("%d",&operation_number);

	while(operation_number > 0)
	{
		scanf("%s %d %d",operation,&a,&b);
		if(strcmp(operation, "replace" ) == 0)
		{
			scanf("%s",p);
		}
		if(strcmp(operation, "print") == 0)
		{
			while(a <=b)
			{
				printf("%c",str[a]);
				if(a==b)
					printf("\n");
				a++;
				
			}
		}
		else if(strcmp( operation, "reverse") == 0)
		{
			while(a <=b)
			{
				tmp = str[b];
				str[b]= str[a];
				str[a] = tmp;
				b--;
				a++;
				
			}
		}
		else if(strcmp(operation, "replace") == 0)
		{
			i = 0;
			while(a <=b)
			{
				str[a] = p[i];
				a++;
				i++;
				
			}
		}
		operation_number--;
}
	
	return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <array>

int main()
{
  int y = 700;
  std::array<char, 3> S;
  for(int i = 0; i < 3; i++){
    std::cin >> S.at(i);
  }
  for(int i = 0; i < 3; i++){
    if(S.at(i) == 'o'){
      y += 100;
    }
  }
  std::cout << y;
  return 0;
}

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

int main()
{
	int a[3] ;
	cin>>a[0]>>a[1]>>a[2];
	swap(a[0], a[1]);
	swap(a[0], a[2]);
	
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
} 

Measured memory_bytes: 256
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        if x > S:
            break
        for y in range(K+1):
            if x+y > S:
                break
            z = S-(x+y)
            if z < 0 or z > K:
                continue
            # print(x,y,z)
            if S == x+y+z:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,x,m;
	cin>>n>>x>>m;
	vector<ll>arr;
	arr.push_back(x);
	ll var=x;
	vector<int>visited(m);
	visited[var]=1;
	ll rep;
	vector<ll>ans;
	ans.push_back(x);
	while(true)
	{
		var=var*var%m;
		if(visited[var]){
			rep=var;
			break;
		}
		else{
			ans.push_back(var);
			visited[var]=1;
		}
	}
    ll cnt1=0,cnt2=0;
    int ch=0;
    ll sum1=0,sum2=0;
    for(int nums : ans)
    {
    //	cout<<nums<<" ";
    	if(nums==rep){
    		ch=1;
		}
		if(ch==0){
		 cnt1++;
		 sum1+=nums;
	    }
		if(ch==1){
		 cnt2++;
		 sum2+=nums;
	    }
	}
	cout<<"\n";
	ll num1=min(n,cnt1);
	n-=num1;
	ll num2=n/cnt2;
	ll num3=n%cnt2;
	ll final=0;
	for(int i=0; i<num1; i++)
	 final+=ans[i];
	final+=num2*sum2;
	for(int i=cnt1; i<cnt1+num3; i++)
	 final+=ans[i];
	cout<<final;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<ll, pair<ll, ll>> kouho;

int main() {

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

    sort(h.begin(), h.end());
    if(n == k) {
        return h[h.size()-1] - h[0];
    }

    ll ans = LONG_MAX;
    rep(i, n-(k-1)) {
        chmin(ans, h[i+k-1]-h[i]);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;



int main(){
  string s;
  lint x;
  cin>>x;
  cin>>s;
  lint N=s.size()/2;
  if(s.size()%2!=0){
    cout<<"No";
    return 0;
  }
  repp(i,N,s.size()){
    if(s[i]!=s[i-N]){
      cout<<"No";
  
      return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
from itertools import chain
from collections import Counter

H, W = map(int, input().split())
dpCost = [list(map(int, input().split())) for _ in range(10)]
area = [list(map(int, input().split())) for _ in range(H)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            dpCost[i][j] = min(dpCost[i][j], dpCost[i][k]+dpCost[k][j])
wall = Counter(chain.from_iterable(area))
ans = 0
for k, v in wall.items():
    if k == 1 or k == -1:
        continue
    ans += v * dpCost[k][1]
print(ans)


Measured memory_bytes: 40284
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn main() {
  input! {
    n: usize,
    task: [(i64, i64); n],
  }
  let mut task = task;
  task.sort_by_key(|&(_, b)| b);
  let mut pass = 0;
  let mut ans = true;
  for &(a, b) in &task {
    pass += a;
    if pass > b {
      ans = false;
    }
  }
  if ans {
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 13560
N, Y = map(int,input().split())

ans = -1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z == Y:
            ans = x,y,z
            break
        else:
            continue
        break
print(*ans)

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

int dp[22][(1 << 22)];
int main(void) {
  int N;
  cin >> N;
  int a[22][22];
  memset(a, 0, sizeof(a));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> a[i][j];
    }
  }

  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int used = 0; used < (1 << N); used++) {
      if (dp[i][used] == 0) continue;
      for (int nx = 0; nx < N; nx++) {
        if ((used >> nx) & 1) continue;
        if (!a[i][nx]) continue;
        dp[i + 1][used | (1 << nx)] += dp[i][used];
        dp[i + 1][used | (1 << nx)] %= 1000000007;
      }
    }
  }
  
  cout << dp[N][(1 << N) - 1] << endl;  

  return 0;
}

Measured memory_bytes: 178432
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
 
int main(){
  int n,ans = 0;
  cin >> n;
  int v[n],c[n];
  REP(i,n) {
    cin >> v[i];
  }
  REP(i,n) {
    cin >> c[i];
  }
  REP(i,n) {
    if (v[i] > c[i]) {
      ans += (v[i] - c[i]);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

map<int, int> ret;

void go(int n) {
	for (int i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n]++;
	
}

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << n << endl;
		return 0;
	}
	for (int i = 2; i <= n; i++)
		go(i);
	ll ans = 1;
	for (auto m : ret) {
		ans = ans * (m.second + 1) % 1000000007LL;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val N = readLine()!!.split(" ").map { Integer.parseInt(it) }[0]
    val AList = mutableListOf<Int>()
    val BList = mutableListOf<Int>()
    val ABList = mutableListOf<Pair<Int, Int>>()
    for (i in 0 until N) {
        val (A, B) = readLine()!!.split(" ").map { Integer.parseInt(it) }
        AList.add(A)
        BList.add(B)
        ABList.add(Pair(A, B))
    }
    ABList.sortByDescending { pair -> pair.second }

    var current = ABList[0].second
    for (AB in ABList) {
        current = Math.min(AB.second, current)
        current -= AB.first
    }
    if (current < 0) {
        println("No")
    } else {
        println("Yes")
    }

}


Measured memory_bytes: 136668
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
// always use 1LL instead of 1
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

// using long doubles saves you from corner cases but is very time consuming
#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
// just comment the line below in case of interactive problems
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		vii v;
		rep(i,1,n)
		{
			int x,y;
			cin >> x >> y;
			v.pb({x,y});
		}
		int f = 0;
		rep(i,0,n-3)
		{
			if(v[i].S==v[i].F && v[i+1].S==v[i+1].F && v[i+2].S==v[i+2].F) 
				f = 1;
		}
		if(f==1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3644
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(`in`: String) = solve(Scanner(`in`))


fun solve(sc: Scanner): String {
    val A = listOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    val K = sc.nextInt() - 1

    return A[K].toString()
}


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

typedef long long LL;


LL cal(LL num,LL BASE)
{
    LL sum = 0;
    while(num)
    {
        sum += num % BASE;
        num /= BASE;
    }

    return sum;
}

LL n,S;
vector<LL> V;

LL solve(LL num)
{
    for(int i = 2;i <= 10000000;++i)
        if(cal(n,i) == S) return i;


    if(num < 0) return -1;
    if(num == 0) return n+1;

    LL m = sqrt(num+0.5);
    V.clear();

    for(int i = 1;i <= m;++i)
        if(num % i == 0)
        {
            LL a = i,b = num/i;

            a++,b++;
            V.push_back(a);
            V.push_back(b);
        }

    sort(V.begin(),V.end());
    int sz = V.size();
    for(int i = 0;i < sz;++i)
    {
        LL v = V[i];
        if(v < 2) continue;
        if(cal(n,v) == S) return v;
    }

    return -1;

}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%lld %lld",&n,&S);

    LL res = solve(n-S);
    printf("%lld\n",res);


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		if(a*b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}

	}
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int INF=10000000;
const int N=100000;

int n;

int p[N];
bool loop[N];
int f[N];

int dp[N];

int main()
{
    cin >>n;
    rep(i,n) scanf(" %d", &p[i]);

    fill(loop,loop+n,false);
    fill(f,f+n,INF);

    rep(i,n)
    {
        if(f[i]!=INF || loop[i]) continue;

        if(p[i]==0)
        {
            f[i]=i;
            continue;
        }

        if(f[i]==INF)
        {
            bool ok=true;
            set<int> vis;
            vis.insert(i);
            int nx=i+p[i];
            while(p[nx]!=0)
            {
                if(vis.find(nx)!=vis.end())
                {
                    ok=false;
                    break;
                }

                if(f[nx]!=INF)
                {
                    nx=f[nx];
                    break;
                }

                vis.insert(nx);
                nx+=p[nx];
            }

            if(!ok) for(const auto &x :vis) loop[x]=true;
            else
            {
                //printf("i=%d, nx=%d\n", i,nx);
                f[i]=nx;
                for(const auto &x: vis) f[x]=nx;
            }
        }
    }

    //rep(i,n) printf("f[%d]=%d\n",i,f[i]);

    fill(dp,dp+n,INF);

    dp[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty())
    {
        int v=que.front();
        que.pop();
        for(int i=1; i<=6; ++i)
        {
            int nx=min(n-1,v+i);
            if(f[nx]==INF) continue;
            nx=f[nx];
            if(dp[nx]>dp[v]+1)
            {
                dp[nx]=dp[v]+1;
                que.push(nx);
            }
        }
    }

    printf("%d\n", dp[n-1]);
    return 0;
}

Measured memory_bytes: 8424
from __future__ import print_function

import sys
input = sys.stdin.readline


# def eprint(*args, **kwargs):
#     print(*args, file=sys.stderr, **kwargs)


import math
# import string
# import fractions
from fractions import Fraction
# from fractions import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq

# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# # from itertools import accumulate
# # from collections import deque
# import random


def crange(a, b, i):
    return range(a, b + 1, i)


def main():
    n, k = map(int, input().split())
    p12 = Fraction(1, 2)
    ans = 0
    for i in crange(1, n, 1):
        if i >= k:
            ans += 1
        else:
            ans += p12**(math.ceil(math.log(Fraction(k, i), 2)))
    print(float(Fraction(ans, n)))
    # eprint("Fraction(ans,n) ", end=": ")
    # eprint(Fraction(ans, n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 79060
#include "bits/stdc++.h"
#include "random"
#include <unistd.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) return(gcd(b, a%b));
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int Uniform_Random(int a, int b){ // (a <= x <= b)

  random_device rd;
  mt19937 mt(rd());
  
  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
  
}
 
int main(){
  
  int n, r; cin >> n >> r;
  if (n >= 10) cout << r << endl;
  else{
    cout << r + 100 * (10 - n) << endl;
  }

  return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private final static String YES = "POSSIBLE";
    private final static String NO = "IMPOSSIBLE";
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt();
        boolean[] from = new boolean[n + 1];
        boolean[] to = new boolean[n + 1];
        for (int i = 1; i <= m; i++) {
            int a = scanner.nextInt(), b = scanner.nextInt();
            if (a == 1)
                from[b] = true;
            if (b == n)
                to[a] = true;
        }
        for (int i = 2; i < n; i++) if (from[i] && to[i]) {
            System.out.println(YES);
            return;
        }
        System.out.println(NO);
    }
}


Measured memory_bytes: 93472
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a[3][3];
  cin>>a[0][0]>>a[0][1]>>a[1][1];
  a[2][0]=a[0][0]+a[0][1]-a[1][1];
  a[1][2]=a[0][0]+a[2][0]-a[1][1];
  a[0][2]=a[0][0]+a[1][1]-a[1][2];
  a[1][0]=a[0][0]+a[0][1]+a[0][2]-a[1][1]-a[1][2];
  a[2][1]=a[0][0]+a[0][1]+a[0][2]-a[0][1]-a[1][1];
  a[2][2]=a[0][0]+a[0][1]+a[0][2]-a[0][2]-a[1][2];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cout<<a[i][j]<<" \n"[j==2];
  return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();


    	ArrayList<String> result = new ArrayList<>();
    	result.add(sc.next());
//    	for(int i=1;i<N;i++) {
//    		System.out.println(i);
//    		String next = sc.next();
//    		boolean chk = true;
//    		for(String j:result) {
//    			if(next.equals(j)) {
//    				chk = false;
//    				break;
//    			}
//    		}
//    		if(chk) {
//    			result.add(next);
//    			Collections.sort(result);
//    		}
//    	}
    	for(int i=1;i<N;i++) {
    		result.add(sc.next());
    	}
//		Collections.sort(result);
		ArrayList<String> ans = new ArrayList<String>(new HashSet<>(result));
    	System.out.println(ans.size());
    }

}

Measured memory_bytes: 69292
N = int(input())
A = list(map(int, input().split()))

for k in range(N):
        print(A[k], end='')
        if k < N-1:
            print(' ', end='')
print('')

for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    for k in range(N):
        print(A[k], end='')
        if k < N-1:
            print(' ', end='')
    print('')


Measured memory_bytes: 6316
fun main(args: Array<String>) {
    a57(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a57(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (now, hours) = args[0].split(" ").map { it.toInt() }
    println((now + hours) % 24)
}

Measured memory_bytes: 38080
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef unsigned long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
const int MAX=2e5+10;
const ll INF=9e18;

int main(){
	int N;
	ll X;
	cin>>N>>X;
	ll x[MAX];
	rep1(i,N)cin>>x[i];
	ll sum[MAX];
	sum[0]=0;
	rep1(i,N)sum[i]=sum[i-1]+x[i];
	ll ans=INF;
	rep1(k,N){
		ll tmp=sum[N]*5+X*(N+k);
		for(int p=N-2*k; p>=1; p-=k){
			tmp+=2*sum[p];
		}
      	ans=min(ans, tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
//ポインタの練習。(あまり意味がない)
//ポインタの使い方教えてくださる人、募集中。

#include <stdio.h>
int calc(int*,char,int*);
int main(void){
    // Your code here!
    int a,b,i;
    char c;
    scanf("%d %c %d",&a,&c,&b);
    i = calc(&a,c,&b);
    printf("%d\n",i);
}

int calc(int *p_a,char c,int *p_b){
    if(c=='+')
        return *p_a+*p_b;
    else
        return *p_a-*p_b;
}

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

using namespace std;

string s;
string t;

int main(){
    cin >> s;
    cin >> t;
    int sl = s.size();
    int tl = t.size();
    if(tl > sl){
        cout << "UNRESTORABLE" << endl;
        return 0; 
    }
    bool f;
    for(int i=sl-1;i>=tl-1;i--){
        f = true;
        for(int j=0;j<tl;j++){
            if(s[i-j]=='?') continue;
            if(t[tl-1-j] != s[i-j]){
                f = false;
                break;
            }
        }
        if(f){
            for(int k=0;k<(i-tl+1);k++){
                if(s[k]=='?') cout << 'a';
                else cout << s[k];
            }
            cout << t;
            for(int k=i+1;k<sl;k++){
                if(s[k]=='?') cout << 'a';
                else cout << s[k];
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>

struct IO{
    IO(){}
#define gc getchar
    inline IO&operator>>(int&_){
        _=0; bool f=0; char c=gc();
        while(c>'9' || c<'0') f|=(c=='-'), c=gc();
        while(c>='0' && c<='9') _*=10, _+=c&15, c=gc();
        _=f?-_:_; return*this;
    }
    inline IO&operator<<(int x){
        if(!x){putchar(48);goto f;}
        if(x<0) putchar('-'),x=~x+1;
        static short wt[20],len;len=0;
        for(;x;x/=10) wt[++len] = x%10;
        while(len)putchar(wt[len--]+48);
        f: putchar('\n'); return *this;
    }
    inline int operator()(){
        int _=0; short f=1; char c=gc();
        while(c>'9' || c<'0') f=(c=='-')?-1:1, c=gc();
        while(c>='0' && c<='9')_*=10, _+=c&15, c=gc(); return _*f;
    }
#undef gc
}io;

#define N 500005

inline int min(int a,int b){ return a<b?a:b; }
inline int max(int a,int b){ return a>b?a:b; }

int n,k,P[N],Ans[N];

struct Segement_Tree{
#define mid (l+r>>1)
#define lson ll,rr,ls
#define rson ll,rr,rs
#define inf 0x7f7f7f7f
#define ls id<<1,l,mid
#define rs id<<1|1,mid+1,r
	int tag[N<<2];
	
	inline void init(){ memset(tag,inf,sizeof tag); }
	
	inline void mdy(int p,int v,int id=1,int l=1,int r=n){
		if(l==r){ tag[id]=v; return; }
		p<=mid?mdy(p,v,ls):mdy(p,v,rs);
		tag[id]=min(tag[id<<1],tag[id<<1|1]);
	}
	
	inline int Query(int ll,int rr,int id=1,int l=1,int r=n){
		if(ll<=l && r<=rr || tag[id]==inf) return tag[id];
		if(rr<=mid) return Query(lson);
		if(ll> mid) return Query(rson);
		return min(Query(lson),Query(rson));
	}
}sg;

int head[N],tot,In[N];
struct edge{ int to,nxt; }e[N<<1];
inline void addedge(int u,int v){ e[++tot].nxt=head[u]; head[u]=tot; e[tot].to=v; ++In[v]; }

std::priority_queue<int,std::vector<int>,std::greater<int> >q;

int main(){
	io>>n>>k; sg.init(); --k;
	for(int i=1;i<=n;++i) P[io()]=i;
	for(int i=n,ps;i;--i){
		ps=sg.Query(P[i],min(P[i]+k,n));
		(ps^inf)?addedge(P[i],P[ps]):void();
		ps=sg.Query(max(P[i]-k,1),P[i]);
		(ps^inf)?addedge(P[i],P[ps]):void(); sg.mdy(P[i],i);
	}
	for(int i=1;i<=n;++i) (!In[i])?q.push(i):void();
	for(int u,rk=0;!q.empty();){
		Ans[u=q.top()]=++rk; q.pop();
		for(int i=head[u];i;i=e[i].nxt)
			(--In[e[i].to]==0)?q.push(e[i].to):void();
	}
	for(int i=1;i<=n;++i) io<<Ans[i];
	return 0;
}

Measured memory_bytes: 27512
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	//01234567
	//FESTIVAL
	string str;
	cin >> str;
	int size = str.size();
	cout << str.substr(0,size-8) << endl;;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e16;
const ll MOD = 1000000007;  // 1e9 + 7

struct edge {
  int from;
  int to;
  int cost;
  edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

vector<vector<edge>> g;
vector<vector<edge>> revG;

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  --s; --t; // 0-indexed

  g.resize(n);
  revG.resize(n);

  rep(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    --u; --v; // 0-indexed
    g[u].push_back(edge(u, v, a));
    g[v].push_back(edge(v, u, a));
    revG[u].push_back(edge(u, v, b));
    revG[v].push_back(edge(v, u, b));
  }

  // Start dijkstra from s
  vector<ll> start(2);
  start[0] = s;
  start[1] = t;
  vector<vector<ll>> ds(2, vector<ll>(n, INF));
  vector<vector<vector<edge>>> graphs;
  graphs.push_back(g);
  graphs.push_back(revG);

  rep(k, 2) {
    ll st = start[k];
    vector<ll>& d = ds[k];
    auto& g = graphs[k];

    d[st] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(0, st));
    while (!q.empty()) {
      P p = q.top(); q.pop();
      int v = p.second;
      if (d[v] < p.first) { continue; }  // Already updated.
      for (auto e : g[v]) {
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          q.push(P(d[e.to], e.to));
        }
      }
    }
  }
  // cout << "ds[0]: "; printvec(ds[0]);
  // cout << "ds[1]: "; printvec(ds[1]);

  // Here, ans is min of ds[0][i] + ds[1][i]
  vector<ll> dp(n); // min cost at year i. At i, we can use [i, n) as trade
  dp[n-1] = ds[0][n-1] + ds[1][n-1];
  for (int i = n-2; i >= 0; --i) {
    dp[i] = min(dp[i+1], ds[0][i] + ds[1][i]);
  }

  ll initial = (ll)1e15;
  rep(i, n) {
    cout << initial - dp[i] << endl;
  }
}


Measured memory_bytes: 29316
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define EPS (1e-10)
#define INF 1000000000000LL

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

void solve(){
    SIN( s )
    ll ans = 0,now = 0;
    char st[s.size()];
    for( int i = 0; i < s.size(); i++ ){
      if( now != 0 && st[ now - 1 ] == 'S' && s[i] == 'T'){
        now--;
      }else{
        st[now++] = s[i];
      }
    }
    ans = now;
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	if (a - w <= b && b <= a + w) cout << 0 << endl;
	else cout << max(a, b) - min(a, b) - w << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B; std::cin >> A >> B;
  if ( A + B >= 10 ) std::cout << "error" << std::endl;
  else std::cout << A + B << std::endl;
  return 0;
}


Measured memory_bytes: 256