akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std;    
 int main()
{
   // #define long long int long long long long int
    int n,m,i,j,c,d,a,b,max1;
    cin >> n >> m;
    int inc[n],dp[n];
    for(i=0;i<n;i++)
    {
        inc[i]=0;
        dp[i]=0;
    }
    vector<vector<int>> g;
    g.resize(n);
    for(i=0;i<m;i++)
    {
        cin >> a >> b;
        a--;b--;
        inc[b]++;
        g[a].push_back(b);
    }
    queue<int> q;
    for(i=0;i<n;i++)
    {
        if(inc[i]==0)
            q.push(i);
    }
    while(!q.empty())
    {
        c=q.front();
        q.pop();
        for(j=0;j<g[c].size();j++)
        {
            d=g[c][j];
            dp[d]=max(dp[d],1+dp[c]);
            inc[d]--;
            if(inc[d]==0)
                q.push(d);
        }

    }
    max1=0;
    for(i=0;i<n;i++)
        max1=max(max1,dp[i]);
    cout << max1;
    

    
}

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

#define ll long long
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1000000007;

using namespace std;

int n,d[100100];
int w,wgh[110],val[110];

int main(){
    for (int i=0;i<100100;i++)d[i]=2e9;
    cin>>n>>w;
    for (int i=1;i<=n;i++){
        cin>>wgh[i]>>val[i];
    }
    for (int i=1;i<=n;i++){
        vector<pair<int,int>>v;
        for (int j=1;j<=1e5;j++){
            if (val[i]==j){
                if (wgh[i]>w)continue;

                v.push_back({j,wgh[i]});
            }
            if (val[i]>=j)continue;
            if (d[j-val[i]]==2e9)continue;
            if (d[j-val[i]]+wgh[i]>w)continue;

            v.push_back({j,d[j-val[i]]+wgh[i]});
        }
        for (auto j:v){
            d[j.first]=min(d[j.first],j.second);
        }
    }
    for (int i=1e5;i>=1;i--){
        if (d[i]<=w){
            return cout<<i,0;
        }
    }
    cout<<0;
	return 0;
}


Measured memory_bytes: 1596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int N_max = 22;
const int n_MAX =    1024 * 1024 * 2 + 5;

signed main(){
    int N;
    cin >> N;
    int A[N_max][N_max];
    REP(i,N) REP(j,N) cin >> A[i][j];

    int n = 1;
    int joutai[25];
    REP(i,N){
        joutai[i] = n;
        n*= 2;
    }

    int dp[2][n_MAX];
    REP(j,2) REP(i,n_MAX) dp[j][i] = 0;
    int woman_id = 0;
    while(1){
        if(A[0][woman_id]) dp[1][joutai[woman_id]] = 1;
        woman_id ++;
        if(woman_id == N) break;
    }

    FOR(man,1,N){
        FOR(j,1,n){
            if(dp[man%2][j] == 0) continue;
            REP(woman,N){
                if(joutai[woman] & j) continue;
                if(A[man][woman] == 0) continue;
                dp[(man + 1) %2][j + joutai[woman]] += dp[man%2][j];
                dp[(man + 1) %2][j + joutai[woman]] %= MOD;
            }
        }
    }
    cout << dp[N%2][n - 1] << endl;




}

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;

using namespace std;

void print(int a[],int s,int e){for(int i=s;i<=e;i++)cout<<a[i]<<" ";cout<<"\n";}
void print(vector<int> &v,int s,int e){for(int i=s;i<=e;i++)cout<<v[i]<<" ";cout<<"\n";}
void print(vector<int> &v){for(int x:v)cout<<x<<" ";cout<<"\n";}

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*b;x%=m;return x;}

string s[5];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    cin>>s[0]>>s[1]>>s[2];
    int t = 0;
    while(true){
        if(s[t].size() == 0){
            cout<<(char)(t+'A');
            return 0;
        }
        char c = s[t][0];
        s[t].erase(s[t].begin());
        t = c-'a';
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
string A[4] = {"AC", "WA", "TLE", "RE"};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<string, int> mp;
    while(N--) {
        string S;
        cin >> S;
        mp[S]++;
    }
    for(int i = 0; i < 4; i++) {
        cout << A[i] << " x " << mp[A[i]] << endl;
    }
    return 0;
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)

#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<"="<<x<<endl
#define uni(x) x.erase(unique(all(x)),x.end())

typedef long long ll;
typedef pair<int,int> P;

