akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    int a,b,k,m=0,n;
    cin>>a>>b>>k;
    n=min(a,b);
    for(int i=n;i>=1;i--){
        if(a%i==0&&b%i==0)
            m++;
        if(m==k){
            cout<<i<<endl;
            return 0;
        }
    }
}


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

#define int long long
#define vi vector <int>
#define endl "\n"
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
const int N=1e5+5 , MOD=1e9+7;

int a[N];

//---------------------------------------------------------------


void solve()
{
    int n,x=0,y=0,z=0;
    cin >> n;
    rep(i,0,n)
    {
    	cin >> a[i];
    }
    x=0;
    y = abs(a[1]-a[0]);
    z=y;
    rep(i,2,n)
    {
    	z = min(x+abs(a[i]-a[i-2]), y+abs(a[i]-a[i-1]));
    	x=y;
    	y=z;
    }

    cout << z << endl;

}

signed main()
{
    speed;
    
 //    int t; cin >> t;
 //    rep(tt,1,t+1)
 //    {
	// cout <<"Case #"<<tt<<": ";
	solve();
 //    }
    return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EEquilateral {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w; cin >> h >> w;
      vector<vector<int>> mat(600, vector<int>(600));
      rep(i, h) {
        rep(j, w) {
          char c; cin >> c;
          if (c == '#') {
            mat[i+j][i-j+300] = 1;
            debug(i+j, i-j+300);
          }
        }
      }

      vector<vector<int>> mat1(601, vector<int>(601));
      rep(i, 600) {
        rep(j, 600) {
          mat1[i][j+1] += mat1[i][j] + mat[i][j];
        }
      }
      vector<vector<int>> mat2(601, vector<int>(601));
      rep(j, 600) {
        rep(i, 600) {
          mat2[i+1][j] += mat2[i][j] + mat[i][j];
        }
      }

      ll ret = 0;
      rep(i, 600) {
        rep(j, 600) {
          for(int k=j+1; k<600; k++) {
            if (mat[i][j] && mat[i][k]) {
              int d = k-j;
              if (i-d >= 0) {
                ret += mat1[i-d][k+1] - mat1[i-d][j];
              }
              if (i+d < 600) {
                ret += mat1[i+d][k+1] - mat1[i+d][j];
              }
            }
            if (mat[j][i] && mat[k][i]) {
              int d = k-j;
              if (i-d >= 0) {
                ret += mat2[k][i-d] - mat2[j+1][i-d];
              }
              if (i+d < 600) {
                ret += mat2[k][i+d] - mat2[j+1][i+d];
              }
            }
          }
        }
      }
      cout << ret << endl;



    }
};

signed main() {
  EEquilateral solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

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

	int fh = n / 500; //number of five-hundred
	int f = (n % 500) / 5; //number of fives;

	//cout << fh << endl << f;

	cout << 1000 * fh + 5 * f << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int N, M;
  cin >> N >> M;
  vector<queue<int>> list(N, queue<int>());
  vector<int> jlist(N, -1);
  rep(i,M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    list.at(a).push(b);
    list.at(b).push(a);
  }
  queue<int> q;
  while(!list.at(0).empty()) {
    int a;
    a = list.at(0).front();
    list.at(0).pop();
    q.push(a);
    jlist.at(a)=0;
  }
  
  while(!q.empty()) {
    int a;
    a = q.front();
    q.pop();
    while(!list.at(a).empty()) {
      int b;
      b = list.at(a).front();
      list.at(a).pop();
      if(jlist.at(b)==-1) {
        q.push(b);
        jlist.at(b) = a;
      }
    }
  }
  
  rep(i, N) {
    jlist.at(i)++;
  }
  
  string ans="Yes";
  for(int i = 1; i<N; i++) {
    if(jlist.at(i)==0) {
      ans = "No";
      break;
    }
  }
  
  if(ans=="No") cout << ans << endl;
  else {
    cout << ans << endl;
    for(int i = 1; i<N; i++) {
      cout << jlist.at(i) << endl;
    }
  }
}

