akhauriyash/Code-Regression huggingface dataset:
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 read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let s: String = read();
    let k: u32 = read();

    let cv: Vec<char> = s.chars().collect();

    let mut sv: Vec<String> = vec![];
    for i in 0..cv.len() {
        let mut tmpv: Vec<char> = vec![];
        for j in 0..5 {
            if i + j >= cv.len() {
                break;
            }
            tmpv.push(cv[i + j]);
            let tmp: String = tmpv.clone().into_iter().collect();
            sv.push(tmp);
        }
    }

    sv.sort();

    let mut cnt: u32 = 1;
    if k == 1 {
        println!("{}", sv[0]);
    } else {
        for i in 1..sv.len() {
            if sv[i] != sv[i - 1] {
                cnt += 1;
            }
            if cnt == k {
                println!("{}", sv[i]);
                break;
            }
        }
    }
}


Measured memory_bytes: 4352
N = int(input())
T = list(map(int,input().split()))
M = int(input())

d = {}
for i in range(N):
  d[i+1] = T[i]

for i in range(M):
  P, X = map(int,input().split())
  cv = d[P]
  d[P] = X
  print(sum(d.values()))
  d[P] = cv

Measured memory_bytes: 3060
class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

mod = 10 ** 9 + 7

N, *A = map(int, open(0).read().split())

mc = ModComb(10 ** 5 + 5, mod=mod)

used = {}
left, right = 0, 0
for i, a in enumerate(A):
    if a in used:
        right = i
        left = used[a]
        break
    used[a] = i

m = left + N - right
for k in range(1, N + 2):
    print((mc.nCk(N + 1, k) - mc.nCk(m, k - 1)) % mod)


Measured memory_bytes: 29280
S = list(input())

last = S.pop(0)
stack = [last]
can_pop = True
cnt = 0
for s in S:
    if last != s and can_pop:
        stack.pop()
        if len(stack) == 0:
            can_pop = False
        # stack.append(s) 読み捨て
        cnt += 2
    else:
        stack.append(s)
        last = s
        can_pop = True

print(cnt)


Measured memory_bytes: 4648
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int Q1, B, C1, C2, Q2; cin >> Q1;
		if (!Q1)break;
		cin>> B >> C1 >> C2 >> Q2;
		pair<int, int>ans=make_pair(-1,-1);
		for (int a = Q2; a >= 1; --a) {
			int rest = B - a*C1;
			if (rest < 0)continue;
			int n = rest / C2;
			if (a + n >= Q1) {

				ans = make_pair(a, n);
				break;
			}
		}
		if (ans.first == -1)cout << "NA" << endl;
		else cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    vector<ll>a(3);
    ll d;
    rep(i, 3) cin >> a[i];
    cin >> d;

    if(abs(a[0]-a[2]) <= d){
        cout << "Yes" << endl;
        return 0;
    }

    sort(all(a));

    if((a[1]-a[0] )<=d && (a[2]-a[1])<=d) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 384
using System;

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var input1 = int.Parse(Console.ReadLine());
            Console.WriteLine(Math.Pow(input1, 1) + Math.Pow(input1, 2) + Math.Pow(input1, 3));
        }
    }
}


Measured memory_bytes: 27860
#include <iostream>

using namespace std;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        cout<<s[i];
    }
    cout<<" ";
    for(int i=4;i<s.length();i++){
        cout<<s[i];
    }
    cout<<endl;
}

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

using namespace std;

