akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
//#define P pair<ull,ull>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;
 
inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 505, M = N * N;
struct node{ 
	int x, d, id; 
	node(int a=0,int b=0,int c=0) { x = a, d = b, id = c; }
	bool operator < (const node&rhs) const { return x > rhs.x; }
} a;
priority_queue<node> q;
int num[M], v[N], ans[M];
inline void out() { puts("No"), exit(0); }

int main() {
	int n = read();
	rep(i,1,n) { 
		v[i] = read();
		ans[v[i]] = i;
		num[i] = i - 1;
		if( i - 1 ) q.push(node(v[i],i-1,i));
	}
	rep(i,1,n*n) { 
		if( ans[i] ) { 
			if( num[ans[i]] ) out();
			if( n - ans[i] ) q.push(node(n*n,n-ans[i],ans[i]));
		} else { 
			if( q.empty() ) out();
			a = q.top(), q.pop();
			if( a.x >= i ) ans[i] = a.id;
			else out();
			a.d--, num[ans[i]]--;
			if( a.d ) q.push(a);
		}
	} 
	puts("Yes");
	rep(i,1,n*n) printf("%d ", ans[i]);
	puts("");
	return 0; 
}

Measured memory_bytes: 2304
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n, m;

int main() {
	cin >> n >> m;
	cout << n*m << endl;
}


Measured memory_bytes: 3084
#include<stdio.h>

