akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    string s;
    cin>>s;
    int ans=0;
    string s2="CODEFESTIVAL2016";
    for(int i=0;i<16;i++){
        if(s2[i]!=s[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    long long h, w;
    cin >> h >> w;

    if(h == 1 || w == 1)
        cout << 1 << endl;
    else
        cout << (h * w + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define MOD 1000000007

int n;
map<vector<long>,pair<long,long>> memo;
// 閉区間

void dfs(vector<long> &v, long k){
  vector<long> tv(n);
  rep(i,n) tv[i] = v[i] - v[0];
// dbg(v,tv,k);
  auto itr = memo.find(tv);
  if(itr == memo.end()){
    memo[tv] = {v[0], max(0L, v[0]-k)};
  } else {
    pair<long,long> pr = itr->second;
    pair<long,long> cr = {v[0], max(0L, v[0]-k)};
    if(max(pr.se, cr.se) > min(pr.fi, cr.fi)) assert(false);
    if(pr.se > cr.se) assert(false);
    return;
  }

  if(all_of(all(v), [](long x){return x==0;})) return;

  if(k>=1){
    rep(i,n) tv[i] = v[i]/2;
    dfs(tv, k-1);
  }
  if(k>=2 && all_of(all(v), [](long x){return x>0;})){
    rep(i,n) tv[i] = (v[i]-1)/2;
    dfs(tv, k-2);
  }//dbg(memo.size());
}

int main(){
  long k;
  cin>>n>>k;
  vector<long> a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));

  dfs(a, k);

  long ans = 0;
  for(auto &p : memo) ans += (p.se.fi - p.se.se +1)%MOD;

  cout << ans %MOD << endl;

  return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

vector<string> A;

int main() {
  i64 H,W;
  cin >> H >> W;
  A.resize(H);
  for(int i = 0;i < H;i++) {
    cin >> A[i];
  }

  int d[] = {1, 0, -1, 0};
  queue<std::pair<int,int>> que;
  vector<vector<i64>> dist(H, vector<i64>(W, 1e8));
  rep(i,0,H - 1) rep(j,0,W - 1) {
    if(A[i][j] == '#'){
      que.push({i, j});
      dist[i][j] = 0;
    }
  }

  while(!que.empty()) {
    int x = que.front().first;
    int y = que.front().second;
    que.pop();
    for(int dd = 0;dd < 4;dd++) {
      int i = x + d[dd];
      int j = y + d[dd ^ 1];
      if(0 <= i && i < H && 0 <= j && j < W && dist[i][j] > dist[x][y] + 1){
        dist[i][j] = dist[x][y] + 1;
        que.push({i, j});
      }
    }
  }
  i64 ans = 0;
  rep(i,0,H - 1) rep(j,0,W - 1) {
    ans = max(ans, dist[i][j]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 17296
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    double a; cin >> a;
    double b; cin >> b;
    double x; cin >> x;
    double tan;
    if (x > a*a*b /2.0){
        tan = 2.0 * (a*a*b - x) / (a*a*a);
    } else {
        tan = a*b*b/x/2.0;
    }
    printf("%lf\n", double(atan(tan)) * double(180.0) / double(PI));
    return 0;
}

Measured memory_bytes: 384
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    input! {
        x: u64,
    }
    let mut ans = 0;
    for i in 1..=x {
        for j in 1..=x {
            for k in 1..=x {
                ans += gcd(gcd(i, j), k);
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2052
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        mut s: Chars,
    }

    let mut i = 0;
    let mut j = s.len() - 1;
    let mut res = 0;
    while i < j {
        while i < n && s[i] == 'R' {
            i += 1;
        }
        while i < j && s[j] == 'W' {
            j -= 1;
        }
        if i >= j {
            break;
        }
        res += 1;
        i += 1;
        j -= 1;
    }
    println!("{}", res);
}


Measured memory_bytes: 2980
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}
    
void run(){
    int n;
    cin>>n;
    vi p(n);
    rep(i,n)cin>>p[i];
    int m=inf;
    int ans=0;
    rep(i,n){
        if(p[i]<m){
            m=p[i];
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int n,k; cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  
  int ans=0;
  rep(i,n){
    if(h[i] >= k) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 640
#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--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n; cin >> n;
    if (n == 0) return;
    vector<vi32> b(21, vi32(21));
    rep(i, n) {
      int x, y; cin >> x >> y;
      y = 20 - y;
      b[y][x] = 1;
    }
    int m; cin >> m;
    int x = 10, y = 10;
    rep(i, m) {
      char c;
      int l;
      cin >> c >> l;
      int dx, dy;
      if (c == 'N') dx = 0, dy = -1;
      if (c == 'S') dx = 0, dy = 1;
      if (c == 'E') dx = 1, dy = 0;
      if (c == 'W') dx = -1, dy = 0;
      rep(i, l) {
        x += dx, y += dy;
        b[y][x] = 0;
      }
    }
    bool f = true;
    rep(i, 21) rep(j, 21) if (b[i][j] == 1) f = false;
    if (f) cout << "Yes" << '\n';
    else cout << "No" << '\n';
  }
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //入力
  int n;
  cin >> n;
  map <int,int> a;
  map <int,int> b;
  REP(i,n){
    int v;
    cin >> v;
    if(i%2 == 0) a[v]++;
    else b[v]++;
  } 
  //変換数は，n/2 - 最大値をそれぞれ足したもの
  int maxa = 0;
  int maxkey_a = 0;
  int maxb = 0;
  int maxkey_b = 0;

  for(auto x: a) {
    if(x.second >= maxa){
      maxa = x.second;
      maxkey_a = x.first;
    }
  }

  for(auto x: b) {
    if(x.second >= maxb){
      maxb = x.second;
      maxkey_b = x.first;
    }
  }

  //
  if(maxkey_a == maxkey_b){
    int max2a = 0;
    int max2key_a = 0;
    for(auto x: a){
      if(x.first == maxkey_a) continue;
      if(x.second >= max2a){
      max2a = x.second;
      max2key_a = x.first;
      }
    }

    int max2b = 0;
    int max2key_b = 0;
    for(auto x: b){
      if(x.first == maxkey_b) continue;
      if(x.second >= max2b){
      max2b = x.second;
      max2key_b = x.first;
      }
    }

    if(maxa - max2a >= maxb - max2b) maxb = max2b;
    else maxa = max2a;
  }

  int ans = n - maxa - maxb;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8240
import math

N, M = map(int, input().split())
if abs(N - M) >= 2:
    print(0)
    exit()


N = math.factorial(N) % (10 ** 9 + 7)
M = math.factorial(M) % (10 ** 9 + 7)
if N == M:
    print((N * M * 2) % (10 ** 9 + 7))
else:
    print((N * M) % (10 ** 9 + 7))


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

int main(){
  string S;
  cin >> S;
  int ans =700;
  if(S[0]=='o'){
    ans += 100;
  }
  if(S[1]=='o'){
    ans += 100;
  }
  if(S[2]=='o'){
    ans += 100;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		//入力準備
		Scanner sc = new Scanner(System.in);

		//参加回数と表示レーティングの入力
		int N = sc.nextInt();
		int R = sc.nextInt();
	
		//内部レーティングXの定義
		int X = 0;

		if(N >= 10){
			X = R;
		}else{
			X = R + 100 * (10 - N);
		}

		System.out.println(X);
	}
}

	

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

using namespace std;

const int MOD = 1e9 + 7;
    
int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<long long> pos, po(s.size()+100);
    po[0] = 1;
    for (long long i = 0; i < s.size(); ++i) {
        if (s[i] & 1) {
            pos.push_back(i);
        }
        if (i > 0) {
            po[i] = (po[i-1] * 3) % MOD;
        }
    }
    long long ans = 0, two = 1;
    reverse(pos.begin(), pos.end());
    for (long long x : pos) {
        //cerr << two << " " << po[x] << "\n";
        ans = (ans + (two * po[x]) % MOD) % MOD;
        two = (two * 2ll) % MOD;
    }
    cout << (ans + two) % MOD;
    return 0;
}

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

int main(){
  int n;cin >> n;
  ll ans = 0;
  vector<string> s(n);
  map<string,int> m;
  rep(i,n){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    m[s[i]] += 1;
  }
  rep(i,n){
    if(m[s[i]] >= 2){
      ans += m[s[i]]-1;
      m[s[i]] -= 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18176
#include<iostream>
using namespace std;
int main() {
	long long a, b, c; cin >> a >> b >> c;
	if (a == b && b == c && a % 2 == 0) {
		cout << "-1" << endl;
		return 0;
	}
	long long cnt = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		long long A = a/2, B = b/2, C = c/2;
		a = B + C;
		b = C + A;
		c = A + B;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3544
isP = [True for _ in range(1005)]
isP[0] = isP[1] = False
for i in range(2, 1005):
  for j in range(2, 1005):
    if i * j >= 1005:
      break
    isP[i*j] = False
P = []
for i in range(1005):
  if isP[i]:
    P.append(i)
N = int(input())
ans = 1
for p in P:
  if p > N:
    continue
  else:
    k = p
    t = 1
    while k <= N:
      t += N // k
      k *= p
    ans *= t
print(ans % 1000000007)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<set<int>> s(26, set<int>());
    rep(i, n)
    {
        char a;
        cin >> a;
        a -= 'a';
        s[a].insert(i + 1);
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int iq;
            char c;
            cin >> iq >> c;
            c -= 'a';
            rep(j, 26)
            {
                s[j].erase(iq);
            }
            s[c].insert(iq);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            rep(j, 26)
            {
                int lb = *s[j].lower_bound(l);
                if (lb >= l && lb <= r)
                {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

const int INF = 1e9+7;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a.at(i);
	}
	vector<int> num(100100);
	for(int i=0; i<100100; i++){
		num.at(i) = 0;
	}
	for(int i=0; i<n; i++){
		num.at(a.at(i))++;
	}
	int diff=0;
	int even=0;
	for(int i=0; i<100100; i++){
		if(num.at(i) > 0){
			diff++;
			if(num.at(i)%2==0){
				even++;
			}
		}
	}
	cout << (even%2==0?diff:diff-1) << endl;
}

Measured memory_bytes: 1024
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

vi adj[N];int in[N];int dp[N];

void solve()
{
   
    int n,m;
    cin>>n>>m;
    int u,v;
    for(int i=1;i<=m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        in[v]++;
    }
    queue<int>q;
    for(int i=1;i<=n;i++)
        if(!in[i])
            q.push(i);
    vi topo;
    while(!q.empty())
    {
        u=q.front();
        topo.pb(u);
        q.pop();
        for(int v:adj[u])
        {
            in[v]--;
            if(!in[v])
                q.push(v);
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        for(int v:adj[topo[i]])
        {
            dp[topo[i]]=max(dp[topo[i]],1+dp[v]);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans<<endl;
    
    
    
    
    
}


int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






Measured memory_bytes: 8180
#include<bits/stdc++.h>
using namespace std;
#define LOL ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<ll ,ll>
const int sz=1e4+100;
ll dp[sz][12];
string sol[sz][12];
ll n;
pii ara[12];
ll tk[]={0,2,5,5,4,5,6,3,7,6};
bool cmp(pii a,pii b)
{
    if(a.f==b.f) return a.s>b.s;
    return a.f<b.f;
}
string Max(string a, string b) {
    sort(a.begin(),a.end(),greater<char>());
    sort(b.begin(),b.end(),greater<char>());
	if(a.size() == b.size()) {
		return (a > b) ? a : b;
	}
	return (a.size() > b.size()) ? a : b;
}
ll cholo(ll in,ll w)
{
       if(in==n){
        if(w==0)  return 1;
        else return 0;
       }
       if(w==0)  return 1;
       ll p=0,q=0;
       string str1="",str2="";
       ll &ret=dp[w][in];
       if(~ret) return ret;
       if(w-ara[in].f>=0) p=cholo(in,w-ara[in].f);
       q=cholo(in+1,w);
       if(p==1) str1=sol[w-ara[in].f][in]+string(1,'0'+ara[in].s);
       if(q==1) str2=sol[w][in+1];
       sol[w][in]=Max(str1,str2);
       if(p==1 || q==1) ret=1ll;
       else ret=0ll;
       return ret;
}
int main()
{
    LOL
    ll a,b,c,i,j,k,q,p,x,y,sum,ct,ct1,m,l,r,x1,y1,mn,ans,h,sum1,in,z,mid,tot;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    cin>>tot>>n;
    memset(dp,-1,sizeof dp);
    for(i=0;i<n;i++){
        cin>>x;
        ara[i]=mk(tk[x],x);
    }

    sort(ara,ara+n,cmp);
    ll last=cholo(0,tot);

    cout<<sol[tot][0]<<endl;

}


Measured memory_bytes: 104192
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# 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 fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("out.txt", "r", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
 
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 2e6 + 7;
typedef vector < vector < ll > > matrix;

int main()
{   
    speed;
    int n;
    cin >> n;
    string s, a, b;
    cin >> s;
    if ( n % 2 ) {
        cout << "No";
        return 0;
    }
    forn( i, n / 2 ) {
        a += s[i];
        b += s[i + n / 2];
    }
    if ( a == b ) cout << "Yes";
    else cout << "No";
    time;
}


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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int H,A,i=0;
    cin>>H>>A;
    while(H>0){
        H-=A;
        i++;
        if(H<=0){
            cout<<i<<endl;
        }
    }

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll MOD=998244353;
const int MAX=200010;

//Union-Find木


int siz[MAX];
int par[MAX];
int depth[MAX];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
  rep(i,n+1){
      siz[i]=1;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  ll sx=siz[x];
  ll sy=siz[y];
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
  siz[root(x)]=sx+sy;
}



signed main(){
    ll n;cin>>n;
    ll q;cin>>q;
    init(n);
    while(q){
        q--;
        int i;cin>>i;
        int u,v;cin>>u>>v;
        if(i){
            int ans=same(u,v);
            cout<<ans<<endl;
        }else{
            unite(u,v);
        }
    }
}

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

using namespace std;

int main(){

    int n, k, vl;
    cin >> n >> k;
    vector<double> arr(1001);
    double num = 0, den = 1;
    for(; den < 1001; den++){
        num += den;
        arr[den] = (num/den);
    }

    vector<double> inp(n);
    for(int i = 0; i < n; i++){
        cin >> vl;
        inp[i] = arr[vl];
    }

    double sm = 0, mx = 0;
    for(int i = 0; i < k; i++)
        sm += inp[i];
    mx = sm;
    for(int l = 0, r = k; r < n; r++, l++){
        sm += inp[r];
        sm -= inp[l];
        mx = max(mx, sm);
    }

    cout << setprecision(8) << mx << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) {
        cin >> A.at(i);
    }

    int c = 0;
    rep(i,N) {
        if (A[i] != i+1) continue;
        swap(A[i], A[i+1]);
        c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n, 0);
    rep(i, n) cin >> d[i];

    sort(d.begin(), d.end());
    int ans = d[n / 2] - d[n / 2 - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  REP(i,N)cin>>A[i];
  REP(k,K){
    int m=N;
    vector<int> B(N,0);
    REP(i,N){
      B[max(0,i-A[i])]++;
      if(i+A[i]+1<N)B[i+A[i]+1]--;
    }
    FOR(i,1,N)B[i]+=B[i-1];
    A=B;
    REP(i,N)m=min(m,A[i]);
    if(m==N)break;
  }
  REP(i,N)cout<<A[i]<<" ";
  cout<<endl;
  return 0;
}


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

int main(){
	char c[11][11];
	string s;
	int w,h,x,a,b,e,d;
	while(1){
		cin >> s;
		if(s[0] == '#')break;
		for(int i = 0;i <= 10;i++){
			for(int j = 0;j <= 10;j++){
				c[i][j] = 'o';
			}
		}

		w = h = 1;
		for(int i = 0;i < s.size();i++){
			if(s[i] == '/'){
				w = 1;
				h++;
				continue;
			}
			else if(s[i] == 'b'){
				c[h][w] = 'b';
				w++;
			}
			else{
				stringstream ss;
				ss << s[i];
				ss >> x;
				for(int j = 0;j < x;j++){
					c[h][w] = '.';
					w++;
				}
			}
		}

		cin >> a >> b >> e >> d;
		c[a][b] = '.';
		c[e][d] = 'b';

		for(int i = 1;i <= 10;i++){
			a = 0;
			if(c[i][1] == 'o')break;
			for(int j = 1;j <= 10;j++){
				if(c[i][j] == '.'){
					a++;
				}
				else if(c[i][j] == 'b'){
					if(a != 0){
						cout << a;
						a = 0;
					}
					cout << 'b';
				}		
				else{
					if(a != 0)cout << a;
					if(c[i+1][1] != 'o')cout << '/';
					break;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
//#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 200009
#define infm 800009
#define INF (int)1e9
#define mod 1000000007LL
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;
int n,k;

struct edge{
	int nxt,y;
	edge(){}
	edge(int nn,int yy){
		nxt=nn,y=yy;
	}
}e[inf*2];
int head[inf],ecnt;

void addedge(int x,int y){
	ecnt++;
	e[ecnt]=edge(head[x],y);
	head[x]=ecnt;
	return;
}

int ans=0;
int fa[inf];

int dfs(int u,int dep){
	int mxdep=dep;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].y;
		mxdep=max(mxdep,dfs(v,dep+1));
	}
	if (mxdep-dep==k-1 && fa[u]!=1){
	    ans++;
	    return 0;
	}
	return mxdep;
}

int main(){
	rd(n) rd(k)
	for (int i=1;i<=n;i++){
		rd(fa[i])
		if (i!=1){
			addedge(fa[i],i);
		}
		else{
			ans+=(fa[i]!=1);
		}
	}
	for (int i=head[1];i;i=e[i].nxt){
		int v=e[i].y;
		dfs(v,0);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8192
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define reg register

const int maxn = 1000005;

int N;

char S[maxn];
char T[maxn];

int main(){
        scanf("%d", &N);
        scanf("%s%s", S+1, T+1);
        int flag = 1;
        for(reg int i = 1; i <= N; i ++)
                if(S[i] != T[i]){ flag = 0; break ; }
        if(flag){ printf("0\n"); return 0; }
        int Min_l = N, Ans = 1;
        std::queue <int> Q;
        for(reg int i = N; i >= 1; i --){
                Min_l = std::min(i, Min_l);
                if(T[i] == T[i-1]) continue ;
                while(Min_l && S[Min_l] != T[i]) Min_l --;
                if(!Min_l){ printf("-1\n"); return 0; }
                while(!Q.empty()){
                        if(Q.front()-Q.size()+1 > i) Q.pop();
                        else break ;
                }
                Q.push(Min_l);
                if(Min_l != i) Ans = std::max(Ans, (int)Q.size() + 1);
        }
        printf("%d\n", Ans);
        return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int n,s[maxn];
bool vis[maxn];
long long ans;
/**
    A+k*(A-B)=(N-1)
    Let c=(A-B)
    then we can iterate over all
    k*(A-B)<n-1
    every visit location is
    A,A-B,A+(A-B),2*(A-B),3*,......,k*(A-B),A+k*(A-B)
    A,C,A+C,2*C,A+2*C,....,A+k*(C)
    Then let's get rid of A
    remember that A is just equal to (N-1)-(k*C)
    The total number of A is k+1
    C,2*C,...,(K-1)*C
    N-1,(N-1)-C,.....(N-1)-C*(K-1)
*/

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    for(int c=1;c<n;c++){
            long long sum=0;
            vector<int> ch;
       /// cerr<<c<<'\n';
        for(int k=1;1LL*c*(k-1)<n;k++){
            int id=(k-1)*c;
            if(vis[id]){
                break;
            }
            else{
             vis[id]=true;
             ch.push_back(id);
             sum+=s[id];
            }
          ///  cerr<<id<<' ';
            id=n-1-c*(k-1);
            if(id<=c){
                break;
            }
        ///    cerr<<id<<' ';
            if(vis[id]){
                break;
            }
            else{
                vis[id]=true;
                sum+=s[id];
                ch.push_back(id);
            }
            ans=max(ans,sum);
        }
        for(int i:ch){
            vis[i]=false;
        }
     ///   cerr<<'\n';
      ///  cerr<<ans<<'\n';
    }
    printf("%lld\n",ans);
}
/*
    Good Luck
        -Lysithea
        a-b=6 k-1=2
        a+(k-1)*(a-b)==n-1
        1
14
0 -59616710 783365911 111189909 -256968442 -989501104 261125694 972992891 -605457409 47321305 -21631829 -235268167 922418061 0
*/


Measured memory_bytes: 1664