akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

vector<int> topologicalSort(const vector<vector<int> > &graph) {
    int V = (int)graph.size(), cur = 0;
    vector<int> deg(V), res(V);
    stack<int> stk;
    for (int i = 0; i < V; ++i)
        for (int v : graph[i])deg[v]++;
    for (int i = 0; i < V; ++i)if (deg[i] == 0)stk.push(i);
    while (!stk.empty()) {
        int v = stk.top(); stk.pop();
        res[cur++] = v;
        for (int w : graph[v])if (!--deg[w])stk.push(w);
    }
    return cur == V ? res : vector<int>();
}

const string OK = "Yes", NG = "No";
string solve() {
    int N, M;
    cin >> N >> M;
    auto G = vv(int, N, 0, 0);
    auto H = vector<vector<pii> > (N);

    rep(i, M) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        --r;
        G[l].emplace_back(r);
        H[l].emplace_back(r, d);
    }

    auto top = topologicalSort(G);
    if (top.empty())RT NG;

    vi dis(N, -1);
    each(i, top) {
        if (dis[i] == -1)dis[i] = 0;
        each(e, H[i]) {
            int j = e.first;
            int d = e.second;
            if (dis[j] != -1 && dis[i] + d != dis[j])RT NG;
            dis[j] = dis[i] + d;
        }
    }

    RT OK;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cout << solve() << endl;
}

Measured memory_bytes: 12672
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int sx, sy, tx, ty; 
    cin >> sx >> sy >> tx >> ty;
    
    int dx = tx - sx, dy = ty - sy;
    rep(i, dx) cout << "R";
    rep(i, dy) cout << "U";
    rep(i, dx) cout << "L";
    rep(i, dy + 1) cout << "D";
    rep(i, dx + 1) cout << "R";
    rep(i, dy + 1) cout << "U";
    cout << "LU";
    rep(i, dx + 1) cout << "L";
    rep(i, dy + 1) cout << "D";
    cout << "R" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int64_t a,b,n,v;
    cin >> n>>a>>b;
    if(n%(a+b)<=a)   cout << n%(a+b)+a*(n/(a+b))<<endl;
    else    cout << a+a*(n/(a+b))<<endl;

}

Measured memory_bytes: 256
def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list(map(float, get_line()))
def get_float_lines(v): return [get_float_line() for _ in range(v)]

A, B = get_int_line()
if B % A == 0:
  print(A + B)
else:
  print(B - A)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef unsigned long long ULong;



int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  string s;
  cin >> s;

  cout << (((s.size() & 1) ^ (s[0] == s.back())) ? "First" : "Second");

}


Measured memory_bytes: 512
a ,b =map(int,input().split())

if a==1 and b==31 or a==2 and b==28 or a==3 and b==31 or a==4 and b==30 or a==5 and b==31 or a==6 and b==30 or a==7 and b==31 or a==8 and b==31 or a==9 and b==30 or a==10 and b==31 or a==11 and b==30 or a==12 and b==31:
    print(1)
else:
    print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

int K;
ll res = 0;

int gcd(int a, int b) {
    if (b == 0) return a;
    a%=b;
    return gcd(b,a);
}

int main() {
    cin >> K;
    for (int i = 1; i <= K; ++i)
        for (int j = 1; j <= K; ++j)
            for (int k = 1; k <= K; ++k) {
                vector<int> v = {i,j,k};
                sort(ALL(v));
                res += gcd(v[2], gcd(v[1], v[0]));
            }
    cout << res << endl;
}


Measured memory_bytes: 3616
import java.util.Scanner;

class Stack{
    int top,max;
    int[] arr;
    
    Stack(int num) {
        top = 0;
        max = num - 1;
        arr = new int[num]; 
    }
    public boolean isEmpty() {
        return top == 0;
    }
    public boolean isFull() {
        return top >= max;
    }
    public void push(int x) {
        if(isFull()) {
            System.out.println("This stack is ovew flow");
        } else {
            arr[++top] = x;
        }
    }
    public int pop() {
        if(isEmpty()) {
            System.out.println("This stack is empty");
        } else {
            top--;
        }
        return arr[top+1];
    }    
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Stack stack = new Stack(101); 
        
        int a,b;
        String str;
        
        String[] test = new String[101]; 
        int i = 0;

