akhauriyash/Code-Regression huggingface dataset:
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int get_id(char c){
	if(c>='a'&&c<='z')return c-'a';
	if(c>='A'&&c<='Z')return c-'A'+26;
	return c-'0'+52;
}
char rev(int x){
	if(x<26)return 'a'+x;
	if(x<52)return 'A'+x-26;
	return '0'+x-52;
}
int cnt[66],func[66],n;
int ask(string s){
	cout<<"? "<<s<<endl;
	fflush(stdout);int x;cin>>x;return x;
}
int Get(string ret,string s,int pos,char c){
	int tot=ret.size()+1+s.size()-pos;
	string ss=ret+c+getstr(s,pos,s.size()-1);
	tot=ss.size();
	return n-tot==ask(ss);
}
int id[66];
string merge_sort(int l,int r){
	if(l==r){
		string ret="";
		for(int i=0;i<cnt[id[l]];i++)ret.push_back(rev(id[l]));
		return ret;
	}
	int mid=(l+r)/2;
	string s1=merge_sort(l,mid);
	string s2=merge_sort(mid+1,r);
	int pos=0;
	string ret="";
	if(s1.size()<s2.size())swap(s1,s2);
	for(int i=0;i<s1.size();i++){
		while(pos<s2.size()&&Get(ret,s2,pos,s1[i])==0)
		ret.push_back(s2[pos]),pos++;
		ret.push_back(s1[i]);
	}
	while(pos<s2.size())ret.push_back(s2[pos++]);
	return ret;
}
int main(){
	for(int i=0;i<62;i++){
		string s="";s.push_back(rev(i));
		for(int i=0;i<7;i++)s=s+s;
		int got=ask(s);
		cnt[i]=128-got;
	}
	for(int i=0;i<62;i++)n+=cnt[i];
	for(int i=0;i<62;i++)id[i]=i;
	random_shuffle(id,id+62);
	string s=merge_sort(0,61);
	cout<<"! "<<s<<endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3804
n = int(input())
l = list(map(int,input().split()))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            a,b,c = l[i],l[j],l[k]
            if a==b or b==c or c==a: continue
            if a<b+c and b<c+a and c<a+b: ans += 1
                
print(ans)

Measured memory_bytes: 9220
#include <iostream>
using namespace std;
int main() {
	char a[5];
	for (int i = 0; i < 4; i++) {
		cin >> a[i];
	}
	if (a[0] == a[1] && a[1] == a[2] || a[1] == a[2] && a[2] == a[3])
		cout << "Yes" << endl;

	else
		cout << "No" << endl;
	return 0;
}

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

int main()
{
  int64_t n;
  int64_t sum=0;
  cin>>n;
  
  for(int i=1;i<n+1;i++)
  {
    if(i%3==0||i%5==0)
      continue;
    else
    {
      sum+=i;
    }
  }
  cout<<sum<<endl;
}
      

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

// gcd
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	x := make([]int, n)

	X := sc.NextInt()

	for i := 0; i < n; i++ {
		tmp := sc.NextInt()
		tmp -= X
		if tmp < 0 {
			x[i] = tmp * (-1)
		} else {
			x[i] = tmp
		}
	}
	ans := x[0]
	for i := 1; i < n; i++ {
		ans = gcd(ans, x[i])
	}

	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
 int w, i;
 string S;

 cin >> S >> w;
if (S.size() % w == 0){
  for (i = 0; i < S.size() / w; i++){
   cout << S.at(w * i);
 }
}
else{
  for(i = 0; i < S.size() / w + 1; i++){
    cout << S.at(w * i);
  }
}

}

Measured memory_bytes: 384
import math
import functools
import itertools
import operator

N = int(input())
points = []
for _ in range(N):
    x, y = map(int, input().split(" "))
    points.append((x, y))


@functools.lru_cache(maxsize=None)
def dis(i, j):
    start = points[i]
    end = points[j]
    x1, x2 = start[0], end[0]
    y1, y2 = start[1], end[1]
    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)


def pairwise(iterable):
    a, b = itertools.tee(iterable)
    next(b, None)
    return zip(a, b)


