akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

// 計算量O(v^3)
// 始点、経由店、終点でDPしている
// 負閉路なければいける。負の辺があっても良い
ll dist[10][10];
// 頂点数v, 辺数e
int v= 10;

// 経由店を固定して回す(kが頭にくることに注意)
void warshall_floyd()
{
    for (int k = 0; k < v; k++)
    {
        for (int i = 0; i < v; i++)
        {
            for (int j = 0; j < v; j++)
            {
                if (dist[i][k] != LINF && dist[k][j] != LINF)
                    chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}
// 負閉路あり->false, 負閉路なし->true
bool negative_judge()
{
    // ワーシャルフロイドは所詮DP
    // ループ回しきってdist[i][i]が負になってたら負閉路
    rep(i, v)
    {
        if (dist[i][i] < 0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int h,w;cin >> h >> w;

    for (int i = 0; i < v; i++)
    {
        for (int j = 0; j < v; j++)
        {
            if (i == j)
            {
                dist[i][j] = (ll)0;
                continue;
            }
            dist[i][j] = LINF;
        }
    }
    for (int i = 0; i < v; i++)
    {
        for (int j = 0; j < v; j++)
        {
            int c;cin >> c;
            dist[i][j] = c;
        }
    }
    warshall_floyd();
    vector<vector<int> > a(h, vector<int>(w));
    ll sum = 0;
    rep(i,h)
    {
        rep(j,w)
        {
            cin >> a[i][j];
            if(a[i][j] == -1)continue;
            sum += dist[a[i][j]][1];
        }
    }
    cout << sum << endl; 
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
struct Card{
    char suit,value;
};
void bubble(struct Card A[],int N){
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i+1;j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
            }
        }
    }
}

void selection(struct Card A[],int N){
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value)minj=j;
        }
        Card t=A[i];
        A[i]=A[minj];
        A[minj]=t;
    }
}
void print(struct Card A[],int N){
    for(int i=0;i<N;i++){
        if(i>0)cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}
bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i=0;i<N;i++){
        if(C1[i].suit!=C2[i].suit)return false;
    }
    return true;
}
int main(){
    Card C1[100],C2[100];
    int N;
    char ch;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>C1[i].suit>>C1[i].value;
    }
    for(int i=0;i<N;i++)C2[i]=C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    print(C1,N);
    cout<<"Stable"<<endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    return 0;
}


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

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main() {
        IOS;

        int k,s,cnt=0;
        cin>>k>>s;
        for(int i=0;i<=k;i++)
        {
            for(int j=0;j<=k;j++)
            {
                if(((s-i-j)>=0)&&((s-i-j)<=k))
                        cnt++;
            }
        }
        cout<<cnt<<endl;

return 0;
}



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

int main() {
	int n;
	cin >> n;

	int num[n], sum = 0;
	num[0] = INT_MAX;
	for (int i = 1; i < n; ++i) cin >> num[i];

	for (int i = 0; i < n-1; ++i) {
		sum += min(num[i], num[i + 1]);
	}

	sum += num[n - 1];

	cout << sum << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

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

int main() {
  int m;
  while(cin >> m, m) {
    int card[m], num[m];
    REP(i,m)
      cin >> card[i] >> num[i];
    int dp[m+1][1001];
    memset(dp,0,sizeof(dp));

    dp[0][0] = 1;
    for(int i=1; i<=m; ++i) {
      REP(j,1001)
        dp[i][j] = dp[i-1][j];
      for(int k=1; k<=num[i-1]; ++k) {
        for (int j=0; j + k*card[i-1] < 1001; ++j) {
          if (dp[i-1][j]>0) {
            dp[i][j + k*card[i-1]] += dp[i-1][j] ;
            //    printf("%d,%d,%d %d\n",i,j,j + k*card[i-1],dp[i][j + k*card[i-1]]);
          }
        }
      }
    }
    int g;
    cin >> g;
    while(g--) {
      int a;
      cin >> a;
      cout << dp[m][a] << endl;
    }
  }
}

Measured memory_bytes: 0
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    const A = tmp[0], B = tmp[1], K = tmp[2];

    int cnt;
    foreach_reverse (x; 1..min(A,B)+1) {
        if (A % x == 0 && B % x == 0) {
            if (++cnt == K) {
                writeln(x);
            }
        }
    }
}



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

