akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<int> odd, none;
    // bool ans = true;
    rep(i,n){
        int a;
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 == 0 || a % 5 == 0) odd.push_back(a);
            else none.push_back(a);
        }
    }
    // if(odd.empty()) ans = false;
    if(none.empty()) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
    int n,m;
    cin>>n>>m;
    long long p;
    if(abs(n-m)>1) cout<<0<<endl;
    else{
        long long  sum=1,cnt=1;
        for(int i=1;i<=n;i++) {
                sum*=i;
                sum%=mod;
        }
        for(int i=1;i<=m;i++) {
                cnt*=i;
                cnt%=mod;
        }
        p=cnt*sum%mod;
        if(m==n) p*=2;
        p%=mod;
        cout<<p<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    string tmp;
    unordered_set<string> s;
    while(n--) {
        cin >> tmp;
        s.insert(tmp);
    }
    cout << s.size() << endl;
    return 0;
}



Measured memory_bytes: 17672
import sys

sys.setrecursionlimit(10**9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

K, X = LIST()

start = max(-1000000, X-K+1)
end = min(1000000, X+K-1)

L = list(range(start, end+1))
print(' '.join(map(str, L)))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  int n;
  cin >> n;
  unsigned long l[2];
  l[0] = 2;
  l[1] = 1;
  for (int i = 0; i < n; i++)
  {
    auto t = l[0];
    l[0] = l[1];
    l[1] += t;
  }
  cout << l[0] << endl;
  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int M=1e6;
const int mod7=1e9+7;
const int mod=998244353;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    double a;
    cin>>a;
    printf("%.2f",3.1415926*a*2);
    return 0;
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL &x, LL &y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i%m;
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

LL N, A, B, C, D;
std::vector<std::vector<LL>>memo;
LL dp(LL i, LL j)
{
	if (i == 0) return 1;
	if (j > B) return 0;
	if (memo[i][j] != -1) return memo[i][j];
	LL res = dp(i, j + 1), c = 1;
	for (LL k = 1; k < C; ++k) c = (c*mod_comb(i - j * (k - 1), j, mod)) % mod;
	for (LL k = C; k <= D; ++k)
	{
		if (j*k > i) break;
		c = (c*mod_comb(i - j * (k - 1), j, mod)) % mod;
		res += ((dp(i - j * k, j + 1)*c) % mod)*mod_inverse(fact[k], mod);
		res %= mod;
	}
	return memo[i][j] = res;
}

int main()
{
	in >> N >> A >> B >> C >> D;

	mod_fact(N, mod);
	memo.resize(N + 1);
	rep(i, memo.size()) memo[i].resize(N + 1, -1);
	out << dp(N, A) << std::endl;
}


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

#define MAX_N 131072
typedef long long LL;

LL dat[2 * MAX_N - 1];
int n;

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 maxvalue(int a, int b, int k, int left, int r){
	if( r <= a || b <= left ) return 0;
	if( a <= left && r <= b ) return dat[k];
	else{
		LL vl = maxvalue(a, b, k * 2 + 1, left, (left + r) / 2);
		LL vr = maxvalue(a, b, k * 2 + 2, (left + r) / 2, r);
		return max(vl, vr);
	}
}

int main(){
	int x;
	int n0;
	scanf("%d", &n0);
	
	n = n0 + 1;
	while( n & (n - 1) ){
		n += n & -n;
	}

	for(int i = 0; i < n0; ++i){
		scanf("%d", &x);

		LL y = maxvalue(0, x, 0, 0, n);
		update(x, y + x);
	}
	
	LL m = maxvalue(0, n0 + 1, 0, 0, n);
	printf("%lld\n", (LL)n0 * (n0 + 1) / 2 - m);
}

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


int main() {
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
    cout<<"hon";
    else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8 )
    cout<<"pon";
    else cout<<"bon";
    
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define M (ll) (1e5+7)
#define INF (3e18)
typedef vector < vector<pll> > vvpll;
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0);
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            if((i<b and j<a) or (b<=i and a<=j)) cout<<1;
            else cout<<0;
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 1280
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
// #define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int k;
int a[100010];