int main(void)
{
  int i,j,count=1;
  char n[10000];
  long int b[10000];


  for(i=0;;i++)
    {
      b[count]=0;
      scanf("%c",&n[i]);
      if(n[i]=='0')
	break;
      else
	while(n[i]!='\n')
	  {   
	    b[count]=b[count]+(n[i]-'0');
	    i++;
	    scanf("%c",&n[i]);
	  }
      count++;
    }
  
  for(j=1;j<count;j++)
    printf("%ld\n",b[j]);
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	ll A, B, C; cin >> A >> B >> C;
	int K; cin >> K;
	for(int i = 0; i < K; i++) {
		if(A >= B) B *= 2;
		else if(B >= C) C *= 2;
	}
	if(A < B && B < C) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

const int MAXN = 2e3+2;
int ans[MAXN];

int main() {
    int n,x,y;
    scanf("%d%d%d", &n, &x, &y);

    //遍历
    for (int i=1; i<=n; i++) {
        for (int j=i+1; j<=n; j++) {
            int a=j-i;
            int b=std::abs(x-i)+std::abs(y-j)+1;
            int c=std::min(a,b);
            ans[c]++;
        }
    }

    for (int i=1; i<n; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0337
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = new int[] { 1867, 1911, 1925, 1988 };
            if (x[0] == 0)
            {
                if (x[1] <= 1911)
                {
                    Console.WriteLine("M" + (x[1] - 1867));
                }
                else if (x[1] <= 1925)
                {
                    Console.WriteLine("T" + (x[1] - 1911));
                }
                else if (x[1] <= 1988)
                {
                    Console.WriteLine("S" + (x[1] - 1925));
                }
                else
                {
                    Console.WriteLine("H" + (x[1] - 1988));
                }
            }
            for (int i = 1; i < 5; i++)
            {
                if (x[0] == i) Console.WriteLine(x[1] + a[i - 1]);
            }
        }
    }
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    cout << (n-2)*180 << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
l = [0]
l.extend(h)
l.append(0)
n += 2
ans = 0
while sum(l) != 0:
    for i in range(1, n):
        if (l[i] == 0) and (l[i-1] != 0):
            ans += 1
    for i in range(1, n):
        if l[i] != 0:
            l[i] -= 1
print(ans)


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

int main()
{
    int n, x;
    while (cin >> n >> x) {
        if (n == 0 && x == 0) break;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                for (int k = j+1; k <= n; k++) {
                    if (i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int ans = 0;
  rep(i, n) for (int j = i+1; j<n; ++j) {
    ans += d[i]*d[j];
  }
  cout << ans << endl;
  return 0;
  }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

//mapの使い方
#include <map>

ll n,x,y;


vi tp(224);
vi ama(224);
/*

void ruiseki(vi &ina,vi &vl,vi &vr){
  for(ll i=0;i<224;i++){
    tp[i]=ina[i]*ama[(i+offset)%224]%2019;
  }
  vl[0]=tp[0];
  for(ll i=1;i<224;i++){
    vl[i]=(vl[i-1]+tp[i])%2019;
  }
  vr[223]=tp[223];
  for(ll i=222;i>=0;i--){
    vr[i]=(vr[i+1]+tp[i])%2019;
  }

}
*/

int main(){
  ll ans=0;
  string s;
  cin>>s;
  n=s.length();
  vi ama(224);
  ama[0]=1;
  for(ll i=1;i<224;i++){
    ama[i]=ama[i-1]*10%2019;
  }
  vi si(n);
  for(ll i=0;i<n;i++){
    si[n-1-i]=s[i]-48;
  }
  
    /*
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    */
  vi nums2(2019);

  for(ll k=0;k<224;k++){

      //map<long long, long long> nums;
      vi nums(2019);
      ll gk=0;
      nums[0]=1;
      ll offset=0;
      for(ll i=0;i+k<n;i++){
        gk+=ama[i%224]*si[i+k]%2019;
        gk%=2019;
        //何個あるか
        ans+=nums[(2019-gk)%2019];

        if (i%224==223){
          //初期化
          for(ll j=0;j<2019;j++){
            nums2[(j+gk)%2019]=nums[j];
          }
          for(ll j=0;j<2019;j++){
            nums[j]=nums2[j];
          }
          
          //ここでnums[0]の数値がnums[0+gk]に移動する操作をする
          //してないので本当のnums[i]は今はnums[i-gk]にある
          offset+=gk;
          offset%=2019;
          //nums[(2019-gk)%2019]++;//本当はnums[0]++をしたい
          nums[0]++;
          gk=0;
        }
      }
  }

  //offset=n%224;//これを224回やる



  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 5188
import java.util.*

fun <T> calcPermutationList(sortedList: List<T>): List<List<T>> {
    val permutationList = mutableListOf<List<T>>()
    val queue = ArrayDeque<List<T>>().apply { addFirst(listOf()) }
    while (queue.isNotEmpty()) {
        val p = queue.removeFirst()

        if (p.size == sortedList.size) {
            permutationList += p
        } else {
            queue += (sortedList - p).map { p + it }
        }
    }

    return permutationList
}

fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList()
    val q = readIntegerList()

    calcPermutationList((1..n).toList())
        .let { it.indexOf(p) - it.indexOf(q) }
        .let(Math::abs)
        .let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 62516
#include <bits/stdc++.h>
#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 REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=1e3+5;
const int base=1e9+7;
int f[maxn];
char s[maxn];
int n,m;
void Input()
{
    cin >> n >> m;
    FOR(i,1,n) {
        cin >> (s+1);
        f[0]=(i==1);
        FOR(j,1,m)
            if (s[j]=='#') f[j]=0;
            else f[j]=(f[j]+f[j-1]) mod base;
    }
    cout << f[m];
}
void Solve()
{

}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}



Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
inline int add(int a,int b){return (a+=b)>=P?a-P:a;}
inline int sub(int a,int b){return (a-=b)<0?a+P:a;}
inline int mul(int a,int b){return 1LL*a*b%P;}
string s;
int main(){
    cin>>s;
    for (int i=0;i<(int)s.length();i++){
        if (s[i]=='9') return puts("Yes")*0;
    }
    puts("No");
    return 0;
}


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

int main() {
 string s; 
   
  cin >> s;
    
    int count=0;
    
    for (int i=0 ; i<3; i++){
      if(s.at(i) == '1'){
        count++;
      }
    }
  cout << count << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

l1=[0]*n
ln=[0]*n
for i in range(m):
    if ab[i][0]==1:
        l1[ab[i][1]-1]+=1
    if ab[i][1]==n:
        ln[ab[i][0]-1]+=1
    #print(l1,ln)
for i in range(n):
    if l1[i]!=0 and ln[i]!=0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 48580
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    ll ary[n], cnt1 = 0, cnt2 = 0, sum = 0;
    rep(i, n) cin >> ary[i];

    // S_odd < 0, S_even > 0
    rep(i, n){
        sum += ary[i];
        if(i % 2 && sum >= 0){
            cnt1 += sum + 1;
            sum = -1;
        } else if(i % 2 == 0 && sum <= 0){
            cnt1 += -sum + 1;
            sum = 1;
        }
    }
    sum = 0;
    // S_odd > 0, S_even < 0
    rep(i, n){
        sum += ary[i];
        if(i % 2 == 0 && sum >= 0){
            cnt2 += sum + 1;
            sum = -1;
        } else if(i % 2 && sum <= 0){
            cnt2 += -sum + 1;
            sum = 1;
        }
    }

    cout << min(cnt1, cnt2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

double dp[301][301][301];

int main()
{
    int n;
    cin >> n;
    vector<int> cnt(3);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ++cnt[x - 1];
    }
    for (int k = 0; k <= n; ++k)
        for (int j = 0; j <= n; ++j)
            for (int i = 0; i <= n; ++i) {
                auto& cur = dp[i][j][k];
                int m = i + j + k;
                if (m) {
                    if (i)
                        cur += dp[i - 1][j][k] * (double) i / m;

                    if (j && i + 1 <= n)
                        cur += dp[i + 1][j - 1][k] * (double) j / m;

                    if (k && j + 1 <= n)
                        cur += dp[i][j + 1][k - 1] * (double) k / m;

                    cur += (double) n / m;
                }
            }
    cout << setprecision(10) << fixed << dp[cnt[0]][cnt[1]][cnt[2]];
    return 0;
}


Measured memory_bytes: 213248
#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <sstream>
#include <vector>

using namespace std;
int main() {
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  string s;
  getline(cin, s);
  istringstream is{s};
  istream_iterator<int> ii{is}, eol;
  vector<int> v{ii, eol};
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  int b, e, k;
  while (cin >> b >> e >> k)
    cout << count_if(v.begin() + b, v.begin() + e, [k](int x) {
      return x == k;
    }) << endl;
}


Measured memory_bytes: 3212
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
narr = lambda d, f: narr(d[:-1], lambda: [f() for _ in range(d[-1])]) if d else f() # narr((2,3), int)
mod = 1000000007
sys.setrecursionlimit(1000000)

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])

queue = deque()
queue.append((start, 0))
#visited = narr((H, W), lambda: float('inf'))
visited = [[float('inf')] * W for _ in range(H)]
visited[start[0]][start[1]] = 0

ds = [(1,0),(-1,0),(0,1),(0,-1)]
while queue:
	n, d = queue.popleft()
	if n == end:
		print(d)
		exit()
	i, j = n
	if visited[i][j] != d:
		continue
	nd = d
	for di, dj in ds:
		ni, nj = i+di, j+dj
		if not (0 <= ni < H and 0 <= nj < W): continue
		if M[ni][nj] == '#': continue
		if nd < visited[ni][nj]:
			queue.appendleft(((ni,nj), nd))
			visited[ni][nj] = nd
	nd = d+1
	for di in range(-2, 3):
		for dj in range(-2, 3):
			if (di, dj) == (0,0): continue
			ni, nj = i+di, j+dj
			if not (0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if nd < visited[ni][nj]:
				queue.append(((ni,nj), nd))
				visited[ni][nj] = nd
print(-1)


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    string a,b,t;
    int n,r;
    while(cin >> a >> b)
    {
        t = a + b;
        n = stoi(t);
        r = sqrt(n);
        cout << (r*r == n? "Yes" : "No") << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int n, x;

    cin >> n >> x;
    while ((n != 0) || (x != 0))
    {
        int cnt = 0;
        for (int i=1; i<=n-2; i++)
        {
            for (int j=(i+1); j<=n-1; j++)
            {
                for (int k=(j+1); k<=n; k++)
                {
                    if (x == i + j + k)
                    {
                         cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
        cin >> n >> x;
    }
}


Measured memory_bytes: 3096
list1=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(list1[K-1])

Measured memory_bytes: 3060
A, B = map(str, input().split())
A = int(A)
ans = A * int(B[0])
ans2 = A * int(B[2]) // 10
ans3 = (A * int(B[2]) - ans2 * 10) / 10
ans4 = A * int(B[3]) // 100
ans5 = (A * int(B[3]) - ans4 * 100) / 100
#print(ans, ans2, ans3, ans4, ans5)
print(int(ans + ans2 + ans4) + int(ans3 + ans5))

Measured memory_bytes: 9200
#include<cstdio>

using namespace std;

int main() {
   
    int H, W;
    while (1) {
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }

        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2564
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	vector<ll>a(n); REP(i, n)a[i] = in();
	sort(ALL(a));
	cout << a.back() - a.front() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int solve(int,int);

int n,A[2000];

int main(){
  int i,m,Q[2000];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&m);

  for(i=0;i<m;i++){
    scanf("%d",&Q[i]);
  }

  for(i=0;i<m;i++){
    if(solve(0,Q[i]) == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  if(m == 0)
    return 1;
  if(i >= n)
    return 0;
  return solve(i + 1, m - A[i])|| solve(i + 1, m);
}



Measured memory_bytes: 2108
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 998244353LL;

int N, X[210], Y[210], p[210];
bool used[210][210];

signed main() {
    cin >> N;
    rep(i,0,N) cin >> X[i] >> Y[i];

    p[0] = 1;
    rep(i,0,N) p[i+1] = (p[i] * 2) % MOD;
    int noneed = (1 + N + N*(N-1)/2) % MOD; // nC0, nC1, nC2
    int ret = (p[N] - noneed + MOD) % MOD;

    rep(P,0,N) rep(Q,0,P) {
        if(used[P][Q]) continue;
        vector<int> points;
        points.push_back(P);
        points.push_back(Q);
        rep(i,0,N) {
            if(i == P || i == Q) continue;
            if((X[Q]-X[i])*(Y[i]-Y[P])==(X[i]-X[P])*(Y[Q]-Y[i])) points.push_back(i);
        }
        int S = points.size();
        rep(i,0,S) rep(j,0,S) used[ points[i] ][ points[j] ] = true;
        if(S >= 3) {
            int noneed_par = (S*MOD + p[S] - (1 + S + S*(S-1)/2)) % MOD;
            ret = (ret - noneed_par + MOD) % MOD;
        }
    }
    cout << ret << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define snd sd.ft
#define td sd.sd
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()

#define ninf -1000000000
#define pinf 1000000000

typedef long long int ll;
const ll MOD= 1e9+7;
typedef vector<pair<ll,ll> > vecpair;
typedef vector<pair<ll, pair<ll,ll> > > vecpair3;
typedef pair<ll, ll> pi;

//double mei ye line cout << fixed << setprecision(10); kam mei le

ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}

struct subset // disjoint set use subsets.claer and subsets.resize............
{
	int parent,sz;
};
vector< subset> subsets;
int find( int i)
{
    if (subsets[i].parent != i)
        subsets[i].parent = find(subsets[i].parent);

    return subsets[i].parent;
}
void uniona(int x, int y){
	if( x == y)
	return ;
    int xroot = find( x);
    int yroot = find( y);
    if (subsets[xroot].sz < subsets[yroot].sz){
        subsets[xroot].parent = yroot;
        subsets[yroot].sz += subsets[xroot].sz;
    }
    else{
        subsets[yroot].parent = xroot;
        subsets[xroot].sz += subsets[yroot].sz;
    }
}
//..............................
vector <int> g[100005];
int dp[100005],vis[100005];
int n,m,x,y;

void dfs(int x)
{
	vis[x]=1;
	dp[x]=1;
	int m1=0,m2=0;
	for(int y:g[x])
	{
		if(vis[y]==1)
		{
			if(dp[y]>m1)
			{
				m2=m1;
				m1=dp[y];
			}
			else if(dp[y]>m2)
			{
				m2=dp[y];
			}
		}
		else
		{
			dfs(y);
			if(dp[y]>m1)
			{
				m2=m1;
				m1=dp[y];
			}
			else if(dp[y]>m2)
			{
				m2=dp[y];
			}
		}
	}
	dp[x]+=m1;

}

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

	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		cin >> x >> y;
		g[x].pb(y);
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			dfs(i);
		}
	}
	int ans=-1;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout << ans-1;
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <queue>

using namespace std;

const int INF = 1000000;

typedef pair<int, int> P;

#define MAX_H 50
#define MAX_W 50

int H, W;
char s[MAX_H][MAX_W + 1];
int sx = 0, sy = 0;
int gx, gy;
int d[MAX_H][MAX_W];

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

int bfs() {
    queue<P> que;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            d[i][j] = INF;
        }
    }
    que.push(P(sx, sy));
    d[sx][sy] = 0;

    while (que.size()) {
        P p = que.front();
        que.pop();
        if (p.first == gx && p.second == gy) break;
        for (int i = 0; i < 4; ++i) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}

int main(void) {
    cin >> H >> W;
    int cnt = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> s[i][j];
            if (s[i][j] == '#') cnt++;
        }
    }
    gx = H - 1, gy = W - 1;

    int res = bfs();
    if (res == INF) {
        cout << "-1" << endl;
    } else {
        cout << H * W - cnt - res - 1 << endl;
    }
    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long Q, std::vector<long long> t, std::vector<long long> u, std::vector<long long> v){
    atcoder::dsu d(N);
    rep(i,0,Q) {
        if (t[i] == 0) {
            d.merge(u[i], v[i]);
        } else {
            cout << (d.same(u[i], v[i]) ? 1 : 0) << endl;
        }
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> t(Q);
    std::vector<long long> u(Q);
    std::vector<long long> v(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&t[i]);
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, Q, std::move(t), std::move(u), std::move(v));
    return 0;
}


Measured memory_bytes: 8104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  string s;
  cin >> N;
  cin >> s;
  int ans=0;
  int x=0;
  for(int i=0;i<N;i++){
    if(s[i]=='I')x++;
    else x--;
    ans = max(ans,x);
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define ii pair <int, int>
#define endl "\n"

int main ()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll

    int n, w;
    cin >> n >> w;

    vector <int> weight(n+1, 0);
    vector <int> value(n+1, 0);

    for (int i=1; i<=n; i++){
    	cin >> weight[i] >> value[i];
    }

    int dp[n+1][w+1];
    memset(dp, 0, sizeof(dp));

    for (int i=0; i<=n; i++){
    	for (int j=0; j<=w; j++){
    		if (i == 0 || j == 0) dp[i][j] = 0;
    		else if (weight[i] <= j){
    			dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i]] + value[i]);
    		}
    		else dp[i][j] = dp[i-1][j];
    	}
    }

    cout << dp[n][w] << endl;
    
	return 0;
}

Measured memory_bytes: 79232
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, X = map(int, readline().split())
psum = 0
books = []
for i in range(N):
    c, *a = map(int, readline().split())
    assert len(a) == M
    books.append((c, a))
    psum += c


def solve():
    U = 1 << N
    minp = psum + 1
    for i in range(U):
        sel = i
        unds = [0] * M
        k = 0
        price = 0
        while (1 << k) < U:
            if (sel >> k) & 1:
                c, a = books[k]
                price += c
                for j in range(M):
                    unds[j] += a[j]
            k += 1
        if minp > price and all(x >= X for x in unds):
            minp = price

    if minp == psum + 1:
        return -1
    return minp


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 9308
import sys
input = sys.stdin.buffer.readline
n,ma,mb=map(int,input().split())
ABC=[list(map(int,input().split())) for _ in range(n)]
infi=10**15
dp=[[[infi]*(401) for _ in range(401)]for _ in range(41)]
dp[0][0][0]=0
for i in range(n):
    a,b,c=ABC[i]
    for j in range(401-a):
        for k in range(401-b):
            ni=i+1
            nj=j+a
            nk=k+b
            dp[ni][j][k]=min(dp[ni][j][k], dp[i][j][k])
            dp[ni][nj][nk]=min(dp[i][j][k]+c,dp[ni][nj][nk])

ans=infi
for i in range(1,401):
    if ma*i>400:
        break
    if mb*i>400:
        break    
    ans=min(ans, dp[n][ma*i][mb*i])
print(ans if ans!=infi else -1)

Measured memory_bytes: 96348
#pragma GCC target("sse,sse2,sse3,sse4.1,sse4.2,popcnt,abm,mmx,avx")
#pragma comment(linker,"/STACK:102400000,102400000")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
#define re register
using namespace std;
typedef long long ll;
typedef double db;
const ll inf=2e9,N=2001001,MAX=2001;
inline void read(register ll &ret)
{
    ret=0;register ll pd=0;register char c=getchar();
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c^48);c=getchar();}
    ret=pd?-ret:ret;
}
ll n,a[N],sum,ans;
int main()
{
	read(n);
	for(re int i=1;i<=n;i++)
	{
		read(a[i]);
		ans+=a[i]*sum;
		sum+=a[i];
	}
	printf("%lld\n",ans);
	exit(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll match[10] = {0,2,5,5,4,5,6,3,7,6};
    ll n,m; cin >> n >> m;
    vvl v(10);
    vl a(m);
    rep(i,m){
        cin >> a[i];
        v[match[a[i]]].push_back(a[i]);
    }
    sort(a.rbegin(), a.rend());
    rep(i,10) sort(v[i].rbegin(), v[i].rend());
    vl dp(n+1,0);
    rep(i,n){
        if(i != 0 && dp[i]==0) continue;
        rep(j,m){
            ll c = match[a[j]];
            if(i+c<=n){
                if(dp[i+c] <= dp[i]){
                    dp[i+c] = dp[i] + 1;
                }
            }
        }
    }
    ll index = n;
    vl ans;
    while(index != 0){
        rep(i,m){
            if(dp[index] - dp[index-match[a[i]]] == 1){
                if(index-match[a[i]]!=0 && dp[index-match[a[i]]]==0) continue;
                ans.push_back(a[i]);
                index -= match[a[i]];
                break;
            }
        }
    }
    for(auto i : ans) cout << i;
    cout << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  bool f=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    f=(s=="Y"?1:f);
  }
  cout<<(f?"Four":"Three")<<endl;
}

