akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

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

template <class T, class Compare>
vector<int> sort_index(const vector<T>& v, Compare comp) {
    vector<int> index(v.size());
    REP(i, v.size()) index[i] = i;
    sort(ALL(index), [&](int i, int j) { return comp(v[i], v[j]); });
    return index;
}

template <typename Int>
struct FenwickTree {
    vector<Int> data;
    explicit FenwickTree(int n): data(n, 0) {}
    void add(int i, Int x) {
        for (; i < (int)data.size(); i |= i+1)
            data[i] += x;
    }
    Int sum(int i) const {
        Int s = 0;
        for (; i >= 0; i = (i & (i+1)) - 1)
            s += data[i];
        return s;
    }
    Int sum(int a, int b) const { // inclusive
        return (a == 0) ? sum(b) : sum(b) - sum(a-1);
    }
};

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

    int N, Q; cin >> N >> Q;
    vector<int> C(N);
    REP(i, N) cin >> C[i];
    vector<pair<int, int>> queries(Q);
    REP(i, Q) {
        cin >> queries[i].first >> queries[i].second;
        queries[i].first--; queries[i].second--;
    }

    auto index = sort_index(queries, [](const auto& p1, const auto& p2) {
        return make_pair(p1.second, p1.first) < make_pair(p2.second, p2.first);
    });

    // 色 → その色を持つ玉の中で最も右にある玉の位置
    vector<int> rightmost(N+1, -1);
    // その位置に最右玉が存在するなら 1、そうでないなら 0
    FenwickTree<int> ft(N);

    vector<int> ans(Q);
    int k = 0;
    REP(x, N) {
        // データ構造を更新
        int c = C[x];
        int old_pos = rightmost[c];
        int new_pos = x;
        if (old_pos != -1) ft.add(old_pos, -1);
        ft.add(new_pos, 1);
        rightmost[c] = new_pos;

        // クエリを処理
        for (; k < Q && queries[index[k]].second == x; ++k) {
            auto [l, r] = queries[index[k]];
            ans[index[k]] = ft.sum(l, r);
        }
    }

    REP(i, Q) cout << ans[i] << '\n';
}


Measured memory_bytes: 17400
import itertools
N=int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
p=0
q=0
p_flag=False
q_flag=False
anslist=list(range(1,N+1))
li=list(map(list,itertools.permutations(anslist)))
for i in range(len(li)):
  if P==li[i]:
    p=i
    p_flag=True
  if Q==li[i]:
    q=i
    q_flag=True
  if p_flag and q_flag:
    break
print(abs(p-q))

Measured memory_bytes: 10228
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define pai 3.141592653589793238462643383279





int main(){
  ll N, K; cin >> N >> K; ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  ll T = min(100LL, K);
  rep(f, T){
    ll b[N+1] = {};
    rep(i, N){
      b[max(0LL, i-a[i])]++;
      b[min(N, i+a[i]+1)]--;
    }
    rep(i, N-1){
      b[i+1]+=b[i];
    }
    rep(i, N){
      a[i] = b[i];
    }
    //rep(i, N){
      //cout << a[i]; cout << " ";
    //}
    //cout << endl;
  }
  K-=T;
  rep(i, N){
    if(i!=0) cout << " "; cout << a[i];
  }
  cout << endl;
}

Measured memory_bytes: 6776
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N;
    cin >> N;
    vec A(N), B(N);
    Rep (i, N) {
        cin >> A[i];
    }

    iota(B.begin(), B.end(), 0);

    sort(B.begin(), B.end(), [&](ll a, ll b) {return A[a] >= A[b];});

    mat dp(N+1, vec(N+1, 0));

    Rep (i, N) {
        Rep (j, i+1) {
            chmax(dp[i+1][j+1], dp[i][j]+A[B[i]]*abs(j-B[i]));
            chmax(dp[i+1][j], dp[i][j]+A[B[i]]*abs(N-1-i+j-B[i]));
        }
    }

    // Rep (i, N+1) {
    //     Rep (j, N+1) {
    //         cout << dp[i][j] << " \n"[j==N];
    //     }
    // }

    ll ans = 0;
    Rep (i, N+1) {
        chmax(ans, dp[N][i]);
    }

    cout << ans << endl;
}

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

const long mod = 1000000000 + 7;

long frac(long n){
  long ret = 1;
  if(n == 0 || n == 1){
    ret = 1;
  }
  
  while(n > 0){
    ret = ret * n;
    ret = ret % mod;
    n = n-1;
  }
  
  return ret;
}