signed main(){

    cin >> k;
    rep(i,k) cin >> a[i];

    if(a[k-1] != 2){
        cout << -1 << endl;
        return 0;
    }

    int max_n = 2;
    int min_n = 2;

    rep(i,k){
        int n1,n2;
        n1 = ((min_n-1)/a[k-1-i]+1)*a[k-1-i];
        n2 = (max_n/a[k-1-i])*a[k-1-i];
        if(min_n <= n1 && n1 <= max_n && min_n <= n2 && n2 <= max_n ){
            min_n = n1;
            max_n = n2 + a[k-1-i] -1;
        }else{
            cout << -1 << endl;
            return 0;
        }
        // cerr << min_n << " " << max_n << endl;     
    }
    cout << min_n << " " << max_n <<endl;
    

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 1024
import numpy as np
mod = 10 ** 9 + 7

if __name__ == "__main__":
	N = int(input())
	L = list(map(int, input().split()))
	L = np.array(L, np.int64)
	ans = 0
	for i in range(60):
		bit = np.count_nonzero(L & 1)
		ans += bit * (N - bit) * (2 ** i)
		ans %= mod
		L >>= 1
	print(ans % mod)

Measured memory_bytes: 48840
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <time.h>
#include <vector>
#include <stdio.h>
#include <queue>
#include <map>
#include <math.h>
#define ll long long
using namespace std;
int n;

bool check(int x[],int y[])
{
	for(int i=1;i<=n;i++)
		if(x[i] != y[i])
			return false;
	return true;
}
int main()
{
	std::ios::sync_with_stdio(false);
	
	int num[10];
	int a[10];
	int b[10];
	cin>>n;
	
	for(int i=1;i<=n;i++)
		num[i]=i;
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]>b[i])
		{
			swap(a,b);
			break;
		}
		else break;
	}
	int ans = 0;
	while(!check(a,num))
		next_permutation(num+1,num+n+1);
	
	while(!check(b,num))
	{
		ans++;
		next_permutation(num+1,num+n+1);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}


#define INPUT_SIZE 3000000
char input[INPUT_SIZE];
char *ptr = input;

void init() {
	size_t read_byte = fread_unlocked(input, 1, INPUT_SIZE-1, stdin);
	assert(read_byte);
	assert(read_byte < INPUT_SIZE-2);
}
int ri() {
	int r=0,s=0;
	for(;;){assert(*ptr);if(*ptr=='-'){s=1;break;}if(*ptr<='9'&&*ptr>='0'){r=*ptr-'0';break;}ptr++;}
	ptr++;
	for(;;){if(*ptr<'0'||*ptr>'9')break;r=r*10+*ptr-'0';ptr++;}
	ptr++;
	if(s)r=-r;
	return r;
}


