akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int N;
    char S[5],T[5];
    
    scanf("%s",S);
    scanf("%s",T);
    
    int answer = 0;
    
    if(S[0] == T[0]){
        answer++;
    }
    if(S[1] == T[1]){
        answer++;
    }
    if(S[2] == T[2]){
        answer++;
    }
    
    printf("%d\n",answer);
    
    return 0;
}













Measured memory_bytes: 128
def inpl(): return list(map(int, input().split()))
H, W, A, B = inpl()

MOD = 10**9 + 7
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
size = H+ W + 1
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    g1[i] =  ( g1[i-1] * i ) % MOD 
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 
    g2[i] =  (g2[i-1] * inverse[i]) % MOD

ans = 0
for a in range(H-A):
    h = H - a - 1
    w = W - B - 1
    ans = (ans + cmb(a+B-1, a, MOD)*cmb(h+w, h, MOD))%MOD
print(ans)

Measured memory_bytes: 26740
#include<stdio.h>
int main(void){
	int a, b, x;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<=5){
		x=0;
	}
	else if(a>=6 && a<=12){
		x=b/2;
	}
	else{
		x=b;
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 128
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <queue>
#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << " = " << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n); inn(m);

    vi adj[n];
    rep(i, m) {
        inn(u); --u;
        inn(v); --v;

        adj[u].push_back(v);
    }

    inn(s); --s;
    inn(t); --t;
    auto bfs = [&](int i) {
        bool done[n][3]; rep(i, n) rep(j, 3) done[i][j] = 0;

        done[i][0] = 1;
        std::queue<ii> q; q.push({i, 0});
        while (!q.empty()) {
            auto top = q.front(); q.pop();
            int u = top.first;
            int d = top.second;

            for (int v: adj[u]) {
                if (v == t) {
                    if (d % 3 == 2) {
                        return out(d/3 + 1), 1;
                    }
                }
                auto x = (d + 1)%3;
                if (!done[v][x]) done[v][x] = 1, q.push({v, d + 1});
            }
        }
        return 0;
    };

    if (!bfs(s)) out(-1);
}

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 6016
object Main extends App {
  import scala.io.StdIn._

  val mod = 1000000007L

  val Array(n, c) = readLine.trim.split(' ').map(_.toInt)
  val a = readLine.trim.split(' ').map(_.toInt)
  val b = readLine.trim.split(' ').map(_.toInt)

  println(
    solve(n, c, a, b)
  )

  def solve(n: Int, c: Int, a: Array[Int], b: Array[Int]): Long = {
    val memo = Array.tabulate(n){_ ⇒ Array.tabulate(c + 1){_ ⇒ -1L}}
    val sumExp = Array.tabulate(401){_ ⇒ Array.tabulate(401){_ ⇒ 0L}}.also{arr ⇒
      for (ab ← arr.indices){
        arr(ab)(0) = 1
        for (ar ← arr(ab).indices.tail){
          arr(ab)(ar) = (arr(ab)(ar - 1) * ab) % mod
        }
      }
      for (i ← arr(0).indices) arr(0)(i) = 0
      for (ab ← arr.indices.tail){
        for (ar ← arr(ab).indices){
          arr(ab)(ar) = (arr(ab)(ar) + arr(ab - 1)(ar)) % mod
        }
      }
    }
    def sub(position: Int, rest: Int): Long = {
      if (position == n) {
        if (rest == 0) 1L
        else 0L
      }else {
        if (memo(position)(rest) == -1L){
          memo(position)(rest) = 0
          for (use ← 0 to rest){
            memo(position)(rest) = (memo(position)(rest) + ((sumExp(b(position))(use) - sumExp(a(position) - 1)(use) + mod) % mod) * sub(position + 1, rest - use)) % mod
          }
        }
        memo(position)(rest)
      }
    }
    sub(0, c)
  }
  def exponent(base: Long, exp: Int): Long = {
    if (exp == 0) 1
    else if (exp == 1) base
    else exponent(base, exp / 2).let(it ⇒ it * it * exponent(base, exp % 2)) % mod
  }


  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
    @inline
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}


