akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
    int R,B,G,N;
    int count = 0;
    int r = 0;
    int g;
    scanf("%d %d %d %d",&R, &B, &G, &N);

    while(r*R <= N){
        g=0;
        while(g*G <= N-r*R){
            if((N - r*R -g*G)%B==0){
                count++;
            }
            g++;
        }
        r++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
import fractions

a, b, c, d = map(int, input().split())

lcm = c*d // fractions.gcd(c,d)


b_num = b - (b//c + b//d - b//lcm)
a_num = a-1 - (a-1)// c - (a-1)//d + (a-1) // lcm

ans = b_num - a_num
print(ans)


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

#define INF 10000000000
long long i,j,k,N,res,tmp,A[305][305];

int main(){
    cin>>N;
    for (i = 0; i < N; i++)
		for (j = 0; j < N; j++)cin>>A[i][j];
    for(i = 0; i < N-1; i++){
        for(j = i+1; j < N; j++){
            tmp = INF;
            for(k = 0; k < N; k++){
                if(i==k||j==k)continue;
                tmp = min(tmp,A[i][k]+A[k][j]);
                if(A[i][j]>A[i][k]+A[k][j]){
                    cout<<-1<<endl;
                    return 0;
                }
            }
            if(A[i][j]<tmp){
                res += A[i][j];
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
     cin>>n>>k;
   ll h[n];
    for(int i=0;i<n;i++)
       cin>>h[i];
  ll ans[n];
  for(int i=0;i<n;i++)
     ans[i]=INT_MAX;
   ans[0]=0;
   for(int i=1;i<n;i++)
      for(int l=1;l<=k;l++)
      {
        if(l<=i)
       ans[i]=min(abs(h[i]-h[i-l])+ans[i-l],ans[i]);
      }
     cout<<ans[n-1];            
    return 0;
}

Measured memory_bytes: 1920
a,b,c,d=map(int,input().split())

def calc_div_num(a,b,x):
  return b//x - (a-1)//x

num_c = calc_div_num(a, b, c)
num_d = calc_div_num(a, b, d)

import numpy as np
lcd = np.lcm(c, d)
num_lcd = calc_div_num(a, b, lcd)

result = b-a+1 - (num_c+num_d-num_lcd)
print(result)

Measured memory_bytes: 27164
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned int  ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
	        res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
} 
vi pr;
void sieve(int n){ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));   
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true){ 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          pr.pb(p); 
} 


signed main(){
	FASTIO
	int n;
	cin >> n;
	int d1[n], d2[n];
	rep(i, 0, n){
		cin >> d1[i] >> d2[i];
	}
	bool f = false;
	rep(i, 1, n - 1){
		if(d1[i-1] == d2[i-1] && d1[i] == d2[i] && d1[i+1] == d2[i+1]){
			f = true;
			break;
		}
	}
	if(f){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec x(N), y(N);
    REP(i,0,N) cin >> x[i] >> y[i];

    double sum = 0.0;
    REP(i,0,N-1) {
        REP(j,i+1,N) {
            sum += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    } 
    cout << setprecision(12) << sum * 2.0 / N<< endl;

    return 0;
}

/*



*/

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

int main(void) {
    int64_t N,K;
    string S;
    char last;
    int rnpos = 0;
    int cnt = 0;
    int64_t sum = 0;
    int rpos,lpos;
    int64_t maxsum = 0;

    cin >> N >> K >> S;

    // rnrnrnrnr の配列で nがkまで rの連続を作ることが出来る
    
    vector<vector<int>> rn(2);
    vector<int> *p = &rn[0];
    if(S[0] == '0'){
        (*p).push_back(0);
        p = &rn[1];
        rnpos = 1;
    } else {
        p = &rn[0];
        rnpos = 0;
    }
    
    last = S[0];
    for(int i=0;i<S.size();i++) {
        if(last != S[i]) {
            (*p).push_back(cnt);
            cnt = 0;
            rnpos++;
            p = &rn[rnpos%2];
        }

        cnt++;
        last = S[i];
    }

    (*p).push_back(cnt);
    if(rn[1].size() <= K) {
        cout << N << endl;
        return 0;
    }

    // しゃくとり法
    vector<int> *pleft;
    vector<int> *pright;
    
    // 直立をK(倒立をK+1)まで加算して直立/倒立の組を一つずつ加算、減算して最大を取得
    for(int i=0;i<K;i++) {
        sum += rn[0][i] + rn[1][i];
    }

    if(rn[0].size() > K) {
        sum += rn[0][K];
    }

    maxsum = sum;

    lpos = K;
    rpos = 0;
    while(1) {
        if(rn[1].size() > lpos) {
            // 直立があれば
            sum += rn[1][lpos];

            // 減算は両方
            sum -= rn[0][rpos];            
            sum -= rn[1][rpos];
            if(maxsum < sum) {
                maxsum = sum;
            }
        } else {
            break;
        }

        lpos++;
        if(rn[0].size() > lpos) {
            sum += rn[0][lpos];
            if(maxsum < sum) {
                maxsum = sum;
            }
        } else {
            break;
        }

        rpos++;
    }
        
    cout  << maxsum << endl;

    return 0;
}


Measured memory_bytes: 1020
K = int(input())
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(0, K):
    if A[i]%10 != 0:
        A.append(10*A[i]+A[i]%10-1)
    A.append(10*A[i]+A[i]%10)
    if A[i]%10 != 9:
        A.append(10*A[i]+A[i]%10+1)
    if len(A) >= K:
        break
print(A[K-1])

Measured memory_bytes: 7188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderBS
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int group = 0;

            while(n >= 3)
            {
                if(n - 3 >= 0)
                {
                    group++;
                }
                n -= 3;
            }

            Console.Write("{0}", group);
            Console.Read();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K; 
  string S;
  scanf("%d %d\n", &N, &K);
  cin >> S;
  
   if(S.at(K-1) == 'A'){
    S.at(K-1) = 'a';
  }
   if(S.at(K-1) == 'B'){
    S.at(K-1) = 'b';
  }
   if(S.at(K-1) == 'C'){
    S.at(K-1) = 'c';
  }  
  
  printf("%s",S.c_str());
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

list_inp = [a,b,c,d,e]
min_last = 100
for index, inp in enumerate(list_inp):
  tmp = int(str(inp)[-1])
  if tmp == 0:
    continue
  
  if tmp <= min_last:
    min_last = tmp
    min_last_index = index

# 全部の料理がちょうど１０分単位だった場合
if min_last == 100:
  min_last_index = 0

# 切り上げ
def ceil(src,range):
  if str(src)[-1] == '0':
    return src
  else:
    return ((int)(src / range) + 1 ) * range

ans = 0
for index,value in enumerate(list_inp):
  if index == min_last_index:
    continue
  else:
    ans += ceil(value, 10)


print(ans + list_inp[min_last_index])

Measured memory_bytes: 3064
from heapq import heapify, heappush, heappop

X, N = map(int, input().split())

if N == 0:
    print(X)
    exit()

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

nums = []

heapify(nums)

for i in range(0, 102):
    if i not in P:
        heappush(nums, (abs(i - X), i))

print(heappop(nums)[1])

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int times = in.nextInt();

		for (int i = 0; i < times; i++) {
			int[] length = new int[3];
			for (int k = 0; k < 3; k++) {
				length[k] = in.nextInt();
				length[k] = (int) Math.pow(length[k], 2);
			}
			Arrays.sort(length);
			if (length[0] + length[1] == length[2]) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
		in.close();
	}
}

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

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	
	for (int i = 0; i < to_string(n).size(); i++)
	{
		sum += (n % (int)(pow(10, i + 1)) / (int)(pow(10, i)));
	}

	if (n % sum == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

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

  set<P> s;
  for (int i = 0; i < n; i++) {
    if (i == a[a[i]]) {
      int ii = i;
      int jj = a[i];
      if(ii > jj) swap(ii, jj);
      s.insert(P(ii, jj));
    }
  }

  int ans = s.size();

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,rez,a;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n;
    i=0;
    while (i<n)
    {
        cin >> a;
        while (a%2==0&&a!=0)
        {
            rez++;
            a/=2;
        }
        i++;
    }
    cout << rez;
    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(m),c(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i] >> c[i];
  priority_queue<P> q;
  rep(i,n){
    q.push(make_pair(a[i],1));
  }
  rep(i,m){
    q.push(make_pair(c[i],b[i]));
  }
  ll ans=0;
  rep(i,n){
    auto p=q.top(); q.pop();
    ans += p.first;
    if(p.second>1){
      p.second--;
      q.push(p);
    }
  }
  cout << ans << "\n";
  
  return 0;
}

Measured memory_bytes: 6516
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k){//from root
    while (u != NIL && k != u->key){
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while( x != NIL){
        y = x;
        if (z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if(y == NIL){
        root = z;
    } else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i=0; i<n; i++){
        cin >> com;
        if (com[0] == 'f'){
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        } else if (com == "insert"){
            scanf("%d", &x);
            insert(x);
        } else if (com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int n, k;
int a[maxn], b[maxn];


int getf(int x) {
    int j=29;
    while (j>=0 && ((x>>j)&1)==0) j--;
    return j;
}

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

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

    assert(getf(5)==2);

    ll best = 0;

    {
	ll cur = 0;
	for (int i=0; i<n; i++) {
	    int x = a[i];
	    if ((x|k)==k) {
		cur += b[i];
	    }
	}

	best = max(best, cur);
    }

    

    {
	// some bit j in K gets turned off
	// make sure all bits in a[i] before j match or are lower, then all bits after j can be whatever.
	for (int j=getf(k); j>=0; j--) {
	    if (k>>j&1) {
		ll cur=0;

		for (int i=0; i<n; i++) {
		    if (getf(a[i])>getf(k) || (a[i]>>j&1)) {
			continue;
		    }
		    bool ok = true;
		    for (int jj=29; jj>j; jj--) {
			if (!(k>>jj&1)) {
			    if (a[i]>>jj&1) {
				ok = false;
			    }
			}
		    }
		    if (ok) {
			cur += b[i];
		    }
		}
		//cout<<j<<": "<<cur<<endl;
		best = max(best, cur);
	    }
	}
    }

    // cout<<bitset<6>(k)<<endl;
    // for (int i=0; i<n; i++) {
    // 	cout<<bitset<6>(a[i])<<": "<<b[i]<<endl;
    // }


    cout<<best<<endl;    
    return 0;
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000003
int fact[1000003];

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int q;
	cin >> q;

	fact[1] = 1;
	rep(i, 2, 1000002)
	{
		fact[i] = (i * fact[i - 1]) % mod;
	}
	int x, d, n;
	zip(i, 0, q)
	{

		cin >> x >> d >> n;

		if (n >= 1000003 && d > 0)
		{
			cout << 0 << en;
		}
		else
		{
			if (d > 0)
			{
				int idx = (x * BE(d, mod - 2, mod)) % mod;
				if (idx == 0 || idx + n - 1 >= mod)
				{
					cout << 0 << en;
				}
				else
				{
					int a = idx + n - 1;
					int b = idx - 1;
					int ans = fact[a] * BE(fact[b], mod - 2, mod) % mod;
					ans = ans % mod;
					ans = (ans * BE(d, n, mod)) % mod;
					cout << ans << en;
				}
			}
			else
			{
				cout << BE(x, n, mod) << en;
			}
		}
	}



	return 0;
}



Measured memory_bytes: 11452
#include <algorithm>
#include <array>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
//region cp_helper
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (int i=0; i<n; i++) in(a[i])
#define viin(a, n) for (int i=0; i<n; i++) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
const int mod = (int)(1e9) + 7;
//endregion
using namespace std;

int main() {
    io();
    int n, m, a, b;
    ll total=0;
    in2(n, m);
    vector<pair<ll, ll>> arr;
    for (int i=0; i<n; i++) {
        in(a);
        arr.pp(1, a);
    }
    for (int i=0; i<m; i++) {
        in2(a, b);
        arr.pp(a, b);
    }
    qsortf(arr, [](ii a, ii b) {
        return a.second > b.second;
    });
    for (auto i : arr) {
        if (i.first <= n) {
            total += i.first * i.second;
            n -= i.first;
        } else {
            total += i.second * n;
            break;
        }
    }
    out(total);
}


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

using namespace std;

#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

int A, B, T;

int main() {
    cin >> A >> B >> T;
    int ans = int((T + 0.5) / A) * B;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    new_divisors = []
    for i, _divisors in enumerate(divisors[::-1]):
        for _remain_divisors in divisors[::-1][i+1:][:-1]:
            if _divisors % _remain_divisors == 0:
                break
        else:
            new_divisors.append(_divisors)
    return new_divisors

    if n == 1:
        return([1])
    divisors = [1, n]
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            if i != n // i:
                div_append = [i, n // i]
            else:
                div_append = [i]
            for _divisors in divisors[1:]:
                if len(div_append) == 0:
                    break
                div_append = [_div_append for _div_append in div_append if _div_append % _divisors != 0]
            else:
                divisors += div_append
    return divisors

def main():
    a, b = map(int, open(0).read().split())

    div_a = make_divisors(a)
    div_b = make_divisors(b)

    cnt = 0
    for _div_a in div_a:
        if _div_a in div_b:
            cnt += 1

    ans = cnt
    print(ans)
    return()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3376
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;

struct MOJI{
	string s;
	int c;
};

int main(){
	int n,m;
	int cost=-9999;
	
	cin >> n;
	struct MOJI b_moji[n];
	
	for(int i=0;i<n;i++){
		cin >> b_moji[i].s;
		b_moji[i].c=1;
		for(int j=0;j<i;j++){
			if(b_moji[i].s==b_moji[j].s){
				b_moji[i].c++;
				b_moji[j].c++;
			}
		}
	}
	
	cin >> m;
	struct MOJI r_moji[m];
	for(int i=0;i<m;i++){
		cin >> r_moji[i].s;
		r_moji[i].c=1;
		for(int j=0;j<i;j++){
			if(r_moji[i].s==r_moji[j].s){
				r_moji[i].c++;
				r_moji[j].c++;
			}
		}
	}	
	
	int f=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(b_moji[i].s==r_moji[j].s){
				f=1;
				if(b_moji[i].c-r_moji[j].c>cost){
					cost=b_moji[i].c-r_moji[j].c;
				}
			}
		}
		if(f==0){
			if(b_moji[i].c>cost){
				cost=b_moji[i].c;	
			}
		}
		f=0;
	}
	
	if(cost<0)cost=0;
	cout << cost << endl;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  bitset<8> s;
  int reinbow_count = 0;
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a/400 >= 8) reinbow_count++;
    else s.set(a/400);
  }
  if (s.count() == 0) cout << 1 << " ";
  else cout << s.count() << " ";
  cout << s.count() + reinbow_count << endl;
}

Measured memory_bytes: 3628
M, K = map(int, input().split())
if M==1:
    if K==0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    if K < 1<<M:
        A = []
        for i in range(1<<M):
            if i != K:
                A.append(i)
        print(*A, end=" ")
        print(K, end=" ")
        print(*A[::-1], end=" ")
        print(K)
    else:
        print(-1)


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

const long long MOD = 998244353;

long long inv[10000005];
long long invFact[10000005];
long long fact[10000005];

long long powmod(long long a, long long b){
    long long x = 1;
    long long y = a;
    while(b){
        if(b&1){ x = (x*y)%MOD; }
        y = (y*y)%MOD;
        b >>= 1;
    }
    return x;
}

inline long long ncr(long long a, long long b){
    return fact[a]*powmod((fact[a-b]*fact[b])%MOD, MOD-2)%MOD;
}

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

    inv[1] = 1;
    for(int i = 2; i <= N; i ++){
        inv[i] = inv[MOD%i]*(MOD-MOD/i)%MOD;
    }

    fact[0] = 1;
    invFact[0] = 1;
    for(int i = 1; i <= N; i ++){
        fact[i] = (fact[i-1]*i)%MOD;
        invFact[i] = (invFact[i-1]*inv[i])%MOD;
    }

    long long tempPow2 = 1;
    long long ans = 0;
    for(int i = N; i > (N>>1); i --){
        ans += tempPow2*ncr(N, i)%MOD;

        tempPow2 += tempPow2;
        if(tempPow2 >= MOD){tempPow2 -= MOD;}
    }
    //printf("ans(%d)=%lld\n", N, ans);
    ans = (ans+ans)%MOD;
    long long finalAns = (powmod(3, N)-ans+MOD)%MOD;

    printf("%lld", finalAns);
    return 0;
}



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

#define MAX_P  100000
#define Q_size 100001

typedef struct{
  char name[10];
  int  time;
}Process;

Process Queue[Q_size];
int     head, tail;

void push(Process p){
  Queue[tail++%Q_size]=p;
}

Process pop(){
  return Queue[head++%Q_size];
}

int main(){
  int     i, n, p_time, total=0;
  Process p;
  
  scanf("%d %d", &n, &p_time);
  
  for(i=0; i<n; i++){
    scanf("%s %d", p.name, &p.time);
    push(p);
  }
  
  while(head != tail){
    p=pop();
    
    if(p.time<=p_time){
      total+=p.time;
      printf("%s %d\n", p.name, total);
    }
    else{
      total+=p_time;
      p.time-=p_time;
      push(p);
    }
  }
  
  return 0;
}



Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int num[10];
int digits[10];
int cnt;
int res;
void dfs(int cur,int ans,bool flag)
{
    if(cur<0)
    {
        res=min(ans,res);
        return;
    }
    int st = flag?digits[cur]:0;
    for(int i=st;i<=9;i++)
    {
        if(cur==cnt-1&&i==0)
            continue;
        if(num[i])
            continue;
        dfs(cur-1,ans*10+i,flag&&i==digits[cur]);
    }
}
void sovle()
{
    int mm=m;
    cnt=0;
    while(mm)
    {
        digits[cnt++]=mm%10;
        mm/=10;
    }
    dfs(cnt-1,0,true);
    if(res==1e9)
    {
        digits[cnt++]=1;
        dfs(cnt-1,0,false);
    }
}
int main()
{
    while(cin>>m>>n)
    {
        res=1e9;
        memset(num,0,sizeof(num));
        for(int i=1;i<=n;i++)
        {
            int x;
            scanf("%d",&x);
            num[x]++;
        }
        sovle();
        cout<<res<<endl;
    }
}


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

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////

vector<int>prime;
void calc(int n){
    for(int i=2;i<=n;i++){
        bool flag=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0)flag=false;
        }
        if(flag)prime.push_back(i);
    }
}

int main(){
    int n;cin>>n;
    calc(n);
    int a[1005];memset(a,0,sizeof(a));
    for(int i=2;i<=n;i++){
        int k=i;
        for(auto x:prime){
            while(k%x==0){
                k/=x;
                a[x]++;
            }
        }
    }
    
    
    ll ans=1;
    for(int i=2;i<=n;i++){
        ans=mod(ans*(a[i]+1));
    }
    ans=mod(ans);
    cout<<ans<<endl;
    
    return 0;
}


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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	ll n,a,b;
	cin>>n>>a>>b;
	if(a==0)
		{cout<<0; return 0;}
	ll s=0;
	s=n/(a+b);
	s=s*a;
	s=s+(min(n%(a+b),a));
	cout<<s;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	int d[50];
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans;
	return 0;
}


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

