akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define TRUE 1
#define FALSE 0

int main(void)
{
	int A, B, C, i, ok = FALSE;
	scanf("%d %d %d", &A, &B, &C);

	for (i = 1; i <= B; i++)
		if ((A * i) % B == C)
			ok = TRUE;
	puts(ok ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define lli long long int
#define pb push_back
#define loop(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000007
#define mem(x,a) memset(x,a,sizeof(x))
#include<vector>
int min1(int a, int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max1(int a, int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int main()
{
	int n,m,s=0,a,b;
	cin>>n>>m;
	vector<pair<int, int>>vec;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		vec.push_back(make_pair(a, b));
	}
	sort(vec.begin(), vec.end());
	int i,x,y,c=0,y1,x1;
	x=vec[0].first;
	y=vec[0].second;
	i=1;
	while(i<m)
	{
		if(vec[i].first>=x && vec[i].first<=y)
		{
			x1=max1(x, vec[i].first);
			x=x1;
			y1=min1(y, vec[i].second);
			y=y1;
		}
		else if(vec[i].first>y)
		{
			c=1;
			break;
		}
		i++;
	}
	if(c)
		cout << "0" << endl;
	else
	{
		s=y-x;
		cout << s+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[100010][2];
signed main() {
    string s; cin >> s;
    int N = s.length();

    dp[0][0] = 1;
    for(int i=0; i<N; i++) {
        for(int f=0; f<2; f++) {
            int lim = f ? 1 : s[i] - '0';
            for(int x=0; x<=lim; x++) {
                if(x == 0) {
                    (dp[i+1][f || x < lim] += dp[i][f]) %= MOD;
                }
                else {
                    (dp[i+1][f || x < lim] += dp[i][f] * 2) %= MOD;
                }
            }
        }
    }

    int ans = (dp[N][0] + dp[N][1]) % MOD;
    cout << ans << endl;
    return 0;
}


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

int a[5];
int main() {
	while (1) {
		rep(i, 5) {
			int s1, s2; cin >> s1 >> s2;
			if (s1 == 0 && s2 == 0)return 0;
			a[i] = s1 + s2;
		}
		int*ans = max_element(a, a + 5);
		cout << (char)(ans - a + 'A') << ' ' << *ans << endl;
	}
}

Measured memory_bytes: 3088
n, h = map(int, input().split())
#AB = []
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    #AB.append((a, b))

x = max(A)
B.sort(reverse=True)
ans = 0
for i, b in enumerate(B):
    if b > x:
        h -= b
        ans += 1
    else:
        break
    if h <= 0:
        print(ans)
        exit()
ans += (h+x-1)//x
print(ans)


Measured memory_bytes: 86652
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    REP(i,n){
        cin>>v[i];
    }
    ll count=0, max=0;
    REP(i,n-1){
        ll left=v[i],right=v[i+1];
        if(left>=right){
            count++;
        }else if(max<count){
            max=count;
            count=0;
        }else{
            count=0;
        }
    }
    if(max<count){
        max=count;
    }
    cout<<max;
    return 0;
}


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

class Heap<T> where T : IComparable
{
    public HeapNode<T> top;

    public void push(T val)
    {
        top = HeapNode<T>.meld(top, new HeapNode<T>(val));
    }

    public T pop()
    {
        T ret = top.val;
        top = HeapNode<T>.meld(top.r, top.l);
        return ret;
    }

    public void merge(Heap<T> h2)
    {
        top = HeapNode<T>.meld(top, h2.top);
    }

    public class HeapNode<NT> where NT : IComparable
    {
        public HeapNode<NT> l, r;
        public NT val;

        public HeapNode(NT _val)
        {
            val = _val;
        }

        public static HeapNode<NT> meld(HeapNode<NT> a, HeapNode<NT> b)
        {
            if (a == null) return b;
            if (b == null) return a;
            if (b.val.CompareTo(a.val) > 0)
            {
                HeapNode<NT> temp = a;
                a = b;
                b = temp;
            }
            a.r = meld(a.r, b);
            HeapNode<NT> temph = a.l;
            a.l = a.r;
            a.r = temph;
            return a;
        }
    }
}

class MainClass
{
    public static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split();
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);

        var array = new Tuple<int, int>[n];

        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split();
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);
            array[i] = Tuple.Create(a, b);
        }

        Array.Sort(array);

        var heap = new Heap<int>();
        var index = 0;
        var ans = 0;

        for (int i = 1; i <= m; i++)
        {
            while (index < n && array[index].Item1 <= i)
            {
                heap.push(array[index].Item2);
                index++;
            }

            if (heap.top != null) ans += heap.pop();
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 26380
#include <stdio.h>
#include <math.h>

double area(double a, double b)
{
	return (sqrt(a * a - b * b) * b / 2);
}

int main(void)
{
	int a, l, x;
	double s;
	
	while (scanf("%d%d%d", &a, &l, &x) != EOF){
		s = area(l, (double)a / 2) * 2;
		s += area((double)(l + x) / 2, (double)l / 2) * 4;
		printf("%.10lf\n", s);
	}
	
	return (0);
}

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> vec(N);
  
  rep(i,N){vec.at(i)=1;}
  
  int d,A;
  
  rep(i,K){cin>>d;
           rep(j,d){cin>>A;
                   vec.at(A-1)=0;}
          }
  int Ans=0;
  rep(i,N){Ans+=vec.at(i);}
  
  cout<<Ans<<endl;
}

Measured memory_bytes: 3592
from itertools import permutations

N,M,R=map(int,input().split())
r=[int(x) for x in input().split()]

INF=float('inf')
d=[[INF for x in range(N)] for y in range(N)]

for i in range(M):
  a,b,c=map(int,input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c

for i in range(N):
  for j in range(N):
    for k in range(N):
      if d[j][i]+d[i][k] < d[j][k]:
        d[j][k]=d[j][i]+d[i][k]

ans=INF
for root in permutations(r):
  cnt=0
  for i in range(R-1):
    cnt+=d[root[i]-1][root[i+1]-1]
    if cnt>ans:
      break
  ans=min(ans,cnt)
print(ans)


Measured memory_bytes: 52824
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>


using namespace std;

int main(){
 
   string str;
   int n;
   
   cin >> n;
   cin >> str;
   
   char wk = ' ';
   
   
   int ans = 0;
   for(int i = 0; i < n;i++){
       if(wk != str[i]){
           ans++;
           wk = str[i];
       }
   }
   
   cout << ans << endl;
   
   return 0;
    
    
}

Measured memory_bytes: 512
#include <stdio.h>

typedef long long lli;

lli a[301][301], f[301][301];
int n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			scanf("%lld", &a[i][j]);
			f[i][j] = a[i][j];
		}
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (f[i][j] > f[i][k] + f[k][j]) f[i][j] = f[i][k] + f[k][j];
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (a[i][j] != f[i][j]) {
				puts("-1");
				return 0;
			}
		}
	}
	lli res = 0;
	for (int u = 1; u <= n; u++) {
		for (int v = u + 1; v <= n; v++) {
			bool found = false;
			for (int k = 1; k <= n; k++) if (k != u && k != v) {
				if (a[u][k] + a[k][v] == a[u][v]) {
					found = true;
					break;
				}
			}
			if (!found) res += a[u][v];
		}
	}
	printf("%lld\n", res);
	return 0;
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;