Measured memory_bytes: 71320
#include<stdio.h>
int main(void)
{
	int lena,lenb,lenc;
	scanf("%d %d %d",&lena,&lenb,&lenc);
	while(1){
		if(lena==5&&lenb==7&&lenc==5){
			printf("YES\n");
			break;
		}
		if(lena==5&&lenb==5&&lenc==7){
			printf("YES\n");
			break;
		}
		if(lena==7&&lenb==5&&lenc==5){
			printf("YES\n");
			break;
		}
		printf("NO\n");
		break;
	}
	return 0;
}


Measured memory_bytes: 128
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1276

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

#define PRIME_MAX 1300000

using namespace std;

int main()
{
	int K;
	bool is_prime[PRIME_MAX];
	is_prime[0] = false;
	is_prime[1] = false;
	REP(i,2,PRIME_MAX) is_prime[i] = true;
	REP(i,2,PRIME_MAX) {
		if (is_prime[i]) {
				for (int j=i+i; j<PRIME_MAX; j+=i) is_prime[j] = false;
		}	
	}

	while(cin >> K && K)
	{
		int left_prime, right_prime;
		for(int lt=K; lt>0; --lt)
		{
			if(is_prime[lt]){ 
				left_prime = lt;
				break;
			}
		}

		for(int rt=K; rt<PRIME_MAX; ++rt)
		{
			if(is_prime[rt]){
				right_prime = rt;
				break;
			}
		}

		cout << right_prime - left_prime << endl;
	}
	return 0;
}

Measured memory_bytes: 2424
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

// reference: https://atcoder.jp/contests/abc162/submissions/11881922

/*
 -> crux: identifying the required states

 -> here, I have alloted two states to odd-indexed elements
    dp[i][0] -> picking floor(n/2) elements before 'i'
    dp[i][1] -> picking ceil(n/2) elements before 'i'
 -> for even-indexed elements, I require only one state i.e. picking n/2 elements before 'i'
*/

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    int dp[n][2];
    mem(dp,0);

    dp[0][0]=0,dp[0][1]=v[0];
    dp[1][0]=max(v[0],v[1]);

    for(int i=2;i<n;++i)
    {
        if(i%2==0)
        {
            dp[i][0]=max(dp[i-1][0],dp[i-2][0]+v[i]);
            dp[i][1]=dp[i-2][1]+v[i];
        }
        else
            dp[i][0]=max(dp[i-1][1],dp[i-2][0]+v[i]);
    }

    cout<<dp[n-1][0];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 7884
require 'complex'

n, d = gets.chomp.split(" ").map(&:to_i)
spots = []
n.times do
  spots << gets.chomp.split(" ").map(&:to_i)
end

sum = 0
spots.each_with_index do |spot1, index1|
  spots.each_with_index do |spot2, index2|
    if spot1 == spot2
      next
    end
    distance = 0.0
    d.times do |dimention|
      distance += (spot1[dimention] - spot2[dimention]).abs.to_f ** 2
    end
    distance = Math.sqrt(distance)
    if distance.ceil == distance.floor
      sum += 1
    end
  end
end

puts sum / 2

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL sum[900000]={0},px[900000],py[900000];
LL h,w,d,q,l,r;
int main(){
	LL i,j,k;
	cin>>h>>w>>d;
	for(i=1;i<=h;i++)for(j=1;j<=w;j++){
		cin>>k;
		px[k]=i;	py[k]=j;
	}
	j=h*w;
	for(i=d+1;i<=j;i++){
		k=i-d;
		sum[i]=sum[k]+abs(px[i]-px[k])+abs(py[i]-py[k]);
	}
	cin>>q;
	while(q--){
		cin>>l>>r;
		cout<<sum[r]-sum[l]<<endl;
	}
	return 0;
}

Measured memory_bytes: 7936
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
	long long int a,n, b, c, d, i, j, k, m=-1, l, t,mi=1000000000;
    vector<long long int>u,v;
    cin >> n >> k;
    for (i = 0,j=1; i < n; i++)
    {
        cin >> a;
        if (j)
        {
            if (a >= 0)
            {
                m = i;
                j--;
                goto again;
            }
       
            v.push_back(abs(a));
            u.push_back(2 * abs(a));
            
        }
        else
        {
            again:
            v.push_back(2*a);
            u.push_back(a);
        }
        if (v.size() >= k)
        {
            if (m == -1)
            {
                mi = (mi < v[i - k + 1]) ? mi : v[i - k + 1];
                mi = (mi < u[i - k + 1]) ? mi : u[i - k + 1];
            }
            else if (i - k + 1 >= m)
            {
                mi = (mi <= u[i])? mi:u[i];
            }
            else
            {
                long long int x = v[i - k + 1] + v[i];
                long long int y = u[i - k + 1] + u[i];
                mi = min(mi, min(x, y));
            }
        }
    }
    cout << mi << endl;

    
    return 0;
}

