akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n,ma,mb;
int a[100],b[100],c[100];
int dp[101][1000][1000]={0};

int mincost(int p,int q){
  rep(k,n+1){
    rep(i,p+1){
      rep(j,q+1){
        dp[k][i][j] = 100000000;
      }
    }
  }
  dp[0][0][0]=0;
  rep(k,n){
    rep(i,p+1){
      rep(j,q+1){
        if(i>=a[k]&&j>=b[k]){
          dp[k+1][i][j]=min(dp[k][i][j],dp[k][i-a[k]][j-b[k]]+c[k]);
        }else{
          dp[k+1][i][j]=dp[k][i][j];
        }
      }
    }
  }
  int ans=100000000;
  Rep(i,1,400/max(ma,mb)+1){
    ans=min(ans,dp[n][ma*i][mb*i]);
  }
  return ans;
}

int main(){
  cin >> n >> ma >> mb;
  rep(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }
  int ans=mincost(401,401);
  if(ans==100000000){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  
  return 0;
}
  
    
  
    


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int a, b;

	cin >> a >> b;

	if (a % 3 == 0) Out("Possible");
	else if (b % 3 == 0) Out("Possible");
	else if ((a + b) % 3 == 0) Out("Possible");
	else Out("Impossible");
	
	return 0;
}


Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)

dp = Array.new(N, 0)

1.upto(N - 1) do |i|
  min_cost = Float::INFINITY
  1.upto(K) do |k|
    break if k > i
    cost = dp[i - k] + (H[i] - H[i - k]).abs
    min_cost = cost if min_cost > cost
  end
  dp[i] = min_cost
end

puts dp[N - 1]


Measured memory_bytes: 8836
S = list(map(int, list(input())))
K = int(input())
result = 0
if len(S) < K:
    for s in S:
        if s != 1:
            result = s
            print(s)
            exit(0)
else:
    for s in S[:K]:
        if s != 1:
            result = s
            print(s)
            exit(0)
print(1)

Measured memory_bytes: 3060
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector> //*max_element(all(変数))で最大値を獲得
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
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; }

