akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)2e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

ll lcm(ll a, ll b){
	while(b){
		a %= b;
		swap(a, b);
	}

	return a;
}

int main(){
	vector<bool> isprime(1000009, true);
	vector<ll> prime;
	for(int i=2;i<=1000000;++i){
		if(isprime[i]){
			prime.push_back(i);
			for(int j=i*2;j<=1000000;j+=i)isprime[j] = false;
		}
	}
	ll a, b;
	cin >> a >> b;
	ll lc = lcm(a, b);
	int ans = 1;
	foreach(i, prime){
		if(lc%i==0){
			++ans;
			while(lc%i==0)lc/=i;
		}
	}
	if(lc!=1)++ans;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;


int main(){
	
	int n;
	bool first = true;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		if(!first){
			cout << endl;
		}
		first = false;
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int rest = a * 10 + b * 50 + c * 100 + d * 500 - n;
		int a2, b2, c2, d2;
		d2 = rest / 500;
		rest -= d2 * 500;
		c2 = rest / 100;
		rest -= c2 * 100;
		b2 = rest / 50;
		rest -= b2 * 50;
		a2 = rest / 10;
		rest -= a2 * 10;
		a2 = max(0, a - a2);
		b2 = max(0, b - b2);
		c2 = max(0, c - c2);
		d2 = max(0, d - d2);
		if(a2 > 0){
			cout << "10 " << a2 << endl;
		}
		if(b2 > 0){
			cout << "50 " << b2 << endl;
		}
		if(c2 > 0){
			cout << "100 " << c2 << endl;
		}
		if(d2 > 0){
			cout << "500 " << d2 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define bs binary_search
#define gcd(a,b) __gcd(a,b)
#define PI 3.1415926535897932384626
#define lp lower_bound
#define up upper_bound
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
#define UNIQUE(x) (x).resize(unique(all(x))-(x).begin())
#define bp(x)  __bulitin_popcount(x)
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}


const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll f(ll i,ll j,string s){
    ll k=0;
    ll a=i,b=j;
    bool ok=true;
    while(i<j){
        if(s[i++]!=s[j--])ok=false;
        
    }
    if(ok)return 1;
    else return 0;
    
}
int main()
{
boost
double  x;
cin>>x;double ans=pow((x/3),3);
printf("%.15f",ans);
return 0;
}


Measured memory_bytes: 256
import itertools
NK = input().split()
N = NK[0]
K = int(NK[1])
 
d = input().split()
D = [int(s) for s in d]
 
Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 
for i in D:
    Da.remove(i)
Da_str = [str(j) for j in Da]
 
a_1 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N))]
a_2 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N)+1)]
a = a_1 + a_2
nu = [int(k) for k in a]
 
for i in nu:
    if i >= int(N):
        print(i)
        break

Measured memory_bytes: 10456
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();

    vvl is(26);
    rep(i, n) {
        is[s[i] - 'a'].pb(i);
    } 
    rep(i, n) {
        is[s[i] - 'a'].pb(i+n);
    }

    ll ans = 0;
    ll p = 0;
    rep(i, m) {
        ll c = t[i] - 'a';
        if(is[c].size() == 0) {
            out(-1);
            re0;
        }
        p = *lower_bound(all(is[c]), p) + 1;
        if(p >= n) {
            p -= n;
            ans += n;
        }
    }
    
    ans += p;

    out(ans);
    re0;
}

Measured memory_bytes: 2800
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
    ll n,k;
    cin>>n>>k;
    ll aa[n];
    for(int i=0; i<n; i++) cin>>aa[i];
    sort(aa,aa+n);
    ll ans=0;
    for(int i=0; i<k; i++) ans+=aa[i];
    cout<<ans<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