struct UnionFind{
  map<int,int> v;
  map<int,bool> isnamori;
  map<int,int> sz;
  vector<P> qs;
  int tot;
  int ans;
  void init(){
    v.clear(); isnamori.clear();
    sz.clear();
    qs.clear();
    tot=0; ans=0;
  }
  void add(int x){
    if(v.find(x)!=v.end())return ;
    v[x]=x;
    sz[x]=1;
    isnamori[x]=false;
    tot++;
  }
  int find(int x) {
    assert(v.find(x)!=v.end());
    return v[x]==x ? x : find(v[x]);
  }
  bool unite(int x,int y){
    qs.push_back(P(x,y));
    add(x);
    add(y);
    x=find(x); y=find(y);
    assert(v.find(x)!=v.end());
    assert(v.find(y)!=v.end());    

    if(x==y){
      if(!isnamori[x])ans++;
      isnamori[x]=true;
      return false;
    }
    if(sz[x]<sz[y])swap(x,y);

    if(isnamori[x]){
      ans-=sz[x];
    }else{
      ans-=sz[x]-1;
    }
    if(isnamori[y]){
      ans-=sz[y];
    }else{
      ans-=sz[y]-1;
    }

    isnamori[x]=(isnamori[x]|isnamori[y]);
    sz[x]+=sz[y];
    v[y]=x;

    if(isnamori[x]){
      ans+=sz[x];
    }else{
      ans+=sz[x]-1;
    }
    return true;
  }
};

int N,K;
vector<int> g[200010];
int C[200010],D[200010];
int res[200010];
UnionFind uf[200010];

int dfs(int v,int pre){
  int mxid=-1;
  vector<int> ids;
  assert(v<2e5);
  for(int nv : g[v]){
    if(nv==pre)continue;
    int id=dfs(nv,v);
    ids.push_back(id);
    assert(mxid<2e5);
    if(mxid==-1)mxid=id;
    else if(uf[mxid].tot<uf[id].tot){
      mxid=id;
    }
  }
  assert(v<2e5);
  if(mxid==-1){
    uf[v].init();
    mxid=v;
  }
  assert(mxid<2e5);
  for(int id : ids){
    if(id==mxid)continue;
    assert(id<2e5);
    for(P p : uf[id].qs){
      uf[mxid].unite(p.first,p.second);
    }
    uf[id].init();
  }
  assert(v<2e5);
  assert(mxid<2e5);
  uf[mxid].unite(C[v],D[v]);
  res[v]=uf[mxid].ans;
  return mxid;
}

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

  rep(i,N-1){
    int u,v;
    cin>>u>>v;
    u--;v--;
    assert(u<2e5);
    assert(v<2e5);
    g[u].push_back(v);
    g[v].push_back(u);
  }

  rep(i,N){
    cin>>C[i]>>D[i];
  }

  dfs(0,-1);
  assert(N<2e5);
  rep(i,N)cout<<res[i]<<endl;

  return 0;
}



Measured memory_bytes: 80188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    char x, y;
    cin >> x >> y;
    if ( x > y ) cout << '>' << endl;
    else if ( x < y ) cout << '<' << endl;
    else              cout << '=' << endl;
    return 0;
}


Measured memory_bytes: 256
# Reconstruction of the Tree

# Tree walk

import sys
sys.setrecursionlimit(10**9)  # 再帰回数上限の向上 かなり多くしないとREになる


def rec(l, r, post_ls):
    if (l >= r):
        return
    global pos
    root = pre_ls[pos]
    pos +=1
    m = in_ls.index(root)
    rec(l, m, post_ls)
    rec(m + 1, r, post_ls)
    post_ls.append(root)

# データの読み込み
n = int(input())
pre_ls = list(map(int, input().split()))
in_ls = list(map(int, input().split()))
post_ls = []

pos = 0
rec(0, len(pre_ls), post_ls)

print(*post_ls)


Measured memory_bytes: 5604
#include<stdio.h>

int main(void){

    int i=0,n[1000],x[1000],j=0;
    while(1){
        scanf("%d %d", &n[i], &x[i]);
    if(n[i]==0&&n[i]==0) break;
    i++;
    }
    int A=0,k,l;
    while(1){
        if(j==i) break;
        for(k=1;k<=n[j];k++){
            for(l=k+1;l<=n[j];l++){
            if(x[j]-k-l>l&&x[j]-k-l<=n[j]) A++;
            }
        }
        printf("%d\n",A);
        A=0;
        j++;
    }

    return 0;
}


