akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> >sf[1234567];
vector<int>cp[1234567];
queue <int> q;
int fa[1234567];
int son[1234567];
int p[1234567];
int f[1234567];
bool vis[1234567];
int n;
int m;
void init(int i)
{
    fa[i]=i;
	son[i]=0;
	p[i]=-1;
	vis[i]=0;
}
int KT(int x)
{
    if(x==fa[x])
    return x;
    else 
    return fa[x]=KT(fa[x]);
}
void PJ(int x,int y)
{
    x=KT(x);
	y=KT(y);
    if(x==y) 
	return;
    if(son[x]<son[y]) 
	fa[x]=y ;
    else 
	{
        fa[y]=x;
        if(son[x]==son[y]) 
		son[x]++;
    }
} 
int main()
{
//	freopen("string.in","r",stdin);
//	freopen("string.out","w",stdout);
    cin>>n>>m;
    for (int i=1;i<=m;i++)
	{
        int a,b,c;
        cin>>a>>b>>c;
        sf[c].push_back(make_pair(a,b));
    }
    int ans=n; 
    for (int i=1;i<=1234567;i++)
	{
        if (sf[i].empty()) 
		continue; 
        for (int j=0;j<sf[i].size();j++)
		{  
            init(sf[i][j].first);
            init(sf[i][j].second);
        }
        for (int j=0;j<sf[i].size();j++) 
		{
			PJ(sf[i][j].first,sf[i][j].second);
		}
        for (int j=0;j<sf[i].size();j++)
		{
            if (!vis[sf[i][j].first])
			{
                vis[sf[i][j].first]=1 ;
                int X=KT(sf[i][j].first) ;
                if(p[X]==-1) 
				p[X]=++ans ;
                cp[sf[i][j].first].push_back(p[X]) ;
                cp[p[X]].push_back(sf[i][j].first) ;
            }
            if (!vis[sf[i][j].second])
			{ 
                vis[sf[i][j].second]=1 ;
                int X=KT(sf[i][j].second) ;
                if(p[X]==-1) 
				p[X]=++ans ;
                cp[sf[i][j].second].push_back(p[X]) ;
                cp[p[X]].push_back(sf[i][j].second) ;
            }
        }
    }
    q.push(1) ;
    memset(f,-1,sizeof(f)) ;
    f[1]=0; 
    while(!q.empty())
	{ 
        int l=q.front();
		q.pop();
        for (int i=0;i<cp[l].size();i++)
		{
            int last=cp[l][i];
            if (f[last]==-1)
			{  
                f[last]=f[l]+1;
                q.push(last);
            }
        }
    }
    if(f[n]==-1) 
	cout<<-1;
    else 
	cout<<f[n]/2 ;
}

Measured memory_bytes: 85376
#include <iostream>
using namespace std;
int main()
{
  string letter;
  cin >> letter;
  int i = 0;
  int flag = 0;
  int existence = 0;
  for(int i = 0; i < letter.length(); i++){
    if(flag == 0 && letter[i] == 'A'){
      flag = 1;
    }
    if(flag == 1 && letter[i] == 'Z'){
      flag = 0;
      existence = 1;
      cout << "AZ";
    }
  }
  if(existence == 0){
    cout << -1 << endl;
  } else {
    cout << "" << endl;
  }
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;

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

  std::cin >> S;

  int n = S.size();

  for(int i=0;i<n;++i){
      std::cout << "x";
  }
  std::cout << std::endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
signed main(){
	int a,b;
	cin>>a;
	f(i,a){
		cin>>b;
		if(b%2){
			puts("first");
			return 0;
		}
	}
	puts("second");
	return 0;
}


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

using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}

int main(){
	ll N; cin>>N;
    vector<ll>A(N+1);
    ll l=1;
    rep(i,N){
        ll x; cin>>x;
        A[x]=l++;
    }
    rep1(i,N) cout<<A[i]<<" ";
}

Measured memory_bytes: 1536
import java.math.BigInteger;
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		String tmp;
		boolean flag;
		
		for(int i=0;i<num;i++){
		flag = false;
			tmp = scan.next();
			if(tmp.length() > 80){
				flag = true;
			}
			BigInteger bix = new BigInteger(tmp);
			tmp = scan.next();
			if(tmp.length() > 80){
				flag = true;
			}
			BigInteger biy = new BigInteger(tmp);
			BigInteger add = bix.add(biy);
			
			if(add.toString().length() > 80 || flag){
				System.out.println("overflow");
			}else{
				System.out.println(add.toString());
			}
		}
	}
}

