akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
-- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons
getInt = readLn :: IO Int
getInt2Tuple = (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector
getInt3Tuple = (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) <$> getIntVector


main = do
  (a,b) <- getInt2Tuple
  print . length $ solve a b

divisor n = loop 1
  where
    loop d
      | n < d^2 = []
      | n == d^2 = [d]
      | otherwise = if r == 0 then d : q : loop (d+1) else loop (d+1)
      where (q,r) = n `divMod` d

divisorTow a b = sort $ loop 1
  where
    minAB = min a b
    loop d
      | minAB < d^2 = []
      | minAB == d^2 = if ra == 0 && rb == 0 then [d] else []
      | otherwise = if ra == 0 && rb == 0
                    then case (bModqa, aModqb) of (0,0) -> d : qa : qb : loop (d+1)
                                                  (0,_) -> d : qa : loop (d+1)
                                                  (_,0) -> d : qb : loop (d+1)
                                                  (_,_) -> d : loop (d+1)
                    else case (bModqa, aModqb) of (0,0) -> qa : qb : loop (d+1)
                                                  (0,_) -> qa : loop (d+1)
                                                  (_,0) -> qb : loop (d+1)
                                                  (_,_) -> loop (d+1)
      where
        (qa,ra) = a `divMod` d
        (qb,rb) = b `divMod` d
        bModqa = b `mod` qa
        aModqb = a `mod` qb

disjoint [] = []
disjoint (1:xs) = 1 : disjoint (filter (/= 1) xs)
disjoint (x:xs) = x : disjoint (filter (\n -> n `mod` x /= 0) xs)

solve a b = disjoint $ divisorTow a b


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int R; cin >> R;
  if(R < 1200) cout << "ABC";
  else if(R < 2800) cout << "ARC";
  else cout << "AGC";
  return 0;
}


Measured memory_bytes: 256
k = int(input())
lis = [1,2,3,4,5,6,7,8,9]

i = 0
while i<9:
    X = []
    for L in lis:
        if i == 0 or L >= 10**i:
            s = str(L)
            if s[-1] == "0":
                X.append(10*L)
                X.append(10*L+1)
            elif s[-1] == "9":
                X.append(10*L+8)
                X.append(10*L+9)
            else:
                X.append(10*L+int(s[-1])-1)
                X.append(10*L+int(s[-1]))
                X.append(10*L+int(s[-1])+1)
    for x in X:
        lis.append(x)
    i += 1
print(lis[k-1])

Measured memory_bytes: 19424
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll f[1<<6][355],ans;
int n,C,L[15];
int main(){
	cin>>n>>C;
	for(int i=0;i<n;++i)cin>>L[i];
	sort(L,L+n);
	int tot=0,t=(1<<n-1)-1;
	do{
        ++tot;
        memset(f,0,sizeof f);
        f[0][n*L[n-1]]=1; 
        for(int i=1;i<=n*C;++i)if(i%n){
            const int id=i%n-1,t=min(i+L[id]*n,n*C);
            for(int S=0;S<1<<n-1;++S)
            if(!(S>>id&1))
            for(int k=i;k<=n*C;++k)
            f[S|1<<id][max(k,t)]+=f[S][k];
        }
        ans+=f[(1<<n-1)-1][n*C];
    }while(next_permutation(L,L+n-1));
//	do{
//		++tot;memset(f,0,sizeof(f));
//		f[0][n*L[n-1]]=1;
//		for(int i=1;i<=n*C;++i){
//			if(i%n){
//				int id=i%n-1,t=min(i+L[id]*n,n*C);
//				for(int s=0;s<=t;++s){
//					if(!(s>>id&1)){
//						for(int k=i;k<=n*C;++k){
//							f[s|(1<<id)][max(t,k)]+=f[s][k];
//						}
//					}
//				}
//			}
//		}
//		ans+=f[t][n*C];
//	}while(next_permutation(L,L+n-1));
	printf("%.16lf\n",1.0*ans/tot/pow(C,n-1));
	return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double d;
	double x,y;
	int ans=0;
	cin>>n>>d;
	for (int i=1;i<=n;i++){
		cin>>x>>y;
		double w=x*x+y*y;
		w=sqrt(w);
//		cout<<w<<endl;
		if (w<=d)ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		int[] B = new int[n];
		int K = Integer.MIN_VALUE;
		for(int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
			K = Math.max(K,  A[i]);
		}

		count(A, B, K);

		StringBuilder sb = new StringBuilder();
		sb.append(B[0]);
		for(int i = 1; i < n; i++) {
			sb.append(" ").append(B[i]);
		}
		System.out.println(sb);
	}

	public static void count(int[] a, int[] b, int k) {
		int[] C = new int[k + 1];
		for(int i = 0; i < a.length; i++) {
			C[a[i]]++;
		}
		for(int i = 1; i <= k; i++) {
			C[i] = C[i - 1] + C[i];
		}
		for(int i = a.length - 1; i >= 0; i--) {
			C[a[i]]--;
			b[C[a[i]]] = a[i];
 		}
	}

}