int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	n%=10;
	if(n==3) cout << "bon";
	else if(n==0 || n==1 || n==6 || n==8) cout << "pon";
	else cout << "hon";

}

Measured memory_bytes: 3648
# frozen_string_literal: true

n = gets.to_i
ab = n.times.map { gets.split.map(&:to_i) }

sab = ab.sort_by(&:last)

t = 0
sab.each do |e|
  a = e[0]
  b = e[1]
  t += a
  if t > b
    puts 'No'
    exit
  end
end
puts 'Yes'


Measured memory_bytes: 22520
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val fibonacci = Fibonacci()
    println(fibonacci.getFibonacci(n))
}

class Fibonacci {
    private val fibonacciMemo = mutableMapOf(0 to 1, 1 to 1)

    fun getFibonacci(n: Int): Int {
        return if (fibonacciMemo[n] != null) {
            fibonacciMemo[n]!!
        } else {
            fibonacciMemo[n] = getFibonacci(n - 2) + getFibonacci(n - 1)
            fibonacciMemo[n]!!
        }
    }
}


Measured memory_bytes: 26360
#include <stdio.h>
int main(void){
    int n,k,x,y,sum,i;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(k>=n){
        sum=n*x;
    }else{
        sum=k*x+(n-k)*y;
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define _ <<" "<<
const int MOD = 1000 * 1000  * 1000 + 7; // odd modulus
const int N = 1000 * 1000 ;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

ll gcd (ll a , ll b ) // b < a
{
return  b == 0 ?  a : gcd( b , a % b   ) ;

}
int main()
{
    Fast_IO();
    int n ;
    cin >> n ;
    double res = 0 ;
    for ( int i = 0 ; i < n ; ++i)
    {
     double x ;
     cin >> x ;

     res += (1.0  / x );

    }

    cout << (1.0 / res ) ;


return 0 ;

}








Measured memory_bytes: 256
from collections import deque
K=int(input())
cnt=0
dp=[0]*(10**6)
piv=0
dig=[0]*10000
d=0
cnt=float("inf")
zure=0
befnum=0
i=0
buf=""
cntall=0
ans=[]
"""なんだこの
while i<2*(10**5):
    if i+1<10:
        dp[i]=i+1
        dig[d]=dig[d]+1
    else:
        if cnt>=dig[d-1]:
            i=i+zure
            zure=0
            cnt=0
            befnum=dig[d]
            d=d+1
        #print(i,befnum)
        buf=str(dp[i-befnum])
        piv=buf[len(buf)-1]
        #print(buf, piv,i-befnum)
        #print(dp,dig,zure,i,dig[i],dp[i-befnum],befnum)
        if int(piv)==0:
            dp[i+zure]=dp[i-befnum]*10
            dp[i+1+zure]=dp[i - befnum] * 10+1
            dig[d]=dig[d]+2
            zure=zure+1
        elif int(piv)==9:
            dp[i + zure] = dp[i - befnum] * 10+8
            dp[i + 1 + zure] = dp[i - befnum] * 10+9
            dig[d] = dig[d] + 2
            zure = zure + 1
        else:
            dp[i+zure]=dp[i-befnum]*10+int(piv)-1
            dp[i+1+zure]=dp[i - befnum] * 10+int(piv)
            dp[i+2+zure] = dp[i - befnum] * 10 + int(piv)+1
            dig[d] = dig[d] + 3
            zure=zure+2
        cnt=cnt+1
    i=i+1
    #if i%20000==0:
        #print(i)
    #print(dp)
    #input()
print(dp[K-1])
"""
#dequeでやればめっちゃ楽だった…
d=deque()
piv=0
num=0
for i in range(9):
    d.append(i+1)
#print(d)
i=0
while i<K:
    num=d.popleft()
    ans.append(num)
    piv=str(num)
    if piv[len(piv)-1]=="0":
        d.append(num*10)
        d.append(num*10+1)
    elif piv[len(piv)-1]=="9":
        d.append(num*10+8)
        d.append(num * 10 + 9)
    else:
        d.append(num*10+int(piv[len(piv)-1])-1)
        d.append(num*10+int(piv[len(piv)-1]))
        d.append(num * 10 + int(piv[len(piv) - 1])+1)
    i=i+1
    #print(d,ans)
    #input()
print(ans[K-1])





Measured memory_bytes: 60504
#https://atcoder.jp/contests/abc069/tasks/arc080_a
N = int(input())
ai = list(map(int, input().split()))
mult_4 = 0
odd = 0
mult_2 = 0
for a in ai:
    if a%4 == 0:
        mult_4 += 1
    elif a%2 == 1:
        odd += 1
    else:
        mult_2 += 1

if mult_2 != 0 and mult_4 >= odd:
    print("Yes")
elif mult_2 == 0 and mult_4+1 >= odd:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s-1);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n; cin>>n;
    int a,b;
    if (n != 1) {
        cin>>a>>b;
        cout << a+b << endl;
    } else {
        cout << "Hello World" << endl;
    }
    

}


