akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
 
//足したり引いたりすると勝手にmodをとってくれる
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
 
//コンビネーションのライブラリ
struct combination {
    //factのなかに階乗を求めている
    //ifactのなかに階乗逆元を求めている
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
 

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}
 
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}

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

int main() {
	int report[12][10] = { 0 };
	int n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		report[(b - 1) * 3 + f - 1][r - 1] += v;
	}

	for (int i = 0; i < 12; i++)
	{
		if (i % 3 == 0 && i!=0)
		{
			for (int j = 0; j < 20; j++) {
				cout << "#";
			}
			cout << endl;
		}
		for (int j = 0; j < 10; j++)
		{
			cout << ' ' << report[i][j];
		}
		cout << endl;
	}
		
	return 0;
}

Measured memory_bytes: 3072
n, k = map(int, input().split())
p_lis = list(map(int, input().split()))
def calc_ex(num):
    return (num - 1) * 0.5 + 1
cur_num = 0
for i in range(k):
    cur_num += p_lis[i]
max_nums = cur_num
max_nums_i = 0
for i in range(len(p_lis) - k):
    cur_num -= p_lis[i]
    cur_num += p_lis[i + k]
    if max_nums < cur_num:
        max_nums = cur_num
        max_nums_i = i + 1
res = 0
for i in range(max_nums_i, max_nums_i + k):
    res += calc_ex(p_lis[i])
print(res)    

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		Integer num = Integer.parseInt(br.readLine());

		for(int i = 0; i < num; i++){

			String str;
			if((str=br.readLine())!=null){
				String[] sp = str.split(" ");
				int a =Integer.parseInt(sp[0]);
				int b =Integer.parseInt(sp[1]);

				if(a % b == 0){
					System.out.println(b);
				} else{
					System.out.println(a % b);
				}
			}
		}
	}

}

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

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


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

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

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

#endif

// main.cpp

int main() {
  i64 x;
  std::cin >> x;
  std::cout << 1 - x << '\n';
  return 0;
}

Measured memory_bytes: 3604
# coding: utf-8
# Your code here!

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))#親ノード
        self.size = [1]*n #グループの要素数

    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            x, self.parent[x] = self.parent[x], self.parent[self.parent[x]]
        return x 
 
    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if self.size[x] < self.size[y]: 
            self.size[y] += self.size[x] #yの要素数を更新
            self.parent[x] = y #xをyにつなぐ
        else:
            self.size[x] += self.size[y] #xの要素数を更新
            self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]

n = int(input())
xy = [[int(i) for i in input().split()] for j in range(n)] 

UF = UnionFind(n)

xval = dict()
yval = dict()
for i,(x,y) in enumerate(xy):
    if y in yval:
        UF.merge(i,yval[y])
    else:
        yval[y] = i

    if x in xval:
        UF.merge(i,xval[x])
    else:
        xval[x] = i


xcon = dict()
ycon = dict()
for i in range(n):
    pi = UF.root(i)
    x,y = xy[i]
    if pi in xcon:
        xcon[pi].add(x)
    else:
        xcon[pi] = {x}

    if pi in ycon:
        ycon[pi].add(y)
    else:
        ycon[pi] = {y}
        

ans = -n
#print(xcon,ycon)
for key, val in xcon.items():
    ans += len(val) * len(ycon[key])

#print(UF.parent)
#print(xval,yval)

print(ans)







Measured memory_bytes: 91224
implicit none 
integer :: n,i
integer,allocatable :: a(:)
real(8) :: s

read *,n
allocate(a(n))
read *,a

s = 0.0
do i = 1, n
   s = s + 1.0/real(a(i),kind=8)
enddo

print '(f20.10)',1/s
end

Measured memory_bytes: 512
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

ll f(ll n, ll x) {
	if (n % x == 0) {
		return 2 * n - x;
	}
	else {
		return (n / x) * (2 * x) + f(x, n % x);
	}
}

ll n, x;

