akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(int i = a; i < n; ++i)
#define pb push_back
#define mp make_pair
#define f first
//#define sex second

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <set>
#include <ostream>
#include <queue>
#include <functional>
#include <sstream>
#include <map>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
#pragma comment(linker, "/STACK:228228000")
const ll mod = 998244353;

ll n;

int main()
{
	/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	
	cin >> n;
	if (n < 1000)
		cout << "ABC";
	else
		cout << "ABD";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n,m,r;
  cin >> n >> m >> r;
  vector<vector<ll>> Graph(n,vector<ll>(n,INF));
  vector<int> R(r);
  rep(i,r) cin >> R.at(i);
  rep(i,r) R.at(i) --;
  sort(R.begin(),R.end());
  rep(i,n) Graph.at(i).at(i) = 0;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    Graph.at(a).at(b) = c;
    Graph.at(b).at(a) = c;
  }
  rep(k,n)rep(i,n)rep(j,n) Graph.at(i).at(j) = min(Graph.at(i).at(k)+Graph.at(k).at(j),Graph.at(i).at(j));
                                                                                   
  ll ans = 1e18;
  do{
    ll now = 0;
    rep(i,r-1){
      now += Graph[R.at(i)][R.at(i+1)];
    }
    ans = min(ans,now);
    
  }while(next_permutation(R.begin(),R.end()));
  
  cout << ans << endl;                                    
  
  return 0;
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



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

    ll n,k; cin >> n >> k;
    vll p(n);
    REP(i,n) cin >> p[i];
    int sum = 0;
    

    REP(i,k) sum += p[i];
    int ans = sum;
    for(int i=k;i<n;i++){
        sum += p[i];
        sum -= p[i-k];
        ans = max(sum,ans);    
    }
    ans += k;
    // cout << ans << endl;    
    cout << ans/2 << ((ans%2==0) ? ".0" : ".5") << endl;
    return 0;
}



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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define endl "\n"

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 w, n, a, b; vector<_i64> list;
        scanf("%ld", &w); list.resize(w); iota(_all(list), 1);
        scanf("%ld", &n);
        _rep(i, n) {
            scanf("%ld,%ld", &a, &b);
            swap(list[a - 1], list[b - 1]);
        }
        _foreach(e, list) { printf("%ld\n", e); }
    }
    return 0;
}


Measured memory_bytes: 3184
import java.io.*;
import java.math.*;
import java.util.*;


public class Main {