vector<bool> eratosthenes(int n) {
	vector<bool> prime(n + 1);
	for (int i = 2; i <= n; i++) {
		prime[i] = true; // 初期化
	}
	prime[0] = prime[1] = false;
	for (int i = 2; i*i <= n;i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= n; j += i) {
				prime[j] = false;
			}
		}
	}
	return prime;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<bool> prime = eratosthenes(n);
	ll ans = 1;
	int kj = 1;
	for (int i = 2; i <= n; i++) {
		kj *= i;
	}
	for (int i = 2; i <= n; i++) {
		if (prime[i]) {
			int e = 0;
			for (int j = i; j <= n; j *= i) {
				e += (n / j);
			//	cout << i << " " << j << " " << e << endl;
			}
			ans = (ans * (e + 1) % 1000000007);
			//cout << i << " " << e << endl;
		}
	}
	cout << ans << endl;

	return 0;
}


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=5e5+10;
int t[maxn],a[maxn],lst[maxn],ans[maxn];
vector<pair<pii,int>> ve;
int n,q;

bool cmp(pii u,pii v){
	if(u.se==v.se)return u.fi<v.fi;
	return u.se<v.se;
}

int lowbit(int x){ return x&-x; }
void add(int p,int x){ while(p<=n){ t[p]+=x;p+=lowbit(p); } }
int qsum(int p){ int r=0;while(p){ r+=t[p];p-=lowbit(p); }return r; }

int main(){
	io;
	cin>>n>>q;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=q;i++){
		int l,r;cin>>l>>r;
		ve.pb(pair<pii,int>(pii(r,l),i));
	}
	sort(ve.begin(),ve.end());
	int p=0;
	for(int i=1;i<=n&&p<q;i++){
		if(lst[a[i]])add(lst[a[i]],-1);
		add(i,1);
		lst[a[i]]=i;
		while(ve[p].fi.fi<=i&&p<q){
			// dbg(ve[p].se);
			ans[ve[p].se]=qsum(ve[p].fi.fi)-qsum(ve[p].fi.se-1);
			p++;
		}
	}
	for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
	return 0;
}

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