using namespace std;

int solve(const string& S, const string& T)
{
	int ans = T.size();

	for (int i = 0; i + T.size() <= S.size(); ++i) {
		int cnt = 0;
		for (int k = 0; k < T.size(); ++k) {
			if (T[k] != S[i + k]) {
				++cnt;
			}
		}
		ans = min(ans, cnt);
	}

	return ans;
}

int main()
{
	string S, T;
	cin >> S >> T;
	cout << solve(S, T) << endl;
}


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

using namespace std;
int n,k;
int h[100000];
long long F[100000];

int minn(int i)
{
    long long res=INT_MAX;
    int p=min(i,k);
    for (int j=1; j<=p; j++)
    {
        res=min(res, F[i-j]+abs(h[i]-h[i-j]));
    }
    return res;
}

int main()
{
    cin >> n >> k;
    F[0]=0;
    for (int i=0; i<n; i++)
    {
        cin >> h[i];
        if (i>=1)F[i]=minn(i);
    }
    cout << F[n-1];
    return 0;
}


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

int main() {
  int N, total, l, r;
  cin >> N;
  total = 0;
  for (int i=0; i<N; i++) {
    cin >> l >> r;
    total += (r - l + 1);
  }
  cout << total << endl;
}

Measured memory_bytes: 256
S = input()
OK = True
if S[0] != "A":
    OK = False
if S[2:-1].count("C") != 1:
    OK = False
large = 0
for s in S:
    if ord("A") <= ord(s) <= ord("Z"):
        large += 1
if large != 2:
    OK = False
if OK:
    print("AC")
else:
    print("WA")

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5;
int mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
ll infll = 1e18 + 7;

int n;
string s, t;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> s >> t;
    FordE(len, n, 1){
        bool ck = 1;
        For(i, n - len, n){
            if (s[i] != t[i - (n - len)]){
                ck = 0;
            }
        }
        if (ck){
            cout << 2 * n - len;
            return 0;
        }
    }
    cout << 2 * n;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll l, r;
    cin >> l >> r;
    if(l / 2019 != r / 2019) cout << 0 << endl;
    else{
        l %= 2019;
        r %= 2019;
        if(l > r) r += 2019;
        int ans = 2019;
        for(int i = l; i < r; i++){
            for(int j = i + 1; j <= r; j++){
                ans = min(ans, i * j % 2019);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int a, b, sum = 0;
    cin >> a >> b;
    for (int i = 0; i < 2; i++)
    {
        if (a > b)
        {
            sum += a;
            a--;
        }
        else
        {
            sum += b;
            b--;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
a=[int(input())]
i=1
while True:
  i+=1
  if a[-1]%2==1:
    if a[-1]*3+1 in a:
      break
    a.append(a[-1]*3+1)
  else:
    if a[-1]/2 in a:
      break
    a.append(a[-1]/2)
print(i)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
  	static int mod = 1000000007;
  static int size = 200001;
	static long[] fac = new long[size];
	static long[] finv = new long[size];
	static long[] inv = new long[size];
	static int INF = Integer.MAX_VALUE;
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int N = sc.nextInt();
  long[] A = new long[N+1];
  long[] B = new long[N];
  int i=0;
  long count=0;
  for(i=0;i<N+1;i++){
    A[i]=sc.nextLong();
  }
  for(i=0;i<N;i++){
    B[i]=sc.nextLong();
  }

  for(i=N;i>0;i--){
    if(A[i]>B[i-1]){
      count+=B[i-1];
    }else if(A[i]+A[i-1]>B[i-1]){
      count+=B[i-1];
      A[i-1]=A[i]+A[i-1]-B[i-1];
    }else{
      count+=A[i]+A[i-1];
      A[i-1]=0;
    }
  }

System.out.println(count);

} 

 //fac, inv, finvテーブルの初期化、これ使う場合はinitComb()で初期化必要
	public static  void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i < size; ++i) {
			fac[i] = fac[i - 1] * i % mod;
			inv[i] = mod - (mod / i) * inv[(int) (mod % i)] % mod;
			finv[i] = finv[i - 1] * inv[i] % mod;
		}
	}
 
	//nCk % mod
	public static long comb(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
		return fac[n] * finv[k] % mod * finv[n - k] % mod;
	}
 
	//n! % mod
	public static long fact(int n){
		return fac[n];
	}
 
	//(n!)^-1 with % mod
	public static long finv(int n){
		return finv[n];
	}
  
}

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

using namespace std;

// #define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
// #define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(20);

  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double rad = M_PI * 2 * ((double)h / 12 + (double)m / 720 - (double)m / 60);

  // double mang, hang, ang, ans;
  // mang = m * 360.0 / 60.0;
  // hang = h * 360.0 / 12.0;
  // hang += m * 360.0 / 720.0;

  // ang = max(mang, hang) - min(mang, hang);
  // if (ang > 180) {
  //   ang = 360 - ang;
  // }
  // ang = deg_to_rad(ang);

  double ans = sqrt((double)(a * a + b * b) - (double)(2 * a * b) * cos(rad));
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 4200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
   ll n,k;
   cin>>n>>k;
   map<ll , ll > m;
   for(int i=0;i<n;i++)
   {
       ll temp , count;
       cin>>temp >> count;
       m [temp  ] += count;
   }
   map<ll , ll> ::iterator  it = m.begin();

   ll index = 0;

   for( it = m.begin() ; it!= m.end() ;it++)
   {
//       cout<<it->first<<" "<<it->second<<endl;
//       cout<<"index is "<<index<<endl;
       if( index < k && (index + it->second ) >= k   ) {
           cout << it->first;

       }
       index += it->second;
   }

}