Measured memory_bytes: 2036
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import gcd, ceil
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    N = int(input())
    A = [int(c) for c in input().split()]
    count = 1
    for i in range(len(A)):
        count *= A[i]
        if count > 10 ** 18:
            count = 10 ** 18 + 1
    if count > 10 ** 18:
        print(-1)
        sys.exit()
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39992
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);



int main() {
  int n; cin >> n;
  int s = n/111;

  if (n%111 != 0) s++;
  cout << s *111 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
buf = sys.stdin.buffer


def main():
    n = int(buf.readline())
    XY = map(int, buf.read().split())
    Xs = []
    Ys = []
    for i, (x, y) in enumerate(zip(XY, XY)):
        Xs.append((x-1, i))
        Ys.append((y-1, i))

    Xs.sort()
    Ys.sort()

    edges = [[] for _ in range(n)]
    for i, ((x, node), (nx, new_node)) in enumerate(zip(Xs[:-1], Xs[1:])):
        edges[node].append((nx-x, new_node))
        edges[new_node].append((nx-x, node))

    for i, ((y, node), (ny, new_node)) in enumerate(zip(Ys[:-1], Ys[1:])):
        edges[node].append((ny-y, new_node))
        edges[new_node].append((ny-y, node))

    seen = [False] * n
    dist = [float('INF')] * n
    todo = [(0, 0)]

    while todo:
        d, node = heappop(todo)
        if seen[node]:
            continue
        seen[node] = True
        dist[node] = d

        while edges[node]:
            edge = edges[node].pop()
            nd, to = edge
            if dist[to] <= nd:
                continue
            heappush(todo, (nd, to))

    print(sum(dist))


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
	char str[101];
	while (scanf("%s", &str) != EOF){
		for (int i = 0; str[i] != '\0'; i++){
			if (str[i] == '@'){
				for (int j = 0; j < (str[i+1] - '0'); j++){
					cout << str[i+2];
				}
				i += 2;
			}
			else
				cout << str[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1144
import sys
import operator


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    m = [list(map(int, input().split())) for i in range(n)]
    m.sort(key=operator.itemgetter(1))
    sumTime = 0
    for i in m:
        sumTime += i[0]
        if sumTime > i[1]:
            print("No")
            exit()
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 82780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep)(__VA_ARGS__)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}

bool prime[1000001];
int main(){
    prime[0]=prime[1]=1;
    rep(i,2,1000001){
        if(!prime[i])for(ll j=i<<1;j<1000001;j+=i)prime[j]=1;
    }
    int n;
    while(cin>>n,n){
        int ans=0;
        rep(i,3,n/2+1,2)if(!prime[i]&&!prime[n-i])ans++;
        out(ans);
    }
}















Measured memory_bytes: 4052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String str = reader.readLine();
			String[] arr = str.split(" ");
			int W = Integer.parseInt(arr[0]);
			int H = Integer.parseInt(arr[1]);
			int x = Integer.parseInt(arr[2]);
			int y = Integer.parseInt(arr[3]);
			int r = Integer.parseInt(arr[4]);

			if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 24312
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
#define readV(_v) rep(j, _v.size()) cin >> _v[j];
#define readVV(_vv) rep(i, _vv.size()) readV(_vv[i]);
#define print(_x) cout << _x << endl;

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

struct edge {
    int to, cost;
    edge(){}
    edge(int _to, int _cost) : to(_to), cost(_cost) {}
};
typedef vector<vector<edge>> Graph;
int dijkstra(const Graph& G, int s, int g) {
    int n = G.size();
    priority_queue<Pii, vector<Pii>, greater<Pii>> pq;   // cost, vertex
    vi d(n, inf);
    d[s] = 0;
    pq.push(make_pair(0, s));

    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        int v = p.second;
        if (v == g) break;
        if (d[v] < p.first) continue;
        for (const auto& e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(make_pair(d[e.to], e.to));
            }
        }
    }
    return d[g];
}

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

    int N, M, K;
    cin >> N >> M >> K;
    vi D(M);
    rep(i, M) {
        cin >> D[i];
        D[i]--;
    }
    sort(all(D));
    vvi v(N, vi(K));
    rep(i, N) {
        rep(j, K) {
            cin >> v[i][j];
            v[i][j]--;
        }
    }

    map<int, int> mp;
    rep(i, M) {
        mp[D[i]] = i;
    }

    Graph G(1 << M);
    rrep(state, 1 << M) {
        rep(j, K) {
            int nstate = 0;
            rep(i, M) {
                if (!((state >> i) & 1)) continue;
                if (!mp.count(v[D[i]][j])) continue;
                nstate |= (1 << mp[v[D[i]][j]]);
            }
            if (nstate != state) {
                G[state].emplace_back(nstate, 1);
            }
        }
    }

    print(dijkstra(G, (1 << M) - 1, 0));
}