int main() {
	init();
    int n = ri();
	int m = ri();
	s64 nn = 0;
	s64 mm = 0;
	int last = ri();
	FOR(i,n-1) {
		int a = ri();
		nn += ((s64)a-last)*(n-i-1)*(i+1)%1000000007;
		last = a;
	}
	last = ri();
	FOR(i,m-1) {
		int a = ri();
		mm += ((s64)a-last)*(m-i-1)*(i+1)%1000000007;
		last = a;
	}
	nn %= 1000000007;
	mm %= 1000000007;

	cout << (((s64)nn)*mm%1000000007) << endl;
    return 0;
}


Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void stronglyConnectedComponents(
    const vector<vector<int> >& edges, vector<int>& indexConvert,
    vector<vector<int> >& nodesOut)
{
    const int n = edges.size();
    vector<int> num(n, -1), low(n, -1);
    vector<bool> isStk(n, false);
    stack<int> stk;
    int cnt = -1;
    nodesOut.clear();

    for(int i=0; i<n; ++i){
        stack<pair<int, unsigned> > arg;
        arg.push(make_pair(i, 0));

        while(!arg.empty()){
            int v = arg.top().first;
            unsigned j = arg.top().second;
            arg.pop();

            if(j == 0){
                if(num[v] != -1)
                    continue;
                num[v] = low[v] = ++ cnt;
                stk.push(v);
                isStk[v] = true;
            }
            else{
                int w = edges[v][j-1];
                if(isStk[w])
                    low[v] = min(low[v], low[w]);
            }

            if(j < edges[v].size()){
                arg.push(make_pair(v, j + 1));
                int w = edges[v][j];
                arg.push(make_pair(w, 0));
            }
            else if(low[v] == num[v]){
                nodesOut.push_back(vector<int>());
                for(;;){
                    int w = stk.top();
                    stk.pop();
                    isStk[w] = false;
                    nodesOut.back().push_back(w);
                    if(v == w)
                        break;
                }
            }
        }
    }

    reverse(nodesOut.begin(), nodesOut.end()); // DAGにするために反転させる
    const int m = nodesOut.size();
    indexConvert.resize(n);
    for(int i=0; i<m; ++i){
        for(unsigned j=0; j<nodesOut[i].size(); ++j)
            indexConvert[nodesOut[i][j]] = i;
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > edges(n);
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
    }

    vector<int> indexConvert;
    vector<vector<int> > nodesOut;
    stronglyConnectedComponents(edges, indexConvert, nodesOut);
    cout << nodesOut.size() << endl;
    for(const auto& v : nodesOut){
        cout << v.size();
        for(const int& a : v)
            cout << ' ' << a;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 58120
if __name__ == "__main__":
    mod = 10 ** 9 + 7
    n, m = map(int, input().split())
    a = list()
    for i in range(m):
        a.append(int(input()))

    dp = [0] * (n + 1)

    for aa in a:
        dp[aa] = -1

    if dp[1] != -1:
        dp[1] = 1
    else:
        dp[1] = 0

    if n > 1:
        if dp[2] != -1:
            dp[2] = 1 + dp[1]
        else:
            dp[2] = 0

        for i in range(3, n+1):
            if dp[i] != -1:
                dp[i] = (dp[i-2] + dp[i-1]) % mod
            else:
                dp[i] = 0

    print(dp[n])


Measured memory_bytes: 7852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String S = scan.next();
		int ans = 0;

		for (int i = 0; i < 1000; i++) {

			String PIN;

			if (i < 10) {
				String T = String.valueOf(i);
				PIN = String.valueOf("00").concat(T);
			} else if (i < 100) {
				String T = String.valueOf(i);
				PIN = String.valueOf("0").concat(T);
			} else {
				PIN = String.valueOf(i);
			}

			int j = 0;

			while (PIN.charAt(0) != S.charAt(j)) {
				j++;

				if (j == N) {
					break;
				}
			}

			if (j >= N-1 || PIN.charAt(0) != S.charAt(j)) {
				continue;
			}

			j++;

			while (PIN.charAt(1) != S.charAt(j)) {
				j++;

				if (j == N) {
					break;
				}

			}

			if ( j >= N-1 || PIN.charAt(1) != S.charAt(j)) {
				continue;
			}

			j++;

			while (PIN.charAt(2) != S.charAt(j)) {
				j++;

				if (j == N) {
					break;
				}

			}

			if ( j == N || PIN.charAt(2) != S.charAt(j)) {
				continue;
			} else {
				ans += 1;
			}

		}

		System.out.println(ans);

		scan.close();

	}
}