Measured memory_bytes: 256
// Poor

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    if ((A == B) && (B != C)) {
        cout << "Yes" << endl;
        return 0;
    }

    if ((A != B) && (B == C)) {
        cout << "Yes" << endl;
        return 0;
    }

    if ((A == C) && (B != A)) {
        cout << "Yes" << endl;
        return 0;
    }

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


Measured memory_bytes: 256
//A - Frog 1
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

int n, a[100005];
int dp[100005];

int func(int ind){
	if (ind == (n-1))
		return 0;
	if (ind >= n)
		return INT_MAX;
	if (dp[ind]!= -1)
		return dp[ind];

	int left = abs(a[ind]- a[ind+1])+func(ind+1);
	int right = INT_MAX;

	if (ind+2<n)
	{
		right = abs(a[ind]-a[ind+2])+ func(ind+2);
	}
	return dp[ind] = min(left,right);
}

signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	memset(dp, -1, sizeof dp); 

	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	cout<<func(0)<<endl;
	return 0;
}


Measured memory_bytes: 9884
using System;

namespace ABC112_D___Partition
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static int solver()
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0];
            var M = NM[1];
            for (int i = N; i <= M / 2; i++)
            {
                if (M % i == 0) return M / i;
            }
            return 1;
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i<N;i++)
		cin >> a[i];
	int result = 0;
	for(int cp=0;cp<N-1;cp++)
	{
		if(a[cp]!=a[cp+1])
			continue;
		result++;
		a[cp+1]=0;
		if(cp==N-2)				break;
		if(a[cp+1]==a[cp+2])	cp+=1;
	}
	cout << result << std::endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll x, y, z, ans = 0;
	cin >> x >> y >> z;
	ll i = 0;
	if (x == y&&y == z) {
		if (x % 2 == 1 && y % 2 == 1 && z % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	while (x % 2 == 0 && y % 2 == 0 && z % 2 == 0) {
		ans++;
		ll a = x, b = y, c = z;
		x = (b + c) / 2;
		y = (c + a) / 2;
		z = (a + b) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#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 FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpii vector<pair<int,int> >
#define vvpii vector<vpii >
#define vpll vector<pair<ll,ll> >
#define vvpll vector<vpll >
#define pb push_back
#define MOD 1000000007

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};
const int mx = 3005;
ll dp[mx][mx];
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	ll n; cin >> n;
	vl v(n);
	for (auto &i : v)cin >> i;
	for (ll i = n - 1; i >= 0; i--) {
		for (ll j = i; j < n; j++) {
			if (i == j) dp[i][j] = v[i];
			else dp[i][j] = max(v[i] - dp[i + 1][j], v[j] - dp[i][j - 1]);
		}
	}
	cout << dp[0][n - 1] << endl;

}

Measured memory_bytes: 70016
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            int x, y;

            if(A>=B)
            {
                if(A>C)
                {
                    x = B;
                    y = C;
                }
                else
                {
                    x = B;
                    y = A;
                }
            }
            else
            {
                if(B>C)
                {
                    x = A;
                    y = C;
                }
                else
                {
                    x = A;
                    y = B;
                }
            }

            Console.Write((x*y/2).ToString());

        }
    }
}


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

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

    int l0 = 0;
    bool isBlack = true;
    rep(i, s.size()) {
        if (isBlack) {
            if (s[i] == '1')
                l0++;
        }
        else
        {
            if (s[i] == '0')
                l0++;
        }
        isBlack = !isBlack;
    }

    int l1 = 0;
    isBlack = false;
    rep(i, s.size()) {
        if (isBlack) {
            if (s[i] == '1')
                l1++;
        }
        else
        {
            if (s[i] == '0')
                l1++;
        }
        isBlack = !isBlack;
    }

    cout << min(l1, l0) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	constexpr long long int MOD = 1000000007LL;
	int height, width, a, b; std::cin >> height >> width >> a >> b;
	std::vector<long long int> factorial(height + width + 1, 1), div(height + width + 1, 1), inverse(height + width + 1, 1);
	for (auto i = 2; i < factorial.size(); ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		div[i] = (MOD - MOD / i) * div[MOD % i] % MOD;
		inverse[i] = div[i] * inverse[i - 1] % MOD;
	}
	if (a > b) {
		std::swap(height, width);
		std::swap(a, b);
	}
	const auto combination = [&factorial, &inverse, MOD](const int n, const int r) {return factorial[n] * inverse[r] % MOD * inverse[n - r] % MOD; };
	const auto pattern = [&combination, height, width, MOD](const int h, const int w) {return combination(h + w - 2, h - 1) * combination(height + width - h - w, height - h) % MOD; };
	long long int result{ combination(height + width - 2, height - 1) };
	const auto w = b - a + 1;
	for (auto h = 0; h < a; ++h) {
		result += MOD - pattern(height - h, w + h);
		result %= MOD;
	}
	std::cout << result << '\n';
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e;
  string s,ss;
  cin>>a>>b>>c;
  cout<<min(min(a*b/2,a*c/2),b*c/2)<<endl;
  return 0;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

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