Measured memory_bytes: 138192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

struct UnionFind{
  
  std::vector<int> data;
  
  UnionFind(int size): data(size, -1) {}
  
  bool unite(int x, int y){
    x=root(x);
    y=root(y);
    if( x != y ){
      if( data[y] < data[x] ) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x!=y;
  }

  bool find(int x, int y){
    return root(x) == root(y);
  }
  
  int root(int x){
    return (data[x] < 0)? x : data[x]=root(data[x]);
  }
  
  int size(int x){
    return -data[root(x)];
  }
};

// #define get_index(a) data[(a)]
template < typename T >
struct UnionFindMap{
  std::map<T, int> data;
  UnionFind uf;
  UnionFindMap(int size): uf(size){ }
  
#ifndef get_index
  int get_index(T x){
    if( data.find(x) == data.end() ){
      data.insert( std::make_pair<T, int>( x, data.size() ) );
    }
    return data[x];
  }
#endif
  int make(T x){
    if( data.find(x) == data.end() ){
      data.insert( std::make_pair<T, int>( x, data.size() ) );
    }
    return data[x];
  }
  
  bool unite(T x, T y){
    return uf.unite( get_index(x), get_index(y) );
  }
  
  bool find(T x, T y){
    return uf.find( get_index(x), get_index(y) );
  }
  