Measured memory_bytes: 256
from operator import itemgetter

n=int(input())
ls=[list(map(str,input().split())) for i in range(n)]
for i in range(len(ls)):
    ls[i][1]=int(ls[i][1])
    ls[i].append(i+1)
ls.sort()

answer=[]
previous=ls[0][0]
while ls!=[]:
    que=[]
    while ls!=[]:
        if ls[0][0]==previous:
            que.append(ls.pop(0))
        else:
            previous=ls[0][0]
            break
    ap_que=sorted(que, key=itemgetter(1))
    ap_que.reverse()
    for k in ap_que:
        answer.append(k)
for i in answer:
    print(i[2])

Measured memory_bytes: 3064
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]


n,m = miinps()
k = lmiinpsf(m)
a = lmiinps()

ans = 0

for i in range(2**n):
  d = []
  p = len(bin(i))
  q = bin(i)
  for j in range(p-2):
    q = bin(i>>j)
    if int(q[len(q)-1]) == 1:
      d.append(j)
    
  count2 = 0 #点灯している電球の数
  
  for j in range(m):
    count1 = 0 #電球に接続されているスイッチの内onになっている数
    for l in range(len(k[j])-1):
      if (k[j][l+1]-1) in d:
        count1 += 1
    count1 %= 2
    if count1 == a[j]:
      count2 += 1
    else:
      break;
  if count2 == m:
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N,K;
  cin >> N >> K;
  int X = 1;
   for(int i = 0; i < N; i++){
    if( X * 2 < X + K ){
     X = X * 2;
    }
    else{
     X = X + K;
    }
  }
  cout << X << endl;
}

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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int x=in(),a=in();
    if (x<a) cout << '0' << endl;
    else cout << "10" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
