akhauriyash/Code-Regression huggingface dataset:
// type b
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod = (lint)1000000007;
#pragma endregion

int h, w, a, b;
bool input() {
	cin >> h >> w >> a >> b;
	if (h % a == 0 && w % b == 0) {
		puts("No");
		return false;
	}
	else return true;
}
void solve() {
	puts("Yes");
	if (h % a != 0) {
		vector<lint> H(h + 1);
		H[0] = 0;
		for (int i = 1; i <= h; i++) {
			if (i < a) {
				H[i] = 10000000;
			}
			else {
				H[i] = H[i - a] - 1;
			}
		}
		vector<lint> ans(h);
		for (int i = 0; i < h; i++) {
			ans[i] = H[i + 1] - H[i];
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << ans[i];
				if (j != w - 1) cout << ' ';
				else cout << endl;
			}
		}
		return;
	}
	else {
		vector<lint> W(w + 1);
		W[0] = 0;
		for (int i = 1; i <= w; i++) {
			if (i < b) {
				W[i] = 10000000;
			}
			else {
				W[i] = W[i - b] - 1;
			}
		}
		vector<lint> ans(w);
		for (int i = 0; i < w; i++) {
			ans[i] = W[i + 1] - W[i];
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << ans[j];
				if (j != w - 1) cout << ' ';
				else cout << endl;
			}
		}
		return;
	}
}

int main(void) {
	if (!input()) return 0;
	solve();
	
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,a=0, b=0, c=0, d=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    //cin >> n;
    //cin >> x >> y;
    //cin >> s >> t;
    vector<int> A(3);
    REP(i, 3)
        cin >> A[i];
        SORT(A);
        cout << A[0] + A[1];
}

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

using Weight = int;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

vector<int> kosaraju(const Graph &g){
    int n = g.size(), sz = 0; Graph rg(n);
    vector<int> stk, cmp(n, -1), added(n), visited(n), ord(n);
    for(const Edges &es : g){
        sz += es.size();
        for(const Edge &e : es) rg[e.dst].eb(e.dst, e.src, e.weight);
    }
    stk.resize(n + sz); sz = 0;
    for(int i = 0; i < n; i++){
        if(visited[i]) continue;
        int s = 0; stk[s++] = i;
        while(s != 0){
            int v = stk[s-1]; visited[v] = true;
            bool pushed = false;
            for(auto & e : g[v]){
                int dst = e.dst;
                if(!visited[dst]){ stk[s++] = dst; pushed = true; }
            }
            if(pushed) continue;
            int t = stk[s-1];
            if(!added[t]){ added[t] = true; ord[sz++] = t; }
            --s;
        }
    }
    int k = 0;
    for(int i = 0; i < n; i++){
        int u = ord[n-i-1];
        if(cmp[u] != -1) continue;
        int s = 0; stk[s++] = u;
        while(s != 0){
            int v = stk[--s]; cmp[v] = k;
            for(auto & e : rg[v]){
                int d = e.dst;
                if(cmp[d] == -1) stk[s++] = d;
            }
        }
        ++k;
    }
    return cmp;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    Graph g(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        g[a].eb(a,b,0);
    }
    vector<int> c = kosaraju(g);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        cin >> a >> b;
        cout << (c[a] == c[b]) << '\n';
    }
}

Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll P = 1000000007;
ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}
int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  ll ans = 0;
  vvl tbl = VV(k+1, 0, 0, ll);
  for(int i=1;i<=k;i++) for(int j=2*i;j<=k;j+=i) tbl[j].push_back(i);

  vll num(k+1, 0);
  for(ll i=k;i>=1;i--){
    ll tmp = mpow((k/i), n, P);
    num[i] = (tmp + num[i])%P;
    for(ll j=0;j<tbl[i].size();j++) num[tbl[i][j]] = (num[tbl[i][j]] - num[i] + P)%P;
    ans = (ans + (num[i]*i)%P)%P;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 19520
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, a[200001];

signed main()
{

 	FLASH

 	cin>>n;
	fr(i, 1, n+ 1) {cin>>a[i]; a[i] -= i;}
 		
 	sort(a + 1, a + n + 1);
 	int b = a[n/2];

 	int ans1 = 0,ans2 = 0;
 	fr(i, 1, n + 1){
 		ans1 += abs(a[i] - b);
 	}


 	b = a[n/2 + 1];

 	fr(i, 1, n + 1){
 		ans2 += abs(a[i] - b);
 	}

 	int ans = min(ans1, ans2);

 	cout<<ans;
}

Measured memory_bytes: 1792
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
a = set(a)
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
        if i in a:
                continue
        if i == 1:
                dp[i] = 1
                continue
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[n]%mod)

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int64 INF = 1LL << 58;