int main() {

    cin >> n >> x;
	cout << f(n - x, x) + n;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e,n;
    cin>>a>>b>>c>>d>>e>>n;
    if(e-a<=n)cout << "Yay!"<<endl;
    else cout <<":("<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	int x, ma = 0;
	cin >> x;

	for (LL i = 1; i <= 100; i++) {
		for (LL j = 2; j < 10; j++) {
			if (pow(i, j) > 1000)break;
			if (pow(i, j) <= x) {
				ma = max(ma, (int)pow(i, j));
			}
		}
	}
	cout << ma << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int D, T, S; cin >> D >> T >> S;
	if (D <= T * S) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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


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

int main(){
    ll N,P;cin>>N>>P;
    ll i=2;ll ans=1;
    ll count=0;
    while(P%i==0){
        count++;
        P/=i;
    }
    if(count>=N)ans*=pow(i,count/N);
    i++;
    while(i<=sqrt(P)+1){
        ll count=0;
        while(P%i==0){
            count++;
            P/=i;
        }
        if(count>=N)ans*=pow(i,count/N);
        i+=2;
    }
    if(N==1)ans*=P;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int H, A;
    cin >> H >> A;

    cout << (H + A - 1) / A << endl;

    return 0;
}

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

#define SIZE 100
#define WMAX 100000

long long dp[SIZE + 1][WMAX + 1] = {0};
long long w[SIZE + 1] = {0}, v[SIZE + 1] = {0};

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

  for (int i = 1; i <= N; i++) {
    cin >> w[i] >> v[i];
  }

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i]) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    int N;
    cin >> N;
    map<int, int> M;
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        M[a]++;
    }

    ll Big=0, Small=0;
    for(auto m:M) {
        if(m.second >= 4) {
            Big = m.first, Small = m.first;
        }
        else if(m.second >= 2) {
            swap(Big, Small);
            Big = m.first;
        }
    }
    cout << Big * Small << endl;
}

Measured memory_bytes: 8276
from itertools import permutations
n = int(input())
x = []
y = []
ans,count,tempx,tempy = 0,0,0,0
for _ in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
order = list(permutations(range(n)))
for i in order:
    for j in i:
        if j == i[0]:
            tempx = x[j]
            tempy = y[j]
            continue
        count += (((x[j]-tempx)**2)+((y[j]-tempy)**2)) ** (0.5) 
        tempx = x[j]
        tempy = y[j]
    ans += count / len(order)
    count = 0
print(ans)

Measured memory_bytes: 13988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

int main() {
	long long N, A, B; std::cin >> N >> A >> B;
	if ((B - A) % 2 == 0)
		std::cout << (B - A) / 2 << std::endl;
	else
		std::cout << (std::min(A - 1, N - B) + (B - A - 1) / 2 + 1)<< std::endl;
}


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

int main(void) {
    
    int N,K; 
    cin>>N>>K;
    
    if(N%2==0){
        if(K<=N/2){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;

        }
    }else{
        if(K<=(N+1)/2){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;            
        }
    }
return 0;
} 

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

using namespace std;

string s;

int main()
{
  cin >> s;

  int ctr[26] = {};
  if (s[0] == s[1]) {
    cout << "1 2" << endl;
    return 0;
  }
  ctr[s[0]-'a']++;
  ctr[s[1]-'a']++;
  for (int i = 2; i < s.size(); i++) {
    ctr[s[i]-'a']++;
    if (ctr[s[i]-'a'] >= 2) {
      cout << i-1 << " " << i+1 << endl;
      return 0;
    }
    ctr[s[i-2]-'a']--;
  }

  cout << "-1 -1" << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>

using namespace std;

const int dh[2]={1, 0};
const int dw[2]={0, 1};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    for(int h=0; h<H; h++) {
        cin >> field[h];
    }
    
    vector<vector<bool> > seen(H, vector<bool>(W, false));
    queue<pair<int, int> > que;
    que.push(make_pair(0, 0));
    bool flag=true;
    while(!que.empty()) {
        if(que.size()>1) {
            flag = false;
            break;
        }
        pair<int, int> cur;
        cur = que.front(); que.pop();
        seen[cur.first][cur.second] = true;

        bool break_or_not=false;
        if(cur.first>0) {
            for(int w=cur.second; w<W; w++) {
                if(field[cur.first-1][w]=='#' && !seen[cur.first-1][w]) {
                    flag = false;
                    break_or_not = true;
                    break;
                }
            }
        }
        if(break_or_not) break;
        if(cur.second>0) {
            for(int h=cur.first; h<H; h++) {
                if(field[h][cur.second-1]=='#' && !seen[h][cur.second-1]) {
                    flag = false;
                    break_or_not = true;
                }
            }
        }
        if(break_or_not) break;
        
        for(int i=0; i<2; i++) {
            int nh=cur.first+dh[i];
            int nw=cur.second+dw[i];
            
            if(nh>=H || nw>=W) continue;
            if(field[nh][nw]=='.') continue;
            if(seen[nh][nw]) continue;
            
            que.push(make_pair(nh, nw));
        }
        
        if((cur.first!=H-1 || cur.second!=W-1) && que.empty()) {
            flag = false;
        }
    }
    
    if(flag) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
		t=(t<<3)+(t<<1)+v-48;
		v=getchar();
	}
	return t;
}
using namespace std;
int n,p[2002],x,y;
signed main(){
	n=read();x=read();y=read();
	for(re int i=1;i<=n;++i)for(re int j=i+1;j<=n;++j)++p[min(j-i,abs(i-x)+1+abs(j-y))];
	for(re int i=1;i<n;++i)printf("%d\n",p[i]);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	while (cin >> N, N)
	{
		vi B(N + 1100, -1);
		vi A(N);
		vs S(N);
		for (int i = 0; i < N; i++)
		{
			cin >> S[i];
			for (int j = 0; j < S[i].size(); j++)
			{
				if (S[i][j] != '.')
				{
					A[i] = j;
					if (j > 0)S[i][j - 1] = '+';
					break;
				}
				else
				{
					S[i][j] = ' ';
				}
			}
			if (B[A[i]] >= 1)
			{
				bool flag = true;
				for (int j = B[A[i]] + 1; j < i; j++)
				{
					if (A[j] < A[i])flag = false;
				}
				if (flag)
				{
					for (int j = B[A[i]] + 1; j < i; j++)
					{
						S[j][A[i] - 1] = '|';
					}
				}
			}
			B[A[i]] = i;
		}
		for (int i = 0; i < N; i++)
		{
			cout << S[i] << endl;
		}
	}
}


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

