akhauriyash/Code-Regression huggingface dataset:
/* #region template */
#![allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, Bytes, Read, Stdin, StdinLock, Stdout, StdoutLock, Write};
use std::iter::{repeat, repeat_with};
use std::mem::swap;
use std::str::FromStr;
#[allow(dead_code)]
struct Io<'a> {
    reader: Bytes<StdinLock<'a>>,
    writer: StdoutLock<'a>,
    in_buf: [u8; BUF_SIZE],
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn new(stdin: &'a Stdin, stdout: &'a Stdout) -> Io<'a> {
        Io {
            reader: stdin.lock().bytes(),
            writer: stdout.lock(),
            in_buf: [0; BUF_SIZE],
        }
    }
    fn r<T: FromStr>(&mut self) -> T {
        let mut count = 0;
        loop {
            match self.reader.next() {
                Some(Ok(b' ')) | Some(Ok(b'\n')) => break,
                Some(Ok(c)) => self.in_buf[count] = c,
                _ => panic!(),
            }
            count += 1;
        }

        let s = unsafe { std::str::from_utf8_unchecked(&self.in_buf[0..count]) };
        s.parse().unwrap_or_else(|_| panic!())
    }
    fn ru(&mut self) -> usize {
        self.r()
    }
    fn iter<'b, T>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter::new(self)
    }
    fn c<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        self.iter().take(n).collect()
    }
    fn cu(&mut self, n: usize) -> Vec<usize> {
        self.c(n)
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.writer, "{}", v).unwrap();
    }
    fn wn<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.writer, "{}", v).unwrap();
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T> {
    io: &'b mut Io<'a>,
    m: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a: 'b, 'b, T> IoIter<'a, 'b, T> {
    fn new(io: &'b mut Io<'a>) -> IoIter<'a, 'b, T> {
        IoIter {
            io,
            m: std::marker::PhantomData,
        }
    }
}
impl<'a, 'b, T: FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut io = Io::new(&stdin, &stdout);
    unsafe {
        solve(&mut io);
    }
}
/* #endregion */

const BUF_SIZE: usize = 1024;

const DIV: usize = 1000000007;
unsafe fn solve(io: &mut Io) {
    let n = io.ru();
    let k = io.ru();

    let mut count = vec![0usize; k + 1];
    let mut sum = 0;

    for i in (1..=k).rev() {
        let mut c = mod_pow(k / i, n, DIV);
        for j in (i * 2..=k).step_by(i) {
            while count[j] > c {
                c += DIV;
            }
            c -= count[j];
        }
        count[i] = c;
        sum += i * c % 1_000_000_007;
        while sum > DIV {
            sum -= DIV;
        }
    }

    io.w(sum);
}

fn mod_pow(a: usize, b: usize, div: usize) -> usize {
    let mut ret = 1;

    let mut m = a;
    for i in 0..std::mem::size_of::<usize>() * 8 {
        if (b >> i) & 1 != 0 {
            ret = (ret * m) % div;
        }
        m = m * m % div;
    }

    ret
}


Measured memory_bytes: 2784
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string.h>

using namespace std;

