akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

// [0, x) の文字で，nums を increment する．
bool increment(vector<pair<lint, lint>> &nums, lint x) {
  if(nums.back().first == x - 1) {
    // 全部 x - 1 なら increment できない
    int cnt = 0;
    while(nums.back().first == x - 1) {
      cnt += nums.back().second;
      nums.pop_back();
      if(nums.empty()) {
        return false;
      }
    }
    
    lint y = nums.back().first;
    nums.back().second--;
    if(nums.back().second == 0) nums.pop_back();
    nums.push_back({y + 1, 1});
    nums.push_back({0, cnt});
    
    return true;
  } else {
    lint y = nums.back().first;
    nums.back().second--;
    if(nums.back().second == 0) nums.pop_back();
    nums.push_back({y + 1, 1});

    return true;
  }
}

int main() {
  
  int n; cin >> n;
  vector<lint> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  lint low = 0;
  lint high = n + 1;
  while(high - low > 1) {
    lint mid = (low + high) / 2;
    // cerr << "mid = " << mid << endl;
    vector<pair<lint, lint>> nums; // {文字，数} のランレングス圧縮
    nums.push_back({0, a[0]});
    bool ok = true;
    for(int i = 1; i < n; i++) {
      if(a[i] > a[i - 1]) nums.push_back({0, a[i] - a[i - 1]});
      else {
        lint pop = a[i - 1] - a[i];
        while(pop >= nums.back().second) {
          pop -= nums.back().second;
          nums.pop_back();
        }
        assert(nums.back().second - pop >= 0);
        nums.back().second -= pop;
      
        // cerr << "i, before = " << i << endl;
        /*for(int i = 0; i < nums.size(); i++) {
          cerr << nums[i].first << " " << nums[i].second << endl;
        }*/
        // 増加させて，ちゃんと増加できたら true を返す．
        if(!increment(nums, mid)) {
          ok = false;
          break;
        }
      }
      /*cerr << "i, after = " << i << endl;
      for(int i = 0; i < nums.size(); i++) {
        cerr << nums[i].first << " " << nums[i].second << endl;
      }*/
    }

    if(ok) high = mid;
    else low = mid;
  }

  cout << high << endl;
  return 0;
}


Measured memory_bytes: 9092
using System;
class Program
{
  static void Main(string[] args)
  {
    // スペース区切りの整数の入力
    string[] input = Console.ReadLine().Split(' ');
    int h = int.Parse(input[0]);
    int w = int.Parse(input[1]);


    string[,] field = new string[h, w];
    string[,] outfield = new string[h, w];
    //出力

    for (int i = 0; i < h; i++) {
      string input2 = Console.ReadLine();
      for (int j = 0; j < w; j++) {
        field[i,j] = input2[j].ToString();
      }
    }

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (field[i,j] == "."){
          int count = 0;
          for (int k=0;k<9;k++){
            if (i + k%3 -1 <0)continue;
            if (j + k/3 -1  < 0)continue;
            if (i + k%3 -1 == h)continue;
            if (j + k/3 -1 == w)continue;
            if (field[i + k%3 -1 ,j +k/3 -1 ] =="#")count++;
          }
          outfield[i,j] = count.ToString();
        }else{
          outfield[i,j] = field[i,j];
        }
      }
    }



    for (int i = 0; i < h; i++) {
      string output ="";
      for (int j = 0; j < w; j++) {
        output += outfield[i,j];
      }
      Console.WriteLine(output);
    }

  }
}

Measured memory_bytes: 13220
#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;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

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

const int maxN = 3e3 + 10;
const int maxS = 3e3 + 10;
const ll mod = 998244353;

int n, s, a[maxN];
ll dp[maxS], ans = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> s;
    for1(i, n)
    {
        cin >> a[i];
    }
    for1(i, n)
    {
        dp[0] = i;
        if (s >= a[i])
        {
            ans += dp[s - a[i]] * (n - i + 1) % mod;
            ans %= mod;
        }
        for (int j = s; j >= a[i]; --j)
        {
            dp[j] += dp[j - a[i]];
            dp[j] %= mod;
        }
    }
    cout << ans;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll D[N][2]; rep(i,N) rep(j,2) cin >> D[i][j];
  bool zoro[N]; rep(i,N) zoro[i] = D[i][0]==D[i][1];
  string result = "No";
  repr(i,2,N) if (zoro[i-2]&&zoro[i-1]&&zoro[i]) result = "Yes";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