class matching {
  public:
  vector< vector<int> > g;
  vector<int> pa;
  vector<int> pb;
  vector<int> was;
  int n, m;
  int res;
  int iter;

  matching(int _n, int _m) : n(_n), m(_m) {
    assert(0 <= n && 0 <= m);
    pa = vector<int>(n, -1);
    pb = vector<int>(m, -1);
    was = vector<int>(n, 0);
    g.resize(n);
    res = 0;
    iter = 0;
  }

  void add(int from, int to) {
    assert(0 <= from && from < n && 0 <= to && to < m);
    g[from].push_back(to);
  }

  bool dfs(int v) {
    was[v] = iter;
    for (int u : g[v]) {
      if (pb[u] == -1) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    for (int u : g[v]) {
      if (was[pb[u]] != iter && dfs(pb[u])) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    return false;
  }

  int solve() {
    while (true) {
      iter++;
      int add = 0;
      for (int i = 0; i < n; i++) {
        if (pa[i] == -1 && dfs(i)) {
          add++;
        }
      }
      if (add == 0) {
        break;
      }
      res += add;
    }
    return res;
  }

  int run_one(int v) {
    if (pa[v] != -1) {
      return 0;
    }
    iter++;
    return (int) dfs(v);
  }
};

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  matching st(n - 1, n);
  vector<vector<int>> e(n - 1);
  range(i, 0, n - 1) {
    int sz;
    cin >> sz;
    range(j, 0, sz) {
      int a;
      cin >> a;
      a--;
      e[i].push_back(a);
      st.add(i, a);
    }
  }
  if(st.solve() != n - 1) {
    cout << -1;
    return 0;
  }
  vector<int> pb = st.pb;
  vector<int> pa = st.pa;
  pa.resize(n);
  range(i, 0, n) if(pb[i] == -1) {
    pb[i] = n - 1;
    pa[n - 1] = i;
  }
  vector<vector<int>> g(n);
  range(i, 0, n - 1) {
    for(int u : e[i]) {
      g[pb[u]].push_back(i);
    }
  }
  vector<int> was(n);
  vector<int> par(n, -1);
  function<void(int, int)> dfs = [&](int v, int p) {
    was[v] = 1;
    par[v] = p;
    for(int u : g[v]) {
      if(was[u]) continue;
      dfs(u, v);
    }
  };
  dfs(n - 1, -1);
  if(count(was.begin(), was.end(), 0) > 1) {
    cout << -1;
    return 0;
  }
  range(i, 0, n - 1) {
    cout << pa[i] + 1 << " " << pa[par[i]] + 1 << endl;
  }
  return 0;
}


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

using namespace std;

#define PMAX (55555+10)
int pt[PMAX]; // 0 is prime

void make(){
    for (int i = 2; i <= PMAX; i++) {
        if (pt[i] == 0) {
            for (int j = i * 2; j <= PMAX; j += i) {
                pt[j] = 1;
            }
        }
    }
}


int main(void){
    make();

    int N;
    cin >> N;

    vector<int> s;

    for(int i=0, p = 2;i<N;){
        while(pt[p]) p++;
        if(p%5==1){
            s.push_back(p);
            i++;
        }
        p++;
    }

    for(auto& x:s){
        cout << x << " ";
    }
    cout << endl;

    return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) (a)*(a)

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b;
	char op;
	
