akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<ctime>
#include<queue>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mp(x,y) make_pair(x,y)
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=(ans<<1)+(ans<<3)+ch-'0',ch=getchar();
	return ans*fh;
}
int n;
int main(){
//	freopen("nh.in","r",stdin);
	//freopen("zhy.out","w",stdout);
	n=read();
	if(n%2){
		printf("%d\n",(n-1)*(n-1)/2);
		for(int i=1;i<n;i++){
			for(int j=1;j<=n;j++){
				if(i==j||i+j==n) continue;
				if(j<i) continue;
				printf("%d %d\n",i,j);
			}
		}
		return 0;
	}
	if(n%2==0){
		printf("%d\n",n*(n-2)/2);
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(i==j||i+j==n+1) continue;
				if(i>j) continue;
				printf("%d %d\n",i,j);
			}
		}
	}
	return 0;
}










Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
int n = sc.nextInt();
int amida [] = new int [w];
for(int i =0; i<w; i++){
  amida[i] = i+1;
}
for(int i =0; i< n; i++){
String hon = sc.next();
char c [] = hon.toCharArray();
String line1 = "";
String line2 = "";
int flag  = 0;
for(int k = 0; k<hon.length(); k++){
  if(c[k]==','){ flag++;}
  else if(flag == 0 ){ line1 += c[k];}
  else if(flag == 1) {line2 += c[k];}
}
int m1 = Integer.parseInt(line1);
int m2 = Integer.parseInt(line2);
int connect = 0;
connect = amida[m1-1];
amida[m1-1]=amida[m2-1];
amida[m2-1] = connect;
}
for(int i =0; i<w; i++){
  System.out.println(amida[i]);
}

}
}



Measured memory_bytes: 26292
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

template<typename T>
struct SegmentTree{
    const T INF = 1e18;
    int n, width;
    vector<T> dat;

    void init(int x){
        n = x;
        width = 1;
        while (width < n) width *= 2;
        dat.assign(2*width-1, INF);
    }

    void update(int i, T x){
        i += width - 1;
        dat[i] = x;
        while (i > 0){
            i = (i - 1) / 2;
            dat[i] = min(dat[i*2+1], dat[i*2+2]);
        }
    }

    T query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return dat[k];
        T vl = query(a, b, k*2+1, l, (l+r)/2);
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return min(vl, vr);
    }

    // [l, r)
    T query(int l, int r){
        return query(l, r, 0, 0, width);
    }
};

int main() {
    int n;
    cin >> n;
    VL h(n), a(n);
    REP(i,n) h[i] = in() - 1;
    REP(i,n) a[i] = in();

    SegmentTree<ll> seg;
    seg.init(n);
    REP(i,n) seg.update(i, 0);
    REP(i,n){
        ll ma = -seg.query(0, h[i] + 1);
        seg.update(h[i], -(ma + a[i]));
    }
    cout << -seg.query(0, n) << endl;
    return 0;
}


Measured memory_bytes: 7424
dice = STDIN.readline.chomp.split
dirs = STDIN.readline.chomp.split //

dirs.each do |dir|
    case dir
    when "N"
        dice[0], dice[4], dice[5], dice[1] = dice[1], dice[0], dice[4], dice[5]
    when "W"
        dice[0], dice[2], dice[5], dice[3] = dice[2], dice[5], dice[3], dice[0]
    when "S"
        dice[1], dice[0], dice[4], dice[5] = dice[0], dice[4], dice[5], dice[1]
    when "E"
        dice[2], dice[5], dice[3], dice[0] = dice[0], dice[2], dice[5], dice[3]
    end
end

puts dice[0]