        while(sc.hasNext()) {
            str = sc.next();
            
            if(str.equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.push(b+a);
            } else if(str.equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.push(b-a);
            } else if(str.equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.push(b*a);
            } else {
                stack.push(Integer.parseInt(str));
            }
        }
        System.out.println(stack.pop());
    }
}

Measured memory_bytes: 26192
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    deque<int> p(n);
    map<int,int>place;
    rep(i, n)
    {
        cin >> p[i];
        place[p[i]]=i;
    }
    int cont=1;
    int maxcont=0;
    rep(i,n-1){
        if(place[i+1]<place[i+2]){
            cont++;
        }else{
            maxcont=max(cont,maxcont);
            cont=1;
        }
        //cout<<cont<<endl;
    }
    maxcont=max(cont,maxcont);
    cout<<n-maxcont<<endl;



}

Measured memory_bytes: 10624
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n, m, a, b;
		String[] str;
		int[][] map;
		int[] prim;
		PriorityQueue<int[]> que;
		while((n = sc.nextInt()) != 0){
			m = sc.nextInt();
			map = new int[n][n];
			for(int i = 0; i < m; i++){
				str = sc.next().split(",");
				a = Integer.parseInt(str[0]);
				b = Integer.parseInt(str[1]);
				map[a][b] = map[b][a] = Integer.parseInt(str[2]);
			}
			prim = new int[n];
			Arrays.fill(prim, -1);
			que = new PriorityQueue<int[]>(m, new Comparator<int[]>(){
				public int compare(int[] a, int[] b){
					return a[0] - b[0];
				}
			});
			for(int i = 1; i < n; i++){
				if(map[0][i] != 0){
					que.add(new int[]{map[0][i], i});
				}
			}
			int[] now;
			int sum = 0;
			prim[0] = 0;
			while(!que.isEmpty()){
				now = que.poll();
				if(prim[now[1]] == -1){
					sum += (now[0] / 100) - 1;
					prim[now[1]] = 0;
					for(int i = 0; i < n; i++){
						if(map[now[1]][i] != 0){
							que.add(new int[]{map[now[1]][i], i});
						}
					}
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ok = true;
    for(int i = 0; i < a; i++)
    {
        if(s.at(i)>='0'&&s.at(i)<='9')
        {

        }
        else ok = false;
    }
    if(s.at(a)=='-')
    {

    }
    else ok = false;
    for(int i = a+1; i < s.length(); i++)
    {
        if(s.at(i)>='0'&&s.at(i)<='9')
        {

        }
        else ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int i;
int main()
{
	cin>>a;
	b=a;
	reverse(b.begin(),b.end());
	for(i=0;i<a.length();i++)
	{
		if(b[i]=='b') b[i]='d';
		else if(b[i]=='d') b[i]='b';
		else if(b[i]=='p') b[i]='q';
		else if(b[i]=='q') b[i]='p';
	}
//	for(i=0;i<=3;i++) if(a[i]!=b[i]){cout<<"No"<<endl;return 0;}
//	cout<<"Yes"<<endl;
	if(a==b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

result=0
for i in range(1,n+1):
  cnt=0
  if i%2==1:
    for j in range(1,i+1):
      if i%j==0:
        cnt+=1
        #print(i,j)
  if cnt==8:
    #print(">>",i)
    result+=1
    
print(result)
      
  


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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  set<int> st;
  rep(i,n){
    cin>>a[i];
    st.insert(a[i]);
  }
  if(st.size()==n)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 13464
n = int(input())

m = n - 1
b = list(map(int,input().split()))

if m == 1:
    print(b[0]*2)
else:
    ans = b[0] + b[-1]
    for i in range(m - 1):
        ans += min(b[i],b[i + 1])
    print(ans)


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

int main()
{
  string S;
  cin >> S;
  map<char, int> mp;
  for (int i = 0; i < S.size(); i++)
  {
    mp[S[i]]++;
  }
  bool can = true;
  for (auto itr = mp.begin(); itr != mp.end(); itr++)
  {
    if (itr->second > 1)
    {
      can = false;
      break;
    }
  }
  if (can)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    p = 2 ** n
    ls = [10 ** 15] * p
    ls[0] = 0
    for i in range(m):
        a, b = list(map(int, readline().split()))
        t = sum([2 ** (x - 1) for x in list(map(int, readline().split()))])
        for j in range(p):
            ls[j | t] = min(ls[j | t], ls[j] + a)
    print(ls[-1] if ls[-1] != 10 ** 15 else -1)


if __name__ == '__main__':
    solve()


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

using namespace std;

namespace NOIP2018 {

stack<char> lty;

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	int len = str.length();
	string tmp(str);
	for(int i = len - 1; i >= 0; i--) {
		if (tmp[i] == ')')
			lty.push(')');
		else if (lty.empty() || lty.top() != ')') {
			str += ')';
			if (!lty.empty())
				lty.pop();
		} else lty.pop();
	}
	while (!lty.empty()) {
		str = '(' + str;
		lty.pop();
	}
	cout << str << endl;
	return 0;
}

}

int main() { return NOIP2018::main(); }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  long double a, b, x;
  cin >> a >> b >> x;
  long double c;
  if(a*a*b >= 2*x){
    c = 2 * x / a / b;
    printf("%llf\n",(long double)90.0 - atan2l(c,b) * (long double)180.0 / M_PI);
  }else{
    c = 2 * (a*a*b - x) / a / a;
    printf("%llf\n", atan2l(c,a) / M_PI * (long double)180.0);
  }
  
}

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

int main(){
  int n,k,d,p;
  int a[100]={0};
  
  //カウンタ
  int i,j;
  cin >> n >> k;
  
  for(j=0;j<k;j++){
    cin >> d;
    for(i=0;i<d;i++){
      cin >> p;
      a[p-1] = 1;
    }
  }
  p=0;
  for(i=0;i<n;i++){
    //cout<<"a["<<i<<"]="<<a[i]<<endl;
    if(a[i]==0) { p++;}
  }
  cout << p << endl;
  return 0;
}

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

int main() {
  long long n;
  while (cin >> n) {
	if (n == 0) break;
	long long res = n;
	for (long long a = 0; a * a * a <= n; ++a) {
	  for (long long b = 0; a * a * a + b * b <= n; ++b) {
		res = min(res, a + b + (n - a*a*a - b*b));
	  }
	}
	cout << res << endl;
  }
}



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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans = 0;

    for (int i=1; i<=n; ++i) {
        if (i<=k) ans += x;
        else ans += y;
    }

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


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  auto dp=vec(41,2,-1LL);
  dp[0][0]=0;
  rep(i,0,40){
    ll bit=1LL<<(40-1-i);
    ll p=0,q=0;
    rep(j,0,n){
      p+=bit&~a[j];
      q+=bit&a[j];
    }
    if(k&bit){
      chmax(dp[i+1][0],dp[i][0]+p);
      if(dp[i][1]!=-1)chmax(dp[i+1][1],dp[i][1]+max(p,q));
      chmax(dp[i+1][1],dp[i][0]+q);
    }
    else{
      chmax(dp[i+1][0],dp[i][0]+q);
      if(dp[i][1]!=-1)chmax(dp[i+1][1],dp[i][1]+max(p,q));
    }
  }
  //debug(dp,41,2);
  cout<<max(dp[40][0],dp[40][1])<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
	char m[11];
	int n,i,sum,x,sa[6];
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		sa[0]=1; sa[1]=5; sa[2]=6;
		sa[3]=2; sa[4]=4; sa[5]=3;
		sum=1;
		for(i=0;i<n;i++){
			scanf("%s",m);
			if(strcmp(m,"North")==0){
				x=sa[0]; sa[0]=sa[3]; sa[3]=sa[2];
				sa[2]=sa[1]; sa[1]=x;
			}
			if(strcmp(m,"East")==0){
				x=sa[0]; sa[0]=sa[4]; sa[4]=sa[2];
				sa[2]=sa[5]; sa[5]=x;
			}
			if(strcmp(m,"West")==0){
				x=sa[0]; sa[0]=sa[5]; sa[5]=sa[2];
				sa[2]=sa[4]; sa[4]=x;
			}
			if(strcmp(m,"South")==0){
				x=sa[0]; sa[0]=sa[1]; sa[1]=sa[2];
				sa[2]=sa[3]; sa[3]=x;
			}
			if(strcmp(m,"Right")==0){
				x=sa[3]; sa[3]=sa[5]; sa[5]=sa[1];
				sa[1]=sa[4]; sa[4]=x;
			}
			if(strcmp(m,"Left")==0){
				x=sa[3]; sa[3]=sa[4]; sa[4]=sa[1];
				sa[1]=sa[5]; sa[5]=x;
			}
			sum+=sa[0];
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 2692
L,R=map(int,input().split())

K=R-L+1
min=3000
if K>=2019:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            if min>=(i*j)%2019:
                min=(i*j)%2019

    print(min)


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;

const int INF = 1 << 30;
int L;

struct edge{
    int to, cost;
};

vector<edge> G[305];
P d[305][305]; //iからjに何回の補給で行けるか

void dijkstra(int s){
    priority_queue<PP, vector<PP>, greater<PP>> que;
    d[s][s] = P(0, 0);
    que.push(PP(d[s][s], s));

    while(!que.empty()){
        PP pp = que.top();
        que.pop();
        int v = pp.second;
        int cnt = pp.first.first;
        int use = pp.first.second;
        if(d[s][v] < pp.first) continue;

        //cout << cnt << " " << use << " " << v + 1 << endl;

        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            P nxt;
            if(L < e.cost){
                continue;
            }
            else if(L - use < e.cost){
                nxt.first = cnt + 1;
                nxt.second = e.cost;
            }
            else if(e.cost <= L - use){
                nxt.first = cnt;
                nxt.second = use + e.cost;
            }

            if(d[s][e.to] > nxt){
                d[s][e.to] = nxt;
                que.push(PP(d[s][e.to], e.to));
            }
        }
    }
}



int main(){
    fill(d[0], d[305], P(INF, INF));

    int N, M;
    cin >> N >> M >> L;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(edge{b, c});
        G[b].push_back(edge{a, c});
    }

    for(int i = 0; i < N; i++){
        //cout << "i = " << i << endl;
        dijkstra(i);
        //cout << endl;

    }

    int Q;
    cin >> Q;
    vector<int> ans;
    for(int i = 0; i < Q; i++){
        int s, t;
        cin >> s >> t;
        s--;
        t--;

        if(d[s][t].first == INF){
            ans.push_back(-1);
        } else {
            ans.push_back(d[s][t].first);
        }
    }

    for(int x : ans){
        cout << x << endl;
    }

    //debug
    /*for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cout << i + 1 << j + 1 << " " << d[i][j].first << " " << d[i][j].second << endl;
        }
    }*/


    return 0;
}

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

int main()
{
  int n;
  int sum;
  int m;
  while(1){
    cin >> n;
    if (n == 0){
      break;
    }
    sum = 0;
    for (int i = 0; i < n / 4; i++){
      cin >> m;
      sum += m;
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

void solve() {
  // int x;
  // cout << endl;
  char a = 'a';
  bool b = false;
  for (int i = 0; i < 4; i++) {
    char c;
    cin >> c;
    if (c == a) {
      b = true;
    }
    a = c;
  }

  if (b) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include<stack>
#include<string.h>
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;
long long int a[300000];
long long int b[300000];
int main(void)
{
    int n;
    scanf("%d",&n);
    int i,j;
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    for(i=n-1,j=0; i>=0; i=i-2,j++)
    {
        b[j]=a[i];
    }
    for(j=n-1,i=n-2; i>=0; j--,i=i-2)
    {
        b[j]=a[i];
    }
    for(i=0; i<n; i++)
        printf("%lld ",b[i]);
    }


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	bool res = true;
	for (int i = 0; i < 30; i++) {
		bool x[n];
		x[0] = a[0] >> i & 1;
		bool cur = false;
		for (int j = 0; j < 2; j++) {
			x[1] = j;
			for (int k = 2; k < n; k++) x[k] = x[k - 1] ^ x[k - 2];
			int yes = 0, yesr = 0;
			for (int k = 0; k < n; k++) {
				if (x[k]) yes++;
				if (a[k] >> i & 1) yesr++;
			}
			if (yes == yesr) cur = true;
		}
		if (!cur) {
			res = false;
			break;
		}
	}
	std::cout << (res ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.*;
import java.lang.Integer; 

public class Main {
  public static void main(String[] args){
    List<Integer> xList = new ArrayList<Integer>();
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()){
      xList.add(sc.nextInt());
    }
    for(int i=0;i < xList.size();i++){
      if(xList.get(i).compareTo(Integer.valueOf(0)) == 0){
    	System.out.println(i+1);
        break;
      }
    }
  }
}

Measured memory_bytes: 35788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n;cin>>n;
    vector<int>v(n);
    rep(i,n)cin>>v[i];
    sort(v.begin(), v.end());
    co(v[n/2]-v[n/2-1]);
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=jp

#define MAX 100005
int A[MAX];

static int par(int l, int r) {
    int v = A[r];
    int i = l - 1;
    for (int j = l; j < r; j++) {
        if (A[j] <= v) {
            i++;
            swap(A[j], A[i]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}

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

    int q = par(0, N-1);
    REP(i, N) {
        if (i) cout << " ";
        if (i==q) cout << "[";
        cout << A[i];
        if (i==q) cout << "]";
    }
    cout << "\n";

    return 0;
}


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

template< typename T >
struct BinaryIndexedTree {
	vector< T > data;

	BinaryIndexedTree(int sz) {
		data.assign(++sz, 0);
	}

	T sum(int k) {
		T ret = 0;
		for(++k; k > 0; k -= k & -k) ret += data[k];
		return (ret);
	}

	void add(int k, T x) {
		for(++k; k < data.size(); k += k & -k) data[k] += x;
	}
};

signed main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N, 0);
	for(ll i=0; i<N; i++) scanf("%lld", &a[i]);
	if(N==1){
		printf("%lld\n", a[0]);
		return 0;
	}

	ll left = 0;
	ll right = 1e9+1;
	auto isOK = [&](ll val) -> bool {
		vector<ll> b(N,0);
		for(ll i=0; i<N; i++) b[i] = (a[i]<val ? -1 : 1);
		vector<ll> rui(N+1, 0);
		for(ll i=0; i<N; i++) rui[i+1] = rui[i] + b[i];
		for(ll i=0; i<N+1; i++) rui[i] += N;

		BinaryIndexedTree<ll> bit(2*N);
		ll tentosu=0;
		for(ll i=0; i<N+1; i++) {
			tentosu += i - bit.sum(rui[i]);
			bit.add(rui[i], 1);
		}
		ll t = N*(N+1)/2 - tentosu;
		return t >= N*(N+1)/2/2;
	};

	while(right - left > 1) {
		ll mid = left + (right - left) / 2;
		if(isOK(mid)) left = mid;
		else right = mid;
	}

	printf("%lld\n", left);
	return 0;
}


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

int main(){
    int h,n;
    cin>>h>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    string s;
    int N, K;

    cin >> N >> K;
    cin >> s;

    s[K - 1] = s[K - 1] - 'A' + 'a';

    cout << s;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define M 100005
int A[M];
int main(){
	int n,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),sum^=A[i];
	if(sum==0)puts("Yes");
	else puts("No");
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// v is sorted
bool isUnique(vector<ll> v){
	rep(i, v.size()-1){
		if(v[i] == v[i+1]) return false;
	}

	return true;
}

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

	int N, M;
	cin >> N >> M;

	vector<ll> A(N);
	rep(i, N) cin >> A[i];
	sort(A.begin(), A.end());
	if(!isUnique(A)){
		cout << 0 << endl;
		return 0;
	}

	vector<ll> B(M);
	rep(i, M) cin >> B[i];
	sort(B.begin(), B.end());
	if(!isUnique(B)){
		cout << 0 << endl;
		return 0;
	}

	ll MOD = 1e9 + 7;
	ll ans = 1;

	for(ll x = N * M; x >= 1; x--){
		int ia = lower_bound(A.begin(), A.end(), x) - A.begin();
		int ib = lower_bound(B.begin(), B.end(), x) - B.begin();
		if(ia >= N || ib >= M){
			cout << 0 << endl;
			return 0;
		}

		if(A[ia] == x && B[ib] == x) continue;

		if(A[ia] == x){
			ans *= M - ib;
			ans %= MOD;
			continue;
		}

		if(B[ib] == x){
			ans *= N - ia;
			ans %= MOD;
			continue;
		}

		ans *= max((N - ia) * (M - ib) - (N * M - x), 0LL);
		ans %= MOD;
	}

	cout << ans << endl;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<long long> h(n);
  bool p[n];
  int ans = 0;
  for(int i = 0; i < n; i++){
    p[i] = true;
  }
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    if(h[a-1] > h[b-1]) p[b-1] = false;
    else if(h[a-1] < h[b-1]) p[a-1] = false;
    else if(h[a-1] == h[b-1]) {p[a-1] = false; p[b-1] = false;}
  }
  for(int i = 0; i < n; i++){
    if(p[i] == true) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4016
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

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

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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int n;
    cin >> n;
    int h = n / 3600;
    n -= h * 3600;
    int m = n / 60;
    n -= m * 60;
    int s = n;
    printf("%d:%d:%d\n",h,m,s);

    return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




int main() {
  int n;
  cin >> n;
  int h[n+1];
  rep (i,n){
    cin >> h[i];
  }
  int ans=1;

  for (int i = 1;i < n;i++){
    bool ok = true;
    for (int j = 0;j < n;j++){
      if (j==i) break;
      if (h[i]<h[j]){
        ok = false;
      }
    }
    if(ok) ans++;
    
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    int num;
	cin >> num;
	string s;
	cin >> s;
	REP(p, 2){
		REP(q, 2){
			vector<int> ans;
			ans.push_back(p), ans.push_back(q);
			REP(i, num){
				if(s[i] == 'o') ans.push_back(ans[i] ^ ans[i + 1]);
				else ans.push_back(ans[i] ^ ans[i + 1] ^ 1);
			}
			if(ans[num] == p && ans[num + 1] == q){
				FOR(i, 1, num + 1){
					if(ans[i]) cout << "W";
					else cout << "S";
				}
				cout << '\n';
				return 0;
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 1392
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll total = 0;
    ll m = 0;
    for(int i = 0; i < n; ++i){
        ll p;
        cin >> p;
        total += p;
        m = max(p, m);
    }
    total -= m / 2;
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    int n;cin>>n;
    vector<ll> v(n);
    rep(i,0,n)cin>>v[i];
    ll xx=0;
    rep(i,0,n)xx^=v[i];
    rep(i,0,n)cout<<(xx^v[i])<<" ";
}


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

int main()
{
    int n, coin_change, sheet_numbers;

    cin >> n;

    sheet_numbers = (n + 999) / 1000;
    coin_change = sheet_numbers*1000 - n;
    
    cout << coin_change << endl;
    return 0;
}

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

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

    int w = 0, b = 0;
    for(int i=0; i<N; ++i) {
        if(S[i] == '.') ++w;
    }
    int res = w;

    for(int i=0; i<N; ++i) {
        if(S[i] == '#') {
            ++b;
        } else {
            --w;
        }
        res = min(res, b + w);
    }

    cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N], b[N];
int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	ll foo = 1e15, hoo = 1e15;
	for(int i = 1; i <= n; i ++)
		cin >> a[i], hoo = min(hoo, a[i]);
	for(int i = 1; i <= m; i ++)
		cin >> b[i], foo = min(foo, b[i]);
	ll mn = foo + hoo;
	for(int i = 1; i <= q; i ++)
	{
		int x, y, z;
		cin >> x >> y >> z;	
		ll o = a[x] + b[y] - z;
		mn = min(mn, o);
	}
	cout << mn;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){

    int w,h,x,y,r,f=0;

    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

    if(x>=r){
      if(y>=r){
        if(w-x>=r){
          if(h-y>=r){
            f=1;
          }
        }
      }
    }

    if(f==1){
      printf("Yes\n");
    }else{
      printf("No\n");
    }

    return 0;
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define req(i,f,N) for(int i = f; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    double N, K;
    cin >> N >> K;
    double possibility = 0;
    int pt = 0, cnt = 0;
    rep(i, N) {
        pt = i + 1;
        cnt = 0;
        while (pt < K) {
            cnt++;
            pt *= 2;
        }
        possibility += pow(0.5, cnt) / N;
    }
    cout << possibility << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_kagami_mochi(void) {
	int n;
	int d[110];
	cin >> n;

	for (int i = 0; i < n; i++)cin >> d[i];

	sort(d, d + n);


	int cnt = 1;
	for (int i = n-2; i >=0 ; i--) {
		if (d[i] != d[i + 1]) cnt++;
	}

	cout << cnt << endl;

}

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

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000<<"\n";   

    return 0;
}

Measured memory_bytes: 3632
N, W = map(int, input().split())
value = []
weight = []

for i in range(N):
    vi, wi = map(int, input().split())
    value.append(vi)
    weight.append(wi)

# dp[i+1][w]:i番目までの品物を入れたとき、wを超えない最大価値

dp = [[0]*(10**4+10) for _ in range(110)]
def rec(i,w):
    dp[i+1][w] = dp[i][w] #i番目は入れない

    if w-weight[i] >= 0:
        dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w])

for i in range(N):
    for j in range(W+1):
        rec(i,j)
print(dp[N][W])


Measured memory_bytes: 42684
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, M, a; bool z[11];
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> a, z[a] = 1;
	for (int i = N; ; i++) {
		string s = to_string(i);
		bool flag = true;
		for (int i = 0; i < s.size(); i++) {
			if (z[s[i] - 48]) flag = false;
		}
		if (flag) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

public class P
{
    public int d { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new List<int>[n + 1];
        for (int i = 1; i <= n; i++) d[i] = new List<int>();
        var dn = new string[n + 1];
        Console.ReadLine();
        dn[1] = Console.ReadLine().Trim();
        for (int i = 2; i <= n; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            var m = Console.ReadLine().Trim();
            dn[i] = m;
            d[k].Add(i);
        }
        print(d, dn);
    }
    static void print(List<int>[] d, string[] dn)
    {
        var sb = new StringBuilder();
        var st = new Stack<P>();
        st.Push(new P { d = 0, id = 1 });
        while (st.Count() > 0)
        {
            var w = st.Pop();
            sb.Append(new string('.', w.d)  + dn[w.id] + "\n");
            var dc = d[w.id].Count();
            if (dc > 0)
            {
                d[w.id].Reverse();
                foreach (var x in d[w.id])
                    st.Push(new P { d = w.d + 1, id = x });
            }
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 22356
#include <stdio.h>

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

  int past = N%10;
  int ans = 1;
  for (int i = 0; i < 3; i++) {
    N /= 10;
    if(past == N%10) ans = 0;
    past = N%10;
  }

  if(ans == 1) printf("Good\n");
  else printf("Bad\n");

  return 0;
}

Measured memory_bytes: 128
N = int(input())
def n_ary(l,d): # リストl中の文字でd桁までを全列挙(sorted)
    if d == 1:
        return(l)
    n = len(l)
    ll = n_ary(l,d-1)
    lll = []
    for i in l:
        for j in ll[n*(n**(d-2)-1)//(n-1):]:
            lll.append(i+j)
    return(ll+lll)
possible = [i.replace('0','3').replace('1', '5').replace('2','7') for i in n_ary(['0','1','2'],9)] # 制約が10^9なので9
print(len([int(i) for i in possible if ('3' in i and '5' in i and '7' in i and int(i) <= N)]))


Measured memory_bytes: 45424
A = []
A_1 = list(map(int,input().split()))
A_2 = list(map(int,input().split()))
A_3 = list(map(int,input().split()))
A.append(A_1)
A.append(A_2)
A.append(A_3)
B = []
check=0
BingocountR=0
BingocountG=0
N = int(input())
ArrayBingo =[[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
    B.append(int(input()))
for j in range (3):
    for k in range (3):
        for l in range (N):
            if A[j][k]==B[l]:
                ArrayBingo[j][k]=1
for i in range(3):
    for j in range(3):
        if ArrayBingo[j][i]==1:
            BingocountR+=1
            if BingocountR ==3:
                check+=1
    BingocountR = 0
for i in range(3):
    for j in range(3):
        if ArrayBingo[i][j]==1:
            BingocountG+=1
            if BingocountG ==3:
                check+=1
    BingocountG = 0
if (ArrayBingo[0][0] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][2] == 1) or (ArrayBingo[0][2] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][0] == 1):
    check += 1
if check>0:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3064
#include <iostream>
#define MAX_N 100000
using namespace std;

int h[MAX_N];
int n, k;

void solve()
{
    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (h[i] >= k)
        {
            ans++;
        }
    }

    cout << ans;
}

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

    solve();
}


Measured memory_bytes: 640
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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









int main(){
    std::string S; std::cin >> S;
    std::cout << S << (*(S.rbegin()) == 's' ? "es" : "s") << std::endl;
    return 0;
}


Measured memory_bytes: 3628