int main(){
  long n,m;
  cin >> n >> m;
  long ans = 0;
  if(abs(n-m) > 1){
    ans = 0;
  }
  if(n == m+1 || m == n+1){
    ans = frac(n) * frac(m);
    ans %= mod;
  } 
  if(n == m){
    ans = frac(n) * frac(n);
    ans %= mod;
    ans = ans * 2;
    ans %= mod;
  }
  // cerr << frac(4) << endl;
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();

    	String s = String.valueOf(N);

    	boolean flag = s.contains("7");

    	if(flag) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}


    }
}


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

int main() {
  long long N;
  long long Ans=0;
  cin>>N;
  vector<long long> vec(N);
  vector<long long> count(N+1);
  rep(i,N){cin>>vec.at(i);
          count.at(vec.at(i))++;}
  rep(i,N){Ans+=count.at(i+1)*(count.at(i+1)-1)/2;}
  
  rep(i,N){cout<<Ans-count.at(vec.at(i))+1<<endl;}
  
}

Measured memory_bytes: 6428
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <set>
#include <iomanip>
#include <cmath>
#define mp make_pair
#define pb push_back
#define ll long long
const int INF = 1e9 + 7;
const int MAXN = 2e5 + 10;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string st;
    cin >> st;
    map <char, bool> used;
    for (int i = 0; i < st.size(); i++) {
        used[st[i]] = true;
    }
    for (char i = 'a'; i <= 'z'; i++) {
        if (!used[i]) {
            cout << st <<i;
            return 0;
        }
    }

    while (!st.empty()) {
        for (char i = st.back() + 1; i <= 'z'; i++) {
            if (!used[i]) {
                st.pop_back();
                cout << st << i;
                return  0;
            }
        }
        used[st.back()] = false;
        st.pop_back();
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 764
#!/usr/bin/perl

$c500 = <STDIN>;
$c100 = <STDIN>;
$c50 = <STDIN>;
$amount = <STDIN>;
$count = 0;

for ($i = 0; $i <= $c500; $i++) {
        if ($i * 500 > $amount) {
                last;
        }
        for ($j = 0; $j <= $c100; $j++) {
                if ($i * 500 + $j * 100 > $amount) {
                        last;
                }
                if ($i * 500 + $j * 100 + $c50 * 50 < $amount) {
                        next;
                }
                for ($k = 0; $k <= $c50; $k++) {
                        if ($i * 500 + $j * 100 + $k * 50 == $amount) {
                                $count++;
                                last;
                        }
                }
        }
}

print "$count\n";


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n;
ll a[301];
ld dp[301][301][301];

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

    cin >> n;

    cout << fixed;
    cout << setprecision(10);
    
    ll x = 0;
    ll y = 0;
    ll z = 0;

    rep(i,n)
    {
        cin >> a[i];
        if(a[i]==1)
            x++;
        else if(a[i]==2)
            y++;
        else
            z++;
    }
    fr(i,0,n)
    {
        if(i>z)
            continue;
        fr(j,0,n)
        {
            if(i+j>y+z)
                continue;
            fr(k,0,n)
            {
                if(i+j+k>x+y+z)
                    continue;

                ld xx = (ld)(i+j+k);
                bool hu = 0;
                if(k!=0)
                {
                    hu = 1;
                    dp[k][j][i] = dp[k][j][i] + (((ld)k/xx))*dp[k-1][j][i];
                }
                if(j!=0)
                {
                    hu = 1;
                    dp[k][j][i] = dp[k][j][i] + (((ld)j/xx))*dp[k+1][j-1][i];
                }
                if(i!=0)
                {
                    hu = 1;
                    dp[k][j][i] = dp[k][j][i] + (((ld)i/xx))*dp[k][j+1][i-1];
                }

                if(hu)
                {
                    ld xxx = (ld)n/xx;
                    dp[k][j][i] = dp[k][j][i] + xxx;
                }

                // cout << dp[k][j][i] << " " << k << " " << j << " " << i << endl;
            }
        }
    }

    cout << dp[x][y][z] << endl;
}

Measured memory_bytes: 213248
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    if (A == 1 && B == 2 || A == 2 && B == 1) {
      System.out.print("3");
    } else if (A == 2 && B == 3 || A == 3 && B == 2) {
      System.out.print("1");
    } else if (A == 1 && B == 3 || A == 3 && B == 1) {
      System.out.print("2");
    }
  }
}

Measured memory_bytes: 19796
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n+1,0);

  for(int i=0;i<n;i++){
    cin>>a.at(i);
    a.at(i)=a.at(i)-i+1;
  }
  sort(a.begin(),a.end());

  int tmp=a.at(n/2);
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=abs(a.at(i)-tmp);
  }
  cout<<sum<<endl;
  //cout<<endl;



  return 0;
}


