akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EQ(a,b) (abs((a)-(b))<EPS)
using namespace std;
typedef long double D;
typedef complex<D> P;
const D EPS = 1e-8;
const D PI = acos(-1);

int n,r,q;
P p[30];
int cur;

inline D dot(P x, P y){return real(conj(x)*y);}

inline P rotate(P v, D s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(P a,P b,P c){return acos(dot(b-a,c-a)/(abs(b-a)*abs(c-a)));}

inline D rot_seta(int end){
  D dis = abs(p[end]-p[cur]);
  D seta = acos( (2*r*r - dis*dis)/(2*r*r) );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  
  while(cin >> n >> r >> q, n){
    rep(i,n){
      D x,y;
      cin >> x >> y;
      p[i] = P(x,y);
      if(EQ(abs(p[i]),r))cur = i;
    }
    
    vector<int> nxt(n,-1);
    
    rep(i,q){
      int id = -1;
      D min_s = PI;
      if(nxt[cur]>=0)id = nxt[cur];
      else{
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(id<0 || s+EPS < min_s)id = j, min_s = s;
	}
	nxt[cur] = id;
      }

      D seta = rot_seta(id);
      rep(i,n){
	if(i==cur)continue;
	p[i] = rotate(p[i]-p[cur],seta) + p[cur];
      }
      cout << fixed << setprecision(10) << p[id].real() << " " << p[id].imag() << endl;
      cur = id;
    }
  }
}

Measured memory_bytes: 1320
<?php
error_reporting(0);
$N = trim(fgets(STDIN));
$K = trim(fgets(STDIN));
//$A = explode(" ",trim(fgets(STDIN)));
//list($N,$M) = explode(" ",trim(fgets(STDIN)));

$n=1;
for($i=0;$i<$N;$i++) {
  $wk = $n * 2;
  if ($wk > $K + $n) {
    $n+=$K;
  }
  else {
    $n=$n*2;
  }
}
printf("%d\n",$n);


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

typedef long long ll;

const int N = 2e5 + 7;
const int MOD = 1e9 + 7;

int add(int a, int b) {
    ll res = (ll)a + b;
    return res % MOD;
}

int sub(int a, int b) {
    ll res = (ll)a - b;
    res %= MOD;
    res += MOD;
    return res % MOD;
}

int mul(int a, int b) {
    ll res = (ll)a * b;
    return res % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int fact[N];

void init() {
	fact[0] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = mul(fact[i - 1], i);
	}
}

int C(int n, int k) {
	return divv(fact[n], mul(fact[k], fact[n - k]));;
}

vector<int> g[N];

int sz[N];
int fdp[N];
int sdp[N];

void dfs(int cur, int p) {
	sz[cur] = 1;
	int scnt = 1;
	vector<int> ss;
	for (auto t : g[cur]) {
		if (t != p) {
			dfs(t, cur);
			sz[cur] += sz[t];
			scnt = mul(scnt, fdp[t]);
			ss.push_back(sz[t]);
		}
	}
	int c = sz[cur] - 1;
	for (auto t : ss) {
		scnt = mul(scnt, C(c, t));
		c -= t;
	}
	fdp[cur] = scnt;
}

int n;