Measured memory_bytes: 43076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
        string s;
        cin >> s;
        int ans = 0;
        for (int i = 0; i < 3; i ++) ans += s[i] == '1';
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int in[12345678];
signed main() {
	int n, a, cnt = 0, ans = 0; cin >> n >> a; vector<int>v(a - 1);
	for (int h = 0; h < a; h++) {
		cin >> in[h];
	}
	sort(in, in + a);
	for (int h = 1; h < a; h++) {
		v[h - 1] = in[h] - in[h - 1];
	}
	sort(v.begin(), v.end());
	for (int h = 0; h < a - n; h++) {
		ans += v[h];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int amax = 0, amin = 0;
    rep(i, n){
        cin >> a[i];
        if(a[i] < a[amin]){
            amin = i;
        }
        if(a[i] > a[amax]){
            amax = i;
        }
    }
    vector<vector<int>> operations;
    if (abs(a[amax]) >= abs(a[amin])) {
        rep(i,n){
            if(i == amax) continue;
            operations.push_back({amax, i});
        }
        for(int i = 0; i < n-1; i++) operations.push_back({i, i + 1});
    } else {
        rep(i,n){
            if(i == amin) continue;
            operations.push_back({amin, i});
        }
        for(int i = n-1; i > 0; i--) operations.push_back({i, i-1});
    }

    cout << operations.size() << endl;
    for(auto v : operations){
        cout << v[0]+1 << " " << v[1]+1 << endl;
    }
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans[] = {1, 2, 3};
    for (int s : ans) {
        if (s != a && s != b) cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3508
#include <stdio.h>
int Min(int a,int b){
    if(a<=b)return a;
    else return b;
}
int main(){
    int n,a[201],i,cnt[201]={0},min=114514;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        while(a[i]%2==0){
            cnt[i]++;
            a[i]/=2;
        }
    }
    for(i=0;i<n;i++){
        min=Min(min,cnt[i]);
    }
    printf("%d",min);
    
    
    
        
    return 0;
}

Measured memory_bytes: 128
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 62;

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

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int X;
    cin >> X;

    for (int a = 0; a <= 100; a++) for (int b = 0; b <= 100; b++) {
        if (a*a*a*a*a+b*b*b*b*b==X) {
            cout << a << " " << -b << endl;
            return 0;
        }
    }

    for (int a = 0; a <= (1 << 12); a++) for (int b = 0; b <= (1 << 12); b++) {
        if (a*a*a*a*a-b*b*b*b*b==X) {
            cout << a << " " << b << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include<bits/stdc++.h>
#define li long long int
using namespace std;

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

   int n=s.length();
   int c=0;
   for(int i=0;i<n;i++){
    if(s[i]==t[i]){
        continue;
    }
    else{
        c++;
    }
   }

   cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3908
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if k < N:
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                ans -= 1

print(ans)

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
const int INF = 1001001001;

int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> H(n);
  rep(i,n) cin >> H[i];
  sort(H.begin(),H.end());
  ll cnt = 0;
  rep(i,n-k) cnt += H[i];
  cout << cnt << endl;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int x, y;
  cin >> x >> y;
  if (abs(x - y) <= 1)
  {
    cout << "Brown" << endl;
  }
  else
  {
    cout << "Alice" << endl;
  }

  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main()
{
     map <string, ll> mp;
     ll n;
     cin >> n;
     ll cnt=0;
     while(n--)
     {
         string s;
         cin >> s;
         sort(s.begin(), s.end());
         cnt+=mp[s];
         mp[s]++;
     }
     cout << cnt << endl;
     return 0;
}


Measured memory_bytes: 11136
# B
def how_many(a, b, c):
    # 1からa-1までのcの倍数の個数と1からbまでのcの倍数の個数を求める
    A, B = (a-1)//c, b//c
    # それらを引いて答えが求まる
    return B-A

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

print(how_many(a, b, x))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using edge=struct{int to; long long cost;};
vector<edge> tree[100000];
long long depth[100000];
void dfs(int v, int p, long long d){
    depth[v]=d;
    for(auto &e :tree[v]){
        if(e.to==p) continue;
        dfs(e.to, v, d+e.cost);
    }
    return;
}
int main(){
    int N,Q,K;
    cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        tree[a-1].push_back({b-1,c});
        tree[b-1].push_back({a-1,c});
    }
    cin>>Q>>K;
    dfs(K-1,-1,0);
    for(int i=0;i<Q;i++){
        int x,y;
        cin>>x>>y;
        cout<<depth[x-1]+depth[y-1]<<endl;
    }
}

Measured memory_bytes: 14336
#include <iostream>

int main(){
  int a, b, c;
  std::cin >> a >> b >> c;
  int x = 0;
  int y = 0;
  if (a + b + c == 17)
  {
    x = 1;
  }
  if (a*b*c == 175){
    y = 1;
  }
  if (x*y == 1){
    std::cout << "YES" << std::endl;
  }
  else{
    std::cout << "NO" << std::endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, m, n, sum, f;
	int d[1000];
	
	while (scanf("%d %d", &n, &m), m + n != 0){
		for (i = 0; i < n; i++){
			d[i] = 1;
		}
		
		i = sum = f = 0;
		while (1){
			sum += d[i];
			if (sum == m){
				d[i] = 0;
				sum = 0;
				f++;
			}
			if (f == n) break;
			if (i == n - 1){
				i = 0;
				continue;
			}
			i++;
		}
		printf("%d\n", i + 1);
	}
	
	return 0;
}

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

int chA[200005], chB[200005];
vector<int> ch[1005];
bool two[1005][1005];
bool care[1005];
int sccid[1005];
bool ons[1005];
int vis[1005];
int idx[1005];
vector<int> S;
int lo[1005];
int n, m;

void dfs1(int at, int fr, int via)
{
	if (care[at] && via != at) two[fr][at] = true;
	if (vis[at] == -1) vis[at] = via;
	else if (vis[at] == -2) return;
	else if (vis[at] == via) return;
	else vis[at] = -2;
	for (int u: ch[at]) dfs1(u, fr, via);
}

int dfs2(int at)
{
	static int Y, Z;
	idx[at] = lo[at] = ++Z;
	S.push_back(at); ons[at] = true;
	for (int u: ch[at])
		if (!idx[u]) lo[at] = min(lo[at], dfs2(u));
		else if (ons[u]) lo[at] = min(lo[at], idx[u]);
	if (idx[at] == lo[at])
	{
		Y++;
		while (true)
		{
			int u = S.back(); S.pop_back();
			ons[u] = false;
			sccid[u] = Y;
			if (u == at) break;
		}
	}
	return lo[at];
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0;i < m;i++)
	{
		scanf("%d%d", chA+i, chB+i);
		ch[--chA[i]].push_back(--chB[i]);
	}
	for (int i = 0;i < n;i++)
	{
		for (int u: ch[i]) care[u] = true;
		for (int j = 0;j < n;j++) vis[j] = -1;
		vis[i] = -2;
		for (int u: ch[i]) dfs1(u, i, u);
		for (int u: ch[i]) care[u] = false;
	}
	for (int i = 0;i < n;i++) if (!idx[i]) dfs2(i);
	for (int i = 0;i < m;i++) printf("%s\n", ((sccid[chA[i]] == sccid[chB[i]]) == (two[chA[i]][chB[i]]))?"same":"diff");
	return 0;
}


Measured memory_bytes: 5376
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
    }

    let mut v = vec![];
    for _ in 0..n {
        input! {
            a: u64,
            b: u64,
        }
        v.push((a, b));
    }
    v.sort();
    let mut left = m as u64;
    let mut ans = 0;
    for i in 0..n {
        let boughtnum = v[i].1.min(left) as u64;
        ans += v[i].0 * boughtnum;
        left -= boughtnum;
        if left == 0 {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5748
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
char a[5001][5001];
int main(){
  int i,j;
  int v,w,x[3000],y[3000],n;
  int mx;
  while(cin>>n&&n){
    memset(a,0,sizeof(a));
    for(i=0;i<n;i++){
      cin>>x[i]>>y[i];
      a[x[i]][y[i]]=1;
    }
    mx=0;
    for(i=0;i<n-1;i++){
      for(j=i+1;j<n;j++){
	v=x[i]-x[j];
	w=y[i]-y[j];
	if((x[i]-w>=0&&y[i]+v>=0&&x[j]-w>=0&&y[j]+v>=0&&x[i]-w<=5000&&y[i]+v<=5000&&x[j]-w<=5000&&y[j]+v<=5000&&a[x[i]-w][y[i]+v]&&a[x[j]-w][y[j]+v])||
	   (x[i]+w>=0&&y[i]-v>=0&&x[j]+w>=0&&y[j]-v>=0&&x[i]+w<=5000&&y[i]-v<=5000&&x[j]+w<=5000&&y[j]-v<=5000&&a[x[i]+w][y[i]-v]&&a[x[j]+w][y[j]-v]))
	  if(mx<v*v+w*w)
	    mx=v*v+w*w;
      }
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!
sx,sy,tx,ty=map(int,input().split())

if sx!=tx and sy!=ty:
    r1="R"*(tx-sx)+"U"*(ty-sy)+"L"*(sx-tx)+"D"*(sy-ty)
    r2="L"*(tx-sx)+"D"*(ty-sy)+"R"*(sx-tx)+"U"*(sy-ty)
    r3=("D" if (ty-sy)>0 else "U")+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"*(sx-tx+1)+"D"*(sy-ty+1)+("L" if (tx-sx)>0 else "R")
    r4=("U" if (ty-sy)>0 else "D")+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R"*(sx-tx+1)+"U"*(sy-ty+1)+("R" if (tx-sx)>0 else "D")

elif sx==tx:
    r1="R"+"U"*(ty-sy)+"D"*(sy-ty)+"L"
    r2="L"+"D"*(ty-sy)+"U"*(sy-ty)+"R"
    r3="U"*(ty-sy)+"D"*(sy-ty)
    r4=("U" if (ty-sy)>0 else "D")+"R"*2+("D"*(ty-sy+2) if (ty-sy)>0 else "U"*(sy-ty+2))+"L"*2+("U" if (ty-sy)>0 else "U")

elif sy==ty:
    r1="D"+"R"*(tx-sx)+"L"*(sx-tx)+"U"
    r2="U"+"L"*(tx-sx)+"R"*(sx-tx)+"D"
    r3="R"*(tx-sx)+"L"*(sx-tx)
    r4=("R" if (tx-sx)>0 else "L")+"D"*2+("L"*(tx-sx+2) if (tx-sx)>0 else "R"*(sx-tx+2))+"U"*2+("R" if (tx-sx)>0 else "L")

print(r1+r2+r3+r4)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;cin>>n;
	int cnt[100]={},id=0;
	while(n>0){
		cnt[++id]=(n%26==0?26:n%26);
		n=(n-cnt[id])/26;
	}
	for(int i=id;i>=1;i--)
		cout<<char(cnt[i]+'a'-1);
	return 0;
}

Measured memory_bytes: 3644
N = int(input())
H =   list(map(int,input().split(" ")))

bef = H[0]
temp = [bef]
for i in H[1:]:
    if i != bef:
        temp.append(i)
    bef = i

H = temp
l = len(H)
H[0] -=1
for i in range(1,l):
    if H[i] <  H[i - 1]:
        H[i - 1] -= 1

for i in range(l -1):
    if H[i] > H[i+1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 64084
#!/usr/bin/python
import sys,heapq
if 'pypy' in sys.version.lower():
	import rpython.rlib.streamio
	stream=rpython.rlib.streamio.fdopen_as_stream(sys.stdin.fileno(),'r')
	raw_input=stream.readline
	def cmp_lt(x,y): return x < y
	heapq.cmp_lt=cmp_lt
elif sys.version_info[0]>=3: raw_input=input

INF=1234567890123456789
COMPILE=123456789012
def compile(a,b,c):
	return ((a+COMPILE)<<18) | (b<<9) | c
def decompile(a):
	return ((a>>18)-COMPILE,(a>>9)&511,a&511)

def shortestPath(g,dist,prev):
	n = len(g)-1
	h = [INF]*n+[0]
	for k in range(n+1):
		for i in range(n+1):
			for e in g[i]:
				if h[e[1]]<INF and e[0]<INF and h[e[2]] > h[e[1]] + e[0]:
					h[e[2]] = h[e[1]] + e[0]
					if k==n: return False # negative cycle
	for i in range(n):
		for e in g[i]:
			e[0]+=h[i]-h[e[2]]
	for s in range(n):
		Q=[]
		heapq.heappush(Q,compile(0,s,s))
		while Q:
			e = decompile(heapq.heappop(Q))
			if prev[s][e[2]]!=-2: continue
			prev[s][e[2]] = e[1]
			for f in g[e[2]]:
				if e[0]<INF and f[0]<INF and dist[s][f[2]] > e[0] + f[0]:
					dist[s][f[2]] = e[0] + f[0]
					heapq.heappush(Q,compile(e[0]+f[0],f[1],f[2]))
		for u in range(n):
			if dist[s][u]<INF: dist[s][u] += h[u] - h[s]
	return True

def entry_point(argv):
	V,E=[int(e) for e in raw_input().rstrip().split(' ')]
	g=[[] for i in range(V+1)]
	dist=[[INF]*V for i in range(V)]
	prev=[[-2]*V for i in range(V)]
	for i in range(V): g[i].append([0,i,i])
	for i in range(V): g[V].append([0,V,i])
	for i in range(E):
		s,t,e=[int(e) for e in raw_input().rstrip().split(' ')]
		g[s].append([e,s,t])
	if not shortestPath(g,dist,prev):
		print("NEGATIVE CYCLE")
	else:
		for i in range(V):
			print(' '.join(["INF" if dist[i][j]>=INF else str(dist[i][j]) for j in range(V)]))
	return 0

def target(*args):
	return entry_point, None

if __name__ == '__main__': entry_point([])

Measured memory_bytes: 6216
#include<stdio.h>
#include<stdlib.h>

int main(void){

  int N;
  scanf("%d %d\n", &N);

  int A[7]={1,105,135,165,189,195,201};

  int ans=0;

  for(int i=0; i<=5; i++){
    if(A[i]<=N && N<A[i+1]){
      printf("%d\n", i);
      return 0;
    }
  }

  return 1;
}



Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
	int a,b,c;
	int flag = 0;
	scanf("%d%d%d",&a,&b,&c);
	int k = a % b;
	for(int i = 1; i <= b; i++)
		if((i*k)%b == c) {
			flag = 1;
			break;
		}
	if(flag) printf("YES\n");
	else printf("NO\n");
}

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

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

#define INF 1000000000

using namespace std;

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

    cout << ((N + 2 - 1) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	int count;
	int n, x;
	int i, j, k;

	while (true)
	{
		scanf("%d %d\n", &n, &x);
		if (n == 0 && x == 0)
			break;

		count = 0;
		for (i = 1; i <= n - 2; ++i)
		{
			for (j = i + 1; j <= n - 1; ++j)
			{
				k = x - i - j;
				if (j + 1 <= k && k <= n)
					count++;
			}
		}

		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll P, Q;

ll gcd(ll x, ll y){
    return (x%y==0 ? y : gcd(y, x%y));
}

ll cnt(ll t, ll x, ll y){
    ll res=(t/P)*Q;
    res += t%P;
    res -= (t%P)/x+(t%P)/y;
    return res;
}

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	P=C*D/gcd(C, D);
	Q=P-P/C-P/D+1;
	cout << cnt(B, C, D)-cnt(A-1, C, D) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

struct plan{
    int t, x, y;
};

int main(){
    int N; cin >> N;
    vector<plan> txy;
    txy.push_back(plan({0,0,0}));
    rep(i,N){
        int t, x, y; 
        cin >> t >> x >> y;
        txy.push_back(plan({t,x,y}));
    }
    for (int i = 0; i < N; i++){
        int time = txy[i+1].t - txy[i].t;
        int dist = abs(txy[i+1].x - txy[i].x) + abs(txy[i+1].y-txy[i].y);
        int diff = time-dist;
        if (diff < 0 || diff % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


}


Measured memory_bytes: 4976
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 3001
#define mod 1000000007
#define inf 1000000000000000
#define ll long long
#define endl '\n'
double dp[MAX][MAX],a;

int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	cin>>a;
	dp[0][0] = (1.0 - a);
	dp[0][1] = a;
	for(int i = 1; i < n ; i++){
		cin>>a;
		for(int j = 0; j < MAX ; j++){
			if(dp[i-1][j]){
				dp[i][j] += dp[i-1][j] * (1.0 - a);
				dp[i][j+1] += dp[i-1][j] * a;
			}
		}
	}
	double ans = 0.0;
	for(int j = n/2 + 1; j < MAX ; j ++)ans += dp[n-1][j];
	cout<<fixed<<setprecision(10)<<ans;
	return 0; 
} 

Measured memory_bytes: 68864
//header{{{
#include<bits/stdc++.h>
  
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 setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	int m = s.size();
	rep(i,m){
		if(s[i] + n > 'Z') s[i] = 'A' + abs('Z' - (s[i] + n)) - 1;
		else s[i] += n;
	}
	cout << s << '\n';

	return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);

typedef pair<int, int> p;

int main(){
  int n;
  scanf("%d", &n);

  vector<p> v(n);
  vector<p> w(n);
  int a, b;
  REP (j, 2) {
    REP (i, n) {
      scanf("%d %d", &a, &b);
      if (j == 0) v[i] = make_pair(b, a);
      else w[i] = make_pair(a, b);
    }
  }

  sort(v.begin(), v.end(), greater<p>() );
  sort(w.begin(), w.end());

  bool vd[n] = {};
  bool wd[n] = {};

  int ans = 0;
  REP (i, n) {
    REP (j, n) {
      if (!vd[i] && !wd[j] && v[i].second < w[j].first && v[i].first < w[j].second) {
        ans++;
        vd[i] = true;
        wd[j] = true;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    int ng=0;
    sort(a.begin(),a.end());
    rep(i,0,n-1){
        if(a[i]==a[i+1])ng=1;
    }
    if(ng)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 1792
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<i64> = read_vec();
    let (n, h) = (v[0], v[1]);
    let n = n as usize;
    let mut a = vec![0; n];
    let mut b = vec![0; n];
    for i in  0..n {
        let v: Vec<i64> = read_vec();
        a[i] = v[0];
        b[i] = v[1];
    }

    let a_max = *a.iter().max().unwrap();
    let mut strong_bs = Vec::new();
    for b_num in b {
        if b_num > a_max {
            strong_bs.push(b_num);
        }
    }
    strong_bs.sort();
    strong_bs.reverse();

    let mut ans = 0;
    let mut h = h;
    for b in strong_bs {
        ans += 1;
        h -= b;
        if h <= 0 {
            println!("{:?}", ans);
            return;
        }
    }
    if h % a_max == 0 {
        ans += h / a_max;
    } else {
        ans += h / a_max + 1;
    }
    println!("{:?}", ans);
}


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


int main(){
	string s;
	cin >> s;
	stack<char> t;
	t.push(s[0]);
	for (int i=1;i<s.length();i++){
		if (t.size()==0){
			t.push(s[i]);
			continue;
		}
		char a = t.top();
		if (a!=s[i]) t.pop();
		else t.push(s[i]);
	}
	cout << s.length()-t.size();
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n, m;
  scanf("%d %d",&n,&m);
  
  int cnt[30] = {};
  int k, a;
  for(int i = 0; i < n; i++){
    scanf("%d",&k);
    for(int j = 0; j < k; j++){
      scanf("%d",&a);
      cnt[a-1]++;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < m; i++){
    if(cnt[i] == n){
      ans++;
    }
  }
  printf("%d",ans);
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    ll k;
    cin>>k;
    vll a;
    ll num1=k/50,num2=k%50;
    rep(i,50)a.push_back(49);
    rep(i,50)a[i]+=num1;
    rep(i,50){
        if (i<num2)a[i]+=50-num2;
        else a[i]-=num2;
    }
    cout<<50<<endl;
    rep(i,50)cout<<a[i]<<" ";
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc130 {
    class ProgramB {
        args: string[];

        // 3 6
        // 3 4 5
        //
        // 2
        constructor(args: string[]) {
            this.args = args;
        }

        main(this: ProgramB) {

            const [n, x]: number[] = this.args[0].split(' ').map(Number);
            const l: number[] = this.args[1].split(' ').map(Number);

            let d: number = 0;
            let ans: number = 0;
            l.forEach((val: number) => {
                if (d <= x) ans++;
                d += val;
            });

            if (d <= x) ans++;


            console.log(ans);

        }
    }

    const args: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    new ProgramB(args).main();
}

Measured memory_bytes: 7372
package main

import(
	"fmt"
	"os"
	"bufio"
)

func main(){
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	defer out.Flush()

	var L, output float64

	fmt.Fscanf(in, "%f\n", &L)

	output = (L / 3) *(L / 3) *(L / 3)

	fmt.Fprintf(out, "%.10f\n", output)




}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const double pi=3.1415926536;
int main(){
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double anm=360*m/60,anh=360*h/12,ans;
	ans=anm-anh-anm/12;
	if(ans<0) ans+=360;
	cout<<setprecision(11)<<sqrt(a*a+b*b-2*a*b*cos(ans/180*pi));
	return 0;
}

Measured memory_bytes: 4212
#from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_3
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]

same_groups=[0]*(1<<n)
for i in range(1,1<<n):
    k=i
    rb=-k&k
    ri=rb.bit_length()-1
    ar=a[ri]
    k^=rb
    val=same_groups[k]
    while k:
        pb=-k&k
        val+=ar[pb.bit_length()-1]
        k^=pb
    same_groups[i]=val

dp=[0]*(1<<n)
for grp in range(1<<n):
    g=grp
    while g:
        dp[grp]=max(dp[grp],same_groups[g]+dp[grp^g])
        g=(g-1)&grp
print(dp[-1])


Measured memory_bytes: 42588
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		arr[i] = v
	}
	sorted := quickSortInt(arr)
	ans := float64(sorted[0])
	for _, v := range sorted {
		ans = (float64(v) + ans) / 2
	}
	fmt.Println(ans)
}

func quickSortInt(s []int) []int {
	if len(s) <= 1 {
		return s
	}
	if len(s) == 2 {
		if s[0] > s[1] {
			return []int{s[1], s[0]}
		}
		return s
	}
	head := 0
	tail := len(s) - 1
	var base int
	if s[0] > s[1] {
		base = s[0]
	} else {
		base = s[1]
	}
	leftFound := false
	rightFound := false
	for head <= tail {
		if !leftFound {
			if base <= s[head] {
				leftFound = true
			} else {
				head++
			}
		}
		if !rightFound {
			if base >= s[tail] {
				rightFound = true
			} else {
				tail--
			}
		}
		if leftFound && rightFound {
			s[head], s[tail] = s[tail], s[head]
			leftFound = false
			rightFound = false
			head++
			tail--
		}
	}
	return append(quickSortInt(s[0:head]), quickSortInt(s[head:])...)
}


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

int isprime(int n){
	if(n < 2) return false;
	for(int i=2;i*i<=n;i++)
		if(n % i == 0) return false;
	return true;
}

int memo[1121][188][15];

vector<int> prime;

int dfs(int n,int pos,int k){
	
	if(k == 0) return n==0;
	if(n <= 0) return 0;
	if(pos>=188) return 0;
	if(memo[n][pos][k] != -1) return memo[n][pos][k];
	
	int ans = 0;
	for(int j=0;j<=min(1,k);j++){
		ans += dfs(n - prime[pos]*j , pos+1 , k-j);
	}
	return memo[n][pos][k] = ans;
}
int main(){
	for(int i=0;i<1121;i++)
		for(int j=0;j<188;j++)
			for(int k=0;k<15;k++)
				memo[i][j][k] = -1;
	for(int i=0;i<=1120;i++) if( isprime(i) ) prime.push_back(i);
	int a,b;
	while( cin >> a >> b && (a || b) ){
		cout << dfs(a,0,b) << endl;
	}
	
}

Measured memory_bytes: 12000
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();
    static int mod = 1_000_000_007;
    static int MAX_N = 2000;
    static int[][] C = new int[MAX_N + 1][MAX_N + 1];
    static {
        for(int i = 0; i <= MAX_N; i++){
            Arrays.fill(C[i], -1);
            C[i][0] = C[i][i] = 1;
        }
    }
    static int c(int n, int r) {
        return n < r ? 0 :
        C[n][r] > -1 ? C[n][r] :
           n / 2 < r ? (C[n][r] = c(n, n - r)) :
                       (C[n][r] = (c(n - 1, r - 1) + c(n - 1, r)) % mod);
    }

    public static void main(String[] args) {
        int S = in.i();
        int ans = 0;

        for (int k = 1; ; k++) {
            int n = S - 3 * k;
            if (n < 0) {
                break;
            }
            int r = k - 1;
            ans = (ans + c(n + r, r)) % mod;
        }
        out.println(ans);
    }
}


class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

using namespace std;

int n;
int slimes[401];
long long memo[401][401] = {};

long long dp(int a, int b)
{
    if (a == b)
        return 0;
    if (memo[a][b] > 0)
        return memo[a][b];
    long long res = LLONG_MAX;
    long long sum = 0;
    for (int i = a; i < b; i++)
    {
        sum += slimes[i];
        res = min(res, dp(a, i) + dp(i + 1, b));
    }
    sum += slimes[b];
    res += sum;
    memo[a][b] = res;
    return res;
}

int main(void)
{
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    int ipt;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &slimes[i]);
    }
    long long res;
    res = dp(0, n - 1);
    cout << res << endl;
}

Measured memory_bytes: 4864
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = lr()
A.sort()
lack = A[2] - A[0] + (A[2] - A[1])
answer = lack // 2
if lack&1:
    answer += 2
print(answer)


Measured memory_bytes: 3064
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val W, H, x, y, r = sc.nextInt

    if (r <= x && x <= W - r && r <= y && y <= H - r) {
      println("Yes")
    }
    else {
      println("No")
    }


  }
}

Measured memory_bytes: 45072
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] l = new int[n];
        int cnt  =0;
        for(int i = 0;i<n;i++){
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);

        for(int i =n-1;i>=n-k;i--){
            cnt+=l[i];
        }
        System.out.println(cnt);
    }
}




Measured memory_bytes: 21972
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 1000000;

  for (int A = 1; A <= N-1; A++){
    int B = N-A;

    int sumA = 0, sumB = 0;
    int x = A, y = B;
    for (int k = 0; k < 6; k++){
      sumA += x % 10;
      sumB += y % 10;
      x /= 10;
      y /= 10;
    }
    if(ans > sumA+sumB) ans = sumA + sumB;
  }

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


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

int selectionSort(int *a, int n)
{
    int sw = 0;
    for (int i = 0; i < n - 1; i++) {
        int minj = i;
        for (int j = i + 1; j < n; j++)
            if (a[j] < a[minj]) minj = j;
        swap(a[i], a[minj]);
        if (i != minj)
            sw++;
    }
    return sw;
}

int main()
{
    int a[101], sw, n;

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

    sw = selectionSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}

Measured memory_bytes: 3104
#include <cstdio>

typedef long long ll;

ll gcd(ll x, ll y) { return !y ? x : gcd(y, x % y); }

int main(void)
{
	ll a, b, num, i, ans = 1;

	scanf("%lld %lld" ,&a, &b);

	num = gcd(a, b);

	for (i = 2; i * i <= num; i++)
		if (num % i == 0)
		{
			++ans;
			while (num % i == 0)
				num /= i;
		}
	if (num > 1)
		++ans;

	printf("%lld" ,ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

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

		while(true){
			int n = sc.nextInt();
			int q = sc.nextInt();
			if(n==0 && q==0) break;
			
			String[] s = new String[n];
			int[] a = new int[n];
			int[] b = new int[n];
			for(int i=0;i<n;i++){
				s[i] = sc.next();
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
			}
			
			boolean flag;
			int c;
			for(int i=0;i<q;i++){
				c = sc.nextInt();
				flag = false;
				for(int j=0;j<n;j++){
					if(b[j]-a[j]<c && c<=b[j]){
						for(int k=1;k<=a[j];k++){
							if(b[j]-a[j]+k==c){
								System.out.println(s[j] + " " + k);
								flag = true;
								j = n;
								break;
							}
						}
					}
				}
				if(flag==false) System.out.println("Unknown");
			}
		}
	}
}

Measured memory_bytes: 61744
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if((a-b)%2==0) {
      System.out.println("Alice");
    }
    else {
      System.out.println("Borys");
    }
  }
}

