akhauriyash/Code-Regression huggingface dataset:
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
signed main() 
{
    fast;
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    s = '#'+s;
    int pre[n+1]={};
    for(int i=2;i<=n;i++)
    {   
        string sub = s.substr(i-1,2); 
        if(sub == "AC")
            pre[i] = pre[i-1]+1;
        else pre[i] = pre[i-1];
    }
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        int ans = pre[r];
        if(s[l-1]=='A' && s[l]=='C')
            ans-=pre[l];
        else ans-=pre[l-1];
        cout<<ans<<"\n";
    }
    return 0;
}

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

int f(int x, int p) {
    return x * (p + 100) / 100;
}

int main() {
    int x, y, s;
    while (cin >> x >> y >> s && x) {
        int ans = -1;
        for (int i = 1; i <= s; i++) {
            for (int j = 1; j <= s; j++) {
                int a1 = f(i, x);
                int b1 = f(j, x);
                int a2 = f(i, y);
                int b2 = f(j, y);
                if (a1 + b1 == s) {
                    ans = max(ans, a2 + b2);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3084
h,n=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
inf=1000000000
ma=ab[0][0]
dp=[inf]*(h+1+ma)
dp[0]=0
for i in range(n):
    x=ab[i]
    for j in range(h):
        if dp[j]!=inf:
            if j+x[0]<=h+ma:
                if j+x[0]>=h:
                    dp[h]=min(dp[h],dp[j]+x[1])
                else:
                    dp[j+x[0]]=min(dp[j+x[0]],dp[j]+x[1])
            else:
                break
print(dp[h])


Measured memory_bytes: 43504
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
K = I()
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
queue = deque(A)
cnt = 0
while cnt != (K - 1):
    x = queue.popleft()
    mod = x % 10
    if mod != 0:
        queue.append(10 * x + mod - 1)
    queue.append(10 * x + mod)
    if mod != 9:
        queue.append(10 * x + mod + 1)
    cnt += 1
print(queue.popleft())


Measured memory_bytes: 74688
# -*- coding: utf-8 -*-

n = int(input())
a = [0] + [int(x) for x in input().split()] + [0]
b = [abs(a[i+1] - a[i]) for i in range(n+1)]
all_cost = sum(b)
for i in range(1, n+1):
    cost = all_cost - (b[i-1] + b[i]) + abs(a[i+1] - a[i-1])
    print(cost)


Measured memory_bytes: 14176
#include <stdio.h>
int main(){

	int x,i,max=1,v;
	scanf("%d",&x);
	
	for(i=2;i<=x;i++){
		v = i*i;
		while( v <= x){
			if ( max < v ){
				max = v;
			}
			v *=i;
		}
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, Z, W;
  cin >> N >> Z >> W;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int ans;
  if (N == 1) {
    ans = abs(a[0] - W);
  } else {
    ans = max(abs(a[N-1] - W), abs(a[N-2] - a[N-1]));
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int K,A,B;
	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	vector<int> given;

	cin >> K >> A >> B;

	for(i=A;i<=B;i++){
		if(i%K==0){
			cout << "OK" << endl;
			exit(0);
		}
	}
	
	cout << "NG" << endl;

	return 0;
}



Measured memory_bytes: 3616
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
p=set()
s=0
for i in range(len(a)):
    if a[i]<3200:
        p.add(a[i]//400)
    else:
        s+=1
print(max(len(p),1), len(p)+s)

Measured memory_bytes: 3060
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    s = int(input())
    M = 2 * (10**6)
    A = [False] * (M+1)
    A[s] = True
    pre = s
    count = 1
    while True:
        count += 1
        if pre%2==1:
            now = 3*pre + 1
        else:
            now = pre//2
        if A[now] == False:
            A[now] = True
            pre = now
            continue
        else:
            print(count)
            break


if __name__ == '__main__':
    main()

Measured memory_bytes: 18676
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DAtCoderExpress2 {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> check(N, vector<int>(N, 0));
    vector<vector<int>> check2(N);
    rep(i, M) {
      int L, R;
      cin >> L >> R;
      check2[R - 1].emplace_back(L - 1);
    }
    rep(i, N) {
      FOR(j, i, N) {
        int temp = 0;
        rep(k, check2[j].size()) {
          if (check2[j][k] >= i) {
            temp++;
          }
        }
        if (i == j) {
          check[i][j] += temp;
        } else {
          check[i][j] = check[i][j - 1] + temp;
        }
      }
    }
    rep(i, Q) {
      int p, q;
      cin >> p >> q;
      cout << check[p - 1][q - 1] << endl;
    }
  }
};


signed main() {
  DAtCoderExpress2 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007
int gcd(int a, int b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k;
    cin>>k;
    ll sum = 0;
    for(int i = 1; i<=k; i++){
        for(int j = 1; j<=k; j++){
            for(int l = 1; l<=k; l++){
                sum+=gcd(gcd(i,j),l);
            }
        }
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    for(int i = 0; i < M; i++) cin >> L.at(i) >> R.at(i);
    int left = -1, right = N + 1;
    for(int i = 0; i < M; i++) {
        left = max(left, L.at(i));
        right = min(right, R.at(i));
    }
    
    if(right - left + 1 >= 1) cout << right - left + 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, c = 0;
    cin >> n;
    vector<int>v(n, 0);

    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    for (int i = 1; i < n - 1; i++) {
        if(v[i] < v[i - 1] && v[i + 1] < v[i] ||
           v[i] < v[i + 1] && v[i - 1] < v[i]) {
            c++;
        }
    }

    cout << c << endl;
    return 0;
}


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

const int N = 21;

int main() {
    int n, a[N], b[N], c[N];

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i];
    }

    int sat = b[a[0] - 1];
    for (int i = 1; i < n; i++) {
        sat += b[a[i] - 1];
        if (a[i] - a[i - 1] == 1) {
            sat += c[a[i - 1] - 1];
        }
    }

    cout << sat << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())


n, T = nm()
t = nl()
count = 0
for i in range(1, n):
    if t[i] - t[i - 1] > T:
        count += t[i] - t[i - 1] - T
print(t[-1] + T - count)


Measured memory_bytes: 25996
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int ans = (X - Z) / (Z + Y);
  cout << ans << endl;
}


Measured memory_bytes: 3624
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


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

	string S = toString(N);

	int count = 0;
	REP(i, SZ(S)) {
		if (S[i] == '2') {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
 
long long int gcd (long long int a,long long int b )
{
  long long int c;
  while ( a != 0 ) {
     c = a; a = b%a;  b = c;
  }
  return b;
}
 
long long int lcm(long long int x, long long int y)
{
  return x/gcd(x,y)*y;
}
 
int main(){
  long long int n;
  cin>>n;
  vector<long long int> t(n);
  for(long long int i=0;i<n;i++)cin>>t[i];
 
  long long int ans=t[0];
  for(int i=1;i<n;i++)ans=lcm(ans,t[i]);
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a, b, c, min;
	scanf("%d %d %d", &a,&b,&c);
	min = a + b;
	if (min > (a + c))
		min = (a + c);
	if (min > (b + c))
		min = (b + c);
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
import math
x = int(input())
f = True
ans = True
while(f):
    for i in range(2,int(math.sqrt(x))+1):
        if x % i == 0:
            ans = False
            break
        elif x % i !=0:
            ans = True
    if ans == True:
        print(x)
        f=False
    elif ans == False:
        x+=1



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

typedef long long int ll;
double PI = 3.14159265358979;


int main(){
 int N;
 cin >> N;
 vector<int> A(N),B(N);
 for(int i = 0;i < N;i++){
     cin >> A[i];
     B[i] = A[i];
 }
 
 sort(B.begin(),B.end());
 for(int i = 0;i < N;i++){
    if(A[i] == B[N-1]){
        cout << B[N-2] << endl;
    }else{
        cout << B[N-1] << endl;
    }
 }
}


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

long long n,a[100005],br1,br2,br3,r;

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

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==1)
            br1++;
        else
        {
            if(a[i]%4==0)
                br3++;
            else
                br2++;
        }
    }
    if(br3+1<br1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    if(br3<br1)
    {
        if(br2==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        return 0;
    }

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 4360
<?php
  list($a, $b, $c, $d) = explode(" ", trim(fgets(STDIN)));

  if($a < $c){
    if($b < $d){
      if( $b > $c ) echo $b - $c;
      else echo "0";
    }else{
      echo $d-$c;
    }
  }else{
    if($d < $b){
      if( $d > $a ) echo $d - $a;
      else echo "0";
      exit;
    }else{
      echo $b-$a;
    }
  }


Measured memory_bytes: 16236
n,a,b,c=map(int,input().split())
s=[input()for _ in range(n)]
if a+b+c==0:exit(print("No"))
if a+b+c!=2:
  ans=[]
  for i in s:
    if i=="AB":
      if a+b==0:exit(print("No"))
      if a>b:
        a,b=a-1,b+1
        ans.append("B")
      else:
        a,b=a+1,b-1
        ans.append("A")
    if i=="BC":
      if b+c==0:exit(print("No"))
      if b>c:
        b,c=b-1,c+1
        ans.append("C")
      else:
        b,c=b+1,c-1
        ans.append("B")
    if i=="AC":
      if a+c==0:exit(print("No"))
      if a>c:
        a,c=a-1,c+1
        ans.append("C")
      else:
        a,c=a+1,c-1
        ans.append("A")
  print("Yes",*ans)
  exit()
if a+b+c==2:
  ans=[]
  s.append("temp")
  for i in range(n):
    if s[i]=="AB":
      if a==b:
        if a==b==0:exit(print("No"))
        if s[i+1]=="AC":
          ans.append("A")
          a,b=2,0
        else:
          ans.append("B")
          a,b=0,2
      elif a>b:
        a,b=a-1,b+1
        ans.append("B")
      else:
        a,b=a+1,b-1
        ans.append("A")
    if s[i]=="BC":
      if b==c:
        if c==b==0:exit(print("No"))
        if s[i+1]=="AB":
          ans.append("B")
          b,c=2,0
        else:
          ans.append("C")
          b,c=0,2
      elif b>c:
        b,c=b-1,c+1
        ans.append("C")
      else:
        b,c=b+1,c-1
        ans.append("B")
    if s[i]=="AC":
      if a==c:
        if a==c==0:exit(print("No"))
        if s[i+1]=="AB":
          ans.append("A")
          a,c=2,0
        else:
          ans.append("C")
          a,c=0,2
      elif a>c:
        a,c=a-1,c+1
        ans.append("C")
      else:
        a,c=a+1,c-1
        ans.append("A")
  print("Yes",*ans)
  exit()

Measured memory_bytes: 18508
S = list(input())
S.sort()
a = ""
cnt_syurui = 0



for i in range(4):
    if a != S[i]:
        cnt_syurui += 1
    a = S[i]

if cnt_syurui == 2:
    if S.count(S[0]) == 2:
        print("Yes")
else:
    print("No")


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

int main() {
	long long n, N = 1e5+7, h, q, b, c, s = 0, a[N];
	memset(a, 0, sizeof(a));
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> h;
		s += h;
		a[h]++;
	}
	cin >> q;
	while(q--){
		cin >> b >> c;
		s += a[b] * (c - b);
		cout << s << '\n';
		a[c] += a[b];
		a[b] = 0;
	}
}

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

int main(){
    int A, B;
    cin >> A >> B;
    int ans = 1251;
    for (int i=1;i<=1250;i++){
        if ((int)(0.08*i) == A && (int)(0.1*i) == B) ans = min(ans, i);
    }
    cout << (ans <= 1250 ? ans : -1) << endl;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

struct Work{
    ll s;
    ll t; 
    ll x;

    bool operator<(const Work& another) const{
        return x < another.x;
    }

    Work(ll _s, ll _t, ll _x){
        s = _s;
        t = _t;
        x = _x;
    }
};

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

    // input
    ll N, Q;
    cin >> N >> Q;

    vector<Work> W;
    FOR(i, 0, N){
        ll s, t, x;
        cin >> s >> t >> x;
        s-=x;
        t-=x;
        W.push_back(Work(s, t, x));
    }
    sort(ALL(W));

    vector<ll> Ans(Q, -1);

    set<pair<ll, ll>> se;
    FOR(i, 0, Q){
        ll d; cin >> d;
        se.insert(make_pair(d, i));
    }

    FOR(i, 0, N){
        auto work = W[i];
        auto it = se.lower_bound(make_pair(work.s, 0));
        while(it!=se.end() && it->first < work.t){
            Ans[it->second] = work.x; // id
            se.erase(it++);
        }
    }

    for(ll ans : Ans){
        p(ans);
    }
    
    return 0;
}

Measured memory_bytes: 21100
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int x, a;
    cin >> x >> a;
    if(x < a) cout << 0;
    else cout << 10;
    cout << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val line = readLine()!!.split(' ').map { it.toInt() }
    val n = line[0]
    val t = line[1]
    var ans = -1
    var isFirst = true
    for (i in (1..n)) {
        val l = readLine()!!.split(' ').map { it.toInt() }
        if (isFirst && l[1] <= t || l[0] < ans && l[1] <= t) {
            ans = l[0]
            isFirst = false
        }
    }
    if (ans == -1) {
        println("TLE")
    } else {
        println(ans)
    }
}

Measured memory_bytes: 38240
<?php
$inputNum = trim(fgets(STDIN));
 
for ($i=1; $i <= $inputNum; $i++) {
    if (($i % 3 == 0) || preg_match('/3/', $i)) 
        $nums[] = $i;
}
 
echo sprintf(' %s', implode(' ', $nums)), PHP_EOL;

Measured memory_bytes: 16364
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;
const int N = 100005;
ll frac[N], rfrac[N];
int m[N];
int n;

ll powMod(int a, int n, int m){
  ll p = 1, t = a;
  while(n > 0){
    if(n & 1) p = p * t % m;
    t = t * t % m;
    n >>= 1;
  }
  return p;
}
ll comb(int a, int b){
  if(a < b)return 0;
  return frac[a] * rfrac[b] % mod * rfrac[a-b] % mod;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  n++;
  frac[0] = rfrac[0] = 1;
  FOR(i, 1, n + 1){
    frac[i] = frac[i - 1] * i % mod;
    rfrac[i] = powMod(frac[i], mod - 2, mod);
  }
  int j;
  FOR(i, 1, n + 1){
    cin >> j;
    if(m[j]){
      j = i - m[j] + 1;
      break;
    }else{
      m[j] = i;
    }
  }
  FOR(i, 1, n + 1){
    cout << (comb(n, i) - comb(n - j, i - 1) + mod) % mod << endl;
  }
}


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


int main(){
    string S,T;
    cin >> S >> T;

    int ans = 0;

    for(int i = 0; i < S.size(); i++){
        if(S.at(i) != T.at(i)) ans++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 3848
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        r: i32,
    }

    let ans = r * r;
    println!("{}", ans);
}


Measured memory_bytes: 2116
using System;
class Program
{
    static void Main(string[] args)
    {
        uint a,b,c;
        string[] str = Console.ReadLine().Split(' ');
        a = uint.Parse(str[0]);
        b = uint.Parse(str[1]);
        c = uint.Parse(str[2]);
        
        int count = 0;
            while(true){
                if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
                    Console.WriteLine(count);
                    break;
                }
                if(a == b && b == c){
            count = -1;
            Console.WriteLine(count);
break;
        }

                count++;
                uint half_a, half_b, half_c;
                half_a = a / 2;
                half_b = b / 2;
                half_c = c / 2;
                a = b = c = 0;
                a = half_b + half_c;
                b = half_a + half_c;
                c = half_a + half_b;
            }
        
    }
}

Measured memory_bytes: 13140
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=4e2+5;

int dp[N][N];

void solve()
{
    int n;
    cin>>n;

    vector<int> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    vector<int> pre(n+1,0);
    for(int i=0;i<n;++i)
        pre[i+1]=pre[i]+v[i];

    for(int i=0;i<n;++i)
    {
        for(int j=0;j<n;++j)
        {
            if(i==j)
                dp[i][j]=v[i];
            else
                dp[i][j]=inf;
        }
    }

    for(int k=2;k<=n;++k)
    {
        for(int i=0;i+k-1<n;++i)
        {
            int pos=i+k-1,tmp;
            for(int j=i;j<pos;++j)
            {
                tmp=pre[pos+1]-pre[i];

                if(i!=j)
                    tmp+=dp[i][j];
                if(j+1!=pos)
                    tmp+=dp[j+1][pos];

                dp[i][pos]=min(dp[i][pos],tmp);
            }
        }
    }

//    for(int i=0;i<n;++i)
//    {
//        for(int j=i;j<n;++j)
//            cout<<dp[i][j]<<" ";
//        cout<<"\n";
//    }

    cout<<dp[0][n-1];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define pi              acos(-1)
#define ll              long long
#define ld              long double
#define gcd             __gcd
#define bitscount       __builtin_popcount
#define ff              first
#define ss              second
#define MAXX            1e18
#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL)
//__builtin_popcount()  -->  counts how many 1 s are in a binary represented integer
//accumulate() --> finds sum of an array of integers
using namespace std;
int main()
{
    ld n;
    cin>>n;
    cout<<ceil(n/1000)*1000 - n;
}


Measured memory_bytes: 3756
n, k = map(int, input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(Base_10_to_n(n, k)))

Measured memory_bytes: 2940
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
 
def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]
 
# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]
 
# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]
 
n,d,a = get_nums_l()
lines = sys.stdin.readlines()
monsters = [ tuple(map(int, s.split(" "))) for s in lines ]
monsters.sort(key=lambda m: m[0])
 
ans = (monsters[0][1] + a - 1)//a
areas = [(monsters[0][0] + 2*d, ans*a)]
sum_ = ans*a
area_cursol = 0
for i in range(1, len(monsters)):
    m = monsters[i]
    x = m[0]
    h = m[1]
 
 
    while area_cursol < len(areas) and x > areas[area_cursol][0]:
        sum_ -= areas[area_cursol][1]
        area_cursol += 1
 
    if sum_ < h:
        # ボムつかう
        nokori = h-sum_
        kaisuu = (nokori+a-1)//a
        sum_ += kaisuu*a
        areas.append((x+2*d, kaisuu*a))
        ans += kaisuu
 
print(ans)

Measured memory_bytes: 121552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   long long int N=0;
   cin >> N;
   
   
   vector<long long int> vec(N);
   for (long long int i = 0; i < N; i++) {
       cin >> vec.at(i);
   }
   vector<long long int> vec2=vec;
   sort(vec.begin(),vec.end());
   
   long long int sum=0;
   long long int count=1;
   long long int count2=0;
   vector<long long int> vec3(N+1);
   for (long long int i = 0; i < N; i++) {
       if(i==N-1){
           vec3.at(vec.at(i))=count;
           sum+=count*(count-1)/2;
           count=1;
       }
       else if(vec.at(i)==vec.at(i+1)){
           count++;
       }
       else{
           vec3.at(vec.at(i))=count;
           sum+=count*(count-1)/2;
           count=1;
       }
   }
   
   for(long long int k=0; k<N;k++){
   cout << sum-vec3.at(vec2.at(k))+1 << endl;
   }
   
   
}

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<algorithm>
#include<limits.h>
#include<utility>
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(i,n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(n);
lpin(i,n,a);
lpin(i,n,b);
lp(i,n){
c[i] = a[i] - b[i];
}
sort(c.rbegin(),c.rend());
int ans = 0;
lp(i,n){
if(c[i] > 0)ans += c[i];
}

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] N = new int[4];
	static {
		Arrays.setAll(N, i->sc.nextInt());
	}
	public static void main(String[] args) {
		Arrays.sort(N);
		if (Arrays.toString(N).equals("[1, 4, 7, 9]")) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 28884
import java.util.*;

public class Main{
    public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      String[] testList = scanner.nextLine().split(" ");
      int HP = Integer.parseInt(testList[0]);
      int ATTACK = Integer.parseInt(testList[1]);
      int attack_count = 0;
      
      if(HP % ATTACK == 0){
        attack_count = HP / ATTACK;
      }else{
        attack_count = HP / ATTACK + 1;
      }
      
      System.out.println(attack_count);
      
    }
} 

Measured memory_bytes: 21844
N = int(input())
s = sorted([sorted(input()) for _ in range(N)])
total = 0
count = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        total += count * (count - 1) / 2
        count = 1
total += count * (count - 1) / 2
print(int(total))


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

constexpr int64_t MOD = 1000000007;
int main(void) {
    int N;
    cin >> N;
    int target;
    int64_t ans = 1;
    
    vector<int64_t> prime(N,0);

    for(int i=2;i<=N;i++) {
        bool found = false;
        target = i;
        for(int j=2;j<=target;j++) {
            if((target%j)== 0) {
                found = true;
                prime[j-1]++;
                target = target / j;
                j = 1;
            }
        }
    }

    for(auto p:prime) {
        if(p>0){
            ans = (ans * (p+1)) % MOD;
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	int count = 0;
	rep(i, n) {
		bool ans = true;
		rep(j, i) {
			if (h[j] > h[i]) {
				ans = false;
			}
		}
		if (ans) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        if(a % 2 != 0 && b % 2 == 0){
            long c = ((b-a-1)/2) % 2;
            System.out.println(a^b^c);
        }else if(a % 2 != 0){
            long c = ((b-a)/2) % 2;
            System.out.println(a^c);
        }else if(b % 2 == 0){
            long c = ((b-a)/2) % 2;
            System.out.println(b^c);
        }else{
            long c = ((b-a+1)/2) % 2;
            System.out.println(c);
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<regex>
using namespace std;

int main()
{
	int num, tmp;
	map<int, int> present;
	cin >> num;
	for(int i = 0; i < num; i++){
        cin >> tmp;
        if(present.find(tmp) != present.end()){
            present.erase(tmp);
        }
        else{
            present.insert(pair<int, int>(tmp, 0));
        }
	}
	cout << present.size() << endl;
	return 0;
}


Measured memory_bytes: 4864
H, W, K = map(int, input().split())
MOD = 10**9 + 7

dp = {i: {j: 0 for j in range(1, W+1)} for i in range(H+1)} # dp[i][j]: i番目の行を通過した後に j 番目の縦線にいる場合の数

dp[0][1] = 1

n_valid_patterns = {i: -1 for i in range(W+1)}

def valid_patterns(n): # 高さ 1 の n 本のあみだくじの valid なパターンの数を計算
    if n_valid_patterns[n] != -1:
        return n_valid_patterns[n]
    elif n <= 1:
        return 1
    elif n == 2:
        return 2
    else:
        n_valid_patterns[n] = (valid_patterns(n-2) + valid_patterns(n-1)) % MOD # n-1, n本目の縦線を結ぶ or not の二つの場合がある.
        return n_valid_patterns[n]

for i in range(1, H+1):
    for j in range(1, W+1):
        if j > 1: # j-1 番目の縦線から j 番目の縦線に来る
            dp[i][j] += dp[i-1][j-1]*(valid_patterns(j-2)*valid_patterns(W-j)) % MOD

        # j 番目の縦線からそのまま j 番目の縦線に降りてくる
        dp[i][j] += dp[i-1][j]*(valid_patterns(j-1)*valid_patterns(W-j)) % MOD

        if j < W: # j+1 番目の縦線から j 番目の縦線に来る
            dp[i][j] += dp[i-1][j+1]*(valid_patterns(j-1)*valid_patterns(W-j-1)) % MOD

        dp[i][j] %= MOD

print(dp[H][K])


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;



const int yy = 20 * 20 + 19 * 10;
int main() {
	int n; cin >> n;
	int ms[30];
	int now = 0;
	for (int i = 0; i < 30; ++i) {
		ms[i] = now;
		if ((i % 2)&&i<20)now += 19;
		else now += 20;	
	}
	while (n--) {
		int y, m, d; cin >> y >> m >> d;
		y--; m--; d--;
		m = y * 10 + m;
		int ans = (m / 30)*yy + ms[m % 30] + d;
		cout << 196470 - ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3008
N, M = map(int, input().split())
stu = []
che = []
for i in range(N):
  stu.append(list(map(int, input().split())))
for i in range(M):
  che.append(list(map(int, input().split())))
  
for i in stu:
  x, y = i[0], i[1]
  ans = 0
  tmp = 99999999999999
  for num, j in enumerate(che):
    if abs(x-j[0])+abs(y-j[1]) < tmp:
      tmp = abs(x-j[0])+abs(y-j[1])
      ans = num + 1
  print(ans)



Measured memory_bytes: 3064
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	string str, answer;
	cin >> str;
	answer = "";

	for (int i = 0; i < str.length(); ++i){
		if (str[i] == '1'){
				answer+='1';
		}
		else if (str[i] == '0'){
				answer+='0';
		}
		else{
			if (answer.length() != 0){
				answer.erase(answer.length()-1);
			}
		}

	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100005
char a[N];
int pref[N], l[N];
int n, k;

bool can(int sz) {
  for (int i = 0; i + sz - 1 < n; i++) {
    int r = i + sz - 1;
    int cur = pref[r];
    if (l[i] > 0) {
      cur -= pref[l[i] - 1];
    }
    if (k >= cur) {
      return true;
    }
  }
  return false;
}

int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", a);
  pref[0] = (a[0] == '0');
  l[0] = 0;
  for (int i = 1; i < n; i++) {
    pref[i] = pref[i - 1];
    if (a[i] == '0' && a[i - 1] == '1') {
      pref[i]++;
    }
    l[i] = (a[i] == a[i - 1] ? l[i - 1] : i);
  }
  int lo = 0, hi = n + 1;
  while (lo + 1 < hi) {
    int mid = (lo + hi) / 2;
    if (can(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  printf("%d\n", lo);
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define BUF_SIZE 10000

int comp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}

int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);
  int *arr = malloc(sizeof(int)*num);
  
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  int i, j, k;
  for(i = 0; i < num; i++) {
    char* tmp = strtok(tmpbuf, " ");
    arr[i] = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
  }

  qsort(arr, num, sizeof(int), comp);
  int cnt = 0;
  int map[4001] = {0};
  int pos = 0;
  int cum = 0;
  for(i = 2; i < num; i++) {
    int longest = arr[i];
    int pivot = arr[i-1];
    for(j = 0; j <= i-2; j++) {
      map[pivot+arr[j]]++;
      cum++;
    }
    while(pos <= longest) {
      cum -= map[pos++];
    }
    cnt += cum;
  }

  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

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

		//input
		Scanner sc = new Scanner(System.in);
		String s,r = "";
		s = sc.next();
        for(int i=s.length()-1;i>=0;i--){
        	 r += String.valueOf(s.charAt(i));
        }
		
         //output
         System.out.println(r);
	}
}

Measured memory_bytes: 17124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

# UnionFind
class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.parent[x] = y

    def same(self, x, y):
        return self.root(x) == self.root(y)

N, K, L = map(int, input().split())
un1 = UnionFind(N)
for i in range(K):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    un1.unite(p, q)
un2 = UnionFind(N)
for i in range(L):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    un2.unite(r, s)
dic = defaultdict(int)
for i in range(N):
    a, b = un1.root(i), un2.root(i)
    k = str(a)+":"+str(b)
    dic[k] += 1

ans = [0]*N
for i in range(N):
    a, b = un1.root(i), un2.root(i)
    k = str(a)+":"+str(b)
    ans[i] = dic[k]
print(*ans)


Measured memory_bytes: 47792
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
//#define all(x , n) x+1,x+n+1
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll

const int N = 5000+54, mod = 1e9 + 7, mod1 = 998244353;
const int MAX = 1e5 + 11 , T = 2000;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const long double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const int LOG = 20;
const double EPS = 1e-4;
const double PI = acos(-1.0);

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <int> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}
bool query = 0;
ll bp(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
///////////////////////////////////////////////////////////


void solve() {
    int x , y;
    cin >> x >> y;
    if(y&1) {
        cout << "No";
        return;
    }
    if(x*2 > y) {
        cout << "No";
        return;
    }
    if(x*4 < y) {
        cout << "No";
        return;
    }
    cout << "Yes";
}

/*
*/

main() {
    ios;
    int tt = 1;
    if(query)
        cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	int a, asum = 0;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a;
		asum += a;
	}
	if(n >= asum){
		cout << n - asum << endl;
		return 0;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3676
#include<stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  int a=n;
  int c,t,i;
  for(i=0;i<=n;i++){
    c=0; t=i;
    while(t>0){
      c+=t%6;
      t/=6;
    }
    t=n-i;
    while(t>0){
      c+=t%9;
      t/=9;
    }
    if(a>c)a=c;
  }
  printf("%d\n", a);
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a.at(i);

	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (a.at(i) % 2 == 0) {
			if ((a.at(i) % 3) != 0 && (a.at(i) % 5) != 0) {
				ok = false;
				break;
			}
		}
	}
	if (ok) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}


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

int main(){
  int n, q;
  string s;
  cin>>n>>q>>s;
  vector<int> a(n,0);
  for(int i=1;i<n;i++){
    //a[i]=a[i-1];
    if(s.substr(i-1,2)=="AC")a[i]++;
  }
  vector<int> sum(n+1,0);
  for(int i=0;i<n;i++)sum[i+1]=sum[i]+a[i];
  for(int Q=0;Q<q;Q++){
    int s,t;cin>>s>>t;
    int ans=sum[t]-sum[s];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n, m;
int a[50], b[50];
bool graph[50][50],reached[50];

void dfs(int v) {
    reached[v] = true;
    for (int w = 0; w < n; ++w) {
        if (graph[v][w] == false) continue;
        if (reached[w] == true) continue;
        dfs(w);
	}
}

int main() {
  cin>>n>>m;
  for(int i=0;i<50;i++){
    for(int j=0;j<50;j++){
      graph[i][j]= false;
    }
  }
  for(int i = 0; i < m; ++i) {
	cin >> a[i] >> b[i];
	a[i]--, b[i]--;
	graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans=0;
  for(int i=0;i<m;i++){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    for(int j=0;j<n;j++) reached[j]=false;
    dfs(0);
    bool bridge=false;
    for(int j=0;j<n;j++) if(reached[j]==false) bridge=true;
    if(bridge) ans+=1;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    
  }
  cout<<ans<<endl;
  return 0;
}





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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    ll ans = 0;
    for(int i=1; i<N; i++){
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
// 21
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef LOCAL
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int n;
  cin >> n;
  vector<li> v(n);
  rep(i, n) cin >> v[i];
  const li inf = 2e18;
  vector<li> pref = v;
  rep(i, 1, n) pref[i] += pref[i - 1];
  vector<vector<li>> mem(n, vector<li>(n, inf));
  function<li(int, int)> f = [&](int L, int R) -> li {
    if (L == R) return 0;
    if (mem[L][R] != inf) return mem[L][R];
    li sum = pref[R] - (L == 0 ? 0 : pref[L - 1]);
    rep(pivot, L, R) {
      mem[L][R] = min(mem[L][R], f(L, pivot) + f(pivot + 1, R) + sum);
    }
    return mem[L][R];
  };
  cout << f(0, n - 1) << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	map<char,ll>ch;
	for(ll i=0;i<4;i++){
		ll now=s[i]-'A';
		ch[now]++;
		if(ch[now]>2){
			cout << "No";
			return 0;
		}
	}
	for(auto itr=ch.begin();itr!=ch.end();itr++){
		ll val=itr->second;
		if(val==1){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	// your code goes here
	return 0;
}

Measured memory_bytes: 3616
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut n: u32 = sc.read();
    let k: u32 = sc.read();

    let mut ans = 0;
    while n > 0 {
        n /= k;
        ans += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 2088