akhauriyash/Code-Regression huggingface dataset:
using System;

class Program {
    static int[] f;

    static void Main() {
        var n = int.Parse(Console.ReadLine());
        f = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        int ans = 0;
        while (0 < CalcTotal()) {
            var l = 0;
            for (int i = 0; i < f.Length; i++) {
                if (0 < f[i]) {
                    l = i;
                    break;
                }
            }

            var r = l;
            for (int i = l + 1; i < f.Length; i++) {
                r = i;
                if (0 == f[i]) {
                    r = i - 1;
                    break;
                }
            }

            for (int i = l; i <= r; i++) {
                f[i]--;
            }

            ans++;
        }

        Console.WriteLine(ans);
    }

    static int CalcTotal() {
        int res = 0;
        for (int i = 0; i < f.Length; i++) {
            res += f[i];
        }

        return res;
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


int main(){
    long double a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c){
        puts("No");
        return 0;
    }
    long double move = (c-a-b)/2;
    if(a*b<(move*move))puts("Yes");
    else puts("No");
    return 0;
}
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s.at(i) == ',') s.at(i) = ' ';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	string s;
	int K;
	cin >> s >> K;
	set<string>se;
	for (char c = 'a'; c <= 'z'; c++) {
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == c) {
				string tmp;
				tmp = c;
				se.insert(tmp);
				for (int j = i + 1; j < s.size(); j++) {
					if (j - i >= K)break;
					tmp += s[j];
					se.insert(tmp);
				}
			}
		}
		if (se.size() >= K)break;
	}
	int cnt = 0;
	for (auto i : se) {
		cnt++;
		if (cnt == K) {
			cout << i << endl;
			return 0;
		}
	}
}

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

double ans = 0.00;
double d[21][21] = {};
vector< long long int > v;

void kansu( long long int n, long long int m ) {

  if ( v.size() == m + 1 ) {

    double cnt = 0.00;

    for ( long long int i = 1; i < v.size(); i++ ) {

      for ( long long int j = i + 1; j < v.size(); j++ ) {

	cnt += d[v[i]][v[j]];

      }

    }

    ans = max( ans, cnt );

    return;
  }

  for ( long long int i = v[ v.size() - 1 ] + 1; i < n; i++ ) {
    v.push_back( i );
    kansu( n, m );
    v.pop_back();
  }

  return;

}

int main() {

  long long int n, m;
  cin >> n >> m;

  vector< double > l, a, b;

  for ( long long int i = 0; i < n; i++ ) {

    double in_l, in_a, in_b;
    cin >> in_l >> in_a >> in_b;
    l.push_back( in_l );
    a.push_back( in_a );
    b.push_back( in_b );

  }

  if ( m <= 1 ) {
    cout << 0 << endl;
    return 0;
  }

  for ( long long int i = 0; i < n; i++ ) {
    for ( long long int j = 0; j < i; j++ ) {
      double dl = l[i] - l[j];
      double da = a[i] - a[j];
      double db = b[i] - b[j];
      d[i][j] = dl*dl + da*da + db*db;
      d[j][i] = d[i][j];
    }
  }

  v.push_back( -1 );

  kansu( n, m );

  cout << setprecision(20) << ans << endl;

  return 0;

}

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

typedef long long ll;

const int N = 1e5 + 5;
int n, u, v;
int a, b, A, B, C;
vector<int> e[N];
vector<int> path;
int d[N];
int res;

bool dfs(int par, int from, vector<int> &p) {
    for (int to : e[from]) {
        if (par == to) continue;
        p.push_back(to);
        if (to == v) {
            path = p;
            return true;
        }
        if (dfs(from, to, p)) return true;
        p.pop_back();
    }
    return false;
}

