akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    
    int now;
    int minimum;
    int maximum;
    
    rep(i, n){
        cin >> now;
        if(!i){
            minimum = now;
            maximum = now;
        }else{
            minimum = min(minimum, now);
            maximum = max(maximum, now);
        }        
    }
    int res = maximum - minimum;
    cout << res << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

struct UnionFind{
    vector<int> d;
    UnionFind(int n): d(n,-1) {}
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(d[x] < d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -d[find(x)];
    }
};

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a,b);
    }
    int ans=0;
    for(int i = 0; i < n; i++) {
        ans=max(uf.size(i),ans);
    }
    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 10232
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




int s, w;

int main() {

	cin >> s >> w;

	if (s <= w)cout << "unsafe" << endl;
	else cout << "safe" << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t A, B, M;
    cin >> A >> B >> M;
    vector<int64_t>reizou(A);
    vector<int64_t>renzi(B);
    for (int i=0; i<A; i++) {
        cin >> reizou.at(i);
    }

    for (int i=0; i<B; i++) {
        cin >> renzi.at(i);
    }

    int64_t min_cost = *min_element(reizou.begin(), reizou.end()) + *min_element(renzi.begin(), renzi.end());
    for (int i=0; i<M; i++) {
        int64_t x, y, c;
        cin >> x >> y >> c;
        int64_t cos = reizou[x-1] + renzi[y-1] - c;
        if (min_cost > cos) {
            min_cost = cos;
        }
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    if (N == 1) cout << "Hello World" << '\n';
    else {
        int a, b; cin >> a >> b;
        cout << a + b << '\n';
    }
}


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

int main()
{
    int N;
    cin >> N;
    vector<ll> L;
    for (int i =0; i < N; i++) {
        ll a;
        cin >> a;
        L.push_back(a);
    }

    sort(L.begin(), L.end());

    ll ans = 0;
    int len = L.size();
    for (int i = 0; i < len; i++) {
        for (int j = i+1; j < len; j++) {
            if (L[i] == L[j]) continue;
            for (int k = j+1; k < len; k++) {
                if (L[i] == L[k]) continue;
                if (L[j] == L[k]) continue;
                ll a, b, c;
                a = L[i];
                b = L[j];
                c = L[k];
                if ( c < (a + b)) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n,m,x,y,s1[105][105],s2[105][105],f[105][105][105],ans;
char a[105][105];

void upd(int &x,int y){if (x<y)  x=y;}

void work()
{
	scanf("%d %d\n",&n,&m);
	for (int i=1; i<=n; i++)
		{
			scanf("%s\n",a[i]+1);
			for (int j=1; j<=m; j++)
				if (a[i][j]=='E')
					x=i,y=j;
		}
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
			if (a[i][j]=='o')
				s1[i][j]=s1[i][j-1]+1,s2[i][j]=s2[i-1][j]+1;
			else  s1[i][j]=s1[i][j-1],s2[i][j]=s2[i-1][j];
	for (int l=0; l<=y; l++)
		for (int u=0; u<=x; u++)
			for (int r=0; r<=m-y; r++)
				for (int d=0; d<=n-x; d++)
					{
						upd(ans,f[u][r][d]);
						if (d<n-x)
							{
								int L=max(r+1,y-l),R=min(m-l,y+r);
								if (x+d+1<=n-u)
									upd(f[u][r][d+1],f[u][r][d]+s1[x+d+1][R]-s1[x+d+1][L-1]);
								else  upd(f[u][r][d+1],f[u][r][d]);
							}
						if (r<m-y)
							{
								int L=max(d+1,x-u),R=min(n-u,x+d);
								if (y+r+1<=m-l)
									upd(f[u][r+1][d],f[u][r][d]+s2[R][y+r+1]-s2[L-1][y+r+1]);
								else  upd(f[u][r+1][d],f[u][r][d]);
							}
						if (u<x)
							{
								int L=max(r+1,y-l),R=min(m-l,y+r);
								if (x-u-1>d)
									upd(f[u+1][r][d],f[u][r][d]+s1[x-u-1][R]-s1[x-u-1][L-1]);
								else  upd(f[u+1][r][d],f[u][r][d]);
							}
						if (l<y)
							{
								int L=max(d+1,x-u),R=min(n-u,x+d);
								if (y-l-1>r)  f[u][r][d]+=s2[R][y-l-1]-s2[L-1][y-l-1];
							}
					}
	printf("%d",ans);
}

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


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
            B[i] = cin.nextInt();
        }
        long answ = A[0] + B[0];
        for (int i = 0; i < N; i++) {
            answ = Math.min(A[i] + B[i],answ);
        }
        System.out.println(answ);

    }
}

Measured memory_bytes: 66916
def c_remainder_minimization_2019(L, R, ITER=673):
    ans = float('inf')
    for i in range(L, min(R, L + ITER)):
        for j in range(i + 1, min(R + 1, L + ITER + 1)):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                return 0
    return ans

L, R = [int(i) for i in input().split()]
print(c_remainder_minimization_2019(L, R))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

queue<int> que;

int main() {
    int N; cin >> N;
    bool ok = false;
    int n;
    if(N == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << 1 << " " << 1<< endl;
        cout << 1 << " " << 1 << endl;
        return 0;
    }
    for(int k = 1; k <= 1000; k++) {
        que.push((k-1)*(k+4)/2+3);
        if(N == (k-1)*(k+4)/2+3) {
            ok = true;
            n = k;
        }
    }
    if(!ok) {
        cout << "No" << endl;
        return 0;
    } else cout << "Yes" << endl;
    //cout << n << endl;
    int r = 2;
    int c = 1;
    int y = 0;
    int x = 0;
    vecveci ans(n+2,veci(n+1));
    ans[0][0] = 1, ans[1][0] = 1;
    for(int i = 2; i <= N; i++) {
        if(i < que.front()) {
            ans[r][x] = i;
            ans[y][c] = i;
            x++;
            y++;
        } else if(i == que.front()) {
            ans[r][x] = i;
            ans[y][c] = i;
            r++;
            c++;
            x = 0;
            y = 0;
            que.pop();
        }
    }

    cout << n+2 << endl;
    REP(i,n+2) {
        cout << n+1 << " ";
        REP(j,n+1) cout << ans[i][j] << " ";
        cout << endl; 
    }
}


Measured memory_bytes: 3916
import sys

input = lambda :sys.stdin.readline().rstrip()

def main():
    N, W = map(int, input().split())
    w, v = [0 for i in range(N)], [0 for i in range(N)]
    for i in range(N):
        w[i],v[i] = map(int, input().split())
    ans = solve(N, W, w, v)
    print(ans)


def solve(N, W, w, v):
    INF = W + 1
    vmax = 10 ** 3 * 10 ** 2
    dp = [[INF for i in range(vmax + 1)] for j in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(vmax + 1):
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
    for v in range(vmax, -1, -1):
        if dp[N][v] <= W:
            ans = v
            break
    return ans


if __name__ == '__main__':
    main()

Measured memory_bytes: 171116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int cnt = 0;
			for (;;) {
				if (H == 1) {
					break;
				}
				H = H / 2;
				cnt++;
			}
			long ans = 1;
			for (int i = 0; i < cnt; i++) {
				ans = 2 * ans + 1;
			}
			System.out.print(ans);
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> vec(3);
    for(int i = 0; i < 3; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(),vec.end());
    cout << vec.at(0) * 10 + vec.at(1) + vec.at(2) << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

typedef vector<vvi> vvvi;

int main() {
	int N;

	while(cin >> N, N) {
		map<int, int> info;
		int tmp;

		REP(i, N) {
			cin >> tmp;
			info[tmp]++;
		}

		map<int, int>::iterator it = info.begin();
		while(it != info.end()) {
			if((*it).second >= (N/2)+1) {
				cout << (*it).first << endl;
				goto end;
			}
			++it;
		}

		cout << "NO COLOR" << endl;
end:;

	}

	return 0;
}

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

int main(){
	char sa[101], sb[101], sc[101];
	cin >> sa >> sb >> sc;
	char c;
	char pre = 'A';
	c = sa[0];
	int ia = 1, ib = 0, ic = 0;
	while(1){
		if(c == 'a'){
			c = sa[ia++];
			pre = 'A';
			if(c == '\0') break;
			
		}else if(c == 'b'){
			c = sb[ib++];
			pre = 'B';
			if(c == '\0') break;
			
		}else if(c == 'c'){
			c = sc[ic++];
			pre = 'C';
			if(c == '\0') break;
			
		}
	}
	
	cout << pre << endl;
}

Measured memory_bytes: 256
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = True

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:


        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
list01 = [int(x) for x in arr_data[1]]

sumdata = sum(list01)

middledata = sumdata // 2
#初期値
x = list01[0]
y = sumdata-x
temp=abs(x-y)

for i in range(1, n-1):

    x += list01[i]
    y = sumdata-x
    
    if temp>abs(x-y):
        
        temp=abs(x-y)
        
        
print(temp) 


Measured memory_bytes: 24676
import fractions
from functools import reduce
n = int(input())
t = [int(input()) for _ in range(n)]
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(t))

Measured memory_bytes: 63980
date = [int(i) for i in input().split('/')]
if date[0] > 2019:
  print("TBD")
else:
  if date[1] > 4:
    print("TBD")
  else:
    if date[2] > 30:
      print("TBD")
    else:
      print("Heisei")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

ll d[50][1000005];

int main() {
    cin >> n >> m;
    REP(i, n) {
        ll a, b, c;
        cin >> a >> b >> c;
        a *= 10;
        b *= 10;
        a -= 5;
        d[c][a] = 1;
        d[c][b + 1] = -1;
    }
    FOR(i, 1, m + 1) {
        FOR(j, 1, 1000005) {
            d[i][j] += d[i][j - 1];
        }
    }
    FOR(i, 1, 1000005) {
        cnt = 0;
        FOR(j, 1, m + 1) {
            if (d[j][i]) {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 237824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A;
  cin >>A;
  if(A.at(0)==A.at(1) || A.at(1)==A.at(2) || A.at(2) == A.at(3)) cout << "Bad" << endl;
  else cout << "Good" << 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 K=sc.nextInt();
		int X=sc.nextInt();
		int Y=sc.nextInt();

		int sum=0;

		if(K<N){
			for(int i=0;i<K;i++){
				sum=sum+X;
			}
			for(int i=K;i<N;i++){
				sum=sum+Y;
			}
		}
		else{
			for(int i=0;i<N;i++){
				sum=sum+X;
			}
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 8788
package main

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

func main() {
	n, an := 0, 0
	fmt.Scanf("%d", &n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ins := strings.Split(sc.Text(), " ")
	var in []int
	for _, i := range ins {
		j, _ := strconv.Atoi(i)
		in = append(in, j)
	}
	for j, i := range in {
		if j%2 == 0 {
          //fmt.Printf("%d a\n",j)
			if i%2 == 1 {
				an++
              //fmt.Println(j)
			}
		}
	}
	fmt.Println(an)
}


Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<vector<int> > a(2, vector<int>(n));
    for (int i = 0; i < 2; i++) for (int j = 0; j < n; j++) cin >> a[i][j];
    for (int i = 0; i < n - 1; i++) {
        a[0][i+1] += a[0][i];
        a[1][n-2-i] += a[1][n-1-i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, a[0][i] + a[1][i]);
    cout << ans << '\n';
}


Measured memory_bytes: 256
//SHIVANSH BHAT
//IIT ROORKEE

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
#define fi first
#define se second
#define pb push_back
ll modulo1=pow(10,9)+7;
int modulo2=998244353;
typedef long double ld;

vector<ll>fact;

ll binpower(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return binpower(n, pp-2, pp);
}

ll nCr(ll n,ll r){
    ll abc=fact[n-r]*fact[r];
    return fact[n]*modInverse(abc,modulo1);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>h(n+1);
    for (int i = 0; i <n ; ++i) {
        cin>>h[i+1];
    }
    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for (int i = 3; i <=n ; ++i) {
         dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n]<<"\n";
    return 0;
}


Measured memory_bytes: 4760
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    string S;
    cin >> S;

    vector<int> count(4);

    for (int i = 0; i < 4; i++){
        for (int j = i+1; j < 4; j++){
            if (S[i] == S[j]){
                count[i]++;
                count[j]++;
            }
        }
    }

    bool pair = true;
    for (int i = 0; i < 4; i++){
        if (count[i] != 1) pair = false;
    }

    if (pair) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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 = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        boolean[] ac = new boolean[n+1];
        int[] wa = new int[n+1];
        int a = 0;
        for(int i = 0; i < m; i++){
            int p = Integer.parseInt(sc.next());
            String s = sc.next();
            if(!ac[p]){
                if(s.equals("AC")){
                    a++;
                    ac[p] = true;
                }else{
                    wa[p]++;
                }
            }
        }
        
        int penalty = 0;
        for(int i = 1; i <= n; i++){
            if(ac[i]){
                penalty += wa[i];
            }
        }
        
        System.out.println(a + " " + penalty);
    }
}

Measured memory_bytes: 51404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c,K,res=0;
  cin>>n>>m;
  vector<vector<int>> s(m);
  for(int i=0;i<m;++i){
    cin>>K;
    for(int j=0;j<K;++j){
      cin>>c;
      s[i].push_back(c-1);
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;++i)cin>>p[i];
  
  vector<bool> sw(n); // whether switch is on/off
  vector<int> num(m); // number of switches connected to i-th lamp and is on
  bool found=false;
  for(int i=0;i<(1<<n);++i){
    int i0=i;
    found=true;
    for(int j=0;j<n;++j)sw[j]=(i0>>j)%2;
    num=vector<int>(m,0);
    for(int j=0;j<m;++j)for(auto k:s[j]) num[j]+=(int)sw[k];
    for(int j=0;j<m;++j){
      if(num[j]%2!=p[j]){
        found=false;
        break;
      }
    }
    if(found)res++;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;
const int mod = 1e9+7;
int n,Q,pre,now;
struct Seg{
	LL mn[maxn<<2],tag[maxn<<2]; int flg;
	Seg(){memset(mn,0x3f,sizeof mn);}
	inline void add(int i,LL v){mn[i]+=v,tag[i]+=v;}
	inline void down(int i){if(tag[i]) add(i<<1,tag[i]),add(i<<1|1,tag[i]),tag[i]=0;}
	void ins(int i,int l,int r,int x,LL v){
		if(l==r) {mn[i]=min(mn[i],v+l*flg);return;}
		int mid=(l+r)>>1; down(i);
		x<=mid?ins(i<<1,l,mid,x,v):ins(i<<1|1,mid+1,r,x,v);
		mn[i]=min(mn[i<<1],mn[i<<1|1]);
	}
	LL qry(int i,int l,int r,int x,int y){
		if(x<=l&&r<=y) return mn[i];
		int mid=(l+r)>>1; LL ret=mn[0]; down(i);
		if(x<=mid) ret=min(ret,qry(i<<1,l,mid,x,y));
		if(y>mid) ret=min(ret,qry(i<<1|1,mid+1,r,x,y));
		return ret;
	}
	LL whole(int i,int l,int r){
		if(l==r) return mn[i]+l;
		int mid=(l+r)>>1; down(i);
		return min(whole(i<<1,l,mid),whole(i<<1|1,mid+1,r));
	}
}T1,T2;
int main()
{
	scanf("%d%d%d%d",&n,&Q,&pre,&now),T1.flg=-1,T2.flg=1;
	T1.ins(1,1,n,now,0),T2.ins(1,1,n,now,0);
	for(int i=1;i<=Q;i++,pre=now){
		scanf("%d",&now); if(now==pre) continue;
		LL tmp=min(T1.qry(1,1,n,1,now)+now,T2.qry(1,1,n,now,n)-now);
		T1.add(1,abs(now-pre)),T2.add(1,abs(now-pre));
		T1.ins(1,1,n,pre,tmp),T2.ins(1,1,n,pre,tmp);
	}
	printf("%lld\n",T1.whole(1,1,n));
}

Measured memory_bytes: 24832
t= input()
t1 = []
t2 = []
for i in range(len(t)):
  if (i+0)%2 == 0:
    t1.append(t[i])
  else:
    t2.append(t[i])
flag = 0
if "L" in t1:
  print("No")
  exit()
elif "R" in t2:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38384
// date: 26/09/20 17:40:42 // 
#include <bits/stdc++.h>
using namespace std;

#define iterall(x) x.begin(), x.end()
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define endl '\n'

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;
typedef vector <pll> vpll;

const ll INF = 1e9+5;
const double EPS = 1e-9;
const int nax = 1e5+5;
vi adj[nax];
vb visited(nax);

void dfs(int u)
{
    visited[u] = 1;
    for(auto v: adj[u])
        if(!visited[v])
            dfs(v);
}

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    ll res = 0;
    for(int i = 1; i < n+1; i++)
        if(!visited[i])
            res++, dfs(i);
    
    cout << res - 1 <<endl;

}

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


int main() {
    int A, B;
    cin >> A >> B;
    int C = A + B;
    if (C == 3) {
        cout << 3 << endl;
    } else if (C == 4) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}




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

using namespace std;

int main(){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	int yes=0;
	
	if(a==b+c||b==a+c||c==a+b){
		yes=1;
	}
	if(yes==1)printf("Yes\n");
	if(yes==0)printf("No\n");
}

Measured memory_bytes: 256
a = int(input())
l = []
for i in range(a):
    t = int(input())
    l.append((i,t-1))
dic={0}
k=l[0][1]
ans=1
for i in range(a):
    if k == 1:
        print(ans)
        break
    elif k not in dic:
        dic.add(k)
        k=l[k][1]
        ans+=1
    else:
        print(-1)
        break


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

int main(){
	string ns;
	cin >> ns;
	ns = '0' + ns;
	ll ans = 0;
	bool nxp = false;
	for(int i=ns.size()-1;i>=0;i--) {
		int tmp = ns[i] - '0';
		if(nxp) {
			tmp++;
			if(tmp == 10) {
				nxp = true;
				tmp = 0;
			} else {
				nxp = false;
			}
		}
		if(tmp < 5) {
			ans += tmp;
			ns[i] = '0';
		} else if(tmp > 5) {
			ans += (10-tmp);
			ns[i] = '0';
			nxp = true;
		} else {
			int nxtmp = ns[i-1] - '0';
			if(nxtmp+1 > 5) {
				ans += (10-tmp);
				nxp = true;
			} else {
				ans += tmp;
				nxp = false;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2308
n,m = map(int, input().split())
#AC, WA
nn = [ [0, 0] for i in range(n)]
ps = []
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if nn[p - 1][0] == 0:
            nn[p - 1][0] += 1
        else:
            pass
    else:
        if nn[p - 1][0] == 0:
            nn[p - 1][1] += 1
        else:
            pass

ac = 0
wa = 0
for i in range(n):
    if nn[i][0] >= 1:
        ac += 1
        wa += nn[i][1]

print(str(ac) + " " + str(wa))


Measured memory_bytes: 13172
#include<stdio.h>
#include<string.h>

int main()
{
    char word[1000];
    scanf("%s",word);
    int c=0,c1=0,l=strlen(word),flag=0;
    if(word[0]=='A')
    {
        for(int i=2;i<l-1;i++)
        {
            if(word[i]=='C')
            {
                c++;
            }

        }
        if(c==1)
        {
            for(int i=0;i<l;i++)
            {
                if(word[i]>='a')
                {
                    c1++;
                }
            }

            if(c1==l-2)
            {
                flag=1;
            }
        }
    }
    if(flag==1)
    {
        printf("AC\n");
    }
    else
    {
        printf("WA\n");
    }


    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
    long long x;
    cin >> x;

    long long year = 0;
    long long sum = 100;
    while (sum < x) {
        sum += sum / 100;
        ++year;
    }
    cout << year << endl;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define bp(x) __builtin_popcountll(x)
#define ll int64_t
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define fw(i, l, r, c) for(int i = l; i <= r; i += c)
#define bw(i, r, l, c) for(int i = r; i >= l; i -= c)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;

ll res(ll x){
	if(x % 4 == 0) return x;
	else if(x % 4 == 1) return 1;
	else if(x % 4 == 2) return x + 1;
	else return 0;
}

int main() {
	//freopen("blu.inp", "r", stdin);
	//freopen("blu.out", "w", stdout);
	fastio;
	ll a, b, c;
	cin >> a >> b;
	ll ress = res(b) xor res(a - 1);
	cout << ress;
}


Measured memory_bytes: 256
#k,t=map(int,input().split())
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
p,ans=0,0
for i in range(n-1):
    p+=a[i]
    if p*2<a[i+1]:
        ans=i+1

print(n-ans)


Measured memory_bytes: 63856
def process() : 
    d = int(input())
    S = 0
    n = 600 / d
    for i in range(1,int(n)) :
        S += (i * d * i * d) * d
    print(S)
    
while True : 
    try : 
        process()
    except EOFError : 
        break
    



Measured memory_bytes: 5592
n = int(input())
a = [int(input()) for i in range(n)]
LSB = [0]*32
xor = 0
for i in a:
    xor ^= i
    k = (i&-i).bit_length()
    LSB[k-1] += 1
ans = 0
while xor:
    k = xor.bit_length()
    if LSB[k-1] == 0:
        print(-1)
        exit()
    ans += 1
    xor ^= (1<<k) - 1
print(ans)

Measured memory_bytes: 49496
n = gets.to_i
ts = gets.chomp.split.map(&:to_i)
m = gets.to_i
ps = Array.new(m)
xs = Array.new(m)
m.times do |i|
  ps[i], xs[i] = gets.chomp.split.map(&:to_i)
end

temp_sum = ts.inject(:+)
ps.each_with_index do |p, i|
  sum = temp_sum - ts[p - 1] + xs[i]
  puts sum 
end

Measured memory_bytes: 1788
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    bool solve(vector<int>& A) {
        int N = A.size();
        int n = 0;
        while (1 << n < N) {
            ++n;
        }


        multiset<int, greater<int>> M;
        multiset<int, greater<int>> R;
        for (auto x : A) {
            R.insert(x);
        }
        M.insert(*R.begin());
        R.erase(R.begin());

        for (int i = 0; i < n; ++i) {
            if (M.size() != (1 << i)) {
                return false;
            }
            auto it = M.begin();
            vector<int> nxt;
            for (int j = 0; j < (1 << i); ++j, ++it) {
                int x = *it;
                auto it2 = R.upper_bound(x);
                if (it2 == R.end()) {
                    return false;
                }
                nxt.push_back(*it2);
                R.erase(it2);
            }
            for (auto x : nxt) {
                M.insert(x);
            }
        }

        return true;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> A(1 << n);
    for (int i = 0; i < (1 << n); ++i) {
        cin >> A[i];
    }
    Solution sol;
    if (sol.solve(A)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 14328
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  if n<r:
    return 0
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n=I()
  l=[]
  for i in range(n):
    a=list(S())
    a.sort()
    l.append(a)

  l.sort()

  a=l[0]
  c=1
  ans=0
  for x in l[1:]:
    if a==x:
      c+=1
    else:
      ans+=nCr(c,2)
      c=1
      a=x

  ans+=nCr(c,2)
  c=1
  a=x
  return ans

# main()
print(main())


Measured memory_bytes: 27996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a,b,n;
  cin>>a>>b>>n;
  ll x;
  if(b-1<n)
  cout<<a*(b-1)/b<<endl;
  else
    cout<<a*n/b<<endl;
}


Measured memory_bytes: 3636
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto C = sread()[0];
    writeln(cast(char)(C + 1));
}


Measured memory_bytes: 256
package MyApp;
use utf8;
use 5.016;

print func(map { chomp; $_ } <>);

sub func {
    my $n = shift;
    my %hash;
    my $count = 0;
    my @lines;
    while (my $line = shift) {
        $count++;
        my ($s, $p) = split / /, $line;
        push @lines, +{city => $s, point => $p, line => $count};
    }
    my @result = map { $_->{line} } sort { $a->{city} cmp $b->{city} } sort { $b->{point} <=> $a->{point} } @lines;
    return join("\n", @result, '');
}

1;
__END__


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

int main(){
  ll n;
  cin>>n;
  ll s1=0;
  rep(i,n){
      if((i+1)%3==0);
      else if((i+1)%5==0);
      else s1+=i+1;
  }
  cout<<s1;
 
  return 0;
}

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

using namespace std;

#define MAXN 100
typedef long long LL;

int n, a, b, c, d;

int main()
{
    int i;
    cin >> n >> a >> b >> c >> d;
    for(i = 0; i < n; ++i){
        LL l = 1LL * c * i - 1LL * d * (n - i - 1);
        LL r = 1LL * d * i - 1LL * c * (n - i - 1);
        if(a + l <= b && b <= a + r){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int DIM = 52;
 
struct Matrix {
  int a[DIM][DIM];
  int *operator [] (int r) { return a[r]; };
 
  Matrix(int x = 0) {
    memset(a, 0, sizeof a);
    if (x)
    {
        for(int i = 0; i < DIM; i++) a[i][i] = x;
    }
  }
} const I(1);
 
Matrix operator * (Matrix A, Matrix B) {
  const ll mod2 = ll(mod) * mod;
  Matrix C;
 for(int i = 0; i < DIM; i++)
 {
     for(int j = 0; j < DIM; j++)
     {
        ll w = 0;
        for(int k = 0; k < DIM; k++)
        {
            w += ll(A[i][k]) * B[k][j];
            if (w >= mod2) w -= mod2;
        }
    C[i][j] = w % mod;
    }
  }
  return C;
}
 
Matrix operator ^ (Matrix A, ll b) {
  Matrix R = I;
  for (; b > 0; b /= 2) {
    if (b % 2) R = R*A;
    A = A*A;
  }
  return R;
}
int main(){
    ll n,k;cin>>n>>k;
    Matrix A;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>A[i][j];
    A=A^k;
    ll ans=0;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans=(ans+A[i][j])%mod;
    if(ans<mod)ans+=mod;
    cout<<ans%mod;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
int32_t main()
{
	int n,k;
	cin>>n>>k;
	int sum = 0;
	int a[n];
	for(int i = 0; i<n ; i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i = 0; i<k; i++)
	{
		sum += a[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    int n;
    cin >> n;

    int tmp;
    
    vector<int> a(100000,0);

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

    int ans = 0;

    for(int i=2;i<100000;i++){
        tmp = a[i-2] + a[i-1] + a[i];
        ans = max(tmp,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,m,a[333][333],cur[333],cnt[333];
bool kill[333];
bool check(int x)
{
	memset(kill,0,sizeof(kill));
	for(int i=1;i<=n;i++)cur[i]=1;
	for(int i=1;i<=m;i++)
	{
		memset(cnt,0,sizeof(cnt));
		for(int j=1;j<=n;j++)
		{
			while(cur[j]<=m&&kill[a[j][cur[j]]])cur[j]++;
			if(cur[j]==m+1)return false;
			cnt[a[j][cur[j]]]++;
		}
		bool up=0;
		for(int j=1;j<=m;j++)if(cnt[j]>x)
		{
			up=1;
			kill[j]=1;
		}
		if(!up)return true;
	}
	return false;
}
int main()
{
	get2(n,m);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)get1(a[i][j]);
	int l=0,r=n,mid;
	while(l<r-1)
	{
		mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	printendl(r);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}

vector<int> x(10);
vector<int> y(10);
double dist(int i, int j)
{
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i] >> y[i];
    }
    double sum = 0.0;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        vec[i] = i + 1;
    }
    do
    {
        for (int i = 0; i < n - 1; i++)
        {
            sum += dist(vec[i], vec[i + 1]);
        }
    } while (next_permutation(vec.begin(), vec.end()));
    int factrial = 1;
    for (int i = 2; i <= n; i++)
    {
        factrial *= i;
    }
    cout << fixed << setprecision(10) << sum / factrial << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>> n;
  vector<ll> v(n);
  rep(i,n){
    cin >> v[i];
    v[i]--;
  }
  ll ans = LINF;
  rep(i,100){
    ll tmp = 0;
    rep(j,n){
      tmp += pow(v[j]-i,2);
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# A - Double Helix
# A：アデニン T：チミン G：グアニン C：シトシン
# 対になる組み合わせ  A-T  G-C

# 標準入力
base = input()
# print(base)

# 条件分岐
if base == 'A':
    print('T')
elif base == 'T':
    print('A')
elif base == 'G':
    print('C')
elif base == 'C':
    print('G')


Measured memory_bytes: 8912
#include <iostream>
#include <algorithm>

int RoundUp10(int val)
{
    if (val % 10 > 0)
    {
        return val / 10 + 1;
    }
    return val / 10;
}

int GetTaxFreeVal(int tax8, int tax10)
{
    const auto taxFreeA10 = tax8 * 125;
    const auto taxFreeB10 = tax10 * 100;
    const auto taxFreeAplus10 = (tax8 + 1) * 125;
    const auto taxFreeBplus10 = (tax10 + 1) * 100;

    if (taxFreeA10 == taxFreeB10)
    {
        return RoundUp10(taxFreeB10);
    }
    if (taxFreeA10 < taxFreeB10)
    {
        if (taxFreeB10 < taxFreeAplus10)
        {
            return RoundUp10(taxFreeB10);
        }
    }
    else
    {
        if (taxFreeA10 < taxFreeBplus10)
        {
            return RoundUp10(taxFreeA10);
        }
    }

    return -1;
}

int main()
{
    int a = 0;
    std::cin >> a;

    int b = 0;
    std::cin >> b;

 
    std::cout << GetTaxFreeVal(a, b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    vint a(4);
    REP(i,4) a[i]=s[i]-'0';

    REP(S,1<<3){
        int ans=a[0];
        REP(i,3) if(S>>i&1) ans+=a[i+1]; else ans-=a[i+1];
        if(ans==7){
            string s="0-0-0-0=7";
            REP(i,4) s[i*2]='0'+a[i];
            REP(i,3) if(S>>i&1) s[i*2+1]='+';
            cout<<s<<endl;
            return 0;
        }
    }
}


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

int main() {
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  int A = a - '0';
  int B = b - '0';
  int C = c - '0';
  int D = d - '0';

  char op1 = '+';
  char op2 = '-';
  char op3 = '+';

  for(int i=0;i<8;i++) {
    bitset<8> op(i);
    int total = A;
    if(op[0]) {
      op1 = '+';
      total += B;
    } else {
      op1 = '-';
      total -= B;
    }
    if(op[1]) {
      op2 = '+';
      total += C;
    } else {
      op2 = '-';
      total -= C;
    }
    if(op[2]) {
      op3 = '+';
      total += D;
    } else {
      op3 = '-';
      total -= D;
    }
    if(total == 7) {
      break;
    }
  }
  cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>

using namespace std;

const int ys[4] = {-1, 0, 1, 0};
const int xs[4] = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;
  
  int num_whites = 0;
  vector<string> maze(H);
  for (int h = 0; h < H; ++h) {
    string line;
    cin >> line;
    for (const char c : line) {
      if (c == '.') ++num_whites;
    }
    maze[h] = line;
  }
  queue<pair<int, int>> q;
  vector<vector<int>> dist(H, vector<int>(W));
  q.push({0, 0});
  dist[0][0] = 1;
  bool find = false;
  while (!q.empty()) {
    const auto& cur = q.front(); q.pop();
    if (cur.first+1 == H && cur.second+1 == W) { find = true; break; }
    for (int i = 0; i < 4; ++i) {
      int h = cur.first + ys[i];
      int w = cur.second + xs[i];
      if (h < 0 || H <= h || w < 0 || W <= w) {
        continue;
      }
      if (dist[h][w] == 0) {
        if (maze[h][w] == '#') {
          dist[h][w] = -1;
        } else {
          dist[h][w] = dist[cur.first][cur.second] + 1;
          q.push({h, w});
        }
      }
    }
  }
  if (find) {
    cout << (num_whites - dist[H-1][W-1]) << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}
  

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    ll cnt[30] = {0};
    rep(i, n){
        string tmp;
        cin >> tmp;
        cnt[*tmp.begin() - 'A'] ++;
    }

    vector<char> chars = {'M', 'A', 'R', 'C', 'H'};
    vector<ll> nums(5);
    rep(i, 5) nums[i] = cnt[chars[i] - 'A'];

    ll sum = 0;
    rep(i, 5){
        repi(j, i+1, 5){
            repi(k, j+1, 5){
                sum += nums[i] * nums[j] * nums[k];
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
def rec(i, a, b, c, d):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')
        return abs(a-A)+abs(b-B)+abs(c-C)+d
    return min(rec(i+1,a+l[i],b,c,d+10),rec(i+1,a,b+l[i],c,d+10),rec(i+1,a,b,c+l[i],d+10),rec(i+1,a,b,c,d))
print(rec(0,0,0,0,-30))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
pair<int,int>arr[400009];
int n,m;
bool cmp(pair<int,int>a,pair<int,int>b){
    return a.second - a.first < b.second - b.first;
}
int sgt[1000009];
void UPD(int node,int l,int r,int k,int val){
    if(l == r){
        sgt[node] += val;
        return;
    }
    if((l+r)/2 >= k)UPD(node*2,l,(l+r)/2,k,val);
    else UPD(node*2+1,(l+r)/2+1,r,k,val);
    sgt[node] = sgt[node*2] + sgt[node*2+1];
}
int query(int node,int l,int r,int s,int e){
    if(l>=s&&r<=e)return sgt[node];
    if((l+r)/2>=s&&(l+r)/2+1<=e)return query(node*2,l,(l+r)/2,s,e)+query(node*2+1,(l+r)/2+1,r,s,e);
    if((l+r)/2>=s)return query(node*2,l,(l+r)/2,s,e);
    return query(node*2+1,(l+r)/2+1,r,s,e);
}
int ans[100009];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>arr[i].first>>arr[i].second;
        arr[i].first--;
        arr[i].second--;
        UPD(1,0,m,arr[i].first,1);
        UPD(1,0,m,arr[i].second+1,-1);
    }
    sort(arr,arr+n,cmp);
    int num = 0;
    for(int i=m;i>=1;i--){
        while(n>0 && i <= arr[n-1].second - arr[n-1].first+1){
            UPD(1,0,m,arr[n-1].first,-1);
            UPD(1,0,m,arr[n-1].second+1,1);
            n--;
            num++;
        }
        ans[i] += num;
        for(int j=i;j<=m;j+=i){
            ans[i] += query(1,0,m,0,j-1);
        }
    }
    for(int i=1;i<=m;i++){
        cout<<ans[i]<<endl;
    }
}


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

int main() {
    long long A,B,C,K;
    cin >> A >> B >> C >> K;
    if(A>=K) {
        cout << K << endl;
    }else if(A+B>=K) {
        cout << A << endl;
    }else{
        cout << A-(K-A-B) << endl;
    }
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = Integer.parseInt(sc.next());
		
		if(x < 30) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

	
	
}



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

string A;
long long dp[102][2][4];

long long solve(int pos, int lo, int K)
{
    if(K < 0)
        return 0;
    
    if(pos == A.size())
        return K == 0;
    
    if(dp[pos][lo][K] != -1)
        return dp[pos][lo][K];
    
    int digit = A[pos] - '0';
    long long ans = 0;

    for(int i=0; i<10; i++)
    {
        if(lo == 0 && i > digit)
            break;
        
        ans += solve(pos+1, (lo | (i < digit)), K - (i > 0));
    }

    return dp[pos][lo][K] = ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int K;
    cin >> A >> K;
    memset(dp, -1, sizeof(dp));
    
    cout << solve(0, 0, K) << "\n";
    return 0;
}


Measured memory_bytes: 256