int main(){
  int x; cin >> x;
  rep0(i,x+1){
    if(x <= i*(i+1)/2){
      cout << i;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
int a[MAXN],n,cnt,k;
int read(){
    int f=1,x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int main(){
    cin>>n>>k;
    int kx=1+(k-1)*2;
    if(n>=kx) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    int x;
    cin >> x;
    cout << 10 - x / 200 << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // //
int q, n;

void solve(){

    return;
}


int main(){
    int64 x;
    int64 rs = 0;
    cin >> x;
    int64 now = 100;
    while (now < x){
        now += now / 100;
        rs++;
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef vector<vector<pair<int,int>>> vp;
void color(vp &v,int s[],int i){
   rep(j,v[i].size()){
      int f=v[i][j].first;
      if(s[f]==2) {
         s[f]=v[i][j].second? !s[i]:s[i];
         color(v,s,f); 
      }
   } 
}
int main() {
  int n,a,b,c;
  cin >> n;
  int s[n];
  fill(s,s+n,2);
  s[0]=1;
  vp v(n);
  rep(i,n-1){
     cin>>a>>b>>c;
     a--;b--;c&=1;
     v[b].push_back(make_pair(a,c));
     v[a].push_back(make_pair(b,c));
  }
  color(v,s,0);
  rep(i,n)
    cout<<s[i]<<endl;
  return 0;
}


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

int friend[502][502], ans[502];

void dfs(int x,int y){
  int i;
  ans[x] = 1;
  if(y == 0)return ;
  for(i = 1;i < 501;i++){
    if(friend[x][i]){
      dfs(i, y - 1);
    }
  }
}

int main(){
  while(1){
    int n, m, res = 0, i, j;
    scanf("%d%d",&n ,&m);
    if(n == 0 && m == 0)return 0;
    memset(friend, 0, sizeof(friend));
    memset(ans, 0, sizeof(ans));
    for(i = 0;i < m;i++){
      int a, b;
      scanf("%d%d", &a, &b);
      friend[a][b] = 1;
      friend[b][a] = 1;
    }
    dfs(1, 2);
    for(i = 2;i <= n;i++){
      res += ans[i];
    }
    printf("%d\n", res);
  }
}

Measured memory_bytes: 1592
while True:
    line = input()
    data = line.split()
    h = int(data[0])
    w = int(data[1])
    if h == 0 and w == 0:
        break

    for i in range(h):   
        for j in range(w):
            if i%2 == 0:
                if j%2 == 0: 
                    print("#", end="")
                elif j%2 == 1:
                    print(".", end="")
            elif i%2 == 1:
                if j%2 == 0:
                    print(".", end="")
                elif j%2 == 1:
                    print("#", end="")
        print("")
    print("")







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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int sum = a + b + c;
    int mi = min(a, min(b, c));
    int ma = max(a, max(b, c));
    cout << mi << " " << sum - mi - ma << " " << ma << endl;
    return 0;
}


Measured memory_bytes: 3096
N=int(input())
a=list(map(int,input().split()))
cnt=0
ans=0
tmp=10**10
for i in range(N):
  if a[i]<0:
    cnt+=1
  v=abs(a[i])
  ans+=v
  tmp=min(tmp,v)
if cnt%2==0 or 0 in a:
  print(ans)
else:
  print(ans-2*tmp)

Measured memory_bytes: 14412
#include <iostream>
#include <vector>
#include <utility>

#define ll long long

using namespace std;

void dfs(int p, int d, ll length, vector<vector<pair<int, ll>>> &tree, vector<int> &color){
	color[d]=length%2;
	
	for(const auto &e: tree[d]){ 
		if(p!=e.first)dfs(d, e.first, length+e.second, tree, color);
	}
}

int main(){
	int n;
	cin >> n;
	vector<vector<pair<int, ll>>> tree(n);
	vector<int> color(n,-1);
	
	ll u, v, w;
	for(int i=0;i<n-1;i++){
		cin >> u >> v >> w;
		tree[u-1].emplace_back(v-1,w);
		tree[v-1].emplace_back(u-1,w);
	}
	
	dfs(-1, 0, 0, tree, color);
	
	for(int i=0;i<n;i++)cout << color[i] << '\n';
	return 0;
}

Measured memory_bytes: 11264
N=int(input())
alp=[]

mozi=[chr(i) for i in range(97, 97+26)]


while(True):
  K=-1
  K = int(N%26)
  alp.insert(0,mozi[K-1]) 
  if(N<=26):break
  if(K==0):N =(N-26)/26
  else:N = (N-K)/26
    
print(''.join(alp))

Measured memory_bytes: 9132
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int a[3];
    rep(i, 3)cin >> a[i];
    sort(a, a + 3);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7)puts("YES");
    else puts("NO");

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 764
//トポロジカルソート,tarjan
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

struct Edge {
    ll st,tr;
    Edge(ll s, ll t)
        : st(s), tr(t)
    {}
};
struct Node{
    vector<Edge> edges;
};
using Graph = vector<Node>;

//各nodeをdfs
vector<ll> tsort_tarjan(Graph& g){
    auto num = g.size();
    enum class State { NEW, ACTIVE, FINISHED };
    vector<State> state(num, State::NEW); 
    vector<ll> res(num);
    function<bool(int)> dfs = [&](ll v){
        state[v]=State::ACTIVE;
        for(const auto& e : g[v].edges){
            auto w = e.tr; //接続するnodeをdfsしていく
            if (state[w] == State::ACTIVE) return false;
            else if (state[w] == State::NEW) if (!dfs(w)) return false;
        }
        state[v]=State::FINISHED;
        res.push_back(v);
        //ここで処理すると逆順に処理できる
        return true;
    };
    for (ll n=0;n<num;++n) {
        if(state[n]==State::NEW && !dfs(n)) return {}; //空を返す
    }
    std::reverse(res.begin(),res.end());
    return res;
}

int main() {
    //aoj_grl_4_b
    ll vn, en; cin>>vn>>en; //頂点数,辺の数
    Graph graph(vn);
    REP(i,en){
        ll s,t; cin>>s>>t;
        graph.at(s).edges.emplace_back(s,t);
    }

    auto ord = tsort_tarjan(graph);
    for(const auto& o:ord){
        cout<<o<<endl;
    }

    return 0;
}


Measured memory_bytes: 4504
#include<bits/stdc++.h> 
using namespace std; 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = a; i <b; i++)
#define forn(i,a,b) for (int i = a; i >b; i--)
#define mod 1000000007
#define MAX 50
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


long long int fact(long long int n)
{
  if(n==0 || n==1)
  return 1;
  else
  return (n*fact(n-1)%mod)%mod;
}

int prime(long long int n)
{
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      return 0;
    }
  }
  return 1;
}

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

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

int check_palin(string s)
{
  string str=s;
  reverse(str.begin(),str.end());
  if(str==s)
  return 1;
  else 
  return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
            int k,n,z=0;
string s;
            cin>>s;
k=0,z=0;
int f=0;
n=s.size();

for(int i=0;i<n;i++)
{
  if(f==0)
  {
    if(s[i]=='1')
    {
      k++;
    }
    f=1;
  }
  else
  {
    if(s[i]=='0')
    k++;
    f=0;
  }
}
f=1;
for(int i=0;i<n;i++)
{
  if(f==0)
  {
    if(s[i]=='1')
    {
      z++;
    }
    f=1;
  }
  else
  {
    if(s[i]=='0')
    z++;
    f=0;
  }
}
 cout<<min(z,k);
            cout<<"\n";
           
            
            
            
return 0;
}
            
            
            
            

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
typedef struct aaaaa{
  int x,y,t;
}Grid;
using namespace std;
int main(){
  int h,w,n;cin>>h>>w>>n;
  vector<pair<int,int> > pii;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    if(a>=b)
      pii.pb(mp(a,b));
  }
  sort(ALL(pii));
  int po=0;
  for(int i=0;i<pii.size();i++){
    if(pii[i].S<pii[i].F-po){
      cout<<pii[i].F-1<<endl;
      return 0;
    }else if(pii[i].S==pii[i].F-po){
      po++;
    }
  }
  cout<<h<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    ll N; cin >> N;
    ll a, b;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0) {
            a = i;
            b = N / i;
        }
    }
    cout << (a-1) + (b - 1) << endl;
}



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