	cin >> a >> op >> b;
	
	if (op == '+') cout << a+b << '\n';
	else if (op == '-') cout << a-b << '\n';
	
	return 0;
}





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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(n*a, b);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
//	cin>>n>>k;
//	cout<<n<<k<<endl;
//string S[100];

int main(){
	int N,K,X,Y;cin>>N>>K>>X>>Y;
	int ans;

	for(int i=1;i<N+1;i++){
		if(K<i){
			ans+=Y;

		}else{
			ans+=X;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import scala.collection.immutable.{Stack, Queue}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main extends App{
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val s = sc.next
    
    def seqFromString(s: String): Seq[Char] = (0 until s.length).map(i => s.charAt(i))
    
    // println(s"${seqFromString(s).toSet}")
    
    def aAndB(a: String, b: String): Int = {
        val va = seqFromString(a).toSet
        val vb = seqFromString(b).toSet
        (va intersect vb).size
    }

    val splits = (1 until s.length-1).map(x => {
        s.splitAt(x) match {
            case (a, b) => {
                aAndB(a, b)
            }
        }
    })
    
    println(s"${splits.foldLeft(0)((acc, x) => Math.max(acc, x))}")
}


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

#define lld long long
#define pii pair<int,int>
#define pb push_back
#define next nextt
#define Size 4000

using namespace std;

int N;
char s[100002];

int main(){
	scanf("%s",s);
	N = strlen(s);
	if(N%2 == 1) printf("%s\n",s[0] == s[N-1] ? "Second" : "First");
	else printf("%s\n",s[0] == s[N-1] ? "First" : "Second");

	return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
from heapq import heappush, heappop
N, M = map(int, input().split())
dic = defaultdict(list)
Els = []
for i in range(M):
  a, b, c = map(int, input().split())
  dic[a-1] += [(b-1,c)]
  dic[b-1] += [(a-1, c)]
  Els += [(a-1,b-1,c)]

def dijkstra(s,e):
  dist = [float('inf')]*N
  dist[s] = 0
  q = [(0,s)]
  z = -1
  while q:
    c, v = heappop(q)
    if dist[v]<c:
      continue
    dist[v] = c
    for u, m in dic[v]:
      if dist[u]>dist[v]+m:
        dist[u] = dist[v]+m
        heappush(q,(dist[u],u))
        if u==e:
          z = v
  return z

ans = 0
for a, b, c in Els:
  if dijkstra(a,b)!=a:
    ans += 1
print(ans)

Measured memory_bytes: 64092
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

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

using namespace std;

int main(){
	double N, K;
	double work, work1;
	double ind;
	cin >> N >> K;
	ind = K;

	vector < pair< double, double > > p;

	for(int i = 0; i < N; i++){
		cin >> work >> work1;
		p.push_back(make_pair(work, work1));
	}
	sort(p.begin(), p.end());


/*	for(int i = 0; i < p.size(); i++){
		cout << p[i].first << " " << p[i].second << endl;
	}*/

	double cnt = 0;
	while(ind > 0){
//		cout << " aaaa" << endl;
//		cout << " " << cnt << ":" << p[cnt].second << endl;
		ind -= p[cnt].second;
		cnt++;
	}
	cout << p[cnt - 1].first << endl;

	return 0;
}


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = 0;
    if(a>b) ans = 0;
    else if (a==b) ans = 1;
    else if(n==1&&a!=b) ans = 0;
    else{
        ans = n*(b-a)+2*a-2*b+1;
    }
    COUT(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> k(N);
  for(int i=0;i<N;i++)cin>>k.at(i);
  int cnt=0;
  for(int j=1;j<N-1;j++){
    if(k.at(j-1)+k.at(j)+k.at(j+1)-max(k.at(j-1),max(k.at(j),k.at(j+1)))-min(k.at(j-1),min(k.at(j),k.at(j+1)))==k.at(j))cnt++;
  }
  cout<<cnt<<endl;
}
    


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

using namespace std;

typedef long long ll;

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

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

/*
 * ref. [Union-Find](https://www.slideshare.net/chokudai/union-find-49066733)
 * ref. [AtCoder ABC 157 - AtCoder Live](https://www.youtube.com/watch?v=TdR816rqc3s)
 */
class UnionFind {
    public:
        UnionFind(int n = 0): d(n, -1) {}

        // 0-index, [0, n) in other words
        int find(int x) {
            if (d[x] < 0) return x;
            return d[x] = find(d[x]);
        }

        // Return false if x and y are alreday in the same group, otherwise return true.
        // 0-index, [0, n) in other words
        bool unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return false;
            if (d[x] > d[y]) swap(x, y);
            d[x] += d[y];
            d[y] = x;
            return true;
        }

        // 0-index, [0, n) in other words
        bool same(int x, int y) {
            return find(x) == find(y);
        }

        // 0-index, [0, n) in other words
        int size(int x) {
            return -d[find(x)];
        }

    private:
        vector<int> d;
};

vector<pair<int, int>> bridges;

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

    bridges.resize(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        bridges[i] = {a, b};
    }
    reverse(bridges.begin(), bridges.end());

    UnionFind uf(N);

    vector<ll> ans(M + 1, 0);
    for (int i = 0; i < M; i++) {
        int a = bridges[i].first;
        int b = bridges[i].second;
        ll na = (ll) uf.size(a);
        ll nb = (ll) uf.size(b);
        if (uf.unite(a, b)) {
            ans[i + 1] = ans[i] + na * nb;
        } else {
            ans[i + 1] = ans[i];
        }
    }

    ll reachable_pairs_num = ans[M];
    // printf("reachable_pairs_num: %lld\n", reachable_pairs_num);
    for (int i = M - 1; i >= 0; i--) {
        ans[i] = reachable_pairs_num - ans[i];
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cmath>

using namespace std;

double CalcurateTheta(double, double, double, double, double, double);
double CalcurateLength(double, double, double, double);
int CheckRadian(double);

int main(){
  double xa, ya, xb, yb, xc, yc, xd, yd;
  double a, b, c, d, w, x, y, z; 
  char c1, c2, c3, c4, c5, c6, c7;

  while(cin >> xa >> c1 >> ya >> c2 >> xb >> c3 >> yb >> c4 >> xc >> c5 >> yc >> c6 >> xd >> c7 >> yd){
    a = CalcurateTheta(xa, ya, xb, yb, xd, yd);
    b = CalcurateTheta(xb, yb, xc, yc, xa, ya);
    c = CalcurateTheta(xc, yc, xd, yd, xb, yb);
    d = CalcurateTheta(xd, yd, xa, ya, xc, yc);

    w = CheckRadian(a+b+d);
    x = CheckRadian(b+c+a);
    y = CheckRadian(c+d+b);
    z = CheckRadian(d+a+c);

    if(w == 1 && x == 1 && y == 1 && z == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

double CalcurateTheta(double xa, double ya, double xb, double yb, double xc, double yc){
  double a, b, c, cos_theta, theta;

  a = CalcurateLength(xa, ya, xb, yb);
  b = CalcurateLength(xc, yc, xa, ya);
  c = CalcurateLength(xb, yb, xc, yc);

  cos_theta = (a*a + b*b - c*c)/(2*a*b);
  theta = acos(cos_theta);

  return theta;
}

double CalcurateLength(double x1, double y1, double x2, double y2){
  double a, b, c;

  a = x2 - x1;
  b = y2 - y1;
  c = sqrt(a*a + b*b);

  return c;
}

int CheckRadian(double radian){
  if(radian > M_PI)
    return 1;
  else
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  cout << b-(a-b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n,i,min,max,A;
  int *R;
  while(1){
  scanf("%d",&n);
  if(n>=2 && n<=200000)break;
  }
  R = (int*)malloc(sizeof(int)*n);
  for(i=0 ; i<n ; i++){
    while(1){
      scanf("%d",&R[i]);
      if(R[i]>=1 && R[i]<=1000000000)break;
    }
  }
  min=R[0];
  max=R[1]-min;
  for(i=1 ; i<n ; i++){
    if(max<R[i]-min)max=R[i]-min;
    if(min>R[i])min=R[i];
  }
  printf("%d\n",max);
  free(R);
  return 0;
}



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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    string s;
    cin>>s;
    rep(i,12){
        if(i==4)cout<<" ";
        cout<<s[i];
    }cout<<endl;

    return 0;

}
/*


*/


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

int dist(int x1, int y1, int x2, int y2) {
  return abs(x2 - x1) + abs(y2 - y1);
}

int main() {
  int N;
  cin >> N;
  int x4 = 0;
  int x2 = 0;
  int x1 = 0;

  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    if (d % 2 == 1) {
      x1++;
    } else if (d % 4 == 0) {
      x4++;
    } else {
      x2++;
    }
  }
  x1 += x2 % 2;
  if (x1 - 1 <= x4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
  ll A, B; cin>>A>>B;
  if((B-1)%(A-1)==0) cout<<(B-1)/(A-1)<<endl;
  else cout<<1+(B-1)/(A-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];
    int size[M_N];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            size[i]=1;
        }
    }

    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            size[y]+=size[x];
        }
        else{
            par[y]=x;
            size[x]+=size[y];
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    int get_size(int x){
        return size[find(x)];
    }
};

int main(){
    LL n,m,q;cin >> n >> m >> q;
    vector<vector<P>> a(2);
    for (int i = 0; i < q; i++) {
        int x,y,c;cin >> x >> y >> c;
        a[c].pb(mp(x,y));
    }
    if(m==n-1&&a[1].size()){
        puts("No");
        return 0;
    }
    UnionFind uf;
    uf.init(n+1);
    for (int i = 0; i < a[0].size(); i++) {
        uf.unite(a[0][i].fs,a[0][i].sc);
    }
    for (int i = 0; i < a[1].size(); i++) {
        if(uf.same(a[1][i].fs,a[1][i].sc)){
            puts("No");
            return 0;
        }
    }
    LL k = 0,mm = 0;
    for (int i = 0; i < n; i++) {
        if(uf.find(i)==i){
            mm += uf.get_size(i) - 1;
            k++;
        }
    }
    if(k<=2&&a[1].size()){
        puts("No");
        return 0;
    }
    if(m<=mm+k*(k-1)/2) puts("Yes");
    else puts("No");
    return 0;
}


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

int main() {
    long long W, H, x, y;
    cin >> W >> H >> x >> y;
    double res = (double)(W) * H / 2;
    cout << fixed << setprecision(10) << res << " ";
 
    if (x*2 == W && y * 2 == H) cout << 1 << endl;
    else cout << 0 << endl;
}

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

const int MAXN = 3e5 + 10;
int dis[MAXN], n, m, S, T;
vector<int> Mat[MAXN];
bool se[MAXN];
queue<int> BFS;

void addv(int v) {
	int a = v / 3;
	int nxt = v % 3 + 1;
	nxt %= 3;
	for (int u : Mat[a]) {
		int t = 3 * u + nxt;
		if (se[t])
			continue;
		se[t] = 1;
		BFS.push(t);
		dis[t] = dis[v] + 1;
	}
}

int main() {
	for (int i = 0; i < MAXN; i++)
		dis[i] = -3;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		Mat[a].push_back(b);
	}
	cin >> S >> T;
	dis[3 * S] = 0;
	se[3 * S] = 1;
	BFS.push(3 * S);
	while (!BFS.empty())
		addv(BFS.front()), BFS.pop();
	cout << dis[3 * T] / 3;
}

Measured memory_bytes: 11904
#include <stdio.h>
#include <string.h>

#define M  1000003
#define L 12

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return (key % (M-1)) +1; }

int find(char str[]){
  int key,i,j;

  key = getKey(str);
  for(i = 0; i < M; i++){
    j = (h1(key) + i*h2(key)) % M;
    if(H[j][0] == '\0') return 0;
    else if(strcmp(H[j],str) == 0){
      return 1;
      break;
    }
  }
}

int insert(char str[]){
  int key,i,j;

  key = getKey(str);
  for(i = 0; i < M; i++){
    j = (h1(key) + i*h2(key)) % M;
    if(H[j][0] == '\0'){
      strcpy(H[j], str);
      break;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      }    else {
        printf("no\n");
      }
    }
  }

  return 0;
}



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

int main() {
    int N; cin >> N;
    
    long long ans = 1, a = 1, b = 1, c = 1;
    for (int i = 0; i < N; i++) {
        a *= 10; b *= 9; c *= 8;
        a %= 1000000007;
        b %= 1000000007;
        c %= 1000000007;
    }
    
    ans = a - 2 * b + c;
    ans %= 1000000007;
    if (ans >= 0) cout << ans << endl;
    else cout << ans + 1000000007 << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((a+b)<(c+d)) cout<<"Right";
  else if((a+b)>(c+d)) cout<<"Left";
  else cout<<"Balanced";


}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, begin, end) for( int i = begin; i < end; i++ )
using namespace std;
 
string button[10] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
 
int main() {
    int n;
    cin >> n;
    rep( i, 0, n ) {
        string input, message = "";
        cin >> input;
        int key = 0, position = 0;
        rep( i, 0, input.size() ) {
            if ( input[i] == '0' ) {
                if ( key == 0 )
                    continue;
                position %= button[key].size();
                message += button[key][position];
                key = 0;
                position = 0;
            }
            else if ( key == 0 ) {
                key = input[i] - '0';
                position = 0;
            }
            else if ( key == input[i] - '0') {
                position++;
            }
        }
        cout << message << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long lli;

int main() {
  lli M, rd, rr, cd, cr;
  cin >> M >> rd >> rr >> cd >> cr;
  lli xd = cd*100/rd;
  while(xd*rd/100 < cd) ++xd;
  if(xd > M) {
    cout << -1 << endl;
    return 0;
  }
  M -= xd;
  lli remd = xd*rd/100 - cd;

  lli xr = cr*100/rr;
  while(xr*rr/100 < cr) ++xr;
  if(xr > M) {
    cout << -1 << endl;
    return 0;
  }
  M -= xr;
  lli remr = xr*rr/100 - cr;

  M += remd * 100 / rd;
  M += remr * 100 / rr;

  cout << M << endl;
  return 0;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int S = Integer.parseInt(line);
        int h = S/3600;
        int m = S%3600/60;
        int s = S%60%60;
        String time = String.format("%s:%s:%s",h,m,s);
        System.out.println(time);
    }
}

Measured memory_bytes: 16904
n, k = map(int, input().split())
a = list(map(int, input().split()))
 
mod = 10 ** 9 + 7
# 配列内で自身より小さい数の個数　前後別に求める
b = [[0, 0] for _ in range(n)]
for i in range(n):
    for j  in range(i,n):
        if a[i] > a[j]:
                b[i][1] += 1
        elif a[i] < a[j]:
        		b[i][0] +=1


b[i][0]=b[i][0]%mod		
b[i][1]=b[i][1]%mod	
ans = 0
sigmakp = ((k * (k+1) ) // 2) % mod

sigmakn = ((k * (k-1)) // 2) % mod

for i in range(n):
    mae = int(sigmakn * b[i][0]) % mod
    ushiro = int(sigmakp * b[i][1]) % mod
    ans = int((mae + ushiro) + ans) % mod 
print(ans)


Measured memory_bytes: 3312
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	int ans_water = 0, ans_sugar = 0;
	double ans_n = 0.0;
	for (int i = 0; i <= F / (100 * A); i++) {
		int max_water = F - (100 * A * i);
		for (int j = 0; j <= max_water / (100 * B); j++) {
			int water = 100 * A * i + 100 * B * j;
			for (int l = 0; l <= (E * (water / 100)) / C; l++) {
				int max_sugar = (E * (water / 100)) - (C * l);
				for (int k = 0; k <= max_sugar / D; k++) {
					//cout << i << " " << j << " " << l << " " << k << endl;
					int sugar = C * l + D * k;
					if (water + sugar <= F) {
						if (water != 0) {
							double n = (double)((100.0 * sugar) / (water + sugar));
							if (n > ans_n) {
								ans_water = water;
								ans_sugar = sugar;
								ans_n = n;
							}
							//cout << i << " " << j << " " << l << " " << k << endl;
						}
					}

				}
			}
		}
	}
	if (ans_water == 0) {
		ans_water = 100 * A;
	}
	cout << ans_water + ans_sugar << " " << ans_sugar << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=5005;
string ch[maxn*6];
char s[maxn];
int n,k,cnt;
int main(){
	scanf("%s%d",s,&k),n=strlen(s);
	for(int i=0,T;i<n;i++){
		ch[++cnt]=s[i];
		T=min(k,n-i);
		for(int j=1;j<T;j++,cnt++) ch[cnt+1]=ch[cnt]+s[i+j];
	}
	
	sort(ch+1,ch+cnt+1);
	unique(ch+1,ch+cnt+1);
	cout<<ch[k]<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>


int main() {

  int n,G[101][101];
  int i,j,k,l,u,a,t;


  scanf("%d",&n);

  for(i=0;i<n+1;i++)
    for(j=0;j<n+1;j++) {
      G[i][j] = 0;

    }

  for(i=0;i<n;i++){

    scanf("%d %d ",&k,&u);
    //    printf("u = %d\n",u);

    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k -1][a-1] = 1;
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
    
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) {
      printf("%d",G[i][j]);
      if(j != n-1) printf(" ");
    }
    printf("\n");
  }


  return 0;

    
    
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n,k;
	string s;
	cin>>n>>k;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(i!=k-1){
			cout<<s[i];
		}else{
			printf("%c",s[i]-'A'+'a');
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	int n;
	cin >> n;
	int p = 1;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if (x == p) {
			p++;
		}else {
			cnt++;
		}
	}
	if (p == 1)cout << -1;
	else 
	cout << cnt;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll>>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].first>>v[i].second;
    }
  sort(v.begin(),v.end());
  ll c=0;
  for(int i=0;i<n;i++)
    {
        c+=v[i].second;
        if(c>=k)
        {
            cout<<v[i].first;
            break;
        }
    }
}


Measured memory_bytes: 4816
def main():
	S = input()
	b = S[0]
	is_good = True
	for i in range(1, 4):
		if b == S[i]:
			is_good = False
		b = S[i]
	if is_good:
		print("Good")
	else:
		print("Bad")


if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 1000

int lcs(char *,char *);
int max(int,int);

int main(){
  char str1[N],str2[N];
  int n,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str1);
    scanf("%s",str2);
 
    printf("%d\n",lcs(str1,str2));

  }

  return 0;
  
}