void jfs(int cur, int p) {
	int ml = sdp[cur];
	for (auto t : g[cur]) {
		if (t != p) ml = mul(ml, fdp[t]);
	}
	vector<int> ss = {n - sz[cur]};
	for (auto t : g[cur]) {
		if (t != p) ss.push_back(sz[t]);
	}
	int c = n - 1;
	int cnt = 1;
	for (auto t : ss) {
		cnt = mul(cnt, C(c, t));
		c -= t;
	}
	for (auto t : g[cur]) {
		if (t != p) {
			int nml = divv(ml, fdp[t]);
			int ncnt = divv(cnt, C(n - 1, sz[t]));
			sdp[t] = mul(ncnt, nml);
			jfs(t, cur);
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	init();

	cin >> n;
	for (int i = 0; i + 1 < n; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0, -1);
	sdp[0] = 1;
	jfs(0, -1);
	for (int i = 0; i < n; i++) {
		int rs = mul(fdp[i], sdp[i]);
		rs = mul(rs, C(n - 1, n - sz[i]));
		cout << rs << '\n';
	}
}


Measured memory_bytes: 17236
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB = sorted(AB, key=lambda x:(x[0]), reverse=True)
AB = sorted(AB, key=lambda x:(x[1]))
time = 0
for ab in AB:
    time += ab[0]
    if time > ab[1]:
        time = -1
        break

print("Yes" if time > 0 else "No")

Measured memory_bytes: 55272
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int bingo[3][3];
bool mark[3][3];

int main(){
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
            int a; 
            cin >> a;
            bingo[i][j] = a;
        }
    }

    int N; cin >> N;

    for(int n=0; n<N; ++n){
        int b; cin >> b;
        for(int i=0; i<3; ++i){
            for(int j=0; j<3; ++j){
                if(b == bingo[i][j]) mark[i][j] = true;
            }
        }
    }

    string ans = "No";

    for(int i=0; i<3; ++i){
            if (mark[i][0] == true && 
                mark[i][1] == true && 
                mark[i][2] ==true ){
                    ans = "Yes";
                }
    }

    for(int j=0; j<3; ++j){
            if (mark[0][j] == true && 
                mark[1][j] == true && 
                mark[2][j] ==true ){
                    ans = "Yes";
                }
    }

    if(mark[0][0] == true &&
        mark[1][1] == true &&
        mark[2][2] == true){
            ans = "Yes";
        }

    if(mark[0][2] == true && 
        mark[1][1] == true &&
        mark[2][0] == true){
            ans = "Yes";
        }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W, 0));
    vector<vector<int>> B(H, vector<int>(W, 0));
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
        }
    }
    REP(i, H) {
        REP(j, W) {
            cin >> B[i][j];
        }
    }
    REP(i, H) {
        REP(j, W) {
            A[i][j] = abs(A[i][j]-B[i][j]);
        }
    }
    vector<vector<vector<bool>>> dp(H, vector<vector<bool>>(W, vector<bool>(6401, false)));
    dp[0][0][A[0][0]] = true;
    REP(i, H) {
        REP(j, W) {
            if(i == 0 && j == 0) continue;
            if(i != 0) {
                REP(k, 6401) {
                    if(dp[i-1][j][k]) {
                        if(k+A[i][j] <= 6400) dp[i][j][k+A[i][j]] = true;
                        if(k-A[i][j] >= 0) {
                            dp[i][j][k-A[i][j]] = true;
                        } else {
                            dp[i][j][A[i][j]-k] = true;
                        }
                    }
                }
            }
            if(j != 0) {
                REP(k, 6401) {
                    if(dp[i][j-1][k]) {
                        if(k+A[i][j] <= 6400) dp[i][j][k+A[i][j]] = true;
                        if(k-A[i][j] >= 0) {
                            dp[i][j][k-A[i][j]] = true;
                        } else {
                            dp[i][j][A[i][j]-k] = true;
                        }
                    }
                }
            }
        }
    }
    REP(k, 6401) {
        if(dp[H-1][W-1][k]) {
            cout << k << endl;
            return 0;
        }
    }
}

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

