akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll x[100004] = {};
	ll y[100004] = {};
	ll z[100004] = {};
	string s;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);

	cin >> a;
	cin >> b;
	vector<pair<ll, ll> > hoges(a);
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
		cin >> y[i];
		hoges[i] = make_pair(x[i], y[i]);
	}
	sort(hoges.begin(),hoges.end(),comp);
	for (int i = 0; i < a; i++)
	{
		if (hoges[i].second>=b)
		{
			ans += hoges[i].first*b;
			break;
		}
		else
		{
			ans += hoges[i].first*hoges[i].second;
			b -= hoges[i].second;

		}
	}


	cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//sort(x, x + a, std::greater<ll>());

//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

using namespace std;

int main() {
    int n;
    cin >> n;
    set<int> a;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        a.insert(tmp);
    }
    cout << a.size() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
const int mxn = 1*(1e5) + 5;
ll n, m;
 
void solve(){
	cin >> n;
	if(n%2 == 0 || n%5 == 0) {
		cout<<"-1";
		return;
	} 
	int ans = -1;
	int r = 7;
	int c = 0;
	while(r%n && c<=n) {
		r %= n;
		c++;
		r = r*10 + 7;
	}
	if(c > n) {
		cout<<"-1";
		return;
	}
	cout<<c+1;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   freopen("output.txt", "w", stdout); 
   #endif 
   
	// tt
		solve();
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,q;
const int N=55;
int a[N],b[N],c[N],d[N];
int ans;
int w[12];                                 //存搜索的数字用
int calc(){
    int res=0;
    for(int i=1;i<=q;i++){
        if(w[b[i]]-w[a[i]]==c[i]) res+=d[i];
    }    
    return res;
}
void dfs(int cur){
    if(cur>n){
        ans=max(ans,calc());
        return;
    }
    for(int i=w[cur-1];i<=m;i++){
        w[cur]=i;
        dfs(cur+1);
    }
}
int main(){
    
    cin>>n>>m>>q;
    w[1]=1;
    for(int i=1;i<=q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    
    dfs(2);
    
    cout<<ans<<endl;
    
    return 0;
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

class RAQ {
public:
	struct Node {
		UL sum, buf;
		Node(UL s, UL b) : sum(s), buf(b) {}
	};
	vector<Node> node;
	UL N;
	UL n;
	void init(UL n) {
		N = 1;
		while (N < n)N <<= 1;
		this->n = n;
		node.assign(N * 2 - 1, Node(0, 0));
	}
	UL query(UL a, UL b, UL l = 0, UL r = -1, UL i = 0) {
		if (r == -1) r = N;
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) return node[i].sum;
		int rag = min(r, b) - max(l, a);
		return query(a, b, l, (l + r) / 2, i * 2 + 1) + query(a, b, (l + r) / 2, r, i * 2 + 2) + node[i].buf * rag;
	}
	void update(UL a, UL b, UL v, UL l = 0, UL r = -1, UL i = 0) {
		if (r == -1) r = N;
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) { node[i].buf += v; node[i].sum += v * (r - l); return; }

		update(a, b, v, l, (l + r) / 2, i * 2 + 1);
		update(a, b, v, (l + r) / 2, r, i * 2 + 2);

		node[i].sum = node[i * 2 + 1].sum + node[i * 2 + 2].sum + node[i].buf * (r - l);
	}

};

struct Problem {

	static const ULL M = 998244353;

	void Solve() {
		UL N; cin >> N;
		vector<pair<int, int>> P(N);
		rep(i, N) cin >> P[i].first >> P[i].second;
		rep(t, 2) {
			sort(P.begin(), P.end());
			rep(i, N) { P[i].first = i; swap(P[i].first, P[i].second); }
		}
		vector<pair<ULL, ULL>> F(N), B(N);
		RAQ Q; Q.init(N);
		//rep(i, N) cout << P[i].first << " "; cout << endl;
		rep(i, N) {
			UL p = P[i].first;
			F[p].first = Q.query(0, p);
			F[p].second = i - F[p].first;
			Q.update(p, p + 1, 1);
		}
		reverse(P.begin(), P.end());
		Q.init(N);
		rep(i, N) {
			UL p = P[i].first;
			B[p].first = Q.query(0, p);
			B[p].second = i - B[p].first;
			Q.update(p, p + 1, 1);
		}
		ULL ans = 0;
		vector<ULL> pow2(N + 1); pow2[0] = 1;
		rep(i, N) pow2[i + 1] = pow2[i] * 2 % M;
		rep(i, N) {
			ans += pow2[N] - 1;
			ans += M - pow2[F[i].first + F[i].second];
			ans += M - pow2[B[i].first + B[i].second];
			ans += M - pow2[F[i].first + B[i].first];
			ans += M - pow2[B[i].second + F[i].second];
			ans += pow2[F[i].first];
			ans += pow2[F[i].second];
			ans += pow2[B[i].first];
			ans += pow2[B[i].second];
			ans %= M;
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 13696
#include <stdio.h>

int main(void) {
	int n,m,a,b;
	int tree[100000] = {0};
	
	scanf("%d %d",&n,&m);
	
	for (int i = 0;i < m;i++) {
		scanf("%d %d",&a,&b);
		tree[a-1]++;
		tree[b-1]++;
	}
	
	for (int i = 0;i < n;i++) {
		if (tree[i]%2) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll l;
  cin >> l;

  ll lb = l * 1e6;
  long double hen = lb / 3;
  long double vol = hen * hen * hen;

  double ans = vol / 1e18;

  printf("%.12f\n", ans);

  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++)
int main(void){
    int A,B;
    
    cin >> A >> B;
    
    if(A != B)
    {
        cout << max(A, B) * 2 - 1 << endl;
    }
    else
    {
        cout << A * 2 << endl;
    }
}


Measured memory_bytes: 256
from collections import Counter

def main():
    
    N = int(input())
    V = list(map(int,input().split()))
    odd = V[1::2]
    even = V[0::2]
    mode_o = Counter(odd).most_common()
    mode_o.append([0,0])
    mode_e = Counter(even).most_common()
    mode_e.append([0,0])
    ans = 0
    if mode_o[0][0] != mode_e[0][0]:
        ans = N-mode_o[0][1]-mode_e[0][1]
    else:
        ans = N - max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21084
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
const int INF = 1001001001;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n),b(n);
    rep(i, n) cin >> a.at(i) >> b.at(i);
    vector<int> dp(h+1, INF);
    dp.at(0) = 0;
    for(int i=0; i<n; i++){
       rep(j, h){
           int nj = min(j+a.at(i), h);
           dp.at(nj) = min(dp.at(nj), dp.at(j)+b.at(i));
       }
    }

    cout << dp.at(h) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << 'A' << b.at(0) << 'C' << endl;
}

Measured memory_bytes: 256
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

int main(){
	fastio;
	ll n; cin>>n;
	ll ans = 0;
	For(i,1,n+1){
		ll times = n/i;
		ans += i * (times)*(times+1)/2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3616
#include<stdio.h>
int main(){
    long long n,sum=0,T,max,min;
    scanf("%lld",&T);
    for(int i=1; i<=T; i++){
        scanf("%lld ",&n);
        if(i==1)
            max=min=n;
        if(max<n)
            max=n;
        else if(min>n)
            min=n;
        sum=sum+n;
    }
    printf("%d %d %lld\n",min,max,sum);
  return 0;
}



Measured memory_bytes: 2104
def main():
    n = int(input())
    h = list(map(int, input().split()))
    flag = True
    for i in range(n-1):
        if h[i+1] - h[i] == 0:
            continue
        elif h[i+1] - h[i] >= 1:
            h[i+1] = h[i+1] - 1
        else:
            flag = False 
    if flag:
        print('Yes')
    else:
        print('No')
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 20560
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long X = scan.nextLong();
		long K = scan.nextLong();
		long D = scan.nextLong();

		long p = Math.abs(X)/D;
		long q = Math.abs(X)%D;
		if(D/2<q){
			p++;
			q=D-q;
		}
		if(K<p){
			System.out.println(Math.abs(Math.abs(X)-K*D));
		}else if((K-p)%2==0){
			System.out.println(q);
		}else{
			System.out.println(D-q);
		}
	}
}

Measured memory_bytes: 27048
//=============================================================
// Name        : b
// Date        : Mon Jun 10 10:13:13 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//=============================================================
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n), pr(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    pr[i + 1] = pr[i] + a[i];
  }
  int ans = 1e9;
  for (int i = 0; i < n; ++i) {
    int s1 = pr[i + 1] - pr[0];
    int s2 = pr[n] - pr[i + 1];
    ans = min(ans, abs(s1 - s2));
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
 
*/
/* }}} */
 
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* cpp template {{{ */
 
/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
 
/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)
 
/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
 
/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
 
/* }}} */
 
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n = in(); int k = in();
  vector<char> d(k);
  REP(i, k) cin >> d[i];
  
  for (int i = n;; i++) {
    stringstream ss;
    ss << i;
    string s = ss.str();
    //print(s);
    bool flg = true;
    REP(j, k) {
      if (s.find_first_of(d[j]) != -1) {
        flg = false;
        break;
      }
    }
    if (flg) {
      print(s);
      break;
    }
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    char J[10000];
    int i,JOI,IOI;
    while(scanf("%s",J)!=EOF){
        JOI=0;
        IOI=0;
        for(i=2;;i++){
            if(J[i]=='\0')break;
            if(J[i-2]=='J'&&J[i-1]=='O'&&J[i]=='I'){
                JOI++;
            }
            if(J[i-2]=='I'&&J[i-1]=='O'&&J[i]=='I'){
                IOI++;
            }
        }
        printf("%d\n%d\n",JOI,IOI);
    }
return 0;
}

Measured memory_bytes: 552
#include <cstdio>
#include <numeric>
const int MAXN = 3005;
double dp[MAXN][MAXN];
double P[MAXN];
int N;

// dp[i][j] = p of landing j heads after tossing first i coins.

double solve() {
  for (int j = 0; j <= N; ++j) dp[0][j] = 0.0;
  dp[0][0] = 1.0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i][j] = (1 - P[i]) * dp[i-1][j];
      if (j == 0) continue;
      dp[i][j] += P[i] * dp[i-1][j-1];
    }
  }
  int half = (N + 1) / 2;
  return std::accumulate(dp[N] + half, dp[N] + N + 1, 0.0);
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%lf", &P[i]);
  }
  printf("%.12f\n", solve());
  return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <cstdint>
#include <string>
#include <sstream>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

int main()
{
  int N;
  string tmp;
  Bint ans = 1;
  Bint lim("1000000000000000000");

  vector<Bint> vec;

  cin >> N;

  for(int i=0; i<N; ++i){
    cin >> tmp;
    vec.push_back(Bint(tmp));
  }

  sort(vec.begin(), vec.end(), greater<Bint>());

  if(vec.back() == 0){
    cout << 0 << endl;
    return 0;
  }

  for(int i=0; i<N; ++i){
    ans *= vec[i];

    if(ans > lim){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

    if(S == "SUN")
        cout << "7" << endl;
    if(S == "SAT")
        cout << "1" << endl;
    if(S == "MON")
        cout << "6" << endl;
    if(S == "TUE")
        cout << "5" << endl;
    if(S == "WED")
        cout << "4" << endl;
    if(S == "THU")
        cout << "3" << endl;
    if(S == "FRI")
        cout << "2" << endl;
}

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

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

    long long n, a, b;
    cin >> n >> a >> b;

    cout << n / (a + b) * a + min(n % (a + b), a) << "\n";

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int a = 1, b = 2, c = 3;
	int n, x;
	int cnt = 0;

	while (1) {
		cnt = 0;
		scanf("%d %d", &n, &x);

		if (n == 0 && x == 0) {
			break;
		}

		for (a = n; a >= 1; a--) {
			for (b = a - 1; b >= 1; b--) {
				for (c = b - 1; c >= 1; c--) {
					if (a + b + c == x) {
						cnt++;
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}


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

int main(){

	string z, y, x;
	cin>>x>>y>>z;
	if(x[x.size() - 1] == y[0] && y[y.size() - 1] == z[0]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
N = int(input())
P = input().split(' ')
P = [int(P[i]) for i in range(N)]
count = 0
PS = []
min = 2*10**5+1
for i in range(N):
  p = P[i]
  if p<=min:
    min = p
    count += 1
print(count)
  

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

using Graph = vector<Vi>;
Graph g;
vector<Vi> color(2);

void dfs(int k, int p, int c) {
    color[c].push_back(k);
    for (const auto& to : g[k]) {
        if (to == p) continue;
        dfs(to, k, 1 - c);
    }
}

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

    int N;
    cin >> N;
    g.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0, -1, 0);

    Vi ans(N);

    int num0 = color[0].size();
    int num1 = color[1].size();

    stack<int> stk[3];
    for (int i = 1; i <= N; i++) {
        stk[i % 3].push(i);
    }

    if (num0 <= N / 3) {
        for (int i = 0; i < num0; i++) {
            ans[color[0][i]] = stk[0].top();
            stk[0].pop();
        }
        for (int i = 0; i < num1; i++) {
            if (stk[0].size()) {
                ans[color[1][i]] = stk[0].top();
                stk[0].pop();
            }
            else if (stk[1].size()) {
                ans[color[1][i]] = stk[1].top();
                stk[1].pop();
            }
            else if (stk[2].size()) {
                ans[color[1][i]] = stk[2].top();
                stk[2].pop();
            }
        }
    }
    else if (num1 <= N / 3) {
        for (int i = 0; i < num1; i++) {
            ans[color[1][i]] = stk[0].top();
            stk[0].pop();
        }
        for (int i = 0; i < num0; i++) {
            if (stk[0].size()) {
                ans[color[0][i]] = stk[0].top();
                stk[0].pop();
            }
            else if (stk[1].size()) {
                ans[color[0][i]] = stk[1].top();
                stk[1].pop();
            }
            else if (stk[2].size()) {
                ans[color[0][i]] = stk[2].top();
                stk[2].pop();
            }
        }
    }
    else {
        for (int i = 0; i < num0; i++) {
            if (stk[1].size()) {
                ans[color[0][i]] = stk[1].top();
                stk[1].pop();
            }
            else if (stk[0].size()) {
                ans[color[0][i]] = stk[0].top();
                stk[0].pop();
            }
        }
        for (int i = 0; i < num1; i++) {
            if (stk[2].size()) {
                ans[color[1][i]] = stk[2].top();
                stk[2].pop();
            }
            else if (stk[0].size()) {
                ans[color[1][i]] = stk[0].top();
                stk[0].pop();
            }
        }
    }

    for (int i = 0; i < N - 1; i++) {
        cout << ans[i] << " ";
    }
    cout << ans[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 20980
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];  
  A.erase(unique(A.begin(), A.end()), A.end());
  int ans = 1;
  FOR(i, 2, A.size()) {
    if ((A[i - 2] < A[i - 1] && A[i - 1] > A[i]) ||
        (A[i - 2] > A[i - 1] && A[i - 1] < A[i])) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3980
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	int u, v;
	ll cost;
};

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

#define N 100010

int par[N];
int urank[N];

void init(int n) {
	REP(i, n) {
		par[i] = i;
		urank[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

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

	if (urank[x] < urank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (urank[x] == urank[y]) urank[x]++;
	}
}

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

edge es[N];

bool used[N];
int V, E;

ll kruskal() {
	sort(es, es + E, comp);
	init(V);
	ll res = 0;
	REP(i, E) {
		edge e = es[i];
		if (!same(e.u, e.v) && !used[e.u] && !used[e.v]) {
			unite(e.u, e.v);
			res += e.cost;
			used[e.u] = used[e.v] = true;
		}
	}
	return res;
}

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


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC133B()
{
	int N, D;
	cin >> N >> D;

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

	int ct = 0;
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < i; ++j)
		{
			int dist = 0;
			for (int k = 0; k < D; ++k)
			{
				int x = (points[i][k] - points[j][k]);
				dist += x * x;
			}
			int sqrtD = static_cast<int>(sqrt(static_cast<double>(dist))+0.0001);
			if (sqrtD * sqrtD == dist)
				++ct;
		}
	}
	cout << ct << endl;

}

int main()
{
	ABC133B();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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






int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    for(int i = a; i >= 1; i--){
        if(!(a % i | b % i)){
            cnt++;
        }
        if(cnt == k){
            cout << i << endl;
            return 0;
        }
    }
}


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

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	long long int n,count=0,a,i=0,d;
  char c;
char alpha[27]={'z','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'},temp[1000000];
	scanf("%lld",&n);
  while(1){
    if(n==0){
    break;
    }
  temp[i]=alpha[n%26];
    i++;
    if(n%26==0){
    n=n/26-1;
    }
    else{
      n=(n-n%26)/26;
    }
  }
  for(int j=0; j<i;j++){
  printf("%c",temp[i-j-1]);
  }
  printf("\n");
return 0;
}


Measured memory_bytes: 1652
from collections import deque

S=deque(input())
Q=int(input())

t=True

for i in range(Q):
  query=input().split()
  if query[0]=='1':
    t = not t
  else:
    if (t and query[1]=='1') or (not t and query[1]=='2'):
      S.appendleft(query[2])
    else:
      S.append(query[2])

S=''.join(S)

if not t:
  S=S[::-1]

print(S)

Measured memory_bytes: 8436
#include <bits/stdc++.h>
#define ri register
//#define int long long
#define E (n+1)
using namespace std; const int N=1000010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,a[N],res,book[N];
signed main()
{
    n=read();
    for(ri int i=1;i<=n;i++) a[i]=read();
    res=a[1];
    for(ri int i=2;i<=n;i++) res=__gcd(res,a[i]);
    int flg=1;
    for(ri int i=1;i<=n;i++)
    {
        if(!flg) break;
        int x=a[i];
        for(ri int j=2;j*j<=x;j++)
        {
            if(x%j) continue;
            while(x%j==0) x/=j;
            if(book[j]) { flg=0; break; }
            book[j]=1;
        }
        if(x>1)
        {
            if(book[x]) { flg=0; break; }
            book[x]=1;
        }
    }
    if(flg) puts("pairwise coprime");
    else if(res==1) puts("setwise coprime");
    else puts("not coprime");
    return 0;
}

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

#define ll long long int
#define ld long double
#define clr(arr) memset(arr,0,sizeof(arr))
#define nn '\n'

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

    int t = 1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        if(n>=30) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; int k;
    cin >> n >> k;
    int cnt = 0,K = k;
    while(n>=K){
        K *= k;
        cnt++;
    }
    cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int w = sc.nextInt();
			int n = sc.nextInt();
			int[] values = new int[w];
			for(int i = 0; i < values.length; i++){
				values[i] = i + 1;
			}
			for(int j = 0; j < n; j++){
				String str = sc.next();
				String[] ab = str.split(",");
				int a = Integer.parseInt(ab[0]) - 1;
				int b = Integer.parseInt(ab[1]) - 1;
				int num = values[a];
				values[a] = values[b];
				values[b] = num;
			}
			for(int k = 0; k < values.length; k++){
				System.out.println(values[k]);
			}
		}
	}
}


Measured memory_bytes: 26392
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
A = LI()

tmp = 0
for a in A:
    tmp += 1/a

print(1/tmp)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){
    int N;
    cin >> N;
    //cout << N/1000.0 << endl;
    //cout << N-1000*(N/1000.0) << endl;
    if(N%1000 == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1000-N%1000 << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxm=2e3+5;
const int mod=1e9+7;
int d[maxm];
int n;
signed main(){
    cin>>n;
    d[0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i-3;j++)
		{
            d[i]+=d[j];
            d[i]%=mod;
        }
    }
    cout<<d[n]<<endl;
    return 0;
}


Measured memory_bytes: 3628
#pragma GCC diagnostic ignored "-Wunused-result"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = (int)1e6 + 34;
const ll INF = (ll)1e18 + 41;
//const int INF = (int)1e9 + 41;
const ll MD = (ll)1e9 + 7;
bool D = false;

void solve() {
	int n;
	cin >> n;
	cout << "Christmas";
	for (int i = n; i < 25; i++) {
		cout << " Eve";
	}
	cout << "\n";
}

int main() {
#ifdef LOCAL
	freopen("a.in", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tst = 1;
	//scanf("%d", &tst);
	//cin >> tst;
#ifdef MADE_BY_SERT
	D = true;	
	tst = 5;
	while (tst--) {
		solve();
	}
#else
	while (tst--) solve();
#endif
}


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

int main() {
    long long H;
    cin >> H;
    int count = 0;
    while (H) {
        ++count;
        H /= 2;
    }
    long long ret = 1;
    for (int i = 0; i < count; i++) {
        ret *= 2;
    }
    --ret;
    cout << ret << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    int ans=0;
    while(n--)
    {
        int x;
        cin >> x;
        if(!(a<=x&&x<b))
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

struct point{
    int x,y;
};

struct vec{
    point left, right;
};


double dot( vec a, vec b ){
    double x1 = a.left.x-a.right.x;
    double x2 = b.left.x-b.right.x;

    double y1 = a.left.y-a.right.y;
    double y2 = b.left.y-b.right.y;

    return x1*x2+y1*y2;
}

double norm( vec a ){
    return sqrt(dot(a,a));
}

double f( vec a, vec b ){
    assert( norm(a)!=0 );
    assert( norm(b)!=0 );
    return 180*acos( dot(a,b)/norm(a)/norm(b) )/3.14159265;
}

int main(){
    int n;
    cin>>n;

    vector<point> vp;
    for( int i=0; i<n; ++i ){
        int x,y;
        cin>>x>>y;
        vp.emplace_back(point{x,y});
    }

    vector<int> num;
    for( int i=0; i<n; ++i ){
        num.emplace_back(i);
    }
    double ans = 1e8;

    do{
        vector<point> tmp;
        tmp.push_back(point{0,0});
        
        for( auto elm: num ){
            tmp.emplace_back(point{vp[elm]});
        }
        tmp.push_back(point{0,0});

        double cand = 0;
        for( int i=0; i<(int)tmp.size()-1; ++i ){
            if( i==0 ){
                vec a = vec{tmp[i  ], tmp[i+1]};
                vec def = vec{point{0,0}, point{1,0}};
                cand += f( a, def );
            }else{
                vec a = vec{tmp[i-1], tmp[i  ]};
                vec b = vec{tmp[i  ], tmp[i+1]};
                cand += f( a, b );
            }
        }
        ans = min( ans, cand );
    }while(next_permutation( num.begin(), num.end() ));
    cout << std::setprecision(10) << ans << endl;
}    



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

using namespace std;

typedef long long ll;

int main(){
  ll N, K;
  cin >> N >> K;

  vector<ll> A(N);
  for(ll i=0; i<N; i++) cin >> A[i];

  ll s = 0;
  ll e = K;
  for(ll i=K+1; i<=N; i++){
    string ret = (A[e] > A[s]) ? "Yes" : "No";
    cout << ret << endl;
    ++s;
    ++e;
  }

  return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){

  CIN(n);VC1(n,a);
  M m;
  REP(i,n){
    if(a[i]%4==0)m[2]++;
    else if(a[i]%2==0)m[1]++;
    else m[0]++;
  }
  m[0]+=(m[1]!=0);
  int x = m[0];//割り切れない
  int y = m[2];
  Yes(x<=y+1);


  return 0;
}

Measured memory_bytes: 1024
n = int(input())
V = list(map(int, input().split()))
#まず偶奇分けして二つの配列にします
Vodd = []
Veven = []
for i in range(n//2):
  Vodd.append(V[2*i])
  Veven.append(V[2*i+1])
#それぞれの配列の最頻と2番目を探します
import collections
Codd = collections.Counter(Vodd)
Ceven = collections.Counter(Veven)
cmlstodd = Codd.most_common()
cmlsteven = Ceven.most_common()
#print(cmlstodd, cmlsteven)
#仕方ないのでここからは地道に場合分けします
if len(cmlstodd)==1:
  if cmlstodd[0][0] == cmlsteven[0][0]:
    if len(cmlsteven)==1:
      print(n//2)
    else:
      print(n//2 - cmlsteven[1][1])
  else:
    print(n//2 - cmlsteven[0][1])
elif len(cmlsteven)==1:
  if cmlsteven[0][0] == cmlstodd[0][0]:
    print(n//2 - cmlstodd[1][1])
  else:
    print(n//2 - cmlstodd[0][1])
else:
  if cmlsteven[0][0] == cmlstodd[0][0]:
    print(n - max(cmlsteven[0][1] + cmlstodd[1][1], cmlsteven[1][1] + cmlstodd[0][1]))
  else:
    print(n - cmlstodd[0][1] - cmlsteven[0][1])

Measured memory_bytes: 23972
N = int(input())
count_all = 0
def count_yakusuu(N):
    count = 0
    for i in range(3, int(N/3)+1):
        if N % i == 0:
            count += 1
    if count == 6:
        return True
    else:
        return False
for k in range(N+1):
    if k % 2 == 1:
        if count_yakusuu(k):
            count_all += 1
print(count_all)

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

template <typename T>
void debug_out(T t) {
  cerr << t;
}

template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}

template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << ", ";
  }
}

template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << endl;
  }
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__), cerr << endl;

struct edge {
  int u, v;
  edge(){};
  edge(int _u, int _v) : u(_u), v(_v) {};
};

void debug_out(edge a) {
  debug_out(make_pair(a.u, a.v));
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<edge> edges;
  range(i, 0, m) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--; v--;
    g[u].push_back(i);
    g[v].push_back(i);
    edges.emplace_back(u, v);
  }
  vector<int> used(m);
  int easy = 0;
  int foo = 0;
  range(i, 0, n) {
    int sz = g[i].size();
    if(sz & 1) {
      cout << "No";
      return 0;
    }
    if(sz == 4) foo++;
    easy = max(easy, sz);
  }
  if(easy > 4 || foo > 2) {
    cout << "Yes";
    return 0;
  }
  int cnt = 0;
  vector<int> cur;
  set<pair<int, int>> to;
  vector<int> was(n);
  vector<int> pas(n);
  function<void(int, int)> dfs = [&](int v, int par) {
    if(!to.empty()) return;
    cur.push_back(v);
    was[v] = 1;
    pas[v] = 1;
    int s = -1;
    for(int p : g[v]) {
      if(used[p]) continue;
      int u = (edges[p].u == v ? edges[p].v : edges[p].u);
      if(u == par) continue;
      if(was[u]) s = u;
    }
    if(~s) {
      reverse(cur.begin(), cur.end());
      while(cur.back() != s) cur.pop_back();
      range(i, 0, (int) cur.size()) to.insert(make_pair(cur[i], cur[(i + 1) % cur.size()]));
      return;
    }
    for(int p : g[v]) {
      if(used[p]) continue;
      int u = edges[p].u == v ? edges[p].v : edges[p].u;
      if(u == par) continue;
      if(!pas[u]) dfs(u, v);
      if(!to.empty()) return;
    }
    was[v] = 0;
    cur.pop_back();
  };
  dfs(0, -1);
  assert(to.size());
  A:;
  debug(cur);
  cnt++;
  range(i, 0, m) {
    pair<int, int> s = make_pair(edges[i].u, edges[i].v);
    if(to.find(s) != to.end()) used[i] = 1;
    swap(s.first, s.second);
    if(to.find(s) != to.end()) used[i] = 1;
  }
  if(*min_element(used.begin(), used.end()) == 1) {
    cout << "No";
    return 0;
  }
  if(cnt == 2) {
    cout << "Yes";
    return 0;
  }
  range(i, 0, m) {
    if(!used[i]) {
      int u = edges[i].u;
      cur.clear(); to.clear();
      fill(was.begin(), was.end(), 0);
      fill(pas.begin(), pas.end(), 0);
      dfs(u, -1);
      goto A;
    }
  }
  return 0;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
    cout << "No\n";
  } else if (a == b || b == c || c == a) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 768
from collections import Counter

from scipy.misc import comb
#a = comb(n, r, exact=True)

N, A, B = list(map(int, input().split()))
V = list(map(int, input().split()))

V.sort(reverse = True)
C = Counter(V)

print(sum(V[:A]) / A)

max_value = V[0]

# V[0], ... V[A-1] がすべて同じとき、そうでないときで異なる
# V[0], ... V[A-1] に異なるものが含まれると、Aコ選ぶときがMAX
key_value = V[A-1]
if key_value < max_value:
  # V[A-1]の個数と、その前に何個あるかを数えればよい
  forward_item_count = 0
  for k,v in C.items():
    if k > key_value:
      forward_item_count += v

  print(int(comb(C[key_value], A - forward_item_count, exact=True)))
  exit(0)
  
# すべて同じときはAコ～Bコ選んでも平均一緒。組み合わせ数を足していく必要性
ans = 0
cnts = C[key_value]
for i in range(A,B+1):
  ans += comb(cnts,i, exact=True)
  
print(int(ans))

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

int main(void)
{
  int n,a[101];
  cin >> n;
  for(int i = 0; i < n ; i++) cin >> a[i];
  
  for(int i = 0 ; i < n ;i++)
  {
    if(a[i] % 2 == 0)
    {
      if(a[i] % 3 == 0 || a[i] % 5 == 0)continue;
      else
      {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
using namespace std; 
typedef long long int ll;

void solve(){
    int n,sum1=0,sum2=0;cin>>n;
    string s;cin>>s;
    for(char c:s) if(c=='R') sum1++;
    for(int i=0;i<sum1;i++){
       if(s[i]=='R') sum2++;
    }
    cout<<sum1-sum2;
}

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

Measured memory_bytes: 3736
N,A,B=[int(i) for i in input().split(" ")]
v=[int(i) for i in input().split(" ")]

v.sort()
v.reverse()

def average(l,a):
    sum=0
    for i in range(a):
        sum+=l[i]
    return (sum/a)


kaijoulist=[1,1]
def kaijou(n):
    t=len(kaijoulist)
    while t<=n:
        kaijoulist.append(kaijoulist[-1]*t)
        t+=1
    return kaijoulist[n]

def combination(n,k):
    return int(kaijou(n)/(kaijou(k)*kaijou(n-k)))



max_index=[A]
max=average(v,A)
for i in range(A+1,B+1):
    ave=average(v,i)
    if max<ave:
        max_index=[i]
        max=ave
    elif max==ave:
        max_index.append(i)

li_uniq = list(set(max_index))



answer=0
for i in li_uniq:
    x=v[i-1]
    kosuu=v.count(x)
    sentou=v.index(x)
    answer+=combination(kosuu,i-sentou)

print(max)
print(answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
int aa,bb,cc,n;
vector<string>s;
vector<char>v;

void cal(int i,int a,int b,int c){ 
    if(i==n){ 
        if(a>=0&&b>=0&&c>=0){ 
            cout<<"Yes"<<'\n';
            for(int j=0;j<n;j++){ 
                cout<<v[j]<<'\n';
            }
            exit(0);
        }
        return ;
    } 
    if(s[i]=="AB"){ 
        if(a-1>=0){ 
            v.push_back('B');
            cal(i+1,a-1,b+1,c);
            v.pop_back();
        }
        if(b-1>=0){ 
            v.push_back('A');
            cal(i+1,a+1,b-1,c);
        }
    } 
    //***
    if(s[i]=="AC"){ 
        if(a-1>=0){ 
            v.push_back('C');
            cal(i+1,a-1,b,c+1);
            v.pop_back();
        }
        if(c-1>=0){
            v.push_back('A');
            cal(i+1,a+1,b,c-1);
         
        }
    } 
    //****
    if(s[i]=="BC"){ 
        if(c-1>=0){ 
            v.push_back('B');
            cal(i+1,a,b+1,c-1);
            v.pop_back();
        }
        if(b-1>=0){ 
            v.push_back('C');
            cal(i+1,a,b-1,c+1);
           
        }
    } 
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>aa>>bb>>cc;
    for(int i=0;i<n;i++){
        string ss;
        cin>>ss;
        s.push_back(ss);
    } 
    cal(0,aa,bb,cc);
    cout<<"No"<<'\n';
    
    
    return 0;
}


Measured memory_bytes: 16092
#include<cstdio>
#include<vector>

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

using namespace std;

const int INF=1<<29;

bool augment(int u,vector<bool> &visited,const vector< vector<int> > &adj,vector<int> match[2]){
	if(u==-1) return true;

	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(!visited[v]){
			visited[v]=true;
			if(augment(match[1][v],visited,adj,match)){
				match[0][u]=v;
				match[1][v]=u;
				return true;
			}
		}
	}
	return false;
}

int BipartiteMatching(const vector< vector<int> > &adj,int R){
	int L=adj.size();

	vector<int> match[2];
	match[0].assign(L,-1);
	match[1].assign(R,-1);

	int ans=0;
	vector<bool> visited(R);
	rep(u,L){
		rep(v,R) visited[v]=false;
		if(augment(u,visited,adj,match)) ans++;
	}
	return ans;
}

int main(){
	for(int n,m,l;scanf("%d%d%d",&n,&m,&l),n;){
		static int dis[100][100];
		rep(u,n) rep(v,n) dis[u][v]=(u==v?0:INF);
		rep(i,m){
			int u,v,d; scanf("%d%d%d",&u,&v,&d);
			dis[u][v]=dis[v][u]=d;
		}

		rep(k,n) rep(i,n) rep(j,n) if(dis[i][k]+dis[k][j]<dis[i][j]) dis[i][j]=dis[i][k]+dis[k][j];

		static int p[1000],t[1000];
		rep(i,l) scanf("%d%d",p+i,t+i);

		vector< vector<int> > adj(l);
		rep(u,l) rep(v,l) if(u!=v) {
			if(t[u]+dis[p[u]][p[v]]<=t[v]) adj[u].push_back(v);
		}

		printf("%d\n",l-BipartiteMatching(adj,l));
	}

	return 0;
}

Measured memory_bytes: 3492
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))  # type:list(int)
    h_arr = []
    for i in range(N):
        _ = int(_in[i+1])  # type:int
        h_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    h_arr.sort()
    cnt = float('inf')
    for i in range(0,N-K+1):
        cnt = min(cnt,abs(h_arr[i]-h_arr[i+K-1]))
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 65244
#include <bits/stdc++.h>
 #define len length
// smile :)
using namespace std;
typedef long long ll;

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


int cnt=0,n,k;

cin>>n>>k;
int arr2[n]={0};
for(int i=0;i<k;i++)
{
    int d;
    cin>>d;
    int arr[d];
    for(int j=0;j<d;j++)
    {
         cin>>arr[j];
         arr[j]--;
        arr2[arr[j]]++;
    }
}
for(int i=0;i<n;i++)
{
    if(arr2[i]==0) cnt++;
}
cout<<cnt;
 return 0;
}


Measured memory_bytes: 3652