int lcs(char *b,char *c){
  int a[N+1][N+1];
  int m,n,i,j,maxl=0;
  char str1[N],str2[N];
  m=strlen(b);
  n=strlen(c);
  
  str1[0]=' ';
  str2[0]=' ';
  strcpy(&str1[1],b);
  strcpy(&str2[1],c);
  for(i=0;i<=m;i++) a[i][0] = 0;
  for(j=1;j<=n;j++) a[0][j] = 0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(str1[i]==str2[j]) a[i][j] = a[i-1][j-1]+1;
      else a[i][j] = max(a[i-1][j],a[i][j-1]);

      maxl=max(maxl,a[i][j]);
    }

  }
  return maxl;
}

int max(int x,int y){
  int m;
  if(x>y) m=x;
  else m=y;
  return m;
}



Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = ~(1<<28);

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int nodeNum;
    cin >> nodeNum;
    Graph<int> nodes(nodeNum, vint());
    vint dist(nodeNum, -1);
    rep(i, nodeNum) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int v;
            cin >> v;
            nodes[u - 1].push_back(v - 1);
        }
    }

    std::queue<int> now;
    std::queue<int> next;
    next.push(0);
    int tmpdist = 0;
    while(!next.empty()) {
        now = next;
        next = std::queue<int>();
        while(!now.empty()) {
            int id = now.front();
            now.pop();
            if (dist[id] == -1) {
                dist[id] = tmpdist;
                for(auto& subid : nodes[id])
                next.push(subid);
            }
        }
        tmpdist++;
    }
    rep(i, nodeNum) {
        cout << i+1 << " " << dist[i] << endl;
    }
}


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