Measured memory_bytes: 515664
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void){
	int N;
	while(cin >> N, N) {
		vector<int> back(N);
		for (int i = 0; i < N; i++) {
			cin >> back[i];
		}

		string list;
		cin.ignore();
		getline(cin, list);

		int bi = 0;
		for (int i = 0; i < list.size(); i++) {
			int n = back[bi];
			while (n > 0) {
				if (list[i] == 'a')
					list[i] = 'Z';
				else if (list[i] == 'A')
					list[i] = 'z';
				else
					list[i] = list[i] - 1;

				n--;
			}

			bi = (bi + 1) % N;
		}
		cout << list << endl;
	}
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node	{
		int a,b;
	}x[100005];
int main()
	{
		int m,n;
		scanf("%d%d",&m,&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d%d",&x[i].a,&x[i].b);
		}
		int start=x[0].a;
		int end=x[0].b;
		for(int i=1;i<n;i++)
		{
			start=max(start,x[i].a);
			end=min(end,x[i].b);
		}
		int sum=end-start+1;
		if(sum<0)
		sum=0;
		printf("%d\n",sum);
		return 0;
	}


Measured memory_bytes: 2508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (i % 2 == 0) {
				if (c != 'R' && c != 'U' && c != 'D') {
					System.out.println("No");
					return;
				}
			} else {
				if (c != 'L' && c != 'U' && c != 'D') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 21844
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

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

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

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

if B - A < K*2:
    for i in range(A, B+1):
        print(i)
else:
    for a in range(A, A+K):
        if a > B:
            break
        print(a)

    for b in range(B-K+1, B+1):
        print(b)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N, P;
	cin >> N >> P;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<vector<lint>>dp(N + 1, vector<lint>(2));
	dp[0][0] = 1;
	dp[0][1] = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 1) {
			dp[i + 1][1] = dp[i][1] + dp[i][0];
			dp[i + 1][0] = dp[i][1] + dp[i][0];
		}
		else if (A[i] % 2 == 0) {
			dp[i + 1][1] = dp[i][1] * 2;
			dp[i + 1][0] = dp[i][0] * 2;
		}
	}
	cout << dp[N][P] << endl;
}


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

#define ll long long
const int mod = 1000000007;

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); 

	int n;
	cin >> n;
	string s;
	cin >> s;
	int redoop = 0;
	int cnt = 0;
	int index = 0;
	for (int i = 0; i < n; i++){
		if (cnt == 0){
			if (s[i] == 'W'){
				cnt++;
				index = i;
			}
		} else if (cnt == 1){
			if (s[i] == 'R'){
				redoop++;
			}
		}
	}
	int ans = 0;

	//cout << "index " << index << " redoop " << redoop << endl;;

	if (redoop == 0){
		cout << 0;
		return 0;
	}

	for (int i = index; i < n; i++){
		if (s[i] == 'W' && redoop > 0){
			ans++;
			redoop--;
		} else if (s[i] == 'R'){
			redoop--;
		}
	}

	cout << ans;

	
}

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

