akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]

ab.sort(key = lambda x:x[0])

import queue
import sys
q = queue.Queue()
memo = [True] * (N+1)
memo[1] = False
cnt = 0
for i in range(M):
    if ab[i][0] == 1:
        q.put(ab[i][1])
        cnt += 1
    else :break
ab2 = [[0]] * (N+1)
for j in range(i,M):
    ab2[ab[j][0]] = ab2[ab[j][0]] + [ab[j][1]]
idx = 0
while not q.empty():
    s = q.get()
    memo[s] = False
    if s==N:
        print('POSSIBLE')
        sys.exit()
    if idx < cnt:
        for i in ab2[s][1:]:
            if memo[i]: q.put(i)
    idx += 1
print('IMPOSSIBLE')        
    
    

Measured memory_bytes: 63012
s = input()
ints = [ord(i) - ord('a') for i in s]
K = int(input())
n = len(s)
i = 0
while i < n:
    if ints[i] != 0 and 25 - ints[i] + 1 <= K:
        K -= 25 - ints[i] + 1
        ints[i] = 0
    i += 1

K %= 26
ints[-1] = (ints[-1] + K) % 26
s_ = ''
for i in ints:
    s_ += chr(i + ord('a'))

print(s_)


Measured memory_bytes: 4212
N = int(input())

seq = [int(i) for i in input().split()]
seq_sort = sorted(seq)