struct team{
    int id,school,right,penalty;
};
bool sor(const team& e,const team& t){
    return e.right==t.right?e.penalty==t.penalty?e.id<t.id:e.penalty<t.penalty:e.right>t.right;
}
int main(){
    int n;
    while(cin>>n,n){
        vector<team>vec;
        for(int i=0;i<n;i++){
            team t;
            cin>>t.id>>t.school>>t.right>>t.penalty;
            vec.push_back(t);
        }
        sort(vec.begin(),vec.end(),sor);
        vector<int>v;
        int sc[1002]={0};
        for(int i=0;i<vec.size();i++){
            if(v.size()<10){
                if(sc[vec[i].school]<3){
                    sc[vec[i].school]++;
                    v.push_back(vec[i].id);
                }
            } else if(v.size()<20){
                if(sc[vec[i].school]<2){
                    sc[vec[i].school]++;
                    v.push_back(vec[i].id);
                }
            } else if(v.size()<26){
                if(sc[vec[i].school]<1){
                    sc[vec[i].school]++;
                    v.push_back(vec[i].id);
                }
            }
        }
        for(int i=0;i<v.size();i++){
            cout<<v[i]<<endl;
        }
    }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int x;
	cin >> x;
	bool f = false;
	int a, b;
	for (a = -120; a <= 120; a++) {
		for (b = -120; b <= 120; b++) {
			if ((pow(a, 5) - pow(b, 5)) == x) {
				f = true;
				break;
			}
		}
		if (f) break;
	}

	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 3976
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	int A[200100];
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	sort(A, A + N);
	int prev = 0;
	string ans = "YES";
	for (int i = 0; i < N; i++) {
		if (prev == A[i]) {
			ans = "NO";
			break;
		} else {
			prev = A[i];}
	}

	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4448
#include <cstdio>
#include <vector>
using namespace std;

int unko(int a, int k) {
        if (a < k) return 0;
        if (a % k == 0) return a / k;
        int hoge = a / k + 1;
        int fuga = a % k - 1;
        return unko(a - (fuga / hoge + 1) * hoge, k);
}

int main() {
        int n;
        scanf("%d", &n);
        long long ans = 0;
        for (int i = 0; i < n; i ++) {
                long long a, k;
                scanf("%lld%lld", &a, &k);
                ans ^= unko(a, k);
        }
        puts(ans ? "Takahashi" : "Aoki");
        return 0;
}



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

#define ll long long int

using namespace std;

int main() {
    ll n, d;
    cin >> n >> d;
    d = d * d;
    ll res = 0;
    for (ll i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= d) {
            ++res;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3632
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  ll a, v, b, w, t;cin>>a>>v>>b>>w>>t;

  if(v<=w){cout<<"NO"<<endl;return 0;}
  cout<<(abs(a-b)<=t*(v-w)?"YES":"NO")<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define LAST(i,n) if(i==n-1)
#define PRINT(s) cout << s << "\n"
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << "\n"; })

typedef long lint;
typedef pair<lint, lint> P;

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

    vector<string> S;
    lint N; cin >> N;

    REP(_,N) {
      string s;cin >> s;S.push_back(s);
    }

    lint res = 0;
    
    REP(a,N) {
      bool flag = true;
      FOR(x, 0, N) {
        FOR(y, x+1, N) {
          if(S[(x+N-a)%N][y] != S[(y+N-a)%N][x]) {
            flag = false;
          }

          if(!flag) break;
        }
        if(!flag) break;
      }
      if(flag) res += N;
    }
    PRINT(res);
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

struct MyStr{
	int Y;
	int P;
	int No;
	int X;
};

bool cmp_no(const MyStr &a, const MyStr &b) {
	return a.No < b.No;
}

bool cmp(const MyStr &a, const MyStr &b) {
	if (a.P == b.P) {
		return a.Y < b.Y;
	}
	else {
		return a.P < b.P;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<MyStr> vec(M);

	for (int i = 0; i < M; i++)
	{
		cin >> vec[i].P >> vec[i].Y;
		vec[i].No = i;
	}

	sort(vec.begin(), vec.end(), cmp);

	int t = 1;
	vec[0].X = 1;
	for (int i = 1; i < M; i++)
	{
		if (vec[i - 1].P != vec[i].P) {
			vec[i].X = 1;
			t = 1;
		}
		else {
			vec[i].X = ++t;
		}
	}

	sort(vec.begin(), vec.end(), cmp_no);

	for (int i = 0; i < M; i++)
	{
		printf("%06d%06d\n", vec[i].P,vec[i].X);
	}

	return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int mod=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%mod;
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}


int main() {
	int n;
	ll ans=0;
	cin>>n;
	rep(i,1,n+1)rep(j,1,n+1)rep(k,1,n+1){
		ans+=__gcd(i,__gcd(j,k));
	}
	print(ans);
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
#define int long long
signed main(){
    int n,k;
    typedef pair<int,int> pii;
    cin>>n>>k;
    vector<bool>flag(n+1,true);
    vector<bool>IsPrint(n+1,true);
    vector<pii>mp(n+1);
    int ans=0;
    rep(i,n){
        int temp; cin>>temp;
        if(temp==0){ans++; mp[i+1]=pii(0,0);flag[i+1]=false; continue;}
        mp[i+1]=pii(temp,mp[temp].second+1);
        flag[temp]=false;
    }
    vector<int>yebi;
    vector<int>dp(n+1,0);
    rep(i,n)if(flag[i+1])yebi.push_back(i+1);
    rep(z,yebi.size()){
        int i=yebi[z];
        ans++;
        IsPrint[i]=false;
        flag[i]=false;
        pii next=mp[i];
        for(int i=1;i<=k-1;i++){
            if(mp[next.first].second==0)break;
            if(IsPrint[next.first]==false){
                if(dp[next.first]>=k-1-i)break;
                dp[next.first]=max(dp[next.first],k-1-i);
                IsPrint[next.first]=false;
                next=mp[next.first];
                continue;
            }
            IsPrint[next.first]=false;
            flag[next.first]=false;
            ans++;
            next=mp[next.first];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int a,b,k;cin>>a>>b>>k;
    map<int,int>mp;
    rep(i,k){
        mp[min(b,a+i)]++;
    }
    rep(i,k){
        mp[max(a, b-i)]++;
    }
    for(auto i=mp.begin();i!=mp.end();i++){
        co(i->first);
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lisson2
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            if (!(1 <= a && a <= 100)) return;
            if (!(0 <= b && b <= 100)) return;

            int x = (a + b + 1) / 2;
            
            Console.WriteLine(x);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    int x,y;
    
    int is_x = 0;
    int is_y = 0;
    
    int a[7] = { 1, 3, 5, 7, 8, 10, 12 };
    
    
    cin >> x;
    cin >> y;
    
    for ( int i = 0; i < 7; i++ ) {
        if ( a[i] == x ) { is_x = 1; }
        if ( a[i] == y ) { is_y = 1; }
    }
    
    if ( x == 2 ) { is_x = 2; }
    if ( y == 2 ) { is_y = 2; }
    
    cout << ( is_x == is_y ? "Yes" : "No" ) << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	if (N == 1 && M == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<int>ans(N);

	REP(i, N)ans[i] = -1;
	bool F = true;
	REP(i, M) {
		int s, c; cin >> s >> c;
		s--;

		if (s == 0 && c == 0 && N != 1)F = false;

		if (ans[s] != -1 && ans[s] != c) {
			F = false;
		}
		else {
			ans[s] = c;
		}

	}
	REP(i, N) {
		if (ans[i] == -1) {
			if (i == 0)ans[i] = 1;
			else ans[i] = 0;
		}
	}
	if (F) {
		REP(i, N)cout << ans[i];
		cout << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  string s;
  cin>>s;
  vector<string>div={"dream","dreamer","erase","eraser"};
  reverse(s.begin(),s.end());
  rep(i,4){reverse(div[i].begin(),div[i].end());}
  bool ex=true;
  for(int i=0;i<s.size();){
    bool ex2=false;
    rep(j,4){
      string d=div[j];
      if(d==s.substr(i,d.size())){
         ex2=true;
         i+=d.size();
      }
    }
      if(ex2==false){
        ex=false;
        break;
      }
  }
  if(ex==true)
         cout<<"YES"<<endl;
  else
         cout<<"NO"<<endl;
}

Measured memory_bytes: 512
N,M=map(int,input().split())
a = -1
List = []
for i in range(M):
    k = int(input())
    List.append(k-a)
    a = k
List.append(N - a + 1)
m = max(List)
mm = min(List)
LL = [0,1]
for i in range(2,m):
    k = LL[i-1] + LL[i-2]
    LL.append(k)
s = 1
for i in range(M+1):
    s = s * LL[List[i]-1]
print(s % 1000000007)

Measured memory_bytes: 460020
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 +7;

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

    cout << (1 + n) * n / 2 - n << endl;
}

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

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

ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod - 2, mod) % mod;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll kit = 10e8 + 7;

    ll ans = modPow(2, n, kit);
    ans--;
    ans -= choose(n, a, kit);
    ans -= choose(n, b, kit);
    ans %= kit;
    if (ans < 0){
        ans += kit;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long p = 1;
		for (int i = 1; i <= N; i++) {
			p = p*i%1000000007;
		}
		long ans = p;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
n,m = map(int, input().split())

sc = set([tuple(map(int, input().split())) for _ in range(m)])
ans = 0
h = []

for x,y in sc:
  if n != 1 and x == 1 and y == 0:
    print(-1)
    exit()
  if x in h:
    print(-1)
    exit()
  ans += y * (10 ** (n-x))
  h.append(x)
  
if ans < 10**(n-1) and n != 1:
  ans += 10**(n-1)
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	long long int k, a, b;
	cin >> k >> a >> b;
	if(a >= k || b - a < 2) cout << k + 1 << endl;
	else cout << ((k - a + 1) / 2) * (b - a) + a + ((k - a + 1) % 2) << endl;
	return 0;
}

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

using namespace std;

typedef long double ld;
const ld eps = 1e-10;

vector<int> p[2];

ld eval(ld x)
{
    int i;
    ld ans = 0;
    for(i=0; i<6; ++i)
        ans += max(p[0][i] * x, p[1][i] * (1 - x));
    return ans;
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false); cin.tie(0);

    p[0].resize(6);
    p[1].resize(6);

    int i, j;

    for(i=0; i<2; ++i)
        for(auto &it : p[i]) cin >> it;

    ld st, dr, mid1, mid2;
    st = 0; dr = 1;

    while(dr - st > eps)
    {
        mid1 = (st * 2 + dr) / 3;
        mid2 = (st + dr * 2) / 3;

        if(eval(mid1) < eval(mid2)) dr = mid2;
            else st = mid1;
    }

    cout << setprecision(9) << fixed;
    cout << eval(st) / 100 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
unsigned f(unsigned long k){
    if(k == 1)
        return 1;
    return (k*f(k-1))%(1000000000+7);
}
int main(){
    long n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<"0";
        return 0;
    }
    int t = max(n,m);
    long nn = n+m - (t-1)*2;
    long nc = f(n),mc;
    if(n== m)
        mc = nc;
    else
        mc = f(m);
    cout<<(mc*nc*nn)%(1000000000+7);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i, M) cin >> B[i];

  vector<vector<int>> A(N, vector<int>(M));
  rep(i, N) {
    rep(j, M) { cin >> A[i][j]; }
  }

  int ans = 0;
  rep(i, N) {
    int temp = 0;
    rep(j, M) { temp += A[i][j] * B[j]; }
    temp += C;
    if (temp > 0) ans++;
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


int main(){
    ll N,K;
    cin >> N >> K;
    ll ans[K+100]={},an=0;
    for(ll i=1; i<=K; i++){
        ll d;
        cin >> d;
        for(ll j=1; j<=d; j++){
            ll A;
            cin >> A;
            ans[A]=1;
        }
    }
    for(ll i=1; i<=N; i++){
        if(ans[i]==0){an++;}
    }
    cout << an << endl;

}


Measured memory_bytes: 3624
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
s=s2(n)
d=defaultdict(int)

for line in s:
    d["".join(sorted(line))]+=1

ans=0
for i in d.values():
    if i>=2:
        ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 25320
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 int n =sc.nextInt();
      
      int[] a = new int[n];
      for(int i=0; i<n; i++){
        a[i] =sc.nextInt();
      }
     
      int total =0;
      for(int i=1; i<n-1; i++){
      if(a[i]>a[i-1] && a[i]<a[i+1]){
        total++;
      }
      else if(a[i]<a[i-1] && a[i]>a[i+1]){
        total++;
      }
      }
        System.out.println(total);
      }
}

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

int main() {
	int i ;
	cin >> i;
	if(i>=400 && i<=599)
	cout << 8 ;
	else if(i>=600 && i<=799)
	cout << 7 ;
	else if(i>=800 && i<=999)
	cout << 6 ;
	else if(i>=1000 && i<=1199)
	cout << 5 ;
	else if(i>=1200 && i<=1399)
	cout << 4 ;
	else if(i>=1400 && i<=1599)
	cout << 3 ;
	else if(i>=1600 && i<=1799)
	cout << 2 ;
	else if(i>=1800 && i<=1999)
	cout << 1 ;
	return 0;
}

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;

    int h[N];
    for(int i = 0; i < N; i++)cin >> h[i];

    sort(h, h+N);

    int ans = 1000000000;
    for(int i = 0; i + K <= N; i++){
        int h_mm = h[i + K - 1] - h[i];
        if(h_mm == 0){
            cout << 0;
            return 0;
        }
        if(h_mm < ans)ans = h_mm;
    }
    cout << ans;

    return 0;
}

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

struct Edge {
    Edge(int64_t t, int64_t A, int64_t B) : to(t), cost_coin(A), cost_time(B) {}
    int64_t to, cost_coin, cost_time;
};

int main() {
    int64_t N, M, S;
    cin >> N >> M >> S;
    vector<int64_t> U(M), V(M), A(M), B(M);
    vector<vector<Edge>> edges(N);
    for (int64_t i = 0; i < M; i++) {
        cin >> U[i] >> V[i] >> A[i] >> B[i];
        U[i]--; V[i]--;
        edges[U[i]].emplace_back(V[i], A[i], B[i]);
        edges[V[i]].emplace_back(U[i], A[i], B[i]);
    }

    vector<int64_t> C(N), D(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> C[i] >> D[i];
    }

    const int64_t MAX_COIN = M * 100;

    constexpr int64_t INF = LLONG_MAX;
    vector<vector<int64_t>> cost(N, vector<int64_t>(MAX_COIN + 1, INF));
    struct Element {
        int64_t node, coin, cost_time;
        bool operator<(const Element& rhs) const {
            return cost_time < rhs.cost_time;
        }
        bool operator>(const Element& rhs) const {
            return cost_time > rhs.cost_time;
        }
    };
    priority_queue<Element, vector<Element>, greater<Element>> pq;

    S = min(S, MAX_COIN);
    for (int64_t i = 0; i <= S; i++) {
        cost[0][i] = 0;
        pq.push({ 0, i, 0 });
    }
    while (!pq.empty()) {
        Element t = pq.top();
//        cout << t.node << " " << t.coin << " " << t.cost_time << endl;
        pq.pop();
        if (t.cost_time > cost[t.node][t.coin]) {
            continue;
        }

        //移動可能なら移動
        for (const Edge& e : edges[t.node]) {
            if (e.cost_coin > t.coin) {
                continue;
            }
            int64_t new_cost_time = t.cost_time + e.cost_time;
            int64_t new_coin = t.coin - e.cost_coin;
            if (new_cost_time < cost[e.to][new_coin]) {
                cost[e.to][new_coin] = new_cost_time;
                pq.push({ e.to, new_coin, new_cost_time });
            }
        }

        //ここで一回交換
        int64_t new_cost_time = t.cost_time + D[t.node];
        int64_t new_coin = min(MAX_COIN, t.coin + C[t.node]);
        if (new_cost_time < cost[t.node][new_coin]) {
            cost[t.node][new_coin] = new_cost_time;
            pq.push({ t.node, new_coin, new_cost_time });
        }
    }

    for (int64_t i = 1; i < N; i++) {
        cout << *min_element(cost[i].begin(), cost[i].end()) << endl;
    }
}

Measured memory_bytes: 13480
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

	int r, c;
	cin >> r >> c;
	int rb[101][101];
	int sumrb[101];

	for (int i = 0; i < c; ++i) {
			sumrb[i] = 0;
	}


	for(int i=0;i<r;++i) {
		int sum = 0;
		for (int j = 0; j < c; ++j) {
			cin >> rb[i][j];
			cout << rb[i][j] << " ";
			sum += rb[i][j];
			sumrb[j] += rb[i][j];
		}
		cout << sum << endl;
	}

	int lsum = 0;

	for (int i = 0; i < c; ++i) {
		cout << sumrb[i] << " ";
		lsum += sumrb[i];
	}
	cout << lsum << endl;
}


Measured memory_bytes: 3140
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=100000000000;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=-100;i<=100;i++){
    ll tmp = 0;
    for(int j=0;j<n;j++){
      ll dis = a[j]-i;
      tmp += dis*dis;
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int[] a = new int[n];
                for(int i = 0 ; i < n ; i++){
                        a[i] = sc.nextInt();
                }
                sc.close();
                Arrays.sort(a);
                int yono = 0;
                for(int i = a[1] ; i > 0 && yono == 0 ; i--){
                        int che = 0;
                        for(int j = 0 ; j < n && che != 2 ; j++){
                                if(a[j] % i != 0) che++;
                        }
                        if(che != 2) yono = i;
                }
                System.out.println(yono);
        }
}

Measured memory_bytes: 59384
def isyymm(s0,s1,s2,s3):
    if s2 == 0:
        if s3 in range(1,10):
            return 1
    elif s2 == 1:
        if s3 in range(3):
            return 1
    else:
        return 0

def ismmyy(s0,s1,s2,s3):
    if s0 == 0:
        if s1 in range(1,10):
            return 1
    elif s0 == 1:
        if s1 in range(3):
            return 1
    else:
        return 0

S = input()
s = [int(i) for i in S]

if isyymm(*s) == 1:
    if ismmyy(*s) == 1:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if ismmyy(*s) == 1:
        print('MMYY')
    else:
        print('NA')


Measured memory_bytes: 3064
#include <iostream>
#include <map>

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

  std::map<std::string, int> table = {
    {"SSS", 0},
    {"SSR", 1},
    {"SRS", 1},
    {"SRR", 2},
    {"RSS", 1},
    {"RSR", 1},
    {"RRS", 2},
    {"RRR", 3},
  };

  std::cout << table[s] << '\n';
}


