akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// 線形篩 (for many numbers)
// for one number 
// https://github.com/atcoder-live/library/blob/master/prime.cpp

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for(int64_t i=2; i<=n; ++i) {
            if(!f[i]) {
                primes.emplace_back(i);
                f[i] = i;
            }
            for(int p:primes) {
                int u = p*i;
                if(u > n or p > f[i]) break;
                f[u] = p;
            }
        }
    }
    //素数判定
    bool isPrime(int x) {return f[x] == x;}
    //素数判定(1つ用)(宣言はsqrt(x)のサイズで)
    bool isPrime1(int64_t x) {
        bool m = true;
        for(int z:primes) {
            if(!(x%z)) {
                m = false;
                break;
            }
        }
        return m;
    }
    //素数列挙
    vector<int> factorList(int x) {
        assert(x <= n);
        vector<int> res;
        while(x != 1) {
            res.emplace_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    //素因数分解　pair(素数, 素因数の数)
    vector<pair<int, int> > factor(int x) {
        vector<int> fl = factorList(x);
        if(fl.size() == 0) return {};
        vector<pair<int, int> > res(1, pair<int, int>(fl[0], 0));
        for(int p : fl) {
            if(res.back().first == p) {
                ++res.back().second;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)
    vector<int64_t> factorList1(int64_t x) {
        vector<int64_t> vec;
        for(int z:primes) {
            while(!(x%z)) {
                vec.emplace_back(z);
                x /= z;
            }
        }
        if(x != 1) vec.emplace_back(x);
        return vec;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)　pair(素数, 素因数の数)
    vector<pair<int64_t, int> > factor1(int64_t x) {
        vector<int64_t> vec = factorList1(x);
        vector<pair<int64_t, int> > vecc;
        for(vector<int64_t>::iterator itr = vec.begin(); itr != vec.end(); ++itr) {
            if(itr != vec.begin() && *itr == *(itr-1)) {
                (vecc.end()-1)->second++;
            } else {
                vecc.emplace_back(pair<int64_t, int>(*itr, 1));
            }
        }
        return vecc;
    }
    //約数列挙
    vector<int64_t> div1(int64_t x) {
        vector<int64_t> res(1, 1);
        vector<pair<int64_t, int> > fac = factor1(x);
        for(int i = 0; i < fac.size(); ++i) {
            int si = res.size();
            for(int j = 0; j < fac[i].second; ++j) {
                for(int k = 0; k < si; ++k) {
                    res.emplace_back(res[k+j*si]*fac[i].first);
                }
            }
        }
        sort(res.begin(), res.end());
        return res;
    }
} pp(1000000);

int main() {
  long long a, b;
  cin >> a >> b;
  long long c = gcd(a, b);
  auto u = pp.factor1(c);
  cout << u.size()+1 << endl;
}

Measured memory_bytes: 7616
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	char a;
	cin>>a;
	if(a>='a'){
		cout<<"a"<<endl;
	}
	else{
		cout<<"A"<<endl;
	}
    return(0);
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;
typedef long long ll;
typedef pair<ll, ll> pll;

//最大公約数
//O(log max(a,b))
template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	return GCD(b, (T)(a % b));
}

ll N;
vector<ll> A;

int main() {
	cin >> N;
	A.resize(N);
	for (ll n = 0; n < N; n++) {
		cin >> A[n];
	}
	ll G = GCD(A[0], A[1]);
	for (ll n = 2; n < N; n++) {
		G = GCD(G, A[n]);
	}
	cout << G << endl;
	return 0;
}

Measured memory_bytes: 1152
import math as m


A, B, H, M = map(int, input().split())

angle_A = 30*H + 0.5*M
angle_B = 6*M
angle = abs(angle_A - angle_B)

print(
    m.sqrt(A**2 + B**2 - 2*A*B*m.cos(m.radians(angle)))
)

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

ll calc(ll l,ll r,ll n){
  l = ((l-1)/n+1)*n;
  if(l>r) return 0;
  return (r-l)/n+1;
}

ll calc(ll x){
  ll len=0,num = 1,cnt=1;
  while(num<=x){
    ll nx = min(x+1,num*10);
    ll d3 = calc(num,nx-1,3);
    ll d5 = calc(num,nx-1,5);
    ll d15= calc(num,nx-1,15);
    ll d  = d3+d5-d15;
    len+= ((nx-num) - d)*cnt;
    len+= (d3+d5)*4;
    num = nx;
    cnt++;
    if(len>n) return len;
  }
  return len;
}

ll search(){
  ll L=0,M,R=1LL<<60;
  while(L<R){
    M = (L+R)/2;
    if(calc(M)>=n)R = M;
    else L = M+1;
  }
  return L-1;
}

string ItoS(ll a){
  if(a==0) return "0";
  string res;
  while(a)res=(char)(a%10+'0')+res,a/=10;
  return res;
}

int main(){
  cin>>n;
  ll num = search()+1;
  ll len = calc(num-1);
  string ans;
  while(ans.size()<100){
    if(num%3==0) ans+="Fizz";
    if(num%5==0) ans+="Buzz";
    if(num%3&&num%5) ans+=ItoS(num);
    num++;
  }
  for(int i=0;i<20;i++)cout<<ans[n-len-1+i];
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 3228
from math import sin,cos,radians
a,b,c=map(int,input().split())
c=radians(c)
s=a*b*sin(c)*0.5
for i in[s,a+b+(a*a+b*b-2*a*b*cos(c))**0.5,s/a*2]:print('%5f'%i)


Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx2[25] = {2, 2, 2, 2, 2,-2, -2, -2,-2,-2,0,0,0,0,0,1,1,1,1,1,-1,-1,-1,-1,-1};
int dy2[25] = {0,-1,-2, 1, 2,-2, -1, 0, 1, 2,2,1,0,-1,-2,-2,-1,0,1,2,0,1,2,-1,-2};
signed main() {
    int H,W;
    cin >> H >> W;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<vector<char>>S(H+2,vector<char>(W+2,'#'));
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            cin >> S[i][j];
        }
    }
    vector<vector<P>>road(H*H+W*W);
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            for(int k = 0; k < 4; k++) {
                int nx = i+dx[k];
                int ny = j+dy[k];
                if(nx >= 1 && nx <= H && ny >= 1 && ny <= W) {
                    if(S[nx][ny] == '.') {
                        road[(i-1)*H+j].push_back({(nx-1)*H+ny,0});
                    }
                }
            }
            for(int k = 0; k < 25; k++) {
                int nx = i+dx2[k];
                int ny = j+dy2[k];
                if(nx >= 1 && nx <= H && ny >= 1 && ny <= W) {
                    if(S[nx][ny] == '.') {
                        road[(i-1)*H+j].push_back({(nx-1)*H+ny,1});
                    }
                }
            }
        }
    }
    vector<int>ans(H*H+W*W,INF);
    ans[(a-1)*H+b] = 0;
    priority_queue<P,vector<P>,greater<P>>que;
    que.push({(a-1)*H+b,0});
    while (!que.empty()) {
        P x = que.top();
        que.pop();
        if(ans[x.first] < x.second) {
            continue;
        }
        for(int i = 0; i < road[x.first].size(); i++) {
            if(ans[road[x.first][i].first] > x.second+road[x.first][i].second) {
                ans[road[x.first][i].first] = x.second+road[x.first][i].second;
                que.push({road[x.first][i].first,x.second+road[x.first][i].second});
            }
        }
    }
    if(ans[(c-1)*H+d] == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans[(c-1)*H+d] << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; ll K; cin >> N >> K;
    int A[N], F[N];
    FOR(i,0,N-1){ cin >> A[i]; }
    FOR(i,0,N-1){ cin >> F[i]; }
    sort(A,A+N);
    sort(F,F+N,greater<int>());

    ll lo = -1, hi = 1e12+1;
    while (hi-lo > 1) {
        ll mid = (lo+hi)/2;

        ll use = 0;
        FOR(i,0,N-1){
            ll x = mid/F[i];
            use += max(0LL,A[i]-x);
        }

        if (use > K) lo = mid;
        else hi = mid;
    }

    cout << hi << '\n';
}