int main(){
  string S;
  cin >> S;
  long long N = S.size();
  
  char A[N+2];
  
  for(int i =0; i < N ; i++){
    A[i] = S.at(i);
  }
  
  if(A[0] == '?') A[0] = 'D';
  for(int i =1 ; i < N; i++){
    if(A[i] == '?'){
      if(A[i-1]== 'D'){
        if(A[i+1]== 'D' || A[i+1] == '?'){
          A[i] = 'P';
        }
        else A[i] = 'D';
      }
      else A[i] = 'D';
    }
  }
  for(int i =0; i <N; i++){
    cout << A[i];
  }
  cout << endl;
}


Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    while(cin >> n, n){
        vector<vector<int>> v(n, vector<int> (n+1));
        for (auto &&i : v) for (auto &&j : i) scanf("%d", &j);
        vector<int> dp(1<<n, INF<int>);
        dp[0] = 0;
        for (int i = 0; i < (1<<n); ++i) {
            for (int j = 0; j < n; ++j) {
                if(i & (1<<j)){
                    int k = i ^ (1<<j);
                    int x = v[j][0];
                    for (int l = 0; l < n; ++l) {
                        if(k & (1<<l)) x = min(x, v[j][l+1]);
                    }
                    dp[i] = min(dp[i], dp[k]+x);
                }
            }
        }
        cout << dp.back() << "\n";
    }
    return 0;
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    LL n;
    Solver(LL n):n(n){};

    void solve(){
        int ans=digsum(n);
        DBG(ans)
        LL k = 1e16;
        LL m =0;
        while(k>0){
            while(m+k<=n+1)m+=k;
            DBG(m)
            ans = max(ans,digsum(m-1));
            k/=10;
        }
        cout << ans <<"\n";

    }
    int digsum(LL a){
        int ret = 0;
        while(a>0){
            ret+=a%10;
            a/=10;
        }
        return ret;
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Problem::Solver sol(n);
    sol.solve();
    Problem::Writer::write();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    while (s.size() > 0) {
        s = s.substr(0, s.size() - 2);
        string s1 = s.substr(0, s.size() / 2);
        string s2 = s.substr(s.size() / 2);
        if (s1 == s2) {
            put(s.size());
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    SPEED;
    string str;
    cin >> str;
    for (int i = 0; i < str.size(); i++) {
        cout << 'x';
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

//int dp[1001][20001][11];

int main() {
    int D, G;
    cin >> D >> G;
    vint P(D + 1), C(D + 1);

    G = G / 100;
    rep(i, D) {
        cin >> P[i + 1] >> C[i + 1];
        C[i + 1] = C[i + 1] / 100;
    }
    v2int dp(D + 1, vint(G + 1, INF));
    dp[0][0] = 0;

    REP(i, 0, D) {
        rep(j, G) {
            if (dp[i][j] == INF) continue;
            int score;
            rep(k, P[i + 1]) {
                score = (i + 1) * k;
                dp[i + 1][min(G, j + score)] = min(dp[i + 1][min(G, j + score)], dp[i][j] + k);

            }
            score = P[i + 1] * (i + 1) + C[i + 1];
            dp[i + 1][min(G, j + score)] = min(dp[i + 1][min(G, j + score)], dp[i][j] + P[i + 1]);
        }
    }

    int ans = INF;
    rep(i, D + 1) {
        ans = min(dp[i][G], ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5248
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  long x = sc.nextLong();
  for(int i = 1;;i++){
    if(i*(i+1)/2 >= x){
      System.out.println(i);
      break;
    }
  }
}}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll a,b,x;
	cin>>a>>b>>x;
	ll res=b/x;
	if(a>0) res-=(a-1)/x;
	else res++;
	cout<<res<<'\n';
}




Measured memory_bytes: 3692
#include<stdio.h>
int main(void){
    int n,d,x,a[100],i,j,sum;
    scanf("%d %d %d",&n,&d,&x);
    sum=x;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        for(j=0;j<100;j++){
            if(j*a[i]+1<=d){
                sum++;
            }
            else{
                break;
            }
        }
    }
    printf("%d\n",sum);
	return 0;		
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n;
	int a, v;
	int max_a, max_v;
	int i;
	
	scanf("%d", &n);
	
	max_v = -1;
	
	for (i = 0; i < n; i++){
		scanf("%d %d", &a, &v);
		
		if (v > max_v || (v == max_v && a < max_a)){
			max_a = a;
			max_v = v;
		}
	}
	
	printf("%d %d\n", max_a, max_v);
	
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <stdio.h>
using namespace std;

int main() {
	int X; cin >> X;
	if (30 <= X) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(a) a.size()
#define INF 0x3f3f3f3f
#define de(x) cout<<#x<<"="<<x<<endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
using namespace std;
const int maxn=100005;
int n,i,j;
ll num[maxn],sum,ge;
int main()
{
	memset(num,0,sizeof(num));
	sum=0;
	
	scanf("%d",&n);
	num[0]=0;
	for(i=1;i<=n;i++){
		scanf("%lld",&num[i]);
	}
	sort(num,num+n+1);

	ge=0;
	for(i=1;i<=n;i++){
		if(num[i]!=num[i-1]){
			if(ge%2!=0)sum++;
			ge=1;
		}
		else{
			ge++;
		}
	}
	if(ge%2!=0)sum++;
	
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 3000;
vector<int>dp(2*maxn+1);
int n,m;
int32_t main(){
	IOS
	cin>>n>>m;
	vector<pair<int,int>>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i].first>>arr[i].second;
	}
	sort(arr.begin(),arr.end());
	for(int i=0;i<n;i++){
		int a = arr[i].first;
		int b = arr[i].second;
		for(int j=m-1;j>=0;j--){
			dp[a+j]=max(dp[a+j],dp[j]+b);
		}
	}
	int ans = 0;
	for(int i=0;i<=2*maxn;i++){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	
 }
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 3704
/*
AtCoder Beginner Contest 085 B - Kagami Mochi
Ver1
結果:
*/

#include<stdio.h>

//#define DEBUG1

int main() {
	int n, i, j;
	int d[100];
	int tmp,ans;
	int m = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
#ifdef DEBUG1
	for (int i = 0; i < n; i++) {
		printf("d[%d] = %d\n", i, d[i]);
	}
#endif
	for (i = 0; i<n; ++i) {
		for (j = i + 1; j<n; ++j) {
			if (d[i] > d[j]) {
				tmp = d[i];
				d[i] = d[j];
				d[j] = tmp;
			}
		}
	}
#ifdef DEBUG1
	for (int i = 0; i < n; i++) {
		printf("d[%d] = %d\n", i, d[i]);
	}
#endif

	for (int i = 0; i < n; i++) {
		if (d[i] == d[i + 1]) {
			m++;
		}
	}
#ifdef DEBUG1
	printf("m = %d\n", m);
#endif
	ans = n - m;


#ifdef DEBUG1
	printf("ans = %d\n", ans);
	getch();
#endif
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
A,B,C = map(int,input().split())
cnt = 0
while True:
    if A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        if A == B == C:
            print(-1)
            break
        else:
            a = A
            b = B
            c = C
            A = (b+c)//2
            B = (a+c)//2
            C = (a+b)//2
            cnt +=1
    else:
        print(cnt)
        break

Measured memory_bytes: 3064
//============================================================================
// Name        : d
// Date        : Wed Feb 20 09:23:06 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define pvi(x, v) if(v) pvar(x); fora(a, x) cout << a << " "; cout << "\n"
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void amax(ll &a, ll b) {
    a = max(a, b);
}

void solve_one() {
// dp[i][v] the maximum value we can get if the last consideration is ith item
// and the weight of knapsack is `v`.
    int n, w; cin >> n >> w;
    vi vv(n + 1), ww(n + 1);
    fori (i, 1, n + 1) {
        cin >> ww[i] >> vv[i];
    }

    vector<vl> dp(n + 1, vl(w + 1, 0));
    fori (i, 1, n + 1) {
        fori (v, 0, w + 1) {
            amax(dp[i][v], dp[i - 1][v]);
            if (v - ww[i] >= 0) {
                amax(dp[i][v], dp[i - 1][v - ww[i]] + vv[i]);
            }
        }
    }
    output(dp[n][w]);
}

void solve() {
// dp[i] the maximum value of items with their sum weight is `i`
    int n, w;
    cin >> n >> w;
    vl dp(w + 1, 0);
    fori (i, 0, n) {
        ll weight, value;
        cin >> weight >> value;
        ford (j, w - weight, -1) {
            amax(dp[j + weight], dp[j] + value);
        }
    }

    ll ret = 0;
    fori (i, 0, w + 1) {
        ret = max(ret, dp[i]);
    }
    output(ret);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
#define int unsigned long long
using namespace std;
int a[100005];
long double s=1;
signed main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<0;
			return 0;
		}
	}
	sort(a+1,a+n+1);
	for(int i=1; i<=n; i++)
	{
		s*=a[i];
		if(s>1000000000000000000)
		{
			cout<<-1;
			return 0;
		}
	}
	cout<<(long long)s;
	return 0;
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n[3];
	cin >> n[0] >> n[1] >> n[2];
	sort(n,n+3);
	cout << n[2]*10+n[1]+n[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }

int n, m, q, ans;
vector<int> A;
vector<array<int, 4>> req;
void dfs(int x){
    if(A.size() == n){
        int cnt = 0;
        for(auto& i : req) if(A[i[1]] - A[i[0]] == i[2]) cnt += i[3];
        chmax(ans, cnt);
        return;
    }
    for(; x <= m; x++){
        A.push_back(x);
        dfs(x);
        A.pop_back();
    }
}
int main(){
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        req.push_back({a, b, c, d});
    }
    dfs(1);
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,h,ans=0;
	cin>>n;
	int f[n];
	for(int i=0;i<n;i++) cin>>f[i];
	h=f[0];
	for(int i=0;i<n;i++)
	if(h<=f[i]) ans++,h=f[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a, n,i,j,p,m;
    cin>>n;
    vector<double>v;
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    p = v[0];
    for(i=1; i<v.size(); i++)
    {

        m = (p + v[i])/2;
        p = m;

    }

    cout<<p<<endl;








    return 0;
}


Measured memory_bytes: 3812
/* 
 * ALDS1_11B.cpp
 */
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int N;
int ad_k[101];
int ad_list[101][101];

int jikan = 0;
int d[101], f[101];
bool visited[101];

void visit(int id) {
    if (visited[id])
        return;

    visited[id] = true;
    d[id] = ++jikan;
    for (int i = 0; i < ad_k[id]; ++i) {
        visit(ad_list[id][i]);
    }
    f[id] = ++jikan;
}

int main(void) {

    scanf("%d", &N);
    for (int i = 1, id; i <= N; ++i) {
        scanf("%d", &id);
        scanf("%d", ad_k + id);
        for (int j = 0; j < ad_k[id]; ++j) {
            scanf("%d", ad_list[id] + j);
        }
    }

    for (int i = 1; i <= N; ++i) {
        visit(i);
    }

    for (int i = 1; i <= N; ++i) {
        printf("%d %d %d\n", i, d[i], f[i]);
    }

    return 0;
}

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

int main() {
	int prev = 4280;
	int w;
	while (cin >> w && w != -1) {
		int price = 0;
		if (w > 30) {
			price += (w - 30) * 160;
			w = 30;
		}
		if (w > 20) {
			price += (w - 20) * 140;
			w = 20;
		}
		if (w > 10) {
			price += (w - 10) * 125;
			w = 10;
		}
		price += 1150;
		cout << prev - price << endl;
	}

	return 0;
}

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

using namespace std;

const int N = 1e5 + 10;

int n,b;
int a[N];
int sum[N];
int main()
{
	cin >> n >> b;
	for (int i = 1; i <= n; i ++)
	{
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	int ans = 0;
	for (int i = 0; i <= n; i ++)
	{
		if(sum[i] <= b)
		ans ++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
ll X, K, D;

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

    cin >> X >> K >> D;
    ll ans = X;
    if(K > abs(X / D)) {
        ans = X % D;
        K -= X / D;
        if(K % 2 == 1) {
            ans = ans > 0 ? ans - D : ans + D;
        }
        // cout << X % D << endl;
    } else {
        ans = ans > 0 ? ans - D * K : ans + D * K;
        // cout << ans << endl;
    }
    cout << abs(ans) << endl;
    return 0;
}


Measured memory_bytes: 3612
S = input()
K = int(input())
Ans = []

while len(Ans) < K:
    for i in range(26):
        if chr(97+i) in S and chr(97+i) not in Ans:
            f = chr(97 + i)
            Ans.append(f)
            break

    for i, s in enumerate(S):
        if s == f:
            for j in range(2, 2 + 10):
                if i + j > len(S):
                    break
                if S[i:i+j] not in Ans:
                    Ans.append(S[i:i+j])
    Ans.sort()
print(Ans[K-1])




Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
// solveE();
 solveF();
  return 0;
}

Measured memory_bytes: 3604
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <utility>

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  printf("%d\n", n*(n-1)/2+m*(m-1)/2);
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//????????±?????¨??????
int lcs(string X, string Y) {
	static const int MAX_X = 1000, MAX_Y = 1000;
	static int dp[MAX_X + 1][MAX_Y + 1];
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= X.size(); i++) {
		for (int j = 1; j <= Y.size(); j++) {
			if (X[i - 1] == Y[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(
					dp[i - 1][j],
					dp[i][j - 1]
				);
			}
		}
	}
	return dp[X.size()][Y.size()];
}

//???????¢??????¨??????
int lis(int A[]) {
	static const int MAX_N = 100000;
	static int a[MAX_N];
	memset(a, 0x3f, sizeof(a));
	for (int i = 0; i < MAX_N; i++) {
		*lower_bound(a, a + MAX_N, A[i]) = A[i];
	}
	return find(a, a + MAX_N, INF) - a;
}

int main() {
	int A[100000] = {};
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	cout << lis(A) << endl;
	return 0;
}

Measured memory_bytes: 3908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[8] = { 0, 1, 0, -1, -1, 1, -1, 1 };

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

inline int gcd(int a, int b) { return (a%b == 0) ? b : gcd(b, a%b); }
inline int fac(int n) { return (n==0) ? 1 : n * fac(n - 1); }

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    for (int iy = 0; iy < h; iy++) {
        for (int ix = 0; ix < w; ix++) {
            if (s[iy][ix] == '#')
                continue;
            int cnt = 0;
            for (int m = 0; m < 8; m++)
            {
                int x = ix + dx[m];
                int y = iy + dy[m];
                if (0 <= x && x < w && 0 <= y && y < h) {
                    if (s[y][x] == '#') {
                        cnt++;
                    }
                }
            }
            s[iy][ix] = cnt + '0';
        }
    }

    for (int iy = 0; iy < h; iy++) {
        cout << s[iy] << endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string S;
	char A;
	int N, K, i;
	cin >> N >> S >> K;
	A = S[K-1];
	for (i = 0; i < N; i++) {
		if (S[i] != A)
			S[i] = '*';
}
	cout << S;


}

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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=1;

    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1])c++;
    }
    cout<<c<<'\n';
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    
    int n,x,min,sum;
    min=1000;
    sum=0;
    scanf("%d %d",&n,&x);
    int m[n];
    
    for(int i=0; i<n; i++){
        scanf("%d",&m[i]);
        sum+=m[i];
        
        if(min>m[i])
            min=m[i];
    }

    printf("%d",n+(x-sum)/min);

    return 0;
}

Measured memory_bytes: 128
if __name__ == '__main__':

    s = list(input())
    sr = list(reversed(s))
    a = s[0:(len(s) - 1) // 2]
    b = s[(len(s) + 3) // 2 - 1:]
    if s == sr and a == b:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
using System;

namespace ABC049_A_UOIAUAI
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] motherLanguage = new[] {"a", "i", "u", "e", "o"};
			string s = Console.ReadLine();

			for (int i = 0; i < 5; i++) {
				if (motherLanguage[i] == s)
				{
					Console.WriteLine("vowel");
					return;
				}
			}
			
			Console.WriteLine("consonant");
		}
	}
}