using namespace std;

#define int long long

struct LCA
{
  vector< vector<int> > tree, parent;
  vector<int> depth;
  int log_V;
  LCA(int V)
  {
    log_V = 1;
    while((1 << log_V) <= V) log_V++;
    tree.resize(V);
    parent.resize(log_V, vector<int>(V, -1));    
    depth.resize(V);
  }
  void add_edge(int u, int v, bool bi = true)
  {
    tree[u].emplace_back(v);
    if(bi) tree[v].emplace_back(u);    
  }
  void dfs(int u, int p, int d)
  {
    parent[0][u] = p;
    depth[u] = d;
    for(auto v : tree[u]) {
      if(v != p) dfs(v, u, d + 1);
    }
  }
  void init(int root = 0)
  {
    dfs(root, -1, 0);
    for(int i = 0; i + 1 < log_V; i++) {
      for(int v = 0; v < parent[i].size(); v++) {
	if(parent[i][v] < 0) parent[i + 1][v] = -1;
	else parent[i + 1][v] = parent[i][parent[i][v]];
      }
    }
  }
  int trace(int u, int v)
  {
    if(depth[u] > depth[v]) swap(u, v);
    for(int i = 0; i < log_V; i++) {
      if((depth[v] - depth[u]) >> i & 1) v = parent[i][v];
    }
    if(u == v) return u;
    for(int i = log_V-1; i >= 0; i--) {
      if(parent[i][u] != parent[i][v]) u = parent[i][u], v = parent[i][v];
    }
    return parent[0][u];
  }
  int dist(int u, int v) {
    return depth[u] + depth[v] - 2*depth[trace(u, v)];
  }
};