Measured memory_bytes: 8668
#include <iostream>
#include <string>
using namespace std;
struct song
{
    bool x;
    string y;
    int z;
};
int main()
{
   //freopen("A-ATc.inp","r",stdin);
   int n,j;
   cin>>n;
   string X;
   song f[n+1];
   for(int i=1;i<=n;i++)
   {
       cin>>f[i].y;
       cin>>f[i].z;
   }
   cin>>X;
   for(int i=1;i<=n;i++)
   {
       if(f[i].y != X)
       {
           f[i].x=true;
       }
       else
       {
           f[i].x=true;
           j=i;
           break;
       }
   }
   int res=0;
   for(int i=j+1;i<=n;i++)
   {
           res+=f[i].z;
   }
   cout<<res;


}


Measured memory_bytes: 256
//03/05/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;


int main(){
    _fastio
    ll n;
    cin>>n;
    ll a[n+10];
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        mp[i+a[i]]++;
    }

    ll ans=0;
    for(ll i=n;i>=1;i--){
        mp[i+a[i]]--;
        ans+=mp[i-a[i]];
    }
    cout<<ans<<en;




    return 0;
}


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

using namespace std;

int main()
{
    long long int n,a,b;

    cin>>n>>a>>b;

    long long int t = n/(a+b);
    
    long long int ans = t * a;

    if(n - (a+b)*(n/(a+b) ) >= a)
    {
        ans += a;
    }
    else{
        ans += n - (a+b)*(n/(a+b));
    }

    cout<<ans;


  
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=1;i<n;i++)
	    {
	        for(int j=1;j<=min(k,i);j++)
	            if(j==1)
	                dp[i]=dp[i-1]+abs(arr[i]-arr[i-j]);
	            else 
	            {
	                dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
	            }
	    }
	cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
using lnt = long long;
using Real = long double;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)
 
#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
 
constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;
 
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}
 
using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N; cin >> N;
	if(N % 1000 == 0) cout << 0 << ln;
	else cout << 1000*(N/1000+1) - N << ln;
}

Measured memory_bytes: 3684
#include<iostream>
#include<cstdio>

using namespace std;

int hex(char c){
	if(c == 'A') return 10;
	else if(c == 'B') return 11;
	else if(c == 'C') return 12;
	else if(c == 'D') return 13;
	else if(c == 'E') return 14;
	else if(c == 'F') return 15;
}




int main(void){
	char x;
	char y;
	
	scanf("%c %c",&x,&y);
	
	
	
	
	if(hex(x) < hex(y)) printf("<");
	else if (hex(x) > hex(y) ) printf(">");
	else if (hex(x) == hex(y)) printf("=");
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String... args) throws IOException {
	        final int[] charCount = new int[26];
                final StringBuilder sb = new StringBuilder();
	        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			final int charactor = br.read();
			if (97 <= charactor && charactor <= 123) {
				charCount[charactor - 97]++;
			} else if (65 <= charactor && charactor <= 91) {
				charCount[charactor - 65]++;
			} else if (charactor == -1) {
				break;
			}
		}

		for (int i = 0; i < 26; i++) {
			sb.append(((char) (i + 97))).append(" : ").append(charCount[i]).append(i != 25 ? '\n' : "");
		}

		System.out.println(sb);
	}
}

Measured memory_bytes: 16876
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k<=a){
		cout << k << endl;
	}
	else if(k<=b){
		cout << a << endl;
	}
	else{
		cout << (a-(k-(a+b))) << endl;
	}

	return 0;
}  


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    int ans = 0, xxa = 0, bxx = 0, bxa = 0;

    string str;
    for (int i = 0; i < N; i++) {
        cin >> str;
        for (int j = 1; j < str.size(); j++)
            if (str[j - 1] == 'A' && str[j] == 'B')
                ans++;
        if (str[0] == 'B' && str.back() == 'A')
            bxa++;
        else if (str[0] == 'B')
            bxx++;
        else if (str.back() == 'A')
            xxa++;
    }

    if (bxa > 0) {
        ans += bxa - 1;
        bxa = 1;

        if (xxa > 0) {
            ans++;
            xxa--;
        }

        if (bxx > 0) {
            ans++;
            bxx--;
        }
    }

    ans += min(xxa, bxx);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s;
  int a;
  if(s=="RRR") a=3;
  else if(s=="RRS"||s=="SRR") a=2;
  else if(s=="SSS") a=0;
  else a=1;
  cout<<a;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