if N % 2 == 0:
    seq_even = []
    for i in range(N // 2):
        seq_even += [2 * i + 1, 2 * i + 1]
    if seq_sort == seq_even:
        print((2 ** (N // 2)) % (10 ** 9 + 7))
    else:
        print(0)
else:
    seq_odd = [0]
    for i in range(N // 2):
        seq_odd += [2 * (i + 1), 2 * (i + 1)]
    if seq_sort == seq_odd:
        print((2 ** (N // 2)) % (10 ** 9 + 7))
    else:
        print(0)


Measured memory_bytes: 13880
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll dp[3333][3333];

void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

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

	ll n, s;cin >> n >> s;
	vector<ll> v(n);REP(i, n)cin >> v[i];

	dp[0][0] = mod_pow(2, n);
	REP(i, n){
		REP(j, 3333){
			if(dp[i][j] == 0)continue;
			mod_add(dp[i+1][j], dp[i][j]);
			if(3333 <= j + v[i])continue;
			mod_add(dp[i+1][j+v[i]], mod_div(dp[i][j], 2));
		}
	}

	cout << dp[n][s] << endl;

	return 0;
}


Measured memory_bytes: 81708
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

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

  const string queries[] = {
      "dream",
      "dreamer",
      "erase",
      "eraser",
  };

  bool found = false;
  for (int64_t i = S.size() - 1; i > 0;) {
    found = false;
    for (const auto& q : queries) {
      const auto offset = i - static_cast<int64_t>(q.size()) + 1;
      if (offset < 0) {
        continue;
      }
      if (S.substr(offset, q.size()) == q) {
        found = true;
        i -= q.size();
        break;
      }
    }
    if (!found) break;
  }

  if (found)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a[maxn], b[maxn];
int n, m;
bool graph[maxn][maxn];
bool vis[maxn];

void dfs(int v) {
    vis[v] = true;
    for(int i = 1; i <= n; ++i) {
        if(graph[v][i] == false) continue;
        if(vis[i]) continue;
        dfs(i);
    }
}

int main(void) {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n >> m) {
        memset(graph, 0, sizeof(graph));
        for(int i = 0; i < m; ++i) {
            cin >> a[i] >> b[i];
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }
        int cnt = 0;
        for(int i = 0; i < m; ++i) {
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
            memset(vis, 0, sizeof(vis));
            dfs(1);
            bool flag = false;
            for(int j = 1; j <= n && !flag; ++j) {
                if(!vis[j]) flag = true;
            }
            cnt += flag;
            graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 256
import itertools
l = [int(i) for i in list(str(input()))]
pm=[1,-1]
l_i=list(itertools.product(pm,repeat=3))
for i in l_i:
    tmp=l[0]
    for j in range(3):
        tmp+=i[j]*l[j+1]
    if tmp==7:
        ans=[str(l[0]),"a",str(l[1]),"a",str(l[2]),"a",str(l[3]),"=7"]
        if i[0]==1:ans[1]="+"
        else:ans[1]="-"
        if i[1]==1:ans[3]="+"
        else:ans[3]="-"
        if i[2]==1:ans[5]="+"
        else:ans[5]="-"
        print("".join(ans))
        exit()

Measured memory_bytes: 3064
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << "\n";
#else
#define DEBUG(message)
#endif

struct Solver {
  void solve() {
    int n, c, k;
    cin >> n >> c >> k;

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

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

    int l = 0;
    int ans = 1;
    for (int i = 0; i < n; i++) {
      if (a[i] - a[l] > k || i - l + 1 > c) {
        l = i;
        ++ans;
      }
    }

    cout << ans << "\n";
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    Solver().solve();
  }
  return 0;
}

Measured memory_bytes: 3136
X, Y, Z, K = map(int, input().split(' '))
A = sorted(list(map(int, input().split(' '))), reverse=True)
B = sorted(list(map(int, input().split(' '))), reverse=True)
C = sorted(list(map(int, input().split(' '))), reverse=True)

import heapq

# 合計値, a_idx, b_idx, c_idx
queue = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
# heapqueueにqueueをかえる
heapq.heapify(queue)

visited = set()
i = 0
for i in range(K):
    while True:
        v, a, b, c = heapq.heappop(queue)  # 候補の中から1番目が一番小さいtupleを取り出す
        if (a, b, c) not in visited:
            break
    visited.add((a, b, c))
    print(-v)

    if a < X - 1:
        heapq.heappush(queue, (-(A[a + 1] + B[b] + C[c]), a + 1, b, c))
    if b < Y - 1:
        heapq.heappush(queue, (-(A[a] + B[b + 1] + C[c]), a, b + 1, c))
    if c < Z - 1:
        heapq.heappush(queue, (-(A[a] + B[b] + C[c + 1]), a, b, c + 1))


Measured memory_bytes: 4212
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
a = 0

for i in range(N):
  if i==0:
    a+=B[A[i]-1]
  else:
    a+=B[A[i]-1]
    if A[i]==A[i-1]+1:
      a+=C[A[i-1]-1]

print(a)

Measured memory_bytes: 3064
while True:
  a, op, b = input().split()
  if op == "+":
    print(int(a) + int(b))
  elif op == "-":
    print(int(a) - int(b))
  elif op == "*":
    print(int(a) * int(b))
  elif op == "/":
    print(int(a) // int(b))
  elif op == "?":
    break


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

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  set <pair <int, int> > q;
  for (int i = 0; i < n; i++) {
    q.insert({b[i], i});
  }
  ll ans = 0;
  while (!q.empty()) {
    int i = q.rbegin()->second;
    q.erase(--q.end());
    if (a[i] == b[i]) {
      continue;
    }
    int delta = b[(i - 1 + n) % n] + b[(i + 1) % n];
    int grab = (b[i] - a[i]) / delta;
    b[i] -= grab * delta;
    ans += grab;
    if (!grab) {
      cout << -1 << '\n';
      return 0;
    }
    q.insert({b[i], i});
  }
  cout << ans << '\n';
}


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

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{

    int n;
    int AC(0), WA(0), TLE(0), RE(0);
    cin >> n;
    string s;
    for (int i = 0; i < n; i++)
    {
        cin >> s;

        if (s == "AC")
            AC++;
        else if (s == "WA")
            WA++;
        else if (s == "RE")
            RE++;
        else if (s == "TLE")
            TLE++;
    }
    cout << "AC x"
         << " " << AC << "\n";
    cout << "WA x"
         << " " << WA << "\n";
    cout << "TLE x"
         << " " << TLE << "\n";
    cout << "RE x"
         << " " << RE << "\n";

    return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var n,k,scan_a,i,falls1,falls2,mod int64
	falls1 = 0
	falls2 = 0
	var a []int64
	var append_a []int64
	mod = 1000000007
	fmt.Scan(&n, &k)

	for i = 0; i < n; i++ {
		fmt.Scan(&scan_a)
		a = append(append_a, scan_a)
		append_a = a
	}

	// 要素一個分の転倒数を求める
	for j, index_a1 := range a {
		for i = 0; i < int64(len(a)); i++ {
			if i > int64(j) && index_a1 > a[i] {
				falls1++
			}
		}
	}

	// 要素二個分の転倒数を求める
	a = append(append_a, append_a...)
	for k, index_a2 := range a {
		for i = 0; i < int64(len(a)); i++ {
			if i > int64(k) && index_a2 > a[i] {
				falls2++
			}
		}
	}
	falls2 = falls2 - falls1 * 2

	ans1 := ((falls1 % mod) * (k % mod)) % mod
	ans2 := ((falls2) % mod) * (((k * (k - 1)) / 2) % mod) % mod
	ans := (ans1 + ans2) % mod
	fmt.Println(ans)
}

Measured memory_bytes: 768
#include <stdio.h>

int main()
{int n,i,j,sum=0;
scanf ("%d",&n);
int a[n];
for (i=0;i<n;i++)
{
    scanf ("%d",&a[i]);
}
for (i=0;i<n;i++)
{
    for (j=i+1;j<n;j++)
    {
        sum=sum+a[i]*a[j];
    }
}
printf ("%d",sum);
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s=="abc") cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>                                  
using namespace std;                                 
                                                     
int main(void) {                                     
  int a, b;                                          
  cin >> a >> b;                                     
  if (a<b) {                                         
    cout << "a < b" << endl;                         
  } else if (a>b) {                                  
    cout << "a > b" << endl;                         
  } else {                                           
    cout << "a == b" << endl;                        
  }                                                  
  return 0;                                          
}                                                    
                                                     
                  

Measured memory_bytes: 3072
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

#define ll long long

using namespace std;

signed main() {
	int n, m; cin >> n >> m;
	if (n == 1) {
		ll a; cin >> a;
		while (m) {
			a /= 2;
			--m;
		}
		cout << a << endl;
		return 0;
	}
	priority_queue<ll> as;
	for (int i = 0; i < n; ++i) {
		ll a; cin >> a;
		as.push(a);
	}
	while (m) {
		ll a_largest = as.top();
		as.pop();
		while (a_largest >= as.top() && m > 0) {
			a_largest /= 2;
			--m;
		}
		as.push(a_largest);
	}

	ll ans = 0;
	while (!as.empty()) {
		ans += as.top();
		as.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,l = 0,r = 0;
	string s;
	cin >> n >> s;
	for(int i = 0;i < n;i++){
		if(s[i] == '(') r++;
		else r = max(0ll,r - 1);
	}
	for(int i = n - 1;i >= 0;i--){
		if(s[i] == ')') l++;
		else l = max(0ll,l - 1);
	}
	for(int i = 0;i < l;i++) s = "(" + s;
	for(int i = 0;i < r;i++) s += ")";
	cout << s << endl;
	return 0;
}

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

int isIn(string s, char c){
  int flg;
//  cout << s << " " << c << endl;
  for (int i=0; s[i]!='\0'; i++){
    if (s[i]==c) return 1;
  }
  return 0;
}

int main(void){
  string s;
  int ans=1;
  
  cin >> s;
  for (int i=0; i<s.size(); i++){
    ans &= isIn(i%2?"LUD":"RUD", s[i]);
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::*;
fn main() {
    input! {
        a: [i64; 4],
    }

    let ans = (a[0] * a[2])
        .max(a[0] * a[3])
        .max(a[1] * a[2])
        .max(a[1] * a[3]);
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int > dp(3);
    for(int day = 0; day < n; ++day) {
		vector<int > new_dp(3, 0);
		vector<int > c(3);
		for(int i = 0; i < 3; ++i) {
			scanf("%d", &c[i]);
		}
		for(int i = 0; i < 3; ++i) {
			for(int j = 0; j < 3; ++j) {
				if(i != j) {
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
				}
			}
		}
		dp = new_dp;
	}
	printf("%d\n", max({dp[0], dp[1], dp[2]}));
    return 0;
}


Measured memory_bytes: 256
/*
  
  Author: Arnab Sinha
	
  ███████╗██╗  ██╗███████╗██████╗         ██╗      ██████╗  ██████╗██╗  ██╗███████╗██████╗  █████╗  █████╗ 
  ██╔════╝██║  ██║██╔════╝██╔══██╗        ██║     ██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██╔══██╗██╔══██╗██╔══██╗
  ███████╗███████║█████╗  ██████╔╝        ██║     ██║   ██║██║     █████╔╝ █████╗  ██║  ██║╚██████║╚██████║
  ╚════ █║██╔══██║██╔══╝  ██╔══██╗        ██║     ██║   ██║██║     ██╔═██╗ ██╔══╝  ██║  ██║ ╚═══██║ ╚═══██║
  ███████║██║  ██║███████╗██║  ██║███████╗███████╗╚██████╔╝╚██████╗██║  ██╗███████╗██████╔╝ █████╔╝ █████╔╝
  ╚══════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚══════╝╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝  ╚════╝  ╚════╝                                                                                                        
*/
 
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define li long long int
#define ld long long double
#define all(v) v.begin(),v.end()
#define sort(a) sort(all(a))
#define rev(a) reverse(all(a))
#define pb push_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define vli vector<li>
#define MAXN 1e5+10
using namespace std;
 
li power(li a, li b, li mod) { a%=mod; li ret = 1; while(b){ if(b&1) ret*=a; a*=a;; if(ret>=mod) ret%=mod; if(a>=mod) a%=mod; b>>=1; } return ret; }
 
template <class T> void read(T& x){
	cin>>x;
}
 
template <class T, class... U> void read(T& x, U&... u){
	read(x);
	read(u...);
}
 
template <class A> void read(vector<A>& v){
	for(auto &it:v)
		read(it);
}
 
template <class A> void print(A x){
	cout<<x;
}
 
template <class A> void printl(A x){
	cout<<x<<endl;
}
 
template <class A> void print(vector<A>& v)
{
	for(auto &it:v){
		print(it);
		cout<<' ';
	}
	cout<<'\n';
}
 
void solve()
{
	li n;
	cin>>n;
	li lim = sqrt(n);
	lim+=1;
	li count = 0;

	for(li i = 1; i<= n; i++){
		li var = 1;
		while((n-(i*var))>0){
			count+=1;
			var++;
		}
	}

	cout<<count<<endl;
}

 
int main()
{
	IOS;
 	
 	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

 	solve();
 
	return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>

int n, k;
long long h[100010];
int main() {
	std::cin >> n >> k;
	for (int i = 0; i < n; ++i)
		std::cin >> h[i];
	std::sort(h, h + n);
	long long ans = 9999999999999;
	for (int i = k - 1; i < n; ++i)
		ans = std::min(ans, h[i] - h[i + 1 - k]);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

int main()
{
  map<string,int> box;

  int a,b;
  string s,t,u;
  cin >> s >> t >> a >> b >> u;

  box[s] = a;
  box[t] = b;

  box[u]--;

  cout << box[s] << ' ' << box[t] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto i:x) cout << i << " "; cout << "\n";}
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b

const ll INF64=LLONG_MAX;
const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;
template <typename T>
struct segment_tree{

    vector<T>tree;
    int size;
    T DEF;
    void init(int n){
        size=1;
        DEF=INF;
        while(size<n)size*=2;
        tree=vector<T>(2*size,0);
    }

    T merge(T a,T b){return a+b;}

    void set(int i,int x,T v,int lx, int rx){
        if(rx-lx==1){
            tree[x]=v;
            return;
        }
        int m=(rx+lx)/2;
        if(i<m){
            set(i,2*x+1,v,lx,m);
        }
        else{
            set(i,2*x+2,v,m,rx);
        }
        tree[x]=merge(tree[2*x+1],tree[2*x+2]);
    }
    void set(int i,T v){
        set(i,0,v,0,size);
    }
    T sum(int l,int r,int x,int lx,int rx){
        if(r<=lx || rx<=l) return 0;//change
        else if(l<=lx && rx<=r)return tree[x];
        int m=(lx+rx)/2;
        return merge(sum(l,r,2*x+1,lx,m),sum(l,r,2*x+2,m,rx));
    }
    T sum(int l,int r){
        return sum(l,r+1,0,0,size);
    }
    void print_tree(){
        for(int i=0; i<tree.size(); i++)
            cout << to_string(tree[i]) << " ";
        cout << "\n";
    }
};
vi bfs(vector<vi>adj, int src){
    queue<int>q;
    vi d(adj.size(),INF);
    q.push(src);
    d[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(d[nbr]==INF)
                q.push(nbr);
            d[nbr]=min(d[nbr],d[c]+1);
        }
    }
    return d;
}
void read(vi& v){
    int n=v.size();
    for(int i=0; i<n; i++)
        cin >> v[i];
}
ld log (ld a,ld b){return log(b)/log(a);}
ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}

void solve();

int main() {
    FAST;
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
}
void solve(){
    ld n,x,t;
    cin >> n>> x >> t;
    cout.precision(9);
    cout << floor(ceil(n/x)*t);
}

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

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



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a;
    cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0(i, n) for (i = 0; i < (n); i++)
#define f1(i, n) for (i = 1; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
template< typename T>
T modpow(T number, T power, T mod_value);
//*/

//int row, column;
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
//int dx[4] = {1,  0, -1, 0};
//int dy[4] = {0, -1,  0, 1};
//ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll n, i, ans = 0;
        string s;

        cin >> n >> s;
        string a;a.PB('A');

        while(s.length() > 0)
        {
            if (a.back() != s.back())
            {
                a.PB(s.back());
            }
            s.pop_back();
        }
        cout << a.length() -1 << endl;
    	//cout << "Test #" << test_case << ": ";
    	//cout << "Case " << test_case << ": ";
    }
    return 0;
}


template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
template< typename T>
T modpow(T number, T power, T mod_value)
{
    if (power == 0)
        return 1%mod_value;
    ll u = modpow(number,power/2,mod_value);
    u = (u*u)%mod_value;
    if (power%2 == 1)
        u = (u*number)%mod_value;
    return u;
}

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

int main() {
    int n, m, l, r, maximum = 0, minimum = INT_MAX;
    cin >> n >> m;
    rep(i, m) {
        cin >> l >> r;
        maximum = max(maximum, l);
        minimum = min(minimum, r);
    }
    int ans = max(0, minimum - maximum + 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=5e5+10;
    int N,Q;
    char S[MAXN];
    set<int> chPos[26];
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>S+1>>Q;
        for(int u=1;u<=N;u++)
            chPos[S[u]-'a'].insert(u);
        while(Q--){
            int t;
            cin>>t;
            if(t==1){
                int i;
                char c;
                cin>>i>>c;
                char cc=S[i];
                chPos[cc-'a'].erase(i);
                chPos[c-'a'].insert(i);
                S[i]=c;
            }
            else {
                int l,r;
                cin>>l>>r;
                int ans=0;
                for(int u=0;u<26;u++){
                    auto p1=chPos[u].lower_bound(l)
                    ,p2=chPos[u].upper_bound(r);
                    if(p1!=p2)ans++;
                }
                cout<<ans<<"\n";
            }
        }
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

using namespace std;

constexpr char nl = '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int N;
  cin >> N;
  unordered_set<string> S;

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S.insert(s);
  }

  cout << S.size() << nl;
}


Measured memory_bytes: 17548
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# 
# s = input()


N, M = map(int, input().split())
k = [0]*(M+1)
s = [0]*(M+1)
for i in range(1, M+1):
    l = list(map(int, input().split()))
    k[i] = l[0]
    s[i] = l[1:]
p = [0] + list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    dp = [0]*(N+1)
    ind = i
    for k in range(N):
        if ind % 2 == 1:
            dp[k+1] = 1
        ind //= 2

    flag = True
    for k in range(1, M+1):
        a = 0
        for e in s[k]:
            a = (a + dp[e]) % 2
        if a != p[k]:
            flag = False
            break

    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 42352
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: i64,
  }
  let MOD: i64 = 1000000007;
  let mut ans = 0;
  ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
  ans=ans % MOD;
  ans=(ans+MOD)%MOD;
  println!("{}", ans);
}

fn powmod(x: i64, y: i64) -> i64 {
  let MOD: i64 = 1000000007;
  let mut res:i64 = 1;
  for _ in 0..y {
    res = res * x % MOD;
  }
  return res as i64;
}




Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int N;
ll K;
vector<int> G[100100];
ll ans = 1;

void bfs() {
    queue<P> que;
    que.push(P(0, -1));
    ans *= K;
    while(que.size()) {
        P p = que.front(); que.pop();
        int siz = G[p.fr].size();
        if(p.fr == 0) {
            ll k = K - 1;
            rep(i, siz) {
                ans *= k;
                ans %= mod;
                k --;
            }
            for(auto v : G[p.fr]) {
                que.push(P(v, p.fr));
            }
        }
        if(p.fr != 0) {
            siz --;
            ll k = K - 2;
            rep(i, siz) {
                ans *= k;
                ans %= mod;
                k --;
            }
            for(auto v : G[p.fr]) {
                if(v == p.sc) continue;
                que.push(P(v,p.fr));
            }
        }
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> K;
    rep(i, N - 1) {
        int a, b; cin >> a >> b;
        a --; b --;
        G[a].pb(b);
        G[b].pb(a);
    }
    bfs();
    ans %= mod;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6904
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        boolean[][] cardHasFlag = new boolean[4][13];
        
        int n = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            String make = sc.next();
            int card = sc.nextInt();
            
            switch(make) {
                case "S" :
                    cardHasFlag[0][card-1] = true;
                    break;
                case "H" :
                    cardHasFlag[1][card-1] = true;
                    break;
                case "C" :
                    cardHasFlag[2][card-1] = true;
                    break;
                case "D" :
                    cardHasFlag[3][card-1] = true;
                    break;
            }
        }
        
        for (int i = 0; i < 4; i++) {
            for (int j = 0 ; j < 13; j++) {
                if (cardHasFlag[i][j] == false) {
                    switch (i) {
                        case 0 :
                            System.out.printf("S %d\n", j+1);
                            break;
                        case 1 :
                            System.out.printf("H %d\n", j+1);
                            break;
                        case 2 :
                            System.out.printf("C %d\n", j+1);
                            break;
                        case 3 :
                            System.out.printf("D %d\n", j+1);
                            break;
                    }
                }
            }
        }
    }
}


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

int main() {
    int h,w;
    cin>>h>>w;
    vector<string> field(h);
    rep(i,h)cin>>field[i];

    //ラムダ式で探索の実装
    auto tansaku=[&](int a,int b){
        int count=0;
        for(int i=-1;i<=1;i++){
            for(int j=-1;j<=1;j++){
                if(i==0&&j==0)continue;
                if(a+i<0||a+i>=h)continue;
                if(b+j<0||b+j>=w)continue;
                if(field[a+i][b+j]=='#')count++;
            }
        }
        char c=count+'0';
        return c;
    };

    rep(p,h){
        rep(q,w){
            if(field[p][q]=='#')continue;
            field[p][q]=tansaku(p,q);
        }
    }

    rep(p,h)cout<<field[p]<<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	se = set(MAP())

	if len(se) == 2:
		print('Yes')
	else:
		print('No')


if __name__=='__main__':
	main()


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

using namespace std;

typedef long long lint;

int main(){
  lint n;
  cin >> n;
  lint ans=0;
  for(lint i=1;i<=n;i++){
    if( !(i%3==0 || i%5==0) ){
      ans+=i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  df(n); df(m);
  vi a(MX);
  rep(i,n) {
    df(x);
    a[x]++;
  }
  int ans = 0;
  rep(i,m) {
    int j = (m-i)%m;
    if (i == j) {
      int s = 0;
      for (int k = i; k < MX; k += m) s += a[k];
      ans += s/2;
    } else if (i < j) {
      int s = 0, sx = 0;
      for (int k = i; k < MX; k += m) s += a[k]/2*2, sx += a[k]&1;
      int t = 0, tx = 0;
      for (int k = j; k < MX; k += m) t += a[k]/2*2, tx += a[k]&1;
      if (sx > tx) {
        swap(s,t);
        swap(sx,tx);
      }
      ans += sx;
      tx -= sx;
      int x = min(tx,s);
      ans += x;
      s -= x;
      ans += s/2;
      ans += t/2;
    }
  }
  cout << ans << endl;
  return 0;
}







Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10000000)
N, M = [int(_) for _ in input().split()]

LRD = []
path = [[] for _ in range(N + 1)]
for _ in range(M):
    l, r, d = [int(_) for _ in input().split()]
    path[l].append((r, d))
    path[r].append((l, -d))
    LRD.append((l, r, d))

INF = -1e12
memo = [INF] * (N + 1)


def dfs(n):
    for ni, d in path[n]:
        if memo[ni] != INF: continue
        memo[ni] = memo[n] + d
        dfs(ni)


for i in range(1, N + 1):
    if memo[i] != INF: continue
    memo[i] = 0
    dfs(i)
for l, r, d in LRD:
    if memo[l] + d != memo[r] and memo[l] - d != memo[r]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 136800
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n,m):
        a = LI()
        r = None
        for i in range(n):
            for j in range(i+1,n):
                t = a[i] + a[j]
                if m >= t and (r is None or r < t):
                    r = t

        if r is None:
            return 'NONE'
        return r

    while 1:
        n,m = LI()
        if n == 0:
            break
        rr.append(f(n,m))

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 9124
#include <iostream>
#include <math.h>

using namespace std;

int n[56];

bool check(int x)
{
    int temp=sqrt(x);
    for(int i=3;i<=temp;i+=2)
        if(x%i==0)
            return false;
    return true;
}

void build()
{
    int d=1;
    int x=0;
    while(x<55)
    {
        d+=10;
        if(check(d))
            n[x++]=d;
    }
}

int main()
{
    build();
    int x;
    while(cin>>x)
    {
        cout<<n[0];
        for(int i=1;i<x;i++)
            cout<<" "<<n[i];
        cout<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int l, r, d;
    cin >> l >> r >> d;

    int cnt = 0;
    repp(i, l, r) {
        if (i % d == 0) cnt++;
    }
    prt(cnt);

    return 0;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
void solve_abc042_a(){
    ll A,B,C; cin >> A >> B >> C;
    if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;}
    if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;}
    if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;}
    cout << "NO" << endl; return ;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve_abc042_a();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    cin>>n;
    string s;
    ll count=0;
    for(i=1;i<=n;i++)
    {
        s=to_string(i);
        if(s.size()%2) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int f(int h){
	if(h==1)return 1;
	else return 2*f(h/2)+1;
}
int32_t main(){
	if(fopen("input.txt", "r"))
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
	ios::sync_with_stdio(0),cin.tie(0);
	int h;
	cin >> h;
	cout << f(h);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll N,K,Q;
ll a[100000];
ll p[100000];

int main(){
    cin >> N >> K >> Q;
    for(int i=0;i<Q;i++){
        cin >> a[i];
        a[i]--;
    }
    for(int i=0;i<N;i++) p[i] = 0;
    ll M = Q - K;
    for(int i=0;i<Q;i++) p[a[i]]++;
    for(int i=0;i<N;i++){
        if(p[i] > M) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n = gets.chomp.to_i
    s = gets.chomp

    ans = s.each_char.inject("") do |ans, c|
      code = c.ord - 'A'.ord
      rc = ((code + n) % 26) + 'A'.ord

      ans += rc.chr
    end

    puts ans
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto pq1 = new BinaryHeap!(Array!int, "a < b");
    auto pq2 = new BinaryHeap!(Array!int, "a < b");
    foreach (a; A) pq1.insert(a);

    auto S = [pq1.front];
    pq1.removeFront;

    foreach (i; 0..N) {
        S.sort!"a > b";
        int ol = S.length.to!int;
        for (int j = 0; j < ol && !pq1.empty; ) {
            if (S[j] > pq1.front) {
                S ~= pq1.front;
                pq1.removeFront;
                j += 1;
            } else {
                pq2.insert(pq1.front);
                pq1.removeFront;
            }
        }
        if (S.length != (1 << (i + 1))) {
            writeln("No");
            return;
        }
        while (!pq2.empty) {
            pq1.insert(pq2.front);
            pq2.removeFront;
        }
    }

    writeln("Yes");
}

Measured memory_bytes: 14712
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


a, b, k = map(int, input().split())
g = gcd(a, b)
l = []
for i in range(1, g + 1):
    if g % i == 0:
        l.append(i)
l.reverse()
print(l[k - 1])

Measured memory_bytes: 3060