akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
input = stdin.buffer.readline
n, k = map(int, input().split())
*a, = map(int, input().split())
def f(mx):
    cnt = 0
    for i in a:
        cnt += (i + mx - 1) // mx - 1
    return cnt
l, r = 1, int(1e9)
while l < r:
    m = (l + r) >> 1
    if f(m) > k:
        l = m + 1
    else:
        r = m
print(r)


Measured memory_bytes: 100748
#include <stdio.h>

int main(void)
{
    int a,b,c,c_sub_b,b_sub_a;

    scanf("%d %d %d",&a,&b,&c);

    c_sub_b=c-b;
    b_sub_a=b-a;

    if(c_sub_b>0&&b_sub_a>0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>

using namespace std;

constexpr int d = 365;
constexpr int t = 26;
constexpr double rest_time = 1950;

int64_t evaluate(const vector<int64_t>& cs, const vector<vector<int64_t>>& ss, vector<int>& state)
{
    int64_t sum = 0;

    vector<int> last(t, -1);

    for (int i = 0; i < d; i++)
    {
        sum += ss[i][state[i]];
        last[state[i]] = i;

        for (int j = 0; j < t; j++)
        {
            sum -= cs[j] * (i - last[j]);
        }
    }

    return sum;
}

void solve(const vector<int64_t>& cs, const vector<vector<int64_t>>& ss, vector<int>& state, mt19937_64& mt)
{
    const auto start = chrono::system_clock::now();

    uniform_int_distribution<int> day_rand(0, d - 1);
    uniform_int_distribution<int> type_rand(0, t - 1);
    uniform_real_distribution<double> prob_rand;

    vector<int> best_state(d);

    auto eval = evaluate(cs, ss, state);
    auto best_eval = eval;

    double rate = 1.0;

    int counter = 0;
    while (true)
    {
        const int change_pos = day_rand(mt);
        int to_type = type_rand(mt);
        while (state[change_pos] == to_type)
        {
            to_type = type_rand(mt);
        }
        const auto from_type = state[change_pos];
        state[change_pos] = to_type;

        const auto after_eval = evaluate(cs, ss, state);

        if (eval < after_eval || exp(-(eval - after_eval) * rate * 2.0) > prob_rand(mt))
        {
            eval = after_eval;
        }
        else
        {
            state[change_pos] = from_type;
        }

        if (counter++ % 1000 == 0)
        {
            const auto end = chrono::system_clock::now();
            const auto duration = chrono::duration_cast<chrono::milliseconds>(end - start).count();
            if (duration > rest_time)
            {
                break;
            }
            rate = (rest_time - duration) / rest_time;
        }
        if (best_eval < eval)
        {
            best_eval = eval;
            copy(state.begin(), state.end(), best_state.begin());
        }
    }
    copy(best_state.begin(), best_state.end(), state.begin());
    std::cerr << counter << std::endl;
}

int main()
{
    {
        int _;
        cin >> _;
    }

    vector<int64_t> cs(t);
    for (auto& c : cs)
    {
        cin >> c;
    }
    vector<vector<int64_t>> ss(d, vector<int64_t>(t));
    for (auto& row : ss)
    {
        for (auto& e : row)
        {
            cin >> e;
        }
    }

    mt19937_64 mt(0);
    uniform_int_distribution<int> rand(0, t - 1);

    vector<int> state(d);
    for (int i = 0; i < d; i++)
    {
        state[i] = rand(mt);
    }

    solve(cs, ss, state, mt);

    for (int i = 0; i < d; i++)
    {
        cout << (state[i] + 1) << endl;
    }
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N, x;
  cin >> N >> A;
  x = N % 500;
  
  if (x <= A){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int p;
    cin >> p;
    for(int i = 0; i < p; i++){
        int q, bgn, end;
        cin >> q >> bgn >> end;
        vector<int>::iterator ans;
        
        if(q == 0){
            ans = min_element(v.begin()+bgn, v.begin()+end);
        }
        else {
            ans = max_element(v.begin()+bgn, v.begin()+end);
        }
        cout << *ans << endl;
    }
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,a[1005],b[1005],c[1005][15],d[1005],dp[1<<12],t;
int main()
{
	cin>>n>>m,t=1<<n;
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=m;i++){
		cin>>a[i]>>b[i];
		for(int j=1;j<=b[i];j++)
			cin>>c[i][j],c[i][j]--,d[i]+=1<<c[i][j];
	}
	for(int i=0;i<t;i++)
		for(int j=1;j<=m;j++)
			dp[i|d[j]]=min(dp[i|d[j]],dp[i]+a[j]);
	if(dp[t-1]==0x3f3f3f3f)cout<<-1;
	else cout<<dp[t-1];
    return 0;
}


Measured memory_bytes: 384
#ABC-121-B
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0

for _ in range(N):
    Ai = list(map(int, input().split()))
    sum_ab = 0
    for i in range(M):
        sum_ab += Ai[i] * B[i]
    if sum_ab + C > 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
h,w,d = map(int,input().split())
p = [(0,0)] * (h*w)
c = [0] * (h*w)
for i in range(h):
  a = list(map(int,input().split()))
  for j in range(w):
    p[a[j]-1] = (i,j)

for i in range(d, h*w):
  c[i] = c[i-d] + abs(p[i][0] - p[i-d][0]) + abs(p[i][1] - p[i-d][1])

q = int(input())
ans = 0
for i in range(q):
  l,r = map(int,input().split())
  print(c[r-1] - c[l-1])

Measured memory_bytes: 14336
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    cout << ((abs(a-b) & 1) ? "Borys\n" : "Alice\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;

    vector<ll> v(n+1);
    rep(i, n) {
        ll a;
        cin >> a;
        a--;
        v[i+1] = (v[i] + a)%k;
    }

    map<ll, ll> mp;
    queue<ll> Q;
    ll ans = 0;
    rep(i, n+1) {
        ans += mp[v[i]];
        mp[v[i]]++;
        Q.push(v[i]);
        if(Q.size() == k) {
            mp[Q.front()]--;
            Q.pop();
        }
    }

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

Measured memory_bytes: 16000
import sys
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)

num=0
b=0
for i in range(n):
    b=a[b]
    num+=1
    if (b+1)==2:
        print(num)
        sys.exit(0)

print(-1)


Measured memory_bytes: 7208
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
using namespace std;
const int maxn = 3010;
int dp[maxn][maxn];
int mark[maxn][maxn];
string a, b;

int main() {
	cin>>a;
	cin>>b;

	for(int i=1;i<=a.length();i++) {
		for(int j=1;j<=b.length();j++) {
			if(a[i-1] == b[j-1]) {
				mark[i][j] = 2;
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else {
				if(dp[i-1][j] > dp[i][j-1]) {dp[i][j] = dp[i-1][j];mark[i][j] = 0;}
				else {dp[i][j] = dp[i][j-1]; mark[i][j] = 1;}
			}
		}
	}

	int i = a.length();
	int j = b.length();

	string result = "";
	while(i > 0 && j > 0) {
		if(mark[i][j] == 2){
			result += a[i-1];
			i--;
			j--;
		}
		else if(mark[i][j] == 1) j--;
		else i--;
	} reverse(result.begin(), result.end());
	cout<<result;
}

Measured memory_bytes: 70912
D, G = map(int, input().split())
set, full = [],[]
for i in range(D):
    set.append(list(map(int, input().split())))
    full.append((i + 1)*100*set[i][0] + set[i][1])

minNum = 1001
for i in range(2 ** D):
    a = list(format(i, "b").zfill(D))
    total, num , largest= 0, 0, 0
    for j in range(D):
        if a[j] == "1":
            total += full[j]
            num += set[j][0]
        else:
            largest = j
    if total >= G:
        minNum = (num if num < minNum else minNum)
    else:
        for j in range(1, set[largest][0]):
            total += (largest + 1) * 100
            num += 1
            if total >= G:
                minNum = (num if num < minNum else minNum)

print(minNum)

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
 
template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    map<ll,ll> ma;
    for(int i = 0;i < N;i++) {
        ma[-vec.at(i)]++;
    }
    ll ret = 0;
    for(int i = 0;i < N && !ma.empty();i++) {
        ll val = -ma.begin()->first;
        ma[-val]--;
        if(ma[-val] == 0) {
            ma.erase(-val);
        }
        ll A = 1;
        while(A <= val) {
            A *= 2;
        }
        A -= val;
        if(ma.count(-A)) {
            ret++;
            ma[-A]--;
            if(ma[-A] == 0) {
                ma.erase(-A);
            }
        }   
    }
    cout << ret << endl;
}

Measured memory_bytes: 14336
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int x = readint;

    int sum = 0;
    for (int t = 1; ; t++) {
        sum += t;
        if (sum >= x) {
            writeln(t);
            break;
        }
    }
}


Measured memory_bytes: 256
n = int(input())
s = input()
mod = 10 ** 9 + 7

dict = {ch: 0 for ch in 'abcdefghijklmnopqrstuvwxyz'}
for i in range(n):
    dict[s[i]] += 1

ans = 1
for x in dict.values():
    ans = ans * (x+1) % mod
print((ans - 1) % mod)

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "<" << #__VA_ARGS__ << ">:", debug_out(__VA_ARGS__)
#define INF LLONG_MAX


int main()
{
  string s;
  cin >> s;
  cout << s[0] << s[1] << s[2] << endl;
	
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int cnt,m;
vector<int> G;

void insertionSort(vector<int>&vec,int g){
	for(int i=g;i<vec.size();i++){
		int v=vec[i];
		int j=i-g;
		while(j>=0&&vec[j]>v){
			vec[j+g]=vec[j];
			j=j-g;
			cnt++;
		}
		vec[j+g]=v;
	}
}

void shellSort(vector<int>&vec){
	cnt=0;
	G.push_back(1);
	for(int i=1;3*G[i-1]+1<vec.size()&&G.size()<=100;i++)
		G.push_back(3*G[i-1]+1);
	m=G.size();
	reverse(G.begin(),G.end());
	for(int i=0;i<m;i++) insertionSort(vec,G[i]);
}

int main(){
	int N;
	cin>>N;
	vector<int> vec(N);
	for(int i=0;i<N;i++) cin>>vec[i];
	cnt=0;
	shellSort(vec);
	cout<<m<<endl;
	for(int i=0;i<m;i++){
		if(i) cout<<" ";
		cout<<G[i];
	}
	cout<<endl<<cnt<<endl;
	for(int i=0;i<N;i++)
		cout<<vec[i]<<endl;
	return 0;
}


Measured memory_bytes: 6696
#include <stdio.h>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    int a = N / 1000;
    N -= a*1000;

    int b = N / 100;
    N -= b*100;

    int c = N / 10;
    N -= c*10;

    int d = N;

    if ((a == b && b == c) || (b == c && c == d)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace templete
{
    class abc100_b
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            if(input[1] == 100){
                WriteLine(Pow(100, input[0])*(input[1]+1));
            }else{
                WriteLine(Pow(100, input[0])*input[1]);
            }
        }

        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			System.out.println(Math.max(Math.min(b, d) - Math.max(a, c), 0));
		}

	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int dp[51][51][2510];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, a;
	cin >> n >> a;
	int x[n];
	zip(i, 0, n)
	{
		cin >> x[i];
	}
	//this is question of DP opps.
	// state of dp will be a,i,number of cards choose from 1st i element .......
	// dp[i][j][k]  sum =k;
	// rep(i, 0, )
	// {
	// 	dp[0][0][i] = 0;
	// }
	dp[0][0][0] = 1;
	zip(i, 0, n)
	{
		zip(j, 0, n + 1)
		{
			rep(k, 0, 2500)
			{
				dp[i + 1][j][k] += dp[i][j][k];
				if (j > 0 && k - x[i] >= 0)
				{
					dp[i + 1][j][k] += dp[i][j - 1][k - x[i]];
				}
			}
		}
	}
	int ans = 0;
	rep(i, 1, n)
	{
		ans += dp[n][i][a * i];
	}
	cout << ans << en;

	return 0;
}



Measured memory_bytes: 53640
n=int(input())
data=[]
for i in range(n):
    x,y=map(int,input().split())
    data.append((x,y))
ans=0
for i in range(n):
    for j in range(i+1,n):
        xi,xj,yi,yj=data[i][0],data[j][0],data[i][1],data[j][1]
        ans+=(((xi-xj)**2+(yi-yj)**2)**0.5)
ans*=2

print(ans/n)


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>

using namespace std;

int main(void)
{
int n,a,b,c,d,k,m,x,y;
cin >> n >> a >> b >> c >> d;
k=n/a;
m=n/c;
if(n>k*a){
k++;}
x=k*b;
if(n>m*c){
m++;}
y=m*d;
if(x>=y){
cout << y << endl;}
else if(x<=y){
cout << x << endl;}
return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;


int main(){
    string a,b;
    std::cin >> a>>b;
    if(a==b)std::cout << "H" << std::endl;
    else std::cout << "D" << std::endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n ){
    ll cnt = 0;
    string s,p;
    int v[2] = {};
    int f[2] = {};
    cin >> p;
    if(p == "lu"){
      v[0] = 1;
    }
    else if(p == "ru"){
      v[1] = 1;
    }
    else if(p == "ld"){
      v[0] = 0;
    }
    else{
      v[1] = 0;
    }
    rep(i,n-1){
      cin >> s;
      if(s == "lu"){
        v[0] = 1;
      }
      else if(s == "ru"){
        v[1] = 1;
      }
      else if(s == "ld"){
        v[0] = 0;
      }
      else{
        v[1] = 0;
      }
      if(v[0] == v[1] && s[0] != p[0]){
        ++cnt;
      }
        /* cout << v[0] << ' ' << v[1] << endl; */
      /* cout << s << ' ' << p << endl;       */
      p = s;
    }
    cout << cnt << endl;
  }

  return 0;
}

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

const long long INF = 1LL << 60;



int main() {
	long long dp[100100];

	dp[0] = 0;
	for (int n = 1; n <= 100000; n++) {
		dp[n] = INF;
		int power = 1;
		while (power <= n) {
			dp[n] = min(dp[n], dp[n - power] + 1);
			power *= 6;
		}
		power = 1;
		while (power <= n) {
			dp[n] = min(dp[n], dp[n - power] + 1);
			power *= 9;
		}
	}

	int n;
	cin >> n;
	cout << dp[n] << endl;
	return 0;

}


Measured memory_bytes: 1024
from collections import defaultdict
dd = defaultdict(int)
S = list(input().rstrip())
tmp = 0
dd[0]+=1
r=1
for s in S[::-1]:
    tmp+=int(s)*r
    r*=10

    tmp%=2019
    r%=2019
    dd[tmp]+=1
su=0
for i in dd.values():
    su+=(i*(i-1))//2
print(su)


Measured memory_bytes: 12524
#include <iostream>
#include <vector>

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> ns;
    ns.resize(N + 1);
    for (int i = 2; i <= N; i++)
    {
        int A;
        std::cin >> A;
        ns[A]++;
    }
    for (int i = 1; i <= N; i++)
    {
        std::cout << ns[i] << std::endl;
    }
}

Measured memory_bytes: 4052
n=int(input())
s=[input() for _ in range(n)]
s=sorted(s,key=lambda x: len(x))
for i in range(n):
    s[i]=sorted(s[i])
x=''.join(set(s[0]))
x=sorted(x)
for i in range(len(x)):
    tmp=s[0].count(x[i])
    for j in range(1,n):
        tmp=min(tmp,s[j].count(x[i]))
    print(x[i]*tmp,end="")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define D(x) cerr<<#x<<'='<<x<<'\n';
using namespace std;
typedef long long ll;
int main()
{
  	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%s",(a==b && b!=c) || (a==c && b!=c) || (b==c && a!=b)?"Yes":"No");
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

int main(){
    int s,w; std::cin >> s >> w;
    std::string ans;
    if(s<=w)
        ans="unsafe";
    else
        ans="safe";
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 2e5+5;
const int inf = 0x3f3f3f3f;
vector<int>VR,VG,VB;
ll a[N],dp[N],sum[N];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	sum[i]=(i>1?sum[i-2]:0)+a[i];
	for(int i=2;i<=n;i++)
	{
		if(i&1)dp[i]=max(a[i]+dp[i-2],dp[i-1]);
		else dp[i]=max(a[i]+dp[i-2],sum[i-1]);
	}
	cout<<dp[n];
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
//#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(a, max(b, c)) - min(a, min(b, c)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;
/**==Info==
*Program:2
*Problem:Fennce VS Snuke
*Date:2017-8-12
*Algorithm:DFS
*Stats:WA for 7 tests*/
int n;
vector<int> nei[100005];
int d[2][100005];
void dfs(int root,int dis,int place){ //root:this point,dis:now distance,place:which place to write in Array
	d[place][root]=dis;
	for(int i=0;i<nei[root].size();i++){
		if(d[place][nei[root][i]]>d[place][root]+1){
			d[place][nei[root][i]]=d[place][root]+1;
			dfs(nei[root][i],dis+1,place);
		}
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	for(int i=0;i<n;i++) d[0][i]=d[1][i]=1e8;
	dfs(0,0,0);
	dfs(n-1,0,1);
	
	int f=0,s=0;
	for(int i=0;i<n;i++){
		//cout<<d[0][i]<<" "<<d[1][i]<<endl;
		if(d[0][i]<=d[1][i]){
			f++;
		}else{
			s++;
		}
	}
	cout<<(f>s?"Fennec":"Snuke");
	return 0;
}


Measured memory_bytes: 14336
def count_rectangle(cnt, x1, y1, x2, y2):
    return cnt[y2][x2] - cnt[y2][x1 - 1] - cnt[y1 - 1][x2] + cnt[y1 - 1][x1 - 1]


if __name__ == '__main__':
    N, M = map(int, raw_input().split())
    K = input()
    field = []
    for i in xrange(N):
        field.append(list(raw_input()))
    cnt = dict()
    ground = ('J', 'O', 'I')
    for k in ground:
        cnt[k] = [[0] * (M + 1) for _ in xrange(N + 1)]

    for i in xrange(N):
        for j in xrange(M):
            for k in cnt:
                tmp = 1 if field[i][j] == k else 0
                cnt[k][i + 1][j + 1] = cnt[k][i + 1][j] + tmp

    for j in xrange(1, M + 1):
        for i in xrange(N):
            for k in cnt:
                cnt[k][i + 1][j] += cnt[k][i][j]
                
    for i in xrange(K):
        y1, x1, y2, x2 = map(int, raw_input().split())
        ret = []
        for k in ground:
            ret.append(count_rectangle(cnt[k], x1, y1, x2, y2))
        print ' '.join(map(str, ret))

Measured memory_bytes: 107220
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

void dfs(string s, ll n_options, ll n){

    if(s.size() == n){
        cout << s << endl;
        return;
    }

    rep(i, n_options){
        char c = 'a' + i;
        string s_next = s;
        s_next.push_back(c);

        if(i == n_options - 1){
            dfs(s_next, n_options + 1, n);
        }
        else{
            dfs(s_next, n_options, n);
        }
    }
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;

    string s = "a";
    dfs(s, 2, n);

    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string x;
  cin >> x;
  int res = 0, s = 0;
  for (char c : x) {
    if (c == 'S') {
      ++s;
    } else if (s != 0) {
      ++res;
      --s;
    }
  }
  cout << x.size() - 2 * res << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, std::string S, long long Q, std::vector<long long> k) {
    auto solve = [&](long long K) {
        long long sum = 0;
        long long ans = 0;
        deque<pair<char, int>> Q;

        int dC = 0;
        int mC = 0;
        for (int i = 0; i < S.size(); i++) {
            while (Q.size() && i - K >= Q.front().second) {
                if (Q.front().first == 'D') {
                    sum -= mC;
                    dC--;
                } else {
                    mC--;
                }
                Q.pop_front();
            }
            if (S[i] == 'D') {
                Q.push_back({'D', i});
                dC++;
            } else if (S[i] == 'M') {
                Q.push_back({'M', i});
                mC++;
                sum += dC;
            } else if (S[i] == 'C') {
                ans += sum;
            }
        }
        return ans;
    };
    for (auto kv : k) {
        cout << solve(kv) << endl;
    }

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> k(Q - 1 - 0 + 1);
    for (int i = 0; i < Q - 1 - 0 + 1; i++) {
        scanf("%lld", &k[i]);
    }
    solve(N, S, Q, std::move(k));
    return 0;
}


Measured memory_bytes: 10452
#include<iostream>
#include<vector>
int main() {
	std::vector<int> a, b;
	while (true) {
		int n;
		int as = 0, bs = 0;
		std::cin >> n;
		if (!n) {
			break;
		}
		for (int i = 0; i < n; ++i){
			int n, m;
			std::cin >> n >> m;
			if (n == m) { as += n;
			bs +=  m;
			}
			else if (n > m) {
				as += n + m;
			}
			else if (m > n) {
				bs += n+ m;
			}
		}
		a.push_back(as);
		b.push_back(bs);
	}
	for (int i = 0; i < a.size(); ++i) {
		std::cout << a[i] << " " << b[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ver first
#define val second
const int M=1e5;
const int INF=1e9;
vector<pair<int,int> >g[M];
set<pair<int,int> >edge;
int n,m,dis[M],b;
bool mark[M];
void input()
{
  cin>>n>>m>>b;
  for(int i=0;i<m;i++)
    {
      int u,v,w;
      cin>>u>>v>>w;
      g[u].push_back(make_pair(v,w));
    }
}
void update(int v)
{
  mark[v]=true;
  for(int i=0;i<g[v].size();i++)
    if(!mark[g[v][i].ver] && dis[v]+g[v][i].val < dis[g[v][i].ver])
      {
		edge.erase(make_pair(dis[g[v][i].ver],g[v][i].ver));
		dis[g[v][i].ver]=dis[v]+g[v][i].val;
		edge.insert(make_pair(dis[g[v][i].ver],g[v][i].ver));
      }
}
void dijkstra(int v)
{
  fill(dis,dis+n+1,INF);
  dis[v]=0;
  update(v);
  for(int i=1;i<n;i++)
  {
	pair<int,int>e=*edge.begin();
    update(e.second);
	edge.erase(e);
  }
}
int main()
{
  input();
  dijkstra(b);
  for(int i=0;i<n;i++)
	if(dis[i]==INF)
		cout<<"INF"<<endl;
	else
		cout<<dis[i]<<endl;
  return 0;
}

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

int main(){
	string s;
	long long res, pl, pr;
	cin >> s;

	res = 0;
	pl = 0;
	pr = 0;
	for(int i=0; i<s.length(); i++){
		if(s[i] == '<'){
			if(pr > 0){
				res += max(pl, pr);
				pl = 0;
				pr = 0;
			}
			res += pl;
			pl++;
			if(i == s.length()-1){
				res += pl;
			}
		}else{
			res += pr;
			pr++;
			if(i == s.length()-1){
				res += max(pl, pr);
			}
		}
	}
	cout << res << endl;
	return 0;


}

Measured memory_bytes: 900
# -*- coding: utf-8 -*-

a,b,c = map(int,input().split())

f=0
s=0

if a==5:
    f = f + 1
elif a == 7:
    s = s + 1
else:
    pass

if b==5:
    f = f + 1
elif b == 7:
    s = s + 1
else:
    pass

if c==5:
    f = f + 1
elif c == 7:
    s = s + 1
else:
    pass

if f==2 and s==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
a=input()
b=int(a)
takaH=0
while b>0:
    if b>=500:
        takaH+=1000
        b=b-500
    elif b>=5:
        takaH+=5
        b=b-5
    elif b>=100:
        b=b-100
    elif b>50:
        b=b-50
    elif b>=10:
        b=b-10
    else :
        b=b-1
print(takaH)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using Pii = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define _GLIBCXX_DEBUG
 
constexpr int MOD = 1000000007;
const int INF = 1 << 30;
 
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }


// 各操作を行う関数を実装する
 
// AとBに共通して含まれる要素からなる集合を返す
int main(){
 int a;
  cin >>a;
 vec b(a);
  for(int i =0;i<a;i++){
    cin>>b[i];
  }
   int sum =0;
 for(int i = 0; i<=a/2;i++){
   if(b[2*i]%2==1){
     sum ++;
   }
 }
  cout << sum;
  
  
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
inline void smax(int &x,int y) {
	x=x<y?y:x;
}
inline void smin(int &x,int y) {
	x=x>y?y:x;
}
int main() {
//	freopen("in.txt","r",stdin);
	double n,m;
	scanf("%lf%lf",&n,&m);
	printf("%d\n",(int)ceil(n/m));
	return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> stuff(n);
    for (int &x : stuff) cin >> x;
    int sum = accumulate(stuff.begin(), stuff.end(), 0);
	int count = 0;
	for(int i = 0; i < n; ++i) {
		double cur = 1.0*stuff[i]/sum;
		if (cur >= 1.0/(4*m)) ++count;
		if (count == m) {
			cout << "Yes\n";
			exit(0);
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long n = sc.nextLong();
        char[] array = s.toCharArray();
        char num = '1';
        for (int i = 0; i < n; i++) {
            if (array[i] != '1') {
                num = array[i];
                break;
            }
        }
        if (s.charAt(0) == 1 && n == 1) {
            System.out.println(1);
        } else if (s.charAt(0) == '1' && n > 1) {
            System.out.println(num);
        } else {
            System.out.println(s.charAt(0));
        }

    }
}


Measured memory_bytes: 79956
from collections import deque
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
S = [input() for _ in range(H)]

ret = 0
for sy in range(H) :
  for sx in range(W) :
    if S[sy][sx] == '#' :
      continue
      
    cost = [[float('inf')] * W for _ in range(H)]
    cost[sy][sx] = 0
    
    q = deque([(sy, sx, 0)])
    while q :
      cy, cx, co = q.popleft()
      for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)) :
        ny, nx = cy + dy, cx + dx
        if 0 <= ny < H and 0 <= nx < W and S[ny][nx] != '#' and co + 1 < cost[ny][nx] :
          q.append((ny, nx, co + 1))
          cost[ny][nx] = co + 1
          ret = max(ret, co + 1)
        
print(ret)

Measured memory_bytes: 46556
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000001;

using namespace std;



int main(void) {
	int n;
	long long int total = 0;
	long long int count = 0;
	long long int point = 0;

	cin >> n;
	vector<int>a(n + 1);
	FOR(i, 1, n) {
		cin >> a[i];
	}
	FOR(i, 1, n) {
		total += a[i];
		if (i % 2 == 1) {
			while (total <= 0) {
				total++;
				count++;
			}
		}
		else if (i % 2 == 0) {
			while (total >= 0) {
				total--;
				count++;
			}
		}
	}
	total = 0;
	FOR(i, 1, n) {
		total += a[i];
		if (i % 2 == 0) {
			while (total <= 0) {
				total++;
				point++;
			}
		}
		else if (i % 2 == 1) {
			while (total >= 0) {
				total--;
				point++;
			}
		}
	}
	cout << min(point, count) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX (1<<17)
int N,A[MX],X,S;
ll D;
int main(void){
    scanf("%d%d",&N,&X),ga(N,A);
    F(N+1)S+=D<=X,D+=A[i];
    printf("%d\n",S);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::cout << S.substr(0, S.size() - 8) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000000;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> cnt(N + 1, 0);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    ll tot = 0;
    for (int i = 0; i <= N; i++) {
        tot += cnt[i] * (cnt[i] - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        cout << tot - cnt[A[i]] + 1 << endl;
    }
}

Measured memory_bytes: 5760
import math
n,m = list(map(int,input().split()))
a = 0
b = 0

if n > m:
    a = n
    b = m
elif n < m :
    a = m 
    b = n
else:
    a = n
    b = n
    
if abs(n-m) ==1:
    print(((math.factorial(a) % 1000000007) * (math.factorial(b) % 1000000007))% 1000000007)
elif n ==m:
    print(((math.factorial(a) % 1000000007) * (math.factorial(b) % 1000000007)) *2 % 1000000007)
else:
    print(0)

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

pair<int, int> f(int x) {
    int a = x % 10;
    int b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
    return {a, b};
}

int main() {
    int n;
    cin >> n;
    map<pair<int, int>, int> mp;
    for (int i = 1; i <= n; ++i) {
        mp[f(i)]++;
    }
    ll ans = 0;
    for (int j = 1; j <= n; ++j) {
        pair<int, int> q = {f(j).second, f(j).first};
        ans += mp[q];
    }
    cout << ans << endl;
}

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

ll arr[100005][3],dp[100005][3];

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    ll n;
    cin>>n;
    for(ll x=0; x<n; x++){
        cin>>arr[x][0]>>arr[x][1]>>arr[x][2];
    }
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(ll x=1; x<n; x++){
        dp[x][0]=max(dp[x-1][1]+arr[x][0],dp[x-1][2]+arr[x][0]);
        dp[x][1]=max(dp[x-1][0]+arr[x][1],dp[x-1][2]+arr[x][1]);
        dp[x][2]=max(dp[x-1][0]+arr[x][2],dp[x-1][1]+arr[x][2]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 4992
matrix=[]
r,c = map(int,input().split())

for i in range(r):
    a=list(map(int,input().split()))
    matrix.append(a)

for rows in matrix:
    rows.append(sum(rows))

column_sum = []
for j in range(c+1):
    element_sum = 0
    for k in range(r):
        element_sum += matrix[k][j]
    column_sum.append(element_sum)

for p in matrix:
    print(" ".join(map(str,p)))
    
print(" ".join(map(str,column_sum)))

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    string s;cin>>s;
    vvi dp(n,vi(n,0));
    for(int start=n-2;start>=0;--start){dp[start][n-1]= (s[start]==s[n-1]);};
    for(int fin=n-2;fin>0;--fin){
        for(int start=fin-1;start>=0;--start){
            if (s[start]==s[fin]){
                dp[start][fin]=min(fin-start,dp[start+1][fin+1]+1);
            }
        }
    }
    int ret=0;
    FOR(i,n){
        for(int j=i+1;j<n;++j){
            ret=max(ret,dp[i][j]);
        }
    }
    cout << ret;
    return 0;
}



Measured memory_bytes: 98176
n,q = map(int,input().split())
s = input()
li = [0]
t = 0
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    t += 1
  li.append(t)
for k in range(q):
  l,r = map(int,input().split())
  print(li[r-1] - li[l-1])


Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second

template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

const int MAX = 200002;
const int MOD = 998244353;
 ;
LL N,M,K;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LL modPow(LL x, LL y){
    LL r = 1, a = x % MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}


LL calc(LL a){
    LL res = COM(N-1,a);
    res *= M;
    res %= MOD;
    LL tmp = modPow(M-1,N-1-a);
    res = (res * tmp) % MOD;
    return res;
}


int main() {
    cin >> N >> M >> K;
    LL ans = 0;

    COMinit();
    rep(i,K+1){
        ans += calc(i);
    }

    ans %= MOD;

    cout << ans << endl;

}

Measured memory_bytes: 8256