akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
vector<ttgl> ones;
ll n, m, q;
int dsu[mxN];
int find(int a) {
    return a==dsu[a] ? a : dsu[a] = find(dsu[a]);
}
void merge(int a, int b) {
    a = find(a);
    b = find(b);
    dsu[b] = a;
}
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>m>>q;
    owo(i, 0, n) {
        dsu[i] = i;
    }
    int a, b, c;
    owo(i, 0, q) {
        cin>>a>>b>>c;
        if(c==1&&m==n-1) {
            cout<<"No\n";
            exit(0);
        }
        if(c==0) {
            merge(a, b);
        }else {
            ones.senpai({a, b});
        }
    }
    for(auto p: ones) {
        if(find(p.first)==find(p.second)) {
            cout<<"No\n";
            exit(0);
        }
    }
    ll comp = 0;
    owo(i, 0, n) {
        if(i==find(i)) {
            comp++;
        }
    }
    cout<<((m<=n-comp+comp*(comp-1)/2) ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 4600
def dfs(A: list):
    if len(A) > nn:
        return
    if len(A) and (x := int("".join(A))) >= n and ans[0] > x:
        ans[0] = x
        return

    for v in d:
        if v == "0" and len(A) == 0:
            next
        A.append(v)
        dfs(A)
        A.pop()


n, k = map(int, input().split())
d = sorted(list(set([str(i) for i in range(10)]) - set(input().split())))
nn = len(str(n))+1
ans = [10**7]
dfs([])
print(ans[0])


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

using namespace std;
#define int long long
const int maxn=3e3+5;
const int p=998244353;
int po[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int u=1;
    for(int i=0;i<maxn;++i)
    {
        po[i]=u;
        u*=2;
        u%=p;
    }
    int n,s;
    cin>>n>>s;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int ans[s+1];
    for(int i=0;i<=s;++i)
    {
        ans[i]=0;
    }
    ans[0]=1;
    for(int i=0;i<n;++i)
    {
        int curr[s+1];
        for(int j=0;j<=s;++j)
        {
            curr[j]=ans[j];
        }
        for(int j=s;j>=0;j--)
        {
            if((a[i]+j)<=s)
            {
                ans[a[i]+j]+=ans[j];
            }
        }
        for(int j=0;j<=s;++j)
        {
            ans[j]+=curr[j];
            ans[j]%=p;
            //cout<<j<<" "<<ans[j]<<endl;
        }
        //cout<<endl;
    }
    cout<<ans[s];
    return 0;
}


Measured memory_bytes: 3752
import math
a,b,x=map(int,input().split())
if x>=(1/2)*a**2*b:
  k=2*(a**2*b-x)/a**3
  print(math.degrees(math.atan(k)))
else:
  j=2*x/(a*b**2)
  print(90-math.degrees(math.atan(j)))

Measured memory_bytes: 9356
def main():
    count=0
    n=int(input())
    x = [list(map(int, input().split())) for i in range(n)]
    for i in range(n):
        if x[i][0]==x[i][1]:
            count=count+1
        else:
            count=0

        if count==3:
            print("Yes")
            break


    if count!=3:
        print("No")





if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <algorithm>
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>

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

const auto INF = static_cast<ll>(1e15);
const auto MOD = static_cast<ll>(1e9 + 7);

/*********** Variables ***********/
ll L, R, ANS;

/*********** Functions ***********/
void input() {
    cin >> L >> R;
}

void solve() {
    ANS = INF;
    for (ll i = L; i < min(L + 2018, R); i++) {
        for (ll j = i + 1; j <= min(L + 2018, R); j++) {
            ANS = min(ANS, i * j % 2019);
        }
    }
}

void output() {
    cout << ANS << endl;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  ll ans = -1;
  for (ll i = 0; i < s.length(); i++) {
    ll cnt = 0;
    for (ll j = 0; j < t.length(); j++) {
      if (i + t.length() > s.length()) {
        break;
      }
      if (i + j < s.length() && s[i + j] == t[j]) {
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << t.length() - ans << endl;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#define X first
#define Y second
#define pb push_back
using namespace std;
typedef pair<int,int> P;
vector<P> cakes; 

int main(){
  int i,j,k,n,w,d,p,s,re[112];
  while(1){
    cin>>n>>w>>d;
    //      cout<<n<<","<<w<<","<<d<<endl;
    if(n==0 && w==0 && d==0)break;
    cakes.clear();
    cakes.pb(P(0,0));
    cakes.pb(P(w,d));
    for(i=0;i<n;i++){
      cin>>p>>s;
      P tmp=cakes[p],temp=cakes[p];
      s%=tmp.X+tmp.Y;
      if(s>tmp.X){
	s-=tmp.X;
	//	cout<<"["<<s<<"]";
	temp.Y=min(tmp.Y-s,s);
	cakes.pb(temp);
	cakes.pb(P(tmp.X,max(tmp.Y-s,s)));
      }else{
	//	cout<<"("<<s<<")";
	temp.X=min(tmp.X-s,s);
	cakes.pb(temp);
	cakes.pb(P(max(tmp.X-s,s),tmp.Y));
      }
      for(j=p;j<cakes.size()-1;j++)
	cakes[j]=cakes[j+1];
      cakes.pop_back();
    }
    for(i=0;i<n+1;i++)
      re[i]=cakes[i+1].X*cakes[i+1].Y;
    sort(re,re+n+1);
    for(i=0;i<n;i++)
      cout<<re[i]<<" ";
    cout<<re[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
# include<bits/stdc++.h>
using namespace std;
bool compare(int a,int b)
{
    return a>b;
}
int main()
{
    int n,m,sum=0,ans=0,f=1;
    cin>>n>>m;
    int arr[n];
    for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            sum+=arr[i];
        }
     sort(arr,arr+n,compare);
     for(int i=0;i<n;i++)
     {
         if(arr[i]>=1.0*sum/(4*m))
         {
             ans++;
         }
         if(ans>=m)
         {
             cout<<"Yes"<<endl;
             f=0;
             break;
         }
     }
     if(f==1)
        cout<<"No"<<endl;
     return 0;
}


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

// ソルバー
class Abc140c {
    public:
    int solve(int n, int *b);
};

int Abc140c::solve(int n, int *b) {
    int s=b[n-1];
    int m=b[n-1];
    for(int i=n-1;i>=2;i--){
        s += (b[i] < b[i-1]) ? b[i] : b[i-1];
    }
    s += b[1];
    return s;
}

// 実行
int main () {
    int n;
    std::cin >> n;
    int* b = new int[n];
    for(int i=1;i<=n-1;i++) {
        std::cin >> b[i];
    }

    Abc140c p;
    std::cout << p.solve(n, b) << std::endl;
    return 0;
}


Measured memory_bytes: 256
X = input()
X_1=int(X[:2])
X_2=int(X[2:])
flag_1=(0 <= X_1 <=99 and 1 <= X_2 <= 12)
flag_2=(0 <= X_2 <=99 and 1 <= X_1 <= 12)
if flag_1 and flag_2:
    print("AMBIGUOUS")
elif flag_1:
    print("YYMM")
elif flag_2:
    print("MMYY")
else:
    print("NA")

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

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

    int value = 1;
    int cnt = 0;

    for(int i=0; i<n; i++){
        if(a[i] == value) { cnt++; value++;}
    }

    if(!cnt) cout << "-1" << endl;
    else cout << n-cnt<< endl;
    return 0;
    
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll h,w;

bool in(ll y, ll x){
    return 0<=y && y<h && 0<=x && x<w;
}

int main(){
    string o,e; cin >> o >> e;
    string ans;
    rep(i,o.size()){
        ans.push_back(o[i]);
        ans.push_back(e[i]);
        if(i==o.size()-1 && o.size()!=e.size())ans.pop_back();
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var nq = Console.ReadLine().Split(' ');
        var n = int.Parse(nq[0]);
        var q = int.Parse(nq[1]);

        var s = Console.ReadLine();
        var d = new int[n];
        for (int i = 1; i < n; i++)
        {
            if (s[i - 1] == 'A' && s[i] == 'C')
            {
                d[i] = d[i - 1] + 1;
            }
            else
            {
                d[i] = d[i - 1];
            }
        }

        for (int i = 0; i < q; i++)
        {
            var lr = Console.ReadLine().Split(' ');
            var l = int.Parse(lr[0]);
            var r = int.Parse(lr[1]);
            Console.WriteLine(d[r - 1] - d[l - 1]);
        }
    }
}

Measured memory_bytes: 16328
import sys
sys.setrecursionlimit(10000000)
n,u,v=map(int,input().split())
kilist=[[] for i in range(n)]
for i in range(n-1):
        a,b=map(int,input().split())
        kilist[a-1].append((b,1))
        kilist[b-1].append((a,1))    
visitedlist=[-1 for  _ in range(n)]
anslist=[0 for _ in range(n)]
searchedlist=[-1 for _ in range(n)]        
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass
        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(u)
u_list=anslist.copy()
visitedlist=[-1 for  _ in range(n)]
anslist=[0 for _ in range(n)]
searchedlist=[-1 for _ in range(n)]  

q=search(v)
v_list=anslist.copy()

maxi=0
for i in range(n):
    if u_list[i]<=v_list[i]:
        maxi=max(maxi,v_list[i])
print(maxi-1)

Measured memory_bytes: 116780
n = int(input())
tmp = [int(i) for _ in range(n) for i in input().split()]

xs = tmp[0::3]
ys = tmp[1::3]
hs = tmp[2::3]
stopflag = False

hmax = max(hs)
index = hs.index(max(hs))
xmax = xs[index]
ymax = ys[index]

for cx in range(101):
    for cy in range(101):
        H = hmax + abs(xmax-cx) + abs(ymax-cy)
        for x,y,h in zip(xs,ys,hs):
            if h != max(H-abs(x-cx)-abs(y-cy),0):
                break
        else:
            print('{} {} {}'.format(cx,cy,H))
            stopflag = True
            break
    if stopflag:
        break


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

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    ll n, k, a[1000 + 100], ke[1000 * (1000 + 1) / 2 + 100], ke_cou = 0, add;
    ll ans = 0, want, cou = 0;

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

    for(int i = 0; i < n; i++){
        ke[ke_cou++] = a[i];
        add = a[i];
        for(int j = i + 1; j < n; j++){
            add += a[j];
            ke[ke_cou++] = add;
        }
    }

    for(int i = 45; i >= 0; i--){
        want = ans | (1LL<<i);
        cou = 0;
        for(int j = 0; j < ke_cou; j++){
            if((want & ke[j]) == want)cou++;
        }
        if(cou >= k)ans = want;
    }

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


Measured memory_bytes: 4224
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=10005;
const int mod=1000000007;
int n;LL jc[N],ny[N];
inline LL quick(LL a,int b)
{
  LL r=1,base=a;
  while(b)
    {
      if(b&1) r=r*base%mod;
      base=base*base%mod;
      b>>=1;
    }
  return r;
}
int f[4005][4005],g[4005][4005],ans;
inline void up(int &x,int y) {x+=y;if(x>=mod) x-=mod;}
int main( )
{
  int i,j,x,y,x2,y2;
  n=read( );
  jc[0]=1;
  for(i=1;i<N;i++) jc[i]=jc[i-1]*i%mod;
  ny[0]=1;ny[N-1]=quick(jc[N-1],mod-2);
  for(i=N-1;i>=2;i--) ny[i-1]=ny[i]*i%mod;
  for(i=1;i<=n;i++)
    {
      x=read( );y=read( );
      f[-x+2000][-y+2000]++;g[x+2000][y+2000]++;
      x2=x<<1,y2=y<<1;
      up(ans,mod-jc[x2+y2]*ny[x2]%mod*ny[y2]%mod);
    }
  for(i=0;i<=4000;i++)
    for(j=0;j<=4000;j++)
      {
	if(g[i][j]) up(ans,(LL)f[i][j]*g[i][j]%mod);
	up(f[i+1][j],f[i][j]);
	up(f[i][j+1],f[i][j]);
      }
  printf("%lld",(LL)ans*quick(2,mod-2)%mod);
  return 0;
}


Measured memory_bytes: 94976
l=[]
m=[]
for i in range(5):
  i = int(input())
  k = 10 - (i%10)
  l.append(i)
  if k != 10:
    m.append(k)
m.sort()
if len(m)==0:
  print(sum(l))
else:
  s = sum(m)-m[-1]
  print(sum(l)+s)

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

using ll = long long;

const int mod = 1000*1000*1000 + 7;

int memo[60][2][2][2];
ll L, R;

void add_self(int& a, int b) { a += b; if(a >= mod) a -= mod; }

int dp(int pos, int flagX, int flagY, int flagZ) {
	if(pos == -1) {
		return 1;
	}
	
	int& ans = memo[pos][flagX][flagY][flagZ];
	if(ans != -1) {
		return ans;
	}
	
	ans = 0;
	
	// x 0, y 0
	if(flagX || (L>>pos & 1) == 0) {
		add_self(ans, dp(pos-1, flagX, (R>>pos & 1) ? 1 : flagY, flagZ));
	}
	
	// x 0, y 1
	if((flagX || (L>>pos & 1) == 0) && (flagY || (R>>pos & 1)) && flagZ) {
		add_self(ans, dp(pos-1, flagX, flagY, flagZ));
	}
	
	// x 1, y 1
	if(flagY || (R>>pos & 1)) {
		add_self(ans, dp(pos-1, (L>>pos & 1) == 0 ? 1 : flagX, flagY, 1));
	}
	
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	memset(memo, -1, sizeof memo);
	cin >> L >> R;
	cout << dp(59, 0, 0, 0) << endl;
}


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

#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
int main(){
  ll n,ans=1;
  cin>>n;
  string s;
  cin>>s;
  rep(i,0,n-1){
    if(s[i]!=s[i+1])ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[][] intervals = new long[n][2];
        int x = 0, l = 0;
        for(int i = 0; i < n; i++) {
        	x = sc.nextInt();
        	l = sc.nextInt();
        	intervals[i][0] = x - l;
        	intervals[i][1] = x + l;
        }
        Arrays.sort(intervals, (itv1, itv2) -> (int)(itv1[1] - itv2[1]));
        int cnt = 1;
        long start = intervals[0][0];
        long end = intervals[0][1];
        for(int i = 1; i < n; i++) {
        	while(i < n && intervals[i][0] < end)
        		i++;
        	if(i < n) {
        		start = intervals[i][0];
        		end  = intervals[i][1];
        		cnt++;
        	}
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 94564
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
#define ll long long
#define tt ll t;cin>>t;while(t--)
#define nl endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define so ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define a_size 100

int main()
{
        so;

        string s,t;
        int mx=-1,i,j,ctr=0;
        cin>>s>>t;
        for(i=0;i+t.size()<=s.size();i++){
          for(j=0;j<t.size();j++){
                    if(s[i+j]==t[j]){
                              ctr++;
                    }
          }
          mx=max(mx,ctr);
          ctr=0;
        }
        cout<<t.size()-mx<<nl;





        return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int X,A,B;
   cin>>X>>A>>B;
   int V;
   V = B-A;
   if(V<=0){
       cout<<"delicious"<<endl;
   }else if(V<=X){
       cout<<"safe"<<endl;
   }else{
       cout<<"dangerous"<<endl;
   }
 
}

Measured memory_bytes: 3536
#include <iostream>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> NODE;
#define pos first
#define distance second

int n;
bool info[100][100];

int bfs(int s,int d){
	queue<NODE> Q;
	bool done[100]={false};
	
	Q.push( make_pair(s,0) );
	while( !Q.empty() ){
		NODE now = Q.front();
		Q.pop();
		done[now.pos] = true;

		if(now.pos == d){
			return now.distance;
		}

		for(int next=0;next<n;next++){
			if(info[now.pos][next] && !done[next]){
				Q.push( make_pair(next,now.distance+1) );
			}
		}
	}
	return INT_MAX;
}

int main(){
	int r,k,t,p,s,d,v;
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> r >> k;
		r--;
		for(int j=0;j<k;j++){
			cin >> t;
			t--;
			info[r][t] = true;
		}
	}	
	
	cin >> p;
	for(int i=0;i<p;i++){
		cin >> s >> d >> v;
		s--;d--;
		if(v > bfs(s,d) )cout << bfs(s,d)+1 << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 1224
#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
    char str1[110], str2[110], str3[210];

    scanf("%s %s", str1, str2);

    strcpy(str3, str1);
    strcat(str3, str1);

    if ( strstr(str3, str2) == NULL ) printf("No\n");
    else printf("Yes\n");

    return 0;
}


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

int main() {
  int x; cin >> x;
  int ans=1;
  for (int i=2; i*i<=x; i++) {
    int p = i*i;
    while (p*i<=x) {
      p*=i;
    }
    ans = max(ans, p);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define NMAX 2005

using namespace std;
vector<int> adiac[NMAX];
bool visited[NMAX];
int nr[NMAX];
void bfs(int node)
{
    queue<pair<int,int>> q;
    q.push({node,0});
    visited[node]=1;
    while(!q.empty()){
        nr[q.front().second]++;
        for(int i=0;i<adiac[q.front().first].size();i++){
            if(visited[adiac[q.front().first][i]]==0){
                q.push({adiac[q.front().first][i],q.front().second+1});
                visited[adiac[q.front().first][i]]=1;
            }
        }
        q.pop();
    }
}
int main()
{
    int n,l,r;
    cin>>n>>l>>r;
    adiac[l].push_back(r);
    adiac[r].push_back(l);
    for(int i=1;i<n;i++){
        adiac[i].push_back(i+1);
        adiac[i+1].push_back(i);
    }
    for(int i=1;i<=n;i++){
        bfs(i);
        memset(visited,0,sizeof(visited));
    }
    for(int i=1;i<n;i++)
        cout<<nr[i]/2<<'\n';
    return 0;
}


Measured memory_bytes: 384
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[]
c=[]
ans=[]
for i in range(h):
    if "#" in a[i]:
        b.append(a[i])
c=list(zip(*b))
for j in range(w):
    if "#" in c[j]:
        ans.append(c[j])
ans=list(zip(*ans))
for k in range(len(ans)):
    print(*ans[k],sep='')

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

int main(){
    long long int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    q *= 8;
    h *= 4;
    s *= 2;
    long long int ans = (n / 2) * min({q, h, s, d});
    if(n % 2 == 1){
        ans += min({q, h, s}) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a;
for(int i=0;i<a;i++){
  cin>>b;
  if(b%2==0){
    if(b%3==0){
      continue;
    }
    else if(b%5==0){
      continue;
    }
    else{
      cout<<"DENIED";
      return 0;
    }
  }
}
  cout<<"APPROVED";
}

Measured memory_bytes: 256
N,K=map(int,input().split())
d=[0 for i in range(K)]
X=[[0 for j in range(N)]for i in range(K)]
for i in range(K):
    d[i]=int(input())
    for j in input().split():
        X[i][int(j)-1]=1
ans=0
for j in range(N):
    flag=1
    for i in range(K):
        if X[i][j]==1:
            flag=0
            break
    if flag:
        ans+=1
print(ans)

Measured memory_bytes: 9300
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
    int n,b;
    scanf("%d%d",&n,&b);
    printf("%d\n",(n+b)%24);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll fact[200000], invFact[200000]; 

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%MOD, c/2)*x)%MOD;
    else return power( (x*x)%MOD, c/2)%MOD;
}

void make_combT(ll n){
    fact[0]=1;
    rep1(i,n) fact[i]= fact[i-1]*i%MOD;
    
    invFact[n] = power(fact[n],MOD-2);
    rrep(i,n-1) invFact[i] = invFact[i+1] * (i+1) %MOD;
}

ll comb(ll n, ll m){
    if(n<m||n<0||m<0) return 0;
    return (fact[n] * invFact[m] %MOD) * invFact[n-m] %MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make_combT(1000);
    int N;
    cin>>N;
    map<int,int> dic;
    
    rep1(i,N){
        int tmp=i;
        for(int d=2;d<=tmp;d++){
            while(tmp%d==0){
                dic[d]++;
                tmp/=d;
            }
        }
    }
    
    int d75=0,d25=0,d15=0,d5=0,d3=0;
    for(auto x:dic){
        int c=x.second;
        if(c+1>=75) d75++;
        if(c+1>=25) d25++;
        if(c+1>=15) d15++;
        if(c+1>=5) d5++;
        if(c+1>=3) d3++;
    }
    ll ans=0;
    ans+=d75;
    ans+=d25*(d3-1);
    ans+=d15*(d5-1);
    ans+=comb(d5,2)*(d3-2);
    cout1(ans);
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F(i, n) for (int i = 0; i < n; i++)
#define Fa(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007
int a[100];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    I(n);
    Fa(n, a);
    sort(a, a+n);
    int r = 0;
    for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++)
            for (int k = j+1; k < n; k++)
                if (a[i] != a[j] && a[j] != a[k] && a[i] + a[j] > a[k])
                    r++;
    cout << r << endl;

    return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N;
  cin >> N;
  cout << N * (1 + N) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};


int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int l,r,d;
	in(l,r,d);
	int ans=0;
	arep(i,l,r+1)if(i%d==0)ans++;
	out(ans);
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>S;
	int same=0,dif=0;
	FOR(i,N-1) {
		if(S[i]==S[i+1]) same++;
		if(S[i]!=S[i+1]) dif++;
	}
	
	cout<<same+min(dif,K*2)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

void dfs(auto& tree,auto& count, auto& ans, int parent, int node,int sum)
{
    sum += count.at(node);
    ans.at(node) = sum;
    for(auto i:tree.at(node))
    {
        if(i == parent) continue;
        dfs(tree, count, ans, node, i, sum);
    }
}

int main(void)
{
    int N,Q;
    cin >> N >> Q;
    vector<int> count(N),ans(N);
    vector<vector<int>> tree(N);
    for(int i = 1; i < N; i++)
    {
        int a,b; 
        cin >> a >> b; --a; --b; 
        tree.at(a).push_back(b);
        tree.at(b).push_back(a);
        
    }

    for(int i = 0; i < N; i++) count[i] = 0; 
    for(int i = 0; i < Q; i++)
    {
        int cnt,x;
        cin >> cnt; --cnt;
        cin >> x;
        count.at(cnt) += x;
    }

    dfs(tree,count,ans,-1,0,0);    

    for(int i = 0; i < N; i++)
    {
        cout << ans.at(i) << " ";
    }
    cout << endl;

}    

Measured memory_bytes: 30464
import java.util.*;
import java.io.*;

public class Main {
    public static int count(boolean[] array){
        int ans = 0;
        for(int i=0;i<array.length;i++)
            if(array[i]) ans++;
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] boll = new int[N];
        boolean[] red = new boolean[N];
        for(int n=0;n<N;n++){
        	boll[n] = 1;
        	red[n]  = (n==0);
        }
        int M = sc.nextInt();
        for(int m=0;m<M;m++){
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            
            if(red[x]) red[y]=true;
            boll[y]++;
            if(boll[x]<=1) red[x]=false;
            boll[x]--;
        }
        System.out.println(count(red));
    }
}

Measured memory_bytes: 66400
main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  print $ solve as

solve :: [Int] -> Int
solve as
  | odd n_nonneg = sum abs_as - 2 * minimum abs_as
  | otherwise    = sum abs_as
  where
    n_nonneg = length $ filter (<= 0) as
    abs_as = abs <$> as

Measured memory_bytes: 39548
import fractions
data=map(int,raw_input().split())
x=map(int,raw_input().split())

x.append(data[1])
x.sort()

#print x
d=[]
for i in range(data[0]):
  d.append(x[i+1]-x[i])
#print d
print reduce(fractions.gcd,d)


Measured memory_bytes: 13600
import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline

def main():
  x, n = map(int, input().split(' '))
  if(n):
    p = list(map(int, input().split(' ')))
  else:
    p = []
    input()
  i = 0
  while(True):
    if not x-i in p:
      ans = x-i
      break
    elif not x+i in p:
      ans = x+i
      break
    else:
      i +=1
  print(ans)
  

if __name__=='__main__':
  main()

Measured memory_bytes: 9068
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll v[1000000];
ll a[1000000];
ll acopy[1000000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	ll T;
	cin>>N>>T;
	ans=INF;
	rep(i,0,N){
		ll c,t;
		cin>>c>>t;
		if(t<=T)ans=min(ans,c);
	}
	if(ans==INF)cout<<"TLE"<<endl;
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
const lines=readlines()
state=0
input()=next(lines,global state+=1)[1]
int(s::String)=parse(Int,s)
intSub(s::SubString{String})=parse(Int,s)
intLine(s::Array{SubString{String},1})=map(intSub,s)
function main()
    const INF=2^60
    a,b,q=input()|>split|>intLine
    s=Array{Int}(a+2)
    s[1],s[a+2]=-INF,INF
    for i in 2:a+1
        s[i]=int(input())
    end
    t=Array{Int}(b+2)
    t[1],t[b+2]=-INF,INF
    for i in 2:b+1
        t[i]=int(input())
    end
    for _ in 1:q
        x=int(input())
        m=INF
        i=searchsortedlast(s,x)
        j=searchsortedlast(t,x)
        for v in view(s,i:i+1)
            for w in view(t,j:j+1)
                m=min(m,abs(x-v)+abs(v-w),abs(x-w)+abs(w-v))
            end
        end
        println(m)
    end
end
main()

Measured memory_bytes: 179588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    
    int len = s.length();
    
    int match_idx = 0;
    while(match_idx < len) {
        int flag = 0;
        for(int i=0; i<len; i++) {
            if(s[(i+match_idx) % len] != t[i]) {
                flag = 1;
                break;
            }
        }
        if(flag) {
            match_idx++;
        } else {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
double t,d;
double t1,t2,d1,d2;

double solve(int a,int b){
    return ( t1*a*d1 + t2*b*d2 ) / ( a*d1+b*d2 );
}

//(tA ?? vA + tB ?? vB) / (vA + vB)

int main(){
    double diff=INF;
    cin>>t>>d;
    cin>>t1>>t2>>d1>>d2;
    for(int i=0;i*d1<=d;i++){
        for(int j=0;j*d2<=d;j++){
            if(i==0&&j==0)continue;
            if(i*d1+j*d2>d)continue;
            double res=solve(i,j);
            if(diff>abs(t-res)){
                diff=abs(t-res);
            }
        }
    }
    printf("%.10lf\n",diff);
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll h, w;
    cin >> h >> w >> n;
    ll x, y;
    cin >> y >> x;
    string s, t;
    cin >> s;
    cin >> t;
    ll xR, xL, yU, yD;
    xR = xL = x;
    yU = yD = y;
    bool flag = false;
    for(i = 0; i < n; i++) {
        if(s[i] == 'U') yU--;
        if(s[i] == 'D') yD++;
        if(s[i] == 'L') xL--;
        if(s[i] == 'R') xR++;
        if(xL < 1) {
            flag = true;
        }
        if(xR > w) {
            flag = true;
        }
        if(yU < 1) {
            flag = true;
        }
        if(yD > h) {
            flag = true;
        }
        if(t[i] == 'U' && yD > 1) yD--;
        if(t[i] == 'D' && yU < h) yU++;
        if(t[i] == 'L' && xR > 1) xR--;
        if(t[i] == 'R' && xL < w) xL++;
        if(flag) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 776
#include <stdio.h>

int max(int a, int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int A, B, C, D;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	printf("%d\n", max(0, min(B, D) - max(A, C)));
	return 0;
}

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

using namespace std;

int main(){
	string a, b, c; cin >> a >> b >> c;
	if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define N_MAX 100000

using namespace std;

int main(){
    int n;
    int odd[N_MAX+1] = {0};
    int even[N_MAX+1] = {0};
    int max_even = 2;
    int max_odd = 1;
    cin >> n;
    for(int i = 0; i < n; i++){
        int v;
        cin >> v;
        if(i%2 == 0)odd[v]++;
        else even[v]++;
    }
    for(int i = 1; i <= N_MAX; i++){
        if(even[i] > even[max_even]) max_even = i;
        if(odd[i] > odd[max_odd]) max_odd = i;
    }
    if(max_even != max_odd){
        cout << n - even[max_even] - odd[max_odd] << endl;
    }else{
        sort(odd, odd+N_MAX+1, greater<int>());
        sort(even, even+N_MAX+1, greater<int>());
        int tmp = max(even[0]+odd[1], even[1]+odd[0]);
        cout << n - tmp << endl;
    }
}


Measured memory_bytes: 1024
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    D, X = li_input()
    A = [int(input()) for _ in range(N)]

    e = 0

    for a in A:
        e += math.ceil(D / a)

    print(e + X)


main()


Measured memory_bytes: 4896
#include<iostream>
using namespace std;
int N;
string S;

int main(){
  cin >> S;
  N = S.size();
  int zero = 0, one = 0;
  
  for(int i = 0; i < N; i++){
    if(S[i] == '0'){
      zero++;
    }else{
      one++;
    }
  }
  
  cout << min(zero,one)*2 << '\n';
}

Measured memory_bytes: 512
k = int(input())

from collections import deque
d = [-1,0,1]

que = deque()
for i in range(1,10):
    que.append(i)
 
cnt = 0
while que:
    p = que.popleft()
    cnt += 1
    if cnt == k:
        print(p)
        break
    for i in d:
        if 0 <= int(str(p)[-1]) + i <= 9:
            que.append(int(str(p) + str(int(str(p)[-1]) + i)))

Measured memory_bytes: 10904
N, K = map(int, input().split())
A = list(map(int, input().split()))

binK = str(bin(K))[2:]
lenbinK = len(binK)

binA = [str(bin(x))[2:] for x in A]
lenbinA = [len(x) for x in binA]

maxlenbinA = max(lenbinA)
maxzentai = max(lenbinK, maxlenbinA)
binA0 = [x.zfill(maxzentai) for x in binA]
binK0 = binK.zfill(maxzentai)


kosu1 = [0 for i in range(maxzentai)]
for i in range(maxzentai):
    for strbinA in binA0:
        if strbinA[i] == '1':
            kosu1[i] += 1

count = 0
flag = False
for i in range(maxzentai):
    if flag:
        count += max(kosu1[i], N - kosu1[i]) * (2 ** (maxzentai - 1 - i))
    else:
        if binK0[i] == '1':
            count += max(kosu1[i], N - kosu1[i]) * (2 ** (maxzentai - 1 - i))
            if kosu1[i] >= N-kosu1[i]:
                flag = True
        elif binK0[i] == '0':
            count += kosu1[i] * (2 ** (maxzentai - 1 - i))
print(count)

Measured memory_bytes: 26748
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,m,a[20][20],pc[20][1000000],dp[20][1000000],rv[1000000];
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    int i,j,k,u,v,w;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;++i){
		scanf("%d%d%d",&u,&v,&w);
		--u;--v;
		a[u][v]=a[v][u]=w;
	}
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
	for(i=0;i<n;++i) rv[1<<i]=i;
    for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			for(k=0;k<(1<<n);++k){
				if(k&(1<<j)) pc[i][k]+=a[i][j];
			}
		}
	}
	for(i=0;i<n;++i) fill(dp[i],dp[i]+(1<<n),iinf);
	dp[0][1]=0;
	for(j=0;j<(1<<n);++j){
		for(i=0;i<n;++i){
			if(!(j&(1<<i)) || dp[i][j]==iinf) continue;
			int v=dp[i][j],msk=(((1<<n)-1)^j),cst=0;
			for(k=0;k<=msk;){
				UMIN(dp[i][j|k],v+cst);
				int cp=msk;
				while(cp && (cp&(-cp))==(k&(-k))){
					int cv=(k&(-k));
					cst-=pc[rv[cv]][j^(1<<i)];
					k^=cv;
					cp^=cv;
				}
				if(!k && !cp) break;
				int cv=cp&(-cp);
				cst+=pc[rv[cv]][j^(1<<i)];
				k|=cv;
			}
			for(k=0;k<n;++k){
				if(a[i][k] && !(j&(1<<k))){
					UMIN(dp[k][j|(1<<k)],v+pc[k][j^(1<<i)]);
				}
			}
		}
	}
	printf("%d\n",dp[n-1][(1<<n)-1]);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,string>> sub(m);
    rep(i,m) cin >> sub[i].first >> sub[i].second;

    int point = 0, pena = 0;
    map<int,int> mp;
    rep(i,m){
        int p = sub[i].first;
        string s = sub[i].second;
        if(s == "WA" && mp[p] != -1){
            mp[p]++;
        }else if(mp[p] != -1){
            point++;
            pena += mp[p];
            mp[p] = -1;
        }
    }
    cout << point << " " << pena << endl;
}

Measured memory_bytes: 11804
#include<bits/stdc++.h>
using namespace std;
#define fep(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, a, b) for (int i = (b)-1; i >= (a); i--)
struct node {
	int t,a,b;
	bool operator<(const node &q)const {
		return t<q.t;
	}
} p[100100];
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	fep(j,0,n) cin>>p[j].t>>p[j].a>>p[j].b;
	sort(p,p+n);
	int posx=0,posy=0,post=0,mark=0;
	fep(j,0,n) {
		int cnt=abs(p[j].a-posx)+abs(p[j].b-posy);
		if (cnt>p[j].t-post) {mark=1; break;}
		else{
			if(cnt<p[j].t){
				if((p[j].t-post-cnt)%2!=0) {mark=1; break;}
			}
		}
	}
	if (mark) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>

using namespace std;

double dp[3005][3005];
double p[3000];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) dp[i][0] = dp[i - 1][0] * p[i];
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= i; ++j) {
            dp[i][j] = dp[i - 1][j] * p[i] + dp[i - 1][j - 1] * (1 - p[i]);
        }
    }
    double res = 0;
    for (int i = n / 2; i >= 0; --i) res += dp[n][i];
    cout << setprecision(15) << res << endl;
}


Measured memory_bytes: 69120
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    final List<Integer> list2 = new ArrayList<>();
    //final List<Long> list3 = new ArrayList<>();

    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    int k = sc.nextInt();

    if(Math.max(Math.max(a,b),c) == a){
        for(int i = 0 ; i < k ; i++){
            a = 2 * a;
        }
        System.out.println(a + b + c);
    }else if(Math.max(Math.max(a,b),c) == b){
        for(int i = 0 ; i < k ; i++){
            b = 2 * b;
        }
        System.out.println(a + b + c);
    }else{
        for(int i = 0 ; i < k ; i++){
            c = 2 * c;
        }
        System.out.println(a + b + c);
    }

    

   

    

    




    







}
}

Measured memory_bytes: 35640
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
    char str[1001];
    
    while(1){
        scanf("%s", str);
        if(str[0]=='0') break;
        int sum = 0;
        for(int i=0; i<strlen(str); i++){
            sum+=(str[i]-'0');
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 3152
#include <cstdio>

int main(){
	char s[1001];int m;
	scanf("%s", s);
	for(m = 0;s[m] != '\0';m++);
	for(int i = 0;i < m;i++){
		if(s[i] < 'D')s[i] = 'Z' - (2 - (s[i] - 'A')), printf("%c", s[i]);
		else printf("%c", s[i] - 3);
	}
	puts("");
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    if (c != a) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
    if (a == c) cout << "Yes" << endl;
    else if (b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0)
    Dim ans=If(a Mod 1000 Mod 111=0 Or a \ 10 Mod 111=0, "Yes", "No")
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 20304