akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>


using namespace std;


void addEdge(vector<pair<int,int> >*adjList,int u, int v, int w)
{
    adjList[u].push_back(pair<int, int>(v, w));
    adjList[v].push_back(pair<int, int>(u, w));

}

void printGraph(vector<pair<int, int> >* adjList,int V)
{
    vector<pair<int, int> >::iterator itr;
    int i;
    for (i = 0; i < V; ++i) {
        cout << i << "->";
        for (itr = adjList[i].begin(); itr != adjList[i].end(); ++itr) {
            cout << itr->first << "," << itr->second << " ";
        }
        cout << "\n";
    }
}



int main()
{
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    int max;
    if (a * b > c* d) {
        cout << a * b;
    }
    else {
        cout << c * d;
    }



    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long  n,t[10000],sum;
int main(){
  while(cin>>n&&n){
    for(int i=0;i<n;i++)cin>>t[i];
    sort(t,t+n);
    if(t[n-1]<2){
      cout<<"NA"<<endl;
      continue;
    }
    sum=0;
    
    for(int i=0;i<n;i++){
      if(t[i]==0)continue;
      sum++;
    }
    cout<<sum+1<<endl;
  }
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    int cnt=0;
    for(i=22; i<=b; i++)
    {
        int x=i%10;
        int y=i/10;
        if(x>=2 && y>=2 && x*y<=a)
        {
            cnt++;
            // cout<<i<<" ";
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a= sc.next();
		String b= sc.next();
		int c= sc.nextInt();
		int d= sc.nextInt();
		String e= sc.next();
		if(e.contentEquals(a)) {
			c--;
		}
		else {
			d--;
		}
		System.out.println(c+" "+d);
	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
vector<int>graph[100001];
int dp[100001];
int solve(int src){
	if(dp[src]!=-1){
		return dp[src];
	}
	bool leaf = 1;
	int bestChild = 0;
	for(int child:graph[src]){
		leaf = 0;
		bestChild = max(bestChild,solve(child));
	}
	return dp[src] = leaf ? 0 : 1 + bestChild;
}
int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int n,m;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	while(m--){
		int x,y;
		cin>>x>>y;
		graph[x].push_back(y);
	}
	int ans = 0 ;
	for(int i=1;i<=n;i++){
		ans = max(ans,solve(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11340
A, B = map(int, input().split())
S = input()
haihun = False
number = True

if S[A] == "-":
    haihun = True

if "-" in S[:A]:
    number = False

for i in S[A+1:]:
    if i == "-":
        number = False
        break
    if int(i) < 0 or int(i) > 9:
        number = False
        break
    else:
        continue


if haihun and number:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    FOR(i,1,n){
        if(s[i] != s[i-1]){
            ans++;
        }
    }
    print(ans)
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
const int maxn = 1e5 + 100;
int dp[maxn], h[maxn];
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.txt");
#endif
	int N,K;
	cin >> N>>K;
	for (int i = 1; i <= N; i++)cin >> h[i];
	dp[1] = 0;
	for (int i = 2; i <= N; i++)
	{
		dp[i] = INF;
		int j = i - 1;
		while (j > 0 && i - j <= K)
		{
			dp[i] = min(dp[j] + abs(h[i] - h[j]), dp[i]);
			j--;
		}
	}
	cout << dp[N] << "\n";
}


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

int main(){
  int n,x;

  while(1){
    cin >> n >> x;
    if( n==0 && x==0 ){
      break;
    }

    int count = 0;
    for( int i=1; i<=n; i++ ){
      for( int j=i+1; j<=n; j++ ){
        for( int k=j+1; k<=n; k++ ){
          if( i+j+k == x ){
            count++;
          }
        }
      }
    }

   cout << count << endl;
  }

  return 0;
}


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

int main()
{
  int N, K;
  cin>>N>>K;
  
  int c = 0;
  for ( int i = 1; i <= N; i+=2 )
  {
    c++;
  }
  if ( c >= K )
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

strL = input().rstrip()

maxD = len(strL)

dp = [[0]*(2) for _ in range(maxD+1)]
dp[0][0] = 1
for d, Ld in enumerate(strL):
    Ld = int(Ld)
    for isLT in range(2):
        dp[d][isLT] %= MOD
        for a, b in [(0, 0), (0, 1), (1, 0)]:
            if not isLT and a+b > Ld: continue
            isLT2 = isLT or a+b < Ld
            dp[d+1][isLT2] += dp[d][isLT]

ans = (dp[-1][0] + dp[-1][1]) % MOD
print(ans)


Measured memory_bytes: 54236
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i,cur=0,st=0;
    string s;
    cin>>n;
    cin>>s;
    for (i=0;i<n;i++)
    {
        if (s[i]=='(')
            cur++;
        else
            cur--;
        if (cur<0)
        {
            st++;
            cur=0;
        }
    }
    for (i=0;i<st;i++)
        cout<<'(';
    cout<<s;
    for (i=0;i<cur;i++)
        cout<<')';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n,m;
struct data{
	int c,t;
	friend bool operator < (const data &a,const data &b){
		return a.t<b.t;
	}
}dp[11][N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=y<x?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace G{
	int cnt,fir[N];
	struct edge{
		int to,nx;
	}eg[N<<1];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	void solve(){
		for(int d=10; d; --d){
			for(int i=1; i<=n; ++i){
				for(int j=fir[i]; j; j=eg[j].nx){
					const int y=eg[j].to;
					apx(dp[d-1][y],dp[d][i]);
				}
			}
		}
	}
}

int main(){
#ifdef LOCAL
	freopen("paint.in","r",stdin);
	freopen("paint.out","w",stdout);
#endif
	n=nxi(),m=nxi();
	for(int i=1; i<=m; ++i){
		const int a=nxi(),b=nxi();
		G::add(a,b);
		G::add(b,a);
	}
	for(int q=nxi(),i=1; i<=q; ++i){
		const int x=nxi(),d=nxi(),c=nxi();
		apx(dp[d][x],(data){c,i});
	}
	G::solve();
	for(int i=1; i<=n; ++i){
		data res=(data){0,0};
		for(int j=0; j<=10; ++j){
			apx(res,dp[j][i]);
		}
		printf("%d\n",res.c);
	}
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int L; cin >> L;
  cpp_dec_float_1000 l = L;
  l /= 3;
  auto res = l * l * l;
  cout
    << std::setprecision(20)
    << std::fixed
    << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import sys
import re

n = input()
v = list(map(float, input().split()))
v = sorted(v, reverse=True)

def calc(v):
    if len(v) == 2:
        return sum(v) / 2
    else:
        return calc(v[:-2] + [((v[-2] + v[-1]) / 2)])

print(calc(v))

Measured memory_bytes: 3188
n = gets.to_i
h = {}
n.times do
  s = gets
  h[s.chomp] = 1
end
 
for m in ["S", "H", "C", "D"] do
  for i in 1..13 do
    puts "#{m} #{i}" if !h.has_key?(m+" "+i.to_s)
  end
end


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

using namespace std;


int main()
{
	int n,k; cin >> n >> k;
	set<int> s;
	for(int i = 0; i < k; i++){
		int k; cin >> k;
		for(int j = 0; j < k; j++){
			int x; cin >> x;
			s.insert(x);
		}
	}
	cout << n-s.size();
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    map<ll,pair<ll,ll>>m1;
    for(int i=0;i<m;i++)
    {
        string s;
        int x;
        cin>>x>>s;
        if(s=="AC"&&m1[x].second!=1)
        m1[x].second=1;
        else
            if(s=="WA"&&m1[x].second!=1)
            m1[x].first+=1;
    }
    ll cntac=0,cntp=0;
    for(auto it:m1)
    {
        if(it.second.second==1)
        {
            cntac+=1;
            cntp+=it.second.first;
        }
    }
    cout<<cntac<<" "<<cntp;
}


Measured memory_bytes: 6528
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

#define m(a,b) memset(a,b,sizeof(a));
typedef long long ll;
const int MAXN=1e5+100;

int main(){
	ll l,r;
	while(~scanf("%lld%lld",&l,&r)){
		int ans=0;
		while(l<=r){
			ans++;
			l*=2;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
constexpr lint mod=1000000007;
struct mint{lint value;};
lint inverse(lint a){
    lint m=mod;
    lint u=0,v=1;
    while(a!=0){
        lint t=m/a;
        m-=t*a;std::swap(a,m);
        u-=t*v;std::swap(u,v);
    }
    assert(m==1);
    if(u<0)u+=mod;
    return u;
}
mint operator*(mint x,mint y){return mint{x.value*y.value%mod};}
mint&operator*=(mint&x,mint y){return x=mint{x.value*y.value%mod};}
mint operator/(mint x,mint y){return mint{x.value*inverse(y.value)%mod};}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<std::vector<lint>>g(n);
    for(lint i=0;i<n-1;i++){
        lint u,v;std::cin>>u>>v;u--,v--;
        g.at(u).push_back(v);
        g.at(v).push_back(u);
    }
    std::vector<lint>ord;
    auto dfs=[&](auto&&dfs,lint x,lint p)->void{
        ord.push_back(x);
        auto&&v=g.at(x);
        for(lint y:v)if(p!=y)dfs(dfs,y,x);
        if(x)v.erase(std::find(v.begin(),v.end(),p));
    };
    dfs(dfs,0,0);
    auto rord=std::vector<lint>(ord.rbegin(),ord.rend());
    std::vector<lint>sz(n,1);
    std::vector<mint>fact(n+1);fact.at(0)=mint{1};
    for(lint i=1;i<=n;i++)fact.at(i)=fact.at(i-1)*mint{i};
    std::vector<mint>dp(n),ep(n);ep.at(0)=mint{1};
    for(lint x:rord){
        for(lint y:g.at(x))sz.at(x)+=sz.at(y);
        dp.at(x)=fact.at(sz.at(x)-1);
        for(lint y:g.at(x))dp.at(x)*=dp.at(y)/fact.at(sz.at(y));
    }
    for(lint x:ord){
        for(lint y:g.at(x)){
            ep.at(y)=dp.at(x)*ep.at(x)*fact.at(n-sz.at(y)-1)*fact.at(sz.at(y))
                /(dp.at(y)*fact.at(sz.at(x)-1)*fact.at(n-sz.at(x)));
        }
    }
    for(lint i=0;i<n;i++){
        std::cout<<(dp.at(i)*ep.at(i)*fact.at(n-1)
            /(fact.at(sz.at(i)-1)*fact.at(n-sz.at(i)))).value<<'\n';
    }
}


Measured memory_bytes: 24176
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	double A, B;
	cin >> A >>B;
		//cin >> B ;
	if (A < B) {
		cout << "LESS" << endl;
	}
	else if (A == B) {
		cout << "EQUAL" << endl;
	}
	else if (A > B) {
		cout << "GREATER" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i,j,k=0;
	long long a[200000],s[200001],mod=1000000007,sum=0,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		s[i+1]=s[i]+a[i];
	}
	for(i=0;i<n;i++){
		sum=(s[n]-s[i+1])%mod;
		ans+=a[i]*sum;
		ans%=mod;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, K, A[202020];
int been[202020];

void solve() {
    FOR (N)
        been[i] = -1;
    int now = 0;
    int cnt = 0;
    int left = 0;
    while (true) {
        if (cnt == K) {
            cout << now + 1 << endl;
            return;
        }
        been[now] = cnt;
        cnt++;

        now = A[now];
        if (been[now] != -1) {
            left = (K - cnt) % (cnt - been[now]);
            break;
        }
    }
    while (left--) {
        now = A[now];
    }
    cout << now + 1 << endl;
}

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

    cin >> N >> K;
    FOR (N) {
        cin >> A[i];
        A[i]--;
    }

    solve();
    return 0;
}


Measured memory_bytes: 6792
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
x = sum(A)
min_ = x / (4*M)
flag = 0

for i, a in enumerate(A):
  if a < min_:
    break
  if i+1 == M:
    flag = 1
    break
if flag == 1:
  print("Yes")
else:
  print("No")

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a*b%2 == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

const ll mod = 1e9+7;

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

  ll n;
  cin >> n;
  ll ans = 1;
  for(ll i = 1; i <= n; i++) {
    ans = ans * i % mod;
  }
  cout << ans << endl;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin >> n;
	int ct=(n+1)/2;
	cout << setprecision(10) << fixed << double(ct)/n << "\n";
	return 0;
}


Measured memory_bytes: 256
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)

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

C = [0]*N
for q in range(Q):
    p,x = map(int,input().split())
    C[p-1] += x
visited = [0]*N
def dfs(i):
    visited[i] = 1
    for k in d[i]:
        if visited[k]==1:
            continue
        C[k]+=C[i]
        dfs(k)
dfs(0)
print(*C)


Measured memory_bytes: 232984
n,m = map(int, input().split())
a = set([int(input()) for i in range(m)])
memo = [0]*(n+1)
 
memo[0] = 1
if 1 in a:
    memo[1] = 0
else:
    memo[1] = 1
for i in range(2,n+1):
    if i in a:
        continue
    memo[i] = (memo[i-1] + memo[i-2])%1000000007
    
print(memo[n])

Measured memory_bytes: 13216
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
  	string n;
    cin>>n;
  	for(int i=0;i+1<n.size();i++)
    {
      if(n[i]==n[i+1])
      {
        cout<<"Bad";
        return 0;
      }
    }
    cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  int X;
  cin >> X;
  X -= 400;
  X /= 200;
  print(8-X);
  return 0;
}

Measured memory_bytes: 3616
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int H, W; cin >> H >> W;
    int A[H][W], B[H][W]; REP(i,H)REP(j,W) cin >> A[i][j]; REP(i,H)REP(j,W) cin >> B[i][j];
    int dif[H][W], mx=0; REP(i,H)REP(j,W){dif[i][j] = abs(A[i][j]-B[i][j]); chmax(mx, dif[i][j]);}

    int s = 160*80;
    bitset<2*160*80> dp[H][W];
    dp[0][0][s-dif[0][0]] = 1; dp[0][0][s+dif[0][0]] = 1;
    REP(i,H)REP(j,W){
        if(i){
            dp[i][j] |= dp[i-1][j]<<dif[i][j];
            dp[i][j] |= dp[i-1][j]>>dif[i][j];
        }
        if(j){
            dp[i][j] |= dp[i][j-1]>>dif[i][j];
            dp[i][j] |= dp[i][j-1]<<dif[i][j];
        }
    }
    REP(i,s){
        if(dp[H-1][W-1][s+i] || dp[H-1][W-1][s-i]){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

int main(void) {
    int n, m;

    cin >> n >> m;

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        double tmp = (double)((double) sum / (double) (4 * m));
        if (v[i] >= tmp) {
            cnt++;
        }
    }

    cout << (cnt >= m ? "Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect

n=int(input())
a=[0]+sorted(list(map(int,input().split())))+[10**9]

ans1=a[-2]

index=bisect.bisect_right(a,(ans1)//2)

b1=a[index-1]
b2=a[index]

if abs((ans1)/2-b1)<=abs((ans1)/2-b2):ans2=b1
else:ans2=b2

print(ans1,ans2,sep=" ")

Measured memory_bytes: 14052
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n;
	vector<int> first(n),next(n),cost(n);
	cin >> n;
	for(int i=0; i<n-1; i++){
		cin >> cost[i] >> first[i] >> next[i];
	}
	long long t=0;
	for(int i=0; i<n-1; i++){
		t=0;
		for(int j=i; j<n-1; j++){
			if(t<=first[j])t=first[j]+cost[j];
			else if((t-first[j])%next[j]==0)t+=cost[j];
			else t+=next[j]-(t-first[j])%next[j]+cost[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 640
//last updated : 11.04.2020
#include <bits/stdc++.h>
#pragma GCC optimization ("O3")
using namespace std;

#define ll              long long
#define ld              long double
#define pll             pair <ll, ll>
#define plll            pair <ll, pll>

#define fa(i, n, N)     for (ll i = n; i <= N; ++i)
#define fac(i, n, b, N) for (ll i = n; i <= N && b; ++i)
#define fd(i, n, N)     for (ll i = n; i >= N; --i)

#define mp              make_pair
#define pb              push_back
#define pob             pop_back
#define pf              push_front
#define pof             pop_front
#define fi              first
#define se              second

#define ms(arr,t)       memset (arr, t, sizeof(arr));
#define all(x)          x.begin(), x.end()
#define len             length()
#define endl            '\n'

#define isss(x, s)      istringstream x (s)
#define db(x)           cout << ">>>>>> " << #x << " -> " << x << endl
#define AAAA            cout << "\t------" << endl;

//urgent cases only!
#define get_rt		cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms.\n"

const ll inf = INT_MAX;
const ll inf2 = 1e18;
const ll MAX = 1e5+5;
const ll MOD = 1e9+7;
const double pi = acos(-1.0);
const double EPS = 1e-9;

void init(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

inline void iofile (){
	freopen ("input.txt", "r", stdin);
	// freopen ("output.txt", "w", stdout);
}


ll n;

int main() {
    init(10);
    //iofile();
	
	cin >> n;
	n <<= 1;
	
	cout << (double)(n) * pi << endl;

	return 0;
}


Measured memory_bytes: 3792
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(B) > sum(A):
  print("-1")
  exit()
D = []
for i in range(N):
  D.append(A[i]-B[i])
D.sort()
#print(D)
num = 0
s = 0; t = -1
yoyu = 0
while D[s] < 0:
  if yoyu+D[s] <0:
    num += 1 #ここで一番余裕があるのを取り出す。
    yoyu += D[t]
    t -= 1
  num += 1 #ここで足りない分が足された試験
  yoyu += D[s]
  s += 1
print(num)  

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

int main() {
	int n;
	cin >> n;
	bool even = true;
	bool zero = false;
	int64_t sum = 0;
	int64_t mini = 1000000000;
	for (int i = 0; i < n; i++) {
		int64_t x;
		cin >> x;
		if (x < 0) {
			even = !even;
		}
		else if (x == 0)zero = true;
		else;
		mini = min(abs(x), mini);
		sum += abs(x);
	}
	if (zero == false && even == false)cout << sum - mini -mini<< endl;
	else cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();

		if(N * A <= B) {
			System.out.println(N*A);
		}else {
			System.out.println(B);
		}
	}

}

Measured memory_bytes: 23508
class diverta2019C:
    def __init__(self):
        self.N = int(input())
        self.s = [input() for i in range(self.N)]
        self.ans = 0
    
    def solve(self):
        a, b, c = 0, 0, 0
        for i in range(self.N):
            if(self.s[i].count('AB')):
                self.ans += self.s[i].count('AB')
            if(self.s[i][-1] == 'A' and self.s[i][0] == 'B'):
                a += 1
            elif(self.s[i][0] == 'B'):
                b += 1
            elif(self.s[i][-1] == 'A'):
                c += 1
        if(a == 0):
            self.ans += min(b, c)
        elif(b + c > 0):
            self.ans += a + min(b, c)
        else:
            self.ans += a-1
        print(self.ans)

if __name__ == '__main__':
    problem = diverta2019C()
    problem.solve()


Measured memory_bytes: 3700
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
ans=0
flg=True
for i in range(1,n):
    if a[i]==i and a[i-1]==i-1 and flg:
        if flg:
            ans-=1
            flg=False
        else:
            flg=True
    else:
        flg=True
for i in range(n):
    if a[i]==i:
        ans+=1
print(ans)


Measured memory_bytes: 52844
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Entry<Integer, Integer>> list = new ArrayList<>(n);
		for(int i = 0; i< n; i++) list.add(new SimpleEntry<Integer, Integer>(i, sc.nextInt()));
		Set<Integer> left = new HashSet<>(n/2);
		Collections.sort(list, new Comparator<Entry<Integer, Integer>>(){

			@Override
			public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
				// TODO 自動生成されたメソッド・スタブ
				return o1.getValue() - o2.getValue();
			}

		});
		for(int i = 0; i < list.size(); i++){
			int x = list.get(i).getKey();
			if(list.size() /2 > i) left.add(x);
		}
		int leftHalf = list.get(list.size() / 2 -1).getValue();
		int rightHalf = list.get(list.size()/2).getValue();
		for(int i = 0; i < n ; i++){
			System.out.println(left.contains(i) ? rightHalf : leftHalf);
		}


	}

}

Measured memory_bytes: 110300
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func abs(a, b int) int {
	return int(math.Abs(float64(a) - float64(b)))
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	p := make([]int, n)
	for i := range p {
		p[i] = nextInt()
	}

	count := 0
	min := p[0]
	for _, v := range p {
		if v <= min {
			count++
			min = v
		}
	}
	fmt.Print(count)
}


Measured memory_bytes: 3584
case class Test(index: Int, test: Boolean)

object Main extends App {
  main()

  def main() {
    val n = readLine().toInt
    val as = for {
      i <- Range(0, n)
    } yield {
      val ai = readLine().toInt
      for {
        ii <- Range(0, ai)
      } yield {
        val xy = readLine().split(' ')
        Test(xy(0).toInt - 1, xy(1).toInt > 0)
      }
    }
    val loop = for {
      dec <- Range(0, math.pow(2, n).toInt).reverse
    } yield {
      val bin = dec.toBinaryString.reverse.padTo(n, '0').reverse
      val bs = bin.map(_ == '1')
      if (as.zip(bs).filter(_._2).foldLeft(true)((a, b) => a && b._1.foldLeft(true)((c, d) => c && d.test == bs(d.index)))) bs.filter(_ == true).size
      else 0
    }
    println(loop.max)
  }
}


Measured memory_bytes: 67476
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int main(void){
    // Here your code !
    const int N_MAX=14;
    int n,i,k,j,b,f,r,v,a;
    int num[5][4][11]={{{0}}};
    
    cin>>n;
    for(i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        num[b][f][r]=num[b][f][r]+v;
    }
    
    for(i=1;i<5;i++){
         for(j=1;j<4;j++){
              for(k=1;k<11;k++){
        cout<<" "<<num[i][j][k];
              }
              cout<<endl;
         }
        if(i!=4) cout<<"####################"<<endl;
    }
    return 0;
}

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

typedef long long ll;
using namespace std;
  
int main(){
  ll N,M; cin >> N >> M;
  vector<ll> A(N);
  for(int i = 0;i<N;i++) cin >> A[i];
  ll ans = 0;
  for(int i = 0;i < N;i++) ans += A[i];
  ans = N - ans;
  if(ans>=0) cout << ans;
  else cout << "-1";
  return 0;
}

Measured memory_bytes: 11176
package main

import "fmt"

func main() {
        var size int
        fmt.Scan(&size)
        dic := make(map[int]int)

        for i := 0; i < size; i++ {
                var po int
                fmt.Scan(&po)
                _, ok := dic[po]
                if !ok {
                        dic[po] = 0
                }
                dic[po]++
        }

        ans := 0
        for key, val := range dic {
                if key < val {
                        ans += val - key
                } else if key > val {
                        ans += val
                }
        }
        fmt.Println(ans)
}

Measured memory_bytes: 9088
from collections import deque
import sys

n = int(input())
deq = deque()

for _ in range(n):
    cmd = input()
    if cmd[0] == "i":
        deq.appendleft(cmd[7:])
    elif cmd[6] == "F":
        deq.popleft()
    elif cmd[6] == "L":
        deq.pop()
    else:
        try:
            deq.remove(cmd[7:])
        except:
            pass

print(" ".join(deq))


Measured memory_bytes: 69740
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);

  if(a<b){
    printf("a < b\n");
  } else if(a>b){
    printf("a > b\n");
  } else if(a==b){
    printf("a == b\n");
  }
  return 0;
}


Measured memory_bytes: 2608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            long x = ReadLong();
            long q = (x - 1) / 11;
            long m = (x - 1) % 11;
            long y = (m < 6) ? q * 2 + 1 : q * 2 + 2;
            Console.WriteLine(y);
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
struct st {
	double late;
	vector<int> call;
};
vector<st> mem;
map<int, int> mpii;
vb called;
int cnt;

double heiro(int first, int idx) {
	double ret = mem[idx].late;
	called[idx] = false;
	REP(i, mem[idx].call.size()) {
		if (called[mem[idx].call[i]]) {
			ret *= heiro(first, mem[idx].call[i]);
		}
	}
	return ret;
}


int main() {
	int n;
	while (cin >> n, n) {
		mem.clear();
		mem.resize(n);
		mpii.clear();
		called.resize(n, false);
		REP(i, n) {
			int m;
			cin >> mem[i].late >> m;
			mem[i].call.resize(m);
			REP(j, m) {
				cin >> mem[i].call[j];
				mem[i].call[j]--;
				called[mem[i].call[j]] = true;
			}
			mpii[i] = i;
		}
		double ans = 1.0;
		queue<int> Q;
		REP(i, n)
			if (called[i] == false) {
				ans *= (1.0 - mem[i].late);
				REP(j, mem[i].call.size())
					Q.push(mem[i].call[j]);
			}
		while (!Q.empty()) {
			int q = Q.front();Q.pop();
			called[q] = false;
			REP(i, mem[q].call.size())
				if (called[mem[q].call[i]])
					Q.push(mem[q].call[i]);
		}
		bool henka;
		do {
			henka = false;
			REP(i, n) {
				if (!called[i])
					continue;
				bool pass = true;
				REP(j, mem[i].call.size())
					if (called[mem[i].call[j]])
						pass = false;
				if (pass) {
					called[i] = false;
					henka = true;
				}
			}
		} while (henka);
			REP(i, n) {
				if (called[i])
					ans *= 1.0 - heiro(i, i);
			}
			printf("%0.9lf\n", ans);
		}
	}

Measured memory_bytes: 3224
#include <iostream>
#include <vector>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<998244353>;

const Mint ibase = Mint(10).pow(18).inv();

int main() {
    int n;
    scanf("%d", &n);
    VV<Mint> sum(3);
    for (int ph = 0; ph < 3; ph++) {
        VV<int> g(n);
        int m;
        scanf("%d", &m);
        for (int i = 0; i < m; i++) {
            int a, b;
            scanf("%d %d", &a, &b); a--; b--;
            if (a > b) swap(a, b);
            g[a].push_back(b);
        }
        Mint now = Mint(10).pow(18 * n);
        V<int> grundy(n), used(n, -1);
        for (int i = n - 1; i >= 0; i--) {            
            for (int j: g[i]) {
                used[grundy[j]] = i;
            }
            while (used[grundy[i]] == i) grundy[i]++;
            while (int(sum[ph].size()) <= grundy[i]) sum[ph].push_back(Mint(0));
            sum[ph][grundy[i]] += now;
            now *= ibase;
        }
    }
    Mint answer = 0;
    for (int i = 0; i < int(sum[0].size()); i++) {
        for (int j = 0; j < int(sum[1].size()); j++) {
            int k = i ^ j;
            if (k < int(sum[2].size())) {
                answer += sum[0][i] * sum[1][j] * sum[2][k];
            }
        }
    }
    printf("%d\n", answer.v);
    return 0;
}


Measured memory_bytes: 5192
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){
		x=_x; y=_y;
	}
};

struct Line{
	double x[2],y[2];
	Line(){}
	Line(Point p,Point q){
		x[0]=p.x; x[1]=q.x;
		y[0]=p.y; y[1]=q.y;
	}
};

void RevXY(Point &p){
	swap(p.x,p.y);
}

void RevXY(Line &l){
	for(int i=0;i<2;i++) swap(l.x[i],l.y[i]);
}

bool Is_SameSide(Line l,Point p,Point q){
	//printf("%lf,%lf - %lf,%lf\np(%lf,%lf),q(%lf,%lf)\n",l.x[0],l.y[0],l.x[1],l.y[1],p.x,p.y,q.x,q.y);
	if(l.x[1]==l.x[0]){
		RevXY(l); RevXY(p); RevXY(q);
	}
	double a,b;
	a = (l.y[1]-l.y[0])/(l.x[1]-l.x[0]);
	b = l.y[0]-a*l.x[0];
	//printf("%lf,%lf - %lf,%lf : y = %lfx+(%lf)\np(%lf,%lf),q(%lf,%lf)\n",l.x[0],l.y[0],l.x[1],l.y[1],a,b,p.x,p.y,q.x,q.y);
	if((p.y-(a*p.x+b))*(q.y-(a*q.x+b))>0) return true;
	else return false;
}

int main(){
	Point S[4];
	while(scanf("%lf,%lf",&S[0].x,&S[0].y)!=EOF){
		Point sum = Point(S[0].x,S[0].y);
		for(int i=1;i<4;i++){
			scanf(",%lf,%lf",&S[i].x,&S[i].y);
			sum.x += S[i].x; sum.y += S[i].y;
		}
		bool ans=true;
		for(int i=0;i<4;i++){
			if(Is_SameSide(Line(S[i],S[(i+2)%4]),S[(i+1)%4],Point((sum.x-S[(i+1)%4].x)/3,(sum.y-S[(i+1)%4].y)/3))==true){
				ans = false;
			}
		}
		if(ans) puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int x = scanner.nextInt();
		int[] a = new int[n];

		long count = 0;
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
			if (i != 0 && a[i - 1] + a[i] > x) {
				int tmp = a[i - 1] + a[i] - x;
				count += tmp;
				if (a[i] - tmp >= 0) {
					a[i] -= tmp;
				} else {
					a[i] = 0;
					tmp -= a[i];
					a[i - 1] -= tmp;
				}
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 51212
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mod 1000000007
long long exgcd(long long a, long long b, long long &x, long long &y) 
{
    if (b == 0) 
	{
        x = 1;
        y = 0;
        return a;   
    }
    long long d = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
long long inv(long long	 a, long long  MOD) 
{
    long long x, y;
    exgcd(a, MOD, x, y);
    x = (x % MOD + MOD) % MOD;
    return x;
}
long long fac[200010];
long long  lucas(long long n, long long  m) 
{
    long long ret = 1, a, b;
    while (n && m) 
	{
        a = n % mod, b = m % mod;
        if (a < b) return 0;
        ret = ret * fac[a] % mod * inv(fac[b] * fac[a - b] % mod, mod) % mod;
        n /= mod, m /= mod;
    }
    return ret;
}
int main()
{
    long long  x, y, n, m;
    scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
    long long ans = 0;
    fac[0] = 1;
    for (int i = 1; i <= 200005; i++) 
		fac[i] = fac[i - 1] * i % mod;
    long long z = y, p = n + m - 2;
    for (long long i = 0; i <= n - x - 1; i++) 
	{
        ans = ans + lucas(z + i - 1, i) * lucas(p - z - i, n - 1 - i) % mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a;
    cin >> a;
    if (a == 22) cout << "Christmas Eve Eve Eve" << endl;
    else if (a == 23) cout << "Christmas Eve Eve" << endl;
    else if (a == 24) cout << "Christmas Eve" << endl;
    else cout << "Christmas" << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = Array.new(n.to_s(2).size){0}
a.each do |i|
  n.to_s(2).size.times do |j|
    b[j] += i[j]
  end
end
f = true
n.to_s(2).size.pred.times do |i|
  f = false if b[i].odd?
end
puts f ? 'Yes' : 'No'

Measured memory_bytes: 11012
#include <iostream>
#include <cassert>
#include <vector>


using Edge = std::pair<int, int>;
using Graph = std::vector<std::vector<Edge>>;

int N;
Graph G;
std::vector<int> res;

void dfs(const int v, const int p) {
  for (auto e : G[v]) {
    if (e.first == p)
      continue;
    res[e.first] = (e.second % 2 == 0) ? res[v] : 1 - res[v];
    dfs(e.first, v);
  }
}

int main()
{
  // Input
  std::cin >> N;
  G.resize(N);
  for (int i = 0; i < N - 1; ++i) {
    int u, v, w;
    std::cin >> u >> v >> w;
    G[u - 1].push_back({v - 1, w});
    G[v - 1].push_back({u - 1, w});
  }

  // Main
  res.assign(N, -1);
  res[0] = 0;
  dfs(0, -1);

  // Output
  for (auto v : res)
    std::cout << v << std::endl;

  return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
int main() {
     int a,b,k; cin >> a >> b >> k;

     for(int i = min(a,b) ; i > 0 ; i--){
          if(a % i == 0 && b % i == 0){
               k--;
               if(k == 0){
                    cout << i << endl;
                    break;
               }
          }
     }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

const int INF = 1e9 + 7;



int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<pii> x(n);
	vector<int> ans(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i].first;
		x[i].second = i;
	}

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

	for (int i = 0; i < n; i++) {
		//cout << x[i].first << " " << x[i].second << endl;
		if (i < n/2) {
			ans[x[i].second] = x[n / 2].first;
		}
		else {
			ans[x[i].second] = x[n / 2 - 1].first;
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		cout << ans[i] << endl;
	}
	return 0;
}


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int a, b, c;
  cin >> a >> b >> c;

  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256