akhauriyash/Code-Regression huggingface dataset:
#include<queue>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
using i64=long long;
using pi=pair<int,int>;
int read(){int x=0,c=getchar(),f=1;while(isspace(c))c=getchar();if(c=='-')f=-1,c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return f*x;}
const int N=3007,dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
int n,m,cx,cy,nx,ny,px[N],py[N],vis[N][N],id[N][N],ban[N][N][4];queue<pi>q;
struct line1{int a,b,c;}l1[N];
struct line2{int a,b,c;}l2[N];
pi get(int x){return pi(x/cx,x%cx);}
int main()
{
    n=read(),m=read();i64 ans=0,inf=1300000000,flg=0;
    px[cx++]=-inf,py[cy++]=-inf,px[cx++]=inf,py[cy++]=inf;
    for(int i=1;i<=n;++i)
    {
	int a=read(),b=read(),c=read();
	l1[i]={a,b,c};
	px[cx++]=a,px[cx++]=b,py[cy++]=c;
    }
    for(int i=1;i<=m;++i)
    {
	int a=read(),b=read(),c=read();
	l2[i]={a,b,c};
	px[cx++]=a,py[cy++]=b,py[cy++]=c;
    }
    sort(px,px+cx),sort(py,py+cy);
    for(int i=1;i<=n;++i) l1[i].a=lower_bound(px,px+cx,l1[i].a)-px,l1[i].b=lower_bound(px,px+cx,l1[i].b)-px,l1[i].c=lower_bound(py,py+cy,l1[i].c)-py;
    for(int i=1;i<=m;++i) l2[i].a=lower_bound(px,px+cx,l2[i].a)-px,l2[i].b=lower_bound(py,py+cy,l2[i].b)-py,l2[i].c=lower_bound(py,py+cy,l2[i].c)-py;
    for(int i=0;i<cx;++i) if(px[i]<=0&&px[i+1]>0) nx=i;
    for(int i=0;i<cy;++i) if(py[i]<=0&&py[i+1]>0) ny=i;
    for(int i=1;i<=n;++i)
    {
	int a=l1[i].a,b=l1[i].b,c=l1[i].c;
	for(int j=a;j<b;++j) ban[j][c-1][2]=ban[j][c][3]=1;
    }
    for(int i=1;i<=m;++i)
    {
	int a=l2[i].a,b=l2[i].b,c=l2[i].c;
	for(int j=b;j<c;++j) ban[a-1][j][0]=ban[a][j][1]=1;
    }
    vis[nx][ny]=1,q.emplace(nx,ny);
    for(;!q.empty();)
    {
	pi t=q.front();q.pop();
	int x=t.first,y=t.second;
	for(int k=0;k<4;++k)
	    if(!ban[x][y][k])
	    {
		int sx=x+dx[k],sy=y+dy[k];
		if(sx<0||sy<0||sx>=cx||sy>=cy) continue;
		if(!vis[sx][sy]) vis[sx][sy]=1,q.emplace(sx,sy);
	    }
    }
    for(int i=0;i<cx;++i) for(int j=0;j<cy;++j) if(vis[i][j]) ans+=1ll*(px[i+1]-px[i])*(py[j+1]-py[j]);
    for(int i=0;i<cx;++i) if(vis[i][0]||vis[i][cy-1]) flg=1;
    for(int i=0;i<cy;++i) if(vis[0][i]||vis[cx-1][i]) flg=1;
    if(flg) return puts("INF"),0;
    printf("%lld",ans);
}


Measured memory_bytes: 160264
N, M, C = [int(_) for _ in input().split()]

B_box = []
ans = 0
count = 0


for _ in input().split():
    B_box.append(int(_))

for i in range(N):
    count_num=0
    for j in input().split():
        j = int(j) 
        count += j * B_box[count_num]
        count_num += 1
    count = count + C
    if count > 0:
        ans += 1
    count = 0
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
int main(){
int N;
std::cin>>N;
double a[N],mul=1.0,mulsum=0.0;
double ans;
for (int i=0;i<N;i++){
  std::cin>>a[i];
  mul*=a[i];
}
for (int i=0;i<N;i++){
  mulsum+=(mul/a[i]);
}
ans=mul/mulsum;
std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
S=int(input())
b=S//100
a=S%100

YYMM=False
MMYY=False

if 0<=b<=99 and 1<=a<=12:
    YYMM=True

if 1<=b<=12 and 0<=a<=99:
    MMYY=True

if YYMM and MMYY:
    print('AMBIGUOUS')
elif YYMM and not MMYY:
    print('YYMM')
elif not YYMM and MMYY:
    print('MMYY')
else:
    print('NA')



Measured memory_bytes: 3060
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         long[] data = ReadLine().Split(' ').Select(long.Parse).ToArray();
         if(data[0] >= data[3]){
             WriteLine(data[3]);
         }else if(data[0] + data[1] >= data[3]){
             WriteLine(data[0]);
         }else if(data[0] + data[1] + data[2] >= data[3]){
             long tmp = data[3] - data[1] - data[0];
             WriteLine(data[0] - tmp);
         }
      }
   }
}

Measured memory_bytes: 28240
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, mod = 1000000007;

