akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  
  int answer=0;
  
  for (int i=0;i<a+1;i++){
    for (int j=0;j<b+1;j++){
      for (int k=0;k<c+1;k++){
        if (500*i+100*j+50*k==x){
          answer+=1;
        }
      }
    }
  }
  cout<<answer<<endl;
  
        
  
  
}

  













Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

class UnionFind {
private:
	vector<int> pastNode;

	class Node {
	public:
		int parent;
		int count;

		Node(int parent) {
			this->parent = parent;
			this->count = 1;
		}
	};

	vector<Node> node;
public:
	UnionFind(int size) {
		for (int i = 0; i < size; i++) {
			node.push_back(Node(i));
		}
	}

	int root(int x) {
		pastNode.clear();

		while (x != node[x].parent) {
			pastNode.push_back(x);
			x = node[x].parent;
		}
		rep(i, pastNode.size()) {
			node[pastNode[i]].parent = x;
		}
		return x;
	}

	void unite(int x, int y) {
		if (root(x) == root(y)) return;

		node[root(y)].count += node[root(x)].count;
		node[root(x)].parent = root(y);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	int countSames(int x) {
		return node[root(x)].count;
	}
};

map<int, unordered_set<int>> g;

signed main() {
	int N, M;
	cin >> N >> M;

	vector<int> p;
	inputVector(p, N);
	rep(i, N) p[i]--;

	UnionFind uf(N);
	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		uf.unite(x, y);
	}

	rep(i, N) {
		g[uf.root(i)].insert(i);
	}