def factorial(n):
    return functools.reduce(operator.mul, range(1, n + 1))


s = 0
for path in itertools.permutations(range(N)):
    d = sum(dis(p, q) for p, q in pairwise(path))
    s += d
print(s / factorial(N))


Measured memory_bytes: 3668
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var ar = scan.nextLong()
    var ans : Long = 0
    var temp : Long=0

    if(ar>=500){
        temp=ar/500
        ans+=(temp*1000)
        ar-=(temp*500)
    }
    if(ar>=5)
    {
        temp=ar/5
        ans+=(temp*5)
        ar-=(temp*5)
    }
    println(ans)

}


Measured memory_bytes: 31396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

int main() {
    int n; cin >> n;
    vector<int> p(n+5);
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i] != i) {
            continue;
        }
        int j = i;
        while (j+1 <= n and p[j+1] == j+1) {
            j++;
        }
        int l = j-i+1;
        ans += l/2;
        if (l & 1) {
            ans++;
        }
        i = j;
    }
    cout << ans << '\n';
}






























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

using namespace std;

#define mod 1000000007
#define sz(c)  (int) c.size()
#define all(c) c.begin(), c.end()
#define tr(container,it) for(__typeof(container.begin()) it = container.begin();it != container.end(); it++)
#define present(s,x) s.find(x) != s.end()
#define cpresent(c,x) find(all(c),x) != c.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a; i<b;i++)
#define ini(n) scanf("%d",&n)
#define opn printf("\n")

 
#define TRACE
 
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)    
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif 

typedef pair<int,int> pi;
typedef vector<pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi , greater<int> >minpq;
typedef priority_queue<pi,vp,greater<pi> > mpq;

vi a;
vi b;
int N;
void com(){
	int pro = 1;
	for(int i=1 ; pro<=N; i++){
		pro *= 6;
		a.pb(pro);
	}
	
	pro = 1;
	for(int i=1; pro<=N ; i++){
		pro *=9 ;
		b.pb(pro);
	}
}
int S[100002];


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

	cin>>N;
	fill(S,S+100002,1e8);
	com();
	S[0] = 0;
	for(int i=1 ; i<=N; i++){
		S[i] = min(S[i],S[i-1]+1);
		for(int j=0; j<sz(a) ; j++){
			if(a[j]<=i and S[i-a[j]] + 1 < S[i]){
				S[i] = S[i-a[j]] + 1;
			}
		}
		for(int j=0; j<sz(b) ; j++){
			if(b[j]<=i and S[i-b[j]] + 1 < S[i]){
				S[i] = S[i-b[j]] + 1;
			}
		}
	}
	cout<<S[N];
	
}

	

	



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

int main(){
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if (U == S)
    cout << A-1 << " " << B << endl;
  else
    cout << A << " " << B-1 << endl;
}

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

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	
	if(n*a > b) cout << b << endl;
	else cout << n*a << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){ 
  int N,M; cin >> N >> M;
  string S; cin >> S;
  
  int pos = N;
  
  vector<int> ans;
  
  while(pos > 0){
    
    ans.push_back(pos);
    
    for(int i = min(M,pos); i >= 0 ; i--){
      if(S[pos-i] == '0' && i > 0){  pos -= i; break;}
      if( i == 0  ){ cout << -1 << endl; return 0;}
    }
  }
  
  ans.push_back(0);
  
  reverse(ans.begin(),ans.end());
  
  for(int i = 0; i < (int)ans.size()-1; i++){ cout << ans[i+1]-ans[i] << " ";}
  
  cout << endl;
  
  return 0;
}
    

Measured memory_bytes: 1144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	string S;
	cin >> S;
	int N = S.size();
	if(S.at(0) != 'A') {
		cout << "WA" << endl;
	}
	else {
		int cnt;
		bool A = false;
		for(int i = 2;i < N - 1;i++) {
			if(S.at(i) == 'C') {
				cnt = i;
				A = true;
				break;
			}
		}
		if(A == false) {
			cout << "WA" << endl;
		}
		else {
			bool B = true;
			for(int i = 1;i < N;i++) {
				if(i == cnt) {
					continue;
				}
				if(S.at(i) < 'a' || S.at(i) > 'z') {
					B = false;
					break;
				}
			}
			if(B == true) {
				cout << "AC" << endl;
			}
			else {
				cout << "WA" << endl;
			}
		}
	}
}