int main(){
	FIO
	
	int n;
	cin >> n;
	cout << 48 - n << '\n';
	return 0; 
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d){
    cout<<"Yes"<<endl;
  }else if(abs(a-b)<=d&&abs(c-b)<=d){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

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

def gcd(a,b):
	while b:
		a,b=b,a%b
	return a
	

c=gcd(a,b)

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

print(len(d)+1)

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

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int N; cin >> N;
    ll ans = INF;
    ll a[200200], sum[200200];
    sum[0] = 0;
    rep(i, N) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    for(int j = 0; j <= N - 2; j++) {
        ll X = sum[j + 1], Y = sum[N] - sum[j + 1];
        ll res = abs(X - Y);
        ans = min(ans, res);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

ll solve(ll n, ll m, string const & s, string const & t) {
    unordered_map<int, char> fixed;
    ll l = lcm(n, m);
    REP (i, n) {
        int k = l * i / n;
        fixed[k] = s[i];
    }
    REP (j, m) {
        int k = l * j / m;
        if (fixed.count(k) and fixed[k] != t[j]) {
            return -1;
        }
    }
    return l;
}

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
    string t; cin >> t;
    cout << solve(n, m, s, t) << endl;
    return 0;
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
ll r(){ll x;cin>>x;return x;}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
void solve() 
{
    ll n,m,lcm=1;cin>>n>>m;ll a[n];
    REP(i,n)a[i]=r()/2;
    REP(i,n){
        lcm=lcm/gcd(a[i],lcm)*a[i];
        if(lcm>m){cout<<0<<endl;return;}
    }
    REP(i,n)if(lcm%(2*a[i])==0){cout<<0<<endl;return;}
    cout<<m/lcm-m/(lcm*2ll)<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	long double ok = *max_element(as.begin(), as.end()), ng = 0;
	for (int64_t t = 0; t < 100; t++)
	{
		long double mid = (ok + ng) / 2;

		int64_t cnt = 0;
		for (auto &&a : as)
		{
			cnt += max<long double>(0, ceil(a / mid) - 1);
		}

		((cnt <= k) ? ok : ng) = mid;
	}

	cout << int64_t(ceil(ok)) << endl;

	return 0;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
vector< vector<int> > m;
int H, W;
int main(void){
  cin >> H >> W;
  m = vector< vector<int> > (H, vector<int>(W));
  for(int p = 0; p < H; p++){
    string tmp; cin >> tmp;
    for(int j=0; j < tmp.length(); j++)
      m[p][j] = tmp[j] - '0';
  }

  vector< vector<int> > dp(H, vector<int>(W, 9*50*50*2));
  dp[0][0] = 0;
  for(int p = 0; p < H; p++){
    for(int q = 0; q < W; q++){
      if(!(p | q)) continue;
      if(!p)
        dp[p][q] = dp[p][q-1]+m[p][q];
      else if(!q)
        dp[p][q] = dp[p-1][q]+m[p][q];
      else
        dp[p][q] = min(dp[p-1][q]+m[p][q], dp[p][q-1]+m[p][q]);
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}

Measured memory_bytes: 1256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

struct SegmentTree {
  int n;
  vector<ll> dat;
  SegmentTree(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0ll);
  }
  void update(int k, ll a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  ll query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return max(vl, vr);
  }
  ll query(int a, int b) { return query(a, b, 0, 0, n); }
};

int main() {
  int N;
  while (cin >> N) {
    SegmentTree dp(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
      int x;
      cin >> x;
      --x;
      ll mx = dp.query(0, x);
      dp.update(x, mx + x + 1);
      sum += x + 1;
    }
    ll mx = 0;
    for (int i = 0; i < N; i++) {
      mx = max(mx, dp.query(i, i + 1));
    }
    ll ans = sum - mx;
    cout << ans << endl;
  }
}



Measured memory_bytes: 4960
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
//const long long mod = 1000000007;
const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::abs;
using std::priority_queue;

int main() {
	int N;
	scanf("%d", &N);
	switch (N%10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon");
		break;
	case 3:
		printf("bon");
		break;
	}
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -9223372036854775807
#define inf 9223372036854775807
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define to_low(s) for_each(s.begin(), s.end(), [](char & c) {c = ::tolower(c);})
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
int par[100000];
int sz[100000];
void init(){
	for(int i=0;i<100000;i++) par[i]=i,sz[i]=1;
}
int find(int x){
	if(par[x]==x) return x;
	return par[x]=find(par[x]);
}
void union_(int x,int y){
	int a=find(x);
	int b=find(y);
	if(a==b) return ;
	par[b]=a;
	sz[a]+=sz[b];
}
void solve(){
	init();
	int n,m,k;
	cin>>n>>m>>k;
	map<int,int> mp;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		mp[a]++;mp[b]++;
		union_(a,b);
	}
	vi ans(n);
	for(int i=0;i<n;i++){
		int val=sz[find(i)];
		ans[i]=val-1-mp[i];
	}
	for(int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		if(find(a)==find(b)) ans[a]--,ans[b]--;
	}
	cout<<ans;
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<vector<int>> a(2, vector<int> (n));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  vector<vector<int>> dp(2, vector<int> (n));
  dp[0][0] = a[0][0];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      // 右
      if (j + 1 < n) dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
      // した
      if (i + 1 < 2) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
    }
  }

  cout << dp[1][n - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a.at(i);
  map<ll,ll> mm;
  rep(i,n){
    mm[a.at(i)]++;
  }
  ll ans=0;
  for(auto p:mm){
    ans+=(p.second*(p.second-1))/2;
  }
  rep(i,n){
    ll ans2=ans;
    if(mm.at(a.at(i)) != 1){
      ans2= ans2-(mm.at(a.at(i))*(mm.at(a.at(i))-1))/2+((mm.at(a.at(i))-1)*(mm.at(a.at(i))-2))/2;
    }
    cout<<ans2<<endl;
  }
}

Measured memory_bytes: 12928
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll INFL = 1e18;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    int digits = 0;

    while(x > 0){
        x /= 10;
        digits++;
    }

    return digits;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    long long n;
    cin >> n;
    int ans = digit(n);
    for (long long i = 1LL;i * i <= n;i++){
        if (n % i != 0) continue;
        long long b = n / i;

        int res = max(digit(i), digit(b));

        if (ans > res){
            ans = res;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    string S;
    cin >> S;
    if (S == "SUN") {
        cout << 7 << 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;
    }
    if (S == "SAT") {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
def mapt(fn, *args):
    return list(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    a, b, c = Input()
    x, y, _ = sorted([abs(a-b), abs(b-c), abs(a-c)])
    print(x + y)


main()

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define SEP " "

int		main(void)
{
	ll a, b, k;
	cin >> a >> b >> k;
	if (a >= k)
	{
		cout << a-k << SEP << b << endl;
		return (0);
	}
	k -= a;
	if (b >= k)
		cout << 0 << SEP << b-k << endl;
	else
		cout << 0 << SEP << 0 << endl;
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# A, B = list(map(int, sys.stdin.readline().split()))
# if (A + B) & 1:
#     print('IMPOSSIBLE')
# else:
#     print((A + B)//2)


N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))
sp = list(sorted(P))
ok = False
for i, j in itertools.product(range(N), range(N)):
    P[i], P[j] = P[j], P[i]
    ok |= sp == P
    P[i], P[j] = P[j], P[i]
if ok:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 23188
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int q[1000000],C[100010];
int ta[100010],nt[200010],fr[200010],to[200010],co[200010];
int f[100010];
int dfs(int v,int e,int s,int d){
  int max=d,i,r;
  for(i=ta[s];i+1;i=nt[i]){//printf("f%d t%d\n",fr[i],to[i]);
    if(f[to[i]])continue;
    //printf("s%d t%d c%d d%d max%d g%d\n",s,to[i],co[i],d,max,g);
    f[to[i]]=1;
    C[to[i]]=C[s]+co[i];
    max=MAX(max,dfs(v,e,to[i],d+co[i]));//printf("r%d max%d->",r,max);
  }//printf("s%d max%d\n",s,max);
  return max;
}
int bfs(int v,int e,int s,int *g){
  int t,r,i,max=0;
  for(i=0;i<v;i++)C[i]=1000000000;
  C[q[0]=s]=t=0;//printf("a\n");
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){//printf("%d %d\n",fr[i],to[i]);
      if(C[to[i]]>C[fr[i]]+co[i]){
	C[to[i]]=C[fr[i]]+co[i];
        if(max<C[to[i]]){
	  max=C[to[i]];
	  *g=to[i];
	}
	q[r++]=to[i];
      }
    }//printf("\n");
  }//printf("%d\n",r);
  return max;
}
int tyokkei(int v,int e,int *a,int *b,int *c){
  int i,max=0,g;
  for(i=0;i<v;i++){
    ta[i]=-1;
    C[i]=1000000000;
    f[i]=0;
  }
  C[0]=0;
  f[0]=1;
  for(i=0;i<e;i++){
    nt[i]=ta[a[i]];
    fr[i]=a[i];
    to[i]=b[i];
    co[i]=c[i];
    ta[a[i]]=i;
    nt[i+e]=ta[b[i]];
    fr[i+e]=b[i];
    to[i+e]=a[i];
    co[i+e]=c[i];
    ta[b[i]]=i+e;    
  }//printf("a\n");
  //for(i=0;i<2*e;i++)printf("%d %d\n",fr[i],to[i]);printf("\n");
  max=dfs(v,e*2,0,0);//printf("g%d\n",g);
  for(i=0;i<v;i++){
    if(max==C[i])g=i;
    C[i]=1000000000;
    f[i]=0;
  }
  C[g]=0;
  f[g]=1;
  return dfs(v,e*2,g,0);
}
int main(){
  int n,a[100010],b[100010],c[100010],i;
  scanf("%d",&n);
  for(i=0;i<n-1;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  printf("%d\n",tyokkei(n,n-1,a,b,c));
  return 0;
}

Measured memory_bytes: 14176
using System;
class roller{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int n = int.Parse(str[0]);
    int k = int.Parse(str[1]);
    int count=0;
    str = Console.ReadLine().Split(' ');
    for(int i=0; i<n; i++){
      if(int.Parse(str[i]) >= k){
        count++;
      }
    }
    Console.WriteLine(count);
  }
}


Measured memory_bytes: 17632
#include"bits/stdc++.h"
using namespace std;

int main(){
  int n, i;
  double sum;
  cin >> n;
  vector <double> v(n);

  for(i=0; i<n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  sum = v[0];
  for(i=1; i<n; i++){
    sum = (sum + v[i]) / 2;
  }
  cout << sum << endl;

  return 0;
}


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

#define SWAP(x, y) do {        \
  int tmp = x; x = y; y = tmp; \
} while (0)

bool is_ordered(std::vector<int> &a) {
  int n = a.size();
  int last = a[0];
  for (int k = 1; k < n; ++k) {
    if (last < a[k]) {
      // OK
      last = a[k];
    } else {
      return false;
    }
  }
  return true;
}

int main(int argc, char** argv) {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }

  if (is_ordered(a)) {
    std::cout << "YES" << std::endl;
    return 0;
  }

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      // std::cout << i << " " << j << std::endl;
      SWAP(a[i], a[j]);

      bool r = is_ordered(a);
      if (r) {
        std::cout << "YES" << std::endl;
        return 0;
      }

      // Swap one more
      SWAP(a[i], a[j]);
    }
  }

  std::cout << "NO" << std::endl;
}


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

int main()
{
  i64 n, k;
  string s;
  cin >> n >> k >> s;
  vector<i64> sec;
  i64 bef = 0;
  for (i64 i = 1; i < n; i++)
    if (s[i - 1] != s[i])
    {
      sec.push_back(i - bef);
      bef = i;
    }
  sec.push_back(n - bef);
  i64 ans = 0, tmp = 0, r = 0, cnt = 0, size = sec.size();
  string now = (s[0] == '0' ? "01" : "10");
  for (i64 l = 0; l < size; l++)
  {
    while (r < size && (now[0] == '1' || (now[0] == '0' && cnt + 1 <= k)))
    {
      tmp += sec[r];
      r++;
      if (now[0] == '0')
        cnt++;
      swap(now[0], now[1]);
    }
    ans = max(ans, tmp);
    if (l == r)
      r++;
    else
    {
      tmp -= sec[l];
      if ((l % 2 == 0 && s[0] == '0') || (l % 2 == 1 && s[0] == '1'))
        cnt--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1528
primes = [0, 0] + [1]*246911
for i in range(2, 497):
    if primes[i]:
        for j in range(i*i, 246913, i):
            primes[j] = 0

while True:
    n = int(input())
    if n == 0:
        break
    print(sum(1 for i in range(n+1, 2*n+1) if primes[i]))

Measured memory_bytes: 11120
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int H, N; cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

    vector<int> dp; dp.push_back(0);

    int ans;
    int mp = 0;
    while (true) {
        mp++;
        dp.push_back(0);
        for (int i = 0; i < N; i++) {
            if (mp - B[i] >= 0) {
                dp[mp] = max(dp[mp], dp[mp - B[i]] + A[i]);
            }
        }
        if (dp[mp] >= H) {
            ans = mp;
            break;
        }
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 525652
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
int main(void){
    int n;
    ll X = 0,x = 0,ans = 100000000000000000LL;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        X += a[i];
    }
    for(int i = 0;i < n;i++){
        x += a[i];
        if(i < n-1)
        ans = min(ans,abs(X-2*x));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll          long long int
#define ull         unsigned long long int
#define pb(x)       push_back(x)
#define pob()		pop_back()
#define sort(a)     sort(a.begin(),a.end())
#define done        return 0

#define toUp(ch)    toupper(ch)
#define isUp(ch)    isupper(ch)  //prototype int isupper(int ch)
#define toLow(ch)   tolower(ch)
#define isLow(ch)   islower(ch)
#define isX(ch)     isxdigit(ch) //hexadecimal digits (0-9 && a-f && A-F)
#define isN(ch)     isdigit(ch)  //decimal digits(0-9)
#define isS(ch)     isspace(ch)  //whitespace
#define isP(ch)     ispunct(ch)  //check punctuations !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~.
#define isPr(ch)    isprint(ch)  //check \n \t \b
#define isA(ch)     isalpha(ch)  //alphabets
#define AtoN(ch)    atol(ch)     // string to integer
#define AtoF(ch)    atof(ch)     //string to double
//https://stackoverflow.com/questions/5590381/easiest-way-to-convert-int-to-string-in-c
//https://www.geeksforgeeks.org/converting-strings-numbers-cc/

/*----------[ string to integer ]--------------
string str;  int x=0;
stringstream demo(str);
demo >> x;
cout<< x <<endl;
*/

/*----------[ integer to string ]--------------
string name;  int x=345;
stringstream demo;
demo << x;
name=demo.str();
cout<< name <<endl;
*/
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    done;
}


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

struct P {
  string name;
  int time;
};
P in[LEN];
int head = 0;
int tail;

void enqueue(P x) {
  //オーバーフローはしない（n <= 1000000の制約)
  // xをinの末尾（tail)に代入する関数
  in[tail] = x;
  //  cout << "CHECK3 " << tail << endl;
  if (tail + 1 == LEN)
    tail = 0; // tail = LEN - 1で末尾のとき
  else
    tail++;
}

P dequeue() {
  // inの最初（head）の値を返す関数
  P x = in[head];
  if (head + 1 == LEN)
    head = 0;
  else
    head++;
  return x;
}

int main() {
  int n, q;
  cin >> n >> q;
  rep(i, n) cin >> in[i].name >> in[i].time;
  tail = n;
  int elapsed_time = 0;
  //ここから実行＋アウトプット部分
  while (head != tail) {
    P x = dequeue();
    //    cout << "CHECK2 " << x.name << endl;
    elapsed_time += min(x.time, q);
    if (x.time - q <= 0)
      cout << x.name << " " << elapsed_time << endl;
    else {
      x.time -= q;
      enqueue(x);
    }
  }
}



Measured memory_bytes: 21080