Measured memory_bytes: 2056
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		PriorityQueue<Integer> queue = new PriorityQueue<>(N, Collections.reverseOrder());
		for(int i=0; i<N; i++){
		    int num = sc.nextInt();
		    queue.add(num);
		}
		
		for(int i=0; i<M; i++){
		    int t = queue.peek(); 
		    queue.remove();
            queue.add(t/2);
		}
		long ans=0;
		while(!queue.isEmpty()==true){
		    ans+=queue.peek();
		    queue.remove();
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 62600
#include <iostream>
using namespace std;
int main(){
    int d;
    cin >> d;
    string s = "Christmas";
    for (int i = 25; i >= 22; i--){
        if(d == i){
            cout << s << endl;
            break;
        }
        s += " Eve";
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A := make([][]int, 3)
	for i := 0; i < 3; i++ {
		A[i] = ReadInts(3)
	}
	N := ReadInt()
	b := ReadInts(N)
	x := make([][]bool, 3)
	for i := 0; i < 3; i++ {
		x[i] = make([]bool, 3)
	}
	for _, bi := range b {
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if A[i][j] == bi {
					x[i][j] = true
				}
			}
		}
	}

	for i := 0; i < 3; i++ {
		if x[i][0] && x[i][1] && x[i][2] {
			fmt.Println("Yes")
			return
		}
	}
	for i := 0; i < 3; i++ {
		if x[0][i] && x[1][i] && x[2][i] {
			fmt.Println("Yes")
			return
		}
	}
	if x[0][0] && x[1][1] && x[2][2] {
		fmt.Println("Yes")
		return
	}
	if x[0][2] && x[1][1] && x[2][0] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1848
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N, K; cin >> N >> K;
  if (K <= (N + 1)/2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define    x            real()
#define    y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     point        complex<double>
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
ll arr[100009];
int main(){
    GO();
    int n,k,q;
    cin>>n>>k>>q;
    arr[1]+=k;
    arr[n+1]-=k;
    for(int i=0;i<q;i++){
        int no;
        cin>>no;
        arr[1]+=-1;
        arr[n+1]-=-1;
        arr[no]+=1;
        arr[no+1]-=1;
    }

    for(int i=1;i<=n;i++){
        arr[i]+=arr[i-1];
    }
    for(int i=1;i<=n;i++){
        if(arr[i]<=0){
            cout<<"No\n";
        }
        else{
            cout<<"Yes\n";
        }
    }
}


Measured memory_bytes: 1408
# ABC086 C - Traveling
import numpy as np
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]

if n == 1:
    if l[0][0] >= l[0][1]+l[0][2]:
        if l[0][0]%2 == (l[0][1]+l[0][2])%2:
            pass
        else:
            print('No')
            exit()    
    else:
        print('No')
        exit()
for i in range(n-1):
    t = l[i+1][0]-l[i][0]
    x = abs(l[i+1][1]-l[i][1])
    y = abs(l[i+1][2]-l[i][2])
    if t >= x+y:
        if t%2 == (x+y)%2:
            pass
        else:
            print('No')    
            exit()
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 38344
n = int(input())
xl = []
for i in range(n):
    l, r = map(int, input().split())
    xl.append([l-r, l+r])
xl.sort(key=lambda x: x[1])
ans = 0
inf = 10 ** 10
prev_r = - inf
for l, r in xl:
    if prev_r > l:
        continue
    ans += 1
    prev_r = r
print(ans)


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

#define ll long long
#define ar array

int h, n, a[1000], b[1000];
int dp[10001];

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

	cin >> h >> n;
	memset(dp, 0x3f, sizeof(dp));
	dp[0]=0;
	for(int i=0; i<n; ++i) {
		cin >> a[i] >> b[i];
		for(int j=0; j<h; ++j)
			dp[min(j+a[i], h)]=min(dp[min(j+a[i], h)], dp[j]+b[i]);
	}
	cout << dp[h];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    int ans=0;
    for(int a=1;a<=n;a++){
        for(int b=1;b<=n;b++){
            if(a*b>=n)break;
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    if(b==c){
      cout << 1 << endl;
    }
    else{
      cout << 2 << endl;
    }
  }
  else{
    if(b==c){
      cout << 2 << endl;
    }
    else if (a==c){
      cout << 2 << endl;
    }
    else{
      cout <<3 << endl;
    }
  }
}

Measured memory_bytes: 256
class PriorityQueue
  def initialize(&block)
    @elements = []
  end
  
  def push(n)
    i = @elements.size
    while i > 0
      p = (i-1) / 2
      break if @elements[p] <= n
      @elements[i] = @elements[p]
      i = p
    end
    @elements[i] = n
  end
  alias :<< :push
  
  def pop
    min = @elements[0]
    n   = @elements.pop
    unless @elements.empty?
      i = 0
      while i * 2 + 1 < @elements.size
        if @elements[i * 2 + 2].nil? or @elements[i * 2 + 1] < @elements[i * 2 + 2]
          buf = i * 2 + 1
        else
          buf = i * 2 + 2
        end
        break if @elements[buf] > n
        @elements[i] = @elements[buf]
        i = buf
      end
      @elements[i] = n
    end
    min
  end
end

N = gets.to_i
a = gets.split.map(&:to_i)

ls = Array.new(N+1, 0)
lq = PriorityQueue.new
(0..N-1).each { |i| lq << a[i]; ls[0] += a[i] }

rs = Array.new(N+1, 0)
rq = PriorityQueue.new { |a, b| b <=> a }
(2*N..3*N-1).each { |i| rq << -a[i]; rs[0] += -a[i] }

N.times do |i|
  lq << a[N+i]
  ls[i+1] = ls[i] + a[N+i] - lq.pop
  
  rq << -a[2*N-i-1]
  rs[i+1] = rs[i] - a[2*N-i-1] - rq.pop
end

max = -Float::INFINITY
(N+1).times do |i|
  dif = ls[i] + rs[N-i]
  max = dif if max < dif
end
puts max


Measured memory_bytes: 27744
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int dfs(string s){
	//cout<<s<<endl;
	if(s.size()==1) return stoll(s);
	
	int ret=stoll(s);
	//cout<<"test";
	rep(j,1,s.size()){
		ret+=dfs(s.substr(j))+mpow(2,s.size()-j-1)*stoll(s.substr(0,j));
	}
	return ret;
}
signed main(){
    string S;
    cin>>S;
    cout<<dfs(S)<<endl;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int wa(int n){
  int res=0;
  while(n!=0){
    res+=n%10;
    n/=10;
  }
  return res;
}

int main(){
  int n;
  int ans=1e+9;
  cin>>n;
  for(int i=1;i<n;i++){
    int j=n-i;
    ans=min(ans,wa(i)+wa(j));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp				make_pair
#define rep(i,n)		for(int i = 0; i < n; i++)
#define foreach(i,c)	for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF			0x7fffffff
#define INF				0x3f3f3f3f
#define LINF			3223372036854775807
#define END(s)			{cout<<s; return 0;}
#define CON(s)			{cout<<s; continue;}
#define BRE(s)			{cout<<s; break;}
#define pb				push_back
//#define int				long long
#define All(a)			a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)			(int)a.size()
#define F				first
#define S				second
//#define usingFiles
using namespace std;

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int N, T, A;
	cin >> N >> T >> A;
	double mn = INF;
	int mnnum;
	rep(i, N){
		int h;
		cin >> h;
		double temp = T - (double)(h * 0.006);
		double dist = abs(A - temp);
		if(dist < mn){
			mnnum = i+1;
			mn = dist;
		}
	}
	cout << mnnum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

class Point2D {
	double m_x, m_y;
public:
	Point2D(double x, double y) :
		m_x(x), m_y(y)
	{}
	Point2D(const Point2D &p) :
		m_x(p.x()), m_y(p.y())
	{}
	double x() const { return m_x; }
	double y() const { return m_y; }
};

Point2D operator-(const Point2D &a, const Point2D &b) {
	return Point2D(a.x() - b.x(), a.y() - b.y());
}

double cross(const Point2D &a, const Point2D &b) {
	return a.x() * b.y() - a.y() * b.x();
}

bool isIntersected(const Point2D &p1, const Point2D &p2, const Point2D &q1, const Point2D &q2) {
	const Point2D p = p2 - p1, q = q2 - q1;
	return cross(p, q1 - p1) * cross(p, q2 - p1) <= 0 && cross(q, p1 - q1) * cross(q, p2 - q1) <= 0;
}

std::vector<std::string> split(std::string &str, char delim) {
	std::vector<std::string> result;
	std::istringstream is(str);
	std::string buf;
	while (getline(is, buf, delim)) {
		result.push_back(buf);
	}
	return result;
}

bool inputDataSet(std::vector<Point2D> *p) {
	std::string line;
	if (!getline(std::cin, line)) { return false; }
	const std::vector<std::string> tokens(split(line, ','));
	if (tokens.size() != 8) { return false; }
	std::vector<double> ds;
	for (std::vector<std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it) {
		std::istringstream is(*it); double x;
		is >> x;
		ds.push_back(x);
	}
	p->clear();
	for (int i = 0; i < 8; i += 2) {
		p->push_back(Point2D(ds[i], ds[i + 1]));
	}
	return true;
}

int main() {
	std::vector<Point2D> p;
	while (inputDataSet(&p)) {
		if (p.size() < 4) { continue; }
		std::cout << (isIntersected(p[0], p[2], p[1], p[3]) ? "YES" : "NO") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vl>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  string S;
  cin >> S;
  Graph ABC(S.size()+1, vl(3,0));  // 1-indexed
  ll count = 1;
  rep(i,S.size()) {
    ABC[i+1] = ABC[i];
    if (S[i] == 'A') (ABC[i+1][0] += count) %= MOD;
    else if (S[i] == 'B') (ABC[i+1][1] += ABC[i][0]) %= MOD;
    else if (S[i] == 'C') (ABC[i+1][2] += ABC[i][1]) %= MOD;
    else {
      ((ABC[i+1][0] *= 3) += count) %= MOD;
      ((ABC[i+1][1] *= 3) += ABC[i][0]) %= MOD;
      ((ABC[i+1][2] *= 3) += ABC[i][1]) %= MOD;
      (count *= 3) %= MOD;
    }
  }
  cout << ABC[S.size()][2] << endl;
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    int h,w;
    cin >>h >>w;
    vector<string> s(h);
    rep(i,h) cin >>s[i];

    vector<string> a(h+2,string(w+2,'#'));
    rep(i,h)rep(j,w) a[i+1][j+1] = s[i][j];

    rep(i,h+2) cout << a[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

ll n;
ll h;
VE a;
VE b;

int main(){
  cin>>n>>h;
  int aa,bb;
  REP(i,n){
    cin>>aa>>bb;
    a.push_back(aa);
    b.push_back(bb);
  }
  ll ma=0;
  ll cnt=0;
  REP(i,n){
    if(ma<a[i])ma=a[i];
  }
  sort(b.begin(), b.end(), std::greater<int>() );
  //printall(n,b);///
  REP(i,n){
    if(ma<b[i]){
      h-=b[i];
      cnt++;
      if(h<=0){
        print(cnt);
        return 0;
      }
    }
  }
  cnt+=h/ma;
  if(h%ma){cnt++;}
  print(cnt);
}

Measured memory_bytes: 1276
from collections import deque

h,w=map(int,input().split())
a = [input() for _ in range(h)]
move=((1,0),(0,1),(-1,0),(0,-1))

que=deque([])
visited=[[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            que.append((i,j,0))
            visited[i][j]=1


while len(que)>0:       
    ci,cj,d=que.popleft()
    for mi,mj in move:
        ni,nj=mi+ci,mj+cj
        if 0<=ni<h and 0<=nj<w and visited[ni][nj]==0:
            if a[ni][nj]==".":
                visited[ni][nj]=1
                que.append((ni,nj,d+1))

print(d)

Measured memory_bytes: 135644
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  string S;
  cin >> S;
  int ans = 700;
  for(int i = 0;i<3;i++){
    if(S.at(i) == 'o'){
      ans = ans + 100;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var A,B int

	fmt.Scan(&A,&B)

	result :=0

	for i:=1;i<=B;i++{

		if (A*i)%B==0{

			result = A*i
			break
		} 
	}

	fmt.Println(result)

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        ll n;
        cin >> n;
        ll t = n / 100;
        ll q = n % 100;
        if(q - 5 * t <= 0){
                cout << 1 << endl;
        }else{
                cout << 0 << endl;
        }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
	int i,j;
	i=0;
	char str[1000];
	gets(str);
	for(j=strlen(str);j>0;j--)
	    printf("%c",str[j-1]);
        printf("\n");
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    
    int ts = t.size();
    
    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    for(int i = 0; i <= s.size() - ts; i++){
        bool include = true;
        for(int j = 0; j < ts; j++){
            if(s.at(i + j) != t.at(j))include = false;
        }
        
        if(include){
            for(int i = 0; i < s.size(); i++){
                if(s.at(i) == '?')s.at(i) = 'a';
            }
            cout << s << endl;
            return 0;
        }
    }
    
    for(int i = s.size() - ts; i >= 0; i--){
        bool include = true;
        for(int j = 0; j < ts; j++){
            if(s.at(i + j) != t.at(j) && s.at(i + j) != '?')include = false;
        }
        
        if(include){
            for(int j = 0; j < ts; j++){
                s.at(i + j) = t.at(j);
            }
            for(int j = 0; j <s.size(); j++){
                if(s.at(j) == '?')s.at(j) = 'a';
            }
            
            cout << s << endl;
            return 0;
        }
    }
    
    cout << "UNRESTORABLE" << endl;
    
}

Measured memory_bytes: 256
def resolve():
    S = input()
    odd_flag = True

    for s in S:
        if odd_flag:
            if not (s == 'R' or s == 'U' or s == 'D'):
                print('No')
                return
        else:
            if not (s == 'L' or s == 'U' or s == 'D'):
                print('No')
                return
        odd_flag = not(odd_flag)

    print('Yes')

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include <iostream>

int main()
{
	int H, W;

	while (std::cin >> H >> W)
	{	
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; ++i)
		{
			for (int j = 0; j < W; ++j) 
			{
				if (i % 2 == 0)
				{
					if (j % 2 == 0) std::cout << "#";
					else std::cout << ".";
				}

				else
				{
					if (j % 2 == 0) std::cout << ".";
					else std::cout << "#";
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
 	}

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
lint N;
vector<vector<lint> > G, memo;
const lint MOD = 1e9+7;

lint dfs(lint start, lint ago, lint color){
	if(memo[start][color] != -1) return memo[start][color];
	lint ans = 1;
	for(lint i = 0; i < G[start].size(); i++){
		lint next = G[start][i];
		if(next == ago) continue;
		if(color == 0){
			ans *= (dfs(next, start, 1) + dfs(next, start, 0));
			ans %= MOD;
		}
		if(color == 1){
			ans *= dfs(next, start, 0);
			ans %= MOD;
		}
	}
	return memo[start][color] = ans;
}

signed main(){
	cin >> N;
	G.resize(N); memo.resize(N, vector<lint> (2, -1));
	for(lint i = 1; i < N; i++){
		lint a, b; cin >> a >> b; --a; --b;
		G[a].push_back(b); G[b].push_back(a);
	}
	cout << (dfs(0, -1, 0) + dfs(0, -1, 1)) % MOD << endl;
}

Measured memory_bytes: 19584
# frozen_string_literal: true

n = gets.to_i
s = gets.chomp

i = 0
count = 0
loop do
  break if i > n - 2

  if s[i..(i+2)] == 'ABC'
    count += 1
    i += 3
  else
    i += 1
  end
end

puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
	all(a);
  cout<<a[n-1]-a[0]<<endl;
}


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

#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

#define ll long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vvi vector<vi > 
#define vii vector<pii >

pii operator+(pii a, pii b)
{
    return {a.fi+b.fi,a.se+b.se};
}
pll operator+(pll a, pll b)
{
    return {a.fi+b.fi,a.se+b.se};
}
std::ostream& operator<<(std::ostream& out,pii a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::ostream& operator<<(std::ostream& out,pll a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::istream& operator>>(std::istream& in,pii &a)
{
    in>>a.fi>>a.se;
    return in;
}
std::istream& operator>>(std::istream& in,pll &a)
{
    in>>a.fi>>a.se;
    return in;
}

using namespace std;

int main()
{
    FAST;
    int n;
    cin>>n;
    int h[n];
    inputarr(h,n);
    ll dp[n];
    dp[0]=0;
    dp[1]=dp[0]+abs(h[1]-h[0]);
    for (int i = 2; i < n; ++i)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[n-1];


}

Measured memory_bytes: 1408
/********
*	??????????????£
*	???????????¢??°??§??????????????????2?¬??????????????????????????´????????????¨??????????????£??????????????????????????????????????????????????????????????????????????????????????¢?????????????????¢?????°????????????????????????
*	????´????????????????????????????????????????????????¨??????????¢??????????????????????????????´??????????????°???Yes????????????????????§????????´????????°NO??§????????????
*	
********/

#include <iostream>
using namespace std;

class Cube{		//??????????????????
public:
	int f[6];
	Cube(){}	//?????????????????????
	void roll_z(){	roll(1,2,4,3);	}	//
	void roll_y(){	roll(0,2,5,3);	}	//toW(?\?)
	void roll_x(){	roll(0,1,5,4);	}	//toN(???)
	void roll(int i, int j, int k, int l){
		int t= f[i];
		f[i] = f[j];
		f[j] = f[k];
		f[k] = f[l];
		f[l] = t;
	}
};

bool eq(Cube c1, Cube c2 ){
	for(int i= 0; i<6; i++){
		if(c1.f[i] != c2.f[i] ){
			return false;
		}
	}
	return true;
}

bool equal( Cube c1, Cube c2 ){
	for(int i= 0; i < 6; i++){
		for(int j = 0; j < 4; j++ ){
			if( eq(c1, c2)){
				return true;
			}
			c1.roll_z();
		}
		if( i% 2 == 0){
			c1.roll_y();
		}
		else{
			c1.roll_x();
		}
	}
	return false;
}

Cube Dice[100];
int n;

bool check(){
	for(int i = 0; i< (n-1); i++ ){
		for(int j = i+1; j < n; j++){
			if( equal(Dice[i], Dice[j])){
				return false;
			}
		}
	}
	return true;
}


int main(){
	cin >> n;
	for( int j =0 ; j < n; j++){
		for( int i =0; i < 6; i++){
			cin >> Dice[j].f[i];
		}
	}
	
	if( check() ){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, X, M, S{0};
    cin >> N >> X >> M;
    vector<pair<unsigned long, unsigned long>> memo(M);
    for(unsigned long i{0}; i < N; ++i){
        if(memo[X].first){
            const auto t{i - memo[X].first}, c{(N - i - 1) / t};
            i += t * c;
            S += (S - memo[X].second) * c;
        }else memo[X] = {i, S};
        S += X;
        (X *= X) %= M;
    }
    cout << S << endl;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
struct thing {
	string str;
	int times;
};
int main()
{
	string str; cin >> str;
	deque<thing> Q;
	thing tmp;
	tmp.str = str; tmp.times = 0;
	Q.push_back(tmp);
	int k; cin >> k;
	int arr[k + 50]; arr[0] = 0;
	for(int i=1; i<=k; i++)
	{
		int t; cin >> t;
		arr[i] = arr[i - 1];
		if(t == 1)
		{
			arr[i] ++;
			continue;
		}
		int f; string c;
		cin >> f >> c;
		thing tmp; tmp.str = c; tmp.times = i;
		if(f == 1)
		{
			if(arr[i] & 1) Q.push_back(tmp);
			else		   Q.push_front(tmp);
		}
		else
		{
			if(arr[i] & 1) Q.push_front(tmp);
			else		   Q.push_back(tmp);
		}
	}
	while(!Q.empty())
	{
		thing top;
		if(arr[k] % 2)
		{
			top = Q.back(); 
			Q.pop_back();
		}
		else
		{
			top = Q.front();
			Q.pop_front();
		}
		if(top.times % 2 == arr[k] % 2)
		{
			for(int i=0; i<top.str.size(); i++)
				cout << top.str[i];
		}
		else
		{
			for(int i=top.str.size() - 1; i >= 0; i--)
				cout << top.str[i];
		}
	}
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
int pos(int t){
    if(t<0) return -t;
    return t;
}
int main(){
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
int n; cin>>n;
vector<int> a(n+1),dp(n+1,0);
for(int i=0;i<n;i++)cin>>a[i];
dp[1]=pos(a[0]-a[1]);
for(int i=2;i<n;i++){
    dp[i]=min(pos(a[i]-a[i-1])+dp[i-1],pos(a[i]-a[i-2])+dp[i-2]);
    ///cout<<dp[i]<<endl;
}
cout<<dp[n-1]<<'\n';
return 0;
}


Measured memory_bytes: 3940
#include <cstdio>
#define max(a,b) ((a>b)?a:b)
using namespace std;
int main()
{
	int N,cons=0,last=-1,ans=0;
	scanf("%d",&N);
	for(int i=0;i<4;i++){
		if(N%10==last) cons++;
		else cons=0;
		ans=max(ans,cons);
		last=N%10;
		N/=10;
	}
	printf((ans>=2)?"Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1, MOD = 1e9 + 7;
int a[MX], b[MX];
int main()
{
    int t = 1;
//    cin>>t;
    while(t--){
        int n;
        cin>>n;
        bool fl = false;
        for(int i = 0; i < n; i++) cin>>a[i]>>b[i];
        for(int i = 0; i < n - 2; i++){
            if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]){
                fl = true;
                break;
            }
        }
        if(fl) cout<<"Yes";
        else cout<<"No";
    }
}


Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1; i<=n; i++) {
            if((i%3) == 0) System.out.printf(" %d", i);
            else if((i%10)==3) System.out.printf(" %d", i);
            else if((i/10)!=0 && ((i/10)%10)==3) System.out.printf(" %d", i);
            else if((i/10)!=0 && ((i/100)%10)==3) System.out.printf(" %d", i);
            else if((i/10)!=0 && ((i/1000)%10)==3) System.out.printf(" %d", i);
        }
        System.out.println();
    }
}



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



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

Measured memory_bytes: 256
def solve(string):
    n, d, x, *a = map(int, string.split())
    return str(sum([d // _a + 1 if d % _a > 0 else d // _a for _a in a]) + x)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n + 1)])))


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int main()
{
	int a;
    cin >> a;
    if(a==3 || a==5 || a==7)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k,sum=0,i,h;
	vector<int> v;
	cin >> n >> k;
	for(i=0;i<n;i++)
	{
		cin >> h;
		v.push_back(h);
	}
	if(k>=n)
		cout <<"0\n";
	else
	{
		sort(v.begin(),v.end(),greater<long long>());
		for(i=k;i<n;i++)
		{
			sum += v[i];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> s(n+1, 0);
    rep(i,n){
        s[i+1] = (s[i] + a[i]) % m;
    }
    map<int, int> ma;
    rep(i,n+1) ma[s[i]]++;
    ll ans = 0;
    for(auto p : ma){
        ll num = p.second;
        ans += num * (num-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	if (abs(a - b) <= w) {
		cout << 0 << endl;
	}
	else {
		cout << abs(a - b) - w << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h, hh, m, mm, k;
  cin >> h >> m >> hh >> mm >> k;
  m+=60*h;
  mm+=60*hh;
  cout << mm-m-k << '\n';
  return 0;
}


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

int main(){
    int N;
    double sum;
    cin>>N;
    vector<double> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }

    for(int i=0;i<N;i++){
        sum+=1/A.at(i);
    }
    cout<<fixed;
    cout<<setprecision(10)<<1/sum<<endl;
}

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

typedef long long ll;

const ll mod = 1e9 + 7;
const int N = 1e3 + 5;

ll dp[N][N];
int n;
ll A, B, C, D;
ll f[N], inv[N];

ll ncr(ll n, ll r) {
  if(n < r or n < 0 or r < 0) return 0;
  ll res = (inv[n - r] * inv[r]) % mod;
  res = (res * f[n]) % mod;
  return res;
}

ll bigmod(ll a, ll b) {
  ll res = 1LL;
  while(b) {
    if(b & 1LL) res = (res * a) % mod;
    b >>= 1LL;
    a = (a * a) % mod;
  }
  return res;
}

ll go(int cur, int sum) {
  if(cur == B + 1) return sum == n;
  if(dp[cur][sum] != -1) return dp[cur][sum];
  ll ways = 0;
  ways = (ways + go(cur + 1, sum)) % mod;
  for(ll c = C; c <= D; c++) {
    if(c * cur + sum > n) break;
    ll facto = bigmod(inv[cur], c);
    ll mul = (ncr(n - sum, c * cur) * f[c * cur]) % mod;
    mul = (mul * facto) % mod;
    mul = (mul * inv[c]) % mod;
    ways = (ways + mul * go(cur + 1, c * cur + sum) % mod) % mod;
  }
  return dp[cur][sum] = ways;
}

int main() {
  f[0] = 1;
  for(ll i = 1; i < N; i++) {
    f[i] = (f[i - 1] * i) % mod;
  }
  inv[N - 1] = bigmod(f[N - 1], mod - 2);
  inv[0] = 1;
  for(ll i = N - 2; i >= 0; i--) {
    inv[i] = (inv[i + 1] * (i + 1)) % mod;
  }
  cin >> n >> A >> B >> C >> D;
  memset(dp, -1, sizeof dp);
  cout << go(A, 0);
}


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

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
 
using namespace std; 

int parent[100001];
int size[100001];

void make_set(int v)
{
    parent[v] = v;
    size[v] = 1;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b)
{
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (size[a] < size[b])
            swap(a, b);
        parent[b] = a;
        size[a] += size[b];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i  = 1 ; i <= n ; i++)
    make_set(i);
    for(int i = 0 ; i < m ; i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        union_sets(a,b);
    }
    for(int i = 1 ; i <= n ; i++)
    find_set(i);
    set<int> s;
    for(int i = 1 ; i<= n ; i++)
    s.insert(parent[i]);
    cout<<s.size();
    return 0;
}

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

int main() {
  int N;
  int A[100010];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  
  int count = 0;
  bool up = false;
  bool down = false;
  for (int i = 1; i < N; i++){
    int dif = A[i] - A[i-1];
    if (dif > 0) up = true;
    if (dif < 0) down = true;
    if (up && down) {
      count++;
      up = down = false;
      continue;
    }
  }
 
  cout << count + 1 << endl;
}

Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;

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

    for (int i = 0;i < 3;i++) {
        if (n[i] == '1') {
            cout << 9;
        }else {
            cout << 1;
        }
    }

    return 0;
}


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

void solve(){
int k;
cin>>k;
string s;
cin>>s;
string ss="...";
if(s.length()<=k){
	cout<<s<<endl;
}

else{
	cout<<s.substr(0,k)+ss<<endl;
}

 
}
int main(){
	solve();
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(void){
    int n,m,i,s,c;
    scanf("%d%d",&n,&m);
    int num[4],cnt[4];
    for(i=0;i<4;i++){
        num[i] = 0;
        cnt[i] = 0;
    }
    
    for(i=0;i<m;i++){
        scanf("%d%d",&s,&c);
        if(n>=2 && s ==1 && c== 0){
            printf("-1");
            return 0;
        }
        
        if(cnt[s]>=1 && num[s] != c){
            printf("-1\n");
            return 0;
        }
        
        num[s] = c;
        cnt[s]++;
    }
    
    if(n==3 && cnt[1] ==0){
        num[1] = 1;
    }else if(n==2 && cnt[1] == 0){
        num[1] = 1;
    }
    if(n==3){
        printf("%d\n",num[1]*100+num[2]*10+num[3]);
    }else if(n==2){
        printf("%d\n",num[1]*10+num[2]);
    }else{
        printf("%d\n",num[1]);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  int h[n],dp[n];
  for(int i=0;i<n;i++) scanf("%d",&h[i]);

  dp[0]=0; dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
     dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  printf("%d",dp[n-1]);
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int N = scanner.nextInt();
        boolean flag=true;
        int[] arr = new int[N];
        for (int i=0; i <N;i++){
            arr[i]=scanner.nextInt();
        }
        Arrays.sort(arr);
        for(int i=0;i<N-1;i++){
            if (arr[i]==arr[i+1]){
                flag=false;
                break;
            }
        }
        if(flag){
            pw.println("YES");
        }else{
            pw.println("NO");
        }
        pw.close();
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

    }

}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
ll fxor(ll b)
{
	ll res=0;
	ll c=b;
	while(c%4!=0)
	{
		res^=c;
		c--;
	}
	res^=c;
	return res;
}

int main()
{
  ll a,b;cin>>a>>b;
	ll fb=fxor(b);
	ll fa=fxor(a-1);
	cout<<(fxor(b)^fxor(a-1))<<endl;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
z = 0
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans *= i
		if ans > mod:
			print(-1)
			z = 1
			break
	if z == 1:
		pass
	else:
		print(ans)

Measured memory_bytes: 78300