Measured memory_bytes: 1792
#include <iostream>
#include <array>

std::array<long long int, 4001> ans;

void solve(int sum, int num) {
    if (num != 1) {
        int new_num = num + 1;
        for (int i = 0; i <= 1000; ++i) {
            solve(sum + i, new_num);
        }
    }
    else {
        for (int i = 0; i <= 1000; ++i) {
            ++ans[sum + i];
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    solve(0, 0);

    int n;

    while (std::cin >> n) {
        int sum = 0;
        for (int i = 0; i <= n; ++i) {
            sum += ans[i] * ans[n - i];
        }

        std::cout << sum << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1212
from bisect import bisect_left
def main():
    n, k = map(int, raw_input().split())
    a = map(int, raw_input().split())
    s = [0] * (n + 1)
    for i, x in enumerate(a):
        s[i+1] = s[i] + x
    b = [s[i] - s[j] for i in xrange(1, n + 1) for j in xrange(i)]
    b.sort()
    l, r = 0, len(b)
    y = z = 0
    for i in xrange(39, -1, -1):
        x = z + (1 << i)
        p = bisect_left(b, x, l, r)
        if r - p >= k:
            z = x
            y += 1 << i
            l = p
        else:
            b = [((1 << i) - 1) & b[j] for j in xrange(l, r)]
            b.sort()
            l, r = 0, len(b)
            z = 0
    print y
main()


Measured memory_bytes: 34636
#include <iostream>

using namespace std;
string ss;
int s[2005][2005][3];
int a[2005][2005];
int n,m,q,i,j,l1,l2,c1,c2;
int sum(int x,int l1,int c1,int l2,int c2)
{
    return s[l2][c2][x]-s[l2][c1-1][x]-s[l1-1][c2][x]+s[l1-1][c1-1][x];
}
int main()
{
    cin>>n>>m>>q;
    for(i=1;i<=n;i++)
    {
        cin>>ss;
        for(j=1;j<=m;j++)
            a[i][j]=ss[j-1]-'0';
        for(j=1;j<=m;j++)
      {
        s[i][j][0]=a[i][j]+s[i-1][j][0]+s[i][j-1][0]-s[i-1][j-1][0];
        s[i][j][1]=(a[i][j]&a[i][j-1])+s[i-1][j][1]+s[i][j-1][1]-s[i-1][j-1][1];
        s[i][j][2]=(a[i][j]&a[i-1][j])+s[i-1][j][2]+s[i][j-1][2]-s[i-1][j-1][2];
      }
    }
    for(i=1;i<=q;i++)
    {
        cin>>l1>>c1>>l2>>c2;
        cout<<sum(0,l1,c1,l2,c2)-sum(1,l1,c1+1,l2,c2)-sum(2,l1+1,c1,l2,c2)<<'\n';
    }
    return 0;
}


Measured memory_bytes: 64512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    s[b-1]=s[b-1]+(char)('a'-'A');
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 888
N = int(input())
A_list = list(map(int, input().split()))
M = max(A_list)+1
cnt = [0 for _ in range(M)]

for i in A_list:
    if cnt[i] != 0:
        cnt[i] = 2
        continue
    for j in range(i, M, i): cnt[j] += 1

ans = 0
for k in A_list:
    if cnt[k] == 1: ans += 1
print(ans)


Measured memory_bytes: 32096
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	int even = 0;
	int odd = 0;
	rep(i, n)
	{
		int a;
		cin >> a;

		if (a % 2 == 0)
		{
			even++;
		}
		else
		{
			odd++;
		}
	}
	cout<<pow(3,n)-pow(2,even)<<endl;
}


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

using namespace std;

int main()
{
    int i,n,x;
    cin >> n;
    for(i = 1;i <= n;i++){
        x = i;
        if(x % 3 == 0 || x % 10 == 3){
            cout << " " << i;
        }else{
            x /= 10;
            for(;x != 0;x /= 10){
                if(x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
    return 0;
}


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

int main(){
    string s;
    while(true){
        cin >> s;
        if (s == "0"){
            break;
        }
        int d = 0;
        for(int i = 0; i < s.size(); i++){
            int n = s[i] - 48;
            d += n;
        }
        cout << d << endl;
    }
}


Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        if (n >= k) {
            long t1 = n % k;
            long t2 = k - t1;
            System.out.println(Math.min(t1, t2));
            return;
        }
        long ans = Math.min(n, k - n);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	long long l,r;
	cin>>l>>r; 
	if(r%2019<l%2019 || r-l >= 2018)
		cout<<0<<endl;
	else{
		long long minn = 2019;
		for(long long i = l; i <= r;i++){
			for(long long j = i+1; j<=r;j++){
				minn = min(minn,(i%2019)*(j%2019)%2019);
			}
		}
		cout<<minn<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int n;
long long f[400];
int main()
{
    scanf("%d",&n);
    f[0]=2;
    for(int i=0;i<=n;i++)
    f[i]=f[i-1]*2+2;
    printf("%lld\n",f[n]);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int n,count=0;
  cin>>n;
  char p,q,temp;

  while(n--)
  {
    cin>>p;
    if(p!=temp)
      count++;
    if(n!=0)
      {
        n--;
        cin>>q;

    if(q!=p)
      count++;

    temp=q;
    } 
  }
  cout<<count;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll rf[4005], gf[4005], bf[4005], rb[4005], gb[4005], bb[4005];
int main() {
    init();
    ll N;
    cin>>N;
    string S;
    cin >> S;
    if(N<=3){
        cout << 0 << endl;
        return 0;
    }

    rep(i,N){
        rf[i + 1] += rf[i] + (S[i] == 'R');
        gf[i + 1] += gf[i] + (S[i] == 'G');
        bf[i + 1] += bf[i] + (S[i] == 'B');
    }

    ll ans = 0;
    repe(i,1,N-1){
        if(S[i]=='R'){
            ans += (gf[i] * (bf[N] - bf[i])) + (bf[i] * (gf[N] - gf[i]));
            repe(d,1,min(i,N-i-1)+1){
                if (S[i - d] == 'R' or S[i + d] == 'R') continue;
                if (S[i - d] != S[i + d]) ans--;
            }

        }
        else if(S[i]=='G'){
            ans += rf[i] * (bf[N] - bf[i]) + bf[i] * (rf[N] - rf[i]);
            repe(d,1,min(i,N-i-1)+1){
                if (S[i - d] == 'G' or S[i + d] == 'G') continue;
                if (S[i - d] != S[i + d]) ans--;
            }
        }
        else{
            ans += rf[i] * (gf[N] - gf[i]) + gf[i] * (rf[N] - rf[i]);
            repe(d,1,min(i,N-i-1)+1){
                if (S[i - d] == 'B' or S[i + d] == 'B') continue;
                if (S[i - d] != S[i + d]) ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int L = sc.nextInt();
        int sum = calcSum(L, L + N - 1);

        if (L > 0) {
            System.out.println(sum - L);
        } else if (N + L <= 0 && L <= 0) {
            System.out.println(sum - (L + N - 1));
        } else {
            System.out.println(sum);
        }

    }

    static int calcSum(int a, int b) {
        return (a + b) * (b - a + 1) / 2;
    }
}
	

Measured memory_bytes: 21588
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: u64 = 1_000_000_000 + 7;


fn main() {
    let n: u64 = read();
    let k: u64 = read();
    let n = n + 1;

    let mut ans = 0;
    let mut min: u64 = (0..k).sum();
    let mut max: u64 = (n-k..n).sum();
    ans += max - min + 1;
    for i in k..n {
        min += i;
        max += n - i - 1;
        // println!("{}: {} {}", i, min, max);
        ans += max - min + 1;
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
package main

import "fmt"

var a [50 + 2]int // レベルNバーガーの厚さ
var p [50 + 2]int // レベルNバーガーに含まれるパティの総数

func bgReal(n, x int) int { // デバッグ用
	str := ""
	if n < 11 {
		str = "P"
		for i := 1; i <= n; i++ {
			str = "B" + str + "P" + str + "B"
		}
		x--
		ret := 0
		for i := 0; i <= x && i < len(str); i++ {
			if str[i] == 'P' {
				ret++
			}
		}
		// fmt.Printf("bgReal(n %d, x %d): %s\n", n, x, str)
		return ret
	}
	return -1
}

func bgInit(n int) {
	a[0] = 1
	p[0] = 1
	for i := 0; i <= n; i++ {
		a[i+1] = 2*a[i] + 3
		p[i+1] = 2*p[i] + 1
	}
}

func rec(n, x int) int { // レベルnバーガーの下からx層に含まれるパティの数を返す関数
	var ret int
	// fmt.Printf("rec(n %d, x %d) en:\n", n, x)
	// レベルNバーガーの構造:
	// B + [レベルN-1バーガー] + P + [レベルN-1バーガー] + B
	if x == 1 { // 最下層についての問い合わせ
		if n == 0 { // レベル0バーガー
			ret = 1
		} else {
			ret = 0
		}
	} else if 1 < x && x <= 1+a[n-1] { // 一番下の層+その上のレベルn-1バーガーの下からx-1層
		ret = rec(n-1, x-1)
	} else if x == 2+a[n-1] { // 一番下の層＋その上のレベルn-1バーガーに含まれるパティ＋このレベルのパティ
		ret = p[n-1] + 1
	} else if 2+a[n-1] < x && x <= 2+2*a[n-1] {
		// 下側のレベルn-1バーガー全てと真ん中のパティを全て含み、上側のレベルn-1バーガーの途中にxがある場合
		ret = p[n-1] + 1 + rec(n-1, x-2-a[n-1])
	} else if x == 3+2*a[n-1] {
		ret = 2*p[n-1] + 1
	}
	return ret
}

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	bgInit(N)
	// fmt.Printf("bgReal(%d,%d)=%d\n", N, X, bgReal(N, X))
	fmt.Println(rec(N, X))
}


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

#define BR "\n"
#define SP " "

int main() {

  while(1) {
    ll H, W;
    cin >> H >> W;

    if (H + W == 0) break;

    string s = "", m = "";
    for (int i = 0; i < W; i++) {
      s += "#";
      if ( i == 0 || i == W - 1 ) {
        m += "#";
      } else {
        m += ".";
      }
    }

    for (int i = 0; i < H; i++) {
      if (i == 0 || i == H - 1) {
        cout << s << BR;
      } else {
        cout << m << BR;
      }
    }
    cout << BR;
  }

  return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> num_switch;
    vector< vector<int> > switch_index(m, vector<int>(0, 0));
    vector<int> mod;

    for (int i = 0; i < m; i++) {
        int tmp;
        cin >> tmp;
        num_switch.push_back(tmp);
        for (int j = 0; j < tmp; j++) {
            int tmp2;
            cin >> tmp2;
            switch_index[i].push_back(tmp2);
        }
    }

    for (int i = 0; i < m; i++) {
        int tmp;
        cin >> tmp;
        mod.push_back(tmp);
    }

    int ans = 0;
    for (int i = 0; i < pow(2, n); i++) {
        string count_str = bitset<10>(i).to_string();
        int sum_ok = 0;
        for (int j = 0; j < m; j++) {
            int on_count = 0;
            for (int k = 0; k < num_switch[j]; k++) {
                if (count_str[count_str.length() - switch_index[j][k]] == '1')
                    on_count++;
            }
            if (on_count % 2 == mod[j])
                sum_ok++;
        }
        if (sum_ok == m)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


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

//Compiler version g++ 6.3.0

int main()
{
    int a[3]={
      1,2,3
    },i,j,c,b;
    
   cin>>c>>b;
   
     for(j=0;j<3;j++){
       if(a[j]==c||a[j]==b) a[j]=0;
     }
     for(j=0;j<3;j++){
      if(a[j]!=0){
        cout<<a[j]<<endl;
        return 0;
      }
     }
}


Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
vector<int> v[100005];
int n,f[100005];
void dfs(int pos){
	vector<int> g;
	for(int i=0;i<v[pos].size();i++){
		dfs(v[pos][i]);
		g.push_back(f[v[pos][i]]);
	}
	sort(g.begin(),g.end());
	int ans=0;
	int len=g.size();
	for(int i=0;i<len;i++){
		ans=max(ans,g[i]+len-i);
	}
	f[pos]=ans;
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		v[x].push_back(i);
	}
	dfs(1);
	cout<<f[1]<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 13952
from collections import Counter
import math
import sys


def division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor


N, P = map(int, input().split())
if N == 1:
    print(P)
    sys.exit()
elif P == 1:
    print(1)
    sys.exit()

flist = division(P)
fc = Counter(flist)
ans = 1

for num, count in fc.items():
    while count >= N:
        ans *= num
        count -= N

print(ans)


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int fir(int l){
    while(l/10 >= 1){
        l /= 10;
    } 
    return l;
}


int main(){
 int n; cin>>n;
 int a[10][10];
 rep(i,9){
     rep(j,9){
         a[i][j] = 0;
     }
 }
 rep1(i,n){
     if(i%10 != 0){
         a[fir(i)-1][i%10-1]++;
     }
 }
 ll ans = 0;
 rep(i,9){
     rep(j,9){
         ans += a[i][j]*a[j][i];
     }
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, x float64
	fmt.Scan(&a, &b, &x)
	height := x / (a * a)
	var rad float64
	// 水が1/2dより入っている時
	if height >= (b / 2) {
		diff := (b - height) * 2
		rad = math.Atan(diff / a)
	} else {
		diff := (2 * x) / (a * b)
		rad = math.Atan(b / diff)
	}
	fmt.Println(radToDeg(rad))
}

func radToDeg(rad float64) float64 {
	return rad * 180.0 / math.Pi
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{  long n,a,b,i,x[10000000],sum=0;
   cin>>n>>a>>b;
   for(i=1;i<=n;i++)
   cin>>x[i];
   for(i=1;i<n;i++)
   {
   if((x[i+1]-x[i])*a>=b) sum+=b;
   else sum+=(x[i+1]-x[i])*a; 
   }
   cout<<sum;
   getchar();
   getchar();
   return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

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

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n], dp[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,a[N],res;
signed main()
{
    n=read();
    for(ri int i=1;i<=n;i++) a[i]=read(), res+=abs(a[i]-a[i-1]);
    res+=abs(a[n]);
    for(ri int i=1;i<=n;i++) printf("%lld\n",res+abs(a[i-1]-a[i+1])-abs(a[i-1]-a[i])-abs(a[i]-a[i+1]));
    return 0;
}

Measured memory_bytes: 4420
n = int(input())
a = [int(input()) for _ in range(n)]
m = max(a)

if a.count(m) > 1:
    for _ in range(n):
        print(m)
else:
    mi = a.index(m)
    for i in range(n):
        if i == mi:
            ma = max(a[: i] + a[i + 1: ])
            print(ma)
        else:
            print(m)


Measured memory_bytes: 15580
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> p(n, 0);
    vector<int> pmin(n, 0);
    int min = 1e9+7;
    for(int i = 0; i < n; ++i) {
        cin >> p.at(i);
        if(min > p.at(i)) {
            min = p.at(i);
        }
        pmin.at(i) = min;
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        int tar = p.at(i);
        bool ok = true;
        if(p.at(i) <= pmin.at(i)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1792
//https://atcoder.jp/contests/dp/tasks/dp_d
#include<bits/stdc++.h>
#define forz(i,n) for(int i=0;i<n;i++)
#define foro(i,n) for(int i=1;i<=n;i++)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define lli long long int
using namespace std;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
lli maxy(lli a,lli b)
{
     return (a>b)?a:b;
}
int main()
{
     faster
     lli n,w;
    cin>>n>>w;
    lli wi[n+1],pi[n+1];
    for(int i=1;i<=n;i++)
    {
         cin>>wi[i]>>pi[i];
    }
    lli dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
         dp[i][0]=0;
    }
    for(int i=0;i<=w;i++)
   {
        dp[0][i]=0;
   }
    for(int i=1;i<=n;i++)
    {
         for(int j=1;j<=w;j++)
         {
              if(j<wi[i])
              {
                   dp[i][j]=dp[i-1][j];
                   continue;
              }
                int itrupto=j-wi[i];
                dp[i][j]=maxy(dp[i-1][j],dp[i-1][itrupto]+pi[i]);
         }
    }
   
cout<<dp[n][w]<<'\n';


}

Measured memory_bytes: 79104
import sys
sys.setrecursionlimit(10 ** 6)

def find(parent, v):
    if v == parent[v]:
        return v
    parent[v] = find(parent, parent[v])
    return parent[v]

def unite(parent, rank, u, v):
    u = find(parent, u)
    v = find(parent, v)
    if u == v:
        return
    if rank[u] < rank[v]:
        parent[u] = v
    else:
        parent[v] = u
        if rank[u] == rank[v]:
            rank[u] += 1

N, K, L = map(int, input().split())
roads = list(range(N+1))
rails = list(range(N+1))
r_rank = [0] * (N + 1)
t_rank = [0] * (N + 1)

for _ in range(K):
    p, q = map(int, input().split())
    unite(roads, r_rank, p, q)
for _ in range(L):
    p, q = map(int, input().split())
    unite(rails, t_rank, p, q)

d = {}
for i in range(1, N+1):
    p = (find(roads, i), find(rails, i))
    d[p] = d.get(p, 0) + 1

print(*[d[(find(roads, i), find(rails, i))] for i in range(1, N+1)])

Measured memory_bytes: 55780
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	long long N;
	int cnt;

	cin>>N;
	cnt=0;

	while(N>1){
		cnt++;
		if(N%3==0) N=N/3;
		else N=N/3+1;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1164
input_text = input()
input_ = input_text.split()

cou5 = 0
cou7 = 0

for i in ([int(j) for j in input_]):
    if int(i) == 5:
        cou5 += 1
    elif int(i) == 7:
        cou7 += 1

if cou5 == 2 and cou7 == 1:
    result = "YES"
else :
    result = "NO"

print(result)

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

template<class T> inline bool chmin(T& a, T b){
    if(a>b){
        a=b;
        return true;
    }
    else
    {
        return false;
    }
}

int main(int argc, char const *argv[])
{
    int n;
    const ll INF = 1ll<<60;
    vector<ll> dp(100000,INF);
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;++i)cin >> h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;++i){
        chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n-1]<< endl;
    

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  ll sum = 0;
  vector<pair<ll, bool> > s(n);  
  rep(i, 0, n) {
    cin >> s[i].first; 
    sum += s[i].first;
    if(s[i].first%10 != 0) s[i].second = true;
    else s[i].second = false;
  }
  if(sum%10 != 0) {
    cout << sum << "\n";
    return 0;
  }
  sort(all(s));
  ll ans = 0;
  rep(i, 0, n) {
    if(s[i].second) {
      ans = sum-s[i].first; 
      cout << ans << "\n";
      return 0;
    }
  }
  cout << 0 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}


#define S0 10000
signed main(){

    int N; cin >> N;
    vec w(N), s(N), v(N);
    vector<Pii> p(N);
    REP(i, N){
        cin >> w[i] >> s[i] >> v[i];
        p[i] = Pii(s[i] + w[i], i);
    }
    SORT(p); REVERSE(p);
    vec W(N), S(N), V(N);
    REP(i, N){
        W[i] = w[p[i].second];
        S[i] = s[p[i].second];
        V[i] = v[p[i].second];
    }
    mat dp(N + 1, vec(S0 + 1, -INF));
    REP(i, N){
        REP(j, S0 + 1) dp[i + 1][j] = dp[i][j];
        dp[i + 1][S[i]] = max(dp[i + 1][S[i]], V[i]);
        REP(j, S0 + 1){
            if(dp[i][j] != -INF && j >= W[i]){
                dp[i + 1][min(S[i], j - W[i])] = max(dp[i + 1][min(S[i], j - W[i])], dp[i][j] + V[i]);
            }
        }
    }
    //debug(dp);
    int ans = -INF;
    REP(i, S0 + 1) ans = max(ans, dp[N][i]);
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 78720
#include <bits/stdc++.h>
using namespace std;
int A, B, X;
int main() {
    cin >> A >> B >> X;
    if(X - A < B) {
        if(X < A) {
            cout << "NO" << endl;
        }else {
            cout << "YES" << endl;
        }
    }else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  
  map<ll, ll> mp[2];
  for(i=0; i<N; i++) {
    ll a;
    cin >> a;
    mp[i&1][a]++;
  }
  mp[0][-1]=0;
  mp[1][-1]=0;
  
  priority_queue<pll> qu[2];
  for(i=0; i<2; i++) {
    for(auto it=mp[i].begin(); it!=mp[i].end(); it++) {
      qu[i].push(pll(it->sc, it->ft));
    }
  }
  
  pll p=qu[0].top(); qu[0].pop();
  pll q=qu[1].top(); qu[1].pop();
  
  pll p1=qu[0].top();
  pll q1=qu[1].top();
  
  if(p.sc==q.sc)
    pt(min(N-p.ft-q1.ft, N-p1.ft-q.ft));
  else
    pt(N-p.ft-q.ft);
  
  
  
}
 
 


Measured memory_bytes: 8824
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int ans = 0;
		int N = scn.nextInt();
		if(N/100==1)ans++;
		if((N%100)/10==1)ans++;
		if(N%10==1)ans++;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22740
H,W,K = map(int,input().split())
s=[list(input()) for i in range(H)]
area=[[0 for _ in range(W)] for _ in range(H)]

st_num=[0]*H
st_pos=[[] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j]=="#":
            st_num[i] += 1
            st_pos[i].append(j)

upper=0
cnt=0
for i in range(H):
    if st_num[i]==0:
        upper=min(upper,i)
    else:
        cnt+=1
        
        #左の余白
        if st_pos[i][0]>0:
            for p in range(upper,i+1):
                for q in range(st_pos[i][0]):
                    area[p][q]=cnt
        #左端のいちごから右端のいちご左まで
        for j in range(st_num[i]-1):
            for p in range(upper,i+1):
                for q in range(st_pos[i][j],st_pos[i][j+1]):
                    area[p][q]=cnt
            cnt+=1
        #右端のいちごから右
        for p in range(upper,i+1):
            for q in range(st_pos[i][-1],W):
                area[p][q]=cnt                    
        upper = i+1
        
if upper!=H:  #下端のいちごよりも下の領域
    for p in range(upper,H):
        for q in range(W):
            area[p][q]=area[upper-1][q]                    
                
for i in area:
    print(*i)

Measured memory_bytes: 9416
#include<stdio.h>
int main(void){
  int n,m;//n:スイッチ m:電球
  scanf("%d%d",&n,&m);
  int k[m];//電球が何このスイッチと繋がってるか
  int s[m][n];//電球がどのスイッチと繋がってるか
  int p[m];//電球がつく条件  
  for(int i=0;i<m;i++){
	scanf("%d",&k[i]);
    for(int j=0;j<k[i];j++){
		scanf("%d",&s[i][j]);
    }
  }
  for(int i=0;i<m;i++){
    	scanf("%d",&p[i]);
  }
  int ans=0;
  int sp[n];  //どのスイッチが点灯してるかのパターン
for(int i=0;i<(1<<n);i++){int c=0;
                 for(int z=0;z<n;z++){
		sp[z]=0;  //spの初期化
                 }
                          int flag=1;
	for(int j=0;j<n;j++){
      if(i&(1<<j)){sp[c++]=j+1;
           // printf("スイッチ%dがon ",j+1); 
                  }
    }
             //   printf("\n");
	for(int l=0;l<m;l++){     //電球一つ一つ見てく
      int oncount=0;
      for(int x=0;x<k[l];x++){//その電球のスイッチを一つ一つ
        for(int y=0;y<c;y++){//onのスイッチを一つ一つ
          if(s[l][x]==sp[y]){
            oncount++;
            break;
          }
      }
    }
      	if(oncount%2!=p[l]){flag=0;
                            break;}
                          
                         }
   	if(flag)ans++;
    }
          printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
INF = 2000000000


def read_adj_mat():
    nv, ne = [int(x) for x in input().split()]
    A = [[0 if fr == to else INF for fr in range(nv)] for to in range(nv)]
    for _ in range(ne):
        s, t, d = [int(x) for x in input().split()]
        A[s][t] = d
    return A


def get_shortest_paths(D):
    n = len(D)
    for to in range(n):
        for fr in range(n):
            here = D[fr][to]
            if here == INF:
                continue
            for to2 in range(n):
                here2 = D[to][to2]
                if here2 == INF:
                    continue
                D[fr][to2] = min(D[fr][to2], here + here2)


def print_result(D):
    for fr in range(len(D)):
        for to in range(len(D)):
            if to != 0:
                print(" ", end="")
            if D[fr][to] == INF:
                print("INF", end="")
            else:
                print(D[fr][to], end="")
        print()


def main():
    D = read_adj_mat()
    get_shortest_paths(D)
    for d in [D[x][x] for x in range(len(D))]:
        if d < 0:
            print("NEGATIVE CYCLE")
            break
    else:
        print_result(D)


if __name__ == '__main__':
    main()



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

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int ans = (a[2] - a[1]) + (a[2] - a[0]);
	if (ans % 2 == 0)cout << ans / 2 << endl;
	else cout << (ans + 3) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
int n;
vector<vector<P> > G;

typedef pair<int,P> PP;
int dijkstra(int s,int t){
  vector<int> D(n,INF);
  vector<int> used(n,0);
  priority_queue<P,vector<P>,greater<P> > Q;
  D[s] = 0;
  Q.push(P(0,s));
  while(!Q.empty()){
    int cost,pos; tie(cost,pos) = Q.top(); Q.pop();
    if(used[pos]++) continue;
    if(pos == t) return cost;
    
    for(auto p:G[pos]){
      int to = p.first;
      int ncost = cost + p.second;
      if(D[to] <= ncost) continue;
      Q.push(P(ncost,to));
      D[to] = ncost;
    }
  }
  assert(0);
}

signed main(){
  int m,s,t;
  cin>>n>>m>>s>>t; s--,t--;
  G.resize(n);
  for(int i=0;i<m;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d; a--,b--,c--;
    G[a].push_back(P(b,d));
    G[b].push_back(P(a,d));
    
    G[a].push_back(P(c,d));
    G[c].push_back(P(a,d));
    
    G[b].push_back(P(c,d));
    G[c].push_back(P(b,d));
  }

  int ans = dijkstra(s,t);
  cout<<ans<<endl;
  
  return 0;
}



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

int main(void){
  int N;
  int n[2];
  bool ans = false;
  cin >> N;
  n[0] = N % 10;
  n[1] = (N - n[0]) / 10;
  if(n[0] == 9 || n[1] == 9)
    ans = true;
  if(ans) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3560
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int dp[110] = {};
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		dp[d]++;
	}
	int ans = 0;
	for (int i = 100; i >= 0; i--) {
		if (dp[i]) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
    int a,b,x,abs1,abs2;
    cin>>x>>a>>b;
    if(a-x>=0){
        abs1= a-x;
    }
    else{
        abs1= -(a-x);
    }
    if(b-x>=0){
        abs2= b-x;
    }
    else{
        abs2=-(b-x);
    }
    if(abs1>abs2){
        printf("B");
    }
    else{
        printf("A");
    }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
	const int maxn=500000;
	int p[32];
	int main(){
		int n,k;
		scanf("%d%d",&n,&k);
		p[0]=1;
		for(int i=1;i<31;i++){
			p[i]=(p[i-1]<<1);
		}
		long double ans=0;
		long double per=1.0/n;
		for(int i=1;i<=n;i++){
			if(i>=k)
				ans+=per;
			else{
				int t=i;
				for(int j=1;j<31;j++){
					if(p[j]*t>=k){
						ans+=per*(1.0/p[j]);
						break;
					}
				}
			}
		}
		cout<<setprecision(20)<<ans<<endl;
	} 

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

int main(){
    string n;
    cin >> n;
    rep(i, n.size()){
        if (n[i] == '7'){
            cout << "Yes" << endl;
            return 0; 
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,x,i,j;
  cin>>k>>x;
  i=x-k+1;
  j=x+k-1;
  for(int n=i;n<=j;n++)
  {
    cout<<n<<" ";
  }
  return 0;
}

Measured memory_bytes: 256
from datetime import date,timedelta
a=date(2012,12,21)
while 1:
    try:s=list(map(int,input().split('.')))
    except:break
    d=0
    if len(s)<4:    
        while s[0]>3000:d+=365*400+97;s[0]-=400
        d+=(date(s[0],s[1],s[2])-a).days
        d,k=divmod(d,20)
        d,w=divmod(d,18)
        d,t=divmod(d,20)
        d,_k=divmod(d,20)
        b=d%13
        print('.'.join(map(str,[b,_k,t,w,k])))
    else:
        for i in range(len(s)-1):
            d+=s[i]
            d*=18 if i==2 else 20
        d+=s[4]
        d=a+timedelta(days=d)
        print('.'.join(map(str,[d.year,d.month,d.day])))

Measured memory_bytes: 8152
#include <stdio.h>

int main(void) {
  double x1, y1, x2, y2, x3, y3, xp, yp;
  while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
    double st, tt, ut;
    int s, t, u;
    x1 -= xp, x2 -= xp, x3 -= xp;
    y1 -= yp, y2 -= yp, y3 -= yp;
    //printf("%f %f %f %f %f %f\n", x1, y1, x2, y2, x3, y3);
    st = x1 * y2 - x2 * y1;
    if(!st) {
      printf("NO\n");
      continue;
    }
    s = st < 0 ? 0 : 1;
    tt = x2 * y3 - x3 * y2;
    if(!tt) {
      printf("NO\n");
      continue;
    }
    t = tt < 0 ? 0 : 1;
    ut = x3 * y1 - x1 * y3;
    if(!ut) {
      printf("NO\n");
      continue;
    }
    u = ut < 0 ? 0 : 1;
    //printf("%d %d %d\n", s, t, u);
    if(s == t && t == u) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 2752