akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


struct union_find {
    vector<int> parent;
    vector<int> size;
    int components = 0;

    union_find(int n = 0) {
        if (n > 0)
            init(n);
    }

    void init(int n) {
        parent.resize(n + 1);
        size.assign(n + 1, 1);
        components = n;
        for (int i = 0; i <= n; ++i) 
            parent[i] = i;
    }

    int find(int v) {
        return v == parent[v] ? v : parent[v] = find(parent[v]);
    }

    bool unite(int u, int v) {
        u = find(u);
        v = find(v);
        if (u == v)
            return false;
        if (size[u] < size[v]) 
            swap(u, v);
        parent[v] = u;
        size[u] += size[v];
        --components;
        return true;
    }
};

int main() {
    FIN;
    ll n,m; cin >> n >> m;
    vector<pair<int,int>> ab(m); // つながってる頂点のpair
    for(ll i=0;i<m;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        ab[i] = pair<int,int>(a,b);
    }

    ll ans = n*(n-1)/2;
    vector<ll> res(m);
    union_find UF(n); // 頂点の数
    for(ll i=m-1;i>=0;i--){
        res[i] = ans;
        int par_a = UF.find(ab[i].first); // 親の頂点をみつける
        int par_b = UF.find(ab[i].second);
        if(par_a == par_b) continue;
        ans -= UF.size[par_a] * UF.size[par_b]; //sizeを出すためにはfind必要
        UF.unite(ab[i].first,ab[i].second); // 頂点のpairをつなげる
    }

    rep(i,0,m) cout << res[i] << endl;

    return 0;
}



Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n,m;
	char c;
	cin>>n>>c>>m;
	if(c=='+'){
		cout<<n+m<<endl;
	}else{
	if((n-m)<0)
	cout<<"-"<<m-n<<endl;
	else
	
	
	cout<<n-m<<endl;
}
	return 0;
} 

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

counter = 0

while(b<=a):
    b = b*2
    counter += 1

while(c<=b):
    c = c*2
    counter += 1

if(counter<=k):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int n;
  cin >> n;
  vector<ll> cum(n+1,0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cum[i + 1] = cum[i] + a;
  }
  ll res = 0;
  map<ll,int> mp;
  for (int i = n; i > 0; i--) {
    res += mp[cum[i]];
    mp[cum[i]]++;
  }
  cout << res + mp[0] << endl;
  return 0;
} 

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;

	return 0;
}


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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll sa = B - A;
    if(sa % 2 == 0){
        cout << sa / 2 << "\n";
    } else {
        ll ans = 0;
        ans += sa / 2;
        ans += min(A, N - B + 1);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(input())
b = list(input())
c = list(input())
cnt = 0

for x,y,z in zip(a,b,c):
    if x == y == z:
        continue
    elif x == y or y == z or z == x:
        cnt += 1
    else:
        cnt += 2

print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 200001
#define INF 1000000007

//問題文のとおり
LL N,K;
LL a[50];

int main() {
	cin>>K;
	
	//何回ループさせるか
	LL roopNum = K / 50;

	//準備
	REP(i,50)a[i]=(i+1)+roopNum; 
	
	//ループがどの辺りで区切られるか.
	int slush= 49 - K%50;
	a[slush]--;

	//答え
	cout<<"50"<<endl;
	REP(i, 50) {
		if(i)cout<<" ";
		cout<<a[i];
	}
	cout<<endl;

	/*
	//=========================
	//デバッグ
	REP(i, K) {
		int del=49-i%50;

		a[del]-=50+1;
		REP(j,50)a[j]++;
	}
	//=============================
	//変化後
	cout << "after" << endl;
	REP(i, 50) {
		if (i)cout << " ";
		cout << a[i];
	}
	cout << endl;

	cin>>N;
	*/
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    ll one = 1, two = 1, three = 1;
    for (int i = 0;i < n;i++){
        one = one * 10 % mod;
        two = two * 9 % mod;
        three = three * 8 % mod;
    }
 
    ll rep = one - two - two + three;
    rep %= mod;
    rep = (rep + mod) % mod;
    cout << rep << endl; 
}

Measured memory_bytes: 3628
n=int(input())
S=input()

ans=0
for i in range(1000):
    j="0"*(3-len(str(i)))+str(i)
    flag1=False
    flag2=False
    flag3=False
    for i in range(n):
        if not flag1 and S[i]==j[0]:
            flag1=True
            continue
        if flag1 and not flag2:
            if S[i]==j[1]:
                flag2=True
                continue
        if flag2 and not flag3:
            if S[i]==j[2]:
                flag3=True
                break
    if flag3:
        ans+=1
print(ans)


Measured memory_bytes: 42716
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
int a[MAXN];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int l=n-k+1,r=n;
	int ans=0x3f3f3f3f;
	while(l>=1){
		if(a[l]<0&&a[r]>0){
			ans=ans<=((a[r]<<1)-a[l])?ans:(a[r]<<1)-a[l];
			ans=ans<=a[r]-(a[l]<<1)?ans:a[r]-(a[l]<<1);
		}
		else if(a[l]>=0)
		{
			ans=ans<a[r]?ans:a[r];
		}
		else if(a[r]<=0){
			ans=ans<-a[l]?ans:-a[l];
		}
//		printf("l:%d,r:%d,%d\n",l,r,ans);
		l--;r--;	
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];

int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN+1) tail=1;
  else tail++;
}