ll mod = 1000000007;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int INF = (int)1e9;
//=========================CODE STARTS HERE=============================//

ll findTrailingZeros(ll n) 
{ 
    // Initialize result 
    ll count = 0; 
  
    
    for (ll i = 10; n / i >= 1; i *= 5) 
        count += n / i; 
  
    return count; 
} 

int main() {

	fast_cin();

	ll n;
	cin >> n;
	
	if (n & 1) cout << 0 << endl;
	else {
		cout << findTrailingZeros(n) << endl;
	}

    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  ll zero, one;
  zero = one = 0;
  if (s.length() < 1)
  {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  for (ll i = 1; i < s.length(); i++)
  {
    if (s[i] == s[i - 1])
    {
      s[i] = s[i] == '0' ? '1' : '0';
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}
 
vs sepstr(string s,string r){vs res;regex R("[^|]+");for(auto _:r)s=regex_replace(s,regex("[\\"+string{_}+"]"),"|"+string{_}+"|");for(sregex_iterator itr(all(s),R),end;itr!=end;++itr)res.pb(itr->str());return res;}

template<class T>string bitstr(T x){return typeid(T)==typeid(int)?bitset<32>(x).to_string('_','#'):bitset<64>(x).to_string();}
template<class T>int bitcnt(T x){return typeid(T)==typeid(int)?__builtin_popcount(x):__builtin_popcountll(x);}
template<class T>int bitdig(T x){return x?typeid(T)==typeid(int)?32-__builtin_clz(x):64-__builtin_clzll(x):0;}
template<class T>int bitpow(T x){return x?typeid(T)==typeid(int)?__builtin_ctz(x):__builtin_ctzll(x):0;}

int main(){
    dclt(int,a,b,c);
    if(a%2 || b%2 || c%2){
        cout<<0<<endl;
    }else if(a==b && b==c){
        cout<<-1<<endl;
    }else{
        cout<<bitpow(gcd(gcd(abs(a-b),abs(b-c)),abs(c-a)))<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

int main() {
    int N, M; cin >> N >> M;
    vector<string> A(N), B(M); cin >> A >> B;
    rep(dy, N) rep(dx, N) {
        bool ok = true;
        rep(y, M) rep(x, M) {
            int yy = y + dy, xx = x + dx;
            if(yy >= N or xx >= N) {
                ok = false;
                goto FAIL;
            }
            ok &= A[yy][xx] == B[y][x];
        }
  FAIL:
        if(ok) {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define asd(i,n,N) for(int i=n;i< N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>> " << #x << " -> " << x << endl
#define mems(x,y) memset(x,y,sizeof x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e6+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;

ll tc,n,x[MAX],y,z,a,b,sz,id,tmp,res,cnt;
string s,t;
vector<int> v;

int main(){
//	cout<<fixed<<setprecision(2);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    rep(i,1,n)cin>>x[i];
    rep(i,1,n)rep(j,i+1,n)rep(k,j+1,n){
    	if(x[i]==x[j]||x[i]==x[k]||x[j]==x[k])continue;
    	v.clear();
    	v.pb(x[i]), v.pb(x[j]), v.pb(x[k]);
    	sort(all(v));
    	if(v[2]<v[0]+v[1])++res;
	}
	cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>

int main()
{
	int N;
	std::cin >> N;
	int K;
	std::cin >> K;
	
	int num=0;
	if (N % 2 == 1) {//奇数
		num = N / 2 + 1;
	}
	else {
		num = N / 2;
	}

	if (K <= num) {//K個選べたら
		std::cout << "YES";
	}
	else {
		std::cout << "NO";
	}

}


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

int n, a, b, c;

void dfs(int &ans, int tmp, int node, vector<int> &l, int L1, int L2, int L3){
    if(node == n){
        if(!L1 || !L2 || !L3) return;
        ans = min(ans, tmp + (int)abs(L1 - a) + (int)abs(L2 - b) + (int)abs(L3 - c));
        return;
    }

    dfs(ans, tmp + 10, node + 1, l, L1 + l[node], L2, L3);
    dfs(ans, tmp + 10, node + 1, l, L1, L2 + l[node], L3);
    dfs(ans, tmp + 10, node + 1, l, L1, L2, L3 + l[node]);
    dfs(ans, tmp, node + 1, l, L1, L2, L3);
    return;

}

int main(){

    cin >> n >> a >> b >> c;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    int ans = INF;
    dfs(ans, 0, 0, l, 0, 0, 0);
    cout << ans - 30 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <set>

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

using namespace std;
string s;
string t;

int main()
{
    cin >> s;
    cin >> t;
    //vector <vector<string>> dp(3001, vector <string>(3001, ""));
    vector <vector<int>> dpsize(3001, vector <int>(3001, 0));
    auto ssize = s.size();
    auto tsize = t.size();
    FOR(i, 1, ssize+1) {
        FOR(j, 1, tsize+1) {
            if (s[i-1]==t[j-1]) {
                //dp[i][j] = dp[i-1][j-1] + s[i-1];
                dpsize[i][j] = dpsize[i-1][j-1] + 1;
            }
            else {
                bool is_bigger;
                is_bigger = dpsize[i-1][j] > dpsize[i][j-1];
                if (is_bigger) {
                    //dp[i][j] = dp[i-1][j];
                    dpsize[i][j] = dpsize[i-1][j];
                } else {
                    //dp[i][j] = dp[i][j-1];
                    dpsize[i][j] = dpsize[i][j-1];
                }
            }
        }
    }
    //REP(i, ssize+1) {
    //    REP(j, tsize+1) {
    //        cout << dpsize[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    int i = ssize;
    int j = tsize;
    string ans = "";
    while (i>0 && j>0) {
        if (dpsize[i][j]==dpsize[i-1][j]) {
            //ans = s[i-1] + ans;
            i--;
        } else if (dpsize[i][j]==dpsize[i][j-1]) {
            //ans = t[j-1] + ans;
            j--;
        } else {
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
    ll N;
    cin >> N;

    ll SN = findSumOfDigits(N);

    if(N % SN == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(){
  int i,j,n;
  double sum=0,im,im2[1000];

  while(cin >> im){
    sum=0;
    im2[1]=im;
    sum+=im;
    for(i=2;i<=10;i++){
      if(i%2 == 0){
	im2[i]=im2[i-1]*2;
	sum+=im2[i];
      }
      else{
	im2[i]=im2[i-1]/3;
	sum+=im2[i];
      }
      //cout << "im2["<<i<<"] = "<<im2[i]<<endl;

    }

    printf("%.8f\n",sum);

  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int maxn = 200001;
int n, m,x,y,z;
long double a[301], dp[301][301][301];
long double sol(int x, int y, int z)
{
    if(dp[x][y][z]>0.5)return dp[x][y][z];
    long double q = 0;
    if(x+y+z == 0)return q;
    if(x > 0) q+=sol(x-1, y, z)*x;
    if(y > 0) q+=sol(x+1, y-1, z)*y;
    if(z > 0) q+=sol(x, y+1, z-1)*z;

    q /= (long double)(x+y+z);
    q += n/(long double)(x+y+z);
    dp[x][y][z] = q;
    return q;
}
void solve()
{
    cin>>n;
    rep(i, 0, n)
    {
        cin>>a[i];
        if(a[i]==1)x++;
        else if(a[i]==2)y++;
        else z++;
    }
    rep(i, 0, 301)rep(j, 0, 301)rep(k, 0, 301)dp[i][j][k] = -1;
    cout<<setprecision(15)<<sol(x, y, z);






















    

}
signed main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 426496
// atcoder/abc166/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

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

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, k;
  while (cin >> n >> k) {
    int cnt[n];
    fill(cnt, cnt + n, 0);
    for (int i = 0; i < k; ++i) {
      int d;
      cin >> d;
      for (int j = 0; j < d; ++j) {
        int x;
        cin >> x;
        --x;
        ++cnt[x];
      }
    }
    cout << count(cnt, cnt + n, 0) << endl;
  }

  return 0;
}


Measured memory_bytes: 3644
// finish date: 2018/01/19
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    string S;
    cin >> S;
    char col=' ';
    int count = 0;
    rep(i, S.length()) {
        if(i==0){
            col = S[i];
            continue;
        }
        if (S[i] != col) {
            count++;
        }
        col = S[i];
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  int naga,sum=0;
  for(int i=0; i<n; i++){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  naga = l.at(n-1);
  for(int i=0; i<n-1; i++){
    sum += l.at(i);
  }
  if(naga<sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
s = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(raw_input())
for i in range(n):
    b, f, r, v = map(int, raw_input().split())
    s[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, s[b][f])))
    if b != 3:
        print("#"*20)

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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r) {
  if (l >= r) return;
  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(), in.end(), root));
  rec(l, m);
  rec(m + 1, r);
  post.push_back(root);
};

void solve() {
  pos = 0;
  rec(0, pre.size());
  for (int i = 0; i < n; i++) {
    if (i < n - 1) cout << post[i] << ' ';
    else cout << post[i] << endl;
  }
};

int main() {
  int k;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k;
    pre.push_back(k);
  }
  for (int i = 0; i < n; i++) {
    cin >> k;
    in.push_back(k);
  }

  solve();
};



Measured memory_bytes: 3160
N = int(input())
L =[' ','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
res = []
q=N
while(q>0):
    r = q % 26
    q = q //26
    if(r==0):
        res.append(L[26])
        q -= 1
    else:
        res.append(L[r])
for i in range(len(res)-1,-1,-1):
    print(res[i],end='',sep='')

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return(0);
		}
	}
	cout<<"NG"<<endl;
  return(0);
}

Measured memory_bytes: 3624
import numpy as np

n = int(input())
A = [int(x) for x in input().split()]

sum_start_plus = 0
sum_start_minus = 0
ans_start_plus = 0
ans_start_minus = 0
flag_start_plus = True
flag_start_minus = True

# プラス始まりの場合を計算する
for a in A:
    sum_start_plus += a
    if flag_start_plus:
        flag_start_plus = False
        if np.sign(sum_start_plus) == 1:
            continue
        else:
            ans_start_plus += abs(1 - sum_start_plus)
            sum_start_plus = 1
    else:
        flag_start_plus = True
        if np.sign(sum_start_plus) == -1:
            continue
        else:
            ans_start_plus += abs(-1 - sum_start_plus)
            sum_start_plus = -1

# マイナス始まりの場合を計算する
for a in A:
    sum_start_minus += a
    if flag_start_minus:
        flag_start_minus = False
        if np.sign(sum_start_minus) == -1:
            continue
        else:
            ans_start_minus += abs(-1 - sum_start_minus)
            sum_start_minus = -1
    else:
        flag_start_minus = True
        if np.sign(sum_start_minus) == 1:
            continue
        else:
            ans_start_minus += abs(1 - sum_start_minus)
            sum_start_minus = 1

print(min(ans_start_plus, ans_start_minus))

Measured memory_bytes: 23220
#include <stdio.h>
#include <math.h>
 int main(void){
  int a,b;
   while(scanf("%d%d",&a,&b) != EOF){
     double x = a+b;
       double digit = log10(x);
	   int digitnew = floor(digit);
	   
	   if(digit == digitnew+1){
		   printf("%d\n",digitnew+2);
	   }else{
	   printf("%d\n",digitnew+1);
	   }
   }  
return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

ll fast_exp(ll base,ll e){
    ll r=1;
    while(e>0){
        if(e%2)r=(r*base);
        base=base*base;
        e/=2;
    }
    return r;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	return (a*b)/gcd(a,b);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	int x=n%10;
	if(x==2||x==4||x==5||x==7||x==9)cout<<"hon"<<endl;
	else if(x==0||x==1||x==6||x==8)cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
}

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

using namespace std;

int main(){

  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  s1 = "A";
  s3 = "C";

  cout << s1 + s2[0] + s3 << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf=(char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char memarr[96000000];
string S;
int main(){
  wmem = memarr;
  rd(S);
  sort(S.begin(), S.end());
  if(S=="abc"){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// string S;
// {
//   rd(S);
//   sort(S.begin(), S.end());
//   wt( if[S=="abc", "Yes", "No"] );
// }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <array>
#include <algorithm>
#include <string>

int main()
{
    int N, L;
    std::cin >> N >> L;

    std::vector<int> taste;
    taste.resize(N);

    int sumBefore = 0;
    for(int i=0; i<N; ++i)
    {
        taste[i] = L + i+1 - 1;
        sumBefore += taste[i];
    }

    int minCost = std::numeric_limits<int>::max();
    int mintaste;
    for(int i=0; i<N; ++i)
    {
        int sumAfter;
        sumAfter = sumBefore - taste[i];
        if(abs(sumAfter-sumBefore)<minCost)
        {
            minCost = abs(sumAfter-sumBefore);
            mintaste = sumAfter;

        }
    }

    std::cout << mintaste << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    ll x,y;
    cin >> x >> y;
    if(x>0 && y>0){
        if(x==y){
            cout << 0 << endl;
        }
        else if(x>y){
            cout << x-y+2 << endl;
        }
        else if(x<y){
            cout << y-x << endl;
        }
    }
    else if(x<0 && y<0){
        if(x==y){
            cout << 0 << endl;
        }
        else if(abs(x)>abs(y)){
            cout << abs(x)-abs(y) << endl;
        }
        else if(abs(x)<abs(y)){
            cout << abs(y)-abs(x)+2 << endl;
        }
    }
    else if(x<0 && y>0){
        if(abs(x)==abs(y)){
            cout << 1 << endl;
        }
        else if(abs(x)>abs(y)){
            cout << abs(x)-abs(y)+1 << endl;
        }
        else if(abs(x)<abs(y)){
            cout << abs(y)-abs(x)+1 << endl;
        }
    }
    else if(x>0 && y<0){
        if(abs(x)==abs(y)){
            cout << 1 << endl;
        }
        else if(abs(x)>abs(y)){
            cout  << abs(x)-abs(y)+1 << endl;
        }
        else if(abs(x)<abs(y)){
            cout << abs(y)-abs(x)+1 << endl;
        }
    }
    else if(x==0 && y==0){
        cout << 0 << endl;
    }
    else if(x==0 && y<0){
        cout << abs(y)+1 << endl;
    }
    else if(x==0 && y>0){
        cout << y << endl;
    }
    else if(x>0 && y==0){
        cout << abs(x)+1 << endl;
    }
    else if(x<0 && y==0){
        cout << abs(x) << endl;
    }
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int mod=998244353;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

const int Vmax=1000010;
int fact[Vmax],factInv[Vmax];
void Init(){
	fact[0]=1;
	FOR(i,1,Vmax){
		fact[i]=fact[i-1];
		mult(fact[i],i);
	}
	factInv[Vmax-1]=modInv(fact[Vmax-1]);
	for(int i=Vmax-2;i>=0;i--){
		factInv[i]=factInv[i+1];
		mult(factInv[i],i+1);
	}
}
int Choose(int n,int k){
	return fact[n]*factInv[n-k]%mod*factInv[k]%mod;
}

signed main(){
	Init();
	int n=read(),m=read();
	int ans=0;
	{
		REP(i,n)if(i+2<=m){
			add(ans,Choose(i+2-1+i,i)*Choose(m-(i+2)+n-1-i,n-1-i)%mod*(i+2+i));
			if(i+1<=n-1)sub(ans,Choose(i+2+i,i)*Choose(m-(i+2)+n-1-i-1,n-1-i-1)%mod*(i+2+i+1));
		}
		if(m<=n)add(ans,Choose(m+n-1,n-1)*(m+n));
	}
	{
		REP(i,m)if(i+1<=n){
			add(ans,Choose(i+i+1-1,i+1-1)*Choose(m-1-i+n-(i+1),n-(i+1))%mod*(i+i+1));
			if(i+1<=m)sub(ans,Choose(i+i+1,i+1)*Choose(m-1-i-1+n-(i+1),n-(i+1))%mod*(i+i+1+1));
		}
		if(n<=m-1)add(ans,Choose(m-1+n,n)*(m+n));
	}
	mult(ans,modInv(Choose(m+n,n)));
	cout<<ans<<endl;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i].first >> a[i].second;
    //円、本数
  }
  ll ans = 0;
  sort(a.begin(), a.end());
  for(int i=0; i<n; i++){
    if(m>a[i].second){
      m -= a[i].second;
      ans +=(ll) a[i].first * a[i].second;
    }else{
      ans +=(ll) a[i].first * m;
      m = 0;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    a,b = LI()
    if a == b:
        return 'Draw'
    if a==13 and b==1:
        return 'Bob'
    if a==1 and b==13:
        return 'Alice'
    if a > b:
        return 'Alice'

    return 'Bob'

print(main())


Measured memory_bytes: 6936
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, p, a;

int main(){
	cin >> n >> p;
	int cnt_odd = 0;
	for(ll i = 1; i <= n; i++){
		cin >> a;
		if(a%2){cnt_odd++;}
	}
	
	ll ans = pow(2, n-cnt_odd);
	if(cnt_odd){ans *= pow(2, cnt_odd)/2;}
	else{ans *= (p == 0)? 1 : 0;}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int a, b;
  int res=0;
  cin >> a>>b;

  int x=(a+b)/2;
  if((a+b)% 2==1) x++;

  cout << x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100003;
ll i,j,n,ans = -MAX;
struct S{
    ll c[3];
} w[N];
ll dp[N][3];
ll solve(ll i,ll p)
{
    if(dp[i][p] != -1) return dp[i][p];
    
    if(i == 0)
        return dp[i][p] = 0;
    
    ll res = -MAX;
    for(ll j = 0;j < 3;j += 1) if(j != p)
        res = max(res,solve(i - 1,j) + w[i].c[p]);
        
    return dp[i][p] = res;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    rep(i,1,n + 1) rep(j,0,3) cin>>w[i].c[j];
    rep(i,0,3)
        ans = max(ans,solve(n,i));
    cout<<ans;
    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    char c;
    cin >> c;
    cout << (c - 'a' >=0 ? 'a' : 'A') << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
int main()
{
	int n,ans;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ans=a[0];
	for(int i=1;i<n;i++)
	{
		ans=__gcd(ans,a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
#define MAX(a, b) a : b ? a : b;

int main(void) {
	int a, b;
	cin >> a >> b;

	int l = a + b;
	int m = a - b;
	int n = a * b;

	int max = l;
	if (max < m) max = m;
	if (max < n) max = n;

	cout << max << endl;
	return 0;
}

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

int main()
{
	ll h,n,sum=0;
	cin>>h>>n;
	ll a[n],b[n];
	ll mini_a=INT_MAX,mini_b=INT_MAX;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	
	ll dp[h+1];
	dp[0]=0;
	for(int i=1;i<=h;i++)
	{
		dp[i]=INT_MAX;
	}
	
	for(int i=1;i<=h;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i-a[j]>=0)
			{
				dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
			}
			else if(i-a[j]<0)
			{
				dp[i]=min(dp[i],b[j]);
			}
		}
	}
	cout<<dp[h]<<endl;
	
	
	
	
}

Measured memory_bytes: 384
from collections import deque

n,q=map(int,input().split())

que = []
for _ in range(n):
	que.append(input())
que.append("")
head=0
tail=n
cnt=0
result=[]
flag=1
#print(que,result,head,tail)
while head!=tail:
	temp=que[head].split()
	head=head+1
	if head>n:
		head=head-n-1
	if int(temp[1])<=q:
		cnt+=int(temp[1])
		result.append(temp[0]+" "+str(cnt))
	else:
		cnt+=q
		que[tail]=temp[0]+" "+str(int(temp[1])-q)
		tail+=1
		if tail>n:
			tail=tail-n-1
	#print(que,result,head,tail)

#print("#################")
for item in result:
	print(item)


Measured memory_bytes: 13368
s = input()
former = int(s[:2])
latter = int(s[2:])

if former > 12 or former < 1:
    if latter > 12 or latter < 1:
        print("NA")
    else:
        print("YYMM")
else:
    if latter > 12 or latter < 1:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Measured memory_bytes: 3060
import sys
from time import time, sleep
from random import random
from bisect import bisect, bisect_left
def inpl(): return list(map(int, input().split()))
start = time()
D = int(input())
C = inpl()
S = [inpl() for _ in range(D)]
X = [0]*D
res = []
max_score = 0

score = 0
A = [[] for _ in range(26)]
used = [1]*26
for i in range(D):
    if (i%26) == 0:
        for j in range(26):
            used[j] = 0
    K = sorted(list(range(26)), key=lambda x: -S[i][x])
    for k in K:
        if not used[k]:
            used[k] = 1
            X[i] = k
            break
    A[X[i]].append(i)
#print(max_score, file=sys.stderr)

from bisect import bisect
while (time() - start < 1.8):
    tmp = 0
    if (random() < .9):
        d = int(random() * D)
        x = X[d]
        y = int(random() * 26)
        if x == y:
            continue
    else:
        M = 0
        ml, mr = -1, -1
        x = -1
        for i in range(26):
            m = 0
            l = 0
            
            if len(A[i]) < 2:
                continue
            for j in range(len(A[i])-1):
                q = A[i][j+1] - A[i][j]
                if m > q:
                    l = j
            n = (A[i][l+1] - A[i][l])
            if n*(n-1)*C[i] > M:
                M = n*(n-1)*C[i]
                ml = A[i][l]
                mr = A[i][l+1]
                x = i
        if x < -1:
            continue
        d = (mr + ml)//2
        y = int(random() * 26)
            
            
    tmp += -S[d][x] + S[d][y]
    di = bisect_left(A[x], d)
    d0 = -1 if di == 0 else A[x][di-1]
    d2 = D - 1 if (di >= len(A[x]) - 1) else A[x][di+1]
    tmp += -(d2-d0)*(d2-d0-1)*C[x]//2 + (d-d0)*(d-d0-1)*C[x]//2 + (d2-d)*(d2-d-1)*C[x]//2

    d0i = bisect_left(A[y], d) - 1
    d0 = -1 if d0i == -1 else A[y][d0i]
    d2 = D - 1 if d0i == len(A[y]) - 1 else A[y][d0i+1]
    tmp += (d2-d0)*(d2-d0-1)*C[y]//2 - (d-d0)*(d-d0-1)*C[y]//2 - (d2-d)*(d2-d-1)*C[y]//2
    if (tmp > 0):
        #print(tmp, file=sys.stderr)
        A[x].pop(di)
        A[y].insert(d0i+1, d)
        X[d] = y
        max_score += tmp
#print(max_score, file=sys.stderr)
for x in X:
    print(x+1)


Measured memory_bytes: 82492
#include<iostream>
bool ex(int, int);
int A[20],n;
int main(){
  int m, input;
  std::cin >> n;
  for(int i=0; i<n; i++) std::cin >> A[i];
  std::cin >> m;
  for(int i=0; i<m; i++){
    std::cin >> input;
    std::cout << (ex(input,0) ? "yes\n" : "no\n");
  }
  return 0;
}

bool ex(int x, int i){
  if(x == 0) return true;
  for(int j=i; j<n; j++) if(ex(x-A[j],j+1)) return true;
  return false;
}

Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		br.close();

		if (n <= 2) {
			System.out.println(0);
			return;
		}

		long ans = 0;
		long n2 = (long) Math.sqrt(n);
		for (long i = n2 + 1; i > 0; i--) {
			if (n % i == 0) {
				long d = n / i - 1;
				if (n / d == n % d) {
					ans += d;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    set<int>st(a.begin(),a.end());
    int pre_ans=st.size();
    map<int,int>mp;
    for (int i = 0; i < n; i++)
    {
        mp[a[i]]++;
    }
    int cnt=0;
    for (int i = 1; i <=1e5; i++)
    {
        if(mp[i]%2==0 && mp[i]!=0){
            cnt++;
        }
    }
    int ans;
    if(cnt%2==0){
        ans=pre_ans;
        cout<<ans<<endl;
    }
    else{
        ans=pre_ans-1;
        cout<<ans<<endl;
    }
    
    
    

    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

int ctoi(char c) {
    // 'a' == 97, 'z' == 122
    // int a = 'a', z = 'z';
    if ('a' <= c && c <= 'z') {
        return (int)c;
    }
    return -1;
}


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

    // input
    string S, res;
    cin >> S;
    
    // calc
    size_t len = S.length();
    REP(i, len) {
        if (S[i] == '0') {
            res += '0';
        } else if (S[i] == '1') {
            res += '1';
        } else {
            if (res.empty()) {
                continue;
            } else {
                res.erase(res.end() - 1);
            }
        }
        
    }
    cout << res << "\n";
    
    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;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, tmp;
  cin >> N;
  tmp = (int)N/1.08;
  if((int)(tmp * 1.08) == N){
    cout << tmp << endl;
  }else if((int)((tmp + 1) * 1.08) == N){
    cout << tmp + 1 << endl;
  }else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256