int main() {
    vector<vector<int>> a(3, vector<int>(3, 0));
    rep(i,3) rep(j,3) cin >> a[i][j];

    rep(i,2){
        int d = a[0][i] - a[0][i+1];
        if(d != a[1][i] - a[1][i+1] || d!= a[2][i]-a[2][i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i,2){
        int d = a[i][0] - a[i+1][0];
        if(d != a[i][1] - a[i+1][1] || d!= a[i][2]-a[i+1][2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll b,c=0,k=0,n,h,w,m,min=100000000000,ans=0,max=0;
    string s,s2;
    cin >> n >> k; 
    VI l(n);
    rep(i,n){
        cin >> l[i];
    }
    sort(ALL(l));
    int i = l.size()-1;
    while(k){
        k--;
        ans += l[i];
        i--;
    }
    cout << ans << endl;
    return 0;
}

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef pair<int,int> pii;

int n,m;
bool vis[101010];
int dis[101010];
vector<pii> V[101010];
bool flag=false;

void dfs(int v,int d){
    if(!vis[v]){
        vis[v]=true;
        dis[v]=d;
    }else{
        if(dis[v]!=d)flag=true;
        return;
    }
    for(int i=0;i<V[v].size();i++){
        pii now=V[v][i];
        dfs(now.fi,now.se+d);
    }
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int l,r,d;
        scanf("%d%d%d",&l,&r,&d);
        V[l].push_back(mk(r,d));
        V[r].push_back(mk(l,-d));
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i,0);
        }
    }
    if(flag)printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 12160
def isInt(n):
    try:
        int(n)
    except:
        return False
    return True

S = input().split()
stack = []
for s in S:
    if isInt(s):
        stack.append(int(s))
    else:
        if s == "+":
            stack.append(stack.pop(-2) + stack.pop(-1))
        elif s == "-":
            stack.append(stack.pop(-2) - stack.pop(-1))
        elif s == "*":
            stack.append(stack.pop(-2) * stack.pop(-1))
print(stack.pop(-1))


Measured memory_bytes: 5600
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 100000

struct node{
  int key;
  struct node *parent,*left,*right;
};

struct node *root,*NIL;

void insert(int k){
  struct node *y = NIL,*x = root,*z;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
  
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(struct node *v){
  if(v == NIL)return;
  inorder(v->left);
  printf(" %d",v->key);
  inorder(v->right);
}

void preorder(struct node *v){
  if(v == NIL)return;
  printf(" %d",v->key);
  preorder(v->left); 
  preorder(v->right);
}

int main(){
  int m,k;
  int i = 0;
  char com[10];
  
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",com);
    if(strcmp(com,"insert") == 0){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(com,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;  
}



Measured memory_bytes: 25228
#include <vector>
#include <iostream>
using namespace std;
int modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n; cin >> n;
    int A[n]; for (int i = 0; i < n; i++) cin >> A[i];
    int x[n+1]; x[0] = 0; for (int i = 0; i < n; i++) x[i+1] = x[i]^A[i];
    long long ans = 0;
    constexpr int M = 1000000007;
    int cz[n+1]; cz[0] = 0; for (int i = 0; i < n; i++) cz[i+1] = cz[i] + (x[i+1]==0);
    // for (int i = 0; i <= n; i++) cerr << x[i] << ' '; cerr << endl;
    // for (int i = 0; i <= n; i++) cerr << cz[i] << ' '; cerr << endl;
    // 0になるようにわける
    if (x[n] == 0) ans += modexp(2, cz[n]-1, M);
    // cerr << cz[n] << ' ' << ans << endl;

    // 0 以外
    vector<int> idxs[1<<20];
    for (int i = 1; i <= n; i++) idxs[x[i]].push_back(i);
    for (int v = 1; v < 1<<20; v++) {
        if (x[n] != v && x[n] != 0) continue;
        if (idxs[v].empty()) continue;
        // cerr << "v = " << v << endl;
        int sz = idxs[v].size();
        long long dp0[sz], dpv[sz], Sv[sz];
        for (int i = 0; i < sz; i++) {
            if (i > 0) {
                int p = idxs[v][i-1], q = idxs[v][i];
                int nz = cz[q] - cz[p];
                dp0[i] = (dp0[i-1] + Sv[i-1] * nz) % M;
                // S0[i] = (S0[i-1] + dp0[i]) % M;
                dpv[i] = (dp0[i] + 1) % M;
                Sv[i] = (Sv[i-1] + dpv[i]) % M;
            } else {
                int q = idxs[v][0];
                dp0[0] = 0; // S0[0] = 0;
                dpv[0] = Sv[0] = 1;
            }
            // cerr << i << ' ' << dp0[i] << ' ' << dpv[i] << ' ' << endl;
        }
        if (x[n] == v) {
            ans = (ans + dpv[sz-1]) % M;
        }
        if (x[n] == 0) {
            int p = idxs[v].back();
            // int nz = cz[n] - cz[p];
            ans = (ans + Sv[sz-1]) % M;
        }
        // cerr << ans << endl;
    }
    cout << ans % M << endl;
}


Measured memory_bytes: 40680
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	int n;
	cin >> n;
	cout << n / 500 * 1000 + n % 500 - n % 5 << endl;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
t = [(T - H[i] * 0.006) for i in range(N)]
cur = 100000
for i in range(N):
    if (abs(t[i] - A) < cur): cur, ans = abs(t[i] - A), i + 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
struct R{int t,c;};
int n,m,ca,vis[2550];
long long d[2550];
bool inf[2550],inq[2550];
vector<R>v[2550];
queue<int>q;
int main()
{
	cin>>n>>m>>ca;
	for(int i=1,x,y,c;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		v[x].push_back({y,c-ca});
	}
	memset(d,-63,sizeof d);
	q.push(1);
	d[1]=0;
	while(!q.empty())
	{
		int x=q.front();
		inq[x]=0;
		q.pop();
		vis[x]++;
		if(vis[x]>n)inf[x]=1;
		for(int i=0;i<v[x].size();i++)
		{
			if(inf[x])
			{
				if(!inf[v[x][i].t])inf[v[x][i].t]=1,q.push(v[x][i].t);
			}
			else if(d[v[x][i].t]<d[x]+v[x][i].c)
			{
				d[v[x][i].t]=d[x]+v[x][i].c;
				if(!inq[v[x][i].t])
				{
					inq[v[x][i].t]=1;
					q.push(v[x][i].t);
				}
			}
		}
	}
	if(inf[n])printf("-1\n");
	else printf("%lld\n",max(0ll,d[n]));
}

Measured memory_bytes: 384
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 NX         PIC X(30).
01 LX         PIC X(30).
01 N          PIC S9(10).
01 L          PIC S9(10).
01 ans        PIC S9(10).
01 zs         PIC -Z(9)9.

*> (N * (L + (L + N - 1))) / 2
*> (N * (2 * L + N - 1)) / 2
PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO NX LX.
  IF NX(1:1) = "-"
    MOVE NX(2:FUNCTION STORED-CHAR-LENGTH(NX) - 1) TO N
    COMPUTE N = -N
  ELSE
    MOVE NX(1:FUNCTION STORED-CHAR-LENGTH(NX)) TO N
  END-IF.
  IF LX(1:1) = "-"
    MOVE LX(2:FUNCTION STORED-CHAR-LENGTH(LX) - 1) TO L
    COMPUTE L = -L
  ELSE
    MOVE LX(1:FUNCTION STORED-CHAR-LENGTH(LX)) TO L
  END-IF.
  COMPUTE ans = (N * (2 * L + N - 1)) / 2.
  IF ZERO < L
    COMPUTE ans = ans - L
  ELSE
    IF L + N - 1 < ZERO
      COMPUTE ans = ans - (L + N - 1)
    END-IF
  END-IF.
  IF ZERO = ans
    DISPLAY 0
  ELSE
    MOVE ans TO zs
    DISPLAY FUNCTION TRIM(zs)
  END-IF.
  STOP RUN.


Measured memory_bytes: 3936
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B,C;cin>>A>>B>>C;
  
  if(A<=C&&C<=B){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#include <numeric>
using ll = long long;
using namespace std;
 int main(){
 ll n,sum=0; 
 cin>>n;
rep(i,n){
if(!(i%3==0||i%5==0))
  sum+=i;
}
cout<<sum<<endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int a;
    cin >> a;
    int ans = 0;
    ans += a;
    ans += pow(a,2);
    ans += pow(a,3);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

enum Cond { Win, Lose };

int loseable_prestates(int pos, const vector<Cond>& ans, int* arr, int N) {
    int cnt = 0;
    for (int i=0; i<N; i++) {
        int st = arr[i];
        if (st > pos)
            break;
        cnt += (ans[pos-st] == Cond::Lose)? 1 : 0;
    }

    return cnt;
}

int main() {
    int N; cin >> N;
    int K; cin >> K;
    int arr[N];
    for (int i=0; i<N; i++)
        scanf("%d", arr+i);
    
    vector<Cond> ans(K+1, Cond::Lose);    
    for (int i=1; i<=K; i++) {
        int q = loseable_prestates(i, ans, arr, N);
        ans[i] = (q == 0)? Cond::Lose : Cond::Win;
    }

    cout << ((ans[K] == Cond::Win)? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    int now = 1, ans = 0;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        if(A == now){
            now++, ans++;
        }
    }
    if(ans){
        cout << N - ans << endl;
    }else{
        cout << -1 << endl;
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  string S;
  cin >> S;
  int len = S.size();
  int ret;
  if(len % 2 == 0) {
    ret = true;
    for(int i=0; i<len; i+=2) {
      if(S[i] != 'h' || S[i+1] != 'i') {
        ret = false;
      }
    }
  } else {
    ret = false;
  }
  cout << (ret ? "Yes" : "No") << endl;
}

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

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

    // 配列の宣言　型　配列名[要素の個数] = {要素の一覧}
    int data[26] = {0};
    for(int i = 0; i < w.size(); i++){
        //今見ている文字をアルファベットの昇順に変換する
        int index = w.at(i) - 'a';
        // カウンタを増やす
        data[index] ++;
    }
    int flag = 0;
    //数え上げたアルファベットの数を確認する
    for(int i = 0; i < 26; i++){
        if(data[i] %2 == 1) flag =1;
    }
    if(flag ==0)cout << "Yes" <<endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;

int main(int argc,char* argv[])
{
    int n,i;
    cin>>n;
    for(i=1;i<=n;i*=2);
    cout<<i/2<<endl;
    
    return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

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

    int s = 0, N = n;
    while(N)
        s += N % 10, N /= 10;

    if(n % s)
        cout << "No\n";
    else
        cout << "Yes\n";
    return 0;
}


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

const int maxn = 1e3 + 20;
int vis[maxn],n;
double x[maxn],y[maxn],r[maxn],dist[maxn],mp[maxn][maxn];

void SPFA(int s)
{
    queue<int>q;
    for(int i = 1;i <= n;i++) dist[i] = 1e10;
    memset(vis,0,sizeof(vis));
    while(!q.empty()) q.pop();
    dist[s] = 0;
    vis[s] = 1;
    q.push(s);

    while(!q.empty())
    {
        int v = q.front();
        q.pop();
        vis[v] = 0;
        for(int i = 1;i <= n;i++)
        {
            if(dist[i] > dist[v] + mp[v][i])
            {
                dist[i] = dist[v] + mp[v][i];
                if(!vis[i])
                {
                    vis[i] = 1;
                    q.push(i);
                }
            }
        }
    }
}

int main()
{
    while(scanf("%lf%lf%lf%lf",&x[1],&y[1],&x[2],&y[2]) != EOF)
    {
        scanf("%d",&n);
        n += 2;
        r[1] = r[2] = 0;
        mp[1][2] = mp[2][1] = sqrt((x[1] - x[2]) * (x[1] - x[2]) + (y[1] - y[2]) * (y[1] - y[2]));
        for(int i = 3;i <= n;i++)
        {
            scanf("%lf%lf%lf",&x[i],&y[i],&r[i]);
        }
        for(int i = 1;i <= n;i++)
        {
            for(int j = 1;j <= n;j++)
            {
                mp[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
                mp[i][j] -= r[i] + r[j];
                if(mp[i][j] < 0)
                {
                    mp[i][j] = 0;
                }
            }
        }
        SPFA(1);
        printf("%.10f\n",dist[2]);
    }
    return 0;
}



Measured memory_bytes: 8320
(N,A,B,C,D) = (int(i) for i in input().split(" "))
S = input()

if "##" in S[A-1:max(C,D)]:
	print("No")
else:
	if C < D:
		print("Yes")
	else:
		if "..." in S[max(0,B-2):min(D+1,N)]:
			print("Yes")
		else:
			print("No")

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;


int main(void){
	int  n;
	cin >> n;
	int dp[n+1];
	dp[0] = 0;
	dp[1] = 1;
	for(int i=2;i<=n;i++){
		dp[i] = dp[i-1]+1;
		int work=6;
		while(work <= i){
			if(dp[i] > dp[i-work]+1)dp[i] = dp[i-work]+1;
			work*=6;
		}
		work=9;
		while(work <= i){
			if(dp[i] > dp[i-work]+1)dp[i] = dp[i-work]+1;
			work*=9;
		}
	}

	cout << dp[n] << endl;
	
	return 0;

}


Measured memory_bytes: 640