Measured memory_bytes: 3648
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const ll MOD = 1e9+7;
// https://qiita.com/asksaito/items/76b71602dd956b79dbf7
bool IsPrime(int num)
{
   if (num < 2) return false;
   else if (num == 2) return true;
   else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

   double sqrtNum = sqrt(num);
   for (int i = 3; i <= sqrtNum; i += 2)
   {
       if (num % i == 0)
       {
           // 素数ではない
           return false;
       }
   }

   // 素数である
   return true;
}
int main(){
    ll n;
    std::cin >> n;
    map<ll,ll> sosu;

    for (int i = 2; i <= 1000; i++) {
        if(!IsPrime(i))continue;
        ll how = 1;
        while( n/(ll)pow(i,how)>0 ){
            // std::cout << n/(ll)pow(i,how)<< std::endl;
            sosu[i]+= n/(ll)pow(i,how);
            how++;
        }
    }
    ll result = 1;
    for (auto e : sosu) {
        // std::cout << e.first <<" "<<e.second << std::endl;
        result %= MOD;
        result *= (e.second+1)%MOD;
    }
    std::cout << result%MOD<< std::endl;
    
}

Measured memory_bytes: 256
import sys
a,b,c,d=map(int,input().split())
turn = 1 #1:Takahashi -1:Aoki
while True:
  if turn==1:
    c-=b
    if c <= 0:
      print('Yes')
      sys.exit()
    else:
      turn *= -1
  else:
    a-=d
    if a <= 0:
      print('No')
      sys.exit()
    else:
      turn *= -1