double ABS(double a){return max(a,-a);}
int x[52];
int y[52];
int main(){
	int n=0;
	int a;
	while(scanf("%d",&a),a){
		for(int i=1;i<=a;i++)scanf("%d%d",x+i,y+i);
		x[a+1]=x[1];
		y[a+1]=y[1];
		x[0]=x[a];
		y[0]=y[a];
		double ret=0;
		for(int i=1;i<=a;i++){
			ret+=(x[i+1]-x[i])*(y[i]+y[i+1]);
		}
		printf("%d %.1f\n",++n,ABS(ret)/2);
	}
}

Measured memory_bytes: 1064
import sys
sys.setrecursionlimit(10**6)

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

newa=sorted(a)

#print(a)
#print(newa)
#print(newa[2])

if newa[2]%2==0 or newa[1]%2==0 or newa[0]%2==0:
    print("0")
else:
    print(newa[0]*newa[1])

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N,M = inputIL()

graph = [[] for i in range(N)]
for _ in range(M):
  a,b = inputIL()
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
  
d = [INF for i in range(N)]
prev = [None for i in range(N)]
q = deque([0])
d[0] = 0
while q:
  x = q.popleft()
  nd = d[x]+1
  for nx in graph[x]:
    if nd < d[nx]:
      d[nx] = nd
      prev[nx] = x
      q.append(nx)
      