int main(){
  int N, ans = 0; string S;
  cin>>N;
  cin>>S;
  for(int i = 0; i < N; i++){
    if(S[i] == 'A')if(S[i+1] == 'B')if(S[i+2] == 'C')ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 256
N = int(input())
S = input().strip()
qn = int(input())
qs = list(map(int, input().split()))
dd,mm,cc = [0],[0],[0]
dd_append = dd.append
mm_append = mm.append
cc_append = cc.append
As = [0]*qn
d=m=dm=0
for i, w in enumerate(S):
    i += 1
    if w=="D":
        d+=1
    elif w == "M":
        m+=1
        dm+=d
    elif w == "C":
        for j, q in enumerate(qs):
            if i-q:
                ll = max(i-q, 0)
                As[j] += dm - cc[ll] - dd[ll]*(m-mm[ll])
            else:
                As[j] += dm
    dd_append(d)
    mm_append(m)
    cc_append(dm)
for a in As:
    print(a)


Measured memory_bytes: 150168
const lines=readlines(open("/dev/fd/0"))
let
    state=0
    global input
    input()=lines[state+=1]
end
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    k=int(input())
    println(Int(ceil(k/2)*floor(k/2)))
end
main()

Measured memory_bytes: 114604
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

#include <math.h>
/*
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
#include <cmath>
ll A;
ll B;
ll C;
ll H;
ll M;
ll K;
#include <iomanip>
int main(){

    
    cin >> A;
    cin >> B;
    cin >> H;
    cin >> M;

    double radA;
    double radB;
    double base;

    base = H * 60 + M;

    radA = base / (12.0*60) * 360;
    radB = (M / 60.0) * 360;
    
    if(radA==radB){
        cout << max(A,B)-min(A,B) << endl;
    
    }
    else{
        double base2;
        base2 = abs(radA-radB);
        if(base2>180) base2=360-base2;
        double value;
        value = A * A + B * B - 2 * A * B * cos(base2/180*M_PI);
        //cout << radA << endl;
        //cout << radB << endl;
        //cout << base2 << endl;
        //cout << base2/180 << endl;
        //cout << cos(base2/180*M_PI) << endl;
        //cout << value << endl;
        //cout << sqrt(value) << endl;
        cout << fixed << setprecision(20) << pow(value,0.5) << endl;
    }

}

Measured memory_bytes: 4424
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

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> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  REP(i, n) { cout << s[i] << t[i]; }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    string a;int b,c;
    getline(cin,a);
    c=a.length();
    for(b=c-1;b>=0;b--)
    {
        cout<<a[b];
    }
    cout<<endl;


    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL)cout << "root, ";
    else if (T[u].l == NIL ) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ){
        if ( i ) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p){
    D[u] = p;
    if( T[u].r != NIL ) rec(T[u].r, p);
    if( T[u].l != NIL ) rec(T[u].l, p + 1);
}

int main(){
    int i, j, d, v, c, l, r;
    cin >> n;
    for ( i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

    for ( i = 0; i < n; i++){
        cin >> v >> d;
        for ( j = 0; j < d; j++){
            cin >> c;
            if ( j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for( i = 0; i < n; i++){
        if(T[i].p == NIL) r = i;
    }

    rec(r, 0);

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

    return 0;
}



Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

const int N=100005;


int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>i)
			cout<<"-1",exit(0);
	}
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[i-1]+1)
			cout<<"-1",exit(0);
	}
	int ans=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]==1)
			ans++;
		else if(!a[i])
			continue;
		else if(a[i]<=a[i-1])
			ans+=a[i];
		else ans++;
		//cerr<<ans<<endl;
	}
	cout<<ans;
 	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 998244353
#define all(vec) vec.begin(), vec.end()

int main(){
  string s;
  cin >> s;
  rep(i,3) cout << s.at(i);
  cout << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>

using namespace std;

int main() {
  char *s;
  s = new char[100001];
  cin >> s;
  for (int i = 0; i < strlen(s); i += 2) {
    cout << s[i];
  }
  cout << '\n';

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(a-b, a*b));
    return 0;
}

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

typedef long long s64;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 200000;
const int MaxTN = 542488;

const int M = 924844033;
const int FFT_G = 5;

inline int modpow(int a, const int &n)
{
	int res = 1;
	for (int i = n; i; i >>= 1)
	{
		if (i & 1)
			res = (s64)res * a % M;
		a = (s64)a * a % M;
	}
	return res;
}

inline int add(int a, const int &b)
{
	a += b;
	return a >= M ? a - M : a;
}
inline int dec(int a, const int &b)
{
	a -= b;
	return a < 0 ? a + M : a;
}

int tn, tl, inv;
int bitRev[MaxTN];
int root[MaxTN];

inline void fft_init(int n)
{
	tn = 1, tl = 0;
	while (tn < n)
		tn <<= 1, ++tl;
	inv = modpow(tn, M - 2);

	for (int i = 1; i < tn; ++i)
	{
		int l = bitRev[i >> 1] >> 1;
		bitRev[i] = l | ((i & 1) << tl - 1);
	}

	int bn = tn >> 1;
	root[bn + 0] = 1;
	root[bn + 1] = modpow(FFT_G, (M - 1) / tn);
	for (int i = 2; i < bn; ++i)
		root[bn + i] = (s64)root[bn + i - 1] * root[bn + 1] % M;
	for (int i = bn - 1; i > 0; --i)
		root[i] = root[i << 1];
}

inline void fft(int *a, int type)
{
	if (type)
		reverse(a + 1, a + tn);

	for (int i = 0; i < tn; ++i)
	{
		int r = bitRev[i];
		if (i < r)
			swap(a[i], a[r]);
	}

	for (int k = 1; k < tn; k <<= 1)
	{
		int *g = root + k;
		for (int s = 0; s < tn; s += k << 1)
		{
			int *w = g;
			for (int i = s; i < s + k; ++i, ++w)
			{
				int o = a[i], e = (s64)a[i + k] * *w % M;
				a[i] = add(o, e);
				a[i + k] = dec(o, e);
			}
		}
	}

	if (type)
	{
		for (int i = 0; i < tn; ++i)
			a[i] = (s64)a[i] * inv % M;
	}
}

inline void polymul(int *a, int *b, int n)
{
	fft_init(n + n + 1);

	fft(a, 0);
	fft(b, 0);
	for (int i = 0; i < tn; ++i)
		a[i] = (s64)a[i] * b[i] % M;
	fft(a, 1);
}

int n;

struct halfEdge
{
	int v;
	halfEdge *next;
};
halfEdge adj_pool[MaxN * 2], *adj_tail = adj_pool;
halfEdge *adj[MaxN + 1];

inline void addEdge(const int &u, const int &v)
{
	adj_tail->v = v, adj_tail->next = adj[u];
	adj[u] = adj_tail++;
}

int coe[MaxTN];

int dfs(const int &u, const int &prev)
{
	int num = 1;
	for (halfEdge *e = adj[u]; e; e = e->next)
		if (e->v != prev)
		{
			int s = dfs(e->v, u);
			num += s, --coe[s];
		}
	++coe[n], --coe[n - num];
	return num;
}

int fact[MaxN + 1];
int rfact[MaxN + 1];

inline void init_fact(int n)
{
	fact[0] = 1;
	for (int i = 1; i <= n; ++i)
		fact[i] = (s64)fact[i - 1] * i % M;

	rfact[n] = modpow(fact[n], M - 2);
	for (int i = n; i; --i)
		rfact[i - 1] = (s64)rfact[i] * i % M;
}

int val[MaxTN];

int main()
{
	cin >> n;
	for (int i = 1; i < n; ++i)
	{
		int u = getint(), v = getint();
		addEdge(u, v);
		addEdge(v, u);
	}

	dfs(1, 0);

	init_fact(n);

	for (int i = 0; i <= n; ++i)
		val[i] = rfact[n - i];
	for (int i = 0; i <= n; ++i)
		coe[i] = (s64)fact[i] * (coe[i] % M + M) % M;

	polymul(coe, val, n);

	for (int i = 1; i <= n; ++i)
		printf("%d\n", (s64)coe[n + i] * rfact[i] % M);

	return 0;
}

Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
#define foru(i,a,n) for (int i=(a); i<=(n); i++)
#define ford(i,n,a) for (int i=(n); i>=(a); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define foreach(it, a) for (auto it = (a).begin(); it != (a).end(); it++)
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define all(x) (x).begin(),(x).end()
#define ms(s, n) memset(s, n, sizeof(s))
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define fi first
#define se second
#define bit(n, i) (((n) >> (i)) & 1)
#define bit1cnt(x) (__builtin_popcountll(x))
#define bit0dau(x) (__builtin_clzll(x))
#define bit0cuoi(x) (__builtin_ctzll(x))
#define sqr(x) ((x) * (x))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;
typedef vector<ii> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int inf = (int) 1e9;
const ll linf = (ll) 1e18;
const ld pi = acos((ld) -1);
const ld eps = 1e-9;
const int N = 202020;
ll n, x, y, a[N], ans;
int main(){
    
    ios::sync_with_stdio(0); cin.tie(0);
    cin >>x >>y;
    if(x==2 || y==2)
        cout <<"No";
    else
        cout <<"Yes";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<vector<int>>table(h, vector<int>(w, 0));
	int x, y, a;
	for (int i = 0;i < n;i++) {
		cin >> x >> y >> a;
		x--;
		y--;
		if (a == 1) {
			for (int i = 0;i < h;i++) {
				for (int j = 0;j <= x;j++) {
					table[i][j] = 1;
				}
			}
		}
		else if (a == 2) {
			for (int i = 0;i < h;i++) {
				for (int j = x + 1;j < w;j++) {
					table[i][j] = 1;
				}
			}
		}
		else if (a == 3) {
			for (int i = h - y - 1;i < h;i++) {
				for (int j = 0;j < w;j++) {
					table[i][j] = 1;
				}
			}
		}
		else if (a == 4) {
			for (int i = 0;i < h - y - 1;i++) {
				for (int j = 0;j < w;j++) {
					table[i][j] = 1;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (!table[i][j]) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {
  private static int gcdFn(int a, int b) {
    return a % b == 0 ? b : gcdFn(b, a%b);
  }
  
  private static boolean solve(int k, int[] a) {
    int maxA = a[0];
    int gcd = a[0];
    
    for (int ai : a) {
      maxA = Math.max(maxA, ai);
      gcd = gcdFn(gcd, ai);
    }
    return maxA >= k && k % gcd == 0;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    int[] a = reader.nextIntArray(n);
    out.println(solve(k, a) ? "POSSIBLE" : "IMPOSSIBLE");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 37004
x,y=gets.split.map!{|i| i.to_i}
nom=Array.new(y)
seigo=Array.new(y)
wa=Array.new(x,0)
ac=0
pena=0
kanri=0
for j in 0..y-1
  nom[j],seigo[j]=gets.split
  kanri=(nom[j].to_i)-1
  if wa[kanri]=="x"
    next
  end
  if seigo[j]=="AC"
    ac+=1
    pena += wa[kanri]
    wa[kanri]="x"
  elsif seigo[j]=="WA"
    wa[kanri]+=1
  else
  end
end
puts "#{ac} #{pena}"


Measured memory_bytes: 32416
while True:
    H, W = map(int, input().split())

    # H = 0 かつ W = 0 のとき終了する
    if H == 0 and W == 0:
        break

    for i in range(H):
        if i == 0 or i == H - 1:
            # 1 行目と H 行目は # のみ
            for j in range(W):
                print('#', end='')
        else:
            # 2 ~ H - 1 行目は 1 列目と W 列目が # でそれ以外は . となる
            for j in range(W):
                if j == 0 or j == W - 1:
                    print('#', end='')
                else:
                    print('.', end='')
        print()

    # データセットごとに改行する
    print()


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

const int N = 303;

int n, m, d, q;
map<int,pii> mp;
int cst[N*N];

int dist (pii a, pii b) { return abs(a.first-b.first) + abs(a.second-b.second); }

int main () {
	scanf("%d %d %d", &n, &m, &d);
	for (int i = 0; i < n; i++) for (int j = 0, x; j < m; j++) { scanf("%d", &x); mp[x] = pii(i,j); }
	scanf("%d", &q);

	for (int i = 1; i <= n*m; i++) { if (i <= d) cst[i] = 0; else cst[i] = cst[i-d] + dist(mp[i],mp[i-d]); }
	while (q--) {
		int l, r;
		scanf("%d %d", &l, &r);
		printf("%d\n", cst[r] - cst[l]);
	}
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[111111];
  cin>>n;  
  for(int i=1;i<=n;i++)cin>>a[i];
  a[0]=0;
  a[n+1]=0;
  int c=0,sum=0;
  for(int i=1;i<=n+1;i++){
    sum+=abs(a[i-1]-a[i]);
  }
  for(int i=1;i<=n;i++){
    cout<<sum-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
  }
  return 0;
}


Measured memory_bytes: 1664
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

double a, b;

int main() {
	cin >> a >> b;
	cout << fixed << setprecision(10) << (a*b) / (a + b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  cout << n / 3 << endl;
  return 0;
}

Measured memory_bytes: 256
def cls(m):
    if m == 'S':
        S.append(num)
    elif m == 'H':
        H.append(num)
    elif m == 'C':
        C.append(num)
    else:
        D.append(num)


def extract(m):
    for i in range(1, 14):
        if i not in eval(m):
            print(m, i)


n = int(input())
S, H, C, D = [], [], [], []
for i in range(n):
    m, num = input().split()
    num = int(num)
    cls(m)

S, H, C, D = sorted(S), sorted(H), sorted(C), sorted(D)
for m in 'SHCD':
    extract(m)


Measured memory_bytes: 5612
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }
    
    int main()
    {
        ll t=1;
        //cin>>t;
        while(t--)
        {
            ll n,d;
            cin>>n>>d;
            ll ans = 0;
            while(n--)
            {
                ll a,b;
                cin>>a>>b;
                if(a*a + b*b <= d *d)ans++;
            }
            cout<<ans<<endl;
        }
    }

Measured memory_bytes: 3592
from subprocess import*
call(("pypy3","-c","""
def main():
  from bisect import bisect
  n,k,*a=map(int,open(0).read().split())
  a.sort()
  i=bisect(a,0)
  a,b=a[i:],a[i-1::-1]
  n,m=len(a),len(b)
  ok=10**18
  ng=-ok
  while ok-ng>1:
    x=(ok+ng)//2
    s=0
    if x>=0:
      i=n
      for y in a:
        while i and a[i-1]*y>x:i-=1   
        s+=i
        if y*y<=x:s-=1
      i=m
      for y in b:
        while i and b[i-1]*y>x:i-=1
        s+=i
        if y*y<=x:s-=1
      s=s//2+n*m
    else:
      i=m
      for y in a:
        while i and b[i-1]*y<=x:i-=1
        s+=m-i
    if s>=k:ok=x
    else:ng=x
  print(ok)
main()
"""))

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

using namespace std;
using  ll = long long;
#define rep(i,n) for (int i = 1; i <= (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main(){
  int k;
  std::cin >> k;
  ll ans=0;
  rep(c,k)
  rep(b,k)
  rep(a,k){
    ans+=gcd(gcd(c,b),a);
  }
  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int N, M;
vector<pii> v;
vector<int> info[112345];

int main() {
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		info[b].push_back(a);
	}
	sort(ALL(v));
	
	int ans = 0, last = -1; // (i-1)-(i)をつなぐ橋を破壊した場合はi
	REP(i, N) {
		bool whet = false;
		REP(j, info[i].size()) {
			if (info[i][j] < last) continue;
			whet = true;
		}
		
		if (whet) {
			ans++;
			last = i;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        set<ll> d;
        rep(i, 0, N) {
                ll inp;
                cin >> inp;
                d.insert(inp);
        }
        cout << len(d) << endl;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int N = s.size();

    int record = 0;

    for (int i = 0; i < N; ++i)
    {
        for (int j = 1; j <= N; ++j)
        {
            string search = s.substr(i, j);
            for (int k = 0; k < search.size(); ++k)
            {
                if (search[k] == 'A' || search[k] == 'T' || search[k] == 'G' || search[k] == 'C')
                {
                    if (record <= k + 1)
                        record = k + 1;
                }
                else
                {
                    break;
                }
            }
        };
    }
    cout << record << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#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>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    ll A,B;
    cin >> A >> B;
    ll N =  __gcd(A,B);
    ll ans=1;//1の分
    for(ll i=2;i*i<=N;i++){
        if(N%i==0){
            while(N%i==0)N/=i;
            ans++;
        }
    }
    if(N>1)ans++;//残った素数を追加
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
int main()
{
	int v1, v2, v3;
	std::cin >> v1 >> v2 >> v3;
	int a[3]={v1, v2, v3};
	for (int i=0; i<2; i++)
	for (int j=0; j<2-i; j++)
	if ( a[j]>a[j+1] )
	{
    int t = a[j];
    a[j] = a[j+1];
    a[j+1] = t;
	}
	std::cout << a[0] << " " <<  a[1] << " " << a[2] << std::endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n, ans = 0;
    cin >> n;
    vector<vector<pair<int,int>>> v;
    v.resize(n + 5);
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        for(int j = 0; j < a; j++)
        {
            int x, y;
            cin >> x >> y;
            v[i].push_back({x, y});
        }
    }
    for(int i = 0; i < (1 << n); i++)///to loop on all possibilities
    {
        vector<int> temp(n + 5, 0);
        int honest = 0;
        bool ok = true;
        for(int j = 0; j < n; j++)
        {
            if(i & (1 << j))///to check if the current person is honest in this possibility
            {
                honest++;
                temp[j + 1] = 1;
            }
        }
        for(int j = 1; j <= n; j++)
        {
            for(int k = 0; k < v[j].size(); k++)
            {
                ///if j is contest then check if the testimonies he said are true
                if(temp[j] && temp[v[j][k].first] != v[j][k].second)
                {
                    ok = false;
                    break;
                }
            }
        }
        if(ok)
            ans = max(ans, honest);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=1e6+5;

ll i,n,m,a[N],d[N],f[N],x;

int main() {
    scanf("%lld %lld",&n,a);
	for(int i=1;i<=n;i++) {
        scanf("%lld",d+i);
        a[i]=min(a[i-1],abs(a[i-1]-d[i]));
    }
    f[n+1]=1;
	for(int i=n;i;i--) {
        f[i]=f[i+1];
        if (d[i]<f[i]*2) f[i]+=d[i];
    }
    scanf("%lld",&m);
	for(int i=1;i<=m;i++) {
        scanf("%lld",&x);
        if (a[x-1]>=f[x+1]) printf("YES\n");
        else printf("NO\n");
    }
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,k,mp[12][1002],pos[12],cnt,ans,cut[1002];
char s[12][1002];
inline int calc(){
	re int lst=1,aa=0;
	for(re int i=1;i<=m;++i){
		for(re int j=1;j<=cnt;++j){
		re int x=pos[j-1]+1,y=pos[j];
	//	printf("%d %d\n",x,y);
		if(mp[y][i]-mp[y][i-1]-mp[x-1][i]+mp[x-1][i-1]>k)return 1e7;
		if(mp[y][i]-mp[y][lst-1]-mp[x-1][i]+mp[x-1][lst-1]>k)cut[i]=1;	
		}
		if(cut[i]){
			++aa;
			lst=i;
		}
	}
	return aa;
}
inline void work(re int x,re int y){
	if(x==n){
		memset(cut,0,sizeof(cut));
	//	printf("%d\n",y);
		pos[++cnt]=n;y+=calc();--cnt;
	//	printf("%d\n\n",y);
		ans=min(ans,y);
		return;
	}
	work(x+1,y);
	pos[++cnt]=x;
	work(x+1,y+1);
	--cnt;
}
signed main(){
	n=read(),m=read(),k=read();ans=1e9;
	for(re int i=1;i<=n;++i)scanf("%s",s[i]+1);
	for(re int i=1;i<=n;++i){
		for(re int j=1;j<=m;++j){
			mp[i][j]=s[i][j]-'0';
			mp[i][j]+=mp[i-1][j]+mp[i][j-1]-mp[i-1][j-1];
		}
	}
	pos[0]=0;pos[1]=n;
	work(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;
const ll use =1e9;

int main()
{ 

    fast;

    ll n,k,s;
    cin>>n>>k>>s;

    
      ll i=0;
      for( i=0;i<k;i++)
        cout<<s<<" ";
      if(s!=use)
      {
        for(i;i<n;i++)
          cout<<s+1<<" ";
      }
      else
      {
        for(i;i<n;i++)
          cout<<1<<" ";
      }

}

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

int n,ans=0;

signed main(){
    cin>>n;
    
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    
    for(int i=2;i*i<=n;i++){
		if(n%i==0){
			int pos=0;
			while(n%i==0)  
                n=n/i,pos++;
			
			int now=sqrt(pos*2);
			
			if(now*(now+1)>pos*2)  
                now--;
			
			ans+=now;
		}
	}
    
    if(n>1)
        ans++;
        
    cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(){
    //入力
    int n,ans = 0;
    cin>>n;
    vector<int>a(n);
    vector<vector<int>>x(n,vector<int>(n)),y(n,vector<int>(n));
    for(int i = 0;i < n;i++){
        cin>>a[i];
        for(int j = 0;j < a[i];j++){
            cin>>x[i][j]>>y[i][j];
            //人が1~になっているため、0~にする。
            x[i][j]--;
        }
    }
    //N人の「正直者」or「不親切な人」の全通りを列挙
    for(int i = 0;i < (1LL << n);i++){
        bool flag = true;//全ての正直者の証言の整合性が取れているか
        for(int j = 0;j < n;j++){//村人を確認
            if(!(i & (1LL << j))){//bitが立っていない=不親切なとき
                continue;
            }   
            for(int k = 0;k < a[j];k++){
                if((i & (1LL << x[j][k])) && y[j][k] == 0 || !(i & (1LL << x[j][k])) && y[j][k] == 1){
                    //正直者の証言の整合性が取れていないとき
                    flag = false;
                }
            }
        }
        //整合性が取れている時
        if(flag){
            int cmp = 0;
            for(int j = 0;j < n;j++){
                if(i & (1LL << j)){
                    //正直者の数を加算
                    cmp++;
                }
            }
            ans = max(ans,cmp);
        }
    }
    //出力
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
a = str(input())
b = str(input())
c = str(input())

count = 0

def match_func(x, y, z):
  if x == y and y == z:
    return 0
  elif x == y:
    return 1
  elif y == z:
    return 1
  elif x == z:
    return 1
  else:
    return 2

for i in range(n):
  count += match_func(a[i], b[i], c[i])

print(count)

Measured memory_bytes: 3064
require 'matrix'

loop do
    n = gets.to_i
    break if n == 0
    s, t, b = gets.chomp.split.map{|c| c.ord - ?A.ord}

    d = [2, 1, 2,
         1, 0, 1,
         2, 1, 2]
    d[b-3] += 1 if b > 2
    d[b-1] += 1 if b % 3 > 0
    d[b+1] += 1 if b % 3 < 2
    d[b+3] += 1 if b < 6

    m = Matrix.build(9, 9) do |i, j|
        if j == i
            d[i] / 4.0
        elsif j == b
            0
        elsif i / 3 == j / 3 && (i - j).abs == 1
            0.25
        elsif i % 3 == j % 3 && (i - j).abs == 3
            0.25
        else
            0
        end
    end

    p (m ** n)[s, t]
end

Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
 
using namespace std;
typedef long long Int;
#define INF (1LL<<60)

Int dp[20][20];
Int table[54000];
Int H, W;
Int c[20][20];
Int A[500][500];
Int p[20][54000];
Int f[20][54000];
Int change[20]; //from i to 1


int solve(){
	for(int k=0;k<10;k++)
	for(int i=0;i<10;i++)
	for(int j=0;j<10;j++)
    dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
}

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

	cin >> H>> W;
	for(int i=0;i<10;i++)
	for(int j=0;j<10;j++)
		cin >> dp[i][j];

	for(int i=0;i<H;i++)
	for(int j=0;j<W;j++)
		cin >> A[i][j];
	
	//初期化
	solve();

	Int cost =0;
	for(int i=0;i<H;i++)
	for(int j=0;j<W;j++)
		if(0<=A[i][j] && A[i][j]<=9) cost +=dp[A[i][j]][1];

	cout << cost << endl;

	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
 
int main(){
    int N;
    int a[2][110];
    int Ans=0;
    int sum=0;
    cin >> N;
    REP(i,2){
        REP(j,N){
            cin >> a[i][j];
        }
    }
    REP(i,N){
        sum=0;
        REP(j,i+1){
            sum+=a[0][j];
        }
        for(int j=i;j<N;j++){
            sum+=a[1][j];
        }
        Ans=max(Ans,sum);
    }

    
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define N 4000005
using namespace std;
const int mod=1e9+7;
int n,k,f[2005][2005],jc[N],invjc[N];
int power(int x,int y)
{
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
	{
		if (y&1) ans=1LL*ans*x%mod;
	}
	return ans;
}
void init()
{
	jc[0]=1;
	for (int i=1;i<N;i++) jc[i]=1LL*jc[i-1]*i%mod;
	invjc[N-1]=power(jc[N-1],mod-2);
	for (int i=N-2;i>=0;i--) invjc[i]=1LL*invjc[i+1]*(i+1)%mod;
}
int C(int n,int m)
{
//	cout<<"!!!"<<n<<"!!!"<<m<<" "<<jc[n]<<" "<<invjc[m]<<" "<<invjc[n-m]<<endl;
	return 1LL*jc[n]*invjc[m]%mod*invjc[n-m]%mod;
}
signed main()
{
	init();
	scanf("%lld%lld",&n,&k);
	if (k==1)
	{
		printf("1\n");
		return 0;
	}
	f[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=i;j++)
		{
			f[i][j]=f[i-1][j];
			if (!j) continue;
			(f[i][j]+=1LL*f[i][j-1]*(n-j+1)%mod*C(n*k-i-1-(j-1)*(k-1),k-2)%mod)%=mod;
		}
	}
	printf("%lld\n",f[n][n]);
	return 0;
}

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

int main(){
	vector<ll> a(3);
	rep(i,3) cin >> a[i];
	sort(a.begin(),a.end());
	if(a[2]%2 == 0) cout << 0 << endl;
	else cout << a[0]*a[1] << endl;
}

Measured memory_bytes: 3580