Measured memory_bytes: 9116
n=int(input())
s = [list (input().split()) for i in range(n)]
q=[float(s[i][0]) for i in range(n)]
price=[]
for j in range(n):
  if s[j][1]=='JPY':
    price.append(1)
  elif s[j][1]=='BTC':
    price.append(380000.0)
ans=sum(q[k]*price[k] for k in range(n))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll>x(n);
    REP(i,n)cin >> x[i];
    ll total = 0;
    ll answer = 99999999999999999;
    FOR(i,1,101){
        total = 0;
        REP(j,n){
            total+=((ll)i - x[j])*((ll)i - x[j]);
        }
        //cout << i << "  " << total << endl;
        answer = min(answer,total);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n,a,b;
    cin>>n>>a>>b;

    cout<<min(a*n,b)<<endl;
    
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  char a; cin >> a;
  a++;
  cout << a << endl;
  system("pause");
}

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

int main(){
  int X;
  cin >> X;
  double ans=1;
  for(int i=X;i>0;--i){
    for(int j=1;j<=sqrt(X);++j){
      for(int k=2;k<=10;++k){
        if(pow(j,k)<=X) ans=max(ans,pow(j,k));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
   long long int N,s=0,i;
    scanf("%lld",&N);
    for(i=1;i<=N;i++)
    {
        if((i%3==0)&&(i%5==0))
        {
            continue;
        }
        else if(i%3==0)
        {
            continue;
        }
        else if(i%5==0)
        {
            continue;
        }
        else
        {
            s=s+i;
        }
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 2148
N = int(input())

A = list(map(int, input().split()))  # N+1個の街
B = list(map(int, input().split()))  # N人の勇者

total_monster = sum(A)

if A[0] >= B[0]:  # 最初の街について、モンスターの方が多かったら
    A[0] -= B[0]
    B[0] = 0
else:  # 最初の街について、勇者のキャパの方が大きかったら
    B[0] -= A[0]
    A[0] = 0

for i in range(1, N):
    # i-1番目の勇者の残りのキャパによって処理を変えていく
    if B[i-1] > 0:  # キャパが残っていた場合
        if A[i] >= B[i-1]:
            A[i] -= B[i-1]
            B[i-1] = 0
        else:  # i-1番目の勇者だけで処理できるなら
            B[i-1] -= A[i]
            A[i] = 0

    if B[i-1] == 0:  # i-1番目の勇者のキャパが0の場合
        if A[i] >= B[i]:
            A[i] -= B[i]
            B[i] = 0
        else:
            B[i] -= A[i]
            A[i] = 0

# 最後の街について処理をする
if A[-1] > 0:
    A[-1] -= min(B[-1], A[-1])

tmp = sum(A)

print(total_monster - tmp)


Measured memory_bytes: 19372
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
def run():
    N, *A_ = map(int, read().split())
    dp = [[-INF] * (N+1) for _ in range(N+1)]
    dp_max = [-INF] * (N+1)
    a, b = A_[:2]
    dp[a][b] = dp[b][a] = dp_max[a] = dp_max[b] = 0

    triplets = 0
    chunks = []

    for i in range(N-1):
        x,y,z = A_[3*i+2 : 3*i+5]
        if x == y == z:
            triplets+=1
        else:
            chunks.append((x,y,z))

    for x,y,z in chunks:
        cache = []
        # transition : a = x = y
        if y == z:
            x,y,z = y,z,x
        elif z == x:
            x,y,z = z,x,y

        if x == y:
            for i in range(1, N+1):
                cache.append((z, i, dp[x][i] + 1))

        # trainsition : a = b = x
        cache.append((y, z, dp[x][x] + 1))
        cache.append((z, x, dp[y][y] + 1))
        cache.append((x, y, dp[z][z] + 1))

        # trainsition : only fill next
        MAX = max(dp_max)
        cache.append((x, y, MAX))
        cache.append((y, z, MAX))
        cache.append((z, x, MAX))
        for i in range(1, N+1):
            cache.append((i, x, dp_max[i]))
            cache.append((i, y, dp_max[i]))
            cache.append((i, z, dp_max[i]))

        # Update
        for a, b, value in cache:
            dp[a][b] = dp[b][a] = max(value, dp[a][b])
            dp_max[a] = max(dp_max[a], dp[a][b])
            dp_max[b] = max(dp_max[b], dp[a][b])

    a = A_[-1]
    dp[a][a] += 1
    dp_max[a] = max(dp[a][a], dp_max[a])

    print(max(dp_max) + triplets)
    #print(chunks)


if __name__ == "__main__":
    run()


Measured memory_bytes: 226456
import sys
def qwe(n,x,ans):
    n1 = "BPPPB"
    n2 = "BBPPPBPBPPPBB"
    if n==1:
        for s in n1:
            if s=="P": ans+=1
            x-=1
            if x==0:
                print(ans)
                sys.exit()
    else:
        for s in n2:
            if s=="P": ans+=1
            x-=1
            if x==0:
                print(ans)
                sys.exit()

def main():
    n,x = map(int, input().split())
    if n<=2:
        qwe(n,x,0)
    a = [1]
    b = [1]
    for i in range(n-1):
        a.append(2*a[-1]+3)
        b.append(2*b[-1]+1)
    ans = 0
    if x== 2*a[n-1]+3:
        print(2*b[n-1]+1)
        sys.exit()
    elif x==2*a[n-1]+2:
        print(2*b[n-1]+1)
        sys.exit()
    elif x == a[n-1]+2:
        print(b[n-1]+1)
        sys.exit()
    elif x== a[n-1]+1:
        print(b[n-1])
        sys.exit()
    elif x > a[n-1]+2:
        ans += b[n-1]+1
        x -= a[n-1]+2
        n = n-1
    else:
        x -=1
        n = n-1
    while n>2 or x > 0:
        if x== 2*a[n-1]+3:
            ans += 2*b[n-1]+1
            print(ans)
            sys.exit()
        elif x==2*a[n-1]+2:
            ans += 2*b[n-1]+1
            print(ans)
            sys.exit()
        if x == a[n-1]+2:
            ans += b[n-1]+1
            print(ans)
            sys.exit()
        elif x== a[n-1]+1:
            ans+=b[n-1]
            print(ans)
            sys.exit()
        elif x > a[n-1]+2:
            ans += b[n-1]+1
            x -= a[n-1]+2
            n = n-1
        else:
            x -=1
            n = n-1
    if x==0:
        print(ans)
        sys.exit()
    qwe(n,x,ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
using pii = pair<int,int>;
#define all(a) a.begin(), a.end()

const int MAX_N = 50;
int N;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<vector<int> > G;
map<pii, int> mp;
int used[MAX_N], dist[MAX_N];

vector<int> bfs(int s, int t){
    for(int i = 0; i < N; i++) dist[i] = 1e9;
    for(int i = 0; i < N; i++) used[i] = 0;
    vector<int> res, point;

    queue<int> Q;
    Q.push(s);
    dist[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        used[v] = 1;
        for(auto nv: G[v]){
            if(used[nv] == 0){
                dist[nv] = dist[v] + 1;
                Q.push(nv);
            }
        }
    }

    while(dist[t] != 0){
        for(auto nv: G[t]){
            if(dist[nv] == dist[t] - 1) {
                point.push_back(t);
                t = nv;
            }
        }
    }
    point.push_back(t);
    for(int i = 0; i < (int)point.size() - 1; i++){
        res.push_back(mp[{point[i], point[i+1]}]);
    }
    return res;
}

int main(){
    cin >> N;
    G.resize(N);
    int idx = 0;
    rep(i, 0, N - 1){
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        mp[{a,b}] = idx;
        mp[{b,a}] = idx;
        idx++;
    }
    int M; cin >> M;
    //vector<vector<int> > edges(M);
    vector<int> tmp;
    vector<ll> edges(50);
    rep(i, 0, M){
        int u, v; cin >> u >> v; u--, v--;
        tmp = bfs(u, v);
        for(auto e : tmp) edges[i] |= (1LL << e);
    }
    ll ans = 0;

    ll dp[50];
    dp[0] = 1;
    rep(i, 1, 50) dp[i] = dp[i-1] * 2;

    for(int i = 0; i < (1 << M); i++){
        //int kcnt = 0;
        //vector<int> tmp;
        ll mask = 0;
        rep(j, 0, M){
            if(i >> j & 1) mask |= edges[j];
        }
        int white = __builtin_popcountll(mask);
        ll now = 1ll << (N - 1 - white);
        if(__builtin_popcountll(i) % 2 == 0) ans += now;
        else ans -= now;
    }
    cout << ans << endl;
}


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

int main() {
    int H, N;
    cin >> H >> N;
    int sum = 0;
    for(int i = 0; i < N; i++){
        int a; cin >> a;
        sum += a;
    }
    cout << (sum >= H? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main()
    {

        int H, W, A, B;
        cin >> H >> W >> A >> B;
        int map[H][W] = {0};
        for(int i = 0; i < B; i++){
            for (int j = 0; j < A; j++){
                cout << 1;
            }
            for (int j = A; j < W; j++){
                cout << 0;
            }
            cout << endl;
        }

        for(int i = B; i < H; i++){
            for (int j = 0; j < A; j++){
                cout << 0;
            }
            for (int j = A; j < W; j++){
                cout << 1;
            }
            cout << endl;
        }
        return 0;
    }

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

int main(void){

  int x,ybas,ylim,yvol,us;
  int resx,resy;

  cin >> x >> ybas >> ylim >> yvol >> us;

  resx = us * x;
  resy = ybas;
  if(ylim < us) resy += (us - ylim) * yvol;

  if(resx < resy) cout << resx << endl;
  else cout << resy << endl;

  return 0;
}

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

int main(){
	int D;
	cin >> D;
	if(D == 25){
		cout << "Christmas" << endl;
	}
	else if(D == 24){
		cout << "Christmas Eve " << endl;
	}
	else if(D == 23){
		cout << "Christmas Eve Eve " << endl;
	}
	else{
		cout << "Christmas Eve Eve Eve" << endl;
	}

}


Measured memory_bytes: 256
import math
k = int(input())
a = k*(k+1)//2
for i in range(k):
  for j in range(i):
    b = math.gcd(i+1,j+1)
    a += b*6
    for k in range(j):
      a += math.gcd(b,k+1)*6
print(a)

Measured memory_bytes: 9100
n=int(input())
lst=map(int,input().split())
od=0
fo=0

for a in lst:
    if (a%4)%2==1:
        od+=1
    elif a%4==0:
        fo+=1
if fo>=od:
    print("Yes")
elif 2*fo+1==n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 16832
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    ll N, X;
    ll sum = 0;
    ll ans = 1;
    cin >> N >> X;
    vector<ll> L(N+2,0);
    for(int i = 0; i < N; i++){
        cin >> L[i];
        sum += L[i];
        if(sum > X){
            cout << ans << endl;
            return 0;
        }else{
            ans++;
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N,time=0;
    bool f=true;
    cin >>N;
    vector<pair<int,int>> task;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        task.emplace_back(b,a);
    }
    sort(task.begin(),task.end());
    for(int i=0;i<N;i++){
      	time+=task[i].second;
        if(time>task[i].first){
            f=false;
            break;
        }
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 5232
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	vector<int>a;
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	k = n / 2;
	ans = a[k] - a[k - 1];
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
string n;
cin >> n;
int len=(int)(n.length());
rep(i,len-1){
    if(n[i]==n[i+1]){
        cout << i+1<<" "<<i+2 << endl;
        return 0;
    }
}
rep(i,len-2){
    if(n[i]==n[i+2]){
        cout << i+1<<" "<<i+3 << endl;
        return 0;
    }
}

cout << "-1 -1" << endl;
return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String ans = "";
		for (int i = 0; i < line.length(); i++) {
			char c = line.charAt(i);
			if (Character.isLowerCase(c)) {
				ans += Character.toUpperCase(c);
			} else {
				ans += Character.toLowerCase(c);
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 31348
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	string s;
	cin >> s;
	bool ans = true;
	if (s[0] != 'A') ans = false;

	int ix = -1;
	REPS(i, 2, s.size() - 1) {
		if (s[i] == 'C') {
			ix = i;
			break;
		}
		if (i == s.size() - 2) ans = false;
	}
	if (ix >= 2) {
		REPS(i, 1, s.size()) {
			if (i != ix) {
				if (islower(s[i]) == 0) ans = false;
			}
		}
	}
	if (ans) cout << "AC";
	else cout << "WA";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int isDead = 0;
    for(int i=0; i<N; i++){
      H -= sc.nextInt();
    }
    if(H<=0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 47316
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;

	cin >> n;

	vector<ll> v(n);

	REP(i, n) {
		cin >> v[i];
	}

	vector<ll> used(20, 0);

	ll nowl = 0;
	ll nowr = 0;
	ll ans = 0;
	bool flag;

	while (nowr < n) {
		bitset<20> b(v[nowr]);
		REP(i, 20) {
			if (b[i]) {
				used[i]++;
			}
		}
		flag = false;
		REP(i, 20) {
			if (used[i] > 1) {
				flag = true;
				break;
			}
		}
		if (flag) {
			ans += nowr - nowl;
			bitset<20> bb(v[nowl]);
			REP(i, 20) {
				if (bb[i]) {
					used[i]--;
				}
				if (b[i]) {
					used[i]--;
				}
			}
			nowl++;
			nowr--;
		}
		nowr++;
	}

	ans += (nowr - nowl) * (nowr - nowl + 1) / 2;

	cout << ans << endl;
}

Measured memory_bytes: 1792