Measured memory_bytes: 16748
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();

    let ans = if s
        .replace("eraser", "")
        .replace("erase", "")
        .replace("dreamer", "")
        .replace("dream", "")
        == ""
    {
        "YES"
    } else {
        "NO"
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

bool check(int y, int m)
{
  if (y < 0 || y > 99) return false;
  if (m < 1 || m > 12) return false;
  return true;
}

int main() {
  string s;
  while (cin >> s) {
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    bool a1 = check(a, b);
    bool a2 = check(b, a);
    if (a1 && a2) cout << "AMBIGUOUS" << endl;
    else if (a1) cout << "YYMM" << endl;
    else if (a2) cout << "MMYY" << endl;
    else cout << "NA" << endl;
  }
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

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

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <queue>
#include <climits>
using namespace std;


#define MOD 1000000007
using ll = long long;

bool operator<(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	return a.first < b.first;
}
ll X[100010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M; cin >> N >> M;
	vector<pair<int, int>> vp;
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b;
		vp.push_back(make_pair(b, a));
	}
	sort(vp.begin(), vp.end());
	
	int ans = 0;
	int next_v = 0;
	for (int i = 0; i < M; ++i) {
		if (next_v <= vp[i].second) {
			next_v = vp[i].first;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std ;

int main(void){
    string S,res;
    bool flag=true;

    cin >> S;
    
    for(int i=0; i<S.length(); i++){
        if((i+1)%2!=0){
            //奇数
             if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D'){
                flag = false;
                break;
            }
        }else{
            if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D'){
                flag = false;
                break;
            }

        }
    }
    if(flag) res = "Yes";
    else res = "No";

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int INF = 1000000;
int C[101][101], T[101][101];

int main() {
  for (;;) {
    int n, m;
    cin >> n >> m;
    if (!n && !m) return 0;
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++)
        C[i][j] = T[i][j] = INF;
    for (int i = 0; i < n; i++) {
      int a, b, cost, time;
      cin >> a >> b >> cost >> time;
      C[a][b] = C[b][a] = cost;
      T[a][b] = T[b][a] = time;
    }
    for (int k = 1; k <= m; k++)
      for (int i = 1; i <= m; i++)
        for (int j = 1; j <= m; j++) {
          C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
          T[i][j] = min(T[i][j], T[i][k] + T[k][j]);
        }
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int p, q, r;
      cin >> p >> q >> r;
      cout << (!r ? C[p][q] : T[p][q]) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 944
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;
const ll MOD = 1e9+7;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	vector<ll> fact, inv;
	FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = inv[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modinv( fact[i] );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact(1000006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}


int main(){
	//ios_base::sync_with_stdio(0);
	ll N;
	ll x[100005], g[100005]={};

	cin >> N;
	rep(i,N) cin >> x[i];
	ll mx = 0;
	rep(i,N){
		ll m = ( (i-mx)*2+1-x[i] ) / 2;
		//if( i == 1 && x[i] >= 2 ) m = 0;
		chmax<ll>(m, 0);
		//bool f = !chmax( mx, m );
		//g[ max( mx, m ) ]++;
		mx += m;
		g[ mx ]++;
		//cout << i << " " << x[i] << " g[" << max( mx, m ) << "] = " << g[ max( mx, m ) ] << endl;
		if( i>0 && (i-mx)*2 == x[i] ) mx++;
	}

	ll ans = 1;
	rep(i,N){
		//cout << g[i] << endl;
		ans *= g[i];
		ans %= MOD;
		g[i+1] += g[i] - 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 17408
#include <stdio.h>

int main(void){
  int A=0;
  int B=0;
  int value=0;
  int result = 0;

  scanf("%d\n",&A );
  scanf("%d\n",&B );

  if (A > B) {
    value = A-B;
    result = A-value/2;
  }else{
    value = B-A;
    result = B-value/2;
  }

  if (value%2==0) {

    printf("%d\n",result);
  }else{
    printf("IMPOSSIBLE\n");
  }


}


Measured memory_bytes: 128
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M, K = MII()
    A = LII()
    B = LII()

    AA = [0]
    for i in range(N):
        AA.append(AA[i]+A[i])

    BB = [0]
    for i in range(M):
        BB.append(BB[i]+B[i])

    ans = 0
    j = M

    for i in range(N+1):
        if AA[i] > K:
            break
        while BB[j] > K - AA[i]:
            j -= 1
        ans = max(ans, i + j)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47132
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    char x, y;
    cin >> x >> y;

    char ans;
    if(x < y)
        ans = '<';
    else if(x > y)
        ans = '>';
    else
        ans = '=';
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;
import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int k = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        out.println(ok(k, a, b) ? "OK" : "NG");
        }

    private boolean ok(int k, int a, int b) {
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                return true;
            }
        }
        return false;
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

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

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 25580
#include <iostream>

using namespace std;

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

    int i;
    for(i = 1; i <= 100000; ++i)
    {
        if(i * i > N)
            break;
    }
    i--;
    cout << i * i << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    MAX_DIGIT = 45
    dp = [[-1] * 2 for _ in range(MAX_DIGIT+1)]
    dp[45][0] = 0
    for d in range(MAX_DIGIT-1,-1,-1):
        mask = 1 << d
        num = 0
        for i in range(N):
            if A[i] & mask:
                num += 1
        
        zero = mask * num
        one = mask * (N - num)

        if dp[d+1][1] != -1:
            dp[d][1] = max(dp[d][1], dp[d+1][1] + max(one, zero))

        if dp[d+1][0] != -1:
            if K & mask:
                dp[d][1] = max(dp[d][1], dp[d+1][0] + zero)
                dp[d][0] = max(dp[d][0], dp[d+1][0] + one)
            else:
                dp[d][0] = max(dp[d][0], dp[d+1][0] + zero)

    print(max(dp[0][0],dp[0][1]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 68696
#include<bits/stdc++.h>
#define maxn 200050
#define maxm 400050
using namespace std;
typedef long long LL;

int n;
int vs,vt;

vector<int> G[maxn];

int tot;
int cost[maxm<<1];
int head[maxn],edge[maxm<<1],nxt[maxm<<1];

void join(int u,int v)
{
    // cout<<"edge:"<<u<<" "<<v<<endl;
    cost[tot]=1; edge[tot]=v; nxt[tot]=head[u]; head[u]=tot++;
    cost[tot]=0; edge[tot]=u; nxt[tot]=head[v]; head[v]=tot++;
}

void init()
{
    tot=0;
    memset(head,-1,sizeof(head));

    scanf("%d",&n);
    vs=n+n,vt=n+n+1;
    for (int k=1;k<n;++k)
    {
        int x,v;
        scanf("%d",&x);
        while (x--)
        {
            scanf("%d",&v);
            G[v].push_back(k);
            join(v,k+n);
        }
    }
    for (int i=1;i<=n;++i)  join(vs,i);
    for (int i=n+1;i<n+n;++i)   join(i,vt);
}

int d[maxn];
int cur[maxn];

queue<int> q;

bool bfs()
{
    memset(d,0x3f,sizeof(d));
    d[vs]=1;
    q.push(vs);
    while (!q.empty())
    {
        int i=q.front();    q.pop();
        for (int k=head[i];~k;k=nxt[k])
        {
            int j=edge[k];
            if (!cost[k]||d[j]<=d[i]+1)   continue;
            d[j]=d[i]+1;
            q.push(j);
        }
    }
    return d[vt]<=vt;
}

int dfs(int i,int f)
{
    // cout<<"dfs:"<<i<<"("<<d[i]<<")"<<f<<endl;
    if (i==vt)  return f;
    int tf=0;
    for (int &k=cur[i];~k;k=nxt[k])
    {
        int j=edge[k];
        if (!cost[k]||d[j]!=d[i]+1) continue;
        int t=dfs(j,1);
        cost[k]-=t,cost[k^1]+=t;
        f-=t,tf+=t;
        if (!f) break;
    }
    return tf;
}

int isap()
{
    int ans=0;
    while (bfs())
    {
        for (int i=1;i<=vt;++i)
            cur[i]=head[i];
        ans+=dfs(vs,maxn);
    }
    return ans;
}

int mp[maxn];

pair<int,int> ans[maxn];

bool vis[maxn];

void dfs(int i)
{
    vis[i]=1;
    for (auto j:G[i])
    {
        if (vis[mp[j]]) continue;
        ans[j]=make_pair(i,mp[j]);
        dfs(mp[j]);
    }
}

int solve()
{
    if (isap()!=n-1)    return puts("-1");

    LL rt=1LL*n*(n+1)/2;
    for (int k=0;k<tot;k+=2)
    {
        int u=edge[k^1],v=edge[k];
        if (u==vs||v==vt||cost[k])   continue;
        rt-=u;
        mp[v-n]=u;
    }

    // cout<<rt<<endl;
    // for (int i=1;i<n;++i)
    //     cout<<i<<" "<<mp[i]<<endl;

    dfs(rt);
    for (int i=1;i<=n;++i)
        if (!vis[i])
            return puts("-1");
    for (int i=1;i<n;++i)
        printf("%d %d\n",ans[i].first,ans[i].second);
}

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

Measured memory_bytes: 25600
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

cnt = 0

if H >= 2 and W >= 3:
	if s[0][0] == "#" and s[0][1] == "." and s[1][0] == ".":
		cnt += 1

	for w in range(1, W - 1):
		if s[0][w] == "#" and s[0][w - 1] == "." and s[0][w + 1] == "." and s[1][w] == ".":
			cnt += 1

	if s[0][W - 1] == "#" and s[0][W - 2] == "." and s[1][W - 1] == ".":
		cnt += 1 

	if H >= 3:
		for h in range(1, H - 1):
			if s[h][0] == "#" and s[h][1] == "." and s[h + 1][0] == "." and s[h - 1][0] == ".":
				cnt += 1

			for w in range(1, W - 1):
				if s[h][w] == "#" and s[h][w - 1] == "." and s[h][w + 1] == "." and s[h + 1][w] == "." and s[h - 1][w] == ".":
					cnt += 1

			if s[h][W - 1] == "#" and s[h][W - 2] == "." and s[h + 1][W - 1] == "." and s[h - 1][W - 1] == ".":
				cnt += 1 

	if s[H - 1][0] == "#" and s[H - 1][1] == "." and s[H - 2][0] == ".":
		cnt += 1

	for w in range(1, W - 1):
		if s[H - 1][w] == "#" and s[H - 1][w - 1] == "." and s[H - 1][w + 1] == "." and s[H - 2][w] == ".":
			cnt += 1

	if s[H - 1][W - 1] == "#" and s[H - 1][W - 2] == "." and s[H - 2][W - 1] == ".":
		cnt += 1

elif H == 1:
	if s[0][0] == "#" and s[0][1] == ".":
		cnt += 1

	for w in range(1, W - 1):
		if s[0][w] == "#" and s[0][w - 1] == "." and s[0][w + 1] == ".":
			cnt += 1

	if s[0][W - 1] == "#" and s[0][W - 2] == ".":
		cnt += 1

elif W == 1:
	if s[0][0] == "#" and s[1][0] == ".":
		cnt += 1

	for h in range(1, H - 1):
		if s[h][0] == "#" and s[h - 1][0] == "." and s[h - 1][0] == ".":
			cnt += 1

	if s[H - 1][0] == "#" and s[H - 2][0] == ".":
		cnt += 1

else: #W==2
	if s[0][0] == "#" and s[0][1] == "." and s[1][0] == ".":
		cnt += 1

	if s[0][1] == "#" and s[0][0] == "." and s[1][1] == ".":
		cnt += 1

	if H >= 3:
		for h in range(1, H - 1):
			if s[h][0] == "#" and s[h][1] == "." and s[h + 1][0] == "." and s[h - 1][0] == ".":
				cnt += 1

			if s[h][1] == "#" and s[h][0] == "." and s[h + 1][1] == "." and s[h - 1][1] == ".":
				cnt += 1 

	if s[1][0] == "#" and s[1][1] == "." and s[0][0] == ".":
		cnt += 1

	if s[1][1] == "#" and s[1][0] == "." and s[0][1] == ".":
		cnt += 1


if cnt == 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3320
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N) {
  ll result = 0;

  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    result += i;
  }

  cout << result << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3688
h,w=map(int,input().split())
grid=[list(map(int,input().split())) for i in range(h)]

def Largest_Square(grid):
    h=len(grid);w=len(grid[0])
    dp=[[0]*w for i in range(h)]
    maxlenth=0
    for i in range(h):
        for j in range(w):
            dp[i][j]=(grid[i][j]+1)%2
            maxlenth=max(maxlenth,dp[i][j])
    for i in range(1,h):
        for j in range(1,w):
            if grid[i][j]:
                continue
            else:
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-1],dp[i][j-1])+1
                maxlenth=max(maxlenth,dp[i][j])
    return maxlenth**2
print(Largest_Square(grid))





Measured memory_bytes: 55184
# frozen_string_literal: true

N, K = gets.chomp.split(' ').map(&:to_i)
S = gets.chomp

cnt = 0
pre_string = nil
S.each_char do |string|
  cnt += 1 if string == pre_string

  pre_string = string
end

puts [cnt + (K * 2), N - 1].min


Measured memory_bytes: 1916
let pi = atan(1.) *. 4.
let () =
  Scanf.scanf "%f %f %f %f\n" @@ fun a b h m ->
  let d = let d' = abs_float (h *. 30. -. m *. 5.5) in
    if d' <= 180. then d' else 360. -. d' in
  let ans = sqrt (a**2. +. b**2. -. 2.*.a*.b*.cos(d *. pi /. 180.)) in
  Printf.printf "%.10f\n" ans

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

template <typename T>
struct FenwickTree {
	int n; // [1, n]
	vector<T> bit;
	FenwickTree(int n) : n(n), bit(n+1) {}
	T sum(int i) {
		T s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i&-i;
		}
		return s;
	}
	void add(int i, T x) {
		while (i <= n) {
			bit[i] += x;
			i += i&-i;
		}
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<int> C(N);
	for (auto& x : C) cin >> x;
	vector<pair<int,int>> LR;
	map<int,map<int,int>> ans;
	for (int i = 0; i < Q; ++ i) {
		int x, y;
		cin >> x >> y;
		LR.push_back({x,y});
		ans[y][x] = 0;
	}
	vector<int> hoge(N+1, -1);
	FenwickTree<int> bit(N);
	for (int p = 1; p <= N; ++ p) {
		int prev = hoge[C[p-1]];
		if (prev != -1) {
			bit.add(prev, -1);
		}
		hoge[C[p-1]] = p;
		bit.add(p, 1);
		if (ans.count(p)) {
			map<int,int> a;
			for (auto x : ans[p]) {
				int q = x.first;
				a[q] = bit.sum(p) - bit.sum(q-1);
			}
			ans[p] = a;
		}
	}
	for (auto x : LR) {
		cout << ans[x.second][x.first] << endl;
	}
}


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



int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<P> A(n);
    rep(i, n) {
      cin >> a[i];
      A[i].first=a[i];
      A[i].second=i;
    }
    sort(A.begin(),A.end());
    ll cnt=0;
    ll as=A.size();

    vector<P> ans;

    bool plus=false;
    ll a1=A[0].first;ll a2=A[as-1].first;

    if (a1>=0)plus=true;
    else if(a2>0){
      if (abs(a2)>abs(a1)){
        plus=true;
        rep(i,n){
          if (i==A[as-1].second)continue;
          a[i]+=a2;
          ans.push_back(make_pair(A[as-1].second+1,i+1));
        }
        cnt+=n-1;
      }
      else if(abs(a2)<=abs(a1)){
      //  plus=true;
        rep(i,n){
          if (i==A[0].second)continue;
          a[i]+=a1;
          ans.push_back(make_pair(A[0].second+1,i+1));
        }
        cnt+=n-1;
      }
    }
    cnt+=n-1;
    if (plus==true){
      rep(i,n-1){
        ans.push_back(make_pair(i+1,i+2));
      }
    }
    else if (plus==false){
      rep(i,n-1){
        ans.push_back(make_pair(n-i,n-i-1));
      }
    }

cout<<cnt<<endl;
rep(i,ans.size()){
  cout<<ans[i].first<<' '<<ans[i].second<<endl;
}



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

void bfs(const int start, vector<vector<int>>& graph,
         vector<int>& dist) {
    queue<int> q; q.push(start); dist[start] = 0;
    while(not q.empty()) {
        auto p = q.front(); q.pop();

        for (auto elm : graph[p]) {
            if(dist[elm] < 0 or dist[elm] > dist[p] + 1) {
                dist[elm] = dist[p] + 1;
                q.push(elm);
            }
        }
    }
}

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

    vector<vector<int>> g(n, vector<int>(0));
    for (auto i = 0; i < n; i++) {
        int u, k; cin >> u >> k; u--;
        for (auto j = 0; j < k; j++) {
            int v; cin >> v; v--;
            g[u].push_back(v);
        }
    }

    vector<int> dist(n, -1);
    bfs(0, g, dist);

    for (auto i = 0; i < n; i++) cout << i+1 << " " << dist[i] << endl;
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    
    *max_element(p.begin(), p.end()) /= 2;
    
    cout << accumulate(p.begin(), p.end(), 0) << endl;
}

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int dp[55][2555];
int a[55];

int32_t main()
{
    IOS;
    int n,av;
    cin>>n>>av;
    FOR(i,1,n+1) cin>>a[i];
    dp[0][0] = 1;
    FOR(i,1,n+1)
    {
    	for(int j=i-1;j>=0;j--)
        {
            FOR(k,0,2501)
            {
                int cur = k + a[i];
                dp[j+1][cur] += dp[j][k];
            }
        }
    }
    int ans = 0;
    FOR(i,1,n+1) ans += dp[i][av*i];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h> 
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p, l, r;};
Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";
  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";
  cout << "[";
  for (i=0, c=T[u].l; c!= NIL; i++, c=T[c].r) {
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
  int n, v, d, c, l, r; cin >> n;
  for(int i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(int i=0; i<n; i++) {
    cin >> v >> d;
    for (int j=0; j<d; j++) {
      cin >> c;
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for(int i=0; i<n; i++) if(T[i].p == NIL) r = i;
  rec(r, 0);
  for(int i=0; i<n; i++) print(i);
  return 0;
}


Measured memory_bytes: 7784
import math


def main():
    a = list(map(int, input().split()))
    t_hp = a[0]
    t_at = a[1]
    a_hp = a[2]
    a_at = a[3]
    t_win = math.ceil(a_hp / t_at)
    a_win = math.ceil(t_hp / a_at)
    if t_win <= a_win:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  long long x, y;
  x = y = 0;
  scanf("%lld %lld", &x, &y);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    long long ka = max(((x+a-1)/a), ((y+b-1)/b));
    x = a * ka;
    y = b * ka;
  }
  printf("%lld\n", x + y);
  return 0;
}

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

using namespace std;
int main(){
  string s;
  std::cin >> s;
  bool ok=true;
  for (int i = 1; i < 4; i++) {
    if(s[i]==s[i-1])ok=false;
  }
  if(ok)std::cout << "Good" << '\n';
  else std::cout << "Bad" << '\n';




  return 0;
}


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

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    string com;
    //char S[100];
    cin >> com;
    
    for(int i=0; i<com.size(); i++){
    if(com[i] == 'S') {
        int tmp = a;
        a = e;
        e = f;
        f = b;
        b = tmp;
    }
    else if(com[i]=='E'){
        int tmp = a;
        a = d;
        d = f;
        f = c;
        c = tmp;
    }
    else if(com[i]=='N'){
        int tmp = a;
        a = b;
        b = f;
        f = e;
        e = tmp;
    }
    else if(com[i]=='W'){
        int tmp = a;
        a = c;
        c = f;
        f = d;
        d = tmp;
    }
    }
    
    cout << a << endl;
    
    return 0;
}

Measured memory_bytes: 3164
// review
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;

string s;

void solve() {
  ll sum = 0;
  int bitSize = s.size()-1;
  for (int i=0;i<(1 << bitSize);i++) {
    ll tmp = s[0] - '0';
    for (int j=0;j<bitSize;j++) {
      if (i & (1 << j)) {
        sum += tmp;
        tmp = 0;
      }
      tmp = tmp * 10 + s[j+1] - '0';
    }
    sum += tmp;
  }
  cout << sum << endl;
}
int main() {
  cin >> s;
  solve();
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(a_I: int,
          a_O: int,
          a_T: int,
          a_J: int,
          a_L: int,
          a_S: int,
          a_Z: int):

    # O型は独立して考えて良い
    ans = a_O

    # I, J, L型の使い方はふた通り
    A = 2*(a_I//2) + 2*(a_J//2) + 2*(a_L//2)
    if a_I > 0 and a_J > 0 and a_L > 0:
        B = 3+2*((a_I-1)//2) + 2*((a_J-1)//2) + 2*((a_L-1)//2)
    else:
        B = 0
    ans += max(A, B)

    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a_I = int(next(tokens))  # type: int
    a_O = int(next(tokens))  # type: int
    a_T = int(next(tokens))  # type: int
    a_J = int(next(tokens))  # type: int
    a_L = int(next(tokens))  # type: int
    a_S = int(next(tokens))  # type: int
    a_Z = int(next(tokens))  # type: int
    solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n,a,b;
    int sum;
    cin>>n>>a>>b;
    sum=(a+b);
    int p=n/sum;
    int ses=p*a;
    int baki=n-(p*sum);
    baki=min(baki,a);
    ses+=baki;
    cout<<ses<<endl;



















    return 0;

}














Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k;
int a[100000];

signed main() {
	int i, j;
	
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	
	int x = 0;
	for (i = 40; i >= 0; i--) {
		int cnt = 0;
		rep(j, n) {
			if ((a[j] >> i) % 2) cnt++;
		}
		
		if (cnt < n - cnt && x + (1LL << i) <= k) {
			x += (1LL << i);
		}
	}
	
	int ans = 0;
	rep(i, n) {
		ans += x ^ a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a < b)
		{
			if (c < a)
			{
				System.out.printf("%d %d %d\n", c, a, b);
			}
			else
			{
				if (b < c)
				{
					System.out.printf("%d %d %d\n", a, b, c);
				}
				else
				{
					System.out.printf("%d %d %d\n", a, c, b);
				}
			}
		}
		else
		{
			if (c > a)
			{
				System.out.printf("%d %d %d\n", b, a, c);
			}
			else
			{
				if (b < c)
				{
					System.out.printf("%d %d %d\n", b, c, a);
				}
				else
				{
					System.out.printf("%d %d %d\n", c, b, a);
				}
			}
		}
	}
}



Measured memory_bytes: 26308
fun main(args: Array<String>) {
    codefestival2017qualc_b()
}

fun codefestival2017qualc_b() {
    val (k, t) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()

    val max = aList.last()
    val exceptMaxSum = aList.dropLast(1).sum()

    val answer = Math.max(0, max - exceptMaxSum - 1)

    println(answer)
}


Measured memory_bytes: 37896
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	char c;
	cin >> c;

	string vowel = "aeiou";
	bool res = false;
	for (size_t i = 0; i < vowel.size(); i++) {
		if (vowel[i] == c) {
			res = true;
			break;
		}
	}
	cout << (res ? "vowel" : "consonant") << endl;

	return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/agc007/tasks/agc007_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll H,W; cin>>H>>W;
    vector<string> ah(H); //0base
    FOR(i,0,H){
        cin>>ah[i];
    }
    ll cnt=0;
    REP(y,H){
        REP(x,W){
            if(ah[y][x]=='#') ++cnt;
        }
    }
    bool ans=(cnt==H+W-1);
    cout<<(ans?"Possible":"Impossible")<<endl;
    //assert(ans);
    return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	public final static int maxn = 55;
	char[][] sa = new char[maxn][maxn];
	char[][] sb = new char[maxn][maxn];

	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt(), m = in.nextInt();
		boolean flag = false;

		for (int i=0; i<n; ++i) {
			String s = in.next();
			sa[i] = s.toCharArray();
		}

		for (int i=0; i<m; ++i) {
			String s = in.next();
			sb[i] = s.toCharArray();
		}

		for (int i=0; !flag&&i+m<=n; ++i) {
			for (int j=0; !flag&&j+m<=n; ++j) {
				boolean f = true;
				for (int ii=0; f&&ii<m; ++ii) {
					for (int jj=0; f&&jj<m; ++jj) {
						if (sa[i+ii][j+jj] != sb[ii][jj])
							f = false;
					}
				}
				flag |= f;
			}
		}

		out.println(flag ? "Yes":"No");
	}
}

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();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  int d, x;
  cin >> n;
  cin >> d >> x;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> m;
    if (m > d) {
      ++ans;
      continue;
    }
    int c = 1;
    while ((c * m) + 1 <= d) {
      ++c, ++ans;
    }
    ++ans;
  }
  cout << x + ans;
  return 0;
}