int n, m;
int a[N];
char s[N];

int main()
{
    n = gi(), m = gi();
    LL sum = 0;
    for (int i = 1; i <= m; i+=1) a[i] = gi(), sum += a[i];
    cout << max(n - sum, 1ll * (-1)) << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define pb push_back
#define fs first
#define sc second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const double EPS = 1e-9;

int main() {
    cin.sync_with_stdio(false);
    int x;
    cin >> x;
    if(x == 0) cout << 1;
    else cout << 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,n,i;
    cin>>k>>n;
    int a[n];
    int b[100001]={0};
    for (i=0;i<n;i++) 
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for (i=0;i<100;i++)
    {
        if (b[k-i]==0) {cout<<k-i;break;}
        if (b[k+i]==0) {cout<<k+i;break;}
    }
}

Measured memory_bytes: 4028
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,M=map(int,input().split())
ans=0
if N>1:
  ans+=combinations_count(N,2)
if M>1:
  ans+=combinations_count(M,2)
print(ans)

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

#define ll long long

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin>>N;
    map<int,int> edge;
    for(int i = 0; i < N ; i++){
        int t;
        cin>>t;
        edge[t]++;
    }
    ll a = 0,b = 0;
    for(auto it = edge.rbegin(); it != edge.rend() ; it++){
        if(a!=0 && b!=0) break;
        if(it->second>=4){
            if(a==0)
                a = it->first;
            if(b==0)
                b = it->first;
            break;
        }
        else if(it->second>=2 && a==0){
            a = it->first;
        }
        else if(it->second>=2 && b==0){
             b = it->first;
        }
    }
    cout<<a*b<<'\n';
}

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

const int Nmax=200010;

int main() {
	int N,K;
	ll x[Nmax],y[Nmax];
	char c[Nmax];
	cin >> N >> K;
	for(int i=0;i < N;i++){
		cin >> x[i] >> y[i] >> c[i];
		if(c[i] == 'W') x[i] += K;
		x[i] %= 2*K;
		y[i] %= 2*K;
	}
	int imosu[4010][4010]={};
	
	for(int i=0;i < N;i++){
		imosu[(x[i])][(y[i])]++;
		imosu[(x[i])+2*K][(y[i])]++;
		imosu[(x[i])][(y[i]+2*K)]++;
		imosu[(x[i]+2*K)][(y[i]+2*K)]++;
	}
	int mac=0;
	for(int i=0;i <= 4*K;i++){
		for(int j=0;j < 4*K;j++){
			imosu[i][j+1] += imosu[i][j];
		}
	}
	for(int j=0;j <= 4*K;j++){
		for(int i=0;i < 4*K;i++){
			imosu[i+1][j] += imosu[i][j];
		}
	}
  	
	for(int i=0;i < 2*K;i++){
		for(int j=0;j < 2*K;j++){
          	int sum=0;
			sum += imosu[i+K][j+K]-imosu[i+K][j]-imosu[i][j+K]+imosu[i][j];
			sum += imosu[i+2*K][j+2*K]-imosu[i+2*K][j+K]-imosu[i+K][j+2*K]+imosu[i+K][j+K];
			mac = max(mac,sum);
		}
	}
	cout << mac << endl;
	return 0;
}

Measured memory_bytes: 66304
#include <iostream>
#include <vector>

using namespace std;

int B[10];