int main(){
	int n, b, b_prev, cnt;
	scanf("%d", &n);
	scanf("%d", &b_prev);
	cnt = b_prev;
	for (int i = 1; i < n-1; ++i){
		scanf("%d", &b);
		cnt += min(b_prev,b);
		b_prev = b;
	}
	(n>2)?cnt += b : cnt +=b_prev;

	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
  int N; cin >> N;
  
  int cnt = 0;
  for (int i = 0; i * i <= N; i++){
    cnt = i;
  }
  cout << cnt * cnt << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [0] * 5
for _ in range(N):
  s = input()
  if s[0] == "M": S[0] += 1
  elif s[0] == "A": S[1] += 1
  elif s[0] == "R": S[2] += 1
  elif s[0] == "C": S[3] += 1
  elif s[0] == "H": S[4] += 1

import itertools
ans = 0
for v in itertools.combinations(S, 3):
  ans +=  v[0] * v[1] * v[2]
print(ans)

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

using namespace std;

using ll = long long;

ll gcd(ll a, ll b){
    if(a%b == 0){
        return b;
    }
    else
    {
        return gcd(b, a%b);
    }
    
    
}

int main(void){
    ll k;
    ll ans = 0;

    cin >> k;

    for(ll a=1; a<=k; a++){
        for(ll b=1; b<=k; b++){
            ll ab = gcd(a, b);
            for(ll c=1; c<=k; c++){
                ans += gcd(ab, c);
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define endl "\n"
#include <map>
#include <numeric>
#include <stack>
#define ll long long int
using namespace std;

bool containsDuplicate(vector<int>& nums) {
        int n=nums.size();
        nums.erase(unique(nums.begin(), nums.end()), nums.end());
        int m=nums.size();
        for(int i: nums)
        {
            cout << i << endl;
        }
        if(n==m){
            return false;
        }return true;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, ans=0;
    cin >> n;
    for(int i=1; i<=n; ++i)
    {
        int x;
        cin >> x;
        if(x%2 && i%2)
        {
            ++ans;
        }
    }cout << ans;

	return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
int N, M, n, m, a[501] = { -1000000000, 999999999 };
int main()
{
	scanf("%d%d%d%d", &N, &M, &n, &m);
	if (N % n)
	{
		puts("Yes");
		for (int i = 1; i <= N; i++)
			for (int j = 1; j <= M; j++)
				printf("%d%c", a[i % n], " \n"[j == M]);
	}
	else if (M % m)
	{
		puts("Yes");
		for (int i = 1; i <= N; i++)
			for (int j = 1; j <= M; j++)
				printf("%d%c", a[j % m], " \n"[j == M]);
	}
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 2816
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#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(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(C >= A && C <= B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//a
int main(){
  
  int N; cin >> N;
  if(N%10==3) cout << "bon" << endl;
  else if(N%10==0 || N%10==1 || N%10==6 || N%10==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
map<int,int> zz;
int N;
int a[MAXN];
void Solve() {
    read(N);
    int cnt = 0,p = 0;
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
	zz[a[i]]++;
    }
    for(auto t : zz) {
	++cnt;
	if(t.se % 2 == 0) p ^= 1;
    }
    out(cnt - p);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

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

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

    int m = 0;
    for(int i = n; i > 0; i--){
        for(int j = i + i; j <= n; j += i){
            A[i] ^= A[j];
        }
        if(A[i]) m++;
    }

    cout << m << endl;
    for(int i = 1; i <= n; i++){
        if(A[i]) cout << i << ' ';
    }

    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(1000000)

n = int(input())
li1 = list(map(int, input().split()))

li2 = []
for i in range(1, len(li1)):
    li2.append(li1[i-1] - li1[i])
    
cnt1 = 0
cnt2 = 0
li3 = []

for i in li2:
    cnt2 += 1
    if i < 0:
        li3.append(cnt1)
        cnt1 = 0
    else:
        cnt1 += 1

li3.append(cnt1)

print(max(li3))

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

typedef struct {
  int a;
  int b;
  char op;
} cal_set_t;

int main () {

  int a,b;
  char op = 0;
  std::vector <cal_set_t> v;

  while(op != '?') {
    std::cin >> a;
    std::cin >> op;
    std::cin >> b;
    v.push_back({a,b,op});
  }

  for (int n = 0; n < v.size() ; n++)
  {
    switch(v[n].op)
    {
      case '+' :
        std::cout << v[n].a + v[n].b << std::endl;
        break;
      case '-' :
        std::cout << v[n].a - v[n].b << std::endl;
        break;
      case '*' :
        std::cout << v[n].a * v[n].b << std::endl;
        break;
      case '/' :
        std::cout << v[n].a / v[n].b << std::endl; 
        break;
      default :
        break;
    }
    /*
    if (v[n].op == '+')
      std::cout << v[n].a + v[n].b << std::endl;
    else if (v[n].op == '-')
      std::cout << v[n].a - v[n].b << std::endl;
    else if (v[n].op == '*')
      std::cout << v[n].a * v[n].b << std::endl;
    else if (v[n].op == '/')
      std::cout << v[n].a / v[n].b << std::endl;
    */
  }

  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;

using ll = long long;

class rolling_hash {
public:
    rolling_hash(std::string const& s)
        : n(s.size()),
          v(n+1, 0),
          p(n+1, 1)
    {
        for(int i=0; i<n; ++i) {
            v[i+1] = (v[i] * B + s[i]);// % mod;
        }
        for(int i=0; i<n; ++i) {
            p[i+1] = p[i] * B ;//% mod;
        }
    }

    ll query(int l, int r) {
        return (v[r] - p[r-l+1] * v[l-1] );// % mod;
    }

private:
    int n;
    std::vector<ll> v;
    std::vector<ll> p;

    static const ll mod = 1000000000000037LL;
    static const ll B = 100000007LL;
};


int main() {
    int n, m;
    string s;
    cin >> n >> m;
    cin >> s;
    int l = 1, r = 1;
    rolling_hash h(s);
    set<ll> s2;
    for(int i=0; i<m; ++i) {
        string q;
        cin >> q;
        if(q == "L++") {
            l++;
        } else if(q == "L--") {
            l--;
        } else if(q == "R++") {
            r++;
        } else {
            r--;
        }
        s2.insert(h.query(l, r));
    }
    cout << s2.size() << endl;
}


Measured memory_bytes: 21864
class Integer
  def mod_pow(n, mod = 10 ** 9 + 7)
    x = self
    res = 1

    while n > 0
      res = res * x % mod if n[0] == 1
      x = x * x % mod
      n >>= 1
    end

    res
  end

  def mod_inverse(mod = 10 ** 9 + 7)
    mod_pow(mod - 2, mod)
  end
end

require 'prime'

MOD = 10 ** 9 + 7
N = gets.to_i
A = gets.split.map(&:to_i)

primes = Hash.new(0)

A.each do |a|
  a.prime_division.each do |n, e|
    if primes[n] < e
      primes[n] = e
    end
  end
end

lcm = 1

primes.each do |n, e|
  e.times do
    lcm *= n
    lcm %= MOD
  end
end

ans = 0

A.each do |a|
  ans += lcm * a.mod_inverse
  ans %= MOD
end

puts ans



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

int main() {
  int a,N;
  string s;
  double ans = 0;

  cin >> N;

  for ( int i; i < N; i++ ){
    cin >> a;
    ans += 1.0 / (double)a;
  }
    ans = 1.0 / ans;
    cout << setprecision(10) << ans << endl;
}

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

vector<string> split(string str, char del){
    int first = 0;
    int last = str.find_first_of(del);

    vector<string> result;

    while (first < str.size()){
        string subStr(str, first, last - first);
        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if (last == string::npos){
            last = str.size();
        }
    }

    return result;
}

int main (){
    string str;
    cin >> str;
    char del = ',';
    for (const auto subStr : split(str, del)){
        cout << subStr << ' ';
    }
}

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

const ll MOD = 1e9 + 7;

ll fast_pow(ll n, ll r){
  ll ret = 1;
  while(r > 0){
    if(r % 2 == 1){
      ret *= n;
      ret %= MOD;
    }
    n *= n;
    n %= MOD;
    r /= 2;
  }
  return ret;
}

ll inv(ll x){
  if(fast_pow(x, MOD - 2) != 0)
    return fast_pow(x, MOD - 2);
  else
    return MOD;
}

int main() {
  ll N, a, b;
  cin >> N >> a >> b;

  ll ans = fast_pow(2, N) - 1;
  ll tmp_ue = 1LL;
  ll tmp_shita = 1LL;

  for(ll i = 0; i < a; i++){
    tmp_ue *= (N - i);
    tmp_ue %= MOD;
    tmp_shita *= inv(i+1);
    tmp_shita %= MOD;
  }

  ans -= (tmp_ue * tmp_shita) % MOD;
  ans %= MOD;

  tmp_ue = 1LL;
  tmp_shita = 1LL;

  for(ll i = 0; i < b; i++){
    tmp_ue *= (N - i);
    tmp_ue %= MOD;
    tmp_shita *= inv(i+1);
    tmp_shita %= MOD;
  }

  ans -= (tmp_ue * tmp_shita) % MOD;
  ans %= MOD;

  while(ans < 0) ans += MOD;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
#define pi 3.141592653589
//#define mod 998244353 
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

/*___________________________TEMPLATE END______________________________*/

signed main() {
    quickie
    int h1, m1, h2, m2, m ;
    cin >> h1 >> m1 >> h2 >> m2 >> m ;
    int H = h2-h1 , M = m2-m1 ;
    int t = H*60+M ;
    cout << t-m << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a); 
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,k;
    cin >> n >> k;
    long double rs = 0;
    for (int i = 1; i <= n; i++){
        long double now = (1 / (long double) n);
        for (int score = i; score < k; score*=2){
            now*= (long double) 1 / 2;
        }
        // db(now);
        rs+=now;
    }
    cout << fixed << setprecision(9) << rs;
    return 0;
}


Measured memory_bytes: 3748
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

ll x, y;

bool read() {
	if  (scanf("%lld%lld", &x, &y) < 2) {
		return 0;
	}
	return 1;
}

int solve() {
	int ans = 0;
	while (x <= y) {
		++ans;
		x *= 2;
	}
	return ans;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		printf("%d\n", solve());
	}

#ifdef LOCAL
	eprintf("Time: %.10f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int k;
    cin>>k;
    vector<int> a(k+1);
    if(k%2!=0){
        int ans=1;
        int mod7=7;
        while(mod7%k!=0){
            a[mod7]++;
            if(a[mod7]>1){
                cout<<-1<<endl;
                return 0;
            }
            mod7=10*mod7+7;
            mod7%=k;
            ++ans;
        }
        cout<<ans<<endl;
        return 0;
    }
    cout<<-1<<endl;
    return 0;
}


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

S = input()

min_num = N+1

W = []
E = []

w_cnt = 0
e_cnt = 0

for i in range(N):
    if S[i] == 'W':
        w_cnt += 1
    W.append(w_cnt)

for i in range(N-1,0,-1):
    min_num = min(min_num,W[i-1]+e_cnt)
    if S[i] == 'E':
        e_cnt += 1

print(min(min_num,e_cnt))



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll a[51];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    ll cnt=0;
    while(1){
        ll sum=0;
        bool flag=true;
        rep(i,n) sum+=a[i]/n;
        cnt+=sum;
        rep(i,n){
            a[i]+=sum-a[i]/n-a[i]/n*n;
            if(a[i]>=n) flag=false;
        }
        if(flag) break;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main(){
	int x; cin >> x;
	int ans=1;
	if(x<=3) {
		cout << ans << endl;
		return 0;
	}
	for(int i=2;;i++){
		int j=i*i;
		while(j<=x){
			ans=max(ans,j);
			j*=i;
		}
		if(j==i*i) break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long int
main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	for(ll k=0; k<n; k++){
		b[k]=a[k];
	}
	sort(b,b+n);
	for(ll j=0; j<n; j++)
	{
		if(a[j]==b[n-1])cout<<b[n-2]<<endl;
		if(a[j]!=b[n-1])cout<<b[n-1]<<endl;
	}
}

Measured memory_bytes: 4736
#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 rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int n; cin >> n;
	int mi = INF,ma = -INF;
	ll sum = 0;
	rep(i, n)
	{
		int tmp;cin>> tmp;
		sum += tmp;
		chmin(mi,tmp);
		chmax(ma,tmp);
	}
	cout << mi<<" "<< ma <<" "<< sum << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    for (int i = 1; i < n; ++i) {
        ll mul_a = (a[i-1] + a[i] - 1) / a[i];
        ll mul_b = (b[i-1] + b[i] - 1) / b[i];
        ll mul = max(mul_a, mul_b);
        a[i] *= mul; b[i] *= mul;
    }
    cout << a[n-1] + b[n-1] << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long int
#define ld long double

using namespace std;


int main()

{

ios_base::sync_with_stdio(false);
cin.tie(NULL);




   {

    ll s;
    cin>>s;
    map<ll,ll> A;

    A[s]++;
    ll q=s;
    ll j=1;

    while(true)
    {  j++;  ll m;
        if(q%2==0)
        {
            m=(q/2);


        }
        else
        {
            m=((q*3)+1);
        }


        if(A[m]==1)
        {
            cout<<j<<endl;
            break;
        }
        A[m]++;
        q=m;

    }


   }


return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N;
string S1, S2;

void solve() {
  ll ans;
  int k;
  if (S1[0] == S2[0]) {
    ans = 3; k = 1;
  } else {
    ans = 6; k = 2;
  }
  for (int i = k; i < N; i++) {
    if (S1[i] == S2[i]) {
      if (S1[i - 1] == S2[i - 1]) {
        ans = (ans * 2) % BASE;
      }
    } else {
      if (S1[i - 1] == S2[i - 1]) {
        ans = (ans * 2) % BASE;
      } else {
        ans = (ans * 3) % BASE;
      }
      i++;
    }
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define push_back pb
#define make_pair mp
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=1e5+10;
ll n,sum;
char a[N][10];
map<string,int> mp;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]);
		sort(a[i],a[i]+10);
		mp[a[i]]++;
		sum+=mp[a[i]]-1;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 12160
min_1=100; min_2=100
sum_1=0; sum_2=0

for i in range(4):
    a=int(input())
    sum_1+=a
    if a<min_1:
        min_1=a

sum_1=sum_1-min_1
    
for j in range(2):
    b=int(input())
    sum_2+=b
    if b<min_2:
        min_2=b
    
sum_2=sum_2-min_2
    
print(sum_1+sum_2)


Measured memory_bytes: 5588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   cin >> n;
   map<string,vector<pair<int,int>>> m;
   rep(i,n){
      string s;
      int tmp;
      cin >> s >> tmp;
      m[s].push_back({tmp,i+1});
   } 
   for (auto w:m){
      sort(w.second.begin(),w.second.end());
      for (int i = w.second.size()-1; i >= 0; i--){
         cout << w.second[i].second << endl;
      }
   }
   return 0;
   
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ll x, y, z, p;
	cin >> x >> y >> z >> p;
	vector<ll> a(x), b(y), c(z);
	rep(i,x) cin >> a[i];
	rep(i,y) cin >> b[i];
	rep(i,z) cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	vector<ll> ans;
	rep(i,x)rep(j,y)rep(k,z){
		if((i+1)*(j+1)*(k+1)<=p) ans.push_back(a[i]+b[j]+c[k]);
		else break;
	}
	sort(ans.rbegin(), ans.rend());
	rep(i,p) cout << ans[i] << endl;
}

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

signed main() {
  int Q,H,S,D,N;
  cin>>Q>>H>>S>>D>>N;
  int k2=Q*8;
  k2=min(k2,H*4);
  k2=min(k2,S*2);
  k2=min(k2,D);
  int k1=Q*4;
  k1=min(k1,H*2);
  k1=min(k1,S);
  cout<<(N/2)*k2+(N%2)*k1<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

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

	string x;
	cin >> x;

	vi pos;

	int n = sz(x);
	rep(i, 0, n - 1)
		if (x[i] == 'R' && x[i + 1] == 'L')
			pos.push_back(i + 1);

	vi ans(n);
	rep(i, 0, n)
	{
		if (x[i] == 'R')
		{
			int nxt = lower_bound(all(pos), i) - pos.begin();
			int diff = pos[nxt] - 1 - i, to = pos[nxt] - 1;
			if (diff % 2 != 0)
				to++;
			ans[to]++;
		}
		else
		{
			int nxt = upper_bound(all(pos), i) - pos.begin();
			nxt--;
			int diff = i - pos[nxt] - 1, to = pos[nxt] - 1;
			if (diff & 1)
				to++;
			ans[to]++;
		}
	}

	rep(i, 0, n)
		cout << ans[i] << " ";

	return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1e+7;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int main(){
    int n;cin>>n;int a,b;cin>>a>>b;
    vector<int> p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int c1=0,c2=0,c3=0;
    for(int i=0;i<n;i++){
        if(p[i]<=a){
            c1++;
        }else if(p[i]>b){
            c3++;
        }else{
            c2++;
        }
    }
    cout<<min(c1,min(c2,c3))<<endl;
}   


Measured memory_bytes: 256
from sys import exit

def kaibun(s):
    i = 0
    N = len(s)
    if N % 2 == 1:
        while i < (N - 1) // 2:
            if s[i] != s[N - 1 - i]:
                print("No")
                exit()
            i += 1
    else:
        while i < N // 2:
            if s[i] != s[N - 1 - i]:
                print("No")
                exit()
            i += 1


s = input()
s_1 = s[0: (len(s) - 1) // 2]
s_2 = s[(len(s) + 1) // 2:]
kaibun(s)
kaibun(s_1)
kaibun(s_2)
print("Yes")


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define FS first
#define SC second
#define M 2000020
using namespace std;
int read(){
	int nm=0,fh=1;char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
set<pii >s;
int p[M],n;
bool tg=true;
bool add(int pos,int now){
	pii K;
	if(pos<1) return false;
	K=*s.lower_bound(mp(pos,0));
	if(K.FS!=pos) s.insert(mp(pos,0)),K=mp(pos,0);
	else
	{
		s.erase(K),K.SC++;
		if(K.SC>=now){if(!add(pos-1,now))return false;}	
		else s.insert(K);
	}
	while(true){
		if(s.upper_bound(K)==s.end())
			break;
		K=*s.upper_bound(K);
		s.erase(K);
	} return true;
}
bool check(int pos){
	s.clear(),tg=true;
	for(int i=1;i<=n;i++) if(p[i]<=p[i-1]){
		if(!add(p[i],pos-1)) return false;
	} return true;
}
int solve(){
	int l=2,r=n-1,now=n;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) now=mid,r=mid-1;
		else l=mid+1;
	} return now;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) p[i]=read(),tg&=(p[i]>p[i-1]);
	if(tg){puts("1");return 0;}
	printf("%d\n",solve()); 
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,k; cin >> a >> b >> c >> k;
    while(a >= b){
        b *= 2;
        k--;
    }
    while(b >= c){
        c *= 2;
        k--;
    }
    cout << (k < 0 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

typedef long long int ll;
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<ll> v(n+1);
  for(int i=1; i<n+1; i++)
    cin >> v[i];
  ll dp[100001][2];
  dp[0][0] = 0;
  dp[0][1] = numeric_limits<ll>::min() / 2;
  for(int i=1; i<n+1; i++) {
    dp[i][0] = max(dp[i-1][0]+v[i], dp[i-1][1]-v[i]);
    dp[i][1] = max(dp[i-1][0]-v[i], dp[i-1][1]+v[i]);
  }
  std::cout << dp[n][0] << std::endl;
}


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

long calc(int way,double ritu,int tesu,long s,int year){
     int rishi=0;
     switch(way){
     case 0:
	  for(int i=0;i<year;i++){
	       rishi+=(int)(s*ritu);
	       s-=tesu;
	  }
	  return s+rishi;
	  break;
     case 1:
	  for(int i=0;i<year;i++){
	       s+=(long)s*ritu;
	       s-=tesu;
	  }
	  return s;
	  break;
     }
     return 0;
}

int main(){
     int M;
     cin>>M;
     int ans[M];

     for(int k=0;k<M;k++){
	  long shikin;
	  int year;
	  cin>>shikin>>year;
	  int N;
	  cin>>N;
	  int karians=0;
	  for(int k1=0;k1<N;k1++){
	       int w,t;
	       double r;
	       cin>>w>>r>>t;
	       karians=max(calc(w,r,t,shikin,year),(long)karians);
	  }
	  ans[k]=karians;
     }
     for(int i=0;i<M;i++)cout<<ans[i]<<endl;
}
	       

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int n,k,x,y;cin>>n>>k>>x>>y;
    if(k>=n)cout<<n*x<<endl;
    else cout<<k*x+(n-k)*y<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 300002;

string s;
ll n,ans=0;
set<char> l,r;

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

	FOR(i,0,s.size()){
		set<char> l,r;
		FOR(j,0,i){
			l.insert(s[j]);
		}
		FOR(j,i,s.size()){
			if(l.count(s[j]))r.insert(s[j]);
		}
		ans=TO(ans<r.size(),r.size(),ans);
	}
	pri(ans);
	return 0;
}


Measured memory_bytes: 256
num = [int(i) for i in input()]

r = 7-num[0]

for i in range(2):
  for j in range(2):
    for k in range(2):
      l = (-1)**i * num[1] + (-1)**j * num[2] + (-1)**k * num[3]
      if l == r:
        if i == 0:
          first = '+'
        else:
          first = '-'
        if j == 0:
          second = '+'
        else:
          second = '-'
        if k == 0:
          third = '+'
        else:
          third = '-'
        print('{}{}{}{}{}{}{}=7'.format(num[0],first,num[1],second,num[2],third,num[3]))
        exit()
        
      
          
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    int N, K;
    cin >> N >> K;
    
    int ans = 1;
    
    for(int i = 0; i < N; i++){
        if(ans*2 < ans + K){
            ans *= 2;
        }
        else{
            ans += K;
        }
    }
    
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
/*
    Problem 60
    https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_C
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int V, E;
    cin >> V >> E;
    vector<vector<ll>>G(V, vector<ll>(V, LINF));
    for (int i = 0; i < E; i++) {
        ll u, v, w;
        cin >> u >> v >> w;
        G[u][v] = w;
    }
    for (int i = 0; i < V; i++) G[i][i] = 0;

    // floyd
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            if (G[i][k] == LINF) continue;
            for (int j = 0; j < V; j++) {
                if (G[k][j] == LINF) continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    bool negative = false;
    for (int i = 0; i < V; i++) if (G[i][i] < 0) negative = true;
    if (negative) cout << "NEGATIVE CYCLE" << '\n';
    else {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (j) cout << ' ';
                if (G[i][j] == LINF) cout << "INF";
                else cout << G[i][j];
            }
            cout << '\n';
        }
    }
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  unordered_map<char, bool> mp;
  for(int i=0;i<s.size();i++){
    mp[s.at(i)]|=true;
  }
  string ans="None";
  for(int i=0;i<=int('z'-'a');i++){
    if(!mp[char('a'+ i)]){ans=char('a' + i);break;}
  }
  cout << ans << endl;
}

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

const int N = 1e5+5, INF = 0x3f3f3f3f;
int n, k, a[N], dp[N];

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

  for (int i = 0; i < n; i++)
    scanf("%d", a+i);

  for (int i = 1; i < k; i++)
    dp[i] = abs(a[0] - a[i]);

  for (int i = k; i < n; i++) {
    dp[i] = INF;
    for (int j = 1; j <= k; j++)
      dp[i] = std::min(dp[i], abs(a[i] - a[i-j]) + dp[i-j]);
  }

  printf("%d\n", dp[n-1]);
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	char s[1024];
	int len;

	scanf("%s", s);
	len = strlen(s);

	if(len >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

/* waffle */


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
#include<unordered_map>
#include<set>
using namespace std;

int a[1000];
signed main() {
	int b; cin >> b;
	for (int c = 0; c < b; c++) {
		scanf("%d", &a[c]);
	}
	int MAX = -1;
	for (int d = 0; d < b - 1; d++) {
		for (int e = d + 1; e < b; e++) {
			string f = to_string(a[d]*a[e]);
			bool h = true;
			for (int g = 1; g < f.length(); g++) {
				if (f[g] - f[g - 1] != 1)h = false;
			}
			if (h)MAX = max(MAX, a[d] * a[e]);
		}
	}
	cout << MAX << endl;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    string S;
    std::cin >> S;

    vector<vector<int>> dp(N, vector<int>(10, -1));
    REP(i, S.size()) {
        if(i != 0) {
            REP(j, 10) {
                dp[N - i - 1][j] = dp[N - i][j];
            }
        }
        dp[N - i - 1][(S[N - i - 1] - '0')] = N - i - 1;
    }

    ll ans = 0;
    REP(i, 10) {
        auto ii = dp[0][i];
        if(ii == -1 || ii == N - 1) continue;
        REP(j, 10) {
            auto ji = dp[ii + 1][j];
            if(ji == -1 || ji <= ii || ji == N - 1) continue;
            REP(k, 10) {
                auto ki = dp[ji + 1][k];
                if(ki == -1 || ki <= ji) continue;
                ans++;
            }
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<cstring>
#include<cctype>
using namespace std;

int main(){

  char w[11] , t[1001];
  int sum=0;

  cin >> w;

  for(int i=0; i<(int)strlen(w); i++)
    w[i] = toupper(w[i]);

  while(1){
    cin >> t;



    if(strcmp(t,"END_OF_TEXT")==0)
      break;


    for(int i=0; i<(int)strlen(t); i++)
      t[i] = toupper(t[i]);


    if(strcmp(t,w)==0)

      sum++;

  }

  cout << sum << endl;


  return 0;
}

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

int main(){
    string str;
    
    while(1){
        getline(cin,str);
        if(str == "END OF INPUT") break;
        
        int cnt = 0;
        for(int i = 0 ; i < str.size() ; i++){
            cnt++;
            if(str[i] == ' '){
                cout << cnt-1;
                cnt = 0;
            }
            if(str[i] == str[str.size()-1] && i == str.size()-1) cout << cnt << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	string s;
	cin >> n >> s;
	rep(i, 4) {
		string t = "";
		rep(j, 2) {
			if ((i >> j) & 1) t += 'S';
			else t += 'W';
		}
		for (int i = 1; i < n - 1; i++) {
			int cnt = 0;
			if (t[i - 1] == 'S') cnt ^= 1;
			if (t[i] == 'S') cnt ^= 1;
			if (s[i] == 'o') cnt ^= 1;
			if (cnt) t += 'S';
			else t += 'W';
		}
		int check = 0;
		if (t[n - 2] == 'S') check ^= 1;
		if (t[n - 1] == 'S') check ^= 1;
		if (t[0] == 'S') check ^= 1;
		if (s[n - 1] == 'o') check ^= 1;
		if (check) continue;
		if (t[n - 1] == 'S') check ^= 1;
		if (t[0] == 'S') check ^= 1;
		if (t[1] == 'S') check ^= 1;
		if (s[0] == 'o') check ^= 1;
		if (check) continue;
		cout << t << '\n';
		return 0;
	}
	cout << -1 << '\n';
}

Measured memory_bytes: 720
import itertools
H,W,K=map(int,input().split())
C=[input() for i in range(H)]
ans=0
for i in range(H+1):
  for j in range(W+1):
    for n in itertools.combinations(list(range(H)),i):
      for m in itertools.combinations(list(range(W)),j):
        count = 0
        for a in n:
          for b in m:
            if(C[a][b]=="#"):count+=1
        if(count == K):
          ans += 1
print(ans)

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

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

  int N;
  cin >> N;
  vector<int> a(N), b(N);
  vector<vector<int>> dp(1 << N, vector<int>(51, INF));
  for (int i = 0; i < N; ++i) cin >> a[i];
  for (int i = 0; i < N; ++i) cin >> b[i];

  dp[0][0] = 0;

  for (int i = 0; i < (1 << N); ++i) {
    vector<int> cnt(N, 0);
    for (int k = N - 2; k >= 0; --k) {
      cnt[k] = cnt[k + 1];
      if ((i >> (k + 1)) % 2 == 1) ++cnt[k];
    }

    int usedCnt = 0, tmp = i;
    while (tmp > 0) {
      if (tmp % 2) ++usedCnt;
      tmp /= 2;
    }
    for (int j = 0; j < N; ++j) {
      if ((i >> j) % 2 == 1) continue;
      int nxtBit = i + (1 << j);

      int nxtNum = (usedCnt % 2 == j % 2) ? a[j] : b[j];
      for (int k = 0; k <= nxtNum; ++k) {
        dp[nxtBit][nxtNum] = min(dp[i][k] + cnt[j], dp[nxtBit][nxtNum]);
      }
    }
  }

  int ans = INF;
  for (int i = 0; i < 51; ++i) {
    ans = min(ans, dp[(1 << N) - 1][i]);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 63744