Measured memory_bytes: 1792
#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[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -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) { if (a%b == 0) { return b; } else { return gcd(b, a%b); } }

int main() {
    int n;
    cin >> n;
    int t[n+1], x[n+1], y[n+1];
    t[0] = x[0] = y[0] = 0;
    bool judge = true;
    for (int i = 1; i < n + 1; i++) {
        cin >> t[i] >> x[i] >> y[i];
        int t_dis = (t[i] - t[i - 1]) - ( abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) );
        judge = judge ? (t_dis % 2 == 0) && (t_dis >= 0) : false;
    }

    cout << (judge ? "Yes" : "No") << endl;
    return 0;
}

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

#define int long long 

queue<int> q;
set<int> vis;

bool check(int n){
     set<int> bc;
     while(n > 0){
         bc.insert(n%10);n /= 10;
     }
     return (bc.size() == 3);
}

signed main() {
    int n;
    cin >> n;
    q.push(0);
    while(!q.empty()){
        int v,tmp;
        int u = q.front();q.pop();
       // cout << u << endl;
        tmp = 3;
        v = 10*u+tmp;
        if(v < 1e9 && vis.find(v) == vis.end()){
            vis.insert(v);
            q.push(v);
        }
        tmp = 5;
        v = 10*u+tmp;
        if(v < 1e9 && vis.find(v) == vis.end()){
            vis.insert(v);
            q.push(v);
        }
        tmp = 7;
        v = 10*u+tmp;
        if(v < 1e9 && vis.find(v) == vis.end()){
            vis.insert(v);
            q.push(v);
        }
        int lg = log10(u);
        lg++;
        tmp = 3;
        v = u+pow(10,lg)*tmp;
        if(v < 1e9 && vis.find(v) == vis.end()){
            vis.insert(v);
            q.push(v);
        }
        tmp = 5;
        v = u+pow(10,lg)*tmp;
        if(v < 1e9 && vis.find(v) == vis.end()){
            vis.insert(v);
            q.push(v);
        }
        tmp = 7;
        v = u+pow(10,lg)*tmp;
        if(v < 1e9 && vis.find(v) == vis.end()){
            vis.insert(v);
            q.push(v);
        }
    }
    auto it = vis.begin();
    int ans = 0;
    while(it != vis.end()){
        int cur = *it;
        if(cur <= n && check(cur))ans++;
        it++;
    }
    cout << ans;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long a, b;
  cin >> n >> a >> b;
  vector<long long> x(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> x[i];
  }
  vector<long long> dp(n, 0);
  dp[0] = 0;
  for(int i = 1; i < n; i++)
  {
    dp[i] = min(a * (x[i] - x[i - 1]), b) + dp[i - 1];
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll>>> net(n);
    for(int i = 0; i < m; ++i){
        ll l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        net.at(l).push_back(make_pair(r, d));
        net.at(r).push_back(make_pair(l, -d));
    }

    vector<bool> touched(n, false);
    vector<ll> pos(n);
    for(int i = 0; i < n; ++i){
        if(touched.at(i)){ continue; }
        queue<ll> q;
        touched.at(i) = true;
        q.push(i);
        while(!q.empty()){
            ll p = q.front();
            q.pop();
            for(auto n : net.at(p)){
                if(touched.at(n.first)){
                    if(pos.at(n.first) != pos.at(p) + n.second){
                        cout << "No" << endl;
                        return 0;
                    }
                }else{
                    pos.at(n.first) = pos.at(p) + n.second;
                    touched.at(n.first) = true;
                    q.push(n.first);
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 14080
(let* ((n (read))
       (arr (make-array n
                        :element-type 'fixnum
                        :initial-element 0))
       (ans 0))

  (loop for i from 0 to (1- n)
        do (setf (aref arr i) (1- (read))))

  (defun f (k)
    (cond ((< n ans) (princ "-1"))
          ((= k 1) (princ ans))
          (t (incf ans) (f (aref arr k)))))

  (f 0))




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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i=0;i<26;i++) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    //ここで日程を決定する==========
    for (int i=0;i<D;i++){
        t[i] = i%26 + 1;
    }
    //=============================
    //for (int i=0;i<D;i++) cin >> t[i];
    //vector<int> last(26);
    //ll sum = 0;
    //for (ll i=0;i<D;i++){
    //    sum += s[i][t[i]-1];
    //    last[t[i]-1] = i+1;
    //    for (int j=0;j<26;j++){
    //        sum -= c[j]*(i+1-last[j]);
    //    }
    //    cout << sum << "\n";
    //}

    for (int i=0;i<D;i++){
        cout << t[i] << "\n";
    }
}

Measured memory_bytes: 3668
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        }
    }
}

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


int main() {
  int N, K;
  cin >> N >> K;

  vector<int> cnt(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    cnt.at(a - 1)++;
  }

  sort(cnt.begin(), cnt.begin() + N);

  int ans = 0;
  for (int i = 0; i < (N - K); i++) {
    ans += cnt.at(i);
  }

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

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MAX_V = 3000;
const int IINF = INT_MAX;
typedef pair<int,int> ii;

map<ii,int> mp; /////////

struct Edge{ int to,cap,rev; bool isRev; };

vector<Edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((Edge){to,cap,G[to].size(),false});
  G[to].push_back((Edge){from,0,G[from].size()-1,true});
}

int dfs(int v,int t,int f){
  if( v == t ) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    Edge &e = G[v][i];
    if( !used[e.to] && e.cap > 0 ){
      int d = dfs(e.to,t,min(f,e.cap));
      if( d > 0 ){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s,t,IINF);
    if( f == 0 ) return flow;
    flow += f;
  }
}

vector<int> G2[MAX_V],rG2[MAX_V];
bool visited[2][MAX_V];

void init(int _size=MAX_V){ rep(i,_size) G[i].clear(), G2[i].clear(), rG2[i].clear(); }

int V,E;

void icompute(int s,bool used[MAX_V],int type){
  used[s] = true;
  deque<int> deq;
  deq.push_back(s);
  while( !deq.empty() ){
    int cur = deq.front(); deq.pop_front();
    rep(i,(int)(type?G2[cur].size():rG2[cur].size())){
      int next = type?G2[cur][i]:rG2[cur][i];
      if( !used[next] ) {
	used[next] = true;
	deq.push_back(next);
      }
    }
  }
}

void compute(int let,int go){
  int maxi = max_flow(let,go);
  rep(i,V) {
    int s = i;
    rep(j,(int)G[i].size()) if( G[i][j].cap ) {
      int t = G[i][j].to, c = G[i][j].cap;
      G2[s].push_back(t), rG2[t].push_back(s);
    }
  }

  memset(visited,false,sizeof(visited));
  icompute(let,visited[0],1);
  icompute(go ,visited[1],0);

  int cnt = 0;
  rep(i,V) rep(j,(int)G[i].size()) if( G[i][j].cap && !G[i][j].isRev ) {
    if( visited[0][G[i][j].to] && visited[1][i] ) ++cnt;
  }
  cout << maxi + ( cnt > 0 ) << " " << cnt << endl;
}

int main(){
  int s,t;
  while( cin >> V >> E >> s >> t, V|E|s|t ) {
    --s, --t;
    init(V);
    set<ii> S;
    rep(i,E) {
      int a,b;
      scanf("%d %d",&a,&b);
      --a, --b;
      add_edge(a,b,1);
    }
    compute(s,t);
  }
  return 0;
}

Measured memory_bytes: 2400
using System;

public class Solution{

       static int[]strToIntArr(String s){
//          s = s.Substring(1,s.Length-2);
	  string[] strArr = s.Split(new char[]{' '});
	  int len = strArr.Length;
          int[] retArr = new int[len];       
	  for(int i=0;i<len;i++){
	     string sVal = strArr[i];
	     int intVal = int.Parse(sVal);
	     retArr[i] = intVal;
	  }
          return retArr;
       }

       public int maxDiff(int n, int k){
          int retV = 0;
	  if(k!=1){
 	     retV = n-k;
	  }
	  return retV;
       }

       public static void Main(string[]args){
          Solution s = new Solution();
	  string nkLn = Console.ReadLine();
	  int[]nkArr = strToIntArr(nkLn);
	  int md = s.maxDiff(nkArr[0],nkArr[1]);
	  Console.WriteLine("{0}",md.ToString());
       }
}

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


int main(){
  int N;
  cin >> N ;
  if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
    cout << "hon" << endl;
  }
  else if(N%10==0||N%10==1||N%10==6||N%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }

  return 0;
}


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

