akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main()
{
        ll N, H;
        cin >> N >> H;
        vll a(N), b(N);
        rep(i, 0, N) cin >> a[i] >> b[i];

        sort(b.rbegin(), b.rend());
        ll ans = 0;
        ll amax = *max_element(all(a));
        rep(i, 0, N) {
                if (b[i] < amax) continue;
                if (H <= 0) {
                        cout << ans << endl;
                        return 0;
                }
                H -= b[i];
                ++ans;
        }

        if (H <= 0) {
                cout << ans << endl;
                return 0;
        }


        ans += H/amax + (H%amax != 0);
        cout << ans << endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
using PP = pair<int, int>;

int n;
int a[200000];
int b[200000];
int v[400000];
int q[400000];
void input() {
  cin >> n;
  vector<PP> p;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    p.push_back(PP(a[i], i));
    p.push_back(PP(b[i], i));
  }
  sort(p.begin(), p.end());
  map<int, int> mp;
  for (int i = 0; i < 2 * n; ++i) {
    v[i] = p[i].first;
    int k = p[i].second;
    if (mp.count(k)) {
      q[mp[k]] = i;
      q[i] = mp[k];
    } else {
      mp[k] = i;
    }
  }
}


bool mark[400000];
int main() {
  input();
  int bn = INF;
  int bx = 0;
  int wn = INF;
  int wx = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (q[i] > i) {
      mark[i] = true;
      bn = min(bn, i);
      bx = max(bx, i);
    } else {
      wn = min(wn, i);
      wx = max(wx, i);
    }
  }
  long mn = long(v[bx] - v[bn]) * (v[wx] - v[wn]);
  for (int i = 0; i < 2 * n; ++i) {
    int j = q[i];
    if (j < i) break;
    mark[i] = false;
    mark[j] = true;
    bn = i + 1;
    bx = max(bx, j);
    wn = min(wn, i);
    while (mark[wx]) {
      --wx;
    }
    long ans = long(v[bx] - v[bn]) * (v[wx] - v[wn]);
    mn = min(mn, ans);
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 19180
#include<stdio.h>

int main(){
    char s[5][5];
    int i, N=3;

    for(i=0; i<N; i++){
        scanf("%s", &s[i]);
    }

    for(i=0; i<N; i++){
        printf("%c", s[i][i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <algorithm>

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

using namespace std;

map<int, int> mp;

int main()
{
    int n, a;
    int array[100005];
    int ans = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> array[i];

        if (mp.count(array[i]) == 0) {
            mp[array[i]] = 0;
        }
        
        mp[array[i]]++;
        mp[array[i]] = mp[array[i]] % 2;
    }

    sort(array, array + n);
    
    for (int i = 0; i < n; i++) {
        if (i == 0 || array[i - 1] != array[i]) {
            ans += mp[array[i]];
        }
    }

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


Measured memory_bytes: 5376
import Data.List
import Data.Array.IArray

solve :: Int -> [Int] -> Double
solve k p = maximum $ map (\i -> (pp!i) - (pp!(i-k))) [k..n]
  where
    n = length p
    f x = (fromIntegral x + 1) / 2
    pp = listArray (0,n) . scanl (+) 0 $ map f p :: Array Int Double

main :: IO ()
main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    p <- map read . words <$> getLine :: IO [Int]
    print $ solve k p

Measured memory_bytes: 86396
n, m = gets.chomp.split.map(&:to_i)
shop = []
result = 0
for x in 1..n
  shop << gets.chomp.split.map(&:to_i)
end
cheapershop = shop.sort!
drink_bought = 0
money_spent = 0
flag = false
for y in 0..n - 1
  if m - drink_bought > shop[y][1]
    money_spent = money_spent + shop[y][0] * shop[y][1]
    drink_bought = drink_bought + shop[y][1]
  elsif money_spent = money_spent + shop[y][0] * (m - drink_bought)
    drink_bought = m - drink_bought
    flag = true
  end
  if flag == true
    puts money_spent
    exit
  end
end


Measured memory_bytes: 10608
#include <cstdio>
#include <algorithm>

using namespace std;

namespace io
{
	const int maxb = 1 << 15;
	char b[maxb], *s = b , *t = b;
	bool Getchar(char &ch)
	{
		return ch = s == t && (t = (s = b) + fread(b, 1, maxb, stdin)) == b ? 0 : *s ++;
	}
	int Getint()
	{
		char ch;
		while (Getchar(ch) && (ch < '0' || ch > '9'));
		int s = ch - '0';
		while (Getchar(ch) && ch >= '0' && ch <= '9')
			s = s * 10 + ch - '0';
		return s;
	}
}

using io::Getchar;
using io::Getint;

int f[21][1 << 20 | 1];

int main()
{
	int n = Getint(), K = Getint();
	
	for (int i = 0; i <= n; ++ i)
	{
		int all = 1 << i;
		char ch;
		while (Getchar(ch) && ch != '0' && ch != '1');
		for (int j = 0; j < all; ++ j)
		{
			f[i][j] = ch - '0';
			Getchar(ch);
		}
	}
	
	for (int pos = 0; pos < n; ++ pos)
	{
		for (int i = n; i > pos; -- i)
		{
			int all = 1 << i;
			for (int j = 0; j < all; ++ j)
			{
				if (!f[i][j]) continue;
				if (pos && (j >> pos & 1) == (j >> pos - 1 & 1)) continue;
				f[i - 1][(j >> pos + 1) << pos | (j & (1 << pos) - 1)] += f[i][j];
			}
		}
	}
	
	for (int i = n; ~ i; -- i)
	{
		int all = 1 << i;
		for (int j = 0; j < all; ++ j)
		{
			if (f[i][j] >= K)
			{
				for (int pos = i - 1; ~ pos; -- pos)
					putchar((j >> pos & 1) + '0');
				return 0;
			}
		}
	}
}


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

int main(){

  int size, max, sa;

  cin >> size;

  int *array = new int[size];

  for(int i = 0; i < size; i++){
    cin >> array[i];
  }

  max = -2000000000;

  int minv = array[0];

  for(int i = 1; i < size; i++){
    if(max < array[i] - minv){
      max = array[i] - minv;
    }
    if(minv > array[i]){
      minv = array[i];
    }

  }

  cout << max << "\n";


  delete[] array;
  return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	vector<int> a;
	int b;
	int c, d;
	int k;
	int n, m;
	long long s, t;
	int x, y, z;
	scanf("%d", &n);
	for (int i = 0; i < 3*n; i++){
		scanf("%d", &b);
		a.push_back(b);
	}
	sort(a.begin(), a.end());
	s = 0;
	for (int i = 1; i <= n; i++){
		s = s + a[(2 * (n - i)) + n];
	}
	printf("%lld\n", s);
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> g[n];
  for (int i=0; i<n-1; i++) {
    int a;
    cin>>a;
    --a;
    g[a].push_back(i);
  }
  for (int i=0; i<n; i++) {
    cout<<g[i].size()<<endl;
  }
}

Measured memory_bytes: 14536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	private final class Vertex {
		List<Integer> vertices = new ArrayList<>();
		int color = -1;
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		Vertex[] vertices = new Vertex[n];
		for (int i = 0; i < n; i++) vertices[i] = new Vertex();
		
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(reader.readLine());
			int id1 = Integer.parseInt(st.nextToken());
			int id2 = Integer.parseInt(st.nextToken());
			vertices[id1].vertices.add(id2);
			vertices[id2].vertices.add(id1);
		}
		
		assignColor(n, vertices);

		int q = Integer.parseInt(reader.readLine());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int id1 = Integer.parseInt(st.nextToken());
			int id2 = Integer.parseInt(st.nextToken());
			int c1 = vertices[id1].color;
			int c2 = vertices[id2].color;
			if (c1 == c2 && c1 != -1) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}

	private void assignColor(int n, Vertex[] vertices) {
		int color = 0;
		for (int i = 0; i < n; i++) {
			if (vertices[i].color == -1) {
				dfs(i, vertices, color);
			}
			color++;
		}
	}

	private void dfs(int id, Vertex[] vertices, int color) {
		Stack<Integer> st = new Stack<>();
		st.push(id);
		while (!st.empty()) {
			id = st.pop();
			vertices[id].color = color;
			int size = vertices[id].vertices.size();
			for (int i = 0; i < size; i++) {
				int nId = vertices[id].vertices.get(i);
				if (vertices[nId].color == -1) {
					st.push(nId);
				}
			}
		}
	}
}


Measured memory_bytes: 80356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
ll n, a, b, res;
inline ll Pow (ll a, ll b) {
    ll t = 1;
    while (b) {
        if (b & 1) t = t * a % mod;
        a = a * a % mod, b >>= 1;
    } return t;
}
ll C (ll n, ll m) {
    if (n < m) return 0;
    ll res = 1;
    for (int i = 1; i <= m; i++) {
        ll a = (n + i - m) % mod;
        ll b = i % mod;
        res = res * (a * Pow (b, mod - 2) % mod) % mod;
    } return res;
}
ll Lucas (ll n, ll m) {
    if (m == 0) return 1;
    return C (n % mod, m % mod) * Lucas (n / mod, m / mod) % mod;
}
signed main() {
    scanf ("%lld %lld %lld", &n, &a, &b);
    res = Pow (2, n) - 1; ll tmp = Lucas (n, a) + Lucas (n, b);
    return printf ("%lld\n", ((res - tmp) % mod + mod) % mod), 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

int k;

int main() {
  cin >> k;
  queue<ll> q;
  reps(i,9)q.push(i);
  ll ans;
  while(k,k--){
    ans=q.front();
    q.pop();
    int p=ans%10;
    if(p)q.push(ans*10+p-1);
    q.push(ans*10+p);
    if(p!=9)q.push(ans*10+p+1);
  }
  cout << ans;
}

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

if n%2==0:
    m=n*(n-1)//2-n//2
    print(m)
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if i+j==n+1:
                continue
            print('{} {}'.format(i,j))
else:
    m=n*(n-1)//2-(n-1)//2
    print(m)
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if i+j==n:
                continue
            print('{} {}'.format(i,j))

Measured memory_bytes: 74632
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

/*
#include <atcoder/all>
using namespace atcoder;
*/

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i < n + 1; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define repr1(i, n) for (ll i = n; i > 0; i--)
#define FOR(i, j, n) for (ll i = j; i < n; i++)

const ll MOD = 1000000007; // 10^9+7
const ll MOD2 = 998244353;
const ll INF = 10000000000;

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

    vector<string > s(n);
    vector<ll> count(5,0);
    char march[5] = {'M','A','R','C','H'};
    rep(i,n){
        cin >> s[i];
        rep(j,5){
            if(s[i][0] == march[j]) count[j]++;
        }
    }

    ll ans = 0;

    for(ll i=0; i<5; i++){
        for(ll j=i+1; j<5; j++){
            for(ll k=j+1; k<5; k++){
                ans += count[i]*count[j]*count[k];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6400
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n1,n2;
	string s,t;
	cin>>s>>t;
	n1=s.length();
	n2=t.length();
	int dp[n1+1][n2+1],to[n1+1][n2+1];
	for(int i=0;i<=n1;i++){
		for(int j=0;j<=n2;j++){
			if(i==0||j==0)dp[i][j]=0;
			else{
				dp[i][j]=dp[i-1][j];
				to[i][j]=1;
				if(dp[i][j]<dp[i][j-1]){dp[i][j]=dp[i][j-1];to[i][j]=2;}
				if(s[i-1]==t[j-1])
				if(dp[i][j]<1+dp[i-1][j-1]){
					dp[i][j]=1+dp[i-1][j-1];
					to[i][j]=3;
					//cout<<i<<" "<<j<<"\n";
				}
			}
			//cout<<to[i][j]<<" ";
		}
		//cout<<"\n";
	}
	string res;
	int i=n1,j=n2;
	while(i>0&&j>0){
		if(to[i][j]==3){
			i--;
			j--;
			res+=s[i];
		}
		else if(to[i][j]==2){
			j--;
		}
		else i--;
	}
	reverse(res.begin(),res.end());
	cout<<res;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
ll N,C,K;
int main(){
	cin >> N >> C >> K;
	ll T[N];
	for(int i=0;i<N;i++){
		cin >> T[i];
	}
	sort(&T[0],&T[N]);
	int ans = 0;
	int id = 0;
	while(id<N){
		int id2 = id+1;
		int count = 1;
		ans++;
		while(id2<N && T[id2]<=T[id]+K && count<C){
			id2++;
			count++;
		}
		id = id2;
	}
	cout << ans << endl;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i){
        if(i % 2 == 0 && s[i] == 'L' || i % 2 == 1 && s[i] == 'R') {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

int main(){
 int n,x;
 cin >> n >> x;
 vector<int> d(n+1);
 d[0] = 0;
 for(int i = 0; i<n; i++){
     int s; cin >> s;
      d[i+1] = d[i] + s;
 }
 int ans = 0;
 for(int i =0; i<=n; i++){
     if(d[i] <= x){
         ans++;
     }
 }
 cout << ans << endl;

 
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        for(int i = 0; i < s1.length(); i++){
        	if(s1.equals(s2)){
            	System.out.println("Yes");
            	return;
            }
            s1 = s1.charAt(s1.length() - 1) + s1.substring(0, s1.length() - 1);
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 38956
#include<bits/stdc++.h>
using namespace std;
int main() {
    string S,T;cin>>S>>T;
    S=S+S;
    int N=T.size();
    for(int i=0;i<N;i++){
        if(S.substr(i,N)==T){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int N, M;
  while (cin >> N >> M && N) {
    vector<int> levels(M, 0);
    REP(i, N) {
      int D, V; cin >> D >> V;
      chmax(levels[--D], V);
    }
    cout << accumulate(begin(levels), end(levels), 0) << endl;
  }
  return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    ll X, Y;
    cin >> X >> Y;
    int res = 0;
    while(X <= Y){
        res++;
        X *= 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;
int main(void) {
	int a,b;
	int n;
	cin >> a >> b;
	if (a >= b + 1)
		n = a + a - 1;
	else if (b >= a + 1)
		n = b + b - 1;
	else
		n = a + b;

	cout << n;
	
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import math
import re
import numpy as np
import copy

#読み込む
S = input().split(" ")
L = int(S[0])
R = int(S[1])
d = int(S[2])

ans = 0

for i in range(L, R+1):
    if i % d == 0:
        ans += 1

print(ans)



Measured memory_bytes: 27180
/************************Code by Hardik Aggarwal!!!!***********************************/

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
vl g[1001];
vl bfs(ll s)
{
    queue<ll> q;
    q.push(s);
    ll vis[1001],parent[1001];
    for(ll i=1;i<=1000;i++)
    {
        vis[i]=0;
        parent[i]=0;
    }
    vis[s]=1;
    vl k;
    while(!q.empty())
    {
        ll u=q.front();
        //trace(u);
        q.pop();
        vis[u]=1;
        vl k;
        for(auto v:g[u])
        {  
             if(v==s)
            {   
                //debug;

                //cout<<s<<endl;
                //cout<<u<<endl;
                while(u!=0)
                {
                    k.pb(u);
                    //cout<<u<<endl;
                    u=parent[u];
                }
                return k;
                
            }     

            if(!vis[v])
                {   
                    parent[v]=u;
                    q.push(v);
                    //dist[v]=dist[u]+1;
                }

        }
    }
    /*for(ll i=0;i<k.size();i++)
    {
        cout<<k[i]<<endl;
    }*/
    return k;
}
int main()
{
    

    IOS
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=m;i++)
    {   ll u,v;

        cin>>u>>v;
        g[u].pb(v);
        //edges.pb({u,v});
    }
    vl ans;
    ll mini=10000000;
    for(ll i=1;i<=n;i++)
    {
        vl temp=bfs(i);
        if(temp.size()!=0)
        {
            if(temp.size()<mini)
            {
                mini=temp.size();
                ans=temp;
            }
        }
        //if(temp.size()<ans.size())
            
    }

    if(ans.size()==0)
    {
        cout<<-1;
        return 0;
    }
    cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<endl;
    }

    

    




    
    
}
    
 
    
    



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >>a>>b>>c>>d>>e>>k;
  if (e-a>k){
    cout << ":(";
  }
  else{
    cout <<"Yay!";
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,line,num,cnt=0;
  scanf("%d %d",&num,&line);
  int height[num];
  for(i=0;i<num;i++){
    scanf("%d",&height[i]);
    if(height[i]>=line) cnt++;
  }
  
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 512
fun readInts(): List<Int> = readLine()!!.split(" ").map { it.toInt() }

const val MAX_H = 100000

fun main(args: Array<String>) {
    val (h, n) = readInts()

    val blocked = IntArray(MAX_H)
    repeat(n) {
        val (x, y) = readInts()
        blocked[y] = blocked[y] or (1 shl x)
    }

    //置き方パターン
    val locate = listOf(0b0000, 0b0011, 0b0110, 0b1100, 0b1111)
    //荷物を置けた数
    val point = listOf(0, 1, 1, 1, 2)
    //一行4マスなので4bit分の障害物のパターンがある
    val howManyPatterns = 1 shl 4
    val patternRange = 0 until howManyPatterns

    //dpテーブル
    var now = IntArray(howManyPatterns) { 0 }
    var next = IntArray(howManyPatterns) { 0 }

    for (obstacle in patternRange) {
        now[obstacle] = if ((obstacle and blocked[0]) > 0) -1 else 0
    }
    for (i in 0 until h - 1) {
        next.fill(-1)
        for (obstacle in patternRange) {
            //そうはなり得ない障害物の配置の時は無視
            if (now[obstacle] == -1) continue
            //置けるパターンを試していく
            for (k in locate.indices) {
                //1行目に置いても障害物と被らないか
                val check0 = (blocked[i] and locate[k]) == 0
                //2行目に置いても障害物と被らないか
                val check1 = (blocked[i + 1] and locate[k]) == 0
                //置いても前の状態と被らないか
                val check2 = (obstacle and locate[k]) == 0
                if (check0 && check1 && check2) {
                    //置ける場合
                    val pattern = blocked[i + 1] or locate[k]
                    next[pattern] = Math.max(now[obstacle] + point[k], next[pattern])
                }
            }
        }
        val tmp = now
        now = next
        next = tmp
    }

    println(now.max()!!)
}


Measured memory_bytes: 66832
#include<iostream>
using namespace std;
int main()
{
	int x, y;
	while (1)
	{
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x < y)
		{
			cout << x << " " << y << endl;
		}
		else
		{
			cout << y << " " << x << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3084
import collections

a = collections.deque()

for i in range(int(input())):
    b = input()
    # 命令がinsertだった場合、
    if b[0] == 'i':
        # キーxを先頭に追加(数字は文字列bの7文字目以降にある)
        a.appendleft(b[7:])
    # 命令がdeleteだった場合
    elif b[6] == ' ':
        # 命令のキーが含まれる場合そのキーのデータを消すが、なければ何もしない
        try:
            a.remove(b[7:])
        except:
            pass
    # 命令がdeleteFirstだった場合
    elif len(b) > 10:
        a.popleft()
    # 命令がdeleteLastだった場合
    elif len(b) > 6:
        a.pop()

print(*a)






Measured memory_bytes: 69736
s = input();
list = s.split("/");
[y,m,d] = list;
flag = False;
if int(y)<2019:
    flag = True;
elif int(y) == 2019:
    if int(m) <= 4:
        flag = True;
if flag:
    print("Heisei");
else:
    print("TBD");

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,k;
    cin>>n>>k;
    ll a[n],dp[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=inf;
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(ll i=2;i<n;i++)
    {
        for(ll j=(i-1);j>=(i-k);j--)
        {
            if(j<0)
                break;
                dp[i]=min(dp[i],(dp[j]+abs(a[j]-a[i])));
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
S = input().strip()
A = [0 for _ in range(len(S))]
i = 1
while i<len(S):
    if S[i]=="L" and S[i-1]=="R":
        cur = i-2
        cntR = 0
        while cur>=0:
            if S[cur]=="R":
                cntR += 1
                cur -= 1
            else:
                break
        cur = i+1
        cntL = 0
        while cur<len(S):
            if S[cur]=="L":
                cntL += 1
                cur += 1
            else:
                break
        A[i-1] = 1+cntR//2+(cntL+1)//2
        A[i] = 1+(cntR+1)//2+cntL//2
        i = cur
    i += 1
print(*A)

Measured memory_bytes: 6408
#include <stdio.h>

int main(void){
	int e,y;
	scanf("%d%d",&e,&y);
	if(e == 1){printf("%d\n",1867+y);}
	if(e == 2){printf("%d\n",1911+y);}
	if(e == 3){printf("%d\n",1925+y);}
	if(e == 4){printf("%d\n",1988+y);}
	if(e == 0){
		if(1868 <= y && y <= 1911){printf("M%d\n",y-1867);}
		if(1912 <= y && y <= 1925){printf("T%d\n",y-1911);}
		if(1926 <= y && y <= 1988){printf("S%d\n",y-1925);}
		if(1989 <= y && y <= 2016){printf("H%d\n",y-1988);}
	}
	return 0;
}

Measured memory_bytes: 1860
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<pair<pair<string, int>,ll>> v(n);
	REP(i, n) {
		string s;
		int ap;
		cin >> s >> ap;
		v[i] = { { s, -ap },i };
	}
	sort(ALL(v));
	REP(i, n) {
		cout << v[i].second + 1 << endl;
	}
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d %d %d", $N, $A, $B, $C);
$L = [];
for ($i = 0; $i < $N; ++$i) {
    $L[] = intval(trim(fgets(STDIN)));
}

function dfs($n, $a, $b, $c) {
    global $N, $A, $B, $C, $L;

    if ($n == $N) {
        if (count($a) === 0 || count($b) === 0 || count($c) === 0) return PHP_INT_MAX;
        return sum($A, $a) + sum($B, $b) + sum($C, $c);
    }

    $min = PHP_INT_MAX;
    $d1 = dfs($n + 1, $a, $b, $c);
    $d2 = dfs($n + 1, array_merge($a, [$L[$n]]), $b, $c);
    $d3 = dfs($n + 1, $a, array_merge($b, [$L[$n]]), $c);
    $d4 = dfs($n + 1, $a, $b, array_merge($c, [$L[$n]]));

    return min($d1, $d2, $d3, $d4);
}

function sum($target, $arr) {
    $sum = 0;

    if (count($arr) > 1) {
        $sum = (count($arr) - 1) * 10;
    }

    $sum += abs($target - array_sum($arr));

    return $sum;
}

echo dfs(0, [], [], []);


Measured memory_bytes: 4856
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[100007];

int main(){
  ll N,K,A[107];
  cin >> N >> K;
  rep(i,N){
    cin >> A[i];
  }
  sort(A,A+N);
  Rep(i,0,K+1){
    if(i<A[0]){
      dp[i]=2;
    }
    else{
      ll x=0;
      bool Y=0;
      while(x<N && A[x]<=i){
        if(dp[i-A[x]]==2){
          Y=1;
        }
        x++;
      }
      if(Y){
        dp[i]=1;
      }
      else{
        dp[i]=2;
      }
    }
  }
  if(dp[K]==1){
    cout << "First" << endl;
  }
  else{
    cout << "Second" << endl;
  }
}

Measured memory_bytes: 1024
// "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 long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

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;
	cin >> n;
	double sum = 0;
	rep(i,n){
		double x;
		string v;
		cin >> x >> v;
		if(v == "JPY") sum += x;
		else sum += 380000.0 * x;
	}
	cout << Fixed << sum << '\n';
	return 0;	
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	a := io.ScanInts(n)

	var count int
	for i, num := range a {
		if (i+1)%2 != 0 && num%2 != 0 {
			count++
		}
	}
	fmt.Println(count)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

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

	for (int i = 1; i <= n; i++)
	{
		if (i % 3 == 0) {
			cout<<" "<< i;
		}
		else {
			x = i;
			do {
				if (x % 10 == 3) {
					cout<<" "<< i;
					break;
				}
				x /= 10;
			} while (x);
		}
	}
	cout << "\n";
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;


namespace M_SOLUTIONS
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            if(a >= 1800) { Console.WriteLine(1); return; }
            else if(a>= 1600) { Console.WriteLine(2); return; }
            else if (a >= 1400) { Console.WriteLine(3); return; }
            else if (a >= 1200) { Console.WriteLine(4); return; }
            else if (a >= 1000) { Console.WriteLine(5); return; }
            else if (a >= 800) { Console.WriteLine(6); return; }
            else if (a >= 600) { Console.WriteLine(7); return; }
            else{Console.WriteLine(8); return; }

        }
    }
}


Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  string s;
  cin>>s;
  int masu = N;
  bool t = 1;
  vector <int> kotae;
  while(t){
    if(masu<=M){
      kotae.push_back(masu);
      break;
    }
    for(int i = M;i>0;i--){
      if(s.at((masu-i)) == '0'){
        masu -= i;
        kotae.push_back(i);
        break;
      }
      if(i == 1 && s.at((masu-i)) == '1'){
        t = 0;
        break;
      }
    }
  }
  reverse(kotae.begin(),kotae.end());
  if(t == 0){
    cout << "-1" << endl;
  }
  else{
    for(int i = 0;i<kotae.size();i++){
      cout << kotae[i] << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 1144
import java.util.*;

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

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

if(R-L<2019){
      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
        }
      }
      System.out.println(ans);
}
else{
  System.out.println("0");
}

    }
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    string str = "";
    for (ll i = 0; i < S.size(); i++) {
        for (ll j = i; j < S.size(); j++) {
            if (S.substr(0, i)+S.substr(j, S.size()-j) == "keyence") {
                YES;
                return 0;
            }
        }
    }

    NO;
    return 0;
}

Measured memory_bytes: 256
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F1 first
#define S2 second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    ull N, count = 0;
    cin >> N;
    for(ull i = 1; i < N; i++)
    {
        if(N%i == 0)
        {
            count += (N/i)-1;
        }
        else
        {
            count += N/i;
        }
    }
    cout << count << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    //cin >> T;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

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

    int n = s.size();
    
    cout << s[0] << n-2 << s[n-1] <<endl;
 
}

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

vector<pair<ll,ll>> prime_factorize(ll N){
    vector<pair<ll,ll>> ret;
    for(ll a = 2; a * a <= N; a++){
        if(N % a != 0) continue;
        ll ex = 0;
        while(N % a == 0){
            ex++;
            N /= a;
        }
        ret.push_back({a, ex});
    }
    if(N != 1) ret.push_back({N, 1});
    return ret;
}

ll mod = 1e9+7;
#define NMAX 200010
ll fac[NMAX];
ll inv[NMAX];

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod-2, mod);
}

int main(){
    constexpr ll mod = 1e9+7;
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    vector<vector<pair<ll,ll>>> rec(N);
    map<ll,ll> mp;
    rep(i, 0, N){
        auto vec = prime_factorize(A[i]);
        rec[i] = vec;
        for(auto v : vec){
            if(mp.count(v.first) > 0){
                mp[v.first] = max(mp[v.first], v.second);
            }else{
                mp[v.first] = v.second;
            }
        }
    }

    ll mul = 1;
    for(auto p : mp){
        mul *= mod_pow(p.first, p.second, mod);
        mul %= mod;
    }

    ll ans = 0;
    rep(i, 0, N){
        ll div = 1;
        for(auto v : rec[i]){
            ll pw = mod_pow(v.first, v.second, mod);
            div *= mod_inv(pw, mod);
            div %= mod;
        }
        ans += (mul * div) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1536
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    #h0,w0h1,w1 = map(int, input().split())
    s=sys.stdin.readline()[:-1]
    t=sys.stdin.read().split()
    ans=0
    for i,w in enumerate(t):
        nw="".join(c.lower() if c.isupper else c for c in w)
        if nw==s:ans+=1
    print(ans)

main()



Measured memory_bytes: 5572
using System;

public class Program
{
  public static void Main()
  {
    int m1 = int.Parse(Console.ReadLine().Split(' ')[0]);
    int m2 = int.Parse(Console.ReadLine().Split(' ')[0]);
    
    Console.WriteLine(m1 != m2 ? 1 : 0);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define LL long long
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int a,b,c,p;
    cin>>a>>b>>c;
    p=b*1ll*c;
    if(p>=a)
    cout<<"Yes"<<en;
    else
    cout<<"No"<<en;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a=0,b=0,c=0;//a 4 ;b 2;c others
    int n;
    cin>>n;
    while(n--){
    	int tmp;
    	cin>>tmp;
    	if(tmp%4==0)
    		a++;
		else if(tmp%2==0)
			b++;
		else
			c++;
	}
	if(c==0&&a==0){
		if(b==1)
			cout<<"No"<<endl;
		else	
			cout<<"Yes"<<endl;
		return 0;
	}
	if(b!=0)
		c++;
	if(a==0&&c!=0)
		cout<<"No"<<endl;
	else if(c<=a+1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
    return 0;
}

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

int main() {
	int N;
    int a[110];  // 最大 100 個ですが余裕をもたせます
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
	
  	sort(a,a+N,greater<int>());
  	int Alice = 0;
  	int Bob = 0;
  	
  	for(int i=0; i<N; i++){
      if(i%2==0){
        Alice += a[i];
      }
      else{
        Bob += a[i];
      }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    h = LI()
    if n <= k:
        print(0)
        return
    h.sort()
    ans = sum(h[:n-k])
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 80204
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
    stack<int> st;
    string word;
    while (cin >> word) {
        if (word == "+") {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a + b);
        } else if (word == "-") {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(b - a);
        } else if (word == "*") {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a * b);
        } else {
            int a = stoi(word);
            st.push(a);
        }
    }
    int ans = st.top();
    cout << ans << endl;
}



Measured memory_bytes: 3164
from collections import defaultdict
from math import sqrt
N,P = map(int, input().split())

def factorize(a:int):
    """prime factorization O(sqrt(N))
    return dict of prime factor
    """
    ps = {}
    i = 2
    nokori = a
    while i*i <= nokori:
        if nokori%i==0:
            cnt = 0
            while nokori%i==0:
                cnt += 1
                nokori //= i
            ps[i] = cnt
        i += 1
    if nokori != 1:
        ps[nokori] = 1
    return ps

ps = factorize(P)
# print(ps)
ans = 1
for k,v in ps.items():
    ans *= pow(k, v//N)
print(ans)


Measured memory_bytes: 38512
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<long long> memo(200001, 0);
  vector<int> c;
  int mae = -1;
  REP(i, n) {
    int cc; cin >> cc;
    if (mae != cc) {
      c.emplace_back(cc);
      mae = cc;
    }
  }
  n = c.size();
  long long pre = 1;
  REP(i, n) {
    (memo[c[i]] += pre) %= MOD;
    pre = memo[c[i]];
  }
  cout << pre << '\n';
  return 0;
}


Measured memory_bytes: 2936