template< typename Monoid, typename OperatorMonoid = Monoid >
struct LazySegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
  using G = function< Monoid(Monoid, OperatorMonoid) >;
  using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;
  using P = function< OperatorMonoid(OperatorMonoid, int) >;

  int sz;
  vector< Monoid > data;
  vector< OperatorMonoid > lazy;
  const F f;
  const G g;
  const H h;
  const P p;
  const Monoid M1;
  const OperatorMonoid OM0;


  LazySegmentTree(int n, const F f, const G g, const H h, const P p,
                  const Monoid &M1, const OperatorMonoid OM0)
      : f(f), g(g), h(h), p(p), M1(M1), OM0(OM0) {
    sz = 1;
    while(sz < n) sz <<= 1;
    data.assign(2 * sz, M1);
    lazy.assign(2 * sz, OM0);
  }

  void set(int k, const Monoid &x) {
    data[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      data[k] = f(data[2 * k + 0], data[2 * k + 1]);
    }
  }

  void propagate(int k, int len) {
    if(lazy[k] != OM0) {
      if(k < sz) {
        lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
        lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      }
      data[k] = g(data[k], p(lazy[k], len));
      lazy[k] = OM0;
    }
  }

  Monoid update(int a, int b, const OperatorMonoid &x, int k, int l, int r) {
    propagate(k, r - l);
    if(r <= a || b <= l) {
      return data[k];
    } else if(a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      propagate(k, r - l);
      return data[k];
    } else {
      return data[k] = f(update(a, b, x, 2 * k + 0, l, (l + r) >> 1),
                         update(a, b, x, 2 * k + 1, (l + r) >> 1, r));
    }
  }

  Monoid update(int a, int b, const OperatorMonoid &x) {
    return update(a, b, x, 1, 0, sz);
  }


  Monoid query(int a, int b, int k, int l, int r) {
    propagate(k, r - l);
    if(r <= a || b <= l) {
      return M1;
    } else if(a <= l && r <= b) {
      return data[k];
    } else {
      return f(query(a, b, 2 * k + 0, l, (l + r) >> 1),
               query(a, b, 2 * k + 1, (l + r) >> 1, r));
    }
  }

  Monoid query(int a, int b) {
    return query(a, b, 1, 0, sz);
  }

  Monoid operator[](const int &k) {
    return query(k, k + 1);
  }
};


int main() {
  int N, M;
  cin >> N >> M;
  vector< pair< int, int > > ev[200001];

  for(int i = 0; i < M; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    --l;
    --r;
    ev[r].emplace_back(l, x);
  }

  auto f = [](int64 a, int64 b) { return max(a, b); };
  auto g = [](int64 a, int64  b) { return a + b; };
  auto p = [](int64 a, int p) { return a; };

  LazySegmentTree< int64 > seg(N+1, f, g, g, p, 0, 0);
  for(int i = 0; i < N; i++) {
    seg.update(i, i + 1, seg.query(0, i));
    for(auto &p : ev[i]) seg.update(p.first, i + 1, p.second);
  }
  cout << seg.query(0, N+1) << endl;
}