Measured memory_bytes: 3616
import sys
from collections import Counter
md = 10**9+7
N, M = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
sa = set(A)
sb = set(B)
if len(sa)<len(A) or len(sb)<len(B):
  print 0
  sys.exit(0)
r = 1
ca = 0
cb = 0
for i in xrange(N*M, 0, -1):
  ia = i in sa
  ib = i in sb
  if ia and ib:
    ca += 1
    cb += 1
  elif ia:
    ca += 1
    r = (r*cb) % md
  elif ib:
    cb += 1
    r = (r*ca) % md
  else:
    r = (r*(ca*cb-(N*M-i))) % md
print r%md

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
int sum =0;
  string S;
  cin >> S;

  if ( S.at(0) == '1') {
    sum ++;
  }
  if ( S.at(1) =='1') {
    sum ++;
  }
  if ( S.at(2) =='1') {
    sum ++;
  }
 cout << sum << endl; 
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApp_CS
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = CIn.ReadInt();
            var x = new long[n];
            var y = new long[n];
            for (var i=0;i < n; i++)
            {
                x[i] = CIn.ReadInt();
                y[i] = x[i];
            }

            Array.Sort(y);


            foreach(var item in x)
            {
                if (item < y[n / 2])
                {
                    Console.WriteLine(y[n / 2]);
                }
                else
                {
                    Console.WriteLine(y[n / 2 - 1]);
                }
            }

            
            
        }
    }

    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }
            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];
            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }
            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];
            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }
            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];
            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }
            return array;
        }

        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];
            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }
            return array;
        }
    }
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