	public static void main(String[] args) throws Exception {
		new Main().solve();
	}
	@SuppressWarnings("unchecked")
	void solve() throws Exception {
		FastScanner in = new FastScanner(System.in);

		// long mod = 1000000007;
		// int a = in.nextInt();
		// int b = in.nextInt();

		String a = in.next();
		String b = in.next();
		String c = in.next();

		System.out.println(
				(char) (a.charAt(0) + 'A' - 'a') + "" +
						(char) (b.charAt(0) + 'A' - 'a') + "" +
						(char) (c.charAt(0) + 'A' - 'a')
				);

	}
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	class FastScanner {

		private InputStream _stream;
		private byte[] _buf = new byte[1024];
		private int _curChar;
		private int _numChars;
		private StringBuilder _sb = new StringBuilder();

		FastScanner(InputStream stream) {
			this._stream = stream;
		}

		public int read() {
			if (_numChars == -1) throw new InputMismatchException();
			if (_curChar >= _numChars) {
				_curChar = 0;
				try {
					_numChars = _stream.read(_buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (_numChars <= 0) return -1;
			}
			return _buf[_curChar++];
		}

		public String next() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			_sb.setLength(0);
			do {
				_sb.appendCodePoint(c);
				c = read();
			} while (!isWhitespace(c));
			return _sb.toString();
		}

		public int nextInt() {
			return (int) nextLong();
		}
		public long nextLong() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9') throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isWhitespace(c));
			return res * sgn;
		}

		public boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//


Measured memory_bytes: 20564
#include <cstdio>
#include <string>
using namespace std;
const double rank[] = {48.0, 51.0, 54.0, 57.0, 60.0, 64.0, 69.0, 75.0, 81.0, 91.0};
const string rank_name[] = {
	"light fly", "fly", "bantam", "feather", "light",
	"light welter", "welter", "light middle", "middle",
	"light heavy", "heavy"
};
/*
const char rank_name[][] = {
	{"light fly"}, {"fly"}, {"bantam"}, {"feather"}, {"light"},
	{"light welter"}, {"welter"}, {"light middle"}, {"middle"},
	{"light heavy"}, {"heavy"}
};
*/

int main(int argc, char *argv[]) {
	float rcv;
	const int loop = sizeof(rank)/sizeof(double);
	while (EOF != fscanf(stdin, "%f", &rcv)) {
		for (int i = 0; i < loop; i++) {
			if (rank[i] >= rcv) {
				//printf("%f %f\n", rank[i], rcv);
				printf("%s\n", rank_name[i].c_str());
				break;
			}
			if (i == loop-1) printf("%s\n", rank_name[loop].c_str());
		}
	}
	return 0;
}

Measured memory_bytes: 0
using System;

namespace TestProject
{
	class MainClass
	{
		public static void Main(string[] args)
		{

			string s = Console.ReadLine();
			string slist = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
			int[] ilist = new int[26];
			for (int i = 0; i < 26; i++)
			{
				ilist[i] = i;
			}
			int count = 0;
			int n = s.Length;
			int now = 0;
			int next = 0;
			for (int i = 0; i < n; i++)
			{
				next = slist.IndexOf(s[i]);
				if (next <= now)
				{
					count++;
				}

				now = next;
			}
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

template<class T>
vector<T> get_divisor(T n) {
    vector<T> res;
    for (long long i = 1; (i * i) <= n; i++) {
        if (n % i != 0) continue;
        res.push_back(i);
        if ((i * i) != n) res.push_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    vector<ll> div = get_divisor(__gcd(a, b));
    set<ll> s;
    s.insert(1);
    ll ans = 0;
    rep(i, sz(div)) {
        bool f = false;
        for(auto x : s) {
            if ((x != 1) && ((x % div[i] == 0) || (div[i] % x == 0))) {
                f = true;
                break;
            }
        }
        if (f) continue;
        ans++;
        set<ll> add;
        for(auto x : s) add.insert(x * div[i]);
        for(auto x : add) s.insert(x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;
const int MAX=1e5;
int a[MAX];
int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

int n;
cin>>n;
int s1=0,s2=0;
cin>>a[0];
forn(i,1,n){
    cin>>a[i];
    a[i]+=a[i-1];
    //cout<<a[i]<<endl;
}
int ans=1e8;
forn(i,0,n-1){
    ans = min(ans,abs(a[i]-(a[n-1]-a[i])));
    //cout<<ans<<endl;
}

cout<<ans<<endl;
}


Measured memory_bytes: 3652
def ok(ab):
    t = 0
    for a, b in ab:
        t += a
        if t > b:
            return False
    return True

n = int(input())
print('Yes' if ok(sorted([list(map(int, input().split())) for _ in range(n)], key=lambda ab: ab[1])) else 'No')

Measured memory_bytes: 55264
#include <stdio.h>
#include <stdbool.h>
int main(void){
    int a,b,c;
    bool ans = true;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a<c){
        if(b>c)
            ans = true;
        else
            ans = false;
    }else{
        if(b<c)
            ans = true;
        else
            ans = false;
    }
    
    if(ans)
        printf("Yes");
    else
        printf("No");
        
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define GET_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(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#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){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<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 SZ 250000
#define B 500

long a[SZ+5];
long b[B+5];
bool same[B+5];

inline void update(int blk){
  if(blk==B) return;
  same[blk] = true;
  rep(i,1,B) same[blk] &= a[blk*B+i]==a[blk*B];
}

inline bool check(){
  rep(i,B) if(!same[i] || a[i*B]+b[i]!=0) return false;
  return true;
}

void query(int l, int r, int x){
  if(l/B == r/B){
    rep(i,l,r) a[i] += x;
    update(l/B);
  }
  else{
    rep(i,l,(l/B+1)*B) a[i] += x;
    rep(i,l/B+1,r/B) b[i] += x;
    rep(i,r/B*B, r) a[i] += x;
    update(l/B);
    update(r/B);
  }
}

int main(){
  int n;
  cin>>n;
  vector<int> s(n);
  rep(i,n) scanf("%d", &s[i]);

  fill(a, a+SZ, 0);
  fill(b, b+B, 0);
  rep(i,n/2) a[i] = s[i] - s[n-i-1];

  rep(i,B) update(i);

  int q;
  cin>>q;
  rep(_,q){
    int l,r,x;
    scanf("%d %d %d", &l, &r, &x);
    l--;

    if(r<n/2){
      query(l,r,x);
    }
    else if(l>=n/2){
      query(n-r, n-l, -x);
    }
    else if(l < n-r){
      query(l,n-r,x);
    }
    else if(n-r < l){
      query(n-r,l,-x);
    }

    if(check()) puts("1");
    else puts("0");
  }

  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> Point(M+1,0);
    for(int i=0; i<N; i++){
        int K;
        cin >> K;
        for(int j=0; j<K; j++){
            int tmp;
            cin >> tmp;
            Point[tmp] += 1;
        }
    }

    int count =0;
    for(int i=0; i<M+1; i++){
        if(Point[i] == N){
            count +=1;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3568
n, s = map(int, input().split())
a = tuple(map(int, input().split()))
MOD = 998244353

# dp = [[0] * (s + 1) for _ in range(n + 1)]
# dp[0][0] = 1
# for i in range(n):  # ここをrange(i, n)にすると、f(i, r)の計算ができる
#     for j in range(s + 1):
#         dp[i + 1][j] += dp[i][j]  # do NOT use a[i]
#         if j + a[i] <= s:
#             dp[i + 1][j + a[i]] += dp[i][j]  # USE a[i]
# # f(1, n) = dp[n][s]
# # f(1, i) = dp[i][s] (i = 1, 2, ..., n)
# print('dp')
# print(*dp, sep='\n')

dp0 = [[0] * (s + 1) for _ in range(n + 1)]
dp1 = [[0] * (s + 1) for _ in range(n + 1)]
dp0[0][0] = 1
ans = 0
for i in range(n):
    for j in range(s + 1):
        # i番目の要素は使わない
        dp0[i + 1][j] += dp0[i][j]
        dp0[i + 1][j] %= MOD
        dp1[i + 1][j] += dp0[i][j] + dp1[i][j]
        dp1[i + 1][j] %= MOD

        if j + a[i] <= s:
            dp1[i + 1][j + a[i]] += dp0[i][j] + dp1[i][j]
            dp1[i + 1][j + a[i]] %= MOD

    ans += dp1[i + 1][s]
    ans %= MOD
# dp[r][s][1] = \sum_{i=1}^{r} f(i, r)

# print('dp[][][1]')
# for i in range(n + 1):
#     print([dp[i][j][1] for j in range(s + 1)])

print(ans)


Measured memory_bytes: 176264
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  rep(i,10000000){
    if(i%2==0){
      c-=b;
      if(c<=0){
        cout << "Yes" << endl;
        return 0;
      }
    }
    else{
      a-=d;
      if(a<=0){
        cout << "No" << endl;
        return 0;
      }
    }
   
  }
  return 0;
  
}


Measured memory_bytes: 15564
#include<bits/stdc++.h>
using namespace std;
#define MN 600
#define MOD 1000000007
int n,m,F[MN+5],R[MN+5],p[MN+5],u[MN+5][MN+5],s[MN+5][MN+5],f[MN+5];
inline int inv(int x)
{
	int r=1,y=MOD-2;
	for(;y;y>>=1,x=1LL*x*x%MOD)if(y&1)r=1LL*r*x%MOD;
	return r;
}
inline void rw(int&x,int y){if((x+=y)>=MOD)x-=MOD;}
inline int cal(int x){return x&1?0:1LL*F[x]*R[x/2]%MOD*p[x/2]%MOD;}
inline int cal(int l,int r)
{
	if((r+1)%n!=l&&s[l][r]+s[(r+1)%n][(l+n-1)%n]<m)return 0;
	return cal((r+n-l)%n+1-2*s[l][r]);
}
inline int C(int n,int m){return 1LL*F[n]*R[m]%MOD*R[n-m]%MOD;}
int main()
{
	int i,j,k,l,ans=0;
	scanf("%d%d",&n,&m);n*=2;
	for(F[0]=p[0]=i=1;i<=n;++i)F[i]=1LL*F[i-1]*i%MOD,p[i]=1LL*p[i-1]*(MOD+1)/2%MOD;
	for(R[i=n]=inv(F[n]);i--;)R[i]=1LL*R[i+1]*(i+1)%MOD;
	for(i=1;i<=m;++i)scanf("%d%d",&j,&k),--j,--k,u[j][k]=u[k][j]=1;
	for(i=0;i<n;++i)for(j=0;j<n;++j)
	{
		s[i][(i+j)%n]=j?s[i][(i+j-1)%n]:0;
		for(k=0;k<j;++k)s[i][(i+j)%n]+=u[(i+j)%n][(i+k)%n];
	}
	for(i=0;i<n;++i)
	{
		memset(f,0,sizeof(f));
		for(j=0;j<=i;++j)
		{
			rw(f[j],cal(i,(j+n-1)%n));
			for(k=j;k<i;++k)rw(f[k+1],(MOD-1LL*f[j]*cal(j,k)%MOD)%MOD);
		}
		ans=(ans+f[i])%MOD;
	}
	printf("%d",(1LL*(n+1)*cal(0,n-1)+MOD-ans)%MOD);
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

//////////////////////////

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

    string ans = "No";
    rep(i, 3) { if (S[i] == '7') { ans = "Yes"; } }
    cout << ans;
    
    system("PAUSE");
}


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

using namespace std;

const int mod =  1e9+7;

int main()
{
	int n,m;
	cin>>n>>m;
	
	vector<string> grid(n);
	for(int i=0;i<n;i++)
	{
		cin>>grid[i];
	}

	vector< std::vector<int> > dp(n,vector<int>(m,0));

	dp[0][0]=1;
	
	for(int i=1;i<m;i++)
	{
		if(grid[0][i]=='.') dp[0][i] = dp[0][i-1];
		else
			break;
	}
	for(int i=1;i<n;i++)
	{
		if(grid[i][0]=='.')	dp[i][0] = dp[i-1][0];
		else
			break;
	}

	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(grid[i][j]=='.')
			{
				dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
			}
		}
	}
	cout<<dp[n-1][m-1]%mod;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
	int n,k;
	string s, ans;

	cin >> n >> s >> k;
	
	ans = "";
	for(char c:s){
		if(s[k-1] != c){
			ans.append("*");
		} else {
			ans.push_back(c);
		}
	}

	cout << ans;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    s = args[0]

    ret = True
    for i in range(0, len(s), 2):
        ret &= s[i:i+2] == 'hi'
    return 'Yes' if ret else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

using namespace std;

int N;
string s;
map < string, map < string, int > > mp;

int main(){
    cin >> N >> s;
    reverse(s.begin() + N, s.begin() + 2 * N);
    for(int i = 0; i < (1 << N); ++i){
        string A, B;
        for(int j = 0; j < N; ++j){
            if(i & (1 << j)){
                A += s[j];
            }
            else{
                B += s[j];
            }
        }
        ++mp[A][B];
    }
    long long ans = 0;
    for(int i = 0; i < (1 << N); ++i){
        string A, B;
        for(int j = N; j < 2 * N; ++j){
            if(i & (1 << (j - N))){
                A += s[j];
            }
            else{
                B += s[j];
            }
        }
        ans += mp[A][B];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 123904
N = input()
k = len(N)
N = int(N)

nums = ['3', '5', '7']
add3 = lambda x: x + '3'
add5 = lambda x: x + '5'
add7 = lambda x: x + '7'

cnt = 0
for _ in range(k-1):
    num_tmp = []
    num_tmp.append(list(map(add3, nums)))
    num_tmp.append(list(map(add5, nums)))
    num_tmp.append(list(map(add7, nums)))
    nums = sum(num_tmp, [])

    for i in range(len(nums)):
        if '3' in nums[i] and '5' in nums[i] and '7' in nums[i] and int(nums[i]) <= N:
            cnt += 1

print(cnt)


Measured memory_bytes: 42224
#include<iostream>                                                     
#include<cmath>                                                       
#include<cstdio>                                                       
using namespace std;                                                   
                                                                       
int main() {                                                           
  int n;                                                               
  double x1, y1, x2, y2, x3, y3;                                       
  double x, y, r;                                                      
  double a1, a2, b1, b2, c1, c2;                                       
                                                                       
  cin >> n;                                                            
  while (n--) {                                                        
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;                           
                                                                       
    a1 = 2*(x2-x1);                                                    
    b1 = 2*(y2-y1);                                                    
    c1 = x1*x1-x2*x2+y1*y1-y2*y2;                                      
                                                                       
    a2 = 2*(x3-x1);                                                    
    b2 = 2*(y3-y1);                                                    
    c2 = x1*x1-x3*x3+y1*y1-y3*y3;                                      
                                                                       
    x = (b1*c2-b2*c1)/(a1*b2-a2*b1);                                   
    y = (c1*a2-c2*a1)/(a1*b2-a2*b1);                                   
                                                                       
    r = hypot(x-x1,y-y1);                                              
                                                                       
    printf("%.3f %.3f %.3f\n", x, y, r);                               
  }                                                                    
                                                                       
  return 0;                                                            
}                       

Measured memory_bytes: 3216
import math


def dfs(sc, i=0, qn=0, used=set()):
    if sc <= 0:
        return qn
    if i == d:
        i -= 1
        while i in used:
            i -= 1
        hanpa = math.ceil(sc / (100 * (i + 1)))
        if hanpa >= pc[i][0]:
            return inf
        return qn + hanpa
    p, c = pc[i]
    zenbu = (i + 1) * 100 * p + c
    used.add(i)
    re1 = dfs(sc - zenbu, i + 1, qn + p, used)
    used.remove(i)
    re2 = dfs(sc, i + 1, qn, used)
    return min(re1, re2)


inf = 10 ** 9
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
print(dfs(g))

Measured memory_bytes: 41200
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, M, X, Y;

int main(void){
	
	scanf("%d %d %d %d", &N, &M, &X, &Y);
	int mx = -INT_MAX, mn = INT_MAX; 
	for(int i = 0; i < N; ++i){
	    int a; scanf("%d", &a);
	    mx = max(mx, a);
	}
	for(int i = 0; i < M; ++i){
	    int a; scanf("%d", &a);
	    mn = min(mn, a);
	}
	
	if(mx < mn && X < mn && mn <= Y) printf("No War\n");
	else printf("War\n");
	
    return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a ,b);

  int ans = 0;
  ans += b;
  b--;

  ans += max(a, b);
  cout << ans << endl;

  return 0;
}


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

int main() {
    lint n, k;
    cin >> n >> k;

    vector<bool> snuke(n);
    for(int i=0; i<k; i++) {
        lint d;
        cin >> d;
        for(int j=0; j<d; j++) {
            int a;
            cin >> a;
            snuke[--a] = true;
        }
    }

    lint ans = 0;
    for(int i=0; i<n; i++) {
        ans += !snuke[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var input string

	for{
		fmt.Scan(&input)

		if input == "0"{
			break
		}

		var sum int
		for _, s := range input{
			i, _ := strconv.Atoi(string(s))
			sum += i
		}
		fmt.Println(sum)
	}
}


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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 1000000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    int ans = (n - m) * 100 + m * 1900;
    rep(i, 0, m)
        ans *= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

   
    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
       	int n =s.nextInt();
       	int p=1000, j=0;
    	while(n>0) {
    		j=n-p;
    		n-=p;
    	}
    	System.out.println(Math.abs(j));
    }	
}





        
    

      
 

Measured memory_bytes: 32712
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int n,i,c,cmax=0; 
  cin>>n;
  vector<string> s(n);
  for(i=0;i<n;i++){
    cin>>s.at(i);
  }
  sort(s.begin(),s.end());
  c=0;
  for(i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1))c++;
    else c=0;
    cmax = max(cmax,c);
  }
  c=0;
  
  for(i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1))c++;
    else c=0;
	if(c==cmax)cout<<s.at(i)<<endl;
  }
  if(cmax==0)cout<<s.at(n-1)<<endl;
}

Measured memory_bytes: 14208
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
// https://atcoder.jp/contests/abc167/tasks/abc167_c
ll a[12][12] = {0,};
bool isVisited[12] ={0,};
vector<ll> c;
ll n,m,x;
ll ans = -1;
void track(){
    ll skill[12] ={0,};
    ll val = 0;
    for(int i = 0;i<n;i++){
        if(isVisited[i]){
            val += c[i];
            for(int j = 0;j<m;j++){
                skill[j] += a[i][j];
            }
        }
    }
    for(int i = 0;i<m;i++){
        if(skill[i] < x){
            return ;
        }
    }
    if(ans == -1){
        ans = val;
    }
    else{
        ans = min(ans, val);
    }
}
void solve(ll cnt){
    if(cnt == n){
        track();
        return;
    }
    isVisited[cnt] = true;
    solve(cnt+1);
    isVisited[cnt] = false;
    solve(cnt+1);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m >> x;
    c.resize(n);
    for(int i = 0;i<n;i++){
        cin >> c[i];
        for(int j = 0;j<m;j++){
            cin >> a[i][j];
        }
    }
    solve(0);
    cout << ans;

	return 0;

}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  string s;
  cin >> s;
  int y,m,d;
  string ys = s.substr(0,4);
  string ms = s.substr(5,2);
  string ds = s.substr(8,2);
  y = stoi(ys);
  m = stoi(ms);
  d = stoi(ds);
  if(y<2019){
    cout << "Heisei" << endl;
    return 0;
  } else if(y>2019){
    cout << "TBD" << endl;
    return 0;
  }
  if(m<=4){
    cout << "Heisei" << endl;
    return 0;
  } else if(m>4){
    cout << "TBD" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
import math

n, kk = tuple(map(int, input().split()))
sumnum = n * (n + 1) // 2
arr = tuple(map(int, input().split()))
sums = [0 for i in range(sumnum)]
hojo = [0 for i in range(n)]
point = 0

for i, e in enumerate(arr):
    for k in range(i):
        hojo[k] += e
        sums[point] = hojo[k]
        point += 1
    hojo[i] = e
    sums[point] = hojo[i]
    point += 1

maxlog = 0
maxe = max(sums)
while maxe >= 2**maxlog:
    maxlog += 1
maxlog -= 1

res = 0

for i in range(maxlog, -1, -1):
    ya = [0 for i in range(len(sums))]
    dab = 0
    gaga = 1 << i
    for e in sums:
        if e & gaga:
            ya[dab] = e
            dab += 1

    if dab >= kk:
        res += gaga
        sums = ya[:dab]

print(res)


Measured memory_bytes: 31672
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")


signed main(){
	cout<<fixed<<setprecision(7);
	int N, k;
	bool flag = false;
	
	cin>>N;
	
	for(int i = 1; i*(i+1) <= 2*N; i++){
		if(i*(i+1) == 2*N){
			k = i+1;
			flag = true;
			break;
		}
	}
	if(flag == false){
		cout<<"No"<<endl;
	} else {
		int count = 1, countb = 0;
		cout<<"Yes"<<endl;
		cout<<k<<endl;
		for(int i = 1; i <= k; i++){
			cout<<k-1;
			for(int  j = 1, l = k-2, d = 0; j < i; j++,d+=l,l--){
				cout<<" "<<i+d-1;
			} countb += i;
			for(int j = i; j <= k-1; j++){
				cout<<" "<<count++;
			}cout<<endl;
		}
		
	}
	
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using ll = long long;

int len(int n) {
    if (n % 2 == 0) return -1;

    int i, k = 0;

    for (i = 1; i <= 1000000; ++i) {
        k = (k*10+7) % n;
        if (!k) return i;
    }
    if (k) return -1;
}

int main() {
    FAST;

    int n;
    cin >> n;
    cout << len(n);

    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  if ( L > R ) {
    cout << "Left" << endl;
  }
  else if ( L < R ) {
    cout << "Right" << endl;
  }
  else if (L == R) { 
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = 10000;
const int maxn = (int)1e3 + 5;//remember to modify it, No RE or MLE 
const int maxm = (int)1e5 + 5;//remember to modify it, No RE or MLE 
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;

int main()
{
	FAST;
	ll n; cin >> n;
	if(n == 2) { cout << 1 << endl; return 0; }
	ll m = sqrt(n);
	int ans = 1;
	rep(i, 2, m){
		if(n % i == 0){
			ll t = n;
			while(t % i == 0) t /= i;
			ans += (t % i == 1);
			if(n / i != i){
				t = n;
				ll t2 = n / i;
				while(t % t2 == 0) t /= t2;
				ans += (t % t2 == 1);
			}
		}
	}
	m = sqrt(n - 1);
	rep(i, 2, m){
		if((n - 1) % i == 0){
			ans++;
			if((n - 1) / i != i) ans++;
		}
	}
	ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e3 + 5;
double dp[N][N], p[N];
int n;
double solve(int idx, int heads){
    if(idx == n){
        if(heads >= (n + 1) / 2)
            return 1;
        return 0;
    }
    if(dp[idx][heads] != -1){
        return dp[idx][heads];
    }
    double ans = 1;
    ans *= p[idx] * solve(idx + 1, heads + 1);
    ans += (1.0 - p[idx]) * solve(idx + 1, heads);
    return dp[idx][heads] = ans;
}
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            dp[i][j] = -1;
    cout << fixed << setprecision(10) << solve(0, 0);
return 0;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<ll >    vecll;
typedef vector<string > vecstr;
////////////////////////////////////////////////
ll num(ll k, ll n, ll m){
  ll zero = 0;
  return max((ll)min((m - 2*k)/2, n + k),zero);
}
////////////////////////////////////////////////
int main()
{
  ll n, m;
  cin >> n >> m;
  if(m <= 2*n){
    cout << m/2 << endl;
    return 0;
  }
  ll k = (m - 2*n)/4;
  cout << max(max(num(k - 1, n, m),num(k, n, m)),num(k + 1, n, m)) << endl;
} 



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 16,mod = 1e9 + 7;

int a[N + 5];
int dp[N + 5][1 << N],fac[(1 << N) + 10],inv[(1 << N) + 10];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline int fpm(int A,int B) {
	int res = 1;
	while(B) {
		if(B & 1) res = 1ll * res * A % mod;
		A = 1ll * A * A % mod,B /= 2;
	}
	return res;
}

inline void init(int n) {
	fac[0] = 1;
	For(i,1,n) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n] = fpm(fac[n],mod - 2);
	Fordown(i,n,1) inv[i - 1] = 1ll * inv[i] * i % mod;
}

inline void add(int &x,int y) {
	if((x += y) >= mod) x -= mod;
}

inline int C(int n,int m) {
	if(n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
	int n = read(),m = read();
	init((1 << n) + 5);
	For(i,1,m) a[i] = read();
	sort(a + 1,a + m + 1,greater<int>());

	dp[0][0] = 1;
	For(i,1,m) For(j,0,(1 << n) - 1) {
		add(dp[i][j],dp[i - 1][j]);
		For(k,0,n - 1) {
			if(j & (1 << k)) continue;
			add(dp[i][j | (1 << k)],1ll * dp[i - 1][j] * C((1 << n) - a[i] - j,(1 << k) - 1) % mod * fac[1 << k] % mod);
		}
	}
	int ans = 0;
	For(i,0,(1 << n) - 1) {
		int Sign = __builtin_popcount(i) & 1 ? mod - 1 : 1;
		add(ans,1ll * Sign * dp[m][i] % mod * fac[(1 << n) - 1 - i] % mod);
	}

	printf("%lld\n",1ll * ans * fpm(2,n) % mod);

	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll f(ll b, ll n) {
    if (n < b) {
        return n;
    }
    return f(b, n / b) + n % b;
}

int main() {
    ll n, s;
    cin >> n >> s;
    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }
    
    for (ll b = 2; b * b <= n; b++) {
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }
    
    ll ans = 1e12;
    for (ll p = 1; p * p <= n; p++) {
        ll b = (n - s) / p + 1;
        if (b >= 2 && f(b, n) == s) {
            ans = min(ans, b);
        }
    }
    if (ans == 1e12) {
        ans = -1;
    }
    cout << ans << endl;
    
}

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

int f(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main(){
    int n,i;
    cin >> n ;
    set<int> S;
    S.insert(n);
    for(i=1;i==S.size();i++){
        n=f(n);
        S.insert(n);
    }
    cout << i <<endl;
}

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

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

deque <llong> deq;
vector <llong> v;

llong n, a[mxn], k, dp[3001][3001], sum2, sum1;
bool ok = 0;

int main (){
    cin >> n;
    for (int i = 1; i <= n; i ++){
        cin >> a[i];
    }for (int i = 1; i <= n; i ++){
        for (int j = 1; j + i - 1 <= n; j ++){
            dp[i][j] = max(a[j] - dp[i - 1][j + 1], a[j + i - 1] - dp[i - 1][j]);
//            cout << dp[i][j] << ' ';
        }/*cout << endl;*/
    }
	cout << dp[n][1] << endl;
    return 0;
}

Measured memory_bytes: 70016
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <bitset>

using namespace std;

#define FSIO  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define DEBUG(a)   cout<<"DEBUG: "<<(a)<<endl;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define MP make_pair
#define X  first
#define Y  second
#define REP(i,st,ed)    for(int i=st;i<=ed;++i)
#define IREP(i,st,ed)   for(int i=st;i>=ed;--i)
#define TCASE(T)    cin>>T;while(T--)

const int MAXN = 200005;
const ll MOD = 1e9+7 ;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 1e9+7;
const double PI = acos(-1.0);
const double EPS = 1e-8;

int _;

using namespace std;



int main()
{
    //freopen("test.in","r+",stdin);
    //freopen("test.out","w+",stdout);
    FSIO;
    string S, T;
    while(cin>>S>>T)
    {
        reverse(S.begin(),S.end());
        reverse(T.begin(),T.end());
        int slen = S.length();
        int tlen = T.length();
        int flag = -1;
        for(int i=0;i<slen;++i)
        {
            if(S[i]==T[0]||S[i]=='?')
            {
                int curflag = 1;
                for(int j=0;j<tlen;++j)
                    if(S[i+j]==T[j]||S[i+j]=='?')   continue;
                    else
                    {
                        curflag = 0;
                        break;
                    }
                if(curflag)
                {
                    flag = i;
                    break;
                }
            }
        }
        if(flag==-1)
        {
            cout<<"UNRESTORABLE"<<endl;
            continue;
        }
        for(int j=0;j<tlen;++j) S[flag+j]=T[j];
        for(int i=0;i<slen;++i) if(S[i]=='?')   S[i]='a';
        reverse(S.begin(),S.end());
        cout<<S<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	pm := make(map[int]int)
	for i := 1; i <= n; i++ {
		tmp := primeFactorize(i)
		for k, v := range tmp {
			pm[k] += v
		}
	}

	ks := make([]int, 0)
	for k := range pm {
		ks = append(ks, k)
	}
	sort.Ints(ks)
	ps := make([]Pair, 0)
	for _, k := range ks {
		ps = append(ps, Pair{k, pm[k]})
	}

	var rec func(i int, ps []Pair, sum int) int
	rec = func(i int, ps []Pair, sum int) int {
		if i == len(ps) {
			if sum == 75 {
				return 1
			}
			return 0
		}

		res := 0
		for j := 0; j <= ps[i].second; j++ {
			x := sum * (j + 1)
			if 75%x != 0 {
				continue
			}
			res += rec(i+1, ps, x)
		}
		return res
	}

	ans := rec(0, ps, 1)
	fmt.Println(ans)
}

// Pair .
type Pair struct {
	first, second int
}

func primeFactorize(n int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			n /= i
			res[i]++
		}
	}
	if n != 1 {
		res[n]++
	}
	return res
}


Measured memory_bytes: 512
A = int(input())
B = int(input())

if A == 1:
  if B == 2:
    print(3)
  elif B == 3:
    print(2)
elif A == 2:
  if B == 1:
    print(3)
  elif B == 3:
    print(1)
else:
  if B == 1:
    print(2)
  elif B == 2:
    print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
int K,N;
int a[maxn];
int b[maxn];

int main(void)
{
	scanf("%d %d",&K,&N);
	for(int i=0;i<N;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<N-1;i++)
		b[i]=a[i+1]-a[i];
	b[N-1]=K-a[N-1]+a[0];

	sort(b,b+N);	
	
	printf("%d\n",K-b[N-1]);
	return 0;
}

Measured memory_bytes: 1792