Measured memory_bytes: 7528
X,N=map(int,input().split())
if N == 0:
    print(X)
    exit()

P=list(map(int,input().split()))

if X in P:
    for i in range(1,100):

        if not X - i in P:
            print(X - i)
            exit()
        if not X + i in P:
                print(X + i)
                exit()
else:
    print(X)

Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,k; cin >> n >> k;
	vl cnt(n,0);
	rep(i,k){
		ll d; cin >> d;
		rep(j,d){
			ll a; cin >> a; a--;
			cnt[a]++;
		}
	}
	ll ans = 0;
	rep(i,n) if(!cnt[i]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9;
const ll N = 2e5 + 5;

int n;
double a[N],pre[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    map<pii,int> M;
    for(int i=0;i<n;i++){
        double x;cin>>x;
        ll y=llround(x*1e9);
        int c2=0,c5=0;
        while(y%2==0) y/=2,c2++;
        while(y%5==0) y/=5,c5++;
        M[{c2,c5}]++;
    }
    ll ans=0;
   	for(auto p1:M)
        for(auto p2:M)
            if(p1.fi.fi+p2.fi.fi>=18 && p1.fi.se+p2.fi.se>=18)
                if(p1>p2) ans+=1ll*p1.se*p2.se;
                else if(p1==p2) ans+=1ll*p1.se*(p1.se-1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e5 + 10;
int n, a[N], d[N];
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        d[i] = 1e9 + 1;
    }
    d[1] = 0;
    for(int i = 1; i <= n; i++)
    {
        d[i + 1] = min(d[i + 1], abs(a[i + 1] - a[i]) + d[i]);
        d[i + 2] = min(d[i + 2], abs(a[i + 2] - a[i]) + d[i]);
    }
    cout << d[n];
}


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

int main(){
	int N[1000][3]={0};
	int n,m=0;
	cin >> n;
	for(int i=0;i<n;i++){
		int tmp[3];
		cin >> tmp[0] >> tmp[1] >> tmp[2];
		sort(tmp,tmp+3);
		bool jud = true;
		for(int j=0;j<m;j++){
			if(N[j][0]==tmp[0]&&(N[j][1]==tmp[1]&&N[j][2]==tmp[2])){
				jud = false;
				break;
			}
		}

		if(jud){
			N[m][0]=tmp[0];
			N[m][1]=tmp[1];
			N[m][2]=tmp[2];
			m++;
		}
	}

	cout << n-m << endl;
	
	

	return 0;
}


Measured memory_bytes: 3172
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];
        int sum = 0;
        for(int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
            sum += a[i];
        }
        double av = (double)sum / (double)N;
        long v = Math.round(av);
        
        long ans = 0;
        for(int i=0; i<N; i++) {
            ans += Math.pow(a[i]-v, 2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
w,h,n = [int(i) for i in input().split()]
lst = []
for _ in range(n):
  lst.append([int(i) for i in input().split()])
a,b = 0,0
for i in lst:
  if i[2] == 1:
    a = max(a, i[0])
  elif i[2] == 2:
    w = min(w, i[0])
  elif i[2] == 3:
    b = max(b, i[1])
  elif i[2] == 4:
    h = min(h, i[1])
if w>a and h>b:
  print((w-a)*(h-b))
else:
  print(0)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int dp[20000000];
    dp[0]=0;
    cin>>N;
    for(int i=1;i<200001;i++){
        dp[i]=9999999;
    }
    for(int i=0;i<N;i++){
        if(dp[i]+1<dp[i+1]){
            dp[i+1]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+6]){
            dp[i+6]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+9]){
            dp[i+9]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+36]){
            dp[i+36]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+81]){
            dp[i+81]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+216]){
            dp[i+216]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+729]){
            dp[i+729]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+1296]){
            dp[i+1296]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+6561]){
            dp[i+6561]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+7776]){
            dp[i+7776]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+46656]){
            dp[i+46656]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+59049]){
            dp[i+59049]=dp[i]+1;
        }
        
    }
    cout << dp[N];
}


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