bool dp[2][1 << 16];
vector<int> nxt[1 << 16];

int main(){
    cin.sync_with_stdio(false);
    int n, m, k, tmp;
    cin >> n >> m >> k;

    int bright[n] = {};
    int dark[m];
    rep(i, n) bright[i] = -1;
    rep(i, m) {
        cin >> dark[i];
        bright[--dark[i]] = i;
    }

    int to[n][k];
    rep(i, n) {
        rep(j, k) {
            cin >> to[i][j];
            to[i][j]--;
        }
    }

    rep(i, 1 << m) {
        int a[k] = {};
        rep(j, m) {
            if (i & (1 << j)) {
                rep(l, k) {
                    if (bright[to[dark[j]][l]] >= 0) {
                        a[l] |= (1 << bright[to[dark[j]][l]]);
                    }
                }
            }
        }
        rep(j, k) nxt[i].pb(a[j]);
    }

    memset(dp, 0, sizeof(dp));
    tmp = 0;
    dp[tmp % 2][(1 << m) - 1] = true;
    while(!dp[tmp % 2][0]) {
        rep(i, 1 << m) {
            if (dp[tmp % 2][i]) {
                rep(j, nxt[i].size()) dp[(tmp + 1) % 2][nxt[i][j]] = true;
            }
            dp[tmp % 2][i] = false;
        }
        tmp++;
    }
    cout << tmp << endl;

    return 0;
}

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

int64_t f(int64_t n,int64_t x){
    if(n<0){
        return 0;
    }else{
        return n/x + 1;
    }
}
int main(){
    int64_t a,b,x;
    cin >> a >> b >> x;
    cout << f(b,x)-f(a-1,x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  int n,i; cin >> n >> i;
  // for (int i=1; i <=n; i++) {

  // }

  cout << n-i+1<< endl;

}

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


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int X, Y, Z;
	cin >>X >>Y >>Z;
	cout <<(X-Z)/(Y+Z) <<endl;
	return 0;
}



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

int n;
long long k=1000,num;
int a[85];
int main()
{
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
	{
		k+=num*a[i];
		num=0;
		if(a[i]<a[i+1])
		{
			num=k/a[i];
			k-=num*a[i];
		}
	}
	cout<<k;
	return 0;
}


Measured memory_bytes: 3648