#include <string>

bool check_kaibun(string& s) {
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != s[s.size() - 1 - i]) {
            return false;
        }
    }
    return true;
}

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

    // for (int i = 0; i < (s.size() - 1) / 2; ++i) {
    //     if (s[i] != s[s.size() - 1 - i]) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }

    // int short_size = (s.size() - 1) / 2;
    // if (short_size % 2 != 1) {
    //     cout << "No" << endl;
    //     return 0;
    // }

    // for (int i = 0; i < (short_size - 1) / 2; ++i) {
    //     if (s[i] != s[short_size - 1 - i]) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }
    // cout << "Yes" << endl;

    if (!check_kaibun(s)) {
        cout << "No" << endl;
        return 0;
    }

    int short_size = (s.size() - 1) / 2;
    string tmp_s = s.substr(0, short_size);
    if (!check_kaibun(tmp_s)) {
        cout << "No" << endl;
        return 0;
    }

    tmp_s = s.substr(short_size + 1, short_size);
    if (!check_kaibun(tmp_s)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}



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

int a[200], n, r, cntr, mn = 40;
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cntr = 0;
		r = a[i] % 2;
		while(r == 0){
			cntr++;
			a[i] = a[i] / 2;
			r = a[i] % 2; 
		}
		if (mn > cntr){ mn = cntr; }
	}
	cout << mn << endl;
}