  int root(T x){
    return uf.root( get_index(x) );
  }
};

map<P,int> mp;

signed main(){
  int n,k,l;
  cin>>n>>k>>l;
  
  UnionFind uf_1=UnionFind(n+1);
  UnionFind uf_2=UnionFind(n+1);
  
  for(int i=0; i<k; i++){
    int a,b; cin>>a>>b;
    uf_1.unite(a, b);
  }
  for(int i=0; i<l; i++){
    int a,b; cin>>a>>b;
    uf_2.unite(a, b);
  }
  for(int i=1; i<=n; i++){
    mp[mk(uf_1.root(i),uf_2.root(i))]++;
  }
  for(int i=1; i<=n; i++){
    cout<<mp[mk(uf_1.root(i),uf_2.root(i))]<<en;
  }
}



Measured memory_bytes: 15104
# -*- coding: utf-8 -*-
"""
Tennis
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0285

"""
import sys


Ans = []

def solve(j, y, score = ''):
    if score.count('A') == j and score.count('B') == y:
        Ans.append(score)
        return
    if score.count('A') == 5 and score.count('B') < 4 or score.count('A') < 4 and score.count('B') == 5:
        return
    if score.count('A') < j:
        solve(j, y, score+'A')
    if score.count('B') < y:
        solve(j, y, score+'B')


def main(args):
    j, y = map(int, input().split())
    solve(j, y)
    print(*sorted(Ans), sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 5640
var a:array[1..200000] of char;
i,j,k,l:longint;
begin
while not eoln do
  begin
  k:=k+1;
  read(a[k]);
  
  end;



for i:=1 to k do if a[i]='A' then begin j:=i; break; end;
for i:=k downto 1 do if a[i]='Z' then begin k:=i;break;end;
writeln(abs(k-j)+1);

end.

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll h=2,w;
ll ans=0;
ll G[2][105];

void dfs(ll y, ll x, ll sum){
  if(y==1 && x==w-1){
    chmax(ans,sum+G[y][x]);
    return;
  }
  if(y>=2||x>=w) return;
  sum+=G[y][x];
  dfs(y+1,x,sum);
  dfs(y,x+1,sum);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>w;
  rep(i,2) rep(j,w) cin>>G[i][j];
  dfs(0,0,0);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

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

    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<>> AB;

    int a, b;
    rep(i,N)
    {
        cin >> a >> b;
        AB.push(make_pair(a,b));
    }

    priority_queue<int> A;
    
    int ans=0;
    rep(i,M+1)
    {
        while (!AB.empty() && AB.top().first <= i)
        {
            A.push(AB.top().second);
            AB.pop();
        }

        if (!A.empty())
        {
            ans += A.top();
            A.pop();
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 1908
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn solve(i: usize, n: usize, mut bs: &mut Vec<bool>, fs: &Vec<Vec<bool>>, ps: &Vec<Vec<i32>>) -> i32 {
    if i == 10 {
        if bs.iter().all(|b|!b) {
            std::i32::MIN
        } else {
            (0..n).map(|i| ps[i][bs.iter().zip(fs[i].iter()).filter(|&(&a, &b)| a && b).count() as usize]).sum()
        }
    } else {
        bs[i] = false;
        let r1 = solve(i+1, n, bs, fs, ps);
        bs[i] = true;
        let r2 = solve(i+1, n, bs, fs, ps);
        cmp::max(r1, r2)
    }
}

fn main() {
    let n = get!(usize);
    let fs = (0..n).map(|_| get!(String).split_whitespace().map(|f| f == "1").collect::<Vec<_>>()).collect::<Vec<_>>();
    let ps = (0..n).map(|_| get!(String).split_whitespace().map(|p| p.parse::<i32>().unwrap()).collect::<Vec<_>>()).collect::<Vec<_>>();
    println!("{}", solve(0, n, &mut vec![false; 10], &fs, &ps));
}

Measured memory_bytes: 2140
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
/*#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")*/
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

string s;

main(){
	cin>>s;
	int n=s.size();
	rep(i,n-1){
		if(s[i]==s[i+1]){
			dump(i+1,i+2);
			return 0;
		}
	}
	rep(i,n-2){
		if(s[i]==s[i+2]){
			dump(i+1,i+3);
			return 0;
		}
	}
	dump(-1,-1);
}


Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <cstring>
#include <vector>
#include <list>
#include <algorithm>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef list<int> li;
typedef vector<li> vli;
typedef vector<vpi> vvpi;
typedef long long i64;

const int inf = 1e9;

void solve_a() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<string> vs;
  fore(j, 1, k) forn(i, s.length() - j + 1) {
    vs.pb(s.substr(i, j));
  }
  sort(all(vs));
  vs.erase(unique(all(vs)), vs.end());
  cout << vs[k - 1] << endl;
}

int main() {
#ifdef HOME
  freopen("input.txt", "rt", stdin);
#endif
  solve_a();
  return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint p25[2000000], p26[2000000], xf[2000000];

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int size = s.size();

  p25[0] = 1;
  for (int i = 1; i <= k; i++) {
    p25[i] = p25[i - 1] * 25;
  }

  p26[k] = 1;
  for (int i = k - 1; i >= 0; i--) {
    p26[i] = p26[i + 1] * 26;
  }

  mint sf = 1;
  for (int i = 2; i < size; i++) {
    sf *= i;
  }

  xf[0] = 1;
  for (int i = size - 1; i > 0; i--) {
    xf[0] *= i;
  }

  for (int i = 1; i <= k; i++) {
    xf[i] = xf[i - 1] * (i + size - 1) / i;
  }
/*
  rep(i, k + 1) {
    cout << p25[i].x << " " << p26[i].x << " " << xf[i].x << endl;
  }
*/
  mint ans = 0;
  rep(i, k + 1) {
    ans += (xf[i] / sf * p25[i] * p26[i]);
  }

  cout << ans.x << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 52196
let ($) f g x = f (g x)

let rec read n = if n = 0 then [] else (Scanf.scanf "%d\n" (fun x -> x) :: read (n - 1))

let rec take n = function
  | [] -> []
  | hd :: tl -> if n <= 0 then [] else hd :: take (n - 1) tl

let _ =
  let lst = read 10 in
  List.iter (Printf.printf "%d\n") ((take 3 $ List.sort (fun x y -> compare y x)) lst)

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

using namespace std;

int n;

void dfs(string s, int k, int m) {
  if (k == 0) {
    cout << s << endl;
    return;
  }
  for (int i = 0; i <= m; i++) {
    dfs(s+char('a'+i), k-1, m);
  }
  dfs(s+char('a'+m+1), k-1, m+1);
}

int main() {
  cin >> n;
  
  dfs("", n, -1);
  return 0;
}

Measured memory_bytes: 1536
#include <cstdio>

const int MaxN = 16;

int N;
int A[MaxN][MaxN];
long long Weight[1 << MaxN];
long long F[1 << MaxN];
bool Vis[1 << MaxN];

template <typename Typ>
inline Typ max(Typ x, Typ y) { return x > y ? x : y; }

void init() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
      scanf("%d", &A[i][j]);
}

inline long long count(long long s) {
  long long ans = 0;
  for (int i = 0; i < N; ++i)
    if (s & (1 << i)) {
      for (int j = i + 1; j < N; ++j)
        if (s & (1 << j))
          ans += A[i][j];
    }
  return ans;
}

long long dfs(int s) {
  if (s == 0) return F[s] = 0;
  if (Vis[s] == true) return F[s];
  Vis[s] = true;
  for (int q = s; q &= s; --q) {
    int t = s &~ q;
    F[s] = max(F[s], dfs(t) + Weight[q]);
  }
  return F[s];
}

void solve() {
  for (int i = 0; i < (1 << N); ++i) Weight[i] = count(i);
  printf("%lld\n", dfs((1 << N) - 1));
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){

    int n,r;
    while(cin>>n>>r,n){
        int a[2][60];
        int now = 1;
        for(int i = 0;i < n;i++)a[0][i] = i;
        while(r--){
            int p,c;
            cin>>p>>c;
            p--;
            for(int i = p;i < p+c;i++){
                a[now][i-p] = a[1-now][i];
            }
            for(int i = 0,t = 0;i < n;i++){
                if(p<=i&&i<p+c)continue;
                a[now][t+c] = a[1-now][i];
                t++;
            }
            //for(int i = 0;i < n;i++)cout<<a[now][i]<<" ";
            //cout<<endl;
            now = 1-now;
        }
        cout<<n-1-a[1-now][0]+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000
#define mod 1000000007
#define ld long double
#define point complex<double>
#define pi  acos(-1)
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;



	int main(){
		int x,y;
		cin>>x>>y;
		bool f=0;
		for(int i=0;i<=x;i++)
		{
			int ii=x-i;
			if((4*i+2*ii)==y)f=1;
		}
		if(f)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
    
    void solve() throws IOException {
        int d=ni(),t=ni(),s=ni();
        if (t*s>=d) out.println("Yes");
        else out.println("No");
        out.flush();
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

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

int main() {
  	string s;
  	cin >> s;
  
  	string ans;
  
  	for(int i = 0; i < s.size(); i++) {
    	if(s.at(i) == '0') {
          	ans.push_back('0');
        }else if(s.at(i) == '1') {
          	ans.push_back('1');
        }else if(s.at(i) == 'B' && ans.size() != 0) {
        	ans.pop_back();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<cstring>
#define  maxn 5500
using namespace std;
bitset<maxn>sum;
int a[maxn];
int n,k;
bool check(int x)
{
    if(a[x]>=k)
        return 1;
    sum.reset();
    sum[0]=1;
    for(int i=1;i<=n;i++)
        if(i!=x)
        sum|=sum<<a[i];
    for(int i=k-1;i>=k-a[x];i--)
        if(sum[i])
        return 1;
    return 0;
}
 
int main()
{scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
sort(a+1,a+n+1);
    int l=0;
    int r=n+1;
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(check(mid))
            r=mid;
        else
            l=mid+1;
    }
    printf("%d\n",l-1);
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const long long M =2e5+2,MOD=1e9+7;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2=false,vis[M]= {false},f=false;
vector<ll>v,v_1,v_2;
string s,p,q,ok,ch;
map<ll,ll>mp,mp_2;
set<ll>st,st_1;
ll arr[M],subtree[M]={0};
ll cnt=0,cost=0,mx=0,NODE,t,par,zero=0,pos=0,neg=0;
deque<ll>Q;
//vector< pair<ll,ll > >v,v_1;
struct node
{
    ll pa,ran,visit;

};
//node X[M];
int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
    //freopen("kamona.txt","r",stdin);
    ll a,b,c,n,t,sum=0,mx=0,l,x,y,i=0,j=0,res,m,second=0,d,ans;
    cin>>a;
   while(a--)
   {
       cin>>b;
       v.pb(b);
   }
   v_1=v;
   sort(v_1.begin(),v_1.end());
   for(i=0;i<v.size();i++)
   {
       ans=v_1[v.size()-1];
       if(v[i]==v_1[v_1.size()-1])
       {
           ans=v_1[v_1.size()-2];
       }
       cout<<ans<<endl;

   }

    return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;
}

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

int main(){
  ll n, k;
  cin >> n >> k;
  
  if(n % k == 0){
    cout << 0 << endl;
    return 0;
  }
  
  if(n < k){
    n = min(n, k-n);
    cout << n << endl;
    return 0;
  }else{
    n = n % k;
  }

  ll minimum = n;
  while(true){
    n = abs(n - k);
    if(minimum == n) break;
    minimum = min(minimum, n);
  }
  
  cout << minimum << endl;
  return 0;
}

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

int main() {
   string S;
   ll K;
   int b = 0;
   cin >> S >> K;
   int N[S.size()];
   rep(i, S.size()){
     N[i] = (int)(S[i] - '0');
   }
   rep(i, S.size()){
     if(N[i] == 1){
       K--;
     }else{
       b = N[i];
       break;
     }
     if(K == 0){
       b = 1;
       break;
     }
   }
   cout << b << endl;
   return 0;
}


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

#define rep(i, n)     for (int i = 0; i < n; ++i)
#define rep1(i, n)    for (int i = 1; i < n + 1; ++i)
#define repN(i, m, n) for (int i = m; i < n; ++i)
#define repR(i, n)    for (int i = n - 1; i >= 0; --i)

using namespace std;

int main() {
	string s;
	cin >> s;
	
	if (s == "RRR") {
		cout << 3;
	} else if (s == "RRS" || s == "SRR") {
		cout << 2;
	} else if (s == "SSS") {
		cout << 0;
	} else {
		cout << 1;
	}

	return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(a.begin(),a.end());
    long sum = 0;
    for(int i = 0; i < n; i++){
        sum += abs(a[i] - a[n/2]);
    }
    cout << sum;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for (int i=0;i<N;i++) {
			L[i]=sc.nextInt();
		}

		Arrays.sort(L);
		int sum=0;
		for (int i=0;i<N-1;i++) {
			sum += L[i];
		}
		if (L[N-1]<sum) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;

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

    if (isupper(s)) {
        cout << "A" << endl; 
    } else {
        cout << "a" << endl;
    }

    return 0;
}


Measured memory_bytes: 3544
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

bool compare_second(pii& a, pii& b) {
	if (a.second != b.second)
		return a.second < b.second;
	else
		return a.first < b.first;
}

int main()
{
	ll N, M;
	cin >> N >> M;
	vpii ab(M);
	cin >> ab;

	sort(all(ab), compare_second);
	//cout << ab << endl;

	ll ans = 0;
	ll del = 0;
	for (int i = 0; i < M; i++) {
		if (del < ab[i].first) {
			del = ab[i].second - 1;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
ll n;
ll a[100001];
ll sa[100005];

int main() {
  cin >> n;
  ll sum = 0;
  ll sum_n = n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    sum_n += i;
  }

  if(sum % sum_n != 0) {
    cout << "NO" << endl;
    return 0;
  }

  ll tmp = sum / sum_n;
  for(int i = 1; i <= n; i++) {
    if(i == n) sa[i] = a[0] - a[i-1] - tmp;
    else sa[i] = a[i] - a[i-1] - tmp;
    // cout << sa[i]<<endl;
  }

  bool ok = true;
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    if(sa[i] > 0) ok = false;

    else if(sa[i] == 0) continue;
    else {
      if(-sa[i] % n != 0) ok = false;
      else {
	ans = ans + (-sa[i] / n);
      }
    }
  }

  if(ok && ans == tmp) {
    cout << "YES" << endl;
    return 0;
  }

  else cout << "NO" << endl;
}

			  
    

  
  

  
  


Measured memory_bytes: 1792