int n, m, xor_lt[N];
bool visited[N];
vector<int> res;
vector<pair<int, int>> bomb, adj[N];

int dfs(int u) {
  visited[u] = true;
  int cur_xor = xor_lt[u];
  for (auto &e: adj[u]) {
    int v = e.first;
    if (visited[v]) continue;
    if (dfs(v)) {
      res.emplace_back(e.second);
      cur_xor ^= 1;
    }
  }
  return cur_xor;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> m;
  for (int i = 1, a, b; i <= n; ++i) {
    cin >> a >> b;
    bomb.emplace_back(a, b);
  }
  sort(bomb.begin(), bomb.end());
  for (int i = 1, l, r; i <= m; ++i) {
    cin >> l >> r;
    l = lower_bound(bomb.begin(), bomb.end(), make_pair(l, 0)) - bomb.begin() + 1;
    r = upper_bound(bomb.begin(), bomb.end(), make_pair(r, 1)) - bomb.begin() + 1;
    adj[l].emplace_back(r, i);
    adj[r].emplace_back(l, i);
  }
  xor_lt[1] = bomb[0].second;
  for (int i = 2; i <= n; ++i) xor_lt[i] = bomb[i - 1].second ^ bomb[i - 2].second;
  xor_lt[n + 1] = bomb[n - 1].second;
  for (int i = 1; i <= n; ++i) {
    if (visited[i]) continue;
    if (dfs(i)) {
      cout << -1;
      return 0;
    }
  }
  sort(res.begin(), res.end());
  cout << res.size() << "\n";
  for (int x: res) cout << x << " ";
  return 0;
}

Measured memory_bytes: 13172
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
	ll a, b;
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", a / __gcd(a, b) * b);
}



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

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

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if (A > X or A+B < X) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int a,b;
	cin>>a>>b;
	cout<<a*b<<" "<<2*a + 2*b<<endl;
}


Measured memory_bytes: 3084
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N, H[20];

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(H[i]));
        if (i < N - 1) {
            scanf(" ");
        }
    }

    size_t max = 0;
    size_t count = 0;

    for (size_t i = 0; i < N; i++) {
        if (max <= H[i]) {
            count++;
            max = H[i];
        }
    }

    printf("%zu\n", count);

    return 0;
}