Measured memory_bytes: 11092
#include<iostream>

using namespace std;

int main()
{
	int m,n,a[1005],i,tot=0,grt=0,tt;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		tot+=a[i];
	}
	tt = tot/(4*m);
	if(tot%(4*m))	tt+=1;
	for(i=1;i<=n;i++)
	{
		if(a[i] >= tt)		grt++;
	}
	
	if(grt>=m)	cout<<"Yes"<<endl;
	else		cout<<"No"<<endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int S=s.size();
  int l=0,r=S-1;
  int cnt=0;
  while(1){
    if(l>=r)break;
    else if(s[l]==s[r]){l++; r--;}
    else if(s[l]=='x'){cnt++; l++;}
    else if(s[r]=='x'){cnt++; r--;}
    else{cout << -1 << endl; return 0;}
  }
  cout << cnt << endl;
}

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

int main(){
    int x;
    int ans;
    cin >> x;
    ans=0;
    int x2;
    x2=x;
    while(ans==0){
        if (x==2){
            ans=2;
            break;
        }
        rep(i,x2-2){
            if (x%(i+2)==0){
                break;
            }
            if (i==x2-3){
                ans=x;
            }
        }
        ++x;
    }
    cout << ans << endl;

    return 0;
}

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

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

	vector <int> v(3);

	cin >> v[0] >> v[1] >> v[2];

	sort(v.begin(),v.end());

	cout << (v[0]*v[1])/2 << '\n';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> SS(N), last(10, -1);
  for (int i = 0; i < N; i++) {
    SS[i] = S[i] - '0';
    last[S[i] - '0'] = i;
  }
  int ans[1000] = {};
  int visited[100] = {};
  int visited2[10] = {};
  for (int i = 0; i < N; i++) {
    if (visited2[SS[i]]) continue;
    visited2[SS[i]] = 1;
    for (int j = i + 1; j < N; j++) {
      if (visited[SS[i] * 10 + SS[j]]) continue;
      visited[SS[i] * 10 + SS[j]] = 1;
      for (int k = 0; k < 10; k++) {
        if (j < last[k]) {
          ans[SS[i] * 100 + SS[j] * 10 + k] = 1;
        }
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < 1000; i++)
    if (ans[i] > 0) ret++;
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
char str[200][200]={};
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int i,j,H,W;
	string s;
	cin >> H;
    cin >> W;
    //cout << H << W << endl;
    for(i=0;i<H+2;i++){
        for(j=0;j<W+2;j++){
            str[i][j]='#';
        }
    }
    for(i=0;i<H;i++){
        cin >> s;
        for(j=0;j<W;j++){
            str[i+1][j+1]=s[j];
        }
    }
    for(i=0;i<H+2;i++){
        cout << str[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int bfs(vector<vector<char>> &ar, P p, int h, int w){
    vector<vector<int>> co(h, vector<int>(w,500));
    co[p.first][p.second] = 0;
    int ans = 0;
    vector<int> dx = {0,1,0,-1};
    vector<int> dy = {1,0,-1,0};
    queue<P> q;
    q.push(p);
    while (!q.empty()){
        P pq = q.front();q.pop();
        int x = pq.first;
        int y = pq.second;
        int cost = co[x][y];
        rep(i,4){
            if (range(0,h,x+dx[i]) && range(0,w,y+dy[i])){
                if (ar[x+dx[i]][y+dy[i]] == '.' && co[x+dx[i]][y+dy[i]] == 500){
                    co[x+dx[i]][y+dy[i]] = cost+1;
                    q.push(P(x+dx[i],y+dy[i]));
                    ans = max(ans, cost+1);
                }
            }
        }
    }
    return ans;
}

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> maze(h, vector<char>(w));
    rep(i,h)rep(j,w) cin >> maze[i][j];
    int ans = 0;
    rep(i,h){
        rep(j,w){
            if (maze[i][j] == '.'){
                P st = P(i,j);
                ans = max(ans, bfs(maze,st,h,w));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  string s;
  std::cin >> s;
  int a,b;
  a=stoi(s.substr(0,2));
  b=stoi(s.substr(2,2));
  if(a>=1&&a<=12){
    if(b>=1&&b<=12){
      std::cout << "AMBIGUOUS" << std::endl;
    }
    else{
      std::cout << "MMYY" << std::endl;
    }
  }
  else {
    if(b>=1&&b<=12){
      std::cout << "YYMM" << std::endl;
    }
    else{
      std::cout << "NA" << std::endl;
    }
  }
  //std::cout << a<<b << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

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

    cout << a+a*a+a*a*a << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3584
/* Press F to pay respects */
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;
typedef vector< vi > vvi;
int modular_exp(int base,int exp,int mod)
{
    int ans =1;
    while(exp)
    {
        if(exp%2)   ans = ans%mod*base%mod;
        base = (base%mod*base%mod)%mod;
        exp/=2;
        ans%=mod;
    }
    return ans;
}
int inverse_modulo(int base,int mod)
{
	return modular_exp(base,mod-2,mod);
}
vvi multiply(vvi &a, vvi &b, int mod = MOD)
{
	int n = sz(a);
	vvi res;
	res.resize(n);
	for(int i = 0; i < n; i++)
	{	
		res[i].resize(n);
		for(int j = 0; j < n; j++)
		{
			int cnt = 0;
			for(int k = 0; k < n; k++)
			{
				cnt += a[i][k]*b[k][j];
				cnt %= mod;
			}
			res[i][j] = cnt;
		}
	}
	return res;
}

int32_t main()
{
	SYNC
	int n,k; cin >> n >> k;
	vvi g,res;
	g.resize(n);
	res.resize(n);
	for(int i = 0; i < n; i++){
		g[i].resize(n);
		res[i].resize(n,0);
		res[i][i] = 1;
		for(int j = 0; j < n; j++)	cin >> g[i][j];
	}
	while(k)
	{
		if(k%2)	res = multiply(res,g);
		g = multiply(g,g);
		k /= 2;
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			ans += res[i][j];
			ans %= MOD;
		}
	}
	cout << ans;
    return 0;
}

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

const int N = 110000;

int a[N], sum[N];
int BIT[3 * N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	int st = 0, en = 1e9, mid, ans = en;
	
	auto add = [&](int u, int v) {
		for (int i = u; i <= 3 * (n + 1); i += i & -i) BIT[i] += v;
	};
	
	auto get = [&](int u) {
		int ret = 0;
		for (int i = u; i > 0; i -= i & -i) ret += BIT[i];
		return ret;
	};
	
	auto can = [&](int mid) {
		sum[0] = 0;
		for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + 2 * (a[i] <= mid);
		for (int i = 0; i <= 3 * (n + 1); i++) BIT[i] = 0;
		long long cnt = 0;
		add(0 + n + 1, 1);
		for (int i = 1; i <= n; i++) {
			cnt += get(sum[i] - i + n);
			add(sum[i] - i + n + 1, 1);
		}
		return cnt * 2 > (long long)n * (n + 1) / 2;
	};
	
	while (st <= en) {
		mid = st + en >> 1;
		if (can(mid)) ans = mid, en = mid - 1;
		else st = mid + 1;
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 5560
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e6+10;
int n,cnt[N],sum[N],tmp=2,ans;
char a[N];
int main() {
	scanf("%d",&n); n--;scanf("%s",a);
	for(int i=0;i<=n;i++) {
		a[i]-='1';
		if(a[i]==1) tmp=1;
	}
	for(int i=1;i<=n;i++) 
		sum[i]=sum[i-1]+(cnt[i]=(i&1?0:cnt[i>>1]+1));
	for(int i=0;i<=n;i++)
		if(sum[n]==sum[i]+sum[n-i])
			(ans+=a[i]/tmp)&=1;
	printf("%d\n",ans*tmp); return 0;
}


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

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, k,ans = 1;
    cin >> n >> k;
    while(n >= k){
        n /= k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;
 
class process {
 
    private String name;
    private int time;
     
    public process(String name,int time){
        this.name = name;
        this.time = time;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getName() {
        return name;
    }
 
    public void setTime(int time) {
        this.time = time;
    }
 
    public int getTime() {
        return time;
    }
}
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int q = sc.nextInt();
 
        ArrayList<process> ar = new ArrayList<process>();
        ArrayList<process> result = new ArrayList<process>();
         
        for (int i = 0; i < n; i++){
            ar.add(new process(sc.next(),Integer.parseInt(sc.next())));
        }
         
        int LapsedTime = 0,i = 0;
        process p;
         
        while(true){
            if(i < n){
                if((p = ar.get(i)).getTime() - q <= 0){
                    LapsedTime += p.getTime();
                    result.add(new process(p.getName(),LapsedTime));
                    ar.remove(i);
                    n--;
                } else {
                    LapsedTime += q;
                    p.setTime(p.getTime() - q);
                    i++;
                }
            } else {
                i = 0;
            }
            if (n == 0){
                break;
            }
        }
        for(process r:result) {
            System.out.println(r.getName() + " " + String.valueOf(r.getTime()));
        }
    }
}

Measured memory_bytes: 72872
n=int(input())
ans=0
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
table=num_divisors_table(n)
for i in range(1,n):
    ans+=table[n-i]
print(ans)

Measured memory_bytes: 16736