int main()
{
  ll m,a,b;
  cin>>m>>a>>b;
  
  ll res = ((m)/(a+b) )*a;
  ll rem  = (m%(a+b));
  
  res+=min(a,rem);
  
  cout<<res;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  while (true)
  {
    S = S.substr(0, S.length() - 2);
    string S1 = S.substr(0, S.length() / 2);
    string S2 = S.substr(S.length() / 2, S.length() / 2);
    if (S1 == S2)
    {
      cout << S.length() << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  ll u = 0;

  rep(i,n-m+1) {
    rep(j,n-m+1) {
      if (a[i][j] == b[0][0]) {
        rep(k,m) {
          rep(l,m) {
            if (a[i+k][j+l] == b[k][l]) {
              ++u;
            }
          }
        }
        if (u == m*m) {
          cout << "Yes\n";
          return 0;  
        }
        else {
          u = 0;
        }
      }
    }
  }
  cout << "No\n";

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

int main() {
  int n;
  cin >>n;
  vector<pair<pair<string, int>, int>> p(n);
  rep(i,n){
    cin >>p[i].first.first >>p[i].first.second;
    p[i].first.second *= -1;
    p[i].second = i+1;
  }
  sort(p.begin(), p.end());
  rep(i,n) cout << p[i].second << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int s = 0, m = 0;
  REP(i, N){
    int tmp; cin >> tmp;
    s += tmp;
    m = max(m, tmp);
  }
  cout << s - m / 2 << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    ll ans = 0;
    rep(i,0,n)rep(j,i+1,n)rep(k,j+1, n){
        if(l[i] == l[j] || l[j] == l[k] || l[i] == l[k])continue;
        ll sum = l[i] + l[j] + l[k];
        ll ma = max({l[i], l[j], l[k]});
        if(ma < sum - ma)ans++;
    }   

    cout << ans << "\n";
}

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

public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	int N = Integer.parseInt(br.readLine());
	int [] nums = new int[N];
	
	for(int i = 0; i < N; i++)
	    nums[i] = Integer.parseInt(br.readLine());

	int count = 0;
	for(int n : nums)
	    if ( isPrime(n) ) count++;

	System.out.println(count);

    }

    private boolean isPrime(int n) {
	if ( n == 2 ) return true;
	else if ( n % 2 == 0 ) return false;
	else if ( n < 9 ) return true;
	else if ( n % 3 == 0 ) return false;
	else {
	    for(int i = 5; i * i <= n; i+=6) {
		if ( n % i == 0 ) return false;
		else if ( n % (i+2) == 0 ) return false;
	    }
	    return true;
	}


    }

}

Measured memory_bytes: 11000
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}