Measured memory_bytes: 128
//此程序使用了qt专属名称，请勿模仿。侵权必究！！！ 
//我真是太菜了啊…… 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=210,M=5010,P=1e9+7;
int n,m,b[N][M],l[N][M],r[N][M],top,st[M],num[M];
ll a[M],s[M][M],ans;
inline ll read()
{
	ll sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int main()
{
	scanf("%d%d",&m,&n);
	for(int i=2;i<=m;++i)
	{
		a[i]=a[i-1]+read();
	}
	for(int i=1;i<=m;++i)
	{
		for(int j=1;j<=n;++j)
		{
			b[j][i]=read();
		}
	}
	for(int i=1;i<=n;++i)
	{
		top=0;
		for(int j=1;j<=m;++j)
		{
			while(top&&b[i][j]>st[top])
			{
				--top;
			}
			if(top)
			{
				l[i][j]=num[top]+1;
			} 
			else
			{
				l[i][j]=1;
			}
			st[++top]=b[i][j];
			num[top]=j;
		}
		top=0;
		for(int j=m;j;--j)
		{
			while(top&&b[i][j]>st[top])
			{
				--top;
			}
			if(top)
			{
				r[i][j]=num[top]-1;
			} 
			else
			{
				r[i][j]=m;
			}
			st[++top]=b[i][j];
			num[top]=j;
		}
		for(int j=1;j<=m;++j)
		{
			s[l[i][j]][j]+=b[i][j];
			s[l[i][j]][r[i][j]+1]-=b[i][j];
			s[j+1][j]-=b[i][j];
			s[j+1][r[i][j]+1]+=b[i][j];
		}
	}
	for(int i=1;i<=m;++i)
	{
		for(int j=1;j<=m;++j)
		{
			s[i][j]+=s[i][j-1];
		}
		for(int j=1;j<=m;++j)
		{
			s[i][j]+=s[i-1][j];
		}
		for(int j=i;j<=m;++j)
		{
			ans=max(ans,s[i][j]-a[j]+a[i]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 208512
def checkDoublet(arr):
    count = 0
    for d in arr:
        if d[0] == d[1]:
            count += 1
            if count >= 3:
                return 'Yes'
        else:
            count = 0
    return 'No'

n = int(input())
arr = []
for i in range(n):
    arr.append(list(map(int, input().rstrip().split())))
print(checkDoublet(arr))

Measured memory_bytes: 62516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int k=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(4*i+7*j==N){
        k++;
        break;
      }
    }
    if(k==1)break;
  }
  if(k==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	SPEED;
	ll n,k,t,c=0,i,j,m,cs=0;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>s;
		// n=s.length();
		ll h[26]={0};
		memset(h,0,sizeof(h));
		rep(i,n)
		{
			h[s[i]-'a']++;
		}
		c=1;
		rep(i,26)
		{
			c=(c*(h[i]+1))%hell;
		}
		c--;
		cout<<c;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll r=0;
    r+=floor(n/500)*1000;
    n%=500;
    r+=floor(n/5)*5;
    cout<<r<<'\n';


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		String str[]=new String[100];
		int k=0;
		for(k=0;sc.hasNext();k++)str[k] = sc.next();

		String data[][]=new String[k][100];
		for(int i=0;i<k;i++)
			data[i] = str[i].split(",");  
		int table[][]=new int[k][k];
		for(int i=0;i<(k+1)/2;i++){
			for(int j=0;j<data[i].length;j++){
				table[i-j][j]=Integer.parseInt(data[i][j]);
			}
		}
		int cnt=1;
		for(int i=(k+1)/2;i<k;i++){
			for(int j=0;j<data[i].length;j++){
				table[i-j-cnt][j+cnt]=Integer.parseInt(data[i][j]);
			}
			cnt++;
		}
		
		int dp[][]=new int[k][k];
		for(int i=0;i<k;i++){
			for(int j=0;j<k;j++){
				if(i==0&&j==0)dp[i][j]=table[i][j];
				else if(i==0)dp[i][j]=table[i][j]+dp[i][j-1];
				else if(j==0)dp[i][j]=table[i][j]+dp[i-1][j];
				else if(dp[i-1][j]>=dp[i][j-1]){
					dp[i][j]=table[i][j]+dp[i-1][j];
				}else if(dp[i-1][j]<dp[i][j-1]){
					dp[i][j]=table[i][j]+dp[i][j-1];
				}
				//System.out.println(dp[i][j]);
			}
		}
		System.out.println(dp[k-1][k-1]);
		
		
		


	}
}

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

namespace ITP2_5_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            List<Node> coordinates = new List<Node>();
            for (int i = 0 ; i < n ; i++)
            {
                int[] line = ReadIntAr();
                coordinates.Add(new Node(line[0], line[1]));
            }
            coordinates = coordinates.OrderBy(x => x.X).ThenBy(x => x.Y).ToList();
            foreach (var item in coordinates)
            {
                Console.WriteLine("{0} {1}", item.X, item.Y);
            }
        }

        internal struct Node
        {
            internal int X { get; private set; }
            internal int Y { get; private set; }
            internal Node(int x, int y) { X = x; Y = y; }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

int a[26][2],ans,temp;

char b[110];


int main()
{
    int n;
    scanf("%d%s",&n,b);
    for (int i=0;i<n;i++)
    a[b[i]-97][0]++;
    for (int i=0;i<n;i++)
    {
        if (a[b[i]-97][1]==0 && a[b[i]-97][0]>=2) temp++;
        if (a[b[i]-97][1]>0 && a[b[i]-97][0]==1) temp--;
        a[b[i]-97][1]++;a[b[i]-97][0]--;
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

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



int main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    X=X/50;
    
    int num=0;
    //10,2,1を合計Xにする方法
    for (int i=0; i<=A; i++) {
        for (int k=0; k<=B; k++) {
            for (int l=0; l<=C; l++) {
                if (i*10+k*2+l==X) {
                    num++;
                }
            }
        }
    }
    
    cout<<num;
    return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;
typedef pair<int, int>P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()



int cnt[1000001];
bool isp[1000001];
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	fill(isp + 2, isp + 1000001,true);
	for (int i = 1; i <= 1000000; i++) {
		if (!isp[i])continue;
		int sup = 1000000 / i;
		for (int j = 1; j <= sup; j++) {
			isp[i*j] = false;
			cnt[i*j] += cnt[j];
		}
	}
	int ans = 0;
	rep(i, n)if (cnt[a[i]] == 1)ans++;
	cout << ans << "\n";
}


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


Measured memory_bytes: 9020
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */


signed main() {
	int x;
	std::cin >> x;
	int max = 2e5;
	std::vector<int> primes(max,1);
	for(int i=2;i<max;i++) {
		for(int j=2;j*i<max;j++) {
			primes[i*j]=0;
		}
	}
	for(int i=x;i<max;i++) {
		if(primes[i]==1) {
			print(i);
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct Event {
  int t;
  int x1,x2,y;
  bool operator<(const Event &b) const {
    return y < b.y;
  }
} event[200000];

int table[100005];
bool flag[2][100005];

int main() {
  int n,r;
  while(cin>>n>>r,n||r) {
    int W = 0;
    int H = 0;
    REP(i,n) {
      int x,y,p,q;
      cin>>x>>y>>p>>q;
      x++;y++;p++;q++;
      W = max(W,p);
      H = max(H,q);
      event[i*2]   = (Event){+1,x,p,y};
      event[i*2+1] = (Event){-1,x,p,q};
    }
    sort(event,event+2*n);
    memset(table,0,sizeof(table));
    int id = 0;
    int a = 0;
    int b = 0;
    bool *cur = flag[0];
    bool *pre = flag[1];
    for (int y=1; y<=H+1; ++y) {
      for (;id<2*n&&event[id].y==y;++id)
        for (int x=event[id].x1; x<event[id].x2; ++x)
          table[x] += event[id].t;
      for (int i=1; i<=W; ++i) {
        cur[i] = !!table[i];
        a += cur[i];
        if (cur[i-1] ^ cur[i]) b++;
        if (pre[i] ^ cur[i]) b++;
      }
      swap(cur,pre);
    }
    cout << a << endl;
    if (r == 2) cout << b << endl;
  }
}

Measured memory_bytes: 1924
n = int(input())
C = {}
s = 0
for a in map(int, input().split()):
    if a not in C: C[a] = 0
    C[a] += 1
    s += a
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    if b not in C: C[b] = 0
    if c not in C: C[c] = 0
    s += (c - b) * C[b]
    C[c] += C[b]
    C[b] = 0
    print(s)


Measured memory_bytes: 21908
import sys

N, M = list(map(int, input().split()))

if N == M == 1:
    print(1)
    sys.exit()
elif N == 1 or M == 1:
    print(max(max(N, M)-2, 0))
    sys.exit()

N = max(0, N-2)
M = max(0, M-2)

print(N*M)

Measured memory_bytes: 9064
#include<iostream>
#include<string>
using namespace std;
string S; int n, a;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		S += to_string(a);
	}
	for (int i = 0; i < 100000; i++) {
		string target = to_string(i);
		int x = (int)(S.size()) - (int)(target.size());
		for (int i = 0; i <= x; i++) {
			if (S.substr(i, target.size()) == target) {
				goto E;
			}
		}
		cout << i << endl;
		break;
	E:;
	}
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  int s[] = {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};
  printf("%d", s[n-1]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3708
N = int(input())
W = [int(x) for x in input().split()]
ans = 1000

for i in range(1,N):
    tmp1 = W[:i]
    tmp2 = W[i:]
    #print(tmp1, tmp2)
    if sum(tmp1) >= sum(tmp2):
        if sum(tmp1) - sum(tmp2) < ans:
            ans = sum(tmp1) - sum(tmp2)
            #print(ans)
    else:
        if sum(tmp2) - sum(tmp1) < ans:
            ans = sum(tmp2) - sum(tmp1)
            #print(ans)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main (void){
    int n,k;
    while(cin>>n>>k){
        int sum=0;
        for(int i=0;i<n;i++) cin>>a[i];
        for(int i=0;i<n;i++){
            sum+=min(a[i],abs(k-a[i]));
        }
        cout<<sum*2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
sn = len(s)
t = input()
tn = len(t)
min_match = tn
for i in range(sn-tn+1):
  count = 0
  for j in range(tn):
    if(s[i+j] != t[j]):
      count += 1
  min_match = min(min_match, count)
print(min_match)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    int turn = 1;
    while (1) {
        if (turn) {
            if (++A == B) {
                cout << "Borys" << endl;
                return 0;
            }
        }
        else {
            if (--B == A) {
                cout << "Alice" << endl;
                return 0;
            }
        }
        turn = (turn + 1) % 2;
    }
    return 0;
}

Measured memory_bytes: 3628
import copy

N, K = map(int, input().split())
V = [int(i) for i in input().split()]

result = 0
# i個取る
for i in range(min(N,K)+1):
    #print('i:',i)
    for sp in range(i+1): # 左右の分け方
        #print('right',sp)
        #print('left',i-sp)
        tmp = []
        V_tmp = copy.copy(V)
        #print('元々：',V_tmp)
        tmp.extend(V_tmp[:sp]) # 左端追加
        #print('left',V_tmp[:sp])
        tmp.extend(V_tmp[N-(i-sp):]) #右端追加
        #print('right',V_tmp[N-(i-sp):])
        #print(tmp)
        tmp = sorted(tmp)
        value = sum(tmp)
        # ret個戻す
        for ret in range(0, min(K-i,i)): #残り操作回数か取った石の個数iの小さい方
            if ret < i:
                # マイナスの価値は戻す
                if tmp[ret] < 0:
                    value -= tmp[ret]
                    #print('捨てた宝石：',tmp[ret])
            else:
                break
        result = max(result,value)
            #print()

print(result)


Measured memory_bytes: 3444
#include <iostream>

using lint = long long;

void solve() {
    lint a, b, n;
    std::cin >> a >> b >> n;

    lint x = std::min(n, b - 1);
    std::cout << (a * x / b) - a * (x / b) << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld n, k;
  cin >> n >> k;
  vector<lld> a(n);
  vector<pair<bool, lld>> b(n, make_pair(false, 0));
  b[0] = make_pair(true, 0);
  for (lld i = 0; i < n; i++) {
    cin >> a[i];
  }
  lld c = 0, u = 1;
  while (true) {
    u = a[u - 1];
    c++;
    if (c == k) {
      break;
    }
    if (b[u - 1].first) {
      lld d = (k - c) % (c - b[u - 1].second);
      for (lld i = 0; i < d; i++) {
        u = a[u - 1];
      }
      break;
    } else {
      b[u - 1] = make_pair(true, c);
    }
  }
  cout << u << "\n";
}

Measured memory_bytes: 8012
#include <bits/stdc++.h>
      
#define pb push_back
#define fst first
#define snd second
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
    
using namespace std;
 
typedef long long ll;
typedef long double ld;

signed main(){
	ios;
	int a, b, c;
	cin >> a >> b >> c;
	a = a + b + c;
	if (a >= 22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define INF 1e+9
using namespace std;

int main(){
	int v,e;
	int cost[15][15];
	int dp[1 << 15][15];
	cin >> v >> e;
	for(int i = 0;i < v;i++){
		for(int j = 0;j < v;j++) cost[i][j] = INF;
	}
	for(int i = 0;i < e;i++){
		int s,t,d;
		cin >> s >> t >> d;
		cost[s][t] = d;
	}
	for(int i = 0;i < (1 << v);i++){
		for(int j = 0;j < v;j++) dp[i][j] = INF;
	}
	dp[(1 << v) - 1][0] = 0;
	for(int i = (1 << v) - 2;i >= 0;i--){
		for(int j = 0;j < v;j++){
			for(int k = 0;k < v;k++){
				if(!(i >> k & 1)){
					dp[i][j] = min(dp[i][j],dp[i | 1 << k][k] + cost[j][k]);
				}
			}
		}
	}
	if(dp[0][0] == INF) cout << -1 << endl;
	else cout << dp[0][0] << endl;
	return 0;
}

Measured memory_bytes: 4972
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        scan.close();
        System.out.println(Math.min(N * A, B));
    }
}

Measured memory_bytes: 21716
n,y = map(int,input().split())
li = list(map(int,input().split()))

absli = list(map(lambda x: abs(x - y), li))

def gcd(a, b):
  if (b == 0):
    return a
  return gcd(b, a % b)

tmp = absli[0]
for i in range(n-1):
  tmp = gcd(tmp, absli[i+1])
print(tmp)

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class M { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	private long N;
	private long[] a;
	private long[] sum;
	private bool[,] flag;
	private long[,] memo;
	public void Solve()
	{
		N = GetLong();
		a = GetLongs(N);

		sum = new long[N + 1];
		for(long i = 0; i < N; i++)
			sum[i + 1] = sum[i] + a[i];

		flag = new bool[N, N];
		memo = new long[N, N];
		WriteLine(rec(0, N - 1));
	}

	private long rec(long l, long r)
	{
		if(flag[l, r])
			return memo[l, r];

		flag[l, r] = true;

		if(l == r)
			return (memo[l, r] = 0);

		long min = long.MaxValue;
		for(long i = l; i < r; i++)
			chmin(ref min, rec(l, i) + rec(i + 1, r) + sum[r + 1] - sum[l]);

		return (memo[l, r] = min);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 30128
import java.util.*;
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    static int parent[]; 

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        int M = nextInt();
     
        parent = new int [N+1];
 
           
        ArrayList<Integer> matrix [] = new ArrayList [N+1];

        for (int x=1; x<=N; x++) {
            matrix[x] = new ArrayList<Integer>();
        }

        for (int x=1; x<=M; x++) {
            int one = nextInt();
            int two = nextInt();
            matrix[one].add(two);
            matrix[two].add(one);
        }
    
        bfs(matrix, 1);
        
        boolean flag = true;
        for (int x=1; x<=N; x++) {
            if(parent[x] == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            System.out.println("Yes");
            for (int x=2; x<=N; x++) {
                System.out.println(parent[x]);
            }
        }
        else{
            System.out.println("No");
        }
        
    
    }
        
    public static boolean bfs (ArrayList [] matrix,  int start) {
        Queue <Integer> queue = new LinkedList<Integer>();
        queue.add(start);
        
        while (!queue.isEmpty()) {
            int cur = queue.poll();
            for (int x=0; x<matrix[cur].size(); x++) {
                int now = (int) matrix[cur].get(x);
                if(parent[now]==0){
                    parent[now] = cur;
                    queue.add(now);
                }
            }
        }
        return false;
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}


Measured memory_bytes: 75796
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++) L[i]=A[left+i];
  for(int i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1]=R[n2]=SENTINEL;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n,i;
  cnt=0;

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

  mergeSort(A,n,0,n);
  
  for(i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  
  cout<<cnt<<endl;

  return 0;
}



Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
int N;
const int mod = 1e9 + 7;
using ll = long long;

vector<pair<long long , int>> factraize(int num){
    vector<pair<long long , int>> res;
    for (int i=2; i * i < N; i++){
        if (num % i != 0) continue;
        res.emplace_back(i, 0);
        while(num % i  == 0){
            res.back().second++;
            num /= i; 
        }
    }
    if (num != 1) res.emplace_back(num, 1);
    return res;
}

int main(void){
    cin >> N;
    unordered_map<long long, int> mp;
    for (int i=1; i<= N; i++){
        vector<pair<long long , int>> res =  factraize(i);   
        // cout << res.size() << endl;
        for (auto it: res){
            mp[it.first] += it.second;
            // cout << it.first << " " << it.second << endl;
        }
    }    
    
    long long ans = 1;
    for (auto it: mp){
        // cout << it.second << endl;
        ans *= (it.second + 1);
        ans %= mod;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	vector <int> v;
	int n,k,a,sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<k;i++)
	{
		sum=sum+v[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;

namespace kozaiyApp
{
    public class MinimumSpanningTree
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int v = int.Parse(input[0]); // 頂点の数
            int e = int.Parse(input[1]); // 辺の数
            List<edge> edges = new List<edge>();

            for (int i = 0; i < e; i++)
            {
                string[] inputEdge = Console.ReadLine().Split(' ');
                edge edgeItem = new edge
                {
                    S = int.Parse(inputEdge[0]),
                    T = int.Parse(inputEdge[1]),
                    Cost = int.Parse(inputEdge[2])
                };
                edges.Add(edgeItem);
            }
            edges.Sort((a, b) => a.Cost - b.Cost); // Costが小さい順にソート

            int res = 0;
            UnionFind U = new UnionFind(v); // UnionFind 初期化
            for (int i = 0; i < e; i++)
            {
                edge eg = edges[i];
                if (!U.same(eg.S, eg.T)) // 同じ集合に属していない(=繋げても閉路にならない)場合のみ、木に併合する
                {
                    U.unite(eg.S, eg.T);
                    res += eg.Cost;
                }
            }

            Console.WriteLine(res);
        }


        public class edge
        {
            public int S { get; set; }
            public int T { get; set; }
            public int Cost { get; set; }
        }

        //// ---- union find ----
        public class UnionFind
        {
            int[] par; // 親
            int[] rank; // 深さ

            // n要素で初期化
            public UnionFind(int n)
            {
                par = new int[n];
                rank = new int[n];

                for (int i = 0; i < n; i++)
                {
                    par[i] = i;
                    rank[i] = 0;
                }
            }

            // 集合を併合する
            public void unite(int x, int y)
            {
                x = find(x); // xの根
                y = find(y); // yの根
                if (x == y) return;

                par[y] = x;
            }

            // 根を調べる
            public int find(int n)
            {
                if (par[n] == n)
                {
                    return n;
                }
                else
                {
                    return par[n] = find(par[n]); // 経路圧縮
                }
            }

            // xとyが同じ集合に属するか否か
            public bool same(int x, int y)
            {
                return find(x) == find(y);
            }
        }
    }
}



Measured memory_bytes: 26376
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b,i;
        scanf("%d %d",&a,&b);
        if (b%a == 0)
        {
            printf("%d\n",a+b);
        }

        else
        {
            printf("%d\n",b-a);
        }

    return 0;
}


Measured memory_bytes: 128