Measured memory_bytes: 256
n = int(input())
up = list(map(int, input().split()))
low = list(map(int, input().split()))

left = [up[0]]
right = [0 for i in range(n)]
right[-1] = low[-1]
for i in range(1, n):
    left.append(left[i-1] + up[i])
for i in range(n-2, -1, -1):
    right[i] = right[i+1] + low[i]

ans = 0
for i in range(n):
    ans = max(left[i] + right[i], ans)
print (ans)

Measured memory_bytes: 62160
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>vint;

#define rep(i,n) for(int i=0;i<(n);i++)
signed main(){
    int K,T;
    cin>>K>>T;
    vint C(T);
    rep(i,T)cin>>C[i];

    rep(i,T){
        if(C[i]*2-1<=K)continue;
        int t=C[i]-(K+1)/2;
        cout<<t*2-(K%2==0)<<endl;
        return 0;
    }

    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long int 
#define pb  push_back
#define mp  make_pair
#define pii pair<int, int>
using namespace std;

const ll mod = 1e9+7;
const int N = 3e3;
ll arr[N+1] = {0};
bool check[N+1][N+1] = {0};
ll dp[N+1][N+1] = {0};
int first;

ll dp_recurse(int l, int r){
	if(l==r){
		if(first == 1){
			return +arr[l];
		}
		return -arr[l];
	}

	if(check[l][r] == 1){
		return dp[l][r];
	}

	if((r-l+1)%2 == first){
		dp[l][r] = max(arr[l] + dp_recurse(l+1, r), arr[r] + dp_recurse(l, r-1));
	}
	else{
		dp[l][r] = min(dp_recurse(l+1, r) - arr[l], dp_recurse(l, r-1) - arr[r]);
	}

	check[l][r] = 1;

	return dp[l][r];
}

void solve(){
    //solve here//
	int n;
	cin >> n;

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

	first = n%2;

	cout << dp_recurse(1, n) << endl;
}


int main(){
    ll t=1;
  //  cin >> t;
    while(t--){
        solve();
    }
}



Measured memory_bytes: 79616
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll a[10000005] = {};
int main() {
	ll n, k;
	cin >> n >> k;
	ll d,kasi;
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> kasi;
			a[kasi]++;
		}
	}
	ll count = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] == 0) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
ll n, m, k = 0, l = 0,x,y;

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

set<int> mn;



int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> m >> n;
	for (ll i = n - m + 1; i < n + m; i++)
		cout << i << ' ';

}

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