signed main()
{
  int n; cin >> n;
  LCA lca(n);
  for(int i = 1; i < n; i++) {
    int p; cin >> p; p--;
    lca.add_edge(p, i, false);
  }
  lca.init();
  int ans = 0, prev = 0;
  queue<int> que; que.push(0);
  while(!que.empty()) {
    int now = que.front(); que.pop();
    ans += lca.dist(prev, now);
    for(int to : lca.tree[now]) que.push(to);
    prev = now;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 25892
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans;
    if(k<=a){
        ans=k;
    }
    if(a<k&&k<=a+b){
        ans=a;
    }
    if(a+b<k&&k<=a+b+c) {
        ans=a-(k-(a+b));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int x, y, z;
    cin >> x >>y  >> z;
    cout << (x + y + z >= 22 ? "bust" : "win") << endl;
    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.format;

auto dp (int n, int c, string s) {
  auto d = new int[n+1];
  d[n] = 0;
  foreach_reverse (i; 0 .. n) {
    debug stderr.writeln ("i = ", i);
    d[i] = d[i+1];
    if (s[i] == 'o') {
      int j = i + 1 + c;
      int v = (j <= n) ? d[j] : 0;
      d[i] = max (d[i], 1 + v); 
    }
  }
  return d;
}

bool[] go (string s, int n, int k, int c, in int[] d1, in int[] d2) {
  auto can = new bool[n];
  int last = -1;
  foreach (i; 0 .. n) {
    if (s[i] == 'x') continue;
    int v1 = 0, j = i + 1;
    if (last >= 0) {
      v1 = d2[last];
      j = max (j, last + 1 + c);
    }
    int v = v1;
    if (j < n) v += d1[j];
    debug stderr.writefln ("i = %d, j = %d, v1 = %d, v = %d", i, j, v1, v);
    if (v >= k) can[i] = true;
    last = i;
  }
  return can;
}

//Modification on semi-interval, single element access
final class SegmentTreeSliceUpdate(T = int) {
  private:
  T [] t;
  size_t n;
  pure nothrow @nogc
  void push () {
    foreach (i; 1 .. n) {
      immutable k = i << 1;
      t[k] = t[k] + t[i];
      t[k+1] = t[k+1] + t[i];
      t[i] = 0;
    }
  }
  pure nothrow @nogc
  void update (size_t l, size_t r, T v) {
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) {
        t[l++] += v;
      }
      if (r & 1) {
        t[--r] += v;
      }
    }
  }
  public:
  pure nothrow @nogc
  inout(T) opIndex (size_t index) inout {
     T res;
     for (index += n; index > 0; index >>= 1) {
       res += t[index];
     }
     return res;
  }
  pure nothrow
  const(T[]) force () {
    push ();
    return t[n .. 2 * n].idup;
  }
  pure nothrow
  this (int _n) {
    n = _n;
    t = new T[2 * n];
  }
}

void main() {
  int n, k, c;
  auto s = readln;
  formattedRead (s, " %d %d %d", &n, &k, &c);
  s = readln[0 .. n];
  if (c == 0) {
    auto cnt = s.count('o');
    if (cnt == k) {
      foreach (i; 0 .. n) if (s[i] == 'o') writeln (i+1);
    }
    return;
  }
  auto d1 = dp (n, c, s);
  d1.popBack ();
  auto t = s.dup;
  t.reverse ();
  auto s2 = t.idup;
  auto d2 = dp (n, c, s2);
  d2.reverse ();
  d2 = dropOne (d2);
  auto st = new SegmentTreeSliceUpdate!int (n);
  debug stderr.writeln ("d1 = ", d1);
  debug stderr.writeln ("d2 = ", d2);
  //d1 -> right
  //d2 -> left
  void upd (int u1, int u2) {
    debug stderr.writefln ("[%d, %d)", u1, u2);
    if (u1 < u2) st.update (u1, u2, 1);
  }
  foreach (i; 0 .. n) {
    if (s[i] == 'o') {
      debug stderr.writeln (i);
      int v = d2[i];
      int j = i + (c + 1);
      if (j < n) v += d1[j]; 
      if (v >= k) {
        upd (i + 1, min (j, n));
      }
      v = d1[i];
      j = i - (c + 1);
      if (j >= 0) v += d2[j]; 
      if (v >= k) {
        upd (max (0, j + 1), i);
      }
    }
  }
  foreach (i; 0 .. n) if (!st[i] && s[i] == 'o') writeln (i + 1);
}



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

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

  int N;
  cin >> N;
  vector<int64_t> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int64_t ans = 0;
  sort(A.begin(), A.end());
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int64_t san = A[i] + A[j];
      int64_t ans1 = lower_bound(A.begin(), A.end(), san) - A.begin();
      ans1 -= j+1;
      int64_t nul = 0;
      ans1 = max(ans1, nul);
      ans += ans1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int math[50][3],sum[50];
	int i,j,k;
	i=0;
	for(;;){
		for(j=0;j<3;j++){
			scanf("%d",&math[i][j]);
		}
		if(math[i][0]==-1&&math[i][1]==-1&&math[i][2]==-1) break;
		sum[i]=math[i][0]+math[i][1];
		i++;
		if(i==50) break;
	}

	for(k=0;k<i;k++){
		if(math[k][0]==-1||math[k][1]==-1) printf("F\n");
		else if(sum[k]>=80) printf("A\n");
		else if(sum[k]>=65) printf("B\n");
		else if(sum[k]>=50) printf("C\n");
		else if(sum[k]>=30&&math[k][2]>=50) printf("C\n");
		else if(sum[k]>=30) printf("D\n");
		else printf("F\n");
	}
	return 0;
}



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