bool solve() {
    vector<int> a, b;
    a.push_back(0);
    b.push_back(0);
    for (int i = 0; i < 10; i++) {
        if (a.back() < B[i]) {
            a.push_back(B[i]);
        } else if (b.back() < B[i]) {
            b.push_back(B[i]);
        } else {
            return false;
        }
    }
    return true;
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> B[j];
        }
        cout << (solve() ? "YES" : "NO") << endl;
    }
    return 0;
}

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

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

    for (int i = 0; i< N; i++) cin >> A.at(i);

    double total = 0.0;
    for (int i = 0; i < N; i++){
        total += double(A.at(i));
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    if(double(A.at(M-1)) >= total/(4.0 * M)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int di(){
	static char s[2]; scanf("%s", s);
	switch(s[0]){
		case 'U': return 1;
		case 'R': return 0;
		case 'D': return 3;
		case 'L': return 2;
	}
	exit(1);
}
constexpr int N = 524288;
int x[N], y[N], d[N];
using vec = vector<pair<int, bool>>;
vec v[N];
int check(vec &v, int a){
	sort(ALL(v));
	REP(i, (int)v.size()-1){
		auto [p, s] = v[i];
		auto [q, t] = v[i+1];
		if(!s && t){
			return (q-p)*a;
			exit(0);
		}
	}
	return INT_MAX;
}

int main(){
	int n; scanf("%d", &n);
	REP(i, n) {
		scanf("%d%d", x+i, y+i);
		d[i] = di();
	}
	int ans = INT_MAX;
	REP(ii, 4){
		REP(i, N) v[i].clear();
		REP(i, n) if(d[i] % 2) v[x[i]].EB(y[i], d[i]/2);
		REP(i, N) SML(ans, check(v[i], 5));

		REP(i, N) v[i].clear();
		REP(i, n) if(d[i] < 2) v[x[i]+y[i]].EB(x[i], d[i]%2);
		REP(i, N) SML(ans, check(v[i], 10));

		REP(i, n){
			DEBUG("(%d, %d)", x[i], y[i]);
			d[i] = (d[i] + 1) % 4;
			swap(x[i], y[i]);
			x[i] = 200'000 - x[i];
			DEBUG(" => (%d, %d)\n", x[i], y[i]);
		}
	}
	if(ans == INT_MAX){
		printf("SAFE\n");
	}else{
		printf("%d\n", ans);
	}
}




Measured memory_bytes: 30300
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <cstdio>
#include <cmath>

#define REP(i, b, n) for(int i=(b); i<(n); ++i)
#define rep(i, n) for(int i=0; i<(n); ++i)
#define foreach(it, v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int h, w;
bool inRange(int a, int x, int b){return a <= x && x < b;}
void dfs(vector<string> &in, int i, int j){
    char c = in[i][j]; in[i][j] = '.';
    rep(d, 4) if(inRange(0, i+dx[d], h) && inRange(0, j+dy[d], w))
        if(in[i+dx[d]][j+dy[d]] == c) dfs(in, i+dx[d], j+dy[d]);
}
void solve(vector<string> &in){
    int res = 0;
    rep(i, h) rep(j, w) if(in[i][j] != '.') dfs(in, i, j), ++res;
    cout << res << endl;
}
int main(void){
    while(cin >> h >> w, h|w){
        vector<string> in(h);
        rep(i, h) cin >> in[i];
        solve(in);
    }
    return 0;
}

Measured memory_bytes: 2012
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

struct Hoge {
	int a, b, c, d;
};

template<typename F>
constexpr decltype(auto) fix(F&& f) {
	return[f = std::forward<F>(f)](auto&&... args) {
		return f(f, std::forward<decltype(args)>(args)...);
	};
}

int main() {
	int n, m, q;
	std::cin >> n >> m >> q;

	std::vector<Hoge> vec(q);
	for (auto&& e : vec)
		std::cin >> e.a >> e.b >> e.c >> e.d;

	auto calcPoint = [&](const std::vector<int>& v) -> int {
		int ret = 0;
		for (auto&& e : vec)
			if (v[e.b - 1] - v[e.a - 1] == e.c)
				ret += e.d;

		return ret;
	};

	int ans = 0;
	auto solve = fix([&](auto f, std::vector<int>& v, int used) -> void {
		if (v.size() == n) {
			ans = std::max(ans, calcPoint(v));
			return;
		}

		for (int i = used; i <= m; ++i) {
			v.push_back(i);
			f(f, v, i);
			v.pop_back();
		}
	});

	std::vector<int> v;
	solve(v, 1);

	std::cout << ans << std::endl;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)

	s := make([]int,m)
	c := make([]int,m)
	
	for i := 0; i < m; i++ {
		fmt.Scan(&s[i], &c[i])
		s[i]--
	}
	
	//矛盾があったらアウト
	for i := 0; i < m - 1; i++ {
		for j := i + 1; j < m; j++ {
			if s[i] == s[j] && c[i] != c[j] {
				fmt.Println(-1)
				return
			}
		}
	}
	
	//予め-1を入れておく
	ans := make([]string, n)
	for i := range ans {
		ans[i] = "-1"
	}
	
	//s,cの値を代入していく
	for i := 0; i < m; i++ {
		ans[s[i]] = strconv.Itoa(c[i])
	}
  
	// 例外に配慮し値を入れる
	for i := range ans {
		if ans[i] == "-1" {
			if n == 1 || n >=2 && i >= 1{
				ans[i] = "0"
			} else if n >= 2 {
				ans[i] = "1"
			}
        }
	}

  
	if n >= 2 && ans[0] == "0" {
		fmt.Println(-1)
		return
	}
  
	fmt.Println(strings.Join(ans,""))
	
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include<set>
using namespace std;
set<string> s;
string w[105];
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> w[i];

  s.insert(w[0]);
  for(int i = 1; i < n; i++) {
    if(w[i-1][w[i-1].size() - 1] == w[i][0] && s.find(w[i]) == s.end())
      s.insert(w[i]);
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
(x, n) = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)

m = [*-200..200] - p
d = 100000
r = 100000

m.each do |i|
  if d > (x - i).abs
    d = (x - i).abs
    r = i
  elsif d = (x - i).abs
    if r > i
      r = i
    end
  end
end

puts r


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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int>ans(N-1);
  double num = (double)(X + Y) / 2;
  for (int i = 1; i < N; i++) {
    for (int j = i+1; j < N+1; j++) {
      if ((i < X && j < X) || (i > Y && j > Y) || (i < X && j == X) || (i == Y && j > Y)) {
        ans.at(j-i-1)++;
      }
      else if (i <= X && j >= Y) {
        ans.at(j-Y+X-i)++;
      }
      else if (i < X && X < j && j < Y) {
        if (j <= num) {
          ans.at(j-i-1)++;
        }
        else {
          ans.at(Y-j+X-i)++;
        }
      }
      else if (X < i && i < Y && Y < j) {
        if (num <= i) {
          ans.at(j-i-1)++;
        }
        else {
          ans.at(j-Y+i-X)++;
        }
      }
      else {
        ans.at(min(j-i-1, Y-j+i-X))++;
      }
    }
  }
  for (int i = 0; i < N-1; i++) {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String y = "Yes";
		String n = "No";
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.nextLine();
		String line = sc.nextLine();
		int cnt = 1;
		int fCnt = 1;
		for(int i=0;i<line.length();i++) {
			char c = line.charAt(i);
			switch(c) {
			case 'a':
				if((A+B) >= cnt) {
					System.out.println(y);
					cnt++;
				} else {
					System.out.println(n);
				}
				break;
			case 'b':
				if(((A+B) >= cnt) && B >= fCnt) {
					System.out.println(y);
					cnt++;
					fCnt++;
				} else {
					System.out.println(n);
				}
				break;
			case 'c':
				System.out.println(n);
				break;
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 36484
# A = [list(map(int, input().split())) for _ in range(3)]
# k = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
import math
a, b = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


if a < 2 and 2 <= b:
    print(combinations_count(b, 2))
elif 2 <= a and b < 2:
    print(combinations_count(a, 2))
elif a < 2 and b < 2:
    print(0)
else:
    print(combinations_count(a, 2)+combinations_count(b, 2))


Measured memory_bytes: 3060
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	sort(h.rbegin(), h.rend());
	long long sum = accumulate(h.begin() + min((int)h.size(), k), h.end(), 0LL);
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <climits>
using namespace std;

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

int main() {
	int n; cin >> n;
	vector<int> r(n);

	int min = INT_MAX, lmax = INT_MIN;
	REP( i, n ) {
		cin >> r[i];
		if( r[i] - min > lmax ) lmax = r[i] - min;
		if( r[i] < min ) min = r[i];
	}

	cout << lmax << endl;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define nyan "(=^･ω･^=)"
using namespace std;

const int mod = 1e9 + 7;
const long long INF = 1LL<<60;
using ll = long long;
using P = pair<int,int>;

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; }

long long factorial(long long n){
    long long temp = 1;
    for (int i = 1; i <= n; i++) temp *= i, temp %= mod;
    return temp;
}

int main(){
    long long n, m;
    cin >> n >> m;
    
    if (abs(n-m) >= 2){
        cout << 0 << endl;
        return 0;
    }
    
    if (n - m == 1){
        cout << (factorial(n) * factorial(m)) % mod << endl;
    }
    else if (m - n == 1) {
        cout  << (factorial(n) * factorial(m)) % mod << endl;
    }
    
    if (n == m){
        cout << (2 * factorial(n) * factorial(m)) % mod << endl;
    }
}


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

namespace practice1
{
    class Program
    {
        static void Main(string[] args)
        {
            long number = long.Parse(MyScanf());
            string moziretsu = MyScanf();
            char[] c1, c2;
            c1 = new char[100];
            c2 = new char[100];
            int i, j, k, flag, count, max = 0;

            for (i = 1; i < moziretsu.Length; i++)
            {
                count = 0;
                c1 = moziretsu.ToCharArray(0, (int)i);
                c2 = moziretsu.ToCharArray(i, (moziretsu.Length - i));

                for (j = 0; j < c1.Length; j++)
                {
                    if (c1[j] == ' ') continue;
                    flag = 0;

                    for (k = 0; k < c2.Length; k++)
                    {
                        if (c1[j] == c2[k]) flag = 1;
                    }

                    if (flag == 1) count++;

                    for (k = 0; k < c2.Length; k++)
                    {
                        if (c1[j] == c2[k]) c2[k] = ' ';
                    }


                }

                if (count > max) max = count;
            }

            Println("" + max);

        }

        public static void Println(string str)
        {
            Console.WriteLine(str);
        }

        public static void Print(string str)
        {
            Console.Write(str);
        }

        public static string MyScanf()
        {
            return Console.ReadLine();
        }

        public static string[] MyScanfSplit()
        {
            return MyScanf().Split();
        }

        public static void MyDoubleSort(double[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            double a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        public static void MyLongSort(long[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            long a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
	ll n, m;
	cin >> n >> m;
	ld a[n], sum = 0, cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	ld ans = sum/(4*m);
	for(int i = 0; i < n; i++){
		if(a[i] >= ans)
			cnt++;
	}
	if(cnt >= m)
		cout << "Yes";
	else if(cnt < m)
		cout << "No"; 	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


//始点全て試す bfs 

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
ll H, W;

ll bfs(int h, int w, string fi[25]){
  if(fi[h][w] == '#') return -1;
  int d[25][25];
  rep(i, 0, 25) rep(j, 0, 25) d[i][j] = -1;
  d[h][w] = 0;
  queue<pair<int, int>> qu;
  qu.push(make_pair(h, w));
  while(!qu.empty()){
    pair<int, int> u = qu.front(); qu.pop();
    fi[u.first][u.second] = '#';
    rep(i, 0, 4){
      int y = u.first+dy[i], x = u.second+dx[i];
      if(y<0 || y>=H || x<0 || x>=W) continue;
      if(fi[y][x] == '#') continue;
      d[y][x] = d[u.first][u.second] + 1;
      fi[y][x] = '#';
      qu.push(make_pair(y, x));
    }
  }
  int res = -1;
  rep(i, 0, H) rep(j, 0, W) res = max(res, d[i][j]);
  return res;
}

int main() {
  string field[25];
  cin >> H >> W;
  rep(i, 0, H){
    cin >> field[i];
  }

  ll ans = -1;
  rep(i, 0, H){
    rep(j, 0, W){
      string fie[25];
      rep(i, 0, H) fie[i] = field[i];
      ans = max(ans, bfs(i, j, fie));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
M = []
dp = [[None for i in range(100)] for i in range(100)]

def calcMatrix(i,j):
    #print(i,j)
    if i == j:
        dp[i][j] = 0
    elif i == j-1:
        dp[i][j] = M[i]*M[i+1]*M[i+2]
    else:
        for k in range(j-i):
            #print(i,j,k)
            #print(dp[i][i+k])
            #print(dp[i+k+1][j])
            #print(M[i]*M[k+1]*M[j])
            current = dp[i][i+k] + dp[i+k+1][j] + M[i]*M[i+k+1]*M[j+1]
            if k==0:
                dp[i][j] = current
            if current < dp[i][j]:
                dp[i][j] = current 

for i in range(n-1):
    Q = list(map(int,input().split()))
    M.append(Q[0])
Q = list(map(int,input().split()))
M.append(Q[0])
M.append(Q[1])
#print(M)

for i in range(n):
    for j in range(n-i):
        calcMatrix(j,i+j)
        #for k in range(10):
        # print(dp[k])
        # print()
print(dp[0][n-1]) 


Measured memory_bytes: 5720
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val A, B = sc.nextInt
    var ans = 0
    for (i <- A to B) {
      if (i.toString.reverse.toInt == i) (ans += 1)
    }
    println(ans)
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

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

const long long MOD = 1000000007;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(26, n+10));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'a'] = i;
    }
    return res;
}

int main(){
    //input
    string S;
    cin >> S;

    //calc
    string T = S;
    reverse(T.begin(),T.end());
    int n = S.length();
    vector<vector<int> > nextS = calcNext(S);
    vector<vector<int> > nextT = calcNext(T);
    vector<vector<long long> > dp(n+1,vector<long long>(n+1,0));
    int i,j,k;
    dp[0][0]=1;
    for(i=0; i<=n; i++){
        for(j=0; j<=n; j++){
            for(k=0; k<26; k++){
                if(nextS[i][k]+1+nextT[j][k]+1<=n){
                    dp[nextS[i][k]+1][nextT[j][k]+1]+=dp[i][j];
                    dp[nextS[i][k]+1][nextT[j][k]+1]%=MOD;
                }
            }
        }
    }
    vector<vector<long long> > dq(n+1,vector<long long>(n+1,0));
    for(i=0; i<=n; i++){
        for(j=0; j<=n; j++){
            for(k=0; k<26; k++){
                if(nextS[i][k]<=n-j-1){
                    dq[i][j]++;
                }
            }
        }
    }
    dq[0][0]--;
    long long ans=0;
    for(i=0; i<=n; i++){
        for(j=0; j<=n; j++){
            if(i+j<=n){
                ans+=(dq[i][j]+1)*dp[i][j];
                ans%=MOD;
            }
        }
    }

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


Measured memory_bytes: 66312
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    int cntk = 0, cntg = 0;
    rep(i,n){
        cin >> a[i];
        if(a[i]%2==1)
            cntk++;
            else
                cntg++;
    }
    if(cntk==0)
        cout << "second" << endl;
        else
            cout << "first" << endl;
        return 0;
}

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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) int s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;
const int size = 9;
const int prime[size] = {3,5,7,11,13,17,19,23,29};


int main() {
  int1(n);
  // a*b*c=n(a,b,c is prime and not 2 and a<b<c)
  int cnt  = 0;
  rep(i,size-2){
    for (int j=i+1; j<size-1; ++j) {
      for (int k=j+1; k < size; ++k) {
        if(prime[i]*prime[j]*prime[k]<=n){
          cnt++;
        }else{
          break;
        }
      }
    }
  }
  rep(i,size-1){
    for (int j=i+1; j<size; ++j) {
      
      if(prime[i]*prime[j]*prime[j]*prime[j]<=n||prime[i]*prime[i]*prime[i]*prime[j]<=n){
        cnt++;
      }else{
        break;
      }
      
    }
  }
  repi(size){
    if(prime[i]*prime[i]*prime[i]*prime[i]*prime[i]*prime[i]*prime[i]<=n){
        cnt++;
      }else{
        break;
      }
  }

  
  prln(cnt);
}

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

int main() {
  int x, y;
  cin >> x >> y;
  
  int product;
  product = x * y;
  
  if (product % 2 == 0){
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 digits(int n) {
  if (n == 0) return 0;
  return 1 + digits(n / 10);
}

int main() {
  int a, b;
  while (cin >> a) {
    cin >> b;
    cout << digits(a + b) << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		
		for(int i=0; i<=n/r; i++){
			for(int j=0; j<=(n-i*r)/g; j++){
				if((n-i*r-j*g)%b == 0){
					ans++;
				}
			}
		}
		
		System.out.println(ans);
	}
}


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

int main() {
    int n;
    cin>>n;
    ll ans=0;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    bool down=false,up=false;
    for (int i=0; i<n-1; i++) {
        if (a[i]<a[i+1]&&!down&&!up) up=true;
        else if(a[i]>a[i+1]&&!down&&!up) down=true;
        else if (a[i]<a[i+1]&&down) {
            down=false;
            ans++;
        }
        else if(a[i]>a[i+1]&&up) {
            up=false;
            ans++;
        }
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[10010][110][11];
int main() {
    string s; cin >> s;
    int d; cin >> d;
    dp[0][0][10] = 1; dp[0][0][0] = 1;
    for (int i = 0; i <= s.size(); i++) {
        for (int j = 0; j < d; j++) {
            for (int k = 0; k < 10; k++) {
                dp[i+1][(j+k)%d][k] += dp[i][j][10];
                dp[i+1][(j+k)%d][10] += dp[i][j][10];
                dp[i+1][(j+k)%d][k] %= mod;
                dp[i+1][(j+k)%d][10] %= mod;
            }
        }
        for (int j = 0; j < d; j++) {
            for (int k = 0; k < 10; k++) {
                if (dp[i+1][j][k] == 0) continue;
            }
        }
    }
    long long ans = -1; int k = 0;
    for (int i = 0; i < s.size(); i++) {
        int t = s[i] - '0';
        for (int u = 0; u < t; u++) {
            ans += dp[s.size()-i][(d-k)%d][u];
            ans %= mod;
        }
        k = (k+t) % d;
    }
    ans = (ans+dp[0][(d-k)%d][0]) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 94848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] s = Console.ReadLine().ToCharArray();
            bool zeroFlag = s[0] == '0' ? true : false;
            int cnt = 0;

            for (int i = 1; i < s.Length; i++)
            {
                if (zeroFlag)
                {
                    if(i % 2 != 0 && s[i] != '1')
                    {
                        cnt++; 
                    }
                    else if(i % 2 == 0 && s[i] != '0')
                    {
                        cnt++;
                    }
                }
                else
                {
                    if (i % 2 != 0 && s[i] != '0')
                    {
                        cnt++;
                    }
                    else if (i % 2 == 0 && s[i] != '1')
                    {
                        cnt++;
                    }
                }
            }

            Console.WriteLine(cnt);

            
        }
    }
}


Measured memory_bytes: 13176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int a,i,c=1;
    cin>>a;
    unsigned long long int b[a];
    for(i=0;i<a;i++)
    {
        cin>>b[i];
    }
    sort(b,b+a);
    if(b[0]==0)
        cout<<"0"<<endl;
    else
    {
        for(i=0;i<a;i++)
        {

            if(c>1000000000000000000/b[i]){
            cout<<-1<<endl;
            return 0;
            }
            else
                c=c*b[i];
        }
        cout<<c<<endl;
    }
}


Measured memory_bytes: 4380
#include <iostream>

#define ll long long
#define mod 1000000007
using namespace std;

ll pw(ll x,ll a){
	ll ans = 1;
	while(a){
		while(!(a&1)){
			a >>= 1;
			x = (x*x)%mod;
		}
		ans = (ans*x)%mod;
		--a;
	}
	return ans;
}

int dig(ll n){
    int res=0;
    while(n){
        res++;
    	n/=10;
    }
    return res;
}

int main(){
	ll i,s,ans=0;
	cin >> s;
	ll r = 0,l = 0,cnt = 0;
   	while(l<10000000){
		while(cnt<s){
			r++;
			cnt += dig(r);
            if(cnt==s) ans++;
			ans %= mod;
        }
        while(cnt>=s){
            l++;
        	cnt -= dig(l);
            if(cnt==s && l<10000000) ans++;
        }       
    }
	
	ans += (s-1)/8;
	ans %= mod;
	for(i=1;i*i<=s;i++){
		if(!(s%i)){
			if(i>=8){
				(ans += 9*pw(10,i-1) - s/i + mod)%mod;
			}
			if(s/i>=8 && i*i!=s){
				(ans += 9*pw(10,s/i-1) - i + mod)%mod;
			}
		}
	}
	cout << ans%mod << endl;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;

  vector<int> cnt(100001, 0);
  for ( int i = 0; i < N; i++ ) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }

  int sum = 0;
  for ( int i = 1; ; i++ ) {
    sum += cnt[i];
    if ( sum >= K ) {
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

    int main()      /*this code is written by 190042146*/
{
    int n, i;
    long long int sum=0;

    scanf("%d", &n);

    for (i=1;i<=n;i++)
    {
        if (i%3==0 || i%5==0)
        {
            continue;
        }
        sum=sum+i;
    }

    printf("%lld",sum);


    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s[15]={"Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge","Paper","Air","Water","Dragon","Devil","Lightning","Gun"};
  map<string,int> r;
  for(int i=0; i<15; i++) r[s[i]]=i;
  int n;
  while(cin >> n && n) {
    map<string,int> m;
    string t[n];
    for(int i=0; i<n; i++) {
      cin >> t[i];
      m[t[i]]++;
    }
    set<string> ans;
    for(int i=0; i<n; i++) {
      int k=r[t[i]];
      int c=0,c2=0;
      for(int j=0; j<7; j++) c+=m[s[(k+j+1)%15]];
      for(int j=0; j<7; j++) c2+=m[s[(k+j+8)%15]];
      if(c&&!c2) ans.insert(t[i]);
    }
    if(ans.size()==1) cout << *ans.begin() << endl;
    else cout << "Draw" << endl;
  }
  return 0;
}


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

int x,y;

int judge(int p){
	if(p==2)return 0;
	if(p==4||p==6||p==9||p==11)return 1;
	else return 2;
}

int main(){
	cin>>x>>y;
	if(judge(x)==judge(y))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<double>>X(N, vector<double>(D));
	rep(i, N) {
		rep(j, D) {
			cin >> X[i][j];
		}
	}
	double ans = 0;
	int ANS = 0;
	int cnt = 0;
	rep(i, N) {
		rep(j, N) {
			if (i < j) {
				ans = 0;
				ANS = 0;
				rep(k, D) {
					ans += pow(X[i][k] - X[j][k], 2);
					ANS += pow(X[i][k] - X[j][k], 2);
				}
				ans = sqrt(ans);
				ANS = int(sqrt(ANS));
				if (ans == ANS) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
int repUnitValue(int n) 
{ 

    if (n % 2 == 0 || n % 5 == 0) 
        return 0; 
    int rem = 1; 
    int power = 1; 
    int k = 1; 
    while (rem % n != 0) 
    { 
        k++; 
        power = power * 10 % n; 
        rem = (rem + power) % n; 
    } 
      
    return k; 
} 
int main()
{
	SPEED
	int k;
	cin >> k;

	if (k==7)
	{
		cout << 1;
	}
	else if (k%2==0)
	{
		cout << -1;
	}
	else
	{
		//check if k contains 7 as factor
		if (k%7==0)
		{
			k=k/7;
		}

		int ans = repUnitValue(k);
		if (ans==0)
		{
			cout << -1;
		}
		else
		{
			cout << ans;
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	int n;
	cin >> n;
	vector<int> g[n];
	int m;
	cin >> m;
	vector<int> h(n);
	forn(i, n) {
		cin >> h[i];
	}
	forn(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	int cnt = 0;
	forn(i, n) {
		int ok = 1;
		for (int v : g[i]) {
			if (h[v] >= h[i]) {
				ok = 0;
				break;
			}
		}
		cnt += ok;
	}
	cout << cnt << "\n";
 	return 0;
}

Measured memory_bytes: 9852
#include<bits/stdc++.h>
#include <chrono>
//#include<math.h>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int inf=1e9;
//const ld M_PI=3.14159265358979323;

/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
ll f(ll x,ll n){
    ll r=1;
    while(n){
        if(n%2==1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return r;

}

vector<ll> fact(2e5+10,1),ifact(2e5+10);
void build(){
    for(ll i=2;i<fact.size();i++)
    fact[i]=(i*fact[i-1])%mod;
    fr(i,0,fact.size()){
        ifact[i]=f(fact[i],mod-2);
    }
}
ll C(int n, int r){
    if(n<r)
    return 0;
    return (((fact[n]*ifact[r])%mod)*ifact[n-r])%mod;
}

/*ll C[1001][1001];
void build(){
    memset(C,0,sizeof(C));
    fr(i,0,1001)
    C[i][i]=1;
    fr(i,0,1001)
    C[i][0]=1;
    fr(i,2,1001){
        fr(j,1,i){
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
        }
    }
}*/
void solve(){
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];
    fr(i,0,m){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    priority_queue<pr,vector<pr> ,greater<pr> > pq;
    int pre[n+1];
    fr(i,1,n+1)
    pre[i]=-1;
    pq.push({0,1});
    vector<int > dist(n+1,inf);
    dist[1]=0;
    while(pq.size()){
        pr p=pq.top();
        pq.pop();
        int d=p.first;
        int s=p.second;
        if(dist[s]<d)
        continue;
        for(auto u:adj[s]){
            if(dist[u]>d+1){
                dist[u]=d+1;
                pq.push({d+1,u});
                pre[u]=s;
            }
        }
    }
    string ans="Yes";
    fr(i,2,n+1){
        if(pre[i]==-1)
        ans="No";
    }
    if(ans=="No"){
        cout<<ans;
        return;
    }
    cout<<ans<<endl;
    fr(i,2,n+1)
    cout<<pre[i]<<endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 14208
N = int(input())
A = [int(x)for x in input().split()]

A_even = [x for x in A if x%2 == 0]
ans = 'APPROVED'
for i in A_even:
    if i%3 == 0 or i%5 == 0:
        ans = 'APPROVED'
    else:
        ans = 'DENIED'
        break
print(ans)
 


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll dp[1 << 18];
ll a[1 << 18];
ll b[1 << 18];
vector<vector<int>> vt;
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 0; i < (1 << n); i++) {
		scanf("%lld", &a[i]);
	}
	vt.resize(n);
	for (int i = 0; i < (1 << n); i++) {
		for (int y = 0; y < n; y++) {
			if (i&(1 << y))continue;
			vt[y].push_back(i);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int y = 0; y < vt[i].size(); y++) {
			int idx = vt[i][y];
			dp[idx | (1 << i)] = max(dp[idx | (1 << i)], a[idx | (1 << i)] + a[idx]);
			dp[idx | (1 << i)] = max(dp[idx | (1 << i)], dp[idx]);
			a[idx | (1 << i)] = max(a[idx | (1 << i)], a[idx]);
		}
	}
	ll dap = 0;
	for (int i = 1; i < (1 << n); i++) {
		dap = max(dap, dp[i]);
		printf("%lld\n", dap);
	}
}


Measured memory_bytes: 16940
s = input()
mod = 10 ** 9 + 7

l = len(s)
dp = [[0] * 4 for _ in range(l + 1)]
dp[0][0] = 1

for i, e in enumerate(s, 1):
	# do not use in ABC
	for j in range(4):
		if e == "?":
			dp[i][j] += dp[i-1][j] * 3
		else:
			dp[i][j] += dp[i-1][j]

	# use in ABC
	if e == "A" or e == "?":
		dp[i][1] += dp[i-1][0]
	if e == "B" or e == "?":
		dp[i][2] += dp[i-1][1]
	if e == "C" or e == "?":
		dp[i][3] += dp[i-1][2]

	for j in range(4):
		dp[i][j] %= mod


ans = dp[l][3]
print(ans)


Measured memory_bytes: 27608
n=int(input())
a=list(map(int,input().split()))
f2=lambda x:x%2==0 and x%4!=0
f4=lambda x:x%4==0
c2,c4=0,0
for i in a:
    c2+=f2(i)
    c4+=f4(i)
print('Yes' if c2+c4*2>=n or (c2==0 and c4*2+1>=n)else 'No')

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

int main() {
    int count = 0;
    char input[101];
    while (cin >> input) {
        bool symmetryFlag = true;
        int size = 0;
        for (int i = 0; input[i] != '\0'; i++) {
            size++;
        }
        for (int i = 0; i * 2 <= size - 1; i++) {
            if (input[i] != input[size - 1 - i]) {
                symmetryFlag = false;
                break;
            }
        }
        if (symmetryFlag) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 0
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = sc.nextInt();
        System.out.println(N / (2*D + 1) + (N % (2 * D + 1) == 0 ? 0 : 1));
    }
}



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

/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
int mod = (int)1e9 + 7 ;
const int inf = (int)1e9 ;
/************************************************************/

int X[] = { 1, -1, 0, 0 } ;
int Y[] = { 0, 0, -1, 1 } ;
bool inside( int x, int y, int &H, int &W ) {
	return ( x >= 1 && x <= H && y >= 1 && y <= W ) ;
}

signed main(){
	int H, W ; cin >> H >> W ;
	int sx, sy ; cin >> sx >> sy ;
	int dx, dy ; cin >> dx >> dy ;
	let grid = matrix<char>( H + 1, W + 1, '.' ) ;
	for( int i = 1 ; i <= H ; i++ ){
		for( int j = 1 ; j <= W ; j++ ){
			cin >> grid[i][j] ;
		}
	}

	let dist = matrix<int>( H + 1, W + 1, inf ) ;
	dist[sx][sy] = 0 ;
	deque<pair<int,int>> q ;
	q.push_front( { sx, sy } ) ;
	int nx, ny ;
	while( !q.empty() ) {
		let cur = q.front() ;
		q.pop_front() ;
		for( int i = 0 ; i < 4 ; i++ ) {
			nx = cur.first + X[i], ny = cur.second + Y[i] ;
			if( inside( nx, ny, H, W ) && grid[nx][ny] != '#' ){
				if( dist[nx][ny] > dist[cur.first][cur.second] ){
					dist[nx][ny] = dist[cur.first][cur.second] ;
					q.push_front( { nx, ny } ) ;
				}
			}
		}
		for( int i = -2 ; i <= 2 ; i++ ){
			for( int j = -2 ; j <= 2 ; j++ ){
				nx = cur.first + i, ny = cur.second + j ;
				if( inside( nx, ny, H, W ) && grid[nx][ny] != '#' ){
					if( dist[nx][ny] > dist[cur.first][cur.second] + 1 ){
						dist[nx][ny] = dist[cur.first][cur.second] + 1 ;
						q.push_back( { nx, ny } ) ;					
					}
				}
			}
		}
	}	 
	if( dist[dx][dy] == inf ) cout << -1 ;
	else cout << dist[dx][dy] ;
	return 0 ;
}

Measured memory_bytes: 8572
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll lcd(ll a, ll b) {
	return (a / gcd(a, b)) * b;
}
int main() {
	ll N; cin >> N;
	ll t[100] = {};
	rep(i, 0, N)cin >> t[i];

	ll T = 1;
	rep(i, 0, N) {
		T = lcd(T, t[i]);
	}
	cout << T << endl;
	return 0;
}

Measured memory_bytes: 256