print("Yes")
for i in prev[1:]:
  print(i+1)

Measured memory_bytes: 105516
#include <bits/stdc++.h>
using namespace std;
#define For(I,A,B) for(int I=(A); I < (B); ++I)
int c[1005][1005];
int main()
{
int t;
string p;
cin>>t;
getline(cin,p);
while(t--){

int x,y,z,k=0,l,i,j;
string a,b;

 For(i,0,1005)
 For(j,0,1005)
 c[i][j]=0;

 getline(cin,a);
 getline(cin,b);
 x=a.length();
 y=b.length();

 For(i,1,x+1)
 For(j,1,y+1)
 {
     if(a[i-1]==b[j-1]) c[i][j]=c[i-1][j-1]+1;
     else  c[i][j]=max(c[i-1][j],c[i][j-1]);
 }
    cout<<c[x][y]<<endl;

}

    return 0;
}

Measured memory_bytes: 7144
#include<stdio.h>

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


Measured memory_bytes: 2112
#include <stdio.h>
int main(void)
{
  int H,W,i,j;
  for ( ; ; )
  {
    scanf("%d %d",&H,&W);
    if (H == 0 && W == 0){break;}
  for (i = 1; i <= H; i++)
  {
    for(j = 1; j <= W; j++)
    {
      printf("#");
      if(j == W){printf("\n");}
    }
    if(i == H){printf("\n");}
  }
  }
  return 0;
}