int main(){
  int P,Q,R;
  cin>>P>>Q>>R;
  int ans=100000;
  int PQ=P+Q;
  int PR=P+R;
  int QR=Q+R;
  ans=min({ans,PQ,PR,QR});
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != t[i]) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
typedef long long ll;
int main()
{
    string s,ans;
    cin>>s;
    for(int i=0;i<s.size();i++)
        if(s[i]=='?') ans+='D';
        else ans+=s[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3584
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        

N, M = map(int, input().split())
AB = []
for i in range(M):
    AB.append(list(map(int, input().split())))
AB.reverse()
    
uf = UnionFind(N)
ans = [N*(N-1)//2]
for i in range(M-1):
    A, B = AB[i]
    if uf.find(A-1) == uf.find(B-1):
        ans.append(ans[i])
    else:
        ans.append(ans[i] - uf.size(A-1) * uf.size(B-1))
    uf.union(A-1, B-1)
    
ans.reverse()
for i in range(M):
    print(ans[i])

Measured memory_bytes: 33460
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i, N) cin >> vec.at(i);

    vector<int> srt = vec;
    sort(all(srt));

    int cnt = 0;
    rep(i, N) {
        if(vec.at(i) != srt.at(i)) cnt++;
    }

    cout << (cnt >= 3 ? "NO" : "YES") << endl;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[0]>='A' && s[0]<='Z') cout << "A";
	else cout << "a";
	return 0;
}

Measured memory_bytes: 3624
// This program converts a given seconds
// to hours, minutes and seconds
#include <iostream>
using namespace std;

int main(){

  // input the time in seconds
  int time;
  cin >> time;
  
  // convert to hours
  int hours=0;
  if(time>=3600){
    hours = time/3600;
    time = time%3600;
  }
  // convert to minutes
  int minutes=0;
  if(time>=60){
    minutes = time/60;
    time = time%60;
  }
  // convert to seconds
  int seconds;
  seconds = time;

  // print h,m,s
  cout << hours << ":" << minutes << ":" << seconds << endl;
  
  return 0;
}

Measured memory_bytes: 3048
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  
  int n;
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
  }  
  else {
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }


return 0;
}
///....


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		// input
		long left = scan.nextLong();
		long right = scan.nextLong();

		// check
		long min = Long.MAX_VALUE;
		fin: for(long i = left; i < right; i++) {
			for(long j = i + 1; j <= right; j++) {
				if(i * j % 2019 < min) {
					min = i * j % 2019;
				}
				if(j % 2019 == 0 || i % 2019 == 0) {
					min = 0;
					break fin;
				}
			}
		}

		System.out.println(min);
	}
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;

vector<ll> cnt(100000);
void solve(long long N, std::vector<long long> A, long long Q, std::vector<long long> B, std::vector<long long> C) {
    ll ans = accumulate(A.begin(), A.end(), 0L);
    rep(i, N) { cnt[A[i]]++; }
    rep(i, Q) {
        ll before = cnt[B[i]];
        cnt[C[i]] += before;
        cnt[B[i]] = 0;
        ans -= before * B[i];
        ans += before * C[i];
        cout << ans << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for (int i = 0; i < Q; i++) {
        scanf("%lld", &B[i]);
        scanf("%lld", &C[i]);
    }
    solve(N, std::move(A), Q, std::move(B), std::move(C));
    return 0;
}


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

int main(void)
{
    char buf[5];
    int A,B;
    int ans = -1;
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf,"%d %d",&A, &B);
    if (A<10 && B<10) {
        ans = A*B;
    }
    printf("%d", ans);
}