ll n;


long long solve2(long long N) {
    if (N % 2 == 1) return 0;

    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        cout << "N/5: " << N/5 <<  endl;
        cout << "res1: " << res <<  endl;
        N /= 5;
    }
    return res;
}


ll solve(ll n) {
    if (n % 2 == 1) return 0;

    ll res = 0;
    n /= 2;
    int c = 1;

    /*
    cout << "n: " << n << endl;
    cout << "n/5: " << n/5 << endl;
    cout << "n/pow(5,c): " << n/((ll) pow(5,c)) << endl;
    cout << "floor(n/pow(5,c)): " << floor(n/((ll) pow(5,c))) << endl;
    */

    while ((ll) n/((ll)pow(5,c))) {
      if((ll)floor(n/(ll)pow(5,c)) != 0) res += n/((ll) pow(5,c));
      c++;
    }
    return res;
}

int main() {
  ll n;
  cin >> n;
  cout << solve(n) << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a, b, c; cin >> a >> b >> c;
	if(b-a == c-b) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
int main() {
   int a,b,c,d,ans;
   cin>>a>>b>>c>>d;
   ans=min(b,d)-max(a,c);
   if(ans<0){
     ans=0;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define pb push_back
const int N=1e5+1;
const int INF=1e9+7;

int32_t main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0); cout.tie(0);
 int n; cin>>n;
 int A[n][3];
 int dp[n][3];

 for(int i=0;i<n;i++)
 {
     cin>>A[i][0]>>A[i][1]>>A[i][2];
 }
 dp[0][0]=A[0][0];
 dp[0][1]=A[0][1];
 dp[0][2]=A[0][2];

 for(int i=1;i<n;i++)
 {
     dp[i][0]=A[i][0]+max(dp[i-1][1],dp[i-1][2]);
     dp[i][1]=A[i][1]+max(dp[i-1][0],dp[i-1][2]);
     dp[i][2]=A[i][2]+max(dp[i-1][1],dp[i-1][0]);
 }
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll k;
  cin >> k;
  string s;
  cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    for (ll i = 0; i < k; ++i) {
      cout << s[i];
    }
    cout << "..." << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <array>

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

    int n, max_cnt = -1;
    std::array<int, 101> arr{{}};
    
    while (std::cin >> n) {
        max_cnt = (max_cnt > ++arr[n]
                   ? max_cnt : arr[n]);
    }

    for (int i = 1; i < 101; ++i) {
        if (arr[i] == max_cnt) {
            std::cout << i << std::endl;
        }
    }

    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int p[200010];
  for(int i=0; i<n; i++) cin >> p[i];
  long long s=0;
  for(int i=0; i<k; i++) s += p[i];
  long long m=s;
  for(int i=k; i<n; i++){
    s += p[i]-p[i-k];
    m = max(m,s);
  }
  printf("%.1f", (m+k)/2.0);
  
}

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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("keyence")){
            System.out.println("YES");
            return;
        }
        int n = s.length();
        boolean ans=false;
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                String cur = s.substring(0,i)+s.substring(j+1,n);
                ans |= cur.equals("keyence");
            }
        }
        String res = ans?"YES":"NO";
        System.out.println(res);
    }
}


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

using namespace std;

int main()
{
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];

  sort(v.rbegin(), v.rend());

  int tmp1 = v[0] * 10 + v[1];
  int tmp2 = v[2];

  cout << tmp1 + tmp2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N;
int P[100], Q[100];
int S[100];

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> P[i];
    }
    rep(i, 0, N)
    {
        cin >> Q[i];
    }
    rep(i, 0, N)
    {
        S[i] = i + 1;
    }

    int cnt = 1;
    int a, b = 0;
    do
    {
        bool eq_p = true;
        bool eq_q = true;
        rep(i, 0, N)
        {
            if (S[i] != P[i])
            {
                eq_p = false;
            }
            if (S[i] != Q[i])
            {
                eq_q = false;
            }
        }
        if (eq_p)
        {
            a = cnt;
        }
        if (eq_q)
        {
            b = cnt;
        }
        cnt++;
    } while (next_permutation(S, S + N));
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

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