void solve(long long N, std::vector<long long> A){
    std::vector<long long> boss(N);
    for (int i = 0; i < A.size(); i++) {
        boss[A[i] - 1]++;
    }
    for (int i = 0; i < N; i++) {
        cout << boss[i] << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-2+1);
    for(int i = 0 ; i < N-2+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 6436
//In the name of Allah

#include <bits/stdc++.h>

using namespace std;

const int N = 100005;

int t[N];

int main() {
  int n, c, k;
  scanf("%d %d %d", &n, &c, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }
  sort(t, t + n);
  bool flg = false;
  int ans = 0, st, cnt;
  for (int i = 0; i < n; i++) {
    if (!flg) {
      flg = true;
      st = t[i];
      ans++;
      cnt = 0;
    }
    if (i + 1 < n && t[i + 1] - st > k || cnt == c - 1) {
      flg = false;
    }
    cnt++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    double a, b, x; cin >> a >> b >> x;
    x /= a;

    cout << setprecision(16);
    if(x >= a*b/2.0){
        double dif = a*b - x;
        // cout << "dif " << dif << endl; 

        double theta = atan(2.0*dif/a/a);

        cout << theta*180.0/M_PI << endl;

        // double theta = asin(2.0*dif/(a*a))*180.0/M_PI;
        // cout << setprecision(16) << theta << endl;

    }
    else{
        double theta = atan(b*b/2/x);

        cout << theta*180.0/M_PI << endl;

    }
        

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
int main(){
  int N;
  int d[1000];
  int count=1;
  cin>>N;
  for(int i=0; i<N; i++){
      cin>>d[i];
  }
  
  sort(d,d+N);
  
  
  for(int j=0; j<N; j++){
      if(d[j]<d[j+1]&&j!=N-1){
          count++;
      }
  }
  cout<<count<<endl;
}


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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  string ans = "No";
  int N;
  cin >> N;

  int count = N / 7 + 1;
  FOR(i, 0, count) {
    int temp = N - 7 * i;

    if (temp % 4 == 0) {
      ans = "Yes";
      break;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
dlst = [int(i) for i in input().split()]
lst = []
for i in range(10):
  if i not in dlst:
    lst.append(str(i))
for i in range(n, 10 * n + 1):
  a = True
  for j in str(i):
    if j not in lst:
      a = False
      break
  if a:
    print(i)
    quit()

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

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

int main() {
    int a, b, c, k, cnt = 0;
    bool ans;
    cin >> a >> b >> c >> k;
    if (a < b && b < c) {
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, k) {
        if (b > a)
            break;
        b = b * 2;
        cnt++;
    }
    k -= cnt;
    if (k >= 0) {
        if (b < c) {
            cout << "Yes" << endl;
            return 0;
        }
    } else {
        cout << "No" << endl;
        return 0;
    }
    cnt = 0;
    rep(i, k) {
        if (c > b)
            break;
        c = c * 2;
        cnt++;
    }
    k -= cnt;
    if (k >= 0) {
        if (b < c) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    } else {
        cout << "No" << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3644
x, n = map(int, input().split())
p = list(map(int, input().split()))
d = list(a*0 for a in range(n))

if n==0:
    print(x)
else:
    for i in range(n+1):
        if not x-i in p:
            print(x-i)
            break
        elif not x+i in p:
            print(x+i)
            break

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }

        int max = 0;
        int result = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] >= max) {
                result++;
            }
            max = Math.max(max, h[i]);
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 21972
import sys
def main():
    input = sys.stdin.readline
    MD = list(map(int, input().split()))
    M = MD[0]
    D = MD[1]

    if D < 22:
        ans = 0
    else:
        ans = 0
        for m in range(M):
            m += 1
            for d in range(D):
                d += 1
                if d >= 22:
                    d_1 = int(str(d)[1])
                    if d_1 >= 2:
                        d_10 = int(str(d)[0])
                        if d_1 * d_10 == m:
                            ans += 1
                            #print(d_1)
                            #print(d_10)
                            #print(m,d)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 40048
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
using ll=int long long;
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main()
{
	int n,k;
	cin>>n>>k;
	int x,y;
	for(int i=0;i<k;i++)
	{
		cin>>x>>y;
		x=min(x,n-x+1);
		y=min(y,n-y+1);
    if(min(x,y)%3==0){
      cout<<3<<endl;
    }
    else{
      cout<<min(x,y)%3<<endl;
    }
	}
}




Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

void print_ans(bool flag){
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   
}

int main(){
    string s;
    cin >> s;
    bool ans = (s[0] == s[1] && s[0] == s[2] && s[1] == s[2])
     || (s[1] == s[2] && s[1] == s[3] && s[2] == s[3]);
     print_ans(ans);
    return 0;
}


Measured memory_bytes: 256
def c_bridge(N, M, E):
    """
    N:頂点の数
    M:辺の数
    E:辺で結ばれる頂点の組
    """
    def dfs(v):
        # 現在の頂点を訪問済にする
        visited[v] = True
        for v2 in range(N):
            # 現在の頂点と次の頂点に辺がない。スキップ
            if adjacent[v][v2] == False:
                continue
            # 次の頂点が訪問済。スキップ
            if visited[v2] == True:
                continue
            dfs(v2)

    # 隣接行列の構成
    adjacent = [[0 for _ in range(N)] for _ in range(N)]
    for a, b in E:
        a, b = a - 1, b - 1
        adjacent[a][b] = True
        adjacent[b][a] = True

    # 各辺が橋であるか？
    # グラフから辺を取り除いて、グラフが連結かを判定
    ans = 0
    for a, b in E:
        a, b = a - 1, b - 1
        # 辺を取り除く
        adjacent[a][b] = False
        adjacent[b][a] = False

        # すべての辺を未訪問として初期化
        visited = [False for _ in range(N)]
        # 頂点0からDFS
        dfs(0)
        # すべての頂点が訪問済なら連結、そうでなければ非連結
        if not all(visited):
            ans += 1

        # 辺を復元
        adjacent[a][b] = True
        adjacent[b][a] = True
    return ans

N,M = [int(i) for i in input().split()]
E = [[int(i) for i in input().split()] for j in range(M)]
print(c_bridge(N, M, E))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a > b) {
		int temp;
		temp = a;
		a = b;
		b = temp;
	}
	if(b > c) {
		int temp;
		temp = b;
		b = c;
		c = temp;
	}
	if(a > b) {
		int temp;
		temp = a;
		a = b;
		b = temp;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int n;
	char a[21]={0};
	cin>>a;
	n=strlen(a);
	for(int i=n-1;i>=0;i--){
        cout<<a[i];
	}
    cout<<endl;

	return 0;
}

Measured memory_bytes: 1132
n = int(input())
A = [0] * n
A = list(map(int, input().split()))
res = 0
flg = 0

while True:
  for j in range(n):
    if A[j]%2 == 1:
      flg = 1
      break
    A[j] = A[j]/2
 
  if flg == 1 : break
  res += 1

print(res)

Measured memory_bytes: 38512
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
        Scanner scanner1 = new Scanner(System.in);
        int H = scanner1.nextInt();
        int W = scanner1.nextInt();
        int h = scanner1.nextInt();
        int w = scanner1.nextInt();
        int x;
        x = H*W+h*w -(h*W+w*H);
        System.out.println(x);
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200005],n,ans,i,j,h;
int main() {
	scanf("%lld",&n);
	for (i=0; i<n; ++i)scanf("%lld",a+i);
	for (i=0; i<n; ++i) {
		for (j; j<n; ++j) {
			if((h|a[j])!=h+a[j])break;
			else h=h+a[j],ans=ans+j-i+1;
		}
		
		h-=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}
//(A+B)-(A^B)=2(A&B)

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * D_Carousel
 */
public class Main {
    public static void main(String[] args) {
        InputReader ir = new InputReader();
        OutputWriter ow = new OutputWriter();

        solve(ir, ow);

        ow.flush();
    }

    private static void solve(InputReader ir, OutputWriter ow) {
        long N = ir.nextLong(), K = ir.nextLong();

        long mod = N / K;

        long a = N - (N / K) * K;
        long b = K - a;

        ow.print(Math.min(a, b));
    }
}

////////////////// IO //////////////////////

class InputReader {
    private BufferedReader br;
    private StringTokenizer st;

    InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }
}

class OutputWriter {
    private BufferedWriter bw;

    OutputWriter() {
        bw = new BufferedWriter(new OutputStreamWriter(System.out));
    }

    void print(String s) {
        try {
            bw.write(s, 0, s.length());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void println() {
        try {
            bw.newLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void println(String s) {
        print(s);
        println();
    }

    void print(int x) {
        print(Integer.toString(x));
    }

    void println(int x) {
        println(Integer.toString(x));
    }

    void print(long l) {
        print(Long.toString(l));
    }

    void println(long l) {
        println(Long.toString(l));
    }

    void print(Object o) {
        print(o.toString());
    }

    void println(Object o) {
        println(o.toString());
    }

    void flush() {
        try {
            bw.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 22868
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 


N,M,C = map(int, input().split())
Bn = list(map(int, input().split()))
ans = 0
for _ in range(N):
  an = list(map(int, input().split()))
  s = C
  for i in range(len(an)):
    s += an[i] * Bn[i]
  if s > 0:
    ans += 1

print(ans)


Measured memory_bytes: 3060
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	return maa(n)
	#b , c = tin()
	#s = input()
	for i in range(1,10000):
		if maa(i)!=mab(i):
			pa(maa(i), mab(i))
			return i
	print('ok')
	
def maa(n):
	ret = 0
	rr=[]
	for i in range(1, n+1):
		if n//i <= i:
			break
			
		if (n-i) % i == 0:
			if i == (n-i)//i:
				return ret
			#pa(i, (n-i)//i)
			ret += (n-i)//i
			#rr.append((n-i)//i)
			
	return ret
	
def mab(n):
	ret = 0
	for i in range(1, n+1):
		if n // i == n%i:
			ret += i
	return ret
	
	
#+++++
isTest=False

def pa(*vl):
	if not isTest:
		return
	print(*vl)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 63916
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int n;
  cin >> n;
  string tmp;
  map<string, int> a;
  map<string, int> b;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    a[tmp]++;
  }

  int m;
  cin >> m;
  for (int i = 0; i < m; i++){
    cin >> tmp;
    a[tmp]--;
  }
  int res = 0;
  for(auto i : a){
     res = max(res,i.second);
   }
  cout << res << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int a,b,c;
  cin >> a >> b >> c;
  for (int i = 1; i <= 10; i++) {
    cout << (c = a * c - b) << endl;
  }
}

int main(int argc, char *argv[]){
  int testcase = 1;
  int multicase = 0;
  if (argc > 1 && stoi(argv[1])) cin >> testcase;
  REP(case_no, testcase) {
    cerr << "case " << case_no + 1 << endl;
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
ans=0
min=0
max=0
for i in range(a[1]):
    min +=i
    max +=a[0]-i
    minx=i-1
    maxx=a[0]-i-1
ans=max-min+1
for i in range(a[1]+1,a[0]+2):
    minx +=1
    min += minx
    maxx += -1
    max +=maxx
    ans=(ans+max-min+1)%(10**9+7)
print(ans)

Measured memory_bytes: 9216
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;
import java.util.LinkedList;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int pt = 0;
        int ph = 0;
        for (int i = 0; i < n; i++) {
            String t = sc.next();
            String h = sc.next();
            int res = t.compareTo(h);
            if (res > 0) {
                pt += 3;
            } else if (res < 0) {
                ph += 3;
            } else {
                pt++;
                ph++;
            }
        }
        
        System.out.println(pt + " " + ph);
    }
}

Measured memory_bytes: 30348
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    
    for(ll i=1;i<n-1;i++){
        if(a[i-1]>a[i] && a[i]>a[i+1]) sum++;
        if(a[i-1]<a[i] && a[i]<a[i+1]) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	s := make([]string, h)
	for i, _ := range s {
		fmt.Scan(&s[i])
	}

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

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if string(s[i][j]) == "#" {
				fmt.Print("#")
				continue
			}

			var cnt int
			for k := 0; k < 8; k++ {
				x := i + dx[k]
				y := j + dy[k]

				if x < 0 || x >= h || y < 0 || y >= w {
					continue
				}
				if string(s[x][y]) == "#" {
					cnt++
				}
			}
			fmt.Print(cnt)
		}
		fmt.Println()
	}
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val N = readLine()!!.toInt();
    var p =  Array(N, {readLine()!!.toInt()})
    var max: Int = 0;
    var sum: Int = 0;

    for ( price in p ){ sum += price }
	for ( price in p ){ 
    	if( price > max ){
            max = price
        }
    }
    println(sum - max/2)
}

Measured memory_bytes: 29812
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


N, K = inpl()
tmpl = [0] * N
for k in range(K):
    d = inp()
    aa = inpl()
    for a in aa:
        tmpl[a - 1] += 1

ans = 0
for t in tmpl:
    if t == 0:
        ans += 1
print(ans)


Measured memory_bytes: 9732
#include<stdio.h>

int main(){
  int i, n, p, q, win, data[50];

  while(1){
    scanf("%d %d", &n, &p);
    if(n == 0 && p == 0) break;

    for(i=0; i<n; i++)
      data[i] = 0;

    i = 0;
    q = p;
    while(1){
      if(q == 0){
        q = data[i];
        data[i] = 0;
      }else{
        data[i]++;
        q--;
      }

      if(data[i] == p && q == 0){
        win = i;
        break;
      }

      if(i == n-1) i = 0;
      else i++;
    }

    printf("%d\n", win);
  }

  return 0;
}

Measured memory_bytes: 404
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		char[] alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();
		int cnt = 0;
		List<String> a = new ArrayList<String>();
		a.add("a");
		map.put(1, a);
		for(int i = 2; i <= n; i++){
			List<String> prevSet = map.get(i-1);
			List<String> newSet = new ArrayList<String>();
			for(String tmp : prevSet){// これまでのStringから一つとる
				char[] cArr = tmp.toCharArray();
				Set<Character> cSet = new HashSet<Character>();
				for(char c : cArr){//そのストリングに使われている文字種類数分のSet
					cSet.add(c);
				}
				for(int j = 0; j < cSet.size()+1; j++){
					newSet.add(tmp+alphabet[j]);
				}

			}
			map.remove(i-1);
			map.put(i,newSet);
		}
		for(String r : map.get(n)){
			System.out.println(r);
		}
		map.clear();
		scanner.close();

	}

}


Measured memory_bytes: 61140
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int f(int x, int n){
	int y=x;
  	for(int i=0;i<n;i++){
    	y*=2;
    }
  	return y;
}

int main(void){
	int a, b, c;
  	cin>>a>>b>>c;
  	int k;
  	cin>>k;
  	int yn=0;
  	for(int i=0;i<=k;i++){
    	for(int j=0;j<=k;j++){
        	for(int l=0;l<=k;l++){
            	if(i+j+l<=k){
                	if(f(a,i)<f(b,j) && f(b,j)<f(c,l)){
                    	yn=1;
                    }
                }
              	if(yn==1) break;
            }
            if(yn==1) break;
        }
      	if(yn==1) break;
    }
  
  	if(yn==1){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
bool is_integer(double a)
{
    int b = a;
    if( fabs((double)b - a) < 1e-9) return true;
    return false;
}
int co[15][15];
int n, d;
double calc_dis(int i, int j)
{
    int k;
    double cur = 0;
    FOR0(k, d)
    {
        cur += (co[i][k] - co[j][k])*(co[i][k] - co[j][k]);
    }
    cur = sqrt(cur);
    return cur;
}
int main()
{
    she_told_me_dont_worry
    cin>>n>>d;
    int i, j;
    FOR0(i, n)
    {
        FOR0(j, d)
            cin>>co[i][j];
    }
    int ans = 0;
    FOR0(i, n)
    {
        FOR(j, i+1, n)
        {
            double dis = calc_dis(i, j);
            if(is_integer(dis)) ans++;
        }
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
from collections import defaultdict, Counter, deque

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

g = defaultdict(list)
for i in range(N - 1):
    u, v = list(map(int, input().split()))
    g[u].append(v)
    g[v].append(u)

# BFS to label each node with its level (bipartite 2-coloring)
source = 1
dist = {}
q = deque()
q.append(source)
dist[source] = 0
while q:
    node = q.popleft()
    level = dist[node]
    for nbr in g[node]:
        if nbr not in dist:
            q.append(nbr)
            dist[nbr] = level + 1

mod1 = list(range(1, N + 1, 3))
mod2 = list(range(2, N + 1, 3))
mod0 = list(range(3, N + 1, 3))

# Count the number of nodes on odd and even levels
parityCounts = Counter(level % 2 for level in dist.values())

assign = {}
# Since 3 is odd, any distance of 3 will connect two nodes of different parity levels
if min(parityCounts[0], parityCounts[1]) <= len(mod0):
    # Either the odd or even levels is small enough to be completely 0 mod 3 which can connect to anything else
    parityOfSmaller = min([0, 1], key=lambda k: parityCounts[k])
    for i in range(1, N + 1):
        if dist[i] % 2 == parityOfSmaller:
            assign[i] = mod0.pop()
        else:
            if mod1:
                assign[i] = mod1.pop()
            elif mod2:
                assign[i] = mod2.pop()
            elif mod0:
                assign[i] = mod0.pop()
else:
    # We want to assign all (1 mod 3) to one parity and all (2 mod 3) to another parity
    # Then the sum will always be a multiple of 3
    # The two levels should always have enough nodes to consume all of mod1 and mod2
    # Anything else can be padded with mod0
    assert len(mod0) <= len(mod2) <= len(mod1)

    if parityCounts[0] < parityCounts[1]:
        assert len(mod2) <= parityCounts[0]
        assert len(mod1) <= parityCounts[1]
        parityToMod = {0: mod2, 1: mod1}
    else:
        assert len(mod1) <= parityCounts[0]
        assert len(mod2) <= parityCounts[1]
        parityToMod = {0: mod1, 1: mod2}

    for i in range(1, N + 1):
        mod = parityToMod[dist[i] % 2]
        if mod:
            assign[i] = mod.pop()
        else:
            assign[i] = mod0.pop()

print(" ".join(str(assign[i]) for i in range(1, N + 1)))


Measured memory_bytes: 139384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a , b , c , d ,l1=0,l2=0,l=0 ;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a>=c)
	l1=a;
	else 
	l1=c;
    if(b<=d)
	l2=b;
	else
	l2=d;
	l=l2-l1;
	if(l<=0)
	printf("0");
	else
	printf("%d",l);
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

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

    ll ans = 0;
    for(char c : s) {
        ans += c - '0';
    }
    cout << ((ans%9)?"No":"Yes") << endl;

    return 0;
}

Measured memory_bytes: 3720
# 100(aA + bB) + cC + dD <= F
# cC + dD <= (aA + bB)E
# maximize 100(cD + dD) / (100(aA + bB) + cC + dD)

A, B, C, D, E, F = map(int, input().split())
concentration = -1
ans = (0, 0)
for a in range(31):
    for b in range(31):
        water = 100*(a*A + b*B)
        if water > F:
            break
        for c in range(3001):
            for d in range(3001):
                sugar = c*C + d*D
                if water + sugar == 0:
                    continue
                if water + sugar > F:
                    break
                if sugar > water // 100 * E:
                    break
                conc = 100*sugar / (water + sugar)
                if concentration < conc:
                    concentration = conc
                    ans = (water + sugar, sugar)
print(ans[0], ans[1])


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
	cin.sync_with_stdio(false);
	int n, c, k;
	cin >> n >> c >> k;
	int t[n];
	rep(i, n) cin >> t[i];
	sort(t, t + n);
	int lim = -1, num = 0, cnt = 0;
	rep(i, n) {
		if (lim < t[i]) {
			num = 0;
			lim = t[i] + k;
			cnt++;
		}
		if (t[i] <= lim) {
			num++;
		}
		if (num == c) {
			num = 0;
			lim = -1;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int a[100001];

int main() {
    int x, i, j;
    
    scanf("%d", &x);
    
    a[0] = 1;
    
    for (i = 0; i <= 5; i++) {
        int c = 100 + i;
        
        for (j = 0; j + c <= x; j++) {
            if (a[j] == 1) a[j + c] = 1;
        }
    }
    
    if (a[x] == 1) {
        puts("1");
    } else {
        puts("0");
    }
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b;cin >> a >> b;
    int ret = 0;
    int pos = min(a,b/2);
    ret += pos;
    a -= pos;
    b -= pos*2;
    ret += b/4;
    cout << ret << endl;
    return 0;
}

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

int main(){
    int N; //整数の個数
    int cnt = 0; //負の数を数える
    ll smst = pow(10,9)+1; //絶対値が一番小さい数
    ll sum = 0; //整数の絶対値の合計
    
    cin >> N;

    for(int i=0; i<N; i++){
        ll a; cin >> a;
        if(a < 0){
            a = abs(a);
            cnt++;
        }

        smst = min(smst,a);
        sum += a;
    }

    if(cnt%2 == 1) sum -= 2*smst;

    cout << sum << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = n;
    for(int i = 0 ; i< n-1 ; i++){
        if(s[i] == s[i+1]){
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512