P dequeue(){
  P x;
  x=Q[head];
  if(head+1==LEN+1)head=1;
  else head++;
  return x;
}

int main(){

  int elaps=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    if(u.t<=q){
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    }else{
      elaps+=q;
      u.t-=q;
      enqueue(u);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var R = int.Parse(Console.ReadLine());

            if (R < 1200)
                Console.WriteLine("ABC");
            else if (R < 2800)
                Console.WriteLine("ARC");
            else
                Console.WriteLine("AGC");
        }
    }
}


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



int main(void){
    int array[512345]={};
    int a[212345]={};
    int n;
    cin >> n;

    for (int i = 0; i < n;i++)cin >> a[i];
    int left = 212345, right = left + 1;
    for (int i = 0; i < n;i++){
        if(i%2 == (n-1)%2){     //手順と順番が一致
            array[left--] = a[i];
        }
        else
            array[right++] = a[i];
    }
    for (int i = left + 1; i < right; i++){
        cout << array[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
int main(){
  int i,j,n,tmp,x,*A;

  scanf("%d",&n);

  A=malloc(sizeof(int)*(n+1));

  for(i=1;i<n+1;i++)
    scanf("%d",&A[i]);

  i=0;
  for(j=1;j<n;j++)
    if(A[j]<=A[n]){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  tmp=A[i+1];
  A[i+1]=A[n];
  A[n]=tmp;
  x=i+1;

  for(i=1;i<x;i++)
    printf("%d ",A[i]);
  printf("[");
  printf("%d]",A[x]);
  for(i=x+1;i<n+1;i++)
    printf(" %d",A[i]);
  printf("\n");

  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    string S;
    cin >> S;

    ll ans = 1;
    rep (i, N-1) {
        if (S[i] != S[i+1]) {
            ans++;
        }
    }

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

Measured memory_bytes: 512
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]


for i in range(1000):
    li = []
    j = str(i)
    for k in range(len(j)):
        li.append(int(j[k]))
    if len(li) != n:
        continue
    else:
        flag = True
        for s,c in sc:
            if li[s-1] != c:
                flag = False
        if flag:
            print(j)
            exit()

print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <complex>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
using namespace std;

#define EPS 1e-6
typedef complex<double> P;

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

double dist(const P& a, const P& b)
{
	return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

bool isIntoC(const P& p, const C& c)
{
	return dist(p, c.p) < c.r+EPS;
}

bool isIntoC(const L& l, const C& c)
{
	return dist(l[0], c.p) < c.r+EPS && dist(l[1], c.p) < c.r+EPS;
}

int CrossPtNum(const C& c, const L& l)
{
	P LV=l[0]-l[1];
	double A=(LV.real()*LV.real())+(LV.imag()*LV.imag());
	double B=(LV.real()*l[0].real())-(LV.real()*c.p.real())+(LV.imag()*l[0].imag())-(LV.imag()*c.p.imag());
	double C=(l[0].real()-c.p.real())*(l[0].real()-c.p.real())+(l[0].imag()-c.p.imag())*(l[0].imag()-c.p.imag())-(c.r*c.r);

	if(fabs(B*B-A*C) < EPS) return 1;
	if(B*B-A*C  > 0) return 2;
	
	return 0;
}

bool intersectSC(const L& l, const C& c)
{	
	double vc=dot(l[1]-l[0], c.p-l[0]);
	if(vc<0)
	{
		double dif=c.r-dist(l[0], c.p);
		return dif+EPS > 0;
	}
	
	double vv=dot(l[1]-l[0], l[1]-l[0]);
	
	if(vc > vv)
	{
		double d=dist(l[1], c.p);
		double dif=c.r*c.r-d*d;
		
		return dif+EPS > 0;
	}
	
	double cc=dot(c.p-l[0], c.p-l[0]);
	double dif=c.r*c.r-(cc-(vc/vv)*vc);
	
	return dif+EPS > 0;
}

int tmr;	

class UFO
{
	public:

		double x,y,r,v,d,x0,y0;

		UFO(int X, int Y, int R, int V)
		{
			x0=X;
			y0=Y;
			r=R;
			v=V;
			d=sqrt(x0*x0+y0*y0);
		}

		int move()
		{
			x=x0-tmr*v*x0/sqrt(x0*x0+y0*y0);
			y=y0-tmr*v*y0/sqrt(x0*x0+y0*y0);
			d-=v;
			return d;
		}
};

int main()
{
	int R,N,x,y,r,v;
	while(cin >> R >> N, (R||N))
	{
		list<UFO> ls;
		while(N--)
		{
			cin >> x >> y >> r >> v;
			ls.push_back(UFO(x,y,r,v));
		}

		int cnt = 0;
		tmr = 0;
		while(true)
		{
			tmr++;
			double md = 1e20;
			double mx,my;
			for(list<UFO>::iterator it=ls.begin(); it!=ls.end();)
			{
				it->move();
				if(it->d <= R)
				{
					it = ls.erase(it);
					cnt++;
				}
				else
				{
					if(md>it->d)
					{
						mx=it->x;
						my=it->y;
						md=it->d;
					}
					it++;
				}
			}
			if(ls.empty()) { cout << cnt << endl; break; }

			L laser(P(R*mx/sqrt(mx*mx+my*my)+EPS,R*my/sqrt(mx*mx+my*my))+EPS,P(mx*3000,my*3000));
			for(list<UFO>::iterator it=ls.begin(); it!=ls.end();)
			{
				C ufo(P(it->x,it->y),it->r);
				if(intersectSC(laser,ufo))
				{
					it = ls.erase(it);
				}
				else
				{
					it++;
				}
			}
		}


	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int n,k;cin>>n>>k;
    vin x(n);
    rep(i,n)cin>>x[i];
    int m=inf;
    for(int i=0;i+k-1<n;i++){
        m=min(m,min(abs(x[i]-x[i+k-1])+abs(x[i]),abs(x[i]-x[i+k-1])+abs(x[i+k-1])));
    }
    cout<<m<<endl;
}

Measured memory_bytes: 640
N = int(input())
H = list(map(int,input().split()))

INF = float('inf')
dp = [INF] * N
dp[0] = 0
for i in range(1,N):
    dp[i] = min(dp[i], dp[i-1] + abs(H[i] - H[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(H[i] - H[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    //a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		//res%=MOD;
		b--;}
        a=(a*a);
        //a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=100000;
	string t,s;
	cin>>s>>t;
	k=s.size()-t.size();
	for(i=0;i<k+1;i++)
	{
	    int dif=0;
	    for(j=i;j<(t.size()+i);j++)
	    {
	        if(s[j]!=t[j-i])
	        dif++;
	    }
	    cnt=min(dif,cnt);
	}
	cout<<cnt;
	
	
	
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

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


int main() {
  int N;
  int k;
  int m;
  int c;
  cin >> N;
  k = N / 100;
  m = ( N - 100 * k) / 10;
  c = ( N - 100 * k - 10 * m);
  if ( c == 2){
    cout << "hon" << endl;
  }
  if ( c == 4){
    cout << "hon" << endl;
  }
  if ( c == 5){
    cout << "hon" << endl;
  }
  if ( c == 7){
    cout << "hon" << endl;
  }
  if ( c == 9){
    cout << "hon" << endl;
  }
  if ( c == 0){
    cout << "pon" << endl;
  }
  if ( c ==  1){
    cout << "pon" << endl;
  }
  if ( c ==  6){
    cout << "pon" << endl;
  }
  if ( c ==  8){
    cout << "pon" << endl;
  }
  if ( c == 3){
    cout << "bon" <<endl;
  }
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
 
ld pi = 3.141592653589;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  ll r;
  cin >> r;
 
  cout << fixed << setprecision(5) << 2 * pi * r << en;
 
  return 0;
}

Measured memory_bytes: 3796
import sys
inp = sys.stdin.readline

N, A, B, C = map(int,inp().split())
L = [int(inp()) for _ in range(N)]

inf = float('inf')

def dfs(x, a, b, c, m):
  if(x == N):
    if(min(a, b, c) > 0):
      return abs(a-A) + abs(b-B) + abs(c-C) + (m-3) * 10
    else:
      return inf
  ret0 = dfs(x+1, a, b, c, m)
  ret1 = dfs(x+1, a+L[x], b, c, m+1)
  ret2 = dfs(x+1, a, b+L[x], c, m+1)
  ret3 = dfs(x+1, a, b, c+L[x], m+1)
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0, 0))

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    D=LI()
    
    for i in range(N,10**5+1):
        ans=str(i)
        f=1
        for j in range(K):
            if str(D[j]) in ans:
                f=0
                break
            
        if f==1:
            break
        
        
    print(ans)

main()


Measured memory_bytes: 40940
#include <cstdio>
#include <cctype>
#include <string>

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

  char buf[16];
  scanf("%s", buf);
  std::string S=buf;

  for (int i=0; i<A; ++i)
    if (!isdigit(S[i]))
      return !printf("No\n");

  if (S[A] != '-')
    return !printf("No\n");

  for (int i=A+1; i<=A+B; ++i)
    if (!isdigit(S[i]))
      return !printf("No\n");

  printf("Yes\n");
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;

    vector<ll> A(10101010, 0);
    for(int i=1;i<=N;i++){
        for(int j=i;j<=N;j+=i){
            A[j]++;
        }
    }
    ll res = 0;
    REP(i, N+1){
        res += A[i] * i;
    }
    cout << res << endl;
    return 0;
}

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//____________________


int32_t main()
{ 
  io;
 
  
  string s;
  cin>>s;
  stack<char> st;
  int cnt=0;

  st.push(s[0]);
  for(int i=1;i<s.size();i++)
  {
    if(st.empty())
    {
      st.push(s[i]); 
      continue;
    }
    if(s[i]!=st.top())
    {
      st.pop();
      cnt+=2;
    }
    else
    {
      st.push(s[i]);
    }
  }
  
  cout<<cnt;
 return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    if (n < 3) {
        cout << 0 << endl;
        return;
    }

    LL sum = n - 1;
    for (LL i = 2; i * i < n; ++i) {
        if (n % i != 0) continue;
        if (n % (n/i - 1) != 0) {
            sum += n / i - 1;
        }
    }
    cout << sum << endl;
}

int main() {
    solve();
    
    return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
	
			//答えの出力
			var ans = N*N*N;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 27896
#include<iostream>
#include<stdio.h>

using namespace std;

class Dice{
public:
	//Constructor
 	Dice(){
		number = new int[6];
		work   = new int[6];
	};
	//Destructor
	~Dice(){
		delete[] number;
		delete[] work;
	};
	//class functions (public)
	void setLabel(int index, int num){
		number[index] = num;
	};
	void roll(char ch){
		for(int i=0;i<6;++i){work[i]=number[i];}
		switch(ch){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'R':
			setNumber(work[0],work[3],work[1],work[4],work[2],work[5]);
			break;	
		}
	};

	int p0(){return number[0];};
	int p1(){return number[1];};
	int p2(){return number[2];};
	int p3(){return number[3];};
	int p4(){return number[4];};
	int p5(){return number[5];};

private:
	void setNumber(int n0, int n1, int n2, int n3, int n4, int n5){
	number[0]=n0;
	number[1]=n1;
	number[2]=n2;
	number[3]=n3;
	number[4]=n4;
	number[5]=n5;

	}

private:
	int* number;
	int* work;

};


int main(){
	Dice dice;
	char ch;
	int  num;
	for(int i=0;i<6;++i){
		cin >> num;
		dice.setLabel(i,num);
	}

	cin >> num; //number of the set of inputs to be given.
	int n0,n1;

	for(int i=0;i<num;++i){
		cin >> n0 >> n1;
		//to get n0 at dice.p0
		if(n0==dice.p3()){dice.roll('E');}
		if(n0==dice.p2()){dice.roll('W');}
		while(n0!=dice.p0()){dice.roll('N');}
		//n1 is in one of p1,p2,p3,p4...
		while(n1!=dice.p1()){dice.roll('R');}
		cout << dice.p2() << endl;
	}

	return 0;
}



Measured memory_bytes: 3072
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
heights = list(map(int, input().split()))
dp = [float("inf") for i in range(n+2)]
dp[0] = 0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(heights[i] - heights[i-j]))
print(dp[n-1])

Measured memory_bytes: 56796
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<=x;l=m;else;r=m;end;end;l;end

function main()
    n = readline() |> parseInt
    a = readline() |> split |> parseMap |> sort
    d = Dict{Int,Int}()
    for i in 1:n
        if haskey(d,a[i])
            d[a[i]]+=1
        else
            d[a[i]]=1
        end
    end
    x = 0
    for i in n:-1:1
        r = 0
        while 2^r<=a[i]
            r+=1
        end
        t = bsearch(a,2^r-a[i])
        if 0<t<=n
            if a[t]+a[i]==2^r
             if (a[t]!=a[i]&&d[a[t]]>0&&d[a[i]]>0)||(a[t]==a[i]&&d[a[i]]>1)
                 x+=1
                 d[a[t]]-=1
                 d[a[i]]-=1
             end
            end
         end
     end

    println(x)
end

main()

Measured memory_bytes: 196776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATenki solver = new ATenki();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATenki {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            String y = in.next();
            int ans = 0;
            for (int i = 0; i < 3; i++) {
                if (x.charAt(i) == y.charAt(i)) ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 24916
#include<iostream>

using namespace std;
int main(){
	while (true){
		int g = 0;
		int s = 0;
		int st = 0;
		cin >> g >> s;
		if (g == 0 && s == 0){
			break;
		}
		for (int i = 1; i <= g; i++){
			for (int b = i + 1; b <= g; b++){
				for (int c = b + 1; c <= g; c++){
					if (i + b + c == s){
						st++;
					}
				}
			}
		}
		cout << st << endl;
	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	while(true){
		int H=in(),W=in();
		if(!H && !W) break;
		REP(i,H){
			REP(j,W){
				if(((i+j)%2)==0) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



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

int main()
{
    string S; cin >> S;
    int Q; cin >> Q;

    string pre, suf;
    int dir = 0;
    int T, F;
    string C;
    rep(i, Q) {
        cin >> T;
        if (T == 1) {
            dir ^= 1;
        } else {
            cin >> F >> C;
            if ((F == 1) == (dir == 0)){
                pre += C;
            } else {
                suf += C;
            }
        }
    }

    string ans;
    if (dir == 0) {
        reverse(all(pre));
        ans = pre + S + suf;
    } else {
        reverse(all(S));
        reverse(all(suf));
        ans = suf + S + pre;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1348
class Pq
  def initialize(enumerable = nil)
    raise ArgumentError unless enumerable.nil? || enumerable.respond_to?(:each)
    @heap = []
    @size = 0
    enumerable.each(&method(:push)) if enumerable
  end

  def push(item)
    i = @size
    @size = @size.next
    while i.positive? do
      p = i.pred / 2
      break if @heap[p] <= item
      @heap[i] = @heap[p]
      i = p
    end
    @heap[i] = item
  end

  def pop
    return if empty?

    r = @heap.first
    @size = @size.pred
    x = @heap[@size]
    i = 0
    while (i * 2).next < @size do
      a = (i * 2).next
      b = a.next
      a = b if b < @size && @heap[b] < @heap[a]
      break if @heap[a] >= x
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    r
  end

  def first
    @heap.first
  end

  def empty?
    @size.zero?
  end
end

N, M = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

queue = Pq.new
A.each {|a| queue.push(-a) }
M.times { queue.push(-(-queue.pop / 2)) }
sum = 0
while money = queue.pop
  sum += -money
end

puts sum


Measured memory_bytes: 10580
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

int main() {
    uint64_t hh, ww;
    cin >> hh >> ww;
    uint64_t h, w;
    cin >> h >> w;
    cout << hh * ww - (h * ww + w * hh - h * w);
    return 0;
}


Measured memory_bytes: 256
S = input()

N = len(S)

f = (N - 1) // 2
s = (N + 1) // 2

if S == S[::-1]:
    flg = True
else:
    flg = False

if flg:
    if S[0:f] == S[s:N]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double min = 10;
		double ans = 0;
		for (int i = 0; i < 5; i++) {
			double A = sc.nextInt();
			ans += Math.ceil(A / 10) * 10;
			double a = A % 10;
			if (min > a&&a!=0) {
				min = a;
			}
		}
		sc.close();
		int ans2=(int)(ans-(10-min));
		System.out.println(ans2);
	}
}


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

const unsigned long long int maxv = pow(10,18);
int main(void){
   
   int N;
   unsigned long long int A;
   
   cin >> N;
   vector<unsigned long long int> vec{};
   
   
   for(int i=0;i<N;i++){
        cin >> A;
        vec.push_back(A);
   }
   
   sort(vec.begin(),vec.end());
   __int128 ans = vec[0];
   
   if(ans == 0){
       cout << 0 << endl;
   }
   else{
       for(int i=1;i<N;i++){
            
            if(ans*vec[i] > maxv) {
                cout << -1 << endl; 
                return 0;
            }
            
            ans *= vec[i];
       }
       unsigned long long t = ans;
       cout << t << endl;
   }
   
}

Measured memory_bytes: 4152
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((g * 10 + b) % 4 == 0)
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";
}

Measured memory_bytes: 3588
#include <iostream>
 
using namespace std;
 
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (abs(a-b) <= d && abs(b-c) <= d) {
        cout<<"Yes"<<endl;
    }else if(abs(a-c) <= d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int amari = x % 100;
        int div = x / 100;
        if (amari <= div * 5) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
    int n;cin>>n;
    double v[n];rep(i,n)cin>>v[i];
    sort(v,v+n);
    rep(i,n-1){
        v[i+1]=(v[i]+v[i+1])/2;
    }
    cout<<setprecision(10)<<v[n-1]<<endl;
}

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

int main() {
	int n;
	for(int x=0;x<3;x++){
		scanf("%1d",&n);
		if(n==1)n=9;
		else if(n==9)n=1;
		cout<<n;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    if(x.first<y.second)
        return true;
    else if(x.first==y.second)
        return x.second<y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }

void solve()
{   
    ll n,W;
    cin>>n>>W;
    vector<ll> w(n);
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
        cin>>w[i],cin>>v[i];
    ll dp[W+1][n+1]={0};
    for(ll i=0;i<=n;i++)
        dp[0][i]=0;
    for(ll i=0;i<=W;i++)
        dp[i][0]=0;
    for(ll i=1;i<=W;i++){
        for(ll j=1;j<=n;j++){
            if(i-w[j-1]>=0){
                dp[i][j]=max(dp[i-w[j-1]][j-1]+v[j-1],dp[i][j-1]);
            }
            else
                dp[i][j]+=dp[i][j-1];
        }
    }
    cout<<dp[W][n];

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


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
int main() {
	// #ifndef ONLINE_JUDGE
	// 	// for getting input from input.txt
	// 	freopen("input.txt", "r", stdin);
	// 	// for writing output to output.txt
	// 	freopen("output.txt", "w", stdout);
	// #endif
		long double a,b;
		cin>>a>>b;
		cout<<long(a*b);
		return 0;
	}	

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

int main(){
    int w, h, n, x, y, a;
    int w0=0, h0=0;
    cin>>w>>h>>n;
    for (int i=0; i<n; i++){
        cin>>x>>y>>a;
        if (a == 1 && w0 < x) w0 = x;
        if (a == 2 && w > x) w = x;
        if (a == 3 && h0 < y) h0 = y;
        if (a == 4 && h > y) h = y;
    }
    if ((w<w0)|(h<h0)) cout<<0<<endl;
    else cout<<(w-w0)*(h-h0)<<endl;
}


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

int main(){
	int a, b, c, count = 0;
	bool divi[10001] = { false };
	
	cin >> a >> b >> c;
	for(int i = 1; i <= c; i++){
		if(c % i == 0){
			divi[i] = true;
		}
	}
	for(int i = a; i <= b; i++){
		if(divi[i] == true){
			count++;
		}
	}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  long s;
  cin>>s;
  set<long> appeared;
  long pre = s;
  auto f = [](long x){
    if(x%2==0) return x/2;
    else return x*3+1;
  };

  int ans = 0;
  while(appeared.count(pre) == 0){
    appeared.insert(pre);
    pre = f(pre);
    ans++;
  }

  cout << ans+1 << endl;


  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

D, = map(int,readline().split())
#D = 365
*c, = map(int,readline().split())
s = tuple(tuple(map(int,readline().split())) for _ in range(D))

def output(ans):
    for i in ans: print(i+1)

def score(c,s,ans):
    last = [-1]*26
    score = 0
    for i, ai in enumerate(ans):
        score += s[i][ai]
        last[ai] = i
        for ci,li in zip(c,last):
            score -= ci*(i-li)
        print(score)
    #return score


ans = [*map(lambda x: int(x)-1,read().split())]
#print(ans)
score(c,s,ans)






Measured memory_bytes: 9396
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main(){
  int n;
  long long int num = 0;
  vector<string> str(100001);
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> str.at(i);
    sort(str.at(i).begin(), str.at(i).end());
  }
  map<string, long long int> list_str;
  for(int i=0; i<n; i++){
    list_str[str.at(i)] = 0;
  }
  for(int i=0; i<n; i++){
    list_str[str.at(i)]++;
  }
  
  for(int i=0; i<n; i++){
    num += list_str[str.at(i)]*(list_str[str.at(i)]-1)/2;
    list_str[str.at(i)] = 0;
  }
  cout << num << endl;
}

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

int main() {
  int N;
  cin >> N;
  if (N % 10 == 3) {
    cout << "bon" << endl;
  }
  else if (N % 10 == 0) {
    cout << "pon" << endl;
  }
  else if (N % 10 == 1) {
    cout << "pon" << endl;
  }
  else if (N % 10 == 6) {
    cout << "pon" << endl;
  }
  else if (N % 10 == 8) {
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<int,int> P;

int n, m, q;
P x[11][100000];
P state[100000];
vector<int> e[100000];

int main(){
    I(n,m);
    rep(i,n) state[i] = P(0, -1);
    rep(i,11) rep(j,n) x[i][j] = P(-1, -1);
    rep(i,m){
        int a, b;
        I(a,b); a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    I(q);
    rep(i,q){
        int v, d, c;
        I(v,d,c); v--;
        x[d][v] = P(c,i);
    }
    for(int i = 10; i >= 0; i--){
        rep(j,n){
            if(x[i][j].first == -1) continue;
            if(state[j].second < x[i][j].second){
                state[j] = x[i][j];
            }
            if(i){
                rep(k, e[j].size()){
                    if(x[i-1][e[j][k]].first == -1 || x[i-1][e[j][k]].second < x[i][j].second){
                        x[i-1][e[j][k]] = x[i][j];
                    }
                }
            }
        }
    }
    rep(i,n) cout << state[i].first << endl;
}
































Measured memory_bytes: 16376
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,w;
  cin>>n>>w;
  long long int wt[n],val[n];
  long long int sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>wt[i]>>val[i];
    sum+=val[i];
  }
  if(n==1)
  {
    if(w>=wt[0])
      cout<<val[0];
    else
      cout<<"0";
    return 0;
  }
  vector<vector<long long int>> dp(n+1,vector<long long int>(sum+1,INT_MAX));
  for(int i=0;i<=n;i++)
  {
    dp[i][0]=0;
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=sum;j++)
    {
      if(val[i-1]<=j)
        dp[i][j]=min(dp[i-1][j-val[i-1]]+wt[i-1],dp[i-1][j]);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  int ans=0;
  for(int i=1;i<=sum;i++)
  {
    if(dp[n][i]<=w)
      ans=i;
  }
  cout<<ans;
}

Measured memory_bytes: 80256
"
3. ABC104C - All Green
リンク：　https://atcoder.jp/contests/abc104/tasks/abc104_c
"

# 入力
D, G = gets.split.map(&:to_i)
p = []
c = []
D.times do |i|
  p[i], c[i] = gets.split.map(&:to_i)
end

# Dでbit全探索
# i桁目をp[i]進報で表せば、得点の計算できそう
ans = 1000
(1 << D).times do |i|
  point = 0
  ma = -1
  gap = 0
  num = 0
  tmp = 0
  D.times do |j|
    # i[j]==1なら配点100(j+1)の問題を完全に解く
    if i[j] == 1
      point = point + 100*(j+1) * p[j] + c[j]
      num = num + p[j]
      if point >= G
        ans = [ans, num].min
      end
    else
      ma = [ma, j].max
    end
  end
  # ここまでで全問解く配点の問題は決まった
  # 目標までの差を出す
  gap = G - point
  if ma != -1 && gap > 0
  # 完全に解かない(i[j]==0なるjの最大値)もののうち、
  # 最も高い配点はmaに入ってる配点100(ma+1)点 
    tmp = (gap.to_f / (100*(ma+1)).to_f).ceil #その配点を何問解けば目標達成できるか
    if tmp <= p[ma]-1 # これを満たさない場合は、完全に解く選択がミスってる
      # ここに入ったってことは、maの問題をnumだけ中途半端に解けば目標達成できる
      num = num + tmp
      ans = [ans, num].min
    end
  end
end
puts ans

Measured memory_bytes: 1788
#include<stdio.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)

int main() {
	int n, k, i;
	unsigned long long a = 0;
	S(d, n), S(d, k);
	for (i = 0; i < n - 1; i++) a += a / (k - 1) + 1;
	P(lld, a);
	return 0;
}

Measured memory_bytes: 600
def keycount(li):
    from collections import defaultdict
    count = defaultdict(int)
    for i in li:
        count[i] += 1
    dst = sorted([i for k, i in count.items()])
    return dst
num, shurui = map(int, input().split())
ball = input().split()
ballset = set(ball)
if shurui < len(ballset):
    count = len(ballset) - shurui
    dst = sum(keycount(ball)[:count])
else:
    dst = 0
print(dst)


Measured memory_bytes: 48928
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<stack>
#include<sstream>
#include<string>
#include<cassert>
#include<ctime>
#include<functional>
#include<deque>
#include<bitset>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
int kase = 0;
int n, m;
const int maxn = 1e5 + 100;
vector<int> G[maxn];
int cnt[maxn], cnt2[maxn];

void dfs(int u, int pa, int d, int wd[])
{
	wd[u] = d;
	for (int i = 0; i < G[u].size(); i++)
	{
		int v = G[u][i];
		if (v != pa)
		{
			dfs(v, u, d + 1, wd);
		}
	}
}


int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, -1, 0, cnt);
	dfs(n, -1, 0, cnt2);
	int ret = 0;
	for (int i = 1; i <= n; i++)  if (cnt[i] <= cnt2[i]) ret++;
	else ret--;
	if(ret > 0)
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  int res = 0;
  int cur = 0;
  for (int i = N - 2; i >= 0; i--) {
    if (H[i] >= H[i + 1]) {
      cur++;
      res = max(res, cur);
    } else {
      cur = 0;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 640