typedef vector< pair<string, int> > VP;


string rec(VP m)
{
	if(m.size() == 1){
		if(m.begin()->second == 10){
			return m.begin()->first;
		}else{
			return "0";
		}
	}
	
	for(VP::iterator it=m.begin();it != m.end();it++){
		for(VP::iterator jt=m.begin();jt != m.end();jt++){
			if( it == jt) continue;
			string res;
			VP tmp, tmp2;
			for(VP::iterator kt=m.begin();kt != m.end();kt++){
				if( kt==it || kt==jt ) continue;
				tmp.push_back(*kt);
			}
			
			tmp2 = tmp;
			string exp = string("(") + it->first + string("+") + jt->first + string(")");
			tmp2.push_back( make_pair(exp, it->second+jt->second) );
			res = rec(tmp2);
			if(res != "0") return res;
			
			tmp2 = tmp;
			exp = string("(") + it->first + string("-") + jt->first + string(")");
			tmp2.push_back( make_pair(exp, it->second - jt->second) );
			res = rec(tmp2);
			if(res != "0") return res;
			
			tmp2 = tmp;
			exp = string("(") + it->first + string("*") + jt->first + string(")");
			tmp2.push_back( make_pair(exp, it->second * jt->second) );
			res = rec(tmp2);
			if(res != "0") return res;
		}
	}
	return "0";
}

int main()
{
	vector<int> v(4);
	string tmp;
	VP m;
	while(1){
		cin >> v[0] >> v[1] >> v[2] >> v[3];
		if(! (v[0] || v[1] || v[2] || v[3] )) break;
		m.clear();
		
		for(int i=0;i<4;i++){
			tmp = "";
			tmp += v[i] + '0';
			m.push_back( make_pair(tmp, v[i] ) );
		}
		
		cout << rec(m) <<endl;
	}
	return 0;
}

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

#define LL long long int 
#define ii pair<int, int>
#define x first
#define y second
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<ii>
#define mp make_pair
#define pb push_back
#define INF int(1e9)
#define MOD 1000000007
#define TAM int(2e5)

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);

    cout << setprecision(9) << fixed;

    int r;

    cin >> r;

    cout << (double)2*M_PI*r << endl;

    return 0;
}

Measured memory_bytes: 3808