Measured memory_bytes: 3636
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)
  exit()
  
# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# x, n = 1, 1
# # p = list(range(1, 101))
# p = [1]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
if len(np) == 0:
  print(x)
  exit()
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = np[0]
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9+5;
int32_t main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    string a;
    string b;
    cin>>a;
    cin>>b;
    int n = a.length();
    int m = b.length();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i = 0; i <= n; i++) dp[i][0] = 0;
    for(int j = 0; j <= m; j++) dp[0][j] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i-1] == b[j-1]) dp[i][j] = 1 +dp[i-1][j-1];
            else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string lcs = "";
    int i = n,j = m;
    while(i > 0 && j > 0){
        if(a[i-1] == b[j-1]){
            lcs += a[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
    reverse(lcs.begin(),lcs.end());
    cout<<lcs;
}

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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    x /= 50;

    int cnt = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            if(10*i+2*j <= x && x-10*i-2*j <= c)    cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int a,n[3];
	int i;
	bool f;

	cin >> n[0]>>n[1];

	if (n[0] > n[1]) {
		i = n[0];
		n[0] = n[1];
		n[1] = i;
	}//swap (n0<n1)

	cin >> n[2];
	/*for (i = 0; i < 3; i++)cout << n[i];
	cout << endl;*/
	if (n[2] >= n[1])f = true;
	else f = false;

	if (f)cout << 10 * n[2] + n[1] + n[0] << endl;
	else cout << 10 * n[1] + n[0] + n[2] << endl;


	return 0;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int digit(int n)
{
  int res = 0;
  while(n){
    res += n % 10;
    n /= 10;
  }
  return res;
}

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

  int ans = 10000000;
  rep(i, 1, N){
    int sum = 0;
    sum += digit(i);
    sum += digit(N - i);
    ans = min(ans, sum);
  }

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

vector<pi> v;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	int N;
	while(cin>>N && N){
		v.clear();
		v.pb(mp(-1,INF));
		rep(i,N){
			char c;
			cin>>c;
			
			if(c=='W'){
				int l,S;
				cin>>l>>S;
				vector<pi> w;
				rep(i,sz(v)){
					if(v[i].fir==-1){
						if(S==0){
							w.pb(v[i]);
						}else if(S<=v[i].sec){
							w.pb(mp(l,S));
							w.pb(mp(-1,v[i].sec-S));
							S=0;
						}else{
							w.pb(mp(l,v[i].sec));
							S-=v[i].sec;
						}
					}
					else{
						w.pb(v[i]);
					}
				}
				v=w;
			}
			
			if(c=='D'){
				int l;
				cin>>l;
				vector<pi> w;
				rep(i,sz(v)){
					if(v[i].fir==l){
						w.pb(mp(-1,v[i].sec));
					}else{
						w.pb(v[i]);
					}
				}
				v=w;
			}
			
			if(c=='R'){
				int P;
				cin>>P;
				rep(i,sz(v)){
					if(P<=v[i].sec-1){
						cout<<v[i].fir<<endl;
						break;
					}
					P-=v[i].sec;
				}
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 10;
int n, m, k;
char w[maxn][maxn];
int res;
int cal(int a, int b) {
	int res = 0;
	for (int i = 0;i < n;++i) if ((1<<i) & a)
		for (int j = 0;j < m;++j) if ((1<<j) & b)
				res += w[i][j] == '#';
	return res;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m >> k;
	for (int i = 0;i < n;++i)
		cin >> w[i];
	for (int i = 0;i < 1<<n;++i)
		for (int j = 0;j < 1<<m;++j)
			res += cal(i, j) == k;
	cout << res << '\n';
}



Measured memory_bytes: 3660
require 'pp'

class Reversi
  attr_accessor :width, :height, :turn, :board
  BLACK = 1
  WHITE = 2
  DX = [-1,-1,-1, 0, 0, 1, 1, 1]
  DY = [-1, 0, 1,-1, 1,-1, 0, 1]
  
  def initialize(width = 8, height = 8)
    @width = width
    @height = height
    @board = Array.new(@height).map!{Array.new(@width, 0)}
    @turn = BLACK
    @colornum = 2
  end

  def check(color=@turn)
    point = Struct.new(:x, :y);
    ar = []
    for i in 0..@height-1
      for j in 0..@width-1
        ar.push point.new(j, i) if put_stone(color, j, i, false) >= 1
      end
    end
    return ar
  end
  
  # 0 => もう置けない
  def next_color()
      turn = @turn
      @colornum.times{
        turn = (turn%2)+1
        return turn if check(turn).size > 0
      }
      return 0
  end
  
  # -1 => 置けない  0 => ゲーム終了  それ以外 => 次の手番
  def put(x, y)
    return 0 if @turn == 0
    if put_stone(@turn, x, y) then
      @turn = next_color
      return @turn
    end
    return -1
  end
  
  def put_stone(color, x, y, put = true) # putがfalseの時は置けるか調べるだけ
    point = Struct.new(:x, :y);

    return 0 if @board[y][x] != 0 # 置く場所をチェック
    queue = [point.new(x,y)]    # 石が変わる座標をqueueで持つ
    
    # 8方向を調べる
    8.times{|i|
      cnt = 0 # 返す石の数
      for j in 1..[@width,@height].max
        nx = x + DX[i] * j
        ny = y + DY[i] * j
        break if nx < 0 || nx >= @width || ny < 0 || ny >= @height # 配列外チェック
        break if @board[ny][nx] == 0                  # 石が無いなら次へ
        break if @board[ny][nx] == color && cnt == 0  # ひっくり返せないなら次へ
        if @board[ny][nx] == color then # ひっくり返せるなら、ひっくり返す
          for k in 1..cnt
            queue.push point.new(x+DX[i]*k, y+DY[i]*k)
          end
          break
        end
        cnt += 1
      end
    }
    
    revnum = queue.size-1 # 返す石の数
    

    if put then
      until queue.empty?  # 石を返す処理
        p = queue.shift
        @board[p.y][p.x] = color
      end
    end
    
    return revnum
  end
end


rev = Reversi.new

input = []
8.times{
  input.push gets.chomp.gsub('o', '1 ').gsub('x', '2 ').gsub('.', '0 ').split(nil).map(&:to_i)
}

rev.board = input

rev.turn = rev.next_color if rev.check.size <= 0

while rev.turn >= 1
  best = 0
  x = 0
  y = 0
  8.times{|i|
    8.times{|j|
      cnt = rev.put_stone(rev.turn, j, i, false)
      if (rev.turn == 2 && best <= cnt) || (rev.turn == 1 && best < cnt) then
        y = i
        x = j
        best = cnt
      end
    }
  }
  rev.put(x, y)
end

rev.board.each{|e|
  puts e.join.to_s.gsub('1', 'o').gsub('2', 'x').gsub('0', '.')
}

Measured memory_bytes: 8472
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;

int N, M;

vector< vector<int> > rotate(vector< vector<int> > &m){
  vector< vector<int> > res(M, vector<int>(M));
  REP(i, M) REP(j, M) res[i][j] = m[M - j - 1][i];
  return res;
}

P result(int ny, int nx, vector< vector<int> > &m){
  REP(i, M) REP(j, M) if(m[i][j] != -1) return P(j + nx + 1, i + ny + 1);
  return P(-1, -1);
}

P solve(vector< vector<int> > &n, vector< vector<int> > &m){
  REP(ny, N - M + 1){
    REP(nx, N - M + 1){
      REP(i, 4){
        bool f = true;
        REP(y, M) REP(x, M) if(m[y][x] != -1 && n[ny + y][nx + x] != m[y][x]) f = false;
        if(f) return result(ny, nx, m);
        m = rotate(m);
      }
    }
  }
  return P(-1, -1);
}

int main() {
  while(cin >>N >>M && N && M){
    vector< vector<int> > n(N, vector<int>(N)), m(M, vector<int>(M));
    REP(i, N) REP(j, N) cin >>n[i][j];
    REP(i, M) REP(j, M) cin >>m[i][j];
    P res = solve(n, m);
    if(res.first == -1) cout <<"NA" <<endl;
    else cout <<res.first <<" " <<res.second <<endl;
  }
  return 0;
}

Measured memory_bytes: 1284
A,B,M = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans=min(a)+min(b)

for i in set(range(M)):
    x,y,c = map(int, input().split())
    ans = min(ans,a[x-1]+b[y-1]-c)
print(ans)

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

int main() {
    int r, c;
    cin >> r >> c;
    int A[102][102];
    
    for (int i = 1; i <= r; i++) {
        int total = 0;
        for (int j = 1; j <= c; j++) {
            cin >> A[i][j];
            total += A[i][j];
        }
        A[i][c+1] = total;
    }
    
    for (int i = 1; i <= c+1; i++) {
        int total= 0;
        for (int j = 1; j <= r; j++) {
            total += A[j][i];
        }
        A[r+1][i] = total;
    }
    
    for(int i = 1; i <= r+1; i++) {
        for (int j = 1; j <= c+1; j++) {
            if (j == c + 1) {
                cout << A[i][j] << endl;
            } else {
                cout << A[i][j] << " ";
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3132
#include <stdio.h>

int b[2000][1000];
int s[2001][1001];

#define calc(x, y, w, h) (s[(x)+(w)][(y)+(h)] - s[(x)+(w)][(y)] - s[(x)][(y)+(h)] + s[(x)][(y)])

int main(void){
    int n, k;
    int x, y;
    char c;
    scanf("%d %d", &n, &k);
    for(long i=0; i<n; i++){
        scanf("%d %d %c", &x, &y, &c);
        y %= 2*k;
        if(c=='W'){
            x += k;
        }
        if(y>=k){
            y-=k;
            x+=k;
        }
        x %= 2*k;
        b[x][y]++;
    }
    s[1][1] = b[0][0];
    for(long i=1; i<2*k; i++){
        s[i+1][1] = s[i][1] + b[i][0];
    }
    for(long i=1; i<k; i++){
        s[1][i+1] = s[1][i] + b[0][i];
    }
    for(long x=1; x<2*k; x++){
        for(long y=1; y<k; y++){
            s[x+1][y+1] = b[x][y] + s[x][y+1] + s[x+1][y] - s[x][y];
        }
    }
    long max = 0;
    for(long x=0; x<k; x++){
        for(long y=0; y<k; y++){
            long t = calc(x, y, k, k-y);
            t += calc(0, 0, x, y);
            t += calc(x+k, 0, k-x, y);
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    printf("%ld", max);
    return 0;
}


Measured memory_bytes: 15744
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl '\n'
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

vector<long long> divisor(long long n) {
vector<long long> ret;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end()); // 昇順に並べる
return ret;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    vector<ll> check(1000001,0);
    for(auto p: A)check[p]++;
    ll ans=0;
    for(ll i=0;i<N;++i){
        if(check[A[i]]>1)continue;
        vl B=divisor(A[i]);
        bool ok=1;
        for(auto p: B){
            if(p==A[i])continue;
            if(check[p]){
                ok=0;break;
            }
        }
        if(ok)ans++;
    }
    prt(ans)


    return 0;
}


Measured memory_bytes: 12704
n = int(input())
ls_h = list(map(int, input().split()))

cnt = 0
cntmx = 0

for i in range(n - 1):
    if ls_h[i] >= ls_h[i + 1]:
        if i != n - 2:
            cnt += 1
        elif i == n - 2:
            cnt += 1
            if cnt > cntmx:
                cntmx = cnt
    else:
        if cnt > cntmx:
            cntmx = cnt
        cnt = 0

print(cntmx)

Measured memory_bytes: 15020
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  while (n--) {
    int h, m;
    scanf("%d:%d", &h, &m);

    int diff = h * 300 - m * 55;
    if (diff < 0)
      diff *= -1;
    if (diff > 1800)
      diff = 3600 - diff;
    if (0 <= diff && diff < 300)
      puts("alert");
    else if (900 <= diff && diff <= 1800)
      puts("safe");
    else
      puts("warning");
  }
  return 0;
}

Measured memory_bytes: 0
a, b, c,d = (int(x) for x in input().split())

kyori1 = a - c
kyori2 = a - b
kyori3 = b - c

if abs(kyori1) <= d or (abs(kyori2) <= d and abs(kyori3) <= d) :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 9040
N = int(input())
K = int(input())


def func(num,counter):
    remain = num%10
    quotient = num//10
    
    
    if counter == 0:
        return 1
    
    if num<10:
        if counter ==1:
            return num
        else:
            return 0

    return func(quotient,counter-1)*remain + func(quotient-1,counter-1)*(9-remain) + func(quotient,counter)

print(func(N,K))

Measured memory_bytes: 56280
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    int N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> cnt(N);
    cnt[0] = 0;
    rep(i, 0, N - 1) {
        if (S[i] == 'A' && S[i + 1] == 'C') cnt[i + 1] += cnt[i] + 1;
        else cnt[i + 1] = cnt[i];
    }

    rep(i, 0, Q) {
        int l, r;
        scanf("%d %d", &l, &r);
        l--;
        r--;
        printf("%d\n", cnt[r] - cnt[l]);
    }
}

Measured memory_bytes: 1472
#B
num = [i for i in raw_input()]
result = 0

a = len(num)
z = 0

for i in range(len(num)):
    if num[i] == "Z" and i>z:
        z = i
    elif num[i] == "A" and i<a:
        a = i
temp = z-a
if temp>0:
    print(temp+1)
else:
    print(0)

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

using namespace std;

int main()
{
    int a;
    for (int i = 0; i < 5; i++)
    {
        cin >> a;
        if (a == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
//typedef pair<int,int> P;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int a,b;
    cin>>a>>b;
    if(a<=9&&b<=9)cout<<a*b;
    else cout<<-1;



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 892
X, Y = map(int, input().split())
if Y % 2 == 1:
  print("No")
  exit()

a = (2 * X) - int(Y / 2)
b = X - a



if a >= 0 and isinstance(a, int) and b >= 0 and isinstance(b, int):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    long long int k;
    cin>>n>>k;
    vector<pair<int,int>> vp(n);
    long long int sum=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        vp[i].first=a;
        vp[i].second=b;
        //cout<<vp[i].first<<" "<<vp[i].second<<endl;
    }
    sort(vp.begin(),vp.end());
    for(int i=0;i<n;i++){
        sum+=vp[i].second;
        if(sum>=k){
            cout<<vp[i].first<<endl;
            return 0;
        }
    }
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N;
  cin >> N;

  vector<int64_t> SUM(N + 1);
  SUM[0] = 0;
  for (int64_t i = 1; i <= N; ++i) {
    SUM[i] = SUM[i - 1] + i;
  }

  int64_t left = 1;
  int64_t right = N;
  while (left < right) {
    int64_t mid = left + (right - left) / 2;
    if (SUM[mid] < N) {
      left = mid + 1;
    } else {  // SUM[mid] > N
      right = mid;
    }
  }

  int64_t skip = SUM[left] - N;
  for (int i = 1; i <= left; ++i) {
    if(i == skip) continue;
    cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 78464
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main () {
  int n;
  cin >> n;
  vi coins;
  int now = 1;
  while (now <= n) {
    coins.push_back(now);
    now *= 6;
  }
  now = 9;
  while (now <= n) {
    coins.push_back(now);
    now *= 9;
  }
  vi dp(n + 1, inf);
  dp[0] = 0;
  rep (i, n) {
    rep (j, coins.size()) {
      if (i + coins[j] <= n) {
        chmin(dp[i + coins[j]], dp[i] + 1);
      }
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
  int n ;
  cin >>n  ;
  vector<int> A(n) ;
  rep(i,n) cin >>A[i] ;
 
  int ans=0 ;
  int j=1 ;
  rep(i,n){
   
    if(A[i]==j){
    
    j++ ;
    ans++ ;
    }
  }
    
  if(ans==0)
  cout<< -1<<endl;
  else  
  cout<< n-ans<< endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	
	int ajkkl[3];
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int>a;
	cin >> ajkkl[0] >> ajkkl[1] >> ajkkl[2];
	a.push_back(ajkkl[0]); a.push_back(ajkkl[1]); a.push_back(ajkkl[2]);
	Sort(a);
	int ans = 0;
	ans += (a[2] - a[0]) / 2;
	a[0] = a[2] - ((a[2] - a[0]) % 2);
	ans += (a[2] - a[1]) / 2;
	a[1] = a[2] - ((a[2] - a[1]) % 2);
	Sort(a);
	if (a[0] + a[1] + a[2] == a[2]*3) { cout << ans << endl;; }
	else if (a[0] + a[1] + a[2] +1==a[2]*3) { cout << ans + 2 << endl; }
	else { cout << ans + 1 << endl; }
	return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var (
		a, b, c, x, ans int
	)

	fmt.Scan(&a, &b, &c, &x)

	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				total := 500*i + 100*j + 50*k
				if total == x {
					ans++
				}
			}
		}
	}

	fmt.Println(ans)
}


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

int main(){
int n;
double x;
double yen = 0;
string u;
cin >> n;
for (int i = 0;i < n;i++){
  cin >> x >> u;
  if (u == "JPY"){
    yen += x;
  }
  else{
    yen += 380000*x;
  }
}
cout << fixed << setprecision(10);
cout << yen << endl;
}


Measured memory_bytes: 256