Measured memory_bytes: 19328
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int solve() {
    int n; cin >> n;
    vector<ll> da(n);
    rip(i,n,0) cin >> da[i];
    string s; cin >> s;
    vector<ll> bases(0);
    for(int i = n-1;i>-1;--i) {
        ll now = da[i];
        rip(j, bases.size(), 0) chmin(now, now^bases[j]);
        if(s[i] == '0' && now > 0) bases.push_back(now);
        else if(s[i] == '1' && now > 0) return true;
    }
    return false;
}

int main() {
    int t; cin >> t;
    vector<bool> ans(t);
    rip(i,t,0) ans[i] = solve();
    rip(i,t,0) cout << ans[i] << '\n';
}

Measured memory_bytes: 3604
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<u8> = itr.next().unwrap().bytes().map(|b| b - 97).collect();
    let t: Vec<u8> = itr.next().unwrap().bytes().map(|b| b - 97).collect();

    let mut p1 = vec![26; 26];
    let mut p2 = vec![26; 26];
    for i in 0..s.len() {
        let u = p1[s[i] as usize];
        let v = p2[t[i] as usize];
        if (u != 26 && u != t[i]) || (v != 26 && v != s[i]) {
            println!("No");
            return;
        }
        p1[s[i] as usize] = t[i];
        p2[t[i] as usize] = s[i];
    }
    println!("Yes")
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#define MOD 10007
using namespace std;
int main(){
    int n,dp[2000][8]={{0}},scd[2000];
    string str;
    cin>>n>>str;
    for(int i=0;i<n;i++){
        if(str[i]=='J')scd[i]=0;
        else if(str[i]=='O')scd[i]=1;
        else scd[i]=2;
    }
    dp[0][1]=1;
    for(int i=0;i<n;i++){
        int b=scd[i];
        for(int j=0;j<8;j++){
            for(int k=0;k<8;k++){
                if(((k>>b)&1)==0)continue;
                if((k&j)==0)continue;
                dp[i+1][k]+=dp[i][j];
                dp[i+1][k]%=MOD;
            }
        }
    }
    int sum=0;
    for(int i=0;i<8;i++)sum+=dp[n][i];
    sum%=MOD;
    cout<<sum<<endl;


}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int X;
    cin >> X;
    if(X>=30)Yes;
    else No;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define int	    int64_t
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,flag=0,ans=0,h[200005],m;
int N=200005;
vll BIT(N);
void update(int x,int val)
{
	for(;x<=N;x+=(x&-x))
		BIT[x]=max(val,BIT[x]);
}
int query(int x)
{
	int res=0;
	for(;x>0;x-=(x&-x))
		res=max(res,BIT[x]);
	return res;
}
void solve(){
	cin>>n;
	int ans =0,temp =0;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	for(int i=0;i<n;i++){
		int w;
		cin>>w;
		temp = query(h[i]-1)+w;
		ans=max(ans,temp);
		update(h[i],temp);
	}
	cout<<ans<<endl;
}
signed main()
{
    ios
    int test = 1;
    //cin>>test;
    while(test--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>

using namespace std;

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

  string res = "";
  for (char c : S) {
    if (c != ',') { res += c;}
    else { res += ' '; }
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int to[100005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &to[i]);
  }
  int curr = 1;
  int ret = 0;
  while(curr != 2 && ret < 1000000) {
    curr = to[curr];
    ret++;
  }
  if(curr != 2) ret = -1;
  printf("%d\n", ret);
}


Measured memory_bytes: 640
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int data[4][4001] = {};

long long int saiki(int N, int x)
{
	if (N < 0)return 0;
	if (N > x * 1000)return 0;
	if (x == 1&&N<=1000)return 1;
	int count = 0;
	for (size_t i = 0; i<=1000&&i <= N; i++)
	{
		if (!data[x - 1][N - i])
		{
			data[x-1][N-i] = saiki(N - i, x - 1);
		}
		count += data[x - 1][N - i];
	}
	return count;
}

int main()
{
	int N;
	while (cin >> N)
	{
		cout << saiki(N, 4) << endl;
	}
}

Measured memory_bytes: 1200
import Control.Applicative
import Control.Monad
import Control.Arrow ((&&&))
import Data.List

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    putStrLn $ solve n
    main

solve :: Int -> String
solve n
   | s > 2 * n = "abundant number"
   | s < 2 * n = "deficient number"
   | otherwise = "perfect number"
  where
    s = sum . divisors . primeFactors $ n

primeFactors :: Int -> [(Int, Int)]
primeFactors 1 = []
primeFactors n = map (head &&& length) $ group $ f [] 2 n
  where
    f rs d x
      | d ^ 2 > x = x : rs
      | x `mod` d == 0 = f (d:rs) d (x `div` d)
      | otherwise = f rs (d + 1) x

divisors :: [(Int,Int)] -> [Int]
divisors [] = [1]
divisors ((d, n):rs) = do
  x <- map (d^) [0..n]
  y <- divisors rs
  return $ x * y



Measured memory_bytes: 4040
#include <iostream>

int main()
{
    while(1) {
        double a,b;

        std::cin >> a;
        std::cin >> b;

        if (std::cin.eof()) {
            break;
        }

        double c = a + b;
        int ans = 1;
        bool flag = false;

        while(!flag) {
            if (c / 10 >= 1) {
                c/= 10;
                ans += 1;
            } else {
                flag = true;
            }
        }

        std::cout << ans << std::endl;
    }

    return 0;

}

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

int main() {
  long long S;
  cin >> S;
  cout << 0 << ' ';
  cout << 0 << ' ';
  cout << (S - 1) / 1000000000 + 1 << ' ';
  cout << 1 << ' ';
  cout << (1000000000000000000 - S) % 1000000000 << ' ';
  cout << 1000000000 << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

void solve();

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

    solve();
}
void solve() {
    ll n, p;
    std::cin >> n >> p;

    auto func = [](ll n, ll p) -> ll {
        if (n == 1) return p;
        if (isprime(p)) return 1;

        vll b, e; ll cnt = 0;
        for (ll i = 2; i * i <= p; i++) {
            if (p % i != 0) continue;
            ll j = 0; for (; p % i == 0; p /= i) j++;
            b.push_back(i), e.push_back(j);
            cnt++;
        }

        ll res = 1;
        for (ll i = 0; i < cnt; i++)
            res *= rpow(b[i], e[i] / n);

        return res;
    };

    std::cout << func(n, p) << '\n';
}


Measured memory_bytes: 3620
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, m, x, y = Is()
X = LI() + [x]
Y = LI() + [y]
X.sort()
Y.sort()
if X[-1] < Y[0]:
    print("No War")
else:
    print("War")


Measured memory_bytes: 63852
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    count = 1
    k,l = 26,26
    while k < n:
        l *= 26
        k += l
        count += 1
    r = n - k + l -1
    s = ''
    for i in range(count):
        m = r%26
        r //= 26
        s += chr(ord('a')+ m)
    s = s[::-1]
    print(s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9212
import java.util.*;
import java.io.*;

public class Main {
	static FastReader f = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		solve();
		out.close();
	}

	static void solve() {
		int n = f.nextInt(), m = f.nextInt();
		Dsu dsu = new Dsu(n);
		while(m-- > 0) {
			int u = f.nextInt() - 1, v = f.nextInt() - 1;
			dsu.join(u, v);
		}

		int[] cnt = new int[n];
		for(int i=0;i<n;i++) {
			cnt[dsu.getPar(i)]++;
		}

		int max = 0;
		for(int i=0;i<n;i++) {
			max = Math.max(max, cnt[i]);
		}

		out.println(max);
 	}

 	static class Dsu {
 		int[] size;
 		int[] par;

 		Dsu(int n) {
 			size = new int[n];
 			par = new int[n];
 			for(int i=0;i<n;i++) {
 				size[i] = 1;
 				par[i] = i;
 			}
 		}

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

 		void join(int a, int b) {
 			a = getPar(a);
 			b = getPar(b);

 			if(a != b) {
 				if(size[a] < size[b]) {
 					int temp = a;
 					a = b;
 					b = temp;
 				}
 				size[a] += size[b];
 				par[b] = a;
 			}
 		}
 	}

	static class FastReader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;

		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			String str = "";

			try {
				str = br.readLine();
			} catch(IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 57292
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

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

using namespace std;

int main(){
	int N;
	cin >>N;
	int ans =0;
	rep(i,N){
		int a;
		cin >> a;
		ans +=(a!=(i+1));
	}
	if(ans<=2)
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <array>
#include <cstdlib>
#include <stack>
#include <string>
#include <queue>
#include <chrono>
#include <functional>
#include <limits>
#include <cmath>
#include <algorithm>
#include <random>
#include <regex>
#include <tuple>
#include <utility>
#include <bitset>
#include <complex>
#include <iomanip>
#include <ostream>
#include <sstream>
#include <ctime>
using namespace std;
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define index INDEX
#ifndef ONLINE_JUDGE
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, const string& NAME) {
	cerr << NAME << " = " << fixed << VARIABLE << "\n";
}
#else
#define print(x) 0 
#endif
#ifdef RAND_MAX
#undef RAND_MAX
#endif
#define RAND_MAX 999999937 
int generate_random() {
	const int MAX_RANDOM = (int)1e6;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution<int>(0, MAX_RANDOM)(rng);
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll INFLL = 2 * (ll)1e18 + 100;
#define int ll
#ifdef int 
const int INFINT = INFLL;
#else
const int INFINT = 2 * (int)1e9 + 100;
#endif
const double PI = atan(1) * 4;
const double EPS = 1e-6;
const int SEED = (int)1e3 + 7;
const int MOD = (int)1e9 + 7;
const int NMAX = (int)1e6 + 5;

void check(int n, int k)
{
	V v;
	for0(i, (1 << n)) v.pb(i), v.pb(i);
	do
	{
		for0(i, (1 << n))
		{
			int start = -1, finish = -1;
			for0(j, v.size())
			{
				auto it = v[j];
				if (it == i)
				{
					if (start == -1) start = j;
					else
					{
						finish = j;
						break;
					}
				}
			}
			int xor_here = 0;
			for (int j = start; j <= finish; j++) xor_here ^= v[j];
			if (xor_here != k) goto skip;
		}
		cout << "GOT ANS for " << n << ' ' << k << '\n';
		for (auto i : v) cout << i << ' ';
		cout << "\n\n";
		break;
	skip:;
	} while (next_permutation(all(v)));
}
int32_t main() {
#ifndef ONLINE_JUDGE
	double START_PROGRAM = clock();
#endif
	srand(time(0));
	cout << setprecision(20) << fixed;
	FASTIO;
	int n, k;
	cin >> n >> k;
	if(k == 0)
	{
		for0(i, (1 << n)) cout << i << ' ' << i << ' ';
		return 0;
	}
	int XOR = 0;
	for0(i, (1 << n)) if(i != k) XOR ^= i;
	if(XOR == k)
	{
		for (int j = (1 << n) - 1; j >= 0; j--) if (j != k) cout << j << ' ';
		cout << k << ' ';
		for0(j, (1 << n)) if (j != k) cout << j << ' ';
		cout << k << ' ';
	}
	else cout << -1;






#ifndef ONLINE_JUDGE
	double END_PROGRAM = clock();
	double ELAPSED_TIME = (END_PROGRAM - START_PROGRAM) / CLOCKS_PER_SEC;
	cerr << "\n\nElapsed Time: " << ELAPSED_TIME * 1000 << "\n";
	system("pause");
#endif
	return 0;
}







Measured memory_bytes: 2040
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 k, n;
    cin >> k >> n;
    akari<i64> house(n), xs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> house[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        xs[i] = house[i + 1] - house[i];
    }
    xs.back() = house[0] + k - house.back();
    cout << k - *max_element(xs.begin(), xs.end()) << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3328
n = int(input())
a = list( map(int, input().split()))


for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            exit()

print('APPROVED')

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

void Main() {
    // input
    for (int i = 1; i<= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << endl;
            return;
        }
    }


    // translate


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N, D;
    int num = 0;
    cin >> N;
    cin >> D;

    int X[N][D];

    for(int i = 0; i < N; i++){
        for(int n = 0; n < D; n++){
            cin >> X[i][n];
        }
    }

    for(int i = 0; i < N - 1; i++){
        for(int n = i + 1; n < N; n++){
            double sum = 0.0;
            double distance = 0.0;
            for(int z = 0; z < D; z++){
                sum += pow(X[i][z] - X[n][z],2);
            }
            distance = sqrt(sum);
            if(ceil(distance) == floor(distance)){
                num++;
            }
        }
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int K = sc.nextInt();
		int ans=0;
		
		while(N>0) {
			N = N/K;
			ans ++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;

int main(){
  long long n, a, b;
  cin >> n >> a >> b;

  long long ans = 0;
  long long x = n / (a + b);
  long long y = n % (a + b);
  ans += x * a;
  ans += (a > y)? y : a;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
listx = list(map(int, input().split()))
subx = []

for i in range(N):
  subx.append(abs(listx[i] - X))
if N == 1:
  subx.append(subx[0])

def gcd(a,b):
  if a < b:
    a, b = b, a
  while a % b != 0:
    a, b = b, a % b
  return b

ans = gcd(subx[0], subx[1])

if N > 2:
  for i in range(2, N):
    ans = gcd(ans, subx[i])
  
print(ans)

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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;

    if ( a < b ) {
        cout << "a < b" << endl;
    } else if ( a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define llu unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction


#define inf 99999999
#define MX 1000006
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int e1,e2,e3;
    data() {}
    data(int a,int b,int c)
    {
        e1=a,e2=b,e3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.e1> b.e1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;

ll a[3*100005];
int main()
{
    int t,tc=1;
	sf1(n);
	for(int i=1;i<=3*n;i++){
		sfl1(a[i]);
	}
	sort(a+1,a+3*n+1);
	ll sum=0;
	for(int i=n+1;i<=3*n;i+=2){
		sum+=a[i];
	}
	pfl(sum);
	NL;

    return 0;
}

/*




*/


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

int main(){
    i64 a,b,c,ans=3;
    cin>>a>>b>>c;
    if(a==b) ans--;
    if(c==b) ans--;
    if(a==c) ans--;
    if(ans==0) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(k[int(input())-1])


Measured memory_bytes: 2940
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<int, P> PP;
struct edge { int to; int to2; int cost; };
int n, m;
struct BIT {
	int dat[1003][1003];
	void update(int x, int y, int v) {
		for (int i = x; i <= n; i += i & -i)
			for (int j = y; j <= m; j += j & -j)
				dat[i][j] += v;
	}
	int qsum(int x, int y) {
		int res = 0;
		for (int i = x; i > 0; i -= i & -i)
			for (int j = y; j > 0; j -= j & -j)
				res += dat[i][j];
		return res;
	}
	int qsum(int x0, int y0, int x1, int y1) {
		return qsum(x1, y1) - qsum(x0 - 1, y1) - qsum(x1, y0 - 1) + qsum(x0 - 1, y0 - 1);
	}
};
BIT rwa;
vector<int> a, b;
int kj[1000005];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, n) { int x; cin >> x; a.push_back(x); } sort(a.begin(), a.end());
	rep(i, m) {
		int x; cin >> x; b.push_back(x);
	} sort(b.begin(), b.end());
	kj[0] = 1;
	for (int i = 1; i <= n*m; i++)kj[i] = kj[i - 1] * i%mod;

	int mn = inf;
	rep(i, n)mn = min(mn, a[i]);
	rep(i, m)mn = min(mn, b[i]);
	int ans = 1;
	rep(i, n - 1)if (a[i] == a[i + 1])ans *= 0;
	rep(i, m - 1)if (b[i] == b[i + 1])ans *= 0;
	for (int i = n*m; i >=1; i--) {
		auto nl = lower_bound(a.begin(), a.end(), i);
		auto ml = lower_bound(b.begin(), b.end(), i);
		int N = nl - a.begin();
		int M = ml - b.begin();

		if (*nl == i&&*ml == i) {
			rwa.update(N+1, M+1 , 1);
		}
		else if (*nl == i) {
		//(N,M)~(N,m-1)
			ans *= (m - M) - rwa.qsum(N + 1, M + 1, N + 1, m);
			rwa.update(N + 1, m, 1);
		}
		else if (*ml == i) {
		//(N,M)~(n-1,M)
			ans *= (n - N) - rwa.qsum(N+1,M+1,n,M+1);
			rwa.update(n, M + 1, 1);
		}
		else {
		//(N,M)~(n-,m-)
			ans *= (n - N)*(m - M) - (n*m-i);
			rwa.update(n, m, 1);
		}

		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 8448
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;
 int main(){
   int n,m,X,Y; int mx=-100,miy=100; 
   cin >>n>>m>>X>>Y;
   int x[n],y[m];
   for(int i=0;i<n;i++){
     cin >>x[i]; mx=max(x[i],mx);
   }
   for(int i=0;i<m;i++){
     cin >>y[i]; miy=min(miy,y[i]);
   }
   
   int res=0;
   for(int i=X+1;i<=Y;i++){
     if(mx<i && i<=miy) res++;
   }
   if(res!=0) cout << "No War" <<endl;
   else cout << "War" <<endl;
 }
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void fanc(string s, int i, set<string> &add){
  string ne;
  rep(j, 5){
    if(i + j >= (int)s.size()) break;
    ne.push_back(s.at(i+j));
    add.insert(ne);
  }
}

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  set<char> se;
  rep(i, s.size()){
    se.insert(s.at(i));
  }
  while(1){
    set<string> add;
    char now = *se.begin();
    se.erase(se.begin());
    rep(i, s.size()){
      if(s.at(i) == now)fanc(s, i, add);
    }
    if((int)add.size() < k) k -= add.size();
    else{
      for(string now : add){
        if(k == 1){
          cout << now << endl;
          return 0;
        }else{
          k--;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 384
a = list(input())
 
sign = "+-"
 
for i in range(2):  #1つめの正負
 for j in range(2):  #2つ目の正負
  for k in range(2):  #3つ目の正負
    if eval(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3] ) == 7:
     print(str(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3])+'=7')
     exit()

Measured memory_bytes: 9136
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            b[i] = a[i] - (i + 1);
        }
        Arrays.sort(b);

        int x;
        if (n % 2 == 0) {
            x = (b[n / 2 - 1] + b[n / 2]) / 2;
        } else {
            x = b[n / 2];
        }

        long y = 0;
        for (int i = 0; i < n; i++) {
            y += Math.abs(a[i] - (x + i + 1));
        }

        out.println(y);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 43088
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
    int n;
    cin>>n;
    ll ans=0;
    for (int i = 1; i <= n; ++i)
    {
        ll yo;
        cin>>yo;
        if(yo%2 && i%2)ans++;
    }
    cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    var ans = n
    var cnt = 0
    for (i in 0 until n) {
        if (a[i] == cnt + 1) {
            cnt++
        }
    }
    println(if (cnt == 0) -1 else ans - cnt)
}

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

using namespace std;

string s;

int main(){
	cin >> s;
	for(int i = 0; i < (int)s.size() - 1; i++){
		if(s[i] == 'S' && s[i + 1] == 'T'){
			s.erase(s.begin() + i);
			s.erase(s.begin() + i);
			i -= 2;
		}
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 640
n, k = map(int, input().split())
lis = [False]*n
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in range(d):
        lis[a[i]-1] = True
ans = 0
for l in lis:
    if l == False:
        ans += 1
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int h,w;
  char c[200][200];
  cin >> h >> w;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++)
      cin >> c[i][j];
  }
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++)
      cout << c[i][j];
    cout << endl;
    for(int j = 0; j < w; j++)
      cout << c[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 3664