akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll cx,cy,x[123],y[123],h[123],p;
	bool flag = true;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i] >> h[i];
	}
	for(cx=0ll; cx<=100ll; ++cx){
		for(cy=0ll; cy<=100ll; ++cy){
			p=INFLL;
			for(i=0; i<n; ++i){
				p = min(h[i]+abs(x[i]-cx)+abs(y[i]-cy),p);
			}
			flag = true;
			for(i=0; i<n; ++i){
				if(max(p-abs(x[i]-cx)-abs(y[i]-cy),0ll)!=h[i]){
					flag = false;
					break;
				}
			}
			if(flag){
				cout << cx << " " << cy << " " << p << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    sort(all(a));
    reverse(all(a));
    ll ans = a[0];
    int cnt = 0, j = 1;
    for (int i = 2; i < n; i++) {
        ans += a[j];
        ++cnt;
        if (cnt == 2) {
            ++j;
            cnt = 0;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3976
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S;
	cin >> T;
	rep(k, 2) {
		rep(j, 26) {
			vector<char> v;
			rep(i, S.length()) {
				if (T[i] == 'a' + j) v.push_back(S[i]);
			}
			rep(i, (int)v.size() - 1) {
				//cout << v[i] <<" "<<  v[i + 1] << endl;
				if (v[i] != v[i + 1]) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
		swap(S, T);
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 916
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(void)
{
	vector<int> v;
	int tmp;
	for (int i = 0; i < 5; i++) {
		cin >> tmp;
		v.push_back(tmp);
	}
	stable_sort(v.begin(), v.end(), greater<int>());
	for (int i = 0; i < 4; i++) cout << v[i] << " ";
	cout << v[4] << endl;
	
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,D,X;
    cin>>N>>D>>X;
    int choco=X;
    for(int i=0;i<N;i++){
        int A;
        cin>>A;
        for(int j=1;j<=D;j+=A){
            choco++;
        }
    }
    cout<<choco<<endl;
}

Measured memory_bytes: 256
macro_rules! input { (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    for i in 1..b {
        if c == (a * i) % b {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
lli extGcd(lli a, lli b, lli &x, lli &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    else
    {
        lli d = extGcd(b, a % b, y, x);
        y -= a / b * x;
        return d;
    }
}

#define MAXN 200000
lli invN[MAXN + 1];
lli Fact[MAXN + 1];
lli FactInv[MAXN + 1];
void init()
{
    REPS(i, MAXN)
    {
        lli x, y;
        extGcd(i, MOD, x, y);
        x += MOD;
        x %= MOD;
        invN[i] = x;
    }
    Fact[0] = 1, FactInv[0] = 1;
    REPS(i, MAXN)
    {
        Fact[i] = (Fact[i - 1] * i) % MOD;
        FactInv[i] = (FactInv[i - 1] * invN[i]) % MOD;
    }
}

int main()
{
    init();
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli N, M, K;
    cin >> N >> M >> K;
    //  cout << Fact[7] << " " << FactInv[2] << "\n";
    lli MN = M * N;

    lli dLen = M * N;
    dLen %= MOD;
    dLen *= M + N;
    dLen %= MOD;
    dLen *= MN - 1;
    dLen %= MOD;
    dLen *= invN[12];
    dLen %= MOD;
    lli ans = (2 * dLen) % MOD;
    //cout << ans << "\n";
    ans *= Fact[MN - 2];
    ans %= MOD;
    ans *= FactInv[K - 2];
    ans %= MOD;
    ans *= FactInv[MN - K];
    ans %= MOD;
    cout << ans << "\n";
}

//NM C K * K C 2

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
ll cnt = 0;
void dfs(ll now,ll n) {
    if (now > n){
        return;
    } else {
        string x = to_string(now);
        if(count(x.begin(),x.end(),'3')&&count(x.begin(),x.end(),'5')&&count(x.begin(),x.end(),'7')){
            cnt++;
        }
        for (ll i = 3; i <= 7; i += 2) {
            dfs(now * 10 + i, n);
        }
    }
}
int main() {
    ll n;
    cin >> n;
    dfs(0LL, n);


    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N  = sc.nextInt();
		int M  = sc.nextInt();
		
		String[] A = new String[N];
		String[] B = new String[M];
		
		for(int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		
		for(int i = 0; i < M; i++) {
			B[i] = sc.next();
		}
		
		for(int i = 0; i <= N - M; i++) {
			for(int j = 0; j <= N - M; j++) {
				for(int k = 0; k < M; k++) {
					String a = A[k + i].substring(j, j + M);
					if(!a.equals(B[k])) {
						break;
					}
					if(k == M - 1) {
						System.out.println("Yes");
						return;
					}
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  int ans;
  cin >> A >> B;
 
  if(B == 1){
      cout << "0" << endl;
      return 0;
  }
  
  ans = ((B-A) + (A-2))/(A-1) + 1;
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%d%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%lld%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>a>>b;
    a-=b*2;
    cout<<max(a,0)<<endl;
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    ll x;
    cin >> x;
    for (ll i = 1; i <= 10000; i++) {
        for (ll j = i * (-1); j <= i; j++) {
            if (i * i * i * i * i - j * j * j * j * j == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

const int MAXN = 2000 + 10;

int N;
string a, b;
int answer = 0x7F7F7F7F;
int asum, bsum;

int pre[MAXN], nxt[MAXN], mx[MAXN];
void solve()
{
	memset(pre, 0x00, sizeof pre);
	memset(nxt, 0x00, sizeof nxt);
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j < N; j++)
			if(b[(i-j+N) % N] == '1')
			{
				pre[i] = j;
				break;
			}
		for(int j = 0; j < N; j++)
			if(b[(i+j)%N]  == '1')
			{
				nxt[i] = j;
				break;
			}
	}

	for(int i = 0; i < N; i++)
	{
		int tCnt = 0;
		memset(mx, 0x00, sizeof mx);
		for(int j = 0; j < N; j++)
			if(a[j] != b[(i + j) % N])
				tCnt++, mx[pre[j]] = max(mx[pre[j]], nxt[j]);
		int mn = 0x7F7F7F7F, cnt = i;
		for(int j = N - 1; j >= 0; j--)
			mn = min(mn, cnt + j), cnt = max(cnt, mx[j]);
		answer = min(answer, 2 * mn - i + tCnt);
	}
}

int main()
{
	cin >> a >> b ;
	N = a.length();

	for(const auto & x : a)
		if(x == '1')
			asum++;
	for(const auto & x : b)
		if(x == '1')
			bsum++;

	if(asum == 0 && bsum == 0)
		return cout << 0 << endl, 0;
	else if(bsum == 0)
		return cout << -1<< endl, 0;

	solve();
	reverse(a.begin(), a.end()), reverse(b.begin(), b.end());
	solve();
	cout << answer << endl ;
	return 0;

}


Measured memory_bytes: 384
#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;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < n; i++)
    {
        ans=(ans+v[i])/2;
    }
   printf("%.10f\n",ans);
    return 0;
}


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

int main(){
    int N;
    int a[110];
    cin >> N;
    for (int i; i < N; ++i) cin >> a[i];

    sort(a,a+N,greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i){
        if(i %2 == 0){
            Alice += a[i];
        }
        else{
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
N,A,B = (int(x) for x in input().split())

Kurikaeshi = N // (A + B) 
Amari = N % (A + B)
Aoi = 0 

if Amari >= A:
    Aoi = A
else:
    Aoi = Amari

result = Aoi + Kurikaeshi * A


print(result)


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll x,k,d; cin>>x>>k>>d;
    ll cnt=abs(x)/d;
    if(cnt+1<k){
        if(x>0){
            if(abs(x-d*cnt)<abs(x-d*(cnt+1))){
                x=x-d*cnt;
                if((k-cnt)%2==0){
                    cout<<abs(x)<<endl;
                    return 0;
                }
                else{
                    cout<<min(abs(x-d),abs(x+d))<<endl;
                    return 0;
                }
            }
            else {
                x=x-d*(cnt+1);
                       if((k-(cnt+1))%2==0){
                    cout<<abs(x)<<endl;
                    return 0;
                }
                else{
                    cout<<min(abs(x-d),abs(x+d))<<endl;
                    return 0;
                }
            }
        }
        else{
                if(abs(x+d*cnt)<abs(x+d*(cnt+1))){
                x=x+d*cnt;
                       if((k-cnt)%2==0){
                    cout<<abs(x)<<endl;
                    return 0;
                }
                else{
                    cout<<min(abs(x-d),abs(x+d))<<endl;
                    return 0;
                }
            }
            else {
                x=x+d*(cnt+1);
                       if((k-(cnt+1))%2==0){
                    cout<<abs(x)<<endl;
                    return 0;
                }
                else{
                    cout<<min(abs(x-d),abs(x+d))<<endl;
                    return 0;
                }
            }
        }
    }
    else{
        cout<<abs(abs(x)-k*d)<<endl;
        return 0;
    }
}
   




















Measured memory_bytes: 3632
N = int(input().strip())
D,X = map(int, input().strip().split(' '))
A = [int(input().strip()) for _ in range(N)]

ans = 0
for a in A:
  now = 1
  while True:
    if now > D: break
    ans += 1
    now += a
    
print(ans+X)


Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
#define ran 100010
int n,a[ran],c[ran];
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d",&a[i]);
		c[i] = labs(i-(n-1-i));
	}
	sort(a,a+n);
	sort(c,c+n);
	if(memcmp(a,c,sizeof(int)*n) != 0)puts("0");else{
		int r=1;
		for(int i=1; i<n; i++)if(a[i] == a[i-1])
			r = r * 2 % 1000000007;
		printf("%d\n",r);
	}
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func popCount(v int) int {
	cnt := 0
	for v > 0 {
		if v&1 == 1 {
			cnt++
		}
		v = v >> 1
	}
	return cnt
}

func main() {
	defer write.Flush()

	var n, m uint
	fmt.Fscan(read, &n, &m)

	lights := make([]int, m)
	for i := range lights {
		var k int
		fmt.Fscan(read, &k)
		for j := 0; j < k; j++ {
			var s uint
			fmt.Fscan(read, &s)
			lights[i] |= (1 << (s - 1))
		}
	}

	points := make([]int, m)
	for i := range points {
		fmt.Fscan(read, &points[i])
	}

	ans := 0
	for mask := 0; mask < (1 << n); mask++ {
		var i uint
		chk := true
		for i = 0; i < m; i++ {
			if popCount(mask&lights[i])%2 != points[i] {
				chk = false
				break
			}
		}
		if chk {
			ans++
		}
	}
	fmt.Fprintln(write, ans)
}


Measured memory_bytes: 640
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		while (true) {
			int w = sc.nextInt(), d = sc.nextInt();
			if (w == 0 && d == 0) break;
			
			int[] h = new int[21];
			int ans = 0;
			for (int i = 0; i < w; i++) {
				int t = sc.nextInt();
				h[t]++;
				ans += t;
			}
			for (int i = 0; i < d; i++) {
				int t = sc.nextInt();
				if (h[t] > 0) h[t]--;
				else ans += t;
			}
			
			out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 23236
from sys import stdin
from collections import defaultdict,deque

N = int(stdin.readline().rstrip())
adj = defaultdict(set)

for i in range(N-1):
    u,v,w = [int(x) for x in stdin.readline().rstrip().split()]
    adj[u].add((v,w))
    adj[v].add((u,w))


ans = [0]*(N+1)
visit_p = deque()
visit_p.append((1,0))
visited = [False]*(N+1)
visited[1] = True


while visit_p:
    now_v,now_w = visit_p.popleft()
    for v,w in adj[now_v]:
        if visited[v]:
            continue
        ans[v] = w + now_w
        visited[v] = True
        visit_p.append((v,w+now_w))
for i in ans[1:]:
    if i % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 61556
#include <iostream>
#include <math.h>
#include <cstdlib>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    int n; cin>>n;
    string s; cin>>s; s+='a';
    int l_w_g=0, l_r_g=0, mi_op=999999999;
    for (int i=0;i<n;i++)
    {
        if (s[i]=='R') l_r_g++;
        else l_w_g++;
    }
    int l_w=0, l_r=0;
    for (int i=0;i<=n;i++)
    {
        int mniej=min(l_w, l_r_g-l_r);
        mi_op=min(mi_op, mniej+max(l_w, l_r_g-l_r)-mniej);
        if (s[i]=='R') l_r++;
        else l_w++;
    }
    cout<<mi_op;
}


Measured memory_bytes: 3792
N = int(input())
l = []

for _ in range(N):
    X, L = map(int, input().split())
    l.append((X-L, X+L))

l.sort(key=lambda x:x[1])
before = -10**9
ans = 0

for i, j in l:
    if i>=before:
        ans += 1
        before = j

print(ans)

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

int main() {
 int N, X;
 cin >> N >> X;
 int a[110];
 
 for(int i=0; i<N ; i++) cin >> a[i];
 
 sort(a,a+N);
 int count = 0;
 
 for(int i=0; i<N ; i++) {
      X -= a[i];
      if (X >=  0) count++ ;
      else break;
 }
 
 if (X>0) count--;
 cout << count << endl;
}
 

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<(n);++i)
#define ote(x) cout<<(x)<<endl
string L = "(";
string R = ")";

int main(){
	int N; cin>>N;
	string S; cin>>S;
	int depth = 0;

	string ans = "";
	rp(i, N){
		char s = S[i];
		if(S[i]=='('){
			// puts("push");//
			depth++;
			ans += L;
		}
		else{
			depth--;
			ans += R;
			if(depth<0){
				ans = L + ans;
				depth++;
			}
		}
	}
	// ote(depth);//
	while(depth--){
		ans += R;
	}
	ote(ans);
}


Measured memory_bytes: 256
import java.util.*;
import java.text.DateFormat;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int count = 0;
        if (a <= b) {
            count = a;
        } else {
            count = a - 1;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23252
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(i,n) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'A')
#define itoc(c) (char)(c+'A')
#define pb push_back
#define cauto const auto&
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
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 read() { ll u, k = scanf(" %lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------------------
int n, k;
vec<H>v;
signed main() {
	cin >> n >> k;
	if ((n - 1) * (n - 2) / 2 < k) cout << -1 << endl;
	else {
		vec<H>v;
		int s = (n - 1) * (n - 2) / 2;
		rep(i, n - 1) {
			v.pp(1, i + 2);
		}
		for (int i = 2; i <= n && s > k; i++) {
			for (int j = i + 1; j <= n && s > k; j++) {
				v.pp(i, j);
				s--;
			}
		}
		cout << v.size() << endl;
		for (auto g : v) {
			cout << g.fs << " " << g.sc << endl;
		}
	}
}

Measured memory_bytes: 512
from collections import deque
n, q = map(int, input().split())

road = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(n - 1):
    a, b = map(int, input().split())
    road[a - 1].append(b - 1)
    road[b - 1].append(a - 1)

for i in range(q):
    idx, v = map(int, input().split())
    cnt[idx - 1] += v

dist = [-1] * n
que = deque()
dist[0] = 0
que.append(0)

while(len(que) != 0):
    # BFS/DFS
    v = que.pop()
    for r in road[v]:
        if dist[r] != -1:
            continue
        # print(r, v)
        dist[r] = dist[v] + 1
        cnt[r] += cnt[v]
        que.append(r)
print(*cnt)

Measured memory_bytes: 62884
X,N = map(int,input().split())
if N!=0:
    p=list(map(int,input().split()))
    p.sort()
    for i in range(X,102):
        if i not in p:
            min_=i
            dif_min=i-X
            break;
    for i in range(X,-1,-1):
        if i not in p:
            max_=i
            dif_max=X-i
            break;
    if dif_max<=dif_min:
          print(max_)
    else:
          print(min_)
else:
    print(X)

Measured memory_bytes: 9200
#include<iostream>
#include<cstdio>
#include<string>
#include<sstream>
#include<algorithm>
using namespace std;

int solve(int[][100],int ,int);
int main(){
  int data[100][100],limx,limy;
  string line;
  int x;
  char ch; // dammy

  //init
  for(int i=0;i<100;i++)
    for(int j=0;j<100;j++)
      data[i][j]=0;

  int i=0;
  while ( cin >> line){
    istringstream sin(line);
    int j=0;
    while ( sin >> x  ){
      //cout << x << endl;
      data[i][j]=x;
      sin >> ch;
      j++;
      limx=max(limx,j);
    }
    i++;
  }
  limy=i;

  printf("%d\n",solve(data,limx,limy));
  return 0;
}

int solve(int data[][100],int limx,int limy){
 
  int dp[limy+1][limx+1];

  //init
  for(int i=0;i<=limy;i++)
    for(int j=0;j<=limx;j++)
      dp[i][j]=0;


  dp[0][0]=data[0][0];
  for(int i=1;i<limy;i++){
    for(int j=0;j<limx;j++){
      if(j==0 && i<=limy/2)
	dp[i][j]=dp[i-1][j]+data[i][0];
      else if(j!=0 && i<=limy/2)
	dp[i][j]=max(dp[i-1][j-1]+data[i][j],dp[i-1][j]+data[i][j]);
      else
	dp[i][j]=max(dp[i-1][j]+data[i][j],dp[i-1][j+1]+data[i][j]);
    }
  }
  /* for(int i=0;i<limy;i++){
    for(int j=0;j<limx;j++)
      printf("%d ",dp[i][j]);
    puts("");
    }*/
  return dp[limy-1][0];
}

Measured memory_bytes: 1276
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	//string s = "";
	while (true)
	{
		int n;
		cin >> n;
		if (n == 0)break;
		ivec A[31];
		//??\?????????1?§?????????????????????????1?§???????
		for (int i = 1; i <= n; i++)//????????????
		{
			int f;
			cin >> f;
			for (int j = 0; j < f; j++)
			{
				int k;
				cin >> k;
				A[k].push_back(i);
			}
		}
		if (n == 1)
		{
			for (int i = 1; i < 31; i++)
			{
				if (A[i].size() > 0)
				{
					cout << i << endl;
					//s += to_string(i) + "\n";
					break;
				}
			}
			continue;
		}


		set<int> ds[100];//????????°
		for (int i = 1; i <= n; i++)
		{
			ds[i].insert(i);
		}
		int ok = 0;

		for (int k = 1; k < 31; k++)//??\?????????
		{
			set<int> today;
			for (auto i: A[k])//????????????
			{
				for (auto j : ds[i])
				{
					today.insert(j);
				}
			}
			if (today.size() == n)
			{
				cout << k << endl;
				//s += to_string(i) + "\n";
				ok = 1;
				break;
			}
			for (auto i : A[k])
			{
				ds[i] = today;
			}
		
		}
		if (!ok)
		{
			cout << -1 << endl;
			//s += to_string(-1) + "\n";
		}

	}
	
	//cout << s;

	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <cstdio>
#include <limits.h>

using namespace std;

#define SENTINEL INT_MAX

int cnt = 0;
int s[500000];


void merge(int A[], int left,int mid,int right)
{
	int n1 = mid - left;
	int n2 = right - mid;

	int *L = new int[n1 + 1];
	int *R = new int[n2 + 1];
	

	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}

	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}

	L[n1] = R[n2] = SENTINEL;

	int i = 0;
	int j = 0;

	for (int k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
		cnt++;
	}

	delete[] R;
	delete[] L;

}

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

int main(void)
{
	int n;


	cin >> n;

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

	mergeSort(s, 0, n);

	for (int i = 0; i < n; i++) {
		if (i != 0) {
			putchar(' ');
		}
		cout << s[i];
	}

	cout << endl << cnt << endl;

	return 0;

}

Measured memory_bytes: 6728
#include <iostream>
#include <set>

using namespace std;

int main()
{
    long long H, W, N;
    cin>>H>>W>>N;
    set<long long> P, C;
    for (int i=0; i<N; i++)
    {
        long long a, b;
        cin>>a>>b;
        a--, b--;
        P.insert(a<<32|b);

        for (int dx=-2; dx<=0; dx++)
        for (int dy=-2; dy<=0; dy++)
        {
            long long x = a + dx;
            long long y = b + dy;
            if (0<=x && x<H-2 && 0<=y && y<W-2)
                C.insert(x<<32|y);
        }
    }

    long long ans[10] = {};

    for (long long c: C)
    {
        long long x = c>>32;
        long long y = c&0xffffffff;
        int num = 0;
        for (int dx=0; dx<3; dx++)
        for (int dy=0; dy<3; dy++)
            if (P.count((x+dx)<<32|(y+dy))>0)
                num++;
        ans[num]++;
    }

    ans[0] = (W-2)*(H-2);
    for (int i=1; i<=9; i++)
        ans[0] -= ans[i];

    for (long long a: ans)
        cout<<a<<endl;
}


Measured memory_bytes: 47104
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll t(n), d(n);
    REP(i, n) {
        cin >> t[i] >> d[i];
        t[i]--;
    }
    vll ord(n); iota(ord.begin(), ord.end(), 0LL);
    sort(ord.begin(), ord.end(), [&](ll i, ll j) {
        return d[i] > d[j];
    });
    vll count(n, 0);
    ll cnt = 0, ans = 0;
    REP(i, k) {
        ans += d[ord[i]];
        count[t[ord[i]]]++;
        if (count[t[ord[i]]] == 1) cnt++;
    }
    ans += cnt*cnt;
    
    ll tmp = ans;
    priority_queue<P<ll, ll> > que;
    REP(i, k) if (count[t[ord[i]]] >= 2) que.push(make_pair(-d[ord[i]], t[ord[i]]));
    rep(i, k, n) {
        if (que.empty()) break;
        if (count[t[ord[i]]] == 0) {
            P<ll, ll> q = que.top(); que.pop();
            while (!que.empty() && count[q.second] == 1) {
                q = que.top(); que.pop();
            }
            if (count[q.second] == 1) continue;
            count[q.second]--;
            tmp += q.first;
            tmp += d[ord[i]];
            count[t[ord[i]]] = 1;
            tmp -= cnt*cnt;
            cnt++;
            tmp += cnt*cnt;
            chmax(ans, tmp);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4600
#include <stdio.h>
 
int main() {
 
  int a,b=0,i,j,N,A[100],count,minj;
 
  while(1) {
    scanf("%d",&N);
    if(N<0 || 100<N) printf("error\n");
    else break;
  }
 
  while(1) {
    count=0;
    for(i=0; i<N; i++) scanf("%d",&A[i]);
    for(i=0; i<N; i++) if(A[i]<0 || 100<A[i]) count++;
    if(count!=0) printf("error\n");
    else break;
  }
 
  for(i=0; i<N; i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[minj]) {
        minj = j;
        count++;
      }
    }
    if(count!=0) {
      a = A[i];
      A[i] = A[minj];
      A[minj] = a;
      b++;
      count = 0;
    }
  }
 
  for(i=0; i<N; i++) {
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",b);
 
  return 0;
}

Measured memory_bytes: 604
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
#define maxv 114514
vector<int> gr[maxv];//隣接リストで持つグラフ
vector<int> fo,si;
string f="No";
void dfs(int v,int u){
	if(v==fo[1]) return;
	if(v==fo[0]){
		f="Yes";return;
	}
	rep(i,gr[v].size()){
		int w=gr[v][i];
		if(w!=u) dfs(w,v);
	}
}
string cal(){
	int n,m,a,b;
	cin>>n>>m;
	rep(i,m){
		cin>>a>>b;a--;b--;
		gr[a].pb(b);gr[b].pb(a);
	}
	rep(i,n){
		if(gr[i].size()%2!=0){
			return "No";
		}
		if(gr[i].size()>4) si.pb(i);
		else if(gr[i].size()>2) fo.pb(i);
	}
	if(m<n+2) return "No";
	//cout<<fo.size()<<endl;
	if(si.size()>0 || fo.size()>2) return "Yes";
	if(fo.size()<2) return "No";
	//cout<<fo[0]<<' '<<fo[1]<<endl;
	rep(i,gr[fo[0]].size()) dfs(gr[fo[0]][i],fo[0]);
	return f;
}
int main()
{
	cout<<cal()<<endl;
}


Measured memory_bytes: 7168
class Main {
	public static void main(String[] args){
		String S = new java.util.Scanner(System.in).nextLine();
		String[] Schar = S.split("");
		int N = 0;
		for (int i = 0; i < 4; i++) {
			if (Schar[i].equals("+")) {
				N++;
			} else {
				N--;
			}
		}
		System.out.println(N);
	}
}

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

int main(void) {
	int l, r;
	int min = 2019;
	scanf("%d %d", &l, &r);
	int f = 0;
	for (int i = l; i <= r; i++) {
		if (f == 1) {
			break;
		}
		for (int j = i + 1; j <= r; j++) {
			//printf("%d %d %d\n", i % 2019, j % 2019, (i % 2019) * (j % 2019) % 2019);
			if ((i % 2019) * (j % 2019) % 2019 < min){ 
				min = (i % 2019) * (j % 2019) % 2019;
			}
			if (i * j == 0 || min == 0) {
				min = 0;
				f = 1;
				break;
			}
		}
	}
	printf("%d\n", min);
	return 0;
}






Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int n, id, c, p[100009], d[100009]; vector<int> child[100009]; bool vis[100009];
void rec(int pos) {
	vis[pos] = true;
	for (int i : child[pos]) rec(i);
}
void solve(int pos) {
	for (int i : child[pos]) {
		d[i] = d[pos] + 1;
		p[i] = pos;
		solve(i);
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &id, &c);
		child[id].resize(c);
		for (int j = 0; j < c; j++) {
			scanf("%d", &child[id][j]);
		}
	}
	int root = -1;
	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			root = i;
			rec(i);
		}
	}
	solve(root); p[root] = -1;
	for (int i = 0; i < n; i++) {
		printf("node %d: parent = %d, depth = %d, %s, [", i, p[i], d[i], (i == root ? "root" : (child[i].size() ? "internal node" : "leaf")));
		for (int j = 0; j < child[i].size(); j++) {
			if (j) printf(", ");
			printf("%d", child[i][j]);
		}
		printf("]\n");
	}
	return 0;
}

Measured memory_bytes: 6356
#include <stdio.h>

int main(void) {
  int H, W, i, j;

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

    for(i=0;i<H;i++) {
      for(j=0;j<W;j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2024
def b161(n , m , al):

    ans = "Yes"
    al.sort(reverse=True)
    gou = sum(al)

    for i in range(m):
        if al[i] < gou / (4 * m):
            ans = "No"

    return ans

def main():
    n , m = map(int , input().split())
    al = list(map(int , input().split()))
    print(b161(n , m , al))

if __name__ == '__main__':
    main()

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

int main(){
	vector<int> v(5000);
	int n , sum=0 , max=-2000000000;
	while(cin>>n,n){
		sum=0;
		max=-2000000000;
		for(int i=0;i<n;++i){
			cin >> v[i];
		}
		for(int i=n;i>=0;--i){
			for(int j=i;j<n;++j){
			sum+=v[j];
			if(sum>max) max=sum;
			}
			sum=0;
		}
		cout << max << endl;
	}
	return 0; 
}

Measured memory_bytes: 1212
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */
int main(){
    int N, M;cin >> N >> M;
    vector<vector<int>> bulb(M);
    for(int i = 0;i < M; ++i){
        int k;cin >> k;
        for(int j = 0; j < k; ++j){
            int s;cin >> s;
            bulb[i].push_back(s - 1);
        }
    }
    int p[M];
    int ans = 0;
    rep(i, M)cin >> p[i];
    for(int bit = 0;bit < (1 << N);++bit){
        bool on[N];
        for(int i = 0;i < N;++i){
            if(1 << i & bit)
                on[i] = true;
            else
                on[i] = false;
        }
        vector<int> bulbOnCount(M, 0);
        bool okFlg = true;
        for(int i = 0;i < M;++i){
            for(int v : bulb[i]){
                if(on[v])bulbOnCount[i] += 1;
            }
            if(bulbOnCount[i] % 2 != p[i])okFlg = false;
        }
        if(okFlg)ans++;
    }
    cout << ans << endl;
}


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

int main()
{
    int n, mx = 0;
    long long x, a[107], s = 0;
    cin >> n >> x;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for(int i = 0; i < n; i++)
    {
        if(s + a[i] > x) break;
        s += a[i];
        mx++;
    }
    if(s != x && mx == n) mx--;
    cout << mx << endl;
    return 0;
}

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

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int N,ma,sum;
	sum = 0;
	ma = 0;
	cin >> N;

	vint L(N);
	
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		ma = max(L[i], ma);
		sum += L[i];
	}
	if (ma < sum - ma)cout << "Yes" << endl;
	else cout << "No" << endl;


	
}



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

int main()
{
  string str;

  //getline(cin, str);
  
  while (cin >> str){
    int cnt1, cnt2;
    cnt1 = cnt2 = 0;

    for (int i = 2; i < str.size(); i++){
     if (str[i] == 'I' && str[i - 1] == 'O'){
       if (str[i - 2] == 'J'){
          cnt1++;
       }
       if (str[i] == str[i - 2]){
          cnt2++;
        }
      }
    }
    cout << cnt1 << "\n" << cnt2 << endl;
  }
  return 0;
}

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

// unsigned GetDigit(unsigned num){
//     unsigned digit = 0;
//     while(num!=0){
//         num/=10;
//         ++digit;
//     }
//     return digit;
// }

// bool check(int N,vector<bool> rest){
//     while(N!=0){
//         if(rest[N%10]){
//             return false;
//         }else{
//             N/=10;
//         }
        
//     }

//     return true;
// }

int main(){
    int N,K ;
    cin >> N >>K;
    vector<bool> rest(10, true);

    REP(i,K){
        int tmp;
        cin >> tmp;
        rest[tmp] = false;
    }



    int x;
    while(1){
        bool ok = true;
        x = N;
        while(x>0){
            if (!rest[x % 10]) {
				ok = false; break;
			}
			x /= 10;
        }
        if(ok) break;

        N++;
    }
    cout << N<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N, M;
  	cin >> N >> M;
  	int p[M];
  	string S[M];

  	string check[2] = {"AC", "WA"};

  	for(int i=0;i<M;i++){
  		cin >> p[i] >> S[i];
  	}

  	bool Acnt[N+1];
  	int Wcnt[N+1];
  	for(int k=1;k<=N;k++) Acnt[k] = false;

  	for(int k=1;k<=N;k++) Wcnt[k] = 0;

  	for(int i=0;i<M;i++){
  		if(S[i]==check[0]){
  			Acnt[p[i]] = true;
  		}else{
  			if(!Acnt[p[i]]) Wcnt[p[i]]++;
  		}
  	}

  	int ACans = 0;
  	for(int k=1;k<=N;k++){
  		if(Acnt[k]) ACans++;
  	}
  	cout << ACans << " ";


  	int WAans = 0;
  	for(int k=1;k<=N;k++){
  		if(Acnt[k]) WAans += Wcnt[k];
  	}
  	cout << WAans <<endl;

    
  	return 0;
}

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

constexpr int MAX_N = 50;

int v[MAX_N];

int main() {
  int N; cin >> N;
  for (int i{}; i < N; ++i) {
    cin >> v[i];
  }
  sort(v, v+N);

  double ans = v[0];
  for (int i{1}; i < N; ++i) {
    ans += v[i];
    ans /= 2;
  }

  cout << ans << 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++)

int main()
{
    int n, m;
    cin >> n >> m;
    if (n == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	int a=sc.nextInt(),b=sc.nextInt(),x=sc.nextInt();

	if(x-a<0 || (a+b)<x) {
		System.out.println("NO");
	}else {
		System.out.println("YES");
	}

	}
}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        char s;
        cin >> s;
        if (s == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	int k,p;
	int ans;
	int i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		
		scanf("%d %d",&k,&p);
		
		
	
		ans=k%p;
	
		if(k%p==0){
			printf("%d\n",p);
			}else{
			printf("%d\n",ans);
			
		}
	}
	
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int ans=0;
    int N;
    cin >> N;
    int p[N];
    rep(i,N) {
        cin >> p[i];
        if(p[i]==i+1) ans++;
    }
    rep(i,N-1){
        if(p[i]==i+1 && p[i+1] == i+2) {
            ans--;
            i++;
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VVL vector<vector<ll>>

int main(){
  ll N, M;
  cin >> N >> M;
  VVL a(N, VL(2,0));
  VL c(N);
  rep(i,0,N){
    cin >> a[i][0] >> a[i][1];
  }
  
  //特定キーでのソート　要素0,1...ex)要素1/////////////////////////////////////////// 
  sort(a.begin(), a.end(),
    [](const VL &alpha, const VL &beta)
    {return alpha[0]<beta[0];});
  
  ll num = 0, ans = 0;
  rep(i,0,N){
    num = min(a[i][1], M);
    ans += num * a[i][0];
    M -= num;
    if(M == 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9564
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
// 82

using namespace std;

int mat[3][101], dp[3][101];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= 2; i++) {
        for(j = 1; j <= n; j++)
            cin >> mat[i][j];
    }
    for(i = 1; i <= 2; i++) {
        for(j = 1; j <= n; j++) {
            dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) + mat[i][j];
        }
    }
    cout << dp[2][n];
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
a = []
while True:
  H, W = list(map(int, input().split(' ')))
  if H == 0 and W == 0:
    break
  a.append([H, W])
for l in a:
  for h in range(l[0]):
    for w in range(l[1]):
      if h%2==0:
        print('#' if w%2==0 else '.', end='')
      else:
        print('.' if w%2==0 else '#', end='')
    print('', sep='\n')
  print('', sep='\n')


Measured memory_bytes: 7016