Measured memory_bytes: 24032
""" 170/C
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [lambda _: readIntegerSet(m) for _ in range(0, n)]

def main(X, N, P):
    mP = {}
    for p in P:
        mP[p] = p

    if X not in mP:
        return X

    i = 0
    while True:
        if X-i not in mP:
            return X-i

        if X+i not in mP:
            return X+i

        i += 1


if __name__ == "__main__":
    _X, _N = readIntegerSet(2)
    _P = readIntegerSet(_N)

    print(main(_X, _N, _P))

Measured memory_bytes: 9456
#include <stdio.h>

int main()
{
    int a,b,c,m,sum;
    scanf("%d%d%d",&a,&b,&c);
    if (a>b) m=a;
    else m=b;
    if (m<c) sum=a+b;
   else sum=a+b+c-m;
printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
li=list(input())	

index = []
rindex = []
rindex.append(0)
tmp = 'R'
for i in range(len(li)):
    if (li[i] == 'L' and tmp == 'R'):
        index.append(i)
    if (li[i] == 'R' and tmp == 'L'):
        rindex.append(i)    
    tmp = li[i]


ans=[0] * len(li)

tmpi = 0
for i in range(len(index)):
    if (i == len(index) -1):
        n = len(li) - rindex[i]
        r = len(li)
    else:
        n = rindex[i+1] -rindex[i]
        r = rindex[i+1]
    left = int((index[i] - rindex[i] + 1)/2) + int((r - index[i]) /2) 
    ans[index[i] - 1] = left
    ans[index[i]] = n - left

for i in ans:
    print(str(i) + " ", end="")
print()

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

//約数列挙 O(sqrt(n))
set<ll> get_divisors(ll n) {
  set<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.insert(i);
      res.insert(n / i);
    }
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i, 1, n + 1) {
    if (i % 2 == 0) {
      continue;
    }
    if (SZ(get_divisors(i)) == 8) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  int w, h, n;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define N 200010
using namespace std;
inline int read()
{
	int neg=1,num=0;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')neg=-1;
	for(;isdigit(c);c=getchar())num=(num<<1)+(num<<3)+c-'0';
	return neg*num;
}
int n,m,ans,u[N],v[N],f[410][410];
bool vis[410]; 
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)u[i]=read(),v[i]=read();
	for(int i=1;i<=n;i++)
	{
		f[i][i]=1;
		for(int j=m;j>=1;j--)
		{
			int x=f[i][u[j]],y=f[i][v[j]];
			if(x && y){vis[i]=1;break;}
			else if(x)f[i][v[j]]=1;
			else if(y)f[i][u[j]]=1;
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			if(vis[i] || vis[j])continue;
			ans++;
			for(int k=1;k<=n;k++)if(f[i][k] && f[j][k]){ans--;break;}
		}
	printf("%d",ans); 
	return 0;
}



Measured memory_bytes: 5132
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);
	      	  
	      	  int N,A;
	      	  cin >> N >> A;
	      	  
	      	  int a=N%500;
	      	  if(A>=a) cout << "Yes" << endl;
	      	  else cout << "No" << endl;

	          return 0;
}


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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    ll N;
    cin>>N;
    vector<ll> v(N);
    for(ll i=0;i<N;i++){
        cin>>v[i];
    }
    
    ll sum=abs(v[0]-0);//全ての観光スポットを通るときの金額
    for(ll i=0;i<N;i++){
        if(i==N-1){//最後の観光地だけ注意
            sum+=abs(v[i]-0);
        }else{
            sum+=abs(v[i]-v[i+1]);
        }
    }
 
    for(ll i=0;i<N;i++){
        ll ba,fo;//番号の１つ前，後の観光地の値
        if(i==0){
            ba=0;
            fo=v[i+1];
        }else if(i==N-1){
            ba=v[i-1];
            fo=0;
        }else{
            ba=v[i-1];
            fo=v[i+1];
        }
        if((v[i]-ba>=0 && fo-v[i]>=0)||(ba-v[i]>=0 && v[i]-fo>=0)){
            cout<<sum<<endl;
        }else{
            ll tmp=abs(v[i]-fo)+abs(v[i]-ba);
            ll tmp2=abs(fo-ba);
            cout<<sum-(tmp-tmp2)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2048
def main():
    S = input()
    odd_cnt = [0,0]
    even_cnt = [0,0]

    for i in range(len(S)):
        if i % 2 == 0 and S[i] == '0':
            even_cnt[0] += 1
        elif i % 2 == 0 and S[i] == '1':
            even_cnt[1] += 1
        elif i % 2 == 1 and S[i] == '0':
            odd_cnt[0] += 1
        elif i % 2 == 1 and S[i] == '1':
            odd_cnt[1] += 1

    if even_cnt[0] + odd_cnt[1] < even_cnt[1] + odd_cnt[0]:
        print(even_cnt[0] + odd_cnt[1])
    else:
        print(even_cnt[1] + odd_cnt[0])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    for(int i = n; i <= 999; i++) {
      String s = String.valueOf(i);
      if((s.charAt(0) == s.charAt(1)) && (s.charAt(1) == s.charAt(2))) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22736
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,k,c;cin>>n>>k>>c;
    string s;cin>>s;

    vector<int> l(n,-1);
    int cnt=0;
    for(int i=0;i<n and cnt<k;i++){
        if(s[i]=='o'){
            cnt++;
            l[i]=cnt;
            i+=c;
        }
    }

    vector<int> r(n,-1);
    for(int i=n-1;i>=0 and cnt;i--){
        if(s[i]=='o'){
            r[i]=cnt;
            cnt--;
            i-=c;
        }
    }
    // debug(l);
    // debug(r);
    rep(i,n){
        if(l[i]<0 or r[i]<0) continue;
        if(l[i]==r[i]){
            cout<<i+1<<endl;
        }
    }

    return 0;
}


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

#define N 1100
#define INF = 0x3f3f3f3f

double a[N];

int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        double sum = 0;
        for (int i = 0; i < n; ++i) {
            scanf("%lf", &a[i]);
            sum += a[i];
        }
        sum /= n;
        int cnt = 0;
        double dif = fabs(sum - a[0]);
        for (int i = 1; i < n; ++i) {
            if (fabs(sum - a[i]) < dif) {
                dif = fabs(sum - a[i]);
                cnt = i;
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

using ll = long long;

inline ll min(ll a, ll b) {
	return a < b ? a : b;
}

const int Max = 1e4;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, p, wrong_elements = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p;
		if (p != i + 1) {
			++wrong_elements;
		}
	}
	if (wrong_elements > 2) {
		cout << "NO";
	} else {
		cout << "YES";
	}
	//system("pause");
	return 0;
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    
    int h, w;
    cin >> h >> w;

    vector<vector<int>> table(H, vector<int>(W, 0));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < W; j++)
        {
            table[i][j] = 1;
        }
    }

    for(int i = 0; i < w; i++)
    {
        for(int j = 0; j < H; j++)
        {
            table[j][i] = 1;
        }
    }

    int ans = 0;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            if(table[i][j] == 0)
            {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;
#define DEBUG 0
#define ll long long
#define lli long long int

const lli N_MAX = 51;

int main() {
	lli N; cin >> N;
	double v[N_MAX];
	for (int i = 0; i < N; i++) cin >> v[i];

	sort(v, v + N);
	for (int i = 0; i < N - 1; i++) {
		v[i + 1] = (v[i] + v[i + 1]) / 2.0;
	}
	cout << v[N - 1] << endl;
}

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

public class Main {

	public static void main(String args[]) {

		try(BufferedReader input = new BufferedReader(new InputStreamReader(System.in))) {
			// ----- input -----
			final int L1[] = readLine(input.readLine());
			final int N = L1[0];
			final int M = L1[1];

			// 1.final int DATA[][] = lines(input.lines(), ROW, COL);
			// 2.final int DATA[][] = readLines(input, N);
			// 2.List<int[]> DATA_LIST = new LinkedList<>(Arrays.asList(DATA));
			PriorityQueue<Data> data = getCollection(input, N, 2);

			// ----- main -----
			long totalPrice = 0;
			int calcCnt = 0;
			int totalCnt = 0;

			while(true) {
				Data min = data.poll();
				calcCnt = (M >= totalCnt + min.num) ? min.num : M-totalCnt;
				totalPrice += (long)min.price * (long)calcCnt;
				totalCnt += calcCnt;
				if(M <= totalCnt) break;
			}
			System.out.println(totalPrice);

		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	private static PriorityQueue<Data> getCollection(BufferedReader input, int num, int col) {

		PriorityQueue<Data> data = new PriorityQueue<>();
		try {
			for(int i=0; i < num; i++) {
				data.add(new Data(input.readLine().split(" ")));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return data;
	}









	private static int[] readLine(String line) {

		String[] vals = line.split(" ");
		int[] data = new int[vals.length];
		int i = 0;

		try {
			for(String val : vals) {
				data[i++] = Integer.parseInt(val);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return data;
	}

	private static int[][] readLines(BufferedReader input, int num){

		int[][] data = new int[num][];
		for(int i=0; i < num; i++) {
			try {
				data[i] = readLine(input.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return data;
	}
}



class Data implements Comparable<Data>{
	int price;
	int num;

	public Data(String[] values) {
		this.price = Integer.parseInt(values[0]);
		this.num = Integer.parseInt(values[1]);
	}

	@Override
	public int compareTo(Data d) {
		return price - d.price;
	}
}

Measured memory_bytes: 47980
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp10
{
    class Program
    {
        static void Main(string[] args)
        {
            Calc calc = new Calc();
            string str;
            int n;
            List<int> combo = new List<int>();

            while ((str = Console.ReadLine()) != null)
            {
                int count;
                n = int.Parse(str);
                if (n > 36)
                {
                    count = 0;
                }
                else if (n <= 18)
                {
                    count = calc.Combo(n);
                }
                else
                {
                    n = 36 - n;
                    count = calc.Combo(n);
                }
                combo.Add(count);
            }

            foreach (int item in combo)
            {
                Console.WriteLine(item);
            }
        }
    }

    class Calc
    {
        int count;

        internal int Combo(int n)
        {
            count = 0;
            for (int a = 0; a < 10; a++)
            {
                for (int b = 0; b < 10; b++)
                {
                    for (int c = 0; c < 10; c++)
                    {
                        int sum = a + b + c;
                        if (n - sum < 10 && n - sum >= 0)
                        {
                            count++;
                        }
                    }
                }
            }
            return count;
        }

    }
}



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

int main()
{
	double w;
	while (cin >> w)
	{
		if (w <= 48.00) cout << "light fly" << endl;
		else if (w <= 51.00) cout << "fly" << endl;
		else if (w <= 54.00) cout << "bantam" << endl;
		else if (w <= 57.00) cout << "feather" << endl;
		else if (w <= 60.00) cout << "light" << endl;
		else if (w <= 64.00) cout << "light welter" << endl;
		else if (w <= 69.00) cout << "welter" << endl;
		else if (w <= 75.00) cout << "light middle" << endl;
		else if (w <= 81.00) cout << "middle" << endl;
		else if (w <= 91.00) cout << "light heavy" << endl;
		else cout << "heavy" << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;//何人か
  cin >> N;
  int data[N];//座標 
  int maxValue = 0;
  for (int i = 0; i < N; i++) {
    cin >> data[i];
    maxValue = max(maxValue, data[i]);//最大値
  }
  int minValue; 
  for (int i = 0; i <= maxValue; i ++) {//iが地点
    int tmp = 0;
    for (int j = 0; j < N; j++) {
      tmp += (data[j] - i) * (data[j] - i);
    }
    if (i != 0) {
      minValue = min(minValue, tmp);
    } else {
      minValue = tmp;
    }
  }
  cout << minValue << endl;
}

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

int main (void)
{
	int n, *a;
	int i;

	scanf("%d", &n);

	a=(int *)malloc(sizeof(int)*n);
	if (a==NULL) exit(0);

	for(i=0;i<n;i++){
		scanf("%d", &a[i]);
	}

	for(i=n-1;i>0;i--){
		printf("%d ", a[i]);
	}

	printf("%d\n", a[0]);

	free(a);

	return 0;
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main(){
    int h,w;
    cin >>h >>w;
    while(h || w)
    {
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
            {
                if(i==0 || i==h-1)
                {
                    if(j>=w-1)
                        cout<< "#"<< endl;
                    else
                        cout<< "#";
                }
                else
                {
                    if(j==w-1 || j==0)
                        cout<< "#";
                    else
                        cout<< ".";
                    if(j==w-1)
                        cout<<endl;
                }
            }
        cout <<endl;
        cin >>h >>w;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

ll X,Y,cnt = 0;

void solve(ll P){
    cnt++;if(2*P > Y) return;
    solve(2*P);
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> X >> Y;
    solve(X);cout << cnt << endl;
}

Measured memory_bytes: 256
S=[ord(c) for c in input()]
l,r=2*10**5-1,2*10**5+len(S)
S=[-1]*(2*10**5)+S+[-1]*(2*10**5)
x=0
Q=int(input())
qs=[input() for i in range(Q)]
for q in qs:
    if q=='1':
        x^=1
    else:
        _,f,c=q.split()
        if x==0 and int(f)==1 or x==1 and int(f)==2:
            S[l]=ord(c)
            l-=1
        else:
            S[r]=ord(c)
            r+=1
print(''.join([chr(c) for c in S[l+1:r]])[::(-1 if x else 1)])

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

const string YES = "YES";
const string NO = "NO";

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    reverse(b.begin(), b.end());
    if (a == b) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    map<int, int> magic;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (!magic.count(a))
            magic[a] = b;
        else if (b < magic[a])
            magic[a] = b;
    }
    vector<lint> dp(int(1e8), LLONG_MAX);
    dp[0] = 0;
    rep(i, h) {
        if (dp[i] != LLONG_MAX)
            for (const auto &e : magic) {
                chmin(dp[i + e.first], dp[i] + e.second);
            }
    }
    lint ans = LLONG_MAX;
    for (int i = h; i < int(1e8); i++) chmin(ans, dp[i]);
    cout << ans << endl;
}

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

int main(){
  char N;
  cin >> N;
  if (isupper(N)){
    cout << "A" << endl;
  }else{
    cout << "a" << endl;
  }
}

  




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


int main(){
    int n;
    cin >> n;
    bool flag = false;
    rep(i,n){
        char tmp;
        cin >> tmp;
        if(tmp == 'Y') flag = true;
    }
    cout << (flag ? "Four\n" : "Three\n");
}


Measured memory_bytes: 256
def main():
    K,A,B = map(int,input().split())
    sum = K+1
    
    if A + 2>= B or K <= A:
        print(K+1)
    else:
        if (K-A+1)%2 == 0:
            sum = (((K-A+1)//2)-1)*(B-A)+B
        else:
            sum = (((K-A+1)//2)-1)*(B-A)+1+B
        print(sum)
main()


Measured memory_bytes: 3060
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(4)],[])
for b in [input()for i in range(int(A[9]))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("YNeos"[S.find("  ")<0::2])

Measured memory_bytes: 3060
x, k, d = map(int, input().split())


x = abs(x);
if (k * d <= x):
    print(x - k * d);
else:
    k1 = x // d;
    x -= k1 * d;
    k -= k1;
    k %= 2;
    x = abs(x - k * d);
    print(x)



Measured memory_bytes: 9168
from heapq import heapify, heappush, heappop

def main(C):
    R = []
    W = []
    for i, c in enumerate(C):
        if c == 'R':
            R.append(-i)
        else:
            W.append(i)
    if len(R)==0 or len(W)==0:
        return 0
    heapify(R)  #マイナスで保持する
    heapify(W)
    cnt = 0
    while True:
        #print(R, W)
        r_last = -heappop(R)
        w_first = heappop(W)
        if r_last < w_first:
            break
        heappush(R, -w_first)
        heappush(W, r_last)
        cnt += 1
    return cnt
    

if __name__ == "__main__":
    N = int(input())
    C = input()
    ans = main(C)
    print(ans)

Measured memory_bytes: 81560
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

string s;
vector<int> ans;
int m;

bool dfs(int start){
    if(s[start] == '1')return false;
    if(start == 0)return true;
    drep(i,m,1){
        if(start - i < 0)continue;
        if(dfs(start - i)){
            ans.push_back(i);
            return true;
        }
    }
    return false;
}

int main(){
    int n;
    cin >> n >> m;
    cin >> s;
    int now = n;
    int cnt = 0;
    rep(i,0,n){
        if(s[i]=='0')cnt = 0;
        else cnt++;
        if(cnt == m){
            puts("-1");
            return 0;
        }
    }

    if(dfs(n)){
        vecprint(ans);
        return 0;
    }else{
        puts("-1");
        return 0;
    }

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 7416
lst_1 = input().split()

N = int(lst_1[0])
T = int(lst_1[1])

ans = "TLE"
cost_min = 9999

lst_A = []

for i in range(N):

    lst_A.append(input().split())

for i in range(N):

    if (int(lst_A[i][0]) < cost_min) and (int(lst_A[i][1]) <= T):
        cost_min = int(lst_A[i][0])
        ans = int(lst_A[i][0])

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	xs := make([]float64, n)
	ys := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i], &ys[i])
	}

	cal := 0.0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			cal += math.Hypot(xs[i]-xs[j], ys[i]-ys[j])
		}
	}

	ans := cal / float64(n)
	fmt.Println(ans)
}


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

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

int main()
{
	while(true){
		int a, b;
		cin >> a >> b;
		if(cin.eof()) break;
		int GCD = GetGCD(a, b);
		int LCM = a * (b / GCD);
		cout << GCD << ' ' << LCM << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll c[3][3];
	rep(i, 3) rep(j, 3) cin >> c[i][j];
	ll a[3];
	ll b[3];
	a[0] = 0;
	rep(i, 3) {
		b[i] = c[0][i];
	}
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];
	rep(i, 2) rep(j, 2) {
		if (a[i + 1] + b[j + 1] != c[i + 1][j + 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int n,k,x,y;
scanf("%d %d %d %d",&n,&k,&x,&y);
int ans;
if(n>=k){ans=k*x+(n-k)*y;}
else{ans=n*x;}
printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const DIGIT = 2 * 1e5;

ll mod_pow(ll a, ll n, ll p) {
  if (n == 0) return 1 % p;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (mod_pow(a, 1, p) * mod_pow(a, n-1, p)) % p;
  ll t = mod_pow(a, n / 2, p);
  return (t * t) % p;
}

int main() {
  ll n;
  string x;
  cin >> n >> x;

  bitset<DIGIT> bs2(x);
  ll cnt = bs2.count();

  ll plus_mod = 0;
  ll minus_mod = 0;
  rep(i, n) {
    if (x[n-1-i] - '0') {
      plus_mod = (plus_mod + mod_pow(2, i, cnt+1)) % (cnt+1);
      if (cnt != 1) minus_mod = (minus_mod + mod_pow(2, i, cnt-1)) % (cnt-1);
    }
  }

  rep(i, n) {
    ll mod;
    if (x[i] == '1') {
      if (cnt == 1) {
        cout << 0 << endl;
        continue;
      }
      mod = (minus_mod - mod_pow(2, n-1-i, cnt-1)) % (cnt-1);
      if (mod < 0) mod += (cnt-1);
    } else {
      mod = (plus_mod + mod_pow(2, n-1-i, cnt+1)) % (cnt+1);
      if (mod < 0) mod += (cnt+1);
    }

    ll ans = 1;
    while(mod != 0) {
      mod %= __builtin_popcountll(mod);
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

using namespace atcoder;
using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  dsu d(n);
  for (ll i = 0; i < m; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    d.merge(a, b);
  }

  cout << d.groups().size()-1 << endl;

  return 0;
}


Measured memory_bytes: 8872
//Practice more and more
//learn for better
#define bn begin()
#define en end()
#define mx 5000010
#define pb push_back
#define PI (2.0*acos(0.0))
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll>   vll;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
	ll a,b,n,m,t,i,j,p,k,x,l,d;
	string str;
	map<string,int> mp;
	cin>>t;
	while(t--)
{
	cin>>str;
	mp[str]++;
}
cout<<"AC x "<<mp["AC"]<<endl;
cout<<"WA x "<<mp["WA"]<<endl;
cout<<"TLE x "<<mp["TLE"]<<endl;
cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  vector<int> taka;
  int count1 = 0, count2 = 0;
  for(int i = 0; true; i++){    
    if(C <= 0) break;
    count1++;
    C = C - B;
  }
  vector<int> aoki;
  for(int i = 0; true; i ++){
    if(A <= 0) break;
    count2++;
    A = A - D;
  }
  if(count1 > count2) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <cstring>
using namespace std;
int main()
{
	int n,a[100005],s=1,sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	set<pair<int,int> > q;
	if(n==1)
	{
		if(a[0]==1)
		{
			cout<<sum<<endl;
			return 0;
		}
		else 
		{
			sum=1;
			cout<<sum<<endl;
			return 0;
		}
	}
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])s++;
		else
		{
			if(i==n-2)
			{
				q.insert(make_pair(a[i],s));
				q.insert(make_pair(a[i+1],1));
				break;
			}
			else
			{
				q.insert(make_pair(a[i],s));
				s=1;
			}
		}
		if(a[i]==a[i+1]&&i==n-2)q.insert(make_pair(a[i],s));
	}
	set<pair<int,int> >::iterator it;
	//for(it=q.begin();it!=q.end();it++)
		//printf("%d %d\n",it->first,it->second);
	int i=0,j=0,more[100005],les[100005];
	memset(more,0,sizeof(more));
	memset(les,0,sizeof(les));
	for(it=q.begin();it!=q.end();it++)
	{
		if(it->first==it->second)continue;
		else 
		{
			if(it->first > it->second)sum+=it->second;
			else sum+=it->second - it->first;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int main(){
  int N;cin>>N;
  set<int> s;
  REP(i,0,N){
    int d;
    cin>>d;
    s.insert(d);
  }
  print(s.size())
}

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

using namespace std;

int main()
{
  int a[5];
  for(int i = 0; i < 5; i++)
    cin >> a[i];
  for(int i = 0; i < 5; i++)
    if(a[i] == 0)
      return !(cout << i+1 << endl);
}

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

long long comb(long long n, long long r) {
    if (r * 2 > n) r = n - r;
    long long dividend = 1;
    long long divisor = 1;
    for (long long i = 1; i <= r; i++ ) {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

void solve(long long N, long long M){
    long long n , m;
    if (N <= 1) n = 0;
    else n = comb(N, 2);
    if (M <= 1) m = 0;
    else m = comb(M, 2);
    cout << n + m << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
using System;

class FizzBuzzSum
{
    static void Main(string[] args)
    {
        var input = ulong.Parse(Console.ReadLine());
        ulong sum = 0;

        for(ulong i = 1; i <= input; i++)
        {
            if(!(i % 3 == 0 || i % 5 == 0))
            {
                sum +=  i;
            }
        }

        Console.WriteLine(sum);

       
    }
}

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

const ll INF = (1 << 30) - 1;
vector<int> heights;
vector<ll> min_costs(100001, INF);

ll min_cost_at(int i) {
    if (min_costs.at(i) < INF) return min_costs.at(i);

    ll min_cost;
    if (i == 0) min_cost = 0;
    else if (i == 1) min_cost = abs(heights.at(1) - heights.at(0));
    else {
        ll cur_h = heights.at(i);
        min_cost = min(
            min_cost_at(i - 1) + abs(cur_h - heights.at(i - 1)),
            min_cost_at(i - 2) + abs(cur_h - heights.at(i - 2))
        );
    }
    min_costs.at(i) = min_cost;
    return min_cost;
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        heights.emplace_back(tmp);
    }

    cout << min_cost_at(N - 1) << "\n";
}

Measured memory_bytes: 4728