Measured memory_bytes: 128
function Main(input) {
  switch (input) {
    case "A":
      console.log('T');
      break;
    case "T":
      console.log('A');
      break;
    case "G":
      console.log('C');
      break;
    case "C":
      console.log('G');
      break;
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

void trace(int A[],int N){
int i;
for(i=0;i<N;i++){
if(i>0)printf(" ");
printf("%d",A[i]);
}
printf("\n");
}

void insertionSort(int A[],int N){
int j,i,v;
for(i=1;i<N;i++){
v=A[i];
j=i-1;
while(j>=0&&A[j]>v){
A[j+1]=A[j];
j--;
}
A[j+1]=v;
trace(A,N);
}
}

int main(){
int N,i,j;
int A[100];

scanf("%d",&N);
for(i=0;i<N;i++)scanf("%d",&A[i]);

trace(A,N);
insertionSort(A,N);

return 0;
}

Measured memory_bytes: 2740
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
int A[3];
 
cin >> A[0] >> A[1] >> A[2];
 
sort(A,A+3);
 
cout << A[0]  << " "<< A[1] << " " <<A[2] << endl;
 
}

Measured memory_bytes: 3096
n = int(input())

towns = []
for i in range(n):
    x, y = map(int, input().split())
    towns.append((x, y))

from itertools import permutations

res = 0
cnt = 0

for lst in permutations([i for i in range(n)], n):
    r = 0
    cnt += 1
    for i in range(n - 1):
        t1 = towns[lst[i]]
        t2 = towns[lst[i - 1]]
        r += ((t1[0] - t2[0]) ** 2 + (t1[1] - t2[1]) ** 2) ** 0.5

    res += r

print(res / cnt)

Measured memory_bytes: 42864
#include<cstdio>
#include<map>
#define fi first
#define se second
using std::map;
const int N=1e5+5;
int n;
int a[N];
map<int,int> M;
signed main()
{
	int a,b,c;
	register int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&::a[i]),M[::a[i]]++;
	if((int)M.size()>3)
		return puts("No"),0;
	if(n%3==0)
	{
		switch((int)M.size())
		{
			case 1:
				if(::a[1]==0) 
					puts("Yes");
				else
					puts("No");
				break;
			case 2:
				a=M.begin()->se;
				b=(++M.begin())->se;
				if(((++M.begin())->fi==0&&a==b*2)||(M.begin()->fi==0&&b==a*2))
					puts("Yes");
				else
					puts("No");
				break;
			case 3:
				a=M.begin()->se;
				b=(++M.begin())->se;
				c=(++(++M.begin()))->se;
				if((M.begin()->fi^(++M.begin())->fi^(++(++M.begin()))->fi)==0&&a==b&&a==c)
					puts("Yes");
				else
					puts("No");
		}
	}
	else
	{
		if((int)M.size()>1)
			puts("No");
		else if(::a[1]==0)
			puts("Yes");
		else
			puts("No");
	}
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
using namespace std;
long long N,X;
long long solve(long long a,long long b)
{
    if(a%b==0) return ((a/b)*2-1)*b;
    if(!b)return 0;
    return 2*b*(a/b)+solve(b,a%b);
}
int main()
{
    cin>>N>>X;
    long long a=X,b=N-X;
    if(a<b)swap(a,b);
    cout<<N+solve(a,b);
    return 0;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

int sumdigit(int x){
    int sum=0;
    while(x){
        sum += x % 10;
        x /= 10;
    }

    return sum;
}

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

    int ans= (1 << 30);
    for (int i = 1; i <= n/2; i++) {
        ans = min(ans, sumdigit(i) + sumdigit(n-i));
    }

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

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,k,q;
long long d[100005];
vector<pair<int,int> > g[100005];
void dfs(int x,int p){
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i].first,c=g[x][i].second;
		if(u==p)continue;
		d[u]=d[x]+c;
		dfs(u,x);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;i++){
		int u,v,c;
		cin>>u>>v>>c;
		u--;
		v--;
		g[u].push_back(make_pair(v,c));
		g[v].push_back(make_pair(u,c));
	}
	cin>>q>>k;
	dfs(--k,-1);
	while(q--){
		int u,v;
		cin>>u>>v;
		cout<<d[--u]+d[--v]<<endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,a.size()){
        cin>>a[i];
    }
    vector<int> b(n);
    vector<int> dif;
    rep(i,0,b.size()){
        cin>>b[i];
        dif.pb(a[i]-b[i]);
    }
    sort(all(dif),greater<int>());
    int ans = 0;
    int sum = 0;
    rep(i,0,dif.size()){
        sum += dif[i];
        ans = max(ans,sum);
    }
    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

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;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int n, m;
    cin >> n >> m;

    Unionfind tree(n);

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

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        tree.unite(x, y);
    }

    int cnt = 0;
    rep(i, n) {
        if(tree.same(i, p[i]-1)) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3996
N, K = list(map(int, input().split()))
Hs = list(map(int, input().split()))

MAX = 10 ** 9
dp = [0] * N
for i in range(1, N):
    m = MAX
    for j in range(max(0, i - K), i):
        t = abs(Hs[i] - Hs[j]) + dp[j]
        if m > t:
            m = t
    dp[i] = m
print(dp[N - 1])

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int r, g, b;
    cin >> r >> g >> b;
    int ans = 100 * r + 10 * g + b;
    if (ans % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

#define ll long long

using namespace std;

int main(void){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        int keta = 0;
        int ii = i;
        while(ii > 0){
            ii /= 10;
            keta++;
        }
        ans += (keta % 2 == 1) ? 1 : 0;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <tuple<string, int, int> > res;
	for (int ii = 0; ii < N; ++ii){
		string S;
		int P;
		cin >> S >> P;
		res.push_back(make_tuple(S, -P, ii+1));
	}
	sort(res.begin(), res.end());

	for (int ii = 0; ii < N; ++ii){
		cout << get<2>(res[ii]) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if grid[i][j] == '#':
            if i - 1 >= 0 and grid[i - 1][j] == '#':
                continue
            if i + 1 <= h - 1 and grid[i + 1][j] == '#':
                continue
            if j - 1 >= 0 and grid[i][j - 1] == '#':
                continue
            if j + 1 <= w - 1 and grid[i][j + 1] == '#':
                continue
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
N, W = map(int, input().split())
INF = float('inf')
weight = [0] * N
value = [0] * N
Max_v = 0
for i in range(N):
    w, v = map(int, input().split())
    weight[i], value[i] = w, v
    Max_v += v

dp = [[INF]*(Max_v+1) for _ in range(N)]
# dp[i][vs] : i番目までの品物から総価値がvs以上になるように選んだ時の総重量の最小値

for i in range(0, value[0]+1):
    dp[0][i] = weight[0] if i else 0

for i in range(1, N):
    for vs in range(Max_v+1):
        if vs - value[i] >= 0:
            dp[i][vs] = dp[i-1][vs - value[i]] + weight[i]
        else:
            dp[i][vs] = weight[i]
        dp[i][vs] = min(dp[i][vs], dp[i-1][vs])

for i in reversed(range(Max_v+1)):
    if dp[N-1][i] <= W:
        print(i)
        break


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    s[i] = (s[i]-'A'+ n)%26+'A';
  }
  cout << s << endl;
  
  return 0;
}


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

using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    map<int, ll> cnt;
    int sum = 0;
    cnt[0] += 1;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        (sum += a[i]) %= m;
        cnt[sum] += 1;
    }

    ll ans = 0;
    for(auto& p : cnt) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
string S;

int main() {
    cin >> N >> S;
    ll tmp = 0;
    for(auto c : S) {
        if(c == '.') tmp++;
    }
    ll ans = tmp;
    for(auto c : S) {
        if(c == '.') tmp--;
        else tmp++;
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  string s;
  cin >> s;
  cout << s.substr(0, s.size() - string("FESTIVAL").size()) << endl;
  return 0;
}


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

#define nguyendz the_best
using namespace std;

#define ll long long
#define endl "\n"
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
#define setpre(x) fixed<<setprecision(x)


const ll maxn=5e3+100;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1 =998244353;
const ll base=31;


pll a[maxn];
ll dp[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    ll n,k;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i].ff;
        a[i].ss=i;
    }
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    dp[0][0]=0;
    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<=i;j++)
        {
            ll lf=i -j;
            ll rt= j ;
            if (i!=j)
            {
                dp[lf][rt]=max(dp[lf][rt],dp[lf-1][rt]+a[i].ff*(abs(a[i].ss-lf)));
            }
            if (j>0)
            {
                dp[lf][rt]=max(dp[lf][rt],dp[lf][rt-1]+a[i].ff*(abs(n-rt+1-a[i].ss)));
            }
        }
    }
    ll t=0;
    for (int i=0;i<=n;i++)
    {
        t=max(t,dp[i][n-i]);
    }
    cout <<t;
}