int main() {
	ll a, b;
	cin >> a >> b;
	cout << a * b / gcd(a,b) << endl;

	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
} rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

const int N(2e5 + 5);
ll C, f[N];
int n, a[N], q[N], l, r;
inline ll sqr(ll x) { return x * x; }
inline ll calc(int i) { return f[i] + sqr(a[i]); }
int main() {
	n = rd, C = rd;
	REP(i, 1, n) a[i] = rd;
	q[l = r = 1] = 1;
	REP(i, 2, n) {
		for (; l < r && 2ll * a[i] * (a[q[l + 1]] - a[q[l]]) >= calc(q[l + 1]) - calc(q[l]); ++l);
		f[i] = f[q[l]] + sqr(a[i] - a[q[l]]) + C;
		for (; l < r && (long double)(calc(i) - calc(q[r])) / (calc(q[r]) - calc(q[r - 1])) <=  (long double)(a[i] - a[q[r]]) / (a[q[r]] - a[q[r - 1]]); --r);
		q[++r] = i;
	}
	std::cout << f[n];
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    long long sum=0;
    for(int b=k+1;b<=n;b++)
    {
        int s1=n%b-k<0?0:n%b-k+1;
        sum+=(n/b)*(b-k)+s1;
    }
    if(k==0)sum-=n;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

n = int(input())
ans = [-1]*n
tree = [[] for i in range(n)]

def dfs(x,y):
  ans[x] = y
  for node in tree[x]:
    if ans[node[0]] == -1:
      if node[1] % 2 == 0:
        dfs(node[0],y)
      else:
        if y:
          dfs(node[0],0)
        else:
          dfs(node[0],1)

for i in range(n-1):
  a,b,w = map(int,input().split())
  tree[a-1].append([b-1,w])
  tree[b-1].append([a-1,w])

dfs(0,0)
for a in ans:
  print(a)

Measured memory_bytes: 85204
#include <stdio.h>

int main(void)
{
	char w[101];
	int i,a[26]={0};
	scanf("%s",w);
	for(i=0;w[i]!='\0';i++)a[w[i]-'a']++;
	for(i=0;i<26;i++)if(a[i]%2)break;
	puts(i==26?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE FlexibleContexts #-}
import           Control.Monad.State
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import qualified Data.Vector           as V
import qualified Data.Vector.Unboxed   as VU

main :: IO ()
main = do
  [n,p] <- map read . words <$> getLine
  avec <- readLnAsVecNWith n unconsInteger
  let aEvenNum = V.length $ V.filter even avec
      aOddNum = fromIntegral $ V.length $ V.filter odd avec
  print $ fromIntegral (2^aEvenNum) * if p == 0
                                      then sum $ map (comb aOddNum) [0,2..aOddNum]
                                      else sum $ map (comb aOddNum) [1,3..aOddNum]

comb :: Integer -> Integer -> Integer
comb n k = go n k 1 `div` go k k 1
  where go _ 0 a = a
        go m i a = go (m-1) (i-1) (a*m)


-- for unboxed value
unconsChar :: StateT BS.ByteString Maybe Char
unconsChar = StateT BS.uncons

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

readLnAsUVecNWith :: VU.Unbox a => Int -> StateT BS.ByteString Maybe a -> IO (VU.Vector a)
readLnAsUVecNWith n st = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- for boxed Values
unconsInteger :: StateT BS.ByteString Maybe Integer
unconsInteger = StateT $ BS.readInteger . BS.dropWhile isSpace

readLnAsVecNWith :: Int -> StateT BS.ByteString Maybe a -> IO (V.Vector a)
readLnAsVecNWith n st = V.unfoldrN n (runStateT st) <$> BS.getLine


Measured memory_bytes: 4308
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, D;
    cin >> N >> D;
    int sum =0;
    int count =0;

    for(int i=0; sum<N; i++){
        sum += 2*D+1;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k;cin>>n>>k;
    vector<pair<ll,ll>> sushi(n);
    ll t,d;
    rep(i,n){
        cin>>t>>d;
        sushi[i]=mp(d,t);
    }
    sort(all(sushi));
    reverse(all(sushi));
    set<ll> used;
    priority_queue<pair<ll,ll>> pq;
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> ans;
    set<pair<ll,ll>> tmp;
    ll sum=0;
    rep(i,n){
        if(!used.count(sushi[i].second)){
            used.insert(sushi[i].second);
            ans.push(sushi[i]);
            sum+=sushi[i].first;
            tmp.insert(sushi[i]);
        }
        else pq.push(sushi[i]);
        if(ans.size()==k)break;
    }
    ll kind=ans.size();
    while(ans.size()<k){
        ans.push(pq.top());
        sum+=(pq.top()).first;
        pq.pop();
    }
    while(pq.size()){
        auto p=pq.top();pq.pop();
        auto q=ans.top();
        if(!tmp.count(q))break;
        if(sum-q.first+(kind-1)*(kind-1)+p.first>sum+kind*kind){
            ans.pop();
            ans.push(p);
            sum-=q.first;
            sum+=p.first;
            kind--;
            tmp.erase(q);
        }
        else break;
    }
    cout<<sum+kind*kind<<endl;
}

Measured memory_bytes: 11636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll dp[3020][3020];//dp[index][weight]

int main(){
  ll r;
  cin >> r;
  cout << r*r << endl;
return 0;}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 14
 * 
 */

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivv(n);
    int x(-1);
    while(n--){
        ivv(temp);
        if(temp>x)
            x = temp - 1;
        ef(temp<x){
            puts("No");
            return;
        }
    }
    puts("Yes");
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
# B - Foods Loved by Everyone
# https://atcoder.jp/contests/abc118/tasks/abc118_b

import numpy as np

N, M = map(int, raw_input().split())

rcd = [[False for c in range(M+1)] for r in range(N)]

for i in range(N):
    KA = list(map(int, raw_input().split()))
    K = KA[0]
    for j in range(1, K+1):
        rcd[i][ KA[j] ] = True

rcd = np.array(rcd)

cnt = 0
for c in range( len(rcd[0]) ):
    if sum(rcd[:,c]) == N:
        cnt += 1

print '{}'.format(cnt)


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int mod = 1000 * 1000 * 1000 + 7;

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	int ans = 1;
	FOR(i, 1, n + 1)
		ans = mult(ans, i);
	for(char c: s)
	{
		if((cnt ^ (c == 'B')) & 1)
			cnt++;
		else
			ans = mult(ans, cnt--);
	}
	cout << (cnt == 0 ? ans : 0);
	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N){

    N %= 10;
    if(N==3)cout<<"bon"<<endl;
    else if(N==0||N==1 || N == 6 || N == 8)cout<<"pon"<<endl;
    else cout<<"hon"<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T concat(T &a, T &b){a.insert(a.end(),b.begin(),b.end());return a;}
template<class T> T gcd(T x,T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(T x,T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,T mod){T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;}
template<class T> bool alltrue(T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(T &a, T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m, const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m, const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> set<T> devisers(T n){set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;}
template<class T> void getand(T &a,T &b,T &c) {set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));}
template<class T> void getor(T &a,T &b,T &c) {set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));}

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

const int MOD=1e9+7;

int main() {
  int N,M;cin>>N>>M;
  struct key { int cost;set<int> box_ids; };
  vector<key> keys;
  REP(i,M) {
    int a,b;cin>>a>>b;
    set<int> box_ids;
    REP(j,b) {
      int c;cin>>c;
      c--;
      box_ids.insert(c);
    }
    keys.push_back({a,box_ids});
  }

  vector<ll> dp(pow(2,N),INT_MAX);
  dp[0] = 0;
  REP(i,M) {
    int tmp = 0;
    key k = keys[i];
    for (auto box_id:k.box_ids) tmp |= (1<<box_id);
    REP(bit,pow(2,N)) mmin(dp[bit|tmp],dp[bit]+k.cost);
  }
  if (dp[pow(2,N)-1]==INT_MAX) OUT(-1);
  else OUT(dp[pow(2,N)-1]);

  return 0;
}


Measured memory_bytes: 896