using namespace std;

int main(){

    int N;
    cin>> N;
    vector<vector<int> > s(N, vector<int>(3));
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            cin>> s[i][j];
        }
    }

    vector<vector<int> > t(3, vector<int>(N));
    for(int i=0; i<3; i++){
        for(int j=0; j<N; j++){
            t[i][j]=s[j][i];
        }
    }

    vector<int> score(N, 0);
    for(int i=0; i<3; i++){
        for(int j=0; j<N; j++){
            if(count(t[i].begin(), t[i].end(), t[i][j])<2){
                score[j]+=t[i][j];
            }
        }
    }
    for(int i=0; i<N; i++){
        cout<< score[i]<< endl;
    }

    return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;



int log10(int x){
    int ret = -1;
    while(x>0){
        ret++;
        x/=10;
    }
    return ret;
}

int pow(int x, int p){
    int ret = 1;
    while(p>0) {
        if(p&1) ret*=x;
        x=x*x;
        p>>=1;
    }
    return ret;
}

int main(){
    int n;
    cin>>n;
    vector<vector<int> > dp(10, vector<int>(10, 0));

    for(int i = 1; i<=n;i++){
        int ld = i%10;
        int lg = log10(i);
        int fd = i/pow(10, lg);
        dp[fd][ld]++;
    }
    long long ans = 0;
    for(int i = 1; i<=9; i++){
        for (int j = 1; j <= 9; j++) {
            ans += (dp[i][j] * dp[j][i]);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n; cin >> n;
  int total = 0;
  int w[n];
  REP(i,n){
    cin >> w[i];
    total += w[i];
  }
  int s1 = 0, s2 = total;
  int ans = total;
  REP(i,n){
    s1 += w[i];
    s2 -= w[i];
    ans = min(ans,abs(s1-s2));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.Bits
import Data.Array
main = do
  n <- read  <$> getLine
  x' <- getLine
  let x = listArray (0,n) x'
      p = length $ filter (=='1') x'
      r0 = sum [if x ! i == '1' then modPow 2 (n-1-i) (p+1) else 0| i <- [0..n-1]]
      r1 = if p /= 1 
        then sum [if x ! i == '1' then modPow 2 (n-1-i) (p-1) else 0| i <- [0..n-1]]
        else undefined 
      ans = fmap (print . f) (solve n x r0 r1 p)
  sequence ans

solve :: Int -> Array Int Char -> Int -> Int -> Int -> [Int]
solve n x r0 r1 p =
  [if x ! i == '1' && p /= 1 then 
    (r1 - modPow 2 (n-1-i) (p-1)) `mod` (p-1) 
  else if x ! i == '1' && p == 1 then -1
    else (r0 + modPow 2 (n-1-i) (p+1)) `mod` (p+1) | i <- [0..(n-1)]]

modPow :: Int -> Int -> Int -> Int
modPow x n p -- x^n mod p
  | n == 0 = 1 `mod` p
  | even n = (t * t) `mod` p
  | odd n = (x * modPow x (n-1) p) `mod` p
    where t = modPow x (n `div` 2) p

f :: Int -> Int
f n
  | n == -1 = 0
  | n == 0 = 1
  | otherwise = 1 + f n'
  where n' = n `mod` popCount n



Measured memory_bytes: 22620
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String A = "";
		String B = "";
		for(int i=0;i<b;i++){
			A = A + String.valueOf(a);
		}
		for(int i=0;i<a;i++){
			B = B + String.valueOf(b);
		}
		if(A.compareTo(B)<=0){
			System.out.println(A);
		}else{
			System.out.println(B);
		}

	}
}


Measured memory_bytes: 20820
C = input()
s = ['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']

a = s.index(C)
print(s[a+1])


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
int h,w,i,j;
char a[100][101];
scanf("%d%d",&h,&w);
for(i=0;i<h;i++)scanf("%s",a[i]);
for(i=-1;i<=h;i++){
if(i==-1||i==h){
for(j=0;j<w+2;j++)printf("#");
puts("");
}
else{
printf("#%s#\n",a[i]);
}
}
return 0;
}

Measured memory_bytes: 128
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    if a<=b+c:
        print(b+c-a)
    else:
        print(0)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import java.util.Map.Entry;
import java.util.*;

import org.w3c.dom.css.Counter;

public class Main {
//public class App {

    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
     HashSet<String> map = new HashSet<String>();
     final int ugeuge= Integer.parseInt(s.next());
      String tareget ="";

    for(int i=0;i < ugeuge ; i++){
        //Scanner hoge = new Scanner(System.in);
        //final String tareget = s.next();
        tareget= s.next();

        if(!map.contains(tareget)){
            map.add(tareget);
        }
    }
            System.out.println(map.size());
    }
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll n, m, k;
	cin >> n >> m >> k; // k分読む
	vector<ll> a(n);
	rep(i, n)cin>>a[i];
	vector<ll> b(m);
	rep(i, m)cin>>b[i];

	vector<ll> A(n+1);
	A[0] = 0;
	rep(i,n){
		A[i+1] = A[i] + a[i];
	}
	vector<ll> B(m+1);
	B[0] = 0;
	rep(i,m){
		B[i+1] = B[i] + b[i];
	}
	ll ans = 0;
	rep(i,n+1){
		// A を i 冊読む
		// この時、Aのために係る時間A[i]分
		ll left = k - A[i];
		if(left < 0) continue;

		ll it = lower_bound(B.begin(),B.end(),left+1) - B.begin();
		ll now = i + it-1;
		chmax(ans,now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 9584
#include <iostream>
#include <cstdint>
#include <algorithm>

using i64 = std::int64_t;

int main() {
	i64 n, a, b;
	std::cin >> n >> a >> b;

	std::cout << n / (a + b) * a + std::min(a, n % (a + b)) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  ll a, b, x;
  cin >> a >> b >> x;

  cout << (a == 0 ? b / x + 1 : b / x - (a - 1) / x) << endl;



  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int H1,M1,H2,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int ans=(H2-H1)*60+(M2-M1);
    ans-=K;
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<bitset>
#include<string>
using namespace std;
#include <numeric> 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using pi=pair<long long,long long>;
#define pii 3.1415926536
#define binary
#define mod 1000000007
typedef long long ll;
typedef long double ld;
bool sortbysec(const pair<long long,long long> &a, 
              const pair<long long,long long> &b) 
{ 
    return (a.first < b.first); 
}
bool compare(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll>&b)
{
    if(a.first.first==b.first.first)return (a.first.second<b.first.second);
    return (a.first.first < b.first.first); 
}
 int lcm(int a, int b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  
 int Kad(ll dp[],ll n)
{
  ll curr_max=0,maxx=INT_MIN;
  for(int i=0;i<n;i++)
  {
    curr_max=curr_max+dp[i];
    if(curr_max>maxx)
      maxx=curr_max;

    if(curr_max<0)
      curr_max=0;
   
  }

  return maxx;
}

/*void dfs(int u)
{
    vis[u]=true;
    //cout<<u<<" ";
    std::vector<ll> ::iterator i;
     for (i = g[u].begin(); i != g[u].end(); ++i) 
        if (!vis[*i]) 
            dfs(*i); 
    for(int i=1;i<g[u].size();i++)
    {
        if(!vis[g[u][i]])
        {
            dfs(i);
        }
    }
}*/
ll solve(std::vector<ll> &v,int sum)
{
  unordered_map<ll,ll> m;
  ll curr=0;
  ll ans=0;
  for(ll i=0;i<v.size();i++)
  {
    curr+=v[i];
    if(curr==sum)
      ans++;
    if(m.find(curr)!=m.end())
    {
      ans+=m[curr];
    }
    m[curr]++;
  }
  return ans;
}
int main()
{
 #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
  #endif  
 
  IOS;
  string str;
  cin>>str;
  ll ans=0;
  ll maxx=0;
  for(int i=0;i<str.size();i++)
  {
    if(str[i]=='R')
      ans++;
    else
      ans=0;
    maxx=max(ans,maxx);
  }
  cout<<maxx<<endl;

}

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

#define rep(i,f,n) for(int i = (f); i < (int)(n); i++)


int main(){


    int N,D; cin >> N >> D;
    int record[N][D];
    rep(i,0,N){
        rep(j,0,D){
            cin >> record[i][j];
        }
    }

    int ans=0;

    for(int i=0; i < N; i++){
    for(int j=i+1; j < N; j++){
        int euc=0;
        for(int k=0; k < D; k++){
            int point = record[i][k]-record[j][k];
            euc += point*point; 
        }
        for(int k=0; k <= euc; ++k){
            if(k*k==euc){
                ans++;
            }
        }
    }
    }

    cout << ans << endl;

}



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

int H, W;

char grid[2001][2001];
int C[2001][2001];

int main() {
  cin >> H >> W;

  rep(i, H) rep(j, W) cin >> grid[i][j];

  rep(i, H) {
    int l = 1, r = 1;
    rep(j, W) {
      if (grid[i][j] == '#') l = 0;
      C[i][j] += l++;
      if (grid[i][W - 1 - j] == '#') r = 0;
      C[i][W - 1 - j] += r++;
    }
  }

  rep(j, W) {
    int u = 1, d = 1;
    rep(i, H) {
      if (grid[i][j] == '#') u = 0;
      C[i][j] += u++;
      if (grid[H - 1 - i][j] == '#') d = 0;
      C[H - 1 - i][j] += d++;
    }
  }

  int ans = 0;
  rep(i, H) rep(j, W) {
    if (grid[i][j] == '#') continue;
    ans = max(ans, C[i][j] - 3);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19840
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue<int> que;
    int tmp;
    rep(i,n){
        cin >> tmp;
        que.push(tmp);
    }
    rep(i,m){
        tmp = que.top();
        que.pop();
        que.push(tmp/2);
    }

    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,s,k;
    cin>>n;
    ll a[n];
    ll dp[n][n];
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    }
    for(i=n-1;i>=0;i--)
    {
    	for(j=i;j<n;j++)
    	{
    		if(i==j)
    		{
    			dp[i][j]=0;
    		}
    		else
    		{
    			s=0;
    			for(k=i;k<=j;k++)
    			{
    				s+=a[k];
    			}
    			dp[i][j]=inf;
    			for(k=i;k<j;k++)
    			{
    				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
    			}
    		}
    	}
    }
    cout<<dp[0][n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 4880
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> x, std::vector<long long> l){
    vector<pair<i64,i64>> v;
    for(i64 i = 0; i < n; ++i){
        v.emplace_back(x[i] - l[i], l[i] + x[i]);
    }
    sort(v.begin(), v.end(), [](auto x, auto y){return x.second < y.second;});
    i64 r = -INF;
    i64 cnt = 0;
    for(i64 i = 0; i < n; ++i){
        if(v[i].first < r)
            continue;
        ++cnt;
        chmax(r, v[i].second);
    }
    cout << cnt << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(X), std::move(L));
    return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

vector< pair<int, int> > points;

int length(const int x, const int y, const int R, const int C) {
  if (y == 0) {
    return x;
  }
  else if (x == R) {
    return R+y;
  }
  else if (y == C) {
    return 2*R+C-x;
  }
  else {
    return 2*R+2*C-y;
  }
}

void solve() {
  sort(points.begin(), points.end());
  vector<int> stack;
  for (pair<int, int> point : points) {
    if (stack.size() == 0 || stack.back() != point.second) {
      stack.push_back(point.second);
    }
    else {
      stack.pop_back();
    }
    //cout << "stack: ";
    // for (int x : stack) {
    //   cout << x << " ";
    // }
    // cout << endl;
  }
  if (stack.size() == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

int main() {
  int N, R, C;
  cin >> R >> C >> N;
  int x1, y1, x2, y2;
  for (int i = 0; i < N; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if ((x1 == 0 || y1 == 0 || x1 == R || y1 == C) &&
	(x2 == 0 || y2 == 0 || x2 == R || y2 == C)) {
      pair<int, int> p1, p2;
      p1 = make_pair(length(x1, y1, R, C), i);
      p2 = make_pair(length(x2, y2, R, C), i);
      points.push_back(p1);
      points.push_back(p2);
      // cout << "point " << i << ": " << p1.first << endl;
      // cout << "point " << i << ": " << p2.first << endl;
    }
  }
  solve();
}

Measured memory_bytes: 4076
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll N, M;
	cin >> N >> M;

	vector<P> AB(N, P(0, 0));
	for (ll i = 0; i < N; ++i)
	{
		cin >> AB[i].first >> AB[i].second;
	}

	sort(AB.begin(), AB.end());
	//reverse(AB.begin(), AB.end());

	ll pay = 0;
	ll m = 0;
	for (ll i = 0; i < N; ++i)
	{
		while (true)
		{
			if (AB[i].second > 0)
			{
				pay += AB[i].first;
				m++;
				AB[i].second--;
			}
			else
			{
				break;
			}

			if (m >= M)
			{
				break;
			}
		}

		if (m >= M)
		{
			break;
		}
	}

	cout << pay << endl;

	//system("pause");
}

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

#define ll long long
#define endl "\n"
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

using namespace std;

const ll mod = 1e9 + 7;

int main() {
    ios
    ll a, b, c;
    cin >> a >> b >> c;
    if (a <= b * c) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<vector<ll>>a(100010);
ll f[100010][2];
void dep(ll now,ll p,ll cnt,ll ban){
	f[now][ban]=cnt;
	if(a[now].size()==1&&a[now][0]==p){
		return;
	}
	for(int i=0;i<a[now].size();i++){
		ll next=a[now][i];
		if(next==p){
			continue;
		}
		dep(next,now,cnt+1,ban);
	}
}

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	dep(0,-1,1,0);
	dep(n-1,-1,1,1);
	ll ansf=0,anss=0;
	for(int i=0;i<n;i++){
		//cout << f[i][0]<< " "<<f[i][1]<<endl;
		if(f[i][0]<=f[i][1]){
			ansf++;
		}
		else{
			anss++;
		}
	}
	cout << (ansf>anss?" Fennec":"Snuke");
	// your code goes here
	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <queue>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

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

    vector<vector<int> > dp(n);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        dp[a].push_back(b);
        dp[b].push_back(a);
    }

    vector<int> dist(n, -1);
    queue<int> q;
    vector<int> pre(n, -1);

    dist[0] = 0;
    q.push(0);

    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto i : dp[v]) {
            if (dist[i] != -1) continue ;
            dist[i] = dist[v] + 1;
            q.push(i);
            pre[i] = v;
        }
    }

    cout << "Yes" << '\n';
    REP(i, n) {
        if (i == 0) continue ;
        cout << pre[i] + 1 << '\n';
    }
    return 0;
}


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

long long n, m, q;
long long s[100005] = {0};
long long l[100005] = {0};
long long ans[100005] = {0};
long long cnt[100005] = {0};
vector<long long> dis;

void solve();

int main() {
  cin >> n >> m;
  for(long long i = 0; i < m; ++i) cin >> s[i];
  cin >> q;
  for(long long i = 0; i < q; ++i) cin >> l[i];
  solve();
  for(long long i = 0; i < q; ++i) {
    int nowans =
        lower_bound(ans + 1, ans + n + 1, l[i] - s[0] + 1,
                    greater<long long>()) -
        ans;
    if(ans[nowans] + s[0] - 1 > l[i]) nowans = -1;
    cout << nowans << endl;
  }
  return 0;
}

void solve() {
  for(int i = 1; i < m; ++i) {
    dis.push_back(s[i] - s[i - 1] - 1);
    ans[1] += dis[i - 1];
  }
  dis.push_back(n - s[m - 1]);
  ans[1] += n - s[m - 1];
  sort(dis.begin(), dis.end());
  for(int i = 1; i <= n; ++i) {
    auto it = lower_bound(dis.begin(), dis.end(), i - 1);
    cnt[i] = dis.end() - it;
  }
  for(int i = 2; i <= n; ++i) ans[i] = ans[i - 1] - cnt[i];
}


Measured memory_bytes: 6820
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


signed main() {
    double n, k;
    cin >> n >> k;
    double result = (n - 1) / (k - 1);
    result = ceil(result);
    cout << result << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define S 1000001
#define M 1000000007
#define newline cout<<"\n";
#define error  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
lli arr[S];
int main()
{
lli n,k,i,sum=0;
cin>>n>>k;
for(i=0;i<n;i++)
{
    cin>>arr[i];
}
sort(arr,arr+n);
if(k>=n)
{
    cout<<"0";
}
else
{
    for(i=0;i<n-k;i++)
    {
        sum=sum+arr[i];
    }
    cout<<sum;
}

}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
int main()
{
    int n, flg = 0;
    scanf("%d", &n);
    char s[n];
    scanf("%s", s);
    if (n % 2 == 1)
    {
        printf("No\n");
    }
    else
    {
        for (int i = 0; i < n / 2; i++)
        {
            if (s[i] != s[n / 2 + i])
            {
                flg = 1;
                break;
            }
        }
        if (flg == 0)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}

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

int main()
{
  int n, player[10];
  string str;

  while (cin >> n, n){
    int m = 0, f = 0;
    for (int i = 0; i < n; i++){
      player[i] = 0;
    }
    cin >> str;
    for (int i = 0; i < 100; i++){
      player[m]++;
      if (str[i] == 'S'){
        f += player[m];
        player[m] = 0;
      }
      else if (str[i] == 'L'){
        player[m] += f;
        f = 0;
      }
      m++;
      m %= n;
    }
    sort(player, player + n);
    cout << player[0];
    for (int i = 1; i < n; i++){
      cout << ' ' << player[i];
    }
    cout << ' ' << f << endl;
  }
  return (0);
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;
string s;
// LONG LONG CASE
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3])cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int m;
    cin>>m;
    vector<int> v(m+1);
    for(int i=1;i<=m;i++) cin>>v[i];
    vector<int> b(m+1,0);
    //for(int i=1;i<=m;i++) cout<<v[i]<<" ";
    //cout<<endl;
    int cnt=0;
    for(int i = m;i>0;i--){
        //cout<<endl;
        //cout<<i<<"start"<<endl;
        int sum = 0;
        for(int j=2*i;j<=m;j+=i){
            if(j>m) break;
            if(b[j]==1) sum+= 1;
        }
        if(v[i]==0){
            //cout<<"0"<<endl;
            if(sum%2==0) b[i]=0;
            else{
                b[i]=1;
                cnt++;
            }
        }
        else{
            //cout<<"1"<<endl;
            if(sum%2==0){
                b[i]=1;
                cnt++;
            }
            else b[i]=0;
        }
        //cout<<sum<<endl;
        //cout<<"v["<<i<<"]"<<"="<<v[i]<<endl;
    }
    
    if(cnt==0) cout<<0<<endl;
    else{
        cout<<cnt<<endl;
        for(int i=1;i<=m;i++){
            if(b[i]==1) cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int N, B[101];

int main() {
    cin >> N;
    REP (i, N - 1) {
        cin >> B[i];
    }
    int s = B[0];
    REP (i, N - 2) {
        s += (B[i] < B[i + 1]) ? B[i] : B[i + 1];
    }
    s += B[N - 2];
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
int main() {
  cin >> n >> m;
  lli ans;
  if (2*n >= m) ans = m/2;
  else {
    lli r = m - 2*n;
    ans = n + r/4;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func pow(a, n int) int {
	ans := 1
	for i := 0; i < n; i++ {
		ans *= a
	}
	return ans
}

func main() {
	n, m, x := nextInt(), nextInt(), nextInt()
	a := make([][]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = nextInt()
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			a[i][j] = nextInt()
		}
	}

	min := math.MaxInt64
	for k := 1; k <= pow(2, n); k++ {
		cost := 0
		points := make([]int, m)
		cnt := make(map[int]bool)
		for i := 0; i < n; i++ {
			mask := 1 << uint(i)
			if k&mask != 0 {
				cost += c[i]
				for j := range points {
					points[j] += a[i][j]
					if !cnt[j] && points[j] >= x {
						cnt[j] = true
						if len(cnt) == m && cost < min {
							min = cost
						}
					}
				}
			}
		}
	}
	if min == math.MaxInt64 {
		fmt.Println(-1)
	} else {
		fmt.Println(min)
	}
}


Measured memory_bytes: 3004
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y int
	fmt.Scan(&w, &h, &x, &y)
	fmt.Println(float64(w*h) / 2)
	if x*2 == w && y*2 == h {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512