Measured memory_bytes: 27312
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
	int N;
	cin >> N;

	vector<int> b(N);
	for (int i = 0; i < N; i++)
		cin >> b[i];

	bool flag = true;
	vector<int> ans(N);
	for (int i = N-1; i >= 0&&flag; i--) {
		flag = false;
		for (int j = i; j >= 0; j--) {
			if (b[j] <= i + 1 && j+1 == b[j]) {
				ans[i] = b[j];
				b.erase(b.begin() + j);
				flag = true;
				break;
			}
		}
	}

	if (flag) {
		for (int i = 0; i < N; i++) {
			cout << ans[i] << endl;
		}
	}
	else
		cout << -1 << endl;
}


Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))
A=sorted(A)
import numpy as np
A=np.array(A,dtype="int64")
Z=A[A==0]
H=A[A<0]
S=A[A>0]
l,r=-10**19,10**19
while r-l>1:
  mid=(r+l)//2
  cnt=0
  cnt+=A.searchsorted(mid//S,side="right").sum()
  cnt+=(N-A.searchsorted((-mid-1)//(-H),side="right")).sum()
  cnt-=np.count_nonzero(A*A<=mid)
  if mid>=0:
    cnt+=len(Z)*N 
  cnt//=2
  if cnt>=K:
    r=mid
  else:
    l=mid 
print(r)


Measured memory_bytes: 35404
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include<map>

using namespace std;

int main()
{
    int N, P;
    string S;
    vector<int> mod, dmod;

    cin >> N >> P;
    cin >> S;
    reverse(S.begin(), S.end());
    if(P != 2 && P != 5){
        mod.resize(S.size());
        dmod.resize(S.size());
        map<int, int> modCount;
        modCount[0] = 1;
        dmod[0] = 1;
        mod[0] = (S[0] - '0') % P;
        if (!modCount.count(mod[0]))
        {
            modCount[mod[0]] = 1;
        }
        else
        {
            modCount[mod[0]]++;
        }

        for (int d = 1; d < S.size(); d++){

            dmod[d] = (dmod[d-1] * 10) % P;
            mod[d] = ((S[d] - '0') * dmod[d] + mod[d-1]) % P;
            if(!modCount.count(mod[d])){
                modCount[mod[d]] = 1;
            }else{
                modCount[mod[d]]++;
            }
        }

        long long result = 0;
        for (auto itr = modCount.begin(); itr != modCount.end(); itr++){
            long long n = itr->second;
            result += n * (n - 1) / 2;
        }

        cout << result << endl;
    }else{
        long long result = 0;
        for (int i = 0; i < S.size(); i++){
            if((S[i] - '0')%P == 0){
                result += S.size() - i;
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 5392
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
ll mod = 1e9+7;

int main(){
    ld res = 0;
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    vector<ll> v(n);
    iota(v.begin(), v.end(), 0);
    std::cout << std::fixed;
    rep(i, facctorialMethod(n)){
        rep(j, n-1){
            res += sqrt((x[v[j]] - x[v[j+1]]) * (x[v[j]] - x[v[j+1]]) + (y[v[j]] - y[v[j+1]]) * (y[v[j]] - y[v[j+1]]));
        }
        
//        cout << fixed << res << endl;
        next_permutation(v.begin(), v.end());
    }
    res /= facctorialMethod(n);
    cout << setprecision(10) << res <<  endl;
    return 0;
}


Measured memory_bytes: 256