	int ret = 0;
	itrep(it, g) {
		unordered_set<int> v = it->second;
		unordered_set<int> w;
		itrep(it2, v) {
			w.insert(p[*it2]);
		}

		itrep(it2, v) {
			if (w.find(*it2) != w.end()) {
				ret++;
			}
		}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 19824
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int a, b;
  cin >> a >> b;
  if(a*b == 15 ) cout << "*";
  else if (a+b == 15) cout << "+";
  else cout << 'x';


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  
  if(a>b)swap(a,b);
  int ans=0;
  for(int i=0;i<b;i++){
    ans=ans*10+a;
    
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>
#include<iterator>
#include<map>
#include<cmath>
#include<unordered_map>
#include<vector>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
const int inf = (1e18)+7;
const int neginf = -1*((int)1e17 ) + 7 ; 

int32_t main() {
    fastio
    int n;
    cin>>n;
    
    int oddct;
    
    if(n&1)
        oddct = (n/2)+1;
    else
        oddct = n/2;
    
    double x = oddct;
    
    cout<<fixed<<setprecision(8)<<(x/(n*1.0));
    
    
        
    
    
     
    
    
    

        
        
        
    
            
        
       
        
        
        
    
     
    
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll)1e9+7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000005; 
int n;
ll cnt[MAXN];
ll arr[MAXN];
ll vis[MAXN];
bool coprime(){
    for(int i=2;i<=1e6;i++){
        if(vis[i])
        continue;
        int ans=0;
        ans+=cnt[i];
        for(int j=i+i;j<=1e6;j+=i){
            ans+=cnt[j];
            vis[j]=1;
        }
        if(ans>1){
            return 0;
        }
    }
    return 1;
}
int main() {
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        cnt[arr[i]]++;
        
    }
    if(coprime()){
        cout<<"pairwise coprime"<<endl;
    }
    else{
        ll gcd=0;
        for(int i=0;i<n;i++){
            gcd=__gcd(gcd,arr[i]);
        }
        if(gcd==1){
            cout<<"setwise coprime"<<endl;
        }
        else{   
            cout<<"not coprime"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 26964
#include"bits/stdc++.h"
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);
bool isMultiOf(LL, LL);

int main() {
	string s, t, u; cin >> s >> t >> u;
	char sa = s[0] - 32, ta = t[0] - 32, ua = u[0] - 32;
	cout << sa << ta << ua;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}
bool isMultiOf(LL a, LL b) {
	return a % b == 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int r, d, x0;
	
	cin>> r>>d>>x0;
	vector<int> a(11);
	a[0] = x0;
	for(int i=1;i<=10;i++){
		a[i] = r*a[i-1] - d;
	}
	for(int i=1;i<=10;i++){
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>

int a[5];

int main() {
	scanf("%d%d%d", &a[1], &a[2], &a[3]);
	std::sort(a+1, a+3+1);
	printf("%d\n", a[3] * 10 + a[1] + a[2]);
	return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())

a = list(map(int, input().split()))

seen = [-1 for i in range(n)]

seen[0] = 0

cur = 1

fin = 0

for step in range(1, n+3):
    n_c = a[cur-1]
    if step == k:
        fin = 1
        print(n_c)
        break
    if seen[n_c-1] >= 0:
        loop = step - seen[n_c-1]
        before = seen[n_c-1]
        start = n_c
        break
    seen[n_c-1] = step
    cur = n_c

if not fin:
    if loop == 0:
        print(start)
    else:
        rem = k - before
        ama = rem % loop
        cur = start
        for i in range(ama):
            n_c = a[cur-1]
            cur = n_c
        print(cur)


Measured memory_bytes: 32304
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sc = list(map(list, set(map(tuple, sc))))

ans = [-1] * n
for i in sc:
    if i[0] == 1 and i[1] == 0 and n == 1:
        print(0)
        exit()
    if i[0] == 1 and i[1] == 0:
        print(-1)
        exit()
    if i[0] > n or ans[i[0]-1] != -1:
        print(-1)
        exit()
    ans[i[0]-1] = i[1]

for i, val in enumerate(ans):
    if val == -1:
        ans[i] = 0

if (m == 0 and n != 1) or (ans[0] == 0 and n != 1):
    ans[0] = 1

flg = False
for i in ans:
    if i != 0:
        flg = True
if not flg:
    print(0)
    exit()

ans = map(lambda x: str(x), ans)
print("".join(ans))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

int main(){

    int n, cont = 0;
    int inicio, fim;

    scanf("%d", &n );

    for (int i = 0; i < n; i++) {
        scanf("%d%d", &inicio, &fim );
        for (int j = inicio; j <= fim; j++) {
            cont++;
        }
    }

    printf("%d\n", cont );

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll ans;
ll n;
ll a[100010];
ll b[100010];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld%lld",a+i,b+i);
	for(ll i=n-1;i>=0;i--)if((a[i]+ans)%b[i])ans+=b[i]-(a[i]+ans)%b[i];
	printf("%lld\n",ans);
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for(int x = 0; x <= k; x++){
    for(int y = 0; y <= k; y++){
      int z = s - x - y;
      if (z <= k && 0 <= z) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  string S; cin >> S;
  if(S[0] == S[S.size()-1]){
    if(S.size() % 2){
      cout << "Second" << endl;
    }else{
      cout << "First" << endl;
    }
  }else{
    if(S.size() % 2){
      cout << "First" << endl;
    }else{
      cout << "Second" << endl;
    }
  }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		sc.close();
		
		if(A.charAt(A.length()-1) == B.charAt(0) && B.charAt(B.length()-1) == C.charAt(0))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


Measured memory_bytes: 23124
fun main(args : Array<String>) {
    val (A, B) = readLine()!!.split(" ").map { it.toLong() }
    var answer = 0L
    val enoughBigDigit = 100
    (1..enoughBigDigit).forEach { digit ->
        val sumA = sum(A - 1, digit)
        val sumB = sum(B, digit)
        answer += Math.abs(sumB - sumA) * Math.pow(2.toDouble(), (digit - 1).toDouble()).toLong()
    }
    println(answer)
}

fun sum(num: Long, digit: Int) : Int {
    if (num == -1L) {
        return 0
    }

    if (digit == 1) {
        if (num.mod(4) == 1L || num.mod(4) == 2L) {
            return 1
        } else {
            return 0
        }
    }

    val freq = Math.pow(2.toDouble(), digit.toDouble()).toLong()
    val mod = num.mod(freq)
    if (mod < freq / 2) {
        return 0
    }

    if ((mod - freq / 2).mod(2) == 0L) {
        return 1
    } else {
        return 0
    }
}

Measured memory_bytes: 38048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repc(i, b, e) for(auto i = (b); i != (e); i++)

int main() {
    ll N, K;
    cin >> N >> K;
    double ans = 0;
    for(ll i = 1; i <= N; i++) {
        if(K <= i) {
            ans += 1;
        } else {
            double n = (ll)ceil(log2(K * 1.0 / i));
            ans += pow(0.5, n);
        }
    }
    cout << setprecision(15) << ans / N << endl;
    return 0;
}

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

using namespace std;
 
const long long inf = 1e18;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;
ll dp[101][100001];
vector <pair<int,int> > in;
ll solv(int ind,ll curw) {
	if (curw > k) {
		return -inf;
	}
	if (ind == n)
		return 0;
	if (dp[ind][curw] != -1)
		return dp[ind][curw];
	return dp[ind][curw] = max(in[ind].second + solv(ind+1,curw + in[ind].first),solv(ind+1,curw));
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	memset(dp,-1,sizeof dp);
	fr(i,0,n) {
		int w,v;
		cin >> w >> v;
		in.pb({w,v});
	}
	cout << solv(0,0) << endl;
	return 0;
}

Measured memory_bytes: 79232
/**
 *    author:   K.R.Surrya  
 *    created:  10/05/2020 18:33:07
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() { 
    long long n,K;
    cin >> n >> K;
    vector<int> a(n);
    vector<int> pos(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
        --a[i];
        pos[a[i]]=i;
    }
    vector<int> ret;
    set<int> visited;
    int src=0;
    visited.insert(src);
    ret.push_back(src);
    int nxt=a[src];
    while(visited.count(nxt)==0) {
        visited.insert(nxt);
        ret.push_back(nxt);
        nxt=a[nxt];
    }

    ret.push_back(a[ret.back()]);
    
    //   for(int i=0;i<ret.size();++i) {
    //     cout << ret[i] << ' ';
    // }
    // cout << '\n';
    
    int idx=ret.size()-1;
    int ele=ret.back();
    for(int i=ret.size()-2;i>=0;--i) {
        if(ret[i]==ele) {
            idx=i;
            break;
        }
    }

//    cout << idx << '\n';

     int left=idx-0+1;
     int mod=(int)ret.size()-2-idx+1;

    //  cout << "left" << left << '\n';
    //  cout << "mod" << mod << '\n';
    //  cout << "K" << K << '\n';
     if(K<=left) {
         cout << ret[K]+1 << '\n';
     } else { 
         K-=idx;
         K%=mod;
         cout << ret[idx+K]+1 << '\n';
     }
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


     auto start = chrono::high_resolution_clock::now();
     solve();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 14708
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)){
        if(s.at(1)!=s.at(2)){
            cout <<"Yes"<<endl;
        }
    else if (s.at(1)==s.at(2)){
        cout <<"No"<<endl;
    }
    }

    else {
        cout << "No" <<endl;
    }
    
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	vector<int> A(N);

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

	bool flag = true;
	REP(i, N){
		if(A[i] % 2 == 0){
			if(A[i] % 3 == 0 or A[i] % 5 == 0) continue;
			flag = false;
		}
	}
	
	if(flag) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll a,b,c,d;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b>>c>>d;
    ll ans=max(a*c,a*d);
    ans=max(ans,b*d);
    ans=max(ans,b*c);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110

int M, N;
int K, sp[MAX], con;
bool can[MAX];
vector<vector<int>> llim(MAX,vector<int>(MAX,0));
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> ulim[MAX];

bool check(int n){
	if(can[n]) return false;
	
	for(int i = 1; i <= N; i++){
		if(llim[n][i] > sp[i]) return false;
	}
	
	can[n] = true;
	con++;
	
	return true;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int s, t;
	string cond;
	
	cin>>M>>N;
	
	for(int i = 1; i <= M; i++){
		cin>>K;
		for(int j = 1; j <= K; j++){
			cin>>s>>cond>>t;
			if(cond == ">="){
				llim[i][s] = max(llim[i][s], t);
			} else if(cond == "<="){
				ulim[s].push(make_pair(t,i));
			}
			
		}
		
	}
	for(int i = 1; i <= N; i++){
		ulim[i].push(make_pair(INF,0));
	}
	
	while(true){
		// cout<<"WHIEL "<<endl;
		bool flag = false;
		
		for(int i = 1; i <= N; i++){
			while(!ulim[i].empty()){
				pair<int,int> p = ulim[i].top();
				if(can[p.second] == false){
					sp[i] = p.first;
					break;
				}
				ulim[i].pop();
			}
			// cout<<i<<" "<<sp[i]<<endl;
		}
		
		for(int i = 1; i <= M; i++){
			if(check(i)) flag = true;
		}
		
		// cout<<"con -> "<<con<<endl;
		if(con == M)break;
		
		if(!flag){
			cout<<"No"<<endl;
			return 0;
		}
	
	}
	
	cout<<"Yes"<<endl;
	
	return 0;
}


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

int main() {
  int n, c, k; cin >> n >> c >> k;
  vector<int> t(n);
  int ans = 0;
  rep(i,n) cin >> t[i];
  sort(t.begin(), t.end());
  t.push_back(0);
  int train = 0, limit = t[0] + k;
  rep(i,n) {
    if (train >= c || limit < t[i]) {
      ans++;
      train = 0;
      limit = t[i] + k;
    }
    train++;
  }
  if (train) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3940
import Control.Monad
import Text.Printf
main :: IO ()
main = do
    n <- readLn :: IO Int
    xu <- replicateM n $ (\[x,u] -> (read x :: Double, u)) . words <$> getLine
    printf "%.4f" . sum $ map (\(x,u) -> if u == "JPY" then x else x * 380000.0) xu

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

int main(){
  int n,i;
  cin >> n;
  vector<tuple<string,int,int>> a;
  for(i=1;i<=n;++i){
    string s;
    int p;
    cin >> s >> p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  for(i=0;i<n;++i){
    cout << get<2>(a[i]) <<endl;
  }
  return 0;

}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s,t;
	cin >> s >> t;
	sort(ALL(s));
	sort(ALL(t));
	reverse(ALL(t));
	Yes(s < t);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;



int main(){
    long long sum=0;
    
    long long N;
    cin>>N;
    
    for(int i=1;i<=N;++i){
        if(!(i%3==0||i%5==0)){
            sum+=i;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[111][3];
	cin>>n;
	cin>>a[1][1]>>a[1][2]>>a[2][1]>>a[2][2];
	for(int i=3;i<=n;i++){
		cin>>a[i][1]>>a[i][2];
		if(a[i][1]==a[i][2]&&a[i-1][1]==a[i-1][2]&&a[i-2][2]==a[i-2][1]){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==b)
	printf("Draw");
	else if((a>b&&b!=1)||(a==1))
	printf("Alice");
	else if((b>a&&a!=1)||(b==1))
	printf("Bob");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e6+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;
const ld EPS = 1e-4;



// ---- コーディングはここから！ ('-')7

int dp[N][4];
int n;
lli f(int u, int ma){
	if(u==n)return (ma==3);
	if(dp[u][ma]!=-1)return dp[u][ma];
	lli res = 8ll * f(u+1,ma) % MOD;
	res = (res + f(u+1,ma|1))%MOD;
	res = (res + f(u+1,ma|2))%MOD;
	dp[u][ma]=res;
	return dp[u][ma] = res;

}
void solve(){
	cin>>n;
	memset(dp, -1, sizeof dp);
	cout<<f(0,0)<<ENDL;
}
int main(){_
	//int t; cin>>t; while(t--)

	solve();
}


Measured memory_bytes: 65988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int A = sc.nextInt(),B = sc.nextInt(),C = sc.nextInt(),P = A+n*B;
			int[] c = new int[n+1];
			for(int i = 1; i <= n; i++) c[i] = sc.nextInt();
			int [][] dp = new int[n+1][P+1];
			for(int p = A; p <= P; p++) dp[0][p] = C;
			for(int i = 1; i <= n; i++){
				for(int p = A; p <= P;p++){
					dp[i][p] = dp[i-1][p];
					if(A+B<=p)dp[i][p] = Math.max(dp[i][p], dp[i-1][p-B]+c[i]);
				}
			}
			int max = 0;
			for(int p = A; p <= P; p++){
				max = Math.max(max, dp[n][p]/p);
			}
			System.out.println(max);
		}
	}
}

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

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

    int n, m;
    cin >> n >> m;

    vector<int> c(m);
    rep(i, m) cin >> c[i];
    sort(c.begin(), c.end());

    const int INF = 1001001001;
    vector<vector<int>> dp(m, vector<int>(n+1, INF));
    rep(i, n+1) dp[0][i] = i;

    rep1(i, m) rep(j, n+1){
        if(j < c[i]) dp[i][j] = dp[i-1][j];
        else dp[i][j] = min(dp[i-1][j], dp[i][j-c[i]] + 1);
    }

    cout << dp[m-1][n] << endl;

    return 0;
}


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

int main()
{
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

using namespace std;

int main (){

  int m1, m2;
  int d1, d2;
  
  cin>>m1>>d1;
  cin>>m2>>d2;
  
  if(m1 == m2) cout<<"0"<<endl;
  else cout<<"1"<<endl;
}

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

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

    for(int i=k+1; i<=n; i++){
        if(a[i]>a[i-k]){
            cout << "Yes" << endl;
        }
        else{cout << "No" << endl;}
    }
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
const int mod=1e9+7;
int n,m,i,j,k,a[605],dp[2][605][605],cnt;
int main(){
	cin>>n;
	rep(i,n){
		int x,y;
		cin>>x>>y;
		if(x==-1&&y==-1){
			cnt++;
		}else if(x!=-1&&y!=-1){
			a[x]=a[y]=2;
		}else if(x!=-1){
			a[x]=1;
		}else{
			a[y]=1;
		}
	}
	dp[1][0][0]=1;
	for(i=n+n;i;i--){
		memset(dp[i&1],0,sizeof(dp[0]));
		for(j=0;j<=n+n;j++){
			for(k=0;k<=n+n;k++){
				if(a[i]==2){
					dp[i&1][j][k]=dp[(i-1)&1][j][k];
				}
				else if(a[i]==1){
					dp[i&1][j][k]=dp[(i-1)&1][j][k+1];
					if(j){
						(dp[i&1][j][k]+=dp[(i-1)&1][j-1][k])%=mod;
					}
				}
				else if(a[i]==0){
					dp[i&1][j][k]=1ll*(j+1)*dp[(i-1)&1][j+1][k]%mod;
					if(k){
						(dp[i&1][j][k]+=dp[(i-1)&1][j][k-1])%=mod;
					}
					(dp[i&1][j][k]+=dp[(i-1)&1][j][k+1])%=mod;
				}
			}
		}
	}
	int ans=dp[1][0][0];
	while(cnt){
		ans=1ll*(cnt--)*ans%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6456
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<pair<ll,ll>> M(n);
  queue<pair<ll,ll>> q;
  vl x(n);
  rep(i,n){
    cin >> M[i].fi >> M[i].se;
  }
  sort(rng(M));
  d = d*2;
  ll ans = 0;
  ll tot = 0;
  rep(i,n){
    ll x = M[i].fi;
    ll h = M[i].se;
    while(q.size() && q.front().fi < x){
        tot-=q.front().se;
        q.pop();
    }
    h-=tot;
    if(h>0){
      int c = (h+a-1)/a;
      ans+=c;
      ll damage = a*c;
      tot+= damage;
      q.emplace(x+d,damage);
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int N;
	int H,W;
	scanf("%d %d %d",&N,&H,&W);
	printf("%d\n", (N - H + 1) * (N - W + 1));
	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

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

    list<int> l;

    int n;
    cin >> n;

    while (n--)
    {
        string cmd;
        cin >> cmd;
        if (cmd == "insert")
        {
            int k;
            cin >> k;
            l.push_front(k);
        }
        if (cmd == "delete")
        {
            int k;
            cin >> k;
            for (auto itr = l.begin(); itr != l.end(); ++itr)
            {
                if (*itr == k)
                {
                    l.erase(itr);
                    break;
                }
            }
        }
        if (cmd == "deleteFirst")
        {
            l.pop_front();
        }
        if (cmd == "deleteLast")
        {
            l.pop_back();
        }
    }
    for (int i = 0; !l.empty();i++)
    {
        if(i)
            cout << " ";
        cout << l.front();
        l.pop_front();
    }
    cout << endl;
}


Measured memory_bytes: 34420
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 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',
];
#[allow(unused)]
const ALPHA: [char; 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',
];
fn main() {
    input!(n: usize);
    for i in 1..100 {
        if n <= i * 1000 {
            println!("{}", i * 1000 - n);
            return;
        }
    }
}


Measured memory_bytes: 2164
#include <iostream>
#include <cmath>
using namespace std;
#define MAX 502

int main(){
    int n;
    int v[MAX];
    
    while(cin >> n,n){
        
        for(int i = 0 ; i <= n ; i++){
            cin >> v[i];
        }
        
        int d;
        for(int i = 0 ; i <= n ; i++){
            int tmp = v[i],nv[MAX],t = 0,cnt = 0;
            v[i] = 0;
            for(int k = 0 ; k <= n ; k++){
                if(!v[k]) continue;
                nv[t++] = v[k];
            }
            
            for(int j = 1 ; j < n ; j++){
                if(j==1){
                    d = nv[j] - nv[j-1];
                }
                if(d == nv[j]-nv[j-1]) cnt++;
            }
            if(cnt == n-1){
                cout << tmp << endl;
                break;
            }
            v[i] = tmp;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1164
h,w=map(int,input().split())
if h*w%3==0:print(0)
else:
    h1=abs((w-w//3)*(h-h//2)-min(w//3*h,(w-w//3)*(h//2)))
    h2=abs(max((w//3+1)*h,(w-w//3-1)*(h-h//2))-(w-w//3-1)*(h//2))
    w1=abs((h-h//3)*(w-w//2)-min(h//3*w,(h-h//3)*(w//2)))
    w2=abs(max((h//3+1)*w,(h-h//3-1)*(w-w//2))-(h-h//3-1)*(w//2))
    print(min(h,w,h1,h2,w1,h2))

Measured memory_bytes: 3064
def resolve():
    N, M = map(int, input().split())
    A = [list(input()) for _ in range(N)]
    B = [list(input()) for _ in range(M)]

    ans = 'No'
    for i in range(N):
        for j in range(N):
            if A[i][j] == B[0][0]:
                count = 0
                for k in range(M):
                    for l in range(M):
                        if i+k>= N or j+l>= N:
                            continue
                        if A[i+k][j+l] == B[k][l]:
                            count += 1
                    if count == M * M:
                        ans = 'Yes'
                        break
                if ans == 'Yes':
                    break
            if ans == 'Yes':
                break
        if ans == 'Yes':
            break
    
    print(ans)

resolve()


Measured memory_bytes: 3064
cards =[]
suit = ["S","H","C","D"]
n = int(input())
for i in range(n):
    s,r = input().split()
    r = int(r)
    if s == "S":cards.append(r) 
    elif s == "H":cards.append(13 + r)
    elif s == "C":cards.append(26 + r)
    elif s == "D":cards.append(39 + r)

for i in range(1,53):
    if not (i in cards):
        print(suit[(i-1)//13],(i-1)%13+1)


Measured memory_bytes: 5600
import sys
 
def ans(num):
    ans = 0
 
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d == num:
                        ans += 1
 
    return ans
 
 
def main():
    a = []
 
    for line in sys.stdin:
        a.append(int(line))
 
    for line in a:
        print(ans(line))
 
if __name__ == "__main__":
    main()


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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int k, n;
    cin >> k >> n;
    int a[n+9];
    for (int i = 0; i < n; ++i) {
    	cin >> a[i];
    }
    int mx = k - a[n-1] + a[0];
    for (int i = 0; i < n-1; ++i) {
    	mx = max(mx, a[i+1]-a[i]);
    }
    cout << k - mx;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;
 
int n,m,b[N],a[1000][1000],c,sum,ans;

int main() 
{
	
	cin >> n >> m >> c;
	for (int i = 0; i < m; ++i)
		cin >> b[i];

	for (int i = 0; i < n; ++i)
	{
		sum = 0;
		for (int j = 0; j < m; ++j)
		{
			cin >> a[i][j];
			sum += a[i][j] * b[j];
		}
		if(sum + c > 0) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 2432
N = int(input())
a = list(map(int, input().split()))

c = [0] * 9

for rate in a:
    i = rate // 400
    if i < 8:
        c[i] = 1
    else:
        c[8] += 1

c_sum = sum(c[:8])
c_min = max(c_sum, 1)
c_max = c_sum + c[8]

print(c_min, c_max)

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

int main(void)
{
	int e, min;
	int x, y, z;

	while(cin >> e && e != 0)
	{
		min = e;
		for(z = 0; z*z*z <= e; z++)
		{
			for(y = 0; y*y <= e - z*z*z; y++)
			{
				x = e - z*z*z - y*y;

				if(x+y+z < min)
					min = x + y + z;
			}
		}
		cout << min << endl;
	}
	return 0;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
	ll n,m;
	cin>>n>>m;
	Graph g(n);
	REP(i,m){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		add_edge(g,a,b,1,true,1);
	}

	queue<ll> que;
	que.push(0);
	Array d(n,-1);
	d[0]=1;
	
	while(que.size()){
		ll v=que.front();
		que.pop();
		for(auto e:g[v]){
			if(d[e.to]!=-1) continue;
			d[e.to]=v+1;
			que.push(e.to);
		}
	}
	cout<<"Yes"<<en;
	rep(i,1,n) cout<<d[i]<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 20868
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int t, a;
	cin >> t >> a;
	vi h(n);
	rep(i, n) cin >> h[i];
	int ans;
	double best = 100000.0;
	rep(i, n){
		double cur = t - (h[i] * 0.006);
		if(abs(a - cur) < best){
			best = abs(a - cur);
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner kbd = new Scanner(System.in);
    void run(){
	while(kbd.hasNext()){
	    int k = kbd.nextInt();
	    if(k==0) break;

	    int i;
	    long sum=0;
	    for(i=0; i<(k*(k-1)/2); i++)
		sum += kbd.nextInt();
	   
	    System.out.println(sum/(k-1));
	}
    }
}
	   

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

int main()
{
    vector<string> s(3);
    string m;
    for(int i=0; i<3; i++)
    {
        cin >> s[i];
    }
    cout << s[0][0] << s[1][1] << s[2][2];
}


Measured memory_bytes: 256
m,n,x,y=map(int,input().split( ))
xline=list(map(int,input().split( )))
yline=list(map(int,input().split( )))
xline.append(x)
yline.append(y)

if max(xline)<min(yline):
  print("No War")
else:
  print("War")

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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));

  for(int i=0;i<N;i++){
    cin >> C[i];
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  
  int ans = 100000000;
  
  bool ex_ans = false;
  
  for(int bit=0;bit<(1<<N);++bit){
    vector<int> D(M);
    int cost = 0;
    for(int i=0;i<N;i++){
      if(bit & (1<<i)){
        cost += C[i];
        for(int j=0;j<M;j++){
          D[j] += A[i][j];
        }
      }
    }
    bool flag = true;
    
    for(int i=0;i<M;i++){
      if(X>D[i]) flag = false;
    }
    
    if(flag){
      ex_ans = true;
      ans = min(cost,ans);
    }
  }
  
  if(ex_ans){
    cout << ans << endl;
  }
  else{
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 3596
object Main {
  def main(args: Array[String]) {
    val stdLineInput = io.StdIn.readLine().toInt

    var s = stdLineInput
    val h = java.lang.Math.floor(s / 3600).toInt
    s = s - (h * 3600)
    val m = java.lang.Math.floor(s / 60).toInt
    s = s - (m * 60)

    println(h + ":" + m + ":" + s)
  }
}

Measured memory_bytes: 43564
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(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 dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define dumparr(a,n) rep(i,n){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define FINF DBL_MAX/3
#define EPS 1e-7
#define OUT1(n1) cout<<n1<<endl
#define OUT2(n1,n2) cout<<n1<<" "<<n2<<endl
#define OUT3(n1,n2,n3) cout<<n1<<" "<<n2<<" "<<n3<<endl
#define OUT4(n1,n2,n3,n4) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<endl
#define OUT5(n1,n2,n3,n4,n5) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<endl
#define OUT6(n1,n2,n3,n4,n5,n6) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<endl
#define OUT(n, ...) OUT##n(__VA_ARGS__)

/* 構成する問題
 * 先ずは気楽に考える
 * 余計に具体例を大事にする
 *
 */

int main(){
  ll h,w,n;
  cin>>h>>w>>n;
  ll a[10001];
  rep(i,n){
    cin>>a[i];
  }

  int c[101][101];
  int color = 0;
  int next = a[0];
  rep(x,h) rep(y,w) {
    ll i = y + x*w;
    if(i==next) {
      color++;
      next = next + a[color];
    }
    c[x][(x%2==0)?y:(w-y-1)] = color+1;
  }

  rep(j,h) {
    dumparr(c[j], w);
  }
  return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X, Y):
    ans = 0


    c = Counter()
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            a = j - i
            b = abs(i-X) + 1 + abs(j-Y)
            c[min(a, b)] += 1


    for k in range(1, N):
        print(c[k])


    return ans


def main():
    N, X, Y = read_int_n()
    (slv(N, X, Y))

    # N = 2 * (10**3)
    # X = 1000
    # Y = 1500
    # (slv(N, X, Y))



if __name__ == '__main__':
    main()


Measured memory_bytes: 68952
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int N;
int a[100001];
int Min,ans;
int main(){
  
  cin >> N;
  for(int i=0;i<N;i++)cin >> a[i];
  sort(a,a+N);
  ans=a[0];
  Min=a[N-1];
  for(int i=0;i<N-1;i++){
    int z=abs((a[N-1]-a[i]) - (a[N-1]+1)/2);
    if(z<=Min) {Min=z;ans=a[i];}
  }
  printf("%d %d\n",a[N-1],ans);
  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  for (int i = 1; i <= 100; i++) {
    C = C - B;
    A = A - D;

    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    } else if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    vector<int> x(3);
    cin >> x.at(0);
    cin >> x.at(1);
    cin >> x.at(2);
    sort(all(x));
    cout << x.at(0) + x.at(1) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  while(1){
    int w, h;
    scanf("%d%d", &w, &h);
    if(w == 0 && h == 0) break;
    for(int i = 0; i < w; i++){
      for(int j = 0; j < h; j++){
        if((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) printf("#");
        else  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2600
import java.util.Scanner;

/**
 * Created by admin on 2017/05/02.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int T = scanner.nextInt();
        long total = 0;
        long timeTotal = 0;
        scanner.nextInt();
        for (int i = 0; i < N - 1; i++) {
            int temp = scanner.nextInt();
            total += Math.min(T, temp-timeTotal);
            timeTotal=temp;
        }
        total += T;
        System.out.println(total);
    }
}


Measured memory_bytes: 62884