Measured memory_bytes: 23124
l, r = map(int, input().split())
l_mod = l % 2019
r_mod = r % 2019
if l + 2019 <= r:
    print(0)
    exit()
m = 3000
for i in range(l_mod, r_mod+1):
    for j in range(i+1, r_mod+1):
        m = min(m, i * j % 2019)
print(m)

Measured memory_bytes: 9044
def main():
    A, B, C = map(int, input().split())
    cnt = 0; flag = False
    for _ in range(pow(10,6)):
        if A%2 == 1 or B%2 == 1 or C%2 == 1:
            flag = True
            break
        A, B, C = B//2+C//2, A//2+C//2, A//2+B//2
        cnt += 1
    ans = flag*cnt + (not flag)*(-1)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, M, ans ;
  cin >> N >> M ;
  cout << N * M << endl ;
  return 0 ;
}  

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

#define INF 100000000

int main() {
    ll N; cin >> N;
    vector<ll> b;
    for(int i = 0; i < N - 1; i++){
        ll tmp; cin >> tmp; b.push_back(tmp);
    }

    ll a[110]; for(int i = 0; i < N; i++) a[i] = INF;
    ll sum = 0;
    for(int i = 0; i < N - 1; i++){
        a[i] = min(b[i], a[i]);
        sum += a[i];
        a[i+1] = b[i];
    }
    sum += a[N - 1];
    cout << sum << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    R, S, P = [int(x) for x in input().split()]
    T = input().strip()

    ans = 0
    for i in range(K):
        f = False
        for j in range(i, N, K):
            if j < K:
                if T[j] == 'r':
                    ans += P
                elif T[j] == 's':
                    ans += R
                else:
                    ans += S
            else:
                if T[j] == T[j - K] and not f:
                    f = True
                    continue
                else:
                    if T[j] == 'r':
                        ans += P
                    elif T[j] == 's':
                        ans += R
                    else:
                        ans += S
                    f = False
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
def is_good(s, sz):
    if len(s) != 2:
        return False
    if len(s[0]) != sz[0] or len(s[1]) != sz[1]:
        return False
    return True

sz = list(map(lambda x: int(x), input().split(' ')))
s = input().split('-')

if is_good(s, sz):
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int n,k,d,ans;
vector<bool>a;
int main(){
	cin>>n>>k;
	a.resize(n);
	int x;
	for(int i=0;i<k;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			cin>>x;
			a[--x]=1;
		}
	}
	
	for(int i=0;i<n;i++)ans+=1-a[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long D = sc.nextInt();
		long[] X = new long[N];
		long[] Y = new long[N];
		for(int i = 0;i < N;i++) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		sc.close();

		int result=0;
		for(int i = 0;i < N;i++) {
			if(Math.sqrt(D*D)>=Math.sqrt(X[i]*X[i]+Y[i]*Y[i])) {
				result++;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 62544
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    ll lenS = S.size();
    ll lenT = T.size();
    ll ans = inf;
    REP(i, 0, lenS - lenT + 1) {
        ll tmp = 0;
        REP(j, 0, lenT) {
            if (S[i + j] != T[j]) {
                tmp++;
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    int ans2 = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'R') {
            ans++;
            ans2 = max(ans, ans2);
        } else {
            ans = 0;
        }
    }

    cout << ans2 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n;
	cin>>n;
	string a = "";
	while(n){
		a+=((n-1)%26+'a');
		n=(n-1)/26;
	}
	reverse(all(a));
	cout<<a;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}


Measured memory_bytes: 3608