void dfs2(int par, int from) {
    res = max(res, d[from]);

    for (int to : e[from]) {
        if (par == to || to == C || to == B) continue;
        d[to] = d[from] + 1;
        dfs2(from, to);
    }
}

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

    cin >> n >> u >> v;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    vector<int> p = {u};
    dfs(-1, u, p);
    int m = path.size() / 2;
    int add = m - 1;
    if (path.size() & 1) {
        A = path[m - 1];
        B = path[m + 1];
        C = path[m];
        add++;
    } else {
        A = path[m - 1];
        B = path[m];
    }
    d[A] = 0;
    dfs2(-1, A);
    cout << res + add << endl;

    return 0;
}



Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first;
#define se second;
#define print(x,y) (cout << (x) << (y))
#define inf INT_MAX
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
const int MOD = 1e9 + 7; //998244353;


int main(){
    boost;
    int n;
    cin >> n;
    vi a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    vi b(n);
    int mx = inf;
    for(int i = 0;i<n;i++){
        b[i] = min(mx , a[i]);
        mx = min(mx , a[i]);
    }
    int count = 1;
    for(int i = 1;i<n;i++){
        if(a[i] <= b[i-1])count++;
    }
    cout << count;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

LL N, K, X, Y;

int main() {
    cin >> N >> K >> X >> Y;
    cout << X * min(K, N) + Y * max(0LL, N - K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
inline li read(){
	li x = 0,y = 0,c = gc;
	while(!isdigit(c)) y = c,c = gc;
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'),c = gc;
	return y == '-' ? -x : x;
}
inline void print(li q){
	if(q < 0){
		pc('-');
		q = -q;
	}
	if(q >= 10) print(q / 10);
	pc(q % 10 + '0');
}
li s1 = 19260817,s2 = 23333333,s3 = 998244853,srd;
inline li rd(){
	return srd = (srd * s1 + s2 + rand()) % s3;
}
inline void file(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
//const int mo = 998244353;
//const int mo = 1000000007;
int n,a,b,wei[200010],mx;
struct node{
	int a[20];
}p;
void wk(int q,node w,int x){
	//cerr<<q<<"*"<<x<<" ";
	//for(int i = 1;i <= n;++i) cerr<<w.a[i]<<" ";cerr<<endl;
	if(q == 1){
		a ^= (1 << w.a[1]);
		print(a);pc(' ');return;
	}
	wk(q - 1,w,1);
	a ^= (1 << w.a[q]);
	print(a);pc(' ');
	if(x == 1) wk(q - 1,w,1);
	else{
		swap(w.a[q - 1],w.a[q - x + 1]);wk(q - 1,w,x - 2);swap(w.a[q - 1],w.a[q - x + 1]);
	}
}
int main(){
	srand(time(0));rd();
	//file();
	int i,j;
	n = read();a = read();b = read();
	if(n == 1){
		printf("YES\n%d %d",a,b);return 0;
	}
	mx = 1 << n;
	for(i = 1;i < mx;++i) wei[i] = wei[i >> 1] + (i & 1);
	if(wei[a ^ b] % 2 == 0){
		puts("NO");return 0;
	}
	puts("YES");
	int cnt = 0;
	for(i = 0;i < n;++i) if(!((a ^ b) & (1 << i))) p.a[++cnt] = i;
	for(i = 0;i < n;++i) if((a ^ b) & (1 << i)) p.a[++cnt] = i;
	//for(i = 1;i <= n;++i) cerr<<p.a[i]<<" ";cerr<<endl;
	print(a);pc(' ');wk(n,p,wei[a ^ b]);
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	string n;
	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n.size(); i++) {
		mp[n[i] - '0']++;
	}
	int ans = 0;
	if (n.size() == 1) {
		cout << n << endl;
		return 0;
	}
	ans = (n.size() - 1) * 9;
	if (mp.size() == 2 && n[0] != '9' && mp[9] == n.size() - 1) {
		cout << (n[0] - '0') + ans << endl;
		return 0;
	}
	if (mp[9] == n.size()) {
		cout << ans + 9 << endl;
		return 0;
	}
	ans += n[0] - '0' - 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	string s;
	cin>>s;
	int n;
	n=s.length();
	int dp[2][2019];
	int ans=-n;
	memset(dp,0,sizeof(dp));
	//for(int i=0;i<2;i++)dp[i][0]=1;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<2019;j++)dp[i&1][j]=0;
		dp[i&1][0]=1;
		for(int j=0;j<2019;j++){
			int num=(j*10+(s[i-1]-'0'))%2019;
			dp[i&1][num]+=dp[(i-1)&1][j];
		}
		ans+=dp[i&1][0];
	}
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

#ifndef __SOULTCH
#define endl '\n'
#define debug(x) 
#else
#define debug(x) cout << " [+] " << #x << " = " << x << endl
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << pai.first << ' ' << pai.second;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> s) {
    for (T p : s) cout << p << ' ';
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> s) {
    for (auto p : s) cout << '(' << p << ") ";
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N;
char str[100001];
int cnt[26];

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> str;
    rep(i, strlen(str)) {
        cnt[str[i]-'a']++;
    }

    ll res = 1;
    rep(i, 26) {
        res = res*(cnt[i]+1)%MOD;
    }

    cout << res-1;
}   







Measured memory_bytes: 384
/**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(){
    char ch;
    cin>>ch;
    if(ch>='A' && ch<='Z') cout<<"A"<<endl;
    else cout<<"a"<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3644
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <llong> vl;
typedef vector <string> vs;
typedef vector <vector <llong>> matrix;

typedef pair <llong, llong> pll;

typedef map <llong, llong> mll;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

llong n, tt, xx, yy;

int main () {
    android;
    random_device rand;
    #ifdef I_LOVE_DILYA
        freopen ("input.txt", "r", stdin);
    #endif
    cin >> n;
    for (llong i = 1; i <= n; ++ i) {
        llong x, y, t;
        cin >> t >> x >> y;
        llong dist = abs (x - xx) + abs (y - yy);
        if ((t - tt - dist) % 2 != 0 || (t - tt) < dist) return cout << "No", 0;
    } cout << "Yes";
    return 0;
}

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

int main() {
  int N;
  double U, Sum=0;
  cin >> N;
  rep(i, N){
    string S;
    cin >> U >> S;
    if(S=="JPY") Sum=Sum+U;
    else Sum=Sum+U*380000;
  }
  cout << Sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;



int main() {
	int n,k, a[200000],b[200000],ans=0,num=0,cont=1;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] != a[i + 1]) {
			b[num] = cont;
			num++;
			cont = 1;
			if (i == n - 2) {
				b[num] = 1;
			}
		}
		else {
			cont++;
			if (i == n - 2) {
				b[num] = cont;
			}
		}
	}
	num++;
	sort(b, b + num);
	for (int i = 0; i < num - k; i++) {
		ans += b[i];
	}
	cout << ans << endl;


}

Measured memory_bytes: 1792
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,t,temp,x,y;
string str;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	ll dp[n+100];
	for(int i=0;i<=n;i++)
	dp[i]=llmax;
	vll v(n);
	read(v);
	dp[1]=0;
	dp[2]=abs(v[1]-v[0]);
	for(int i=3;i<=n;i++)
	{
	  dp[i]=min(dp[i-2]+abs(v[i-1]-v[i-3]),dp[i-1]+abs(v[i-1]-v[i-2]));  
	}
	cout<<dp[n];
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  int flag = 0;
  while (cin >> s) {
    if (flag++) cout << endl;
    while (int(s.size()) < 5) s = "0" + s;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 5; j++) {
        cout << " *"[i ^ ((s[j] - '0') / 5 == 0)];
      }
      cout << endl;
    }
    for (int i = 0; i < 5; i++) {
      cout << "=";
    }
    cout << endl;
    for (int i = 0; i < 5; i++) {
      for (int j = 0; j < 5; j++) {
        cout << " *"[(s[j] - '0') % 5 != i];
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3028
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(n*2<=m){
        ans+=n;
        m-=ans*2;
        ans+=m/4;
    }
    else{
        ans+=m/2;
    }
    cout<<ans<<endl;


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,i,j,x,y,z,A,A2;
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d%d%d",&x,&y,&z);
        if(x<=y&&y<=z){
            A=z*z;
            A2=x*x+y*y;
            if(A==A2){
                printf("YES\n");
            }else printf("NO\n");
        }else if(x<=z&&z<=y){
            A=y*y;
            A2=x*x+z*z;
            if(A==A2){
                printf("YES\n");
            }else printf("NO\n");
        }else if(y<=x&&x<=z){
            A=z*z;
            A2=x*x+y*y;
            if(A==A2){
                printf("YES\n");
            }else printf("NO\n");
        }else if(y<=z&&z<=x){
            A=x*x;
            A2=z*z+y*y;
            if(A==A2){
                printf("YES\n");
            }else printf("NO\n");
        }else if(z<=y&&y<=x){
            A=x*x;
            A2=z*z+y*y;
            if(A==A2){
                printf("YES\n");
            }else printf("NO\n");
        }else if(z<=x&&x<=y){
            A=y*y;
            A2=x*x+z*z;
            if(A==A2){
                printf("YES\n");
            }else printf("NO\n");
        }
    }
return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n;
char s[10010];

int main() {
  cin >> n;
  scanf("%s", s);
  int len = strlen(s);
  
  int a, b;
  rep(i, len) {
    a = s[i] - 'A';
    b = (a+n) % 26;
    printf("%c", 'A' + b);
  }
}

Measured memory_bytes: 256
from copy import deepcopy
n,m=map(int,input().split())
lst=[]
for i in range(n):
    x,y,z=map(int,input().split())
    lst.append([x,y,z])
ans=0
for i in range(8):
    switch=[0,0,0]
    for j in range(3):
        if (i>>j)&1:
            switch[j]=1
    tmp=deepcopy(lst)
    for j in range(n):
        p=0
        for k in range(3):
            if switch[k]==1:
                p+=tmp[j][k]
            else:
                p-=tmp[j][k]
        tmp[j].append(p)
    tmp=sorted(tmp,key=lambda x:x[3],reverse=True)
    x=0
    y=0
    z=0
    for j in range(m):
        x+=tmp[j][0]
        y+=tmp[j][1]
        z+=tmp[j][2]
    ans=max(ans,abs(x)+abs(y)+abs(z))
print(ans)

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

int main(){
	int d,n ;
	cin >> d >> n ;
	if(d==0){
		if(n==100) cout << 101 ;
		else cout << n ;
	}
	if(d==1){
		if(n==100) cout << 10100 ;
		else cout << n*100 ;
	}
	if(d==2){
		if(n==100) cout << 1010000 ;
		else cout << n*10000 ;
	}
	cout << endl ;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
A = [0] * N
A[0], A[N - 1] = B[0], B[N - 2]
for i in range(1, N - 1):
    A[i] = min(B[i - 1], B[i])
print(sum(A))

Measured memory_bytes: 3060
#include <stdio.h>

int
main(void)
{
	int a;
	int b;
	int i;
	int idx = 0;
	int ans[100];
	char op;

	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '+')
			ans[idx] = a + b;
		else if (op == '-')
			ans[idx] = a - b;
		else if (op == '*')
			ans[idx] = a * b;
		else if (op == '/')
			ans[idx] = a / b;
		else	break;

		idx++;
	}

	for (i = 0; i < idx; i++) {
		printf("%d\n", ans[i]);
	}

	return 0;
}


Measured memory_bytes: 2104
import math

N=int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

while True:
    if is_prime(N)==True:
        print(N)
        break
    N+=1

Measured memory_bytes: 3060
# F - Silver Fox vs Monster

from math import ceil

n, d, a = map(int, input().split())
xh = [tuple(map(int, input().split())) for _ in range(n)]

# X座標の昇順に整列
xh.sort(key=lambda x: x[0])

bomb = 0
head = 0
accum = 0  # 破壊済みの体力
for i in range(n):
    while xh[head][0] < xh[i][0] - d - d:
        accum -= ceil(xh[head][1] / a) * a
        head += 1
    xh[i] = (xh[i][0], max(0, xh[i][1] - accum))
    b = ceil(xh[i][1] / a)
    bomb += b
    accum += b * a

print(bomb)


Measured memory_bytes: 100824
#include<iostream>
#include<algorithm>

using namespace std;

/*
三角形：最大の辺 < その他の辺の和
鋭角三角形：最大の辺の二乗 < 最小の辺の二乗＋中間の辺の二乗
直角三角形：最大の辺の二乗 = 最小の辺の二乗＋中間の辺の二乗
鈍角三角形：最大の辺の二乗 > 最小の辺の二乗＋中間の辺の二乗
*/

int main() {
	int a[3];
	int Triangle = 0;
	int eikaku = 0;
	int chokkaku = 0;
	int donkaku = 0;

	while (true) {
		cin >> a[0] >> a[1] >> a[2];
		sort(begin(a), end(a));
		// 三角判定
		if (a[2] < a[1] + a[0]) {
			Triangle++;
			const int a0_sq = a[0] * a[0];
			const int a1_sq = a[1] * a[1];
			const int a2_sq = a[2] * a[2];
			//鋭角判定
			if (a2_sq < a1_sq + a0_sq) {
				eikaku++;
			}
			//直角判定
			else if(a2_sq == a1_sq + a0_sq) {
				chokkaku++;
			}
			else {
				donkaku++;
			}
		}
		else {
			break;
		}
	}

	cout << Triangle << ' ' << chokkaku << ' ' << eikaku << ' ' << donkaku << endl;

	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

  int a,b;
	cin >> a >> b;

	if (a == b) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> P( N );
	for( auto& v: P ) { cin >> v; }

	vector<int> q( N );
	q[0] = P[0];

	for( int i = 1; i < N; ++i ) {
		q[i] = min( q[i-1], P[i] );
	}

	int ans = 0;
	for( int i = 0; i < N; ++i ) {
		if( P[i] <= q[i] ) { ans += 1; }
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
x, n = map(int, input().split())
P = list(map(int, input().split()))
diff, ans = 1000, -1
for i in range(0, 102):
    if (P.count(i)):
        continue
    if (abs(i - x) < diff):
        diff = abs(i - x)
        ans = i
print(ans)


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


int main(){
 string a;
 int flag=0;
 cin>>a;
 for(int i=0; i<3; i++){
 	if(a[i]==a[i+1]){
 	  flag=1;
 	}
 }
 if(flag==0){
 	cout<<"Good"<<endl;
 }else{
 	cout<<"Bad"<<endl;
 }
}

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 5005;

int n, k;
int P[N];
int C[N];
vector<ll> cycle;

void getCycle(int node)
{
	vector<bool> vis (n+7);

	while (vis[node] == false)
	{
		vis[node] = true;
		cycle.pb(C[node]);
		node = P[node];
	}
}

ll solve(int node)
{
	cycle.clear();
	getCycle(node);

	for (int i = 1; i < cycle.size(); ++i)
		cycle[i] += cycle[i-1];

	ll sum = cycle[cycle.size() - 1];

	if (k <= cycle.size())
	{
		ll res = -1e9;
		for (int i = 0; i < k; ++i)
			res = max(res, cycle[i]);
		return res;
	}

	if (sum <= 0)
	{
		ll res = -1e9;
		for (int i = 0; i < cycle.size(); ++i)
			res = max(res, cycle[i]);
		return res;
	}

	ll ctr;

	//using full advantage of cycle
	ll res1 = sum * (k / cycle.size());

	ctr = 0;
	for (int i = 0; i < k % cycle.size(); ++i)
		ctr = max(ctr, cycle[i]);
	res1 += ctr;

	//using full cycle - 1
	ll res2 = sum * (k / cycle.size()) - sum;

	ctr = 0;
	for (int i = 0; i < cycle.size(); ++i)
		ctr = max(ctr, cycle[i]);
	res2 += ctr;

	return max(res1, res2);
}

int main()
{
	fastio;

	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> P[i];
		P[i] -= 1;
	}
	for (int i = 0; i < n; ++i)
		cin >> C[i];

	ll res = *max_element(C, C+n);
	for (int i = 0; i < n; ++i)
		res = max(res, solve(i));

	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<map>
using namespace std;
int a[233333];
map<int,int> mp;
int main(){
	int ans=0;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(mp[a[i]]<a[i]){
			mp[a[i]]++;
		}
		else{
			ans++;
			i--;
			n--;
		}
	}
	for(int i=0;i<n;i++){
		if(mp[a[i]]<a[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    string s;
    cin>>s;

    int n = s.size();
    int suff[n];
    suff[n-1] = s[n-1]-'0';
    int d = 10;
    int rem[2019];
    mem(rem,0);
    for(int i = n-2;i>=0;i--){
        suff[i] = ((int)(s[i]-'0')*d + suff[i+1])%2019;
        d *= 10;
        d %= 2019;
    }
    for(int i = 0;i<n;i++){
        rem[suff[i]]++;
    }
    rem[0]++;
    int ans = 0;
    for(int i = 0;i<2019;i++){
        ans += (rem[i]*(rem[i]-1))/2;
    }
    cout<<ans;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

using namespace std;
#define sync   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define ll long long
const int mod = int(1e9+7);
const int MN = int(2e6+7);
#define rep(i,a,b) for(int i=a;i<=n;i++)

int main(){

	string X,Y;
	cin>>X>>Y;
    ll n=X.size(),m=Y.size();
	
	vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=m;j++){
			if(i==0 || j==0)dp[i][j]=0;
			else if(X[i-1]==Y[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}



	string ans="";
	ll i=n,j=m;
	while(i!=0 &&j!=0){
		if(dp[i][j]==dp[i-1][j]){
			i--;
		}else if(dp[i][j]==dp[i][j-1]){
			j--;
		}else if(dp[i][j]==dp[i-1][j-1]+1){
			ans.push_back(X[i-1]);
			i--;j--;
		}
	}
	reverse(ans.begin(),ans.end());
cout<<ans;
}

Measured memory_bytes: 73728
import itertools

N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

result = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    score = 0
    for i in range(Q):
        if A[b[i]] - A[a[i]] == c[i]:
            score += d[i]
    result = max(result, score)
print(result)

Measured memory_bytes: 9220
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
#define ll long long
#define maxn 10010
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
string s[maxn];
int main(){
	int n,ans=0,t01=0,t11=0,t10=0;cin>>n;
	for(int i=1;i<=n;++i){
		cin>>s[i];
		for(int j=0;j<(int)s[i].size()-1;++j)if(s[i][j]=='A'&&s[i][j+1]=='B')++ans;
		if(s[i][0]=='B'){
			if(s[i].back()=='A')++t11;
			else ++t10;
		}
		else if(s[i].back()=='A')++t01;
	}
	int tmp=min(t01,t10),tmp2=min(tmp+t11,max(t01,t10)),x=tmp2-tmp;
	t11-=x;
	int p=1;
	if(tmp2)p=0;
	cout<<ans+max(0,t11-p)+tmp2<<endl;
	return 0;
}

Measured memory_bytes: 768
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_f) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
puts_yesno n.to_s==n.to_s.reverse

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

int main() {
  int h, w;
  cin >> h >> w;
  string a[h];
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  bool right[h][w], left[h][w];
  for (int i = 0; i < h; i++) {
    fill(right[i], right[i] + w, false);
    fill(left[i], left[i] + w, false);
    for (int j = 1; j < w; j++) {
      if (a[i][j] == '#' && a[i][j - 1] == '#')
        right[i][j - 1] = left[i][j] = true;
    }
  }
  for (int j = 0; j < w; j++) {
    for (int i = 1; i < h; i++) {
      if (a[i][j] == '#' && a[i - 1][j] == '#') {
        if (right[i - 1][j] || left[i][j]) {
          cout << "Impossible" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Possible" << endl;
  return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 13;
const int maxM = 1e3 + 1;
const int maxpowN = 1 << maxN;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int n, m;
ll dp[maxpowN][maxM];

ll a[maxM];
ll b;
int msk[maxM];

void init()
{
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    memset(msk, 0, sizeof(msk));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    init();
    for1(i, m)
    {
        cin >> a[i] >> b;
        while (b--)
        {
            int c;
            cin >> c;
            msk[i] |= 1 << (c - 1);
        }
    }
    for1(i, m)
    {
        for0(mask, 1 << n)
        {
            dp[mask][i] = dp[mask][i - 1];
            int mmask = 0;
            for0(j, n)
            {
                mmask |= (((mask >> j) & 1) > ((msk[i] >> j) & 1)) << j;
            }
            dp[mask][i] = min(dp[mask][i], dp[mmask][i - 1] + a[i]);
        }
    }
    if (dp[(1 << n) - 1][m] == INF)
    {
        cout << -1;
    }
    else
    {
        cout << dp[(1 << n) - 1][m];
    }
    return 0;
}


Measured memory_bytes: 64384
#include<bits/stdc++.h>
using namespace std;
vector<int> dp;
int mod = 1000000007;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    dp = vector<int>(k + 1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++)
    {
        // used candies
        vector<int> fake(k + 1);
        for(int used = k; used >= 0; used--)
        {
            int L = used + 1, R = used + min(v[i], k - used);
            if(L <= R)
            {
                fake[L] = (fake[L] + dp[used]) % mod;
                if(R + 1 <= k)   
                    fake[R + 1] = (fake[R + 1] - dp[used] + mod) % mod;
            }
        }
        int prefix = 0;
        for(int j = 0; j <= k; j++)
        {
            prefix = (prefix + fake[j]) % mod;
            dp[j] = (dp[j] + prefix) % mod;
        }
    }
    cout << dp[k];
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
cnt = 0

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])
	if temp!=1:
		arr.append([temp, 1])
	if arr==[]:
		arr.append([n, 1])
	return arr

a = factorization(n)
c = 0
for i in a:
	k = 1
	x = i[1]
	while x-k >= 0:
		x -= k
		c += 1
		k += 1
if n == 1:
	print (0)
else:
	print (c)


Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
const int maxn=507,maxm=maxn*maxn,inf=1e9;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
int n,nn,px[maxm],py[maxm];
int d[maxn][maxn];
int a[maxn][maxn];
void go(deque<pair<int,int>>q)
{
    while(!q.empty())
    {
        int x=q.front().first,y=q.front().second;
        q.pop_front();
        for(int i=0;i<4;++i)
        {
            int nx=x+dx[i],ny=y+dy[i];
            if(nx>=0&&nx<n&&ny>=0&&ny<n&&d[x][y]+a[nx][ny]<d[nx][ny])
            {
                d[nx][ny]=d[x][y]+a[nx][ny];
                if (a[x][y])
                {
                    q.emplace_back(nx,ny);
                }
                else
                {
                    q.emplace_front(nx,ny);
                }
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    nn=n*n;
    for(int i=0;i<nn;++i)
    {
        int p;
        cin>>p;
        --p;
        px[i]=p/n;
        py[i]=p%n;
    }
    deque<pair<int,int>>q;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<n;++j)
        {
            a[i][j]=1;
            if(i==0||j==0||i==n-1||j==n-1)
            {
                d[i][j]=1;
                q.emplace_back(i,j);
            }
            else
            {
                d[i][j]=inf;
            }
        }
    }
    go(q);
    long long an=0;
    for(int i=0;i<nn;++i)
    {
        a[px[i]][py[i]]=0;
        --d[px[i]][py[i]];
        go({{px[i],py[i]}});
        an+=d[px[i]][py[i]];
    }
    cout<<an;
    return 0;
}


Measured memory_bytes: 8564
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
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; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    vector<string> m(0),a(0),r(0),c(0),h(0);

    rep(i,n){
        if(s[i].at(0) == 'M') m.push_back(s[i]);
        else if(s[i].at(0) == 'A') a.push_back(s[i]);
        else if(s[i].at(0) == 'R') r.push_back(s[i]);
        else if(s[i].at(0) == 'C') c.push_back(s[i]);
        else if(s[i].at(0) == 'H') h.push_back(s[i]);
    }

    ll empcnt = 0;

    if(m.empty()) empcnt++;
    if(a.empty()) empcnt++;
    if(r.empty()) empcnt++;
    if(c.empty()) empcnt++;
    if(h.empty()) empcnt++;

    ll mn = m.size();
    ll an = a.size();
    ll rn = r.size();
    ll cn = c.size();
    ll hn = h.size();

    ll ans = mn*an*rn + mn*an*cn + mn*an*hn + mn*rn*cn + mn*rn*hn + mn*cn*hn + an*rn*cn + an*rn*hn + rn*cn*hn + an*cn*hn;
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11636
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();

            string[] inS = Console.ReadLine().Split(' ');
            int[] w = new int[inS.Length];

            for (int i = 0; i < inS.Length; i++)
            {
                w[i] = int.Parse(inS[i]);
            }

            int ans = int.MaxValue;

            for(int T = 0; T < w.Length; T++)
            {
                int belowT = 0;
                int aboveT = 0;

                for (int i = 0; i < w.Length; i++)
                {
                    if (T < i)
                    {
                        aboveT += w[i];
                    }
                    else
                    {
                        belowT += w[i];
                    }
                }

                ans = Math.Min(ans, Math.Abs(belowT - aboveT));
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int mx,n,i,cnt[3];
char s[100005];
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++)cnt[s[i]-'a']++;
	mx=max(cnt[0],max(cnt[1],cnt[2]));
	if(min(cnt[0],min(cnt[1],cnt[2]))>=mx-1)printf("YES\n");
	else printf("NO\n");
	return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int m,k;
  cin>>m>>k;
  if(m==1){
    if(k==0){
      cout<<"0 0 1 1"<<endl;
    }else{
      cout<<-1<<endl;
    }
    return 0;
  }

  if(k>=(1<<m)){
    cout<<-1<<endl;
    return 0;
  }
  
  vector<Int> vs,ws;
  for(Int i=0;i<(1<<m);i++){
    if(i==k) continue;
    vs.emplace_back(i);
    ws.emplace_back(i);
  }
  vs.emplace_back(k);

  reverse(ws.begin(),ws.end());
  for(Int x:ws) vs.emplace_back(x);

  vs.emplace_back(k);

  for(Int i=0;i<(Int)vs.size();i++){
    if(i) cout<<" ";
    cout<<vs[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 5096
#include <stdio.h>

int main()
{
  int ret, limit, point, points[5], i, j;

  for (i = 0; i < 5; i++) {
    ret = scanf("%d", &point);
    if (ret == EOF) {
      return -1;
    }
    points[i] = point;
  }
  ret = scanf("%d", &limit);
  if (ret == EOF) {
    return -1;
  }

  for (i = 0; i < 4; i++) {
    for (j = 1; j < 5; j++){
      if ((points[j] - points[i]) > limit) {
        printf(":(\n");
        return 0;
      }
    }
  }
  printf("Yay!\n");

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll n,m,c;
  cin>>n>>m>>c;
  vector<ll>b(m,0);
  ll an=0;
  for(ll i=0;i<m;i++){
    cin>>b[i];
  }
  for(ll i=0;i<n;i++){
    ll k;
    ll ans=0;
    for(ll j=0;j<m;j++){
      cin>>k;
      ans+=k*b[j];
    }
    ans+=c;
    if(ans>0){
      an++;
    }
  }
  cout<<an<<endl;
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
c = list(input() for _ in range(h))
ans = 0
for i in range(1<<h): #bitシフト
    for j in range(1<<w): #bitシフト
        b = 0
        for y in range(h):
            for x in range(w):
                if i>>y&1 and j>>x&1 and c[y][x] == "#":
                    b+=1
        if b==k:
            ans+=1
print(ans)


Measured memory_bytes: 9148