Measured memory_bytes: 2672
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,Q = map(int,readline().split())
# 1-indexed union-find
# parent(親)
par = [i for i in range(N+1)]
# rank(深さ)
rank = [0]*(N+1)
# 同グループの頂点数
size = [1]*(N+1)

# 木の根を求める
def root(x):
    if par[x] == x:             # 根の時
        return x
    else:
        par[x] = root(par[x])   # 経路圧縮
        return par[x]

# xとyの属する集合を併合(ランク有)
def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y              # xの親をyに
        size[y] += size[x]      # yの頂点数+=xの頂点数
    else:
        par[y] = x              # yの親をxに
        size[x] += size[y]      # xの頂点数+=yの頂点数
        if rank[x] == rank[y]:
            rank[x] += 1
 
for i in range(Q):
    x,y,z = map(int,readline().split())
    unite(x,y)

ans = [0]*(N+1)
for i in par:
    ans[root(i)] += 1

aaa = 0
for i in range(N+1):
    if ans[i] > 0:
        aaa += 1
print(aaa-1)




Measured memory_bytes: 82772
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#define mod 3.1415926535897932384626
using namespace std;
typedef long long ll;
  int main()
  { ll n,m,sum=0,i,k;
     cin>>n>>m;
      for(i=1;i<=m;i++)
       { cin>>k;
         sum+=k;
	   }
	   if(sum>n)
	    cout<<"-1"<<endl;
	    else
	    cout<<n-sum<<endl;
	}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;i<n;i+=2){
    if(s[i]!='h'||s[i+1]!='i'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}




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

using namespace std;

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

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(b-a <= 0){
    cout <<"delicious" << endl;
  }else if(b-a <= x){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {

    int k, x;
    cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s=to_string(n);
  int su=0;
  for(int i=0;i<s.size();i++)
    su+=s.at(i)-48;
  cout << ((n%su==0)?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3688