akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int e() { return -1; }
int ma(int x, int y) { return max(x, y); }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n, q;
  cin >> n >> q;
  vi a(n);
  rep(i, n){
    cin >> a[i];
  }
  segtree<int, ma, e> seg(a);
  while(q--){
    int t, x, y;
    cin >> t >> x >> y;
    if(t == 1){
      seg.set(x-1, y);
    }
    if(t == 2){
      print(seg.prod(x-1, y));
    }
    if(t == 3){
      print(seg.max_right(x-1, [&y](int v){return v < y;}) + 1);
    }
  }
}


Measured memory_bytes: 6116
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		int all = scan.nextInt();
		for (int i = 0; i < all; i++) {
			int m = scan.nextInt();
			int n = scan.nextInt();
			int sum = m * m + n * n;

			refact: for (int x = 2; x * x <= sum; x++) {
				// m^2*n^2の約数を探す
				if (sum % x == 0) {
					int y = sum / x;
					for (int j = 0; j * j <= x; j++) {
						double diff = Math.sqrt(x - j * j);
						int tmp = (int) diff;
						if (diff == tmp) {
							System.out.println("C");
							break refact;
						}
					}
					for (int j = 0; j * j <= y; j++) {
						double diff = Math.sqrt(y - j * j);
						int tmp = (int) diff;
						if (diff == tmp) {
							System.out.println("C");
							break refact;
						}
					}
				}
				if ((x + 1) * (x + 1) > sum) {
					System.out.println("P");
				}
			}

		}
		scan.close();

	}
}

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

#define int long long int
const int N=1e5+4;
int A[N],B[N];

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>A[i];
		B[i] = INT_MAX;
	}
	B[0] = 0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j < 0)
				break;
			if(B[i] > B[i-j]+abs(A[i]-A[i-j]))
				B[i] = B[i-j]+abs(A[i]-A[i-j]);
		}
	}
	cout<<B[n-1];

	return 0;
}

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

int main(){
string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
 
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{

    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int mod = n % 10;
            if (mod == 3)
            {
                Console.WriteLine("bon");
            }
            else if (mod == 0 || mod == 1 || mod == 6 || mod == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

        }

    }
}



Measured memory_bytes: 27472
L,R=map(int,input().split())
c=2019
z=0
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a=i*j
        b=a%2019
        if c>b:
            c=b
        if c==0:
            z=1
            break
    if z==1:
        break
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e9+7;
const int N = 1e5+5;

ll f[N],sum[N];
int a[N];

inline ll qpow(ll a,ll b){
	ll res = 1;
	while(b){
		if(b & 1) res = (res*a)%M;
		a = (a*a)%M;
		b >>= 1;
	}
	return res%M;
}
inline ll inv(ll a){return qpow(a,M-2);}

void table(int n,int k){
	if(k == 0) for(int i = 0;i <= n;++i) f[i] = 1;
	else{
		for(int i = 0;i <= k;++i) f[i] = 1;
		for(int i = k+1;i <= n;++i) f[i] = ((f[i-1]*i)%M)*inv(i-k)%M;
	}
	return ;
}

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    table(n,k-2);
    
	for(int i = 1;i <= n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	
	sum[0] = 0;
	for(int i = 1;i <= n;++i) sum[i] = sum[i-1]+a[i];
	
	if(k == 1){printf("0\n");return 0;}
	else if(k == n){printf("%d\n",a[n]-a[1]);return 0;}
	else{
		ll ans = 0;
		for(int i = k-2;i <= n-2;++i){
			ll t1 = (sum[n]-sum[i+1])%M;
			ll t2 = (sum[n-i-1])%M;
			ans = (((t1-t2)%M*f[i]%M)+ans)%M;
		}
		printf("%lld\n",(ans+M)%M);
	}
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define ROF(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

vector<int> blank;
void solve(){
    int n, k;
    scanf("%d %d",&n,&k);
    vector<int> P(n+1), C(n+1);
    FOR(i, 1, n) scanf("%d",&P[i]);
    FOR(i, 1, n) scanf("%d",&C[i]);
    vector<int> ring(n+1), sz(n+1);
    vector<LL> sum(n+1);
    int cnt = 0;
    FOR(i, 1, n){
        if(ring[i]) continue;
        LL s = C[i];
        ring[i] = ++cnt;
        sz[cnt] = 1;
        int nw = P[i];
        while(nw != i) ++sz[cnt], s += C[nw], ring[nw] = cnt, nw = P[nw];
        sum[cnt] = s;
    }
    // try all possible
    LL ans = -1e9;
    FOR(i, 1, n){
        int s = sz[ring[i]];
        int nw = i;
        LL S = 0;
        FOR(j, 1, min(s, k)){
            nw = P[nw];
            assert(ring[nw] == ring[i]);
            S += C[nw];
            ans = max(ans, S);
            if(sum[ring[nw]] > 0) ans = max(ans, S+sum[ring[nw]]*((k-j)/s));
        }
    }
    printf("%lld",ans);
}

int main(){
    solve();
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

Measured memory_bytes: 3876
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
mod(x::Int,p::Int)=x%p>0?x%p:x%p+p

function main()
	p = 92709568269121
	n = readline() |> parseInt
	t = readline() |> chomp
	s = zeros(Int,n)
	for i in 1:n
		s[i] = Int(t[i])
	end
	b = 101
	c = zeros(Int,n>>1+1)
	c[1] = 1
	for i in 1:n>>1
		c[i+1] = c[i]*b%p
	end
	ll = 0
	rr = n>>1+1
	while rr-ll>1
		i = (ll+rr)>>1
		f = 0
		set = Set{Int}([])
		arch = Int[0 for i in 1:n-i+1]
		l = 0
		for j in 1:i
			l = mod(l+s[j]*c[i-j+1],p)
		end
		arch[1] = l
		for j in 2:n-i+1
			l = mod(mod(mod(l-s[j-1]*c[i],p)*b,p)+s[j+i-1],p)
			arch[j] = l
			if j>i
				push!(set,arch[j-i])
			end
			if l in set
				f = 1
				break
			end
		end
		if f == 1
			ll = i
		else
			rr = i
		end
	end
	println(ll)
end

main()

Measured memory_bytes: 115720
N = int(input())
A = [int(input()) for _ in range(2**N)]

while len(A) > 1:
  B = []
  i = 0
  while i+1 < len(A):
    if A[i] == A[i+1]:
      B.append(A[i])
    else:
      B.append(abs(A[i] - A[i+1]))      
    i += 2
  A = B
print(A[0])

Measured memory_bytes: 24752
/*
*  Author: windystreet
*  Date  : 2019-04-13 20:02:03
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 100+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

string s;
string a;
void solve(){
	int n;
	while(cin>>s){
		//cin>>s;
		a = s;
		n = s.length();
		int cnt = 0;
		int ans = mod;
		for(int i=1;i<n;i++){
			if(s[i] == s[i-1]){
				if(s[i-1] == '0') s[i] = '1';
				else s[i] = '0';
				++cnt;
			}
		}
		ans = min(ans,cnt);
		cnt = 0;
		s = a;
		for(int i=n-2;i>=0;i--){
			if(s[i] == s[i+1]){
				if(s[i+1] == '0') s[i] = '1';
				else s[i] = '0';
				++cnt;
			}
		}
		ans = min(ans,cnt);
		printf("%d\n",ans );
	}


    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

Measured memory_bytes: 512
def resolve():
    X = list(map(int, input().split()))
    X.sort()
    
    ans = X[-1] - X[1]
    if (X[-1]-X[0]-ans) % 2 == 0:
        ans += (X[-1] - X[0]-ans) / 2
    else:
        ans += 1
        ans += (X[-1] - X[0]-ans) / 2  + 1
    print(int(ans))

    return

resolve()

Measured memory_bytes: 9144
import java.util.*;

public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = 0;
    int ans = 0;
    
    if(N<4){
        ans = 1;
    }else{
    for(int i=2; i<=N; i++){
        M = 0;
        for(int j=2; M<=N; j++){
                        if(ans < M){
                ans = M;
            }
            M = (int)Math.pow(i,j);

        }
    }  
    }
    System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	string s;
	cin>>s;
	ll l=s.size();
	ll sum=0;
	for(int i=0;i<l;i++)
	{
		sum+=int(s[i])-48;
	}
	//cout<<sum<<endl;
	if(sum%9==0)
	{
		cout<<"Yes";
	}
	else
	cout<<"No";
}

Measured memory_bytes: 3696
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int main(){
	long long a,b;scanf("%lld%lld",&a,&b);
	int ret=0;
	while(a<=b){
		ret++;
		a*=2;
	}
	printf("%d\n",ret);
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;

	int sum = 0;
	bool find = false;
	vector<int> ps;
	for (int i = 1; !find && i < N+1; ++i) {
		if (sum+i >= N) {
			sum += i;
			ps.push_back(i);
			find = true;
		}
		else {
			sum += i;
			ps.push_back(i);
		}
	}

	int ns = sum - N;
	for (size_t i = 0; i < ps.size(); ++i) {
		if (ns != ps[i]) {
			cout << ps[i] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2,s3;
  int a,b;
  cin>>s1>>s2;
  cin>>a>>b;
  cin>>s3;
  if(s1.compare(s3)==0)
    cout<<(a-1)<<" "<<b<<endl;
  else if(s2.compare(s3)==0)
    cout<<a<<" "<<(b-1)<<endl;
  }

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  deque<int> a;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (i % 2 == 0) {
      a.push_back(x);
    } else {
      a.push_front(x);
    }
  }
  if (n % 2 == 1) reverse(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    printf("%d%c", a[i], " \n"[i + 1 == n]);
  }
  return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>
#include<string>
using namespace std;

int main() {
  char s[3];
  scanf("%s", s);
  int a = 0;
  int b = 0;
  int c = 0;
  for (int i=0 ; i<3 ; i++) {
    if (s[i] == 'a') {
      a++;
    } else if (s[i] == 'b') {
      b++;
    } else if (s[i] == 'c') {
      c++;
    }
  }
  if (a == 1 && b == 1 && c == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 888
#!/usr/bin
# -*- coding:"utf-8" -*-

a, b, c = map(int, input().split())
if a <= b:
  if c <= b:
    x  = a + c
  else:
    x = a + b
else:
  if c <= a:
    x = b + c
  else:
    x = b + a
print(x)

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline bool can_create_triangle(const int a, const int b, const int c) {
    return a < b + c && b < c + a && c < a + b;
}

#define MAX_L 1000

int cnt[MAX_L + 1] = { 0 };

inline ll combi3(const int n) {
    return ((ll)n) * (n - 1) * (n - 2) / 6;
}

inline ll combi2(const int n) {
    return ((ll)n) * (n - 1) / 2;
}

int main() {
    int n;
    cin >> n;
    vi l;
    set<int> st;
    REP(i, n) {
        int a;
        cin >> a;
        if(st.count(a) == 0) l.push_back(a);
        cnt[a]++;
        st.insert(a);
    }
    SORTALL(l);
    ll ans = 0;
    REP(i, l.size()) {
        FOR(j, i + 1, l.size()) {
            for(int k = j + 1; l[k] < l[i] + l[j] && k < l.size(); k++) {
                ans += ((ll)cnt[l[k]]) * cnt[l[i]] * cnt[l[j]];
            }
        }
    }
    // DBG(ans);
    REP(i, l.size()) {
        if(cnt[l[i]] >= 2) {
            for(int j = 0; l[j] < 2 * l[i] && j < l.size(); j++) {
                if(i == j) continue;
                // DBG(l[i]);
                // DBG(l[j]);
                ans += combi2(cnt[l[i]]) * cnt[l[j]];
                // DBG(ans);
            }
        }
    }
    // DBG(ans);
    REP(i, l.size()) {
        if(cnt[l[i]] >= 3) ans += combi3(cnt[l[i]]);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
vector<int> adj[100005];
int color[100005],f[100005],v[100010],d[100010],c[100010],n,m,q,a,b,mxd[100010];
void dfs(int node,int D,int C){
	if (mxd[node]>=D) return ;
	if (color[node]==0) color[node]=C;
	if (d==0) return ;
	mxd[node]=D;
	for (int i=0;i<adj[node].size();i++) dfs(adj[node][i],D-1,C);
}
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cin>>q;
	for (int i=0;i<q;i++) cin>>v[i]>>d[i]>>c[i];
	memset(mxd,-1,sizeof(mxd));
	for (int i=q-1;i>=0;i--) dfs(v[i],d[i],c[i]);
	for (int i=1;i<=n;i++) cout<<color[i]<<endl;
	return 0;
}

Measured memory_bytes: 8440
N=gets.to_i
$x,$y=N.times.map{gets.split.map(&:to_i)}.transpose
def dist(x,y)
    res=0.0
    N.times do |i|
        d=((x-$x[i])**2+(y-$y[i])**2)**(1/2.0)
        res=res<d ? d : res
    end
    return res
end

ylrec=0.0
lx=0.0
rx=1000.0
80.times do |i|
    cl=(lx*2+rx)/3
    cr=(lx+rx*2)/3
    ly1=0.0
    ry1=1000.0
    80.times do |j|
        ccl=(ly1*2+ry1)/3
        ccr=(ly1+ry1*2)/3
        if dist(cl,ccl)>dist(cl,ccr)
            ly1=ccl
        else
            ry1=ccr
        end
    end
    ylrec=ly1
    ly1=0.0
    ry1=1000.0
    80.times do |j|
        ccl=(ly1*2+ry1)/3
        ccr=(ly1+ry1*2)/3
        if dist(cr,ccl)>dist(cr,ccr)
            ly1=ccl
        else
            ry1=ccr
        end
    end
    yrrec=ly1
    if dist(cl,ylrec)<dist(cr,yrrec)
        rx=cr
    else
        lx=cl
    end
end
puts dist(lx,ylrec)


Measured memory_bytes: 1916
#include <iostream>

int main() {
  int a, b;
  int num, sum;
  while (std::cin >> a >> b) {
    num = 1;
    sum = a + b;
    while ((sum /=10) != 0)
      num += 1;
    std::cout << num << std::endl;

  }
  return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define N 500005
#define M 500005
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int n,m,first[N],cnt=0,d[N];
bool vis[N];
struct edge{int v,next,c;}e[M<<1];
inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;}
struct heap{int u,v;};
inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;}
priority_queue<heap>q;
set<int>col[N*10];
inline void dijkstra(){
	for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false;
	q.push((heap){1,d[1]});
	while(!q.empty()){
		heap x=q.top();
		q.pop();
		if(vis[x.u])continue;
		vis[x.u]=1;
		for(int i=first[x.u];i;i=e[i].next){
			int v=e[i].v,w=col[x.u].count(e[i].c)?0:1;
			if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c);
			else if(d[v]==d[x.u]+w)col[v].insert(e[i].c);
		}
	}
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;++i){
		int u=read(),v=read(),c=read();
		add(u,v,c),add(v,u,c);
	}
	dijkstra();
	printf("%d",d[n]==0x3f3f3f3f?-1:d[n]);
	return 0;
}

Measured memory_bytes: 249976
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v)/len(u)/len(v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        len (a,b) = sqrt(a^2+b^2)
        eps=1e-7

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N+10];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      int n,w;
      cin>>n>>w;
      int val[n];
      int wt[n];
      rep(i,0,n)
      {
          cin>>wt[i]>>val[i];
      }
      dp[0] = 0;
      rep(i,0,n)
      {
          bep(j,w,1)
          {
             if(wt[i]<=j)
             {
                 dp[j] = max(dp[j],dp[j-wt[i]]+val[i]);

             }
          }
      }
      cout<<dp[w]<<el;



    }
    return 0;
}


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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
ll a[200010], b[200010];

/*==================================================*/
/*function*/

//最終的なxorにおいて, 下からd桁目が 1 かどうか判定
bool check(int d){
    ll t = (1 << d);

    //下d桁目までのみが必要
    ll aa[200010], bb[200010];
    REP(i,0,N){
        aa[i]  = a[i] % (2*t);
        bb[i]  = b[i] % (2*t);
    }

    //繰り上がりの条件分岐のために分類
    vector<ll> sb[2];
    REP(i,0,N){
        if(bb[i] & t) sb[1].push_back(bb[i] - t);
        else sb[0].push_back(bb[i]);
    }

    sort(sb[0].begin(), sb[0].end());
    sort(sb[1].begin(), sb[1].end());

    ll cnt = 0;

    REP(i,0,N){
        ll ta = aa[i];

        //a'=a[i]%2^(d+1),b'=b[i]%2^(d+1)

        //a',b'それぞれ(2^d)引いてのしきい値t(2^d)との大小比較
        //=> d桁目のビットの1/0をチェック (d桁目について, 繰り上がって1になるか or もとの1が残るか)

        if(ta & t){
            ta -= t;
            //(d-1)桁目からの繰り上がりがなくa'のd桁目の1が残る (逆に繰り上がりがあるとd桁目が0になる)
            //((a'-(2^d))+(b'-(2^d))) < (2^d)
            cnt += lower_bound(sb[0].begin(), sb[0].end(), t - ta) - sb[0].begin(); //しきい値を超えない値(=未満)が欲しいのでこのまま

            //a'とb'の各d桁目の1で繰り上がるため,(d-1)桁目からの繰り上がりが必要
            //((a'-(2^d))+(b'-(2^d))) >= (2^d)
            cnt +=  sb[1].size()
                    - (lower_bound(sb[1].begin(), sb[1].end(), t - ta) - sb[1].begin()); //しきい値以上がほしいので"未満"のサイズとの差分
        }else{
            //a'とb'のどちらのd桁目にも0がないため,(d-1)桁目からの繰り上がりが必要
            //((a'-(2^d))+(b'-(2^d))) >= (2^d)
            cnt += sb[0].size()
                   -  (lower_bound(sb[0].begin(), sb[0].end(), t - ta) - sb[0].begin());

            //(d-1)桁目からの繰り上がりがなくb'のd桁目の1が残る (逆に繰り上がりがあるとd桁目が0になる)
            //((a'-(2^d))+(b'-(2^d))) < (2^d)
            cnt += lower_bound(sb[1].begin(), sb[1].end(), t - ta) - sb[1].begin();
        }
    }

    return cnt % 2 == 1;
}

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N) cin>>a[i];
    REP(i,0,N) cin>>b[i];

    ll ans = 0;
    REP(d,0,29){
        if(check(d)) ans += (1 << d);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 11088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N;
	cin >> N;

	int a[N];
	rep(i,N) cin >> a[i];

	int k = 0;
	rep(i,N) k = max(k,a[i]);

	int cnts[k+1] = {};
	rep(i,N) cnts[a[i]]++;

	bool hasLongestPath = true;
	if(k%2 == 0){
		if(cnts[k/2] == 0) hasLongestPath = false;
		FOR(i,k/2+1,k+1){
			if(cnts[i] <= 1) hasLongestPath = false;
		}
	}else{
		FOR(i,k/2+1,k+1){
			if(cnts[i] <= 1) hasLongestPath = false;
		}
	}

	if(!hasLongestPath){
		cout << "Impossible" << endl;
		return 0;
	}

	if(k%2 == 0){
		cnts[k/2]--;
		FOR(i,k/2+1,k+1) cnts[i] -= 2;
	}else{
		FOR(i,k/2+1,k+1) cnts[i] -= 2;
	}

	bool tooClose = false;
	if(k%2 == 0){
		FOR(i,1,k/2+1){
			if(cnts[i] > 0) tooClose = true;
		}
	}else{
		FOR(i,1,k/2+2){
			if(cnts[i] > 0) tooClose = true;
		}
	}

	if(tooClose){
		cout << "Impossible" << endl;
		return 0;
	}else{
		cout << "Possible" << endl;
		return 0;
	}
}

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

using ll = long long;

int main() {
    int A, B, C, X, Y, ans = 1e9;
    cin >> A >> B >> C >> X >> Y;
    rep(i, max(X, Y) + 1) {
        ans = min(ans, 2 * i * C + max(0, X - i) * A + max(0, Y - i) * B);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    map<char,int>mp;
    rep(i,s.size())if(mp[s[i]]++)return puts("no")*0;
    cout<<"yes"<<endl;
}



Measured memory_bytes: 256
N,K,Q=map(int,input().split())
A=[0 for _ in range(N)]
for _ in range(Q):
    a=int(input())-1
    A[a]+=1
for i in range(N):
    A[i]+=K-Q
    if A[i]<=0:
        print("No")
    else:
        print("Yes")

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s;cin>>s;
    string t="";
    int n=s.size();
    rep(i,n){
        int m=t.size();
        if(s[i]!='B'){
            t.PB(s[i]);
        }
        else{
            if(m>0){
            t.erase(m-1,1);}
        }
    }
    cout<<t<<endl;
}

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

using namespace std;

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

  int n, m, k, a;
  cin >> n >> m;

  map<int, int> vote;
  for (int i = 0; i < n; ++i) {
    cin >> k;
    while (k--) {
      cin >> a;
      vote[a]++;
    }
  }
  int res = 0;
  for (auto &p : vote) {
    if (p.second == n) ++res; 
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

int main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  rep(l, k+1) {
    rep(r, k-l+1) {
      if(l+r > n) continue;
      int d = k - l - r;
      int now = 0;
      vector<int> s;
      rep(i, l) {
        now += v[i];
        s.push_back(v[i]);
      }
      for(int i = n-r; i < n; i++) {
        now += v[i];
        s.push_back(v[i]);
      }
      sort(s.begin(), s.end());
      rep(i, d) {
        if(i >= s.size()) break;
        if(s[i] > 0) break;
        now -= s[i];
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::cmp;

#[allow(dead_code)]
fn getline() -> Vec<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok().unwrap();
    s.split(' ').map(|x| x.trim().to_string()).collect::<Vec<String>>()
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>(s: &String) -> T {
    s.parse().ok().unwrap()
}

fn main() {
    let ss = getline();
    for s in &ss {
        print!("{}", s.chars().collect::<Vec<char>>()
               .first().unwrap().to_uppercase().next().unwrap());
    }
    println!("");
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
using namespace std;
int main () {
long long n,m;
cin>>n>>m;
cout<< ((m & (m % 2 ? 0 : ~0) | ( ((m & 2)>>1) ^ (m & 1) ))^((n-1) & ((n-1) % 2 ? 0 : ~0) | ( (((n-1) & 2)>>1) ^ ((n-1) & 1) )));
return 0;
}


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

int main(){int N, A, B;
cin >> N >> A >> B;
int sum = 0;
for(int i = 1; i <= N; i++){
    int digsum = 0;
    for(int k = 0; k <= 4; k++){
      int tmp = i / pow(10, k);
        digsum += tmp % 10;
    }
    if(digsum >= A && digsum <= B) sum += i;
}

cout << sum << endl;
  return 0;
}

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

int main(){
    while(1){
        int h,w ;
        cin >> h >> w ;
        if(h==w&&h==0) break ;
        vector<vector<char>> chart(h,vector<char>(w,'#')) ;
        for(int i=1;i<h-1;i++){
            for(int j=1;j<w-1;j++){
                chart.at(i).at(j) = '.' ;
            }
        }
        for(auto i:chart){
            for(auto j:i) cout << j ;
            cout << endl ;
        }
        cout << endl ;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
 ll n,m;
 cin>>n>>m;
 Fr(i,m){
     if(i%2==1){
         cout<<(1-i/2+n-1)%n+1<<" "<<2+i/2<<"\n";
     }
     else{
         cout<<n/2+2-i/2<<" "<<n/2+2+i/2<<"\n";
     }
 }
}

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

typedef long long ll;

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = max(max((ll)a * c, (ll)a * d), max((ll)b * c, (ll)b * d));
	cout << ans << '\n';
	return 0;
}


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

typedef long long ll;

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

    int cnt = 0;
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    for(int i=0;i<16;i++){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

namespace Volume0023
{
    class Program
    {
        static void Main(string[] args)
        {
            int dataSets = int.Parse(Console.ReadLine());
            for (int i = 0; i < dataSets; ++i)
            {
                double[] circleInfo = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                double[] circleA = new double[3] { circleInfo[0], circleInfo[1], circleInfo[2] };
                double[] circleB = new double[3] { circleInfo[3], circleInfo[4], circleInfo[5] };
                double radiusA = circleA[2];
                double radiusB = circleB[2];
                if (radiusA > radiusB)
                {
                    Console.WriteLine(Circle.JudgeOverlaping(circleA, circleB));
                }
                else if (Circle.JudgeOverlaping(circleB, circleA) == 2)
                {
                    Console.WriteLine(-2);
                }
                else
                {
                    Console.WriteLine(Circle.JudgeOverlaping(circleB, circleA));
                }
            }
        }
    }
    class Circle
    {
        internal static int JudgeOverlaping(double[] circleA, double[] circleB)
        {
            double xA = circleA[0];
            double yA = circleA[1];
            double radiusA = circleA[2];
            double xB = circleB[0];
            double yB = circleB[1];
            double radiusB = circleB[2];
            double distanceOfCenterAB = Math.Abs(Math.Sqrt(Math.Pow(xB - xA, 2) + Math.Pow(yB - yA, 2)));
            if (distanceOfCenterAB + radiusB < radiusA)
            {
                return 2;
            }
            else if (distanceOfCenterAB > radiusA + radiusB)
            {
                return 0;
            }
            return 1;
        }
    }
}



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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

string S;

int w , n , e , s;

int check()
{
    if(w && e  && n && s )return 1;
    if(w  && e && n == 0 && s == 0)return 1;
    if(w == 0 && e == 0 && n && s)return 1;
    if(w == 0 && e == 0 && n == 0 && s == 0)return 1;
    return 0;
}
int main()
{
    getline(cin , S);
    for(size_t i = 0; i < S.length() ; ++i)
        if(S[i] == 'W')w++;
        else if(S[i] == 'N')n++;
        else if(S[i] == 'E')e++;
        else if(S[i] == 'S')s++;
    puts(check() ? "Yes" : "No");
    return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    int r=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='R'){
            r++;
        }
    }
//    int n = s.length();
//    int tp = n-1;
//    for(int i=0;i<r;i++){
//        if(s[i]=='W'){
//                int flag=0;
//            for(int j=tp;j>=r;j--){
//                if(s[j]=='R'){
//                    flag=1;
//                    swap(s[i],s[j]);
//                    break;
//                    tp = j-1;
//                }
//            }
//            count++;
//        }
//    }
int rplaced=0;
    for(int i=0;i<r;i++){
        if(s[i]=='R'){
            rplaced++;
        }
    }
    cout << r - rplaced;

    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




ll factorial(int n){
  if (n==0){
    return 1;
  }
  if (n==1){
    return 2;
  }
  if (n%2==0){
    return (factorial(n/2)*factorial(n/2))%MOD;
  }
  if (n%2==1){
    return (((factorial(n/2)*factorial(n/2))%MOD)*2)%MOD;
  }
}

  



int main(){

  ll n;
  cin>>n;
  vector<ll> data(n);
  rep(i,n){
    ll tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  vector<ll> count0(61,0);
  vector<ll> count1(61,0);
  
  rep(i,n){
    bitset<61> x(data.at(i));
    rep(j,61){
      if (x.test(j)==1){
        count1.at(j)++;
      }
      else {
        count0.at(j)++;
      }
    }
  }

 
  ll answer=0;
  
  rep(i,61){
    ll tmp;
    tmp=((count0.at(i)*count1.at(i)%MOD)*factorial(i))%MOD;
    answer+=tmp;
    answer%=MOD;
  }
  
  cout<<answer<<endl;

  
}




















Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	if (n % 2 > 0)
	{
		for (i = 1; i <= m; i++)
			printf("%d %d\n", i, n - i);
	}
	else
	{
		i = 1;
		while (i < n / 2 - i + 1)
		{
			printf("%d %d\n", i, n / 2 - i + 1);
			m--;
			i++;
			if (m == 0)
				break;
		}
		if (m > 0)
		{
			i = n / 2 + 1;
			while (m > 0)
			{
				printf("%d %d\n", i, n - i + n / 2);
				i++;
				m--;
			}
		}
	}
	return 0;
}

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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i, c in enumerate(p):
    if i == 0 or i == n-1:
        continue
    if p[i + 1] > p[i] > p[i - 1] or p[i - 1] > p[i] > p[i + 1]:
        cnt += 1

print(cnt)

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

int main()
{
    string s;
    cin>>s;
    int sum=0;
    int count=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        sum++;
        else
        sum=0;
        if(sum>count)
        count=sum;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>

using namespace std; 

#define MP make_pair
typedef unsigned long long ULL;

/*
string enc(string s){

	bool app[26]={false};

	string str=s;
	char sz=str.size();
	for(char i=0;i<sz;++i){
		char c=s[i]-'a';
		if(!app[c] && c!=0){
			--str[i];
			app[c]=true;
		}
	}

	return str;

}
*/
int main(){

	ios::sync_with_stdio(false);
	string s;

	while(cin>>s,s!="#"){


		set<string> ss1,ss2;
		vector<string> ans;
		int n=s.size()/2;
		int m=s.size()-n;
		ULL N=(1ULL<<n);
		ULL M=(1ULL<<m);
		for(ULL state=0;state<N;++state){
			string str=s.substr(0,n);
			for(char i=0;i<n;++i){
				if((1<<i)&state && str[i]!='z') str[i]++;
			}
 
			ss1.insert(str);
		}

		for(ULL state=0;state<M;++state){
			string str=s.substr(n);
			for(char i=0;i<m;++i){
				if((1<<i)&state && str[i]!='z') str[i]++;
			}

			ss2.insert(str);
		}

		for(auto it1=ss1.begin();it1!=ss1.end();++it1){
			for(auto it2=ss2.begin();it2!=ss2.end();it2++){
//				if(enc(str1+(*it2))==s) ans.push_back(str1+(*it2)+"\n");
				string str=(*it1)+(*it2);
				bool app[26]={false};
				for(char i=0;i<n+m;++i){
					char c=str[i]-'a';
					if(!app[c] && c!=0){
						--str[i];
						app[c]=true;
					}
				}

				if(str==s) ans.push_back((*it1)+(*it2)+"\n");

			}
		}

		const ULL sz=ans.size();
		cout<<sz<<endl;

		if(sz<=10){
			for(char i=0;i<sz;i++)
				cout<<ans[i];
		}else{
			cout<<ans[0]+ans[1]+ans[2]+ans[3]+ans[4]
			+ans[sz-5]+ans[sz-4]+ans[sz-3]+ans[sz-2]<<ans[sz-1];
		}


	}

	return 0;
}

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

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
    int n;
    cin>> n;
  	int mod = n%1000;
  	if(mod){
      cout<< (1000 - mod)<< endl;
    }
  else{
    cout<< 0<< endl;
  }

}


Measured memory_bytes: 3652
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] daikeihen = new int[3];
        for(int i = 0;i <= 2; i++){
      	daikeihen[i] = sc.nextInt();
        }System.out.println((daikeihen[0] + daikeihen[1]) * daikeihen[2] / 2);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int> x,y,h;
int idx;
rep(i,n){
    int _x,_y,_h;
    cin>>_x>>_y>>_h;
    x.pb(_x);
    y.pb(_y);
    h.pb(_h);
    if(_h!=0){
        idx=i;
    }
}

int CX,CY,H;
rep(cy,101){
    rep(cx,101){
        int _h = h[idx]+abs(cx-x[idx])+abs(cy-y[idx]);
        bool isFit=true;
        rep(i,n){
            if(h[i]!= max(_h-abs(cx-x[i])-abs(cy-y[i]),0)){
                isFit=false;
                break;
            }
        }

        if(isFit){
            CX=cx;
            CY=cy;
            H=_h;
            cout<<CX<<" "<<CY<<" "<<H<<" "<<endl;
            // system("pause");
            return 0;
        }
    }
}
// system("pause");
return 0;
}

Measured memory_bytes: 256
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
N = int(input())
ans = 0
for i in range(1,N+1):
    if i%2 == 0:
        continue
    else:
        tmp = factorize(i)
        if len(tmp) == 2:
            if tmp[0][1]*tmp[1][1] ==3:
                ans += 1
        if len(tmp) == 3:
            if tmp[0][1]*tmp[1][1]*tmp[2][1] ==1:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
//#define for(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

void solve(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	int cnt=0;
	for(int i=1;i<n-1;i++){
		if(arr[i]>arr[i-1] && arr[i]<arr[i+1]) cnt++;
		else if(arr[i]<arr[i-1] && arr[i]>arr[i+1]) cnt++;
	
	}
	cout<<cnt;	
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

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

int main(){
	string s;
	cin >> s;
	string key{"keyence"};
	if(s==key) {cout << "YES"; return 0;}
	for(int i=0;i<(int)s.length()-7;i++){
		for(int j = i;j < (int) s.length();j++){
			for(int k = 0;k<8;k++){
				//cout << s.substr(i,k)+s.substr(j,7-k) << endl;
				if(s.substr(i,k)+s.substr(j,7-k) == key){
					if(i>0 && j-i>k) continue;
					if(i==0 && j+7-k!=(int)s.length()) continue;
					cout << "YES";
					return 0;
				}
			}
		}
	}
	cout << "NO";
	//zxlxbwhcvkpvoahiohfozjtceocbsgdnpnbpuyqejdbwgnapzeyence
}


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

using namespace std;
typedef long long LL;
const double pi = acos(-1.0);
const double eps = 1e-7;
const LL mod = 1000000007;
const LL N = 10001;

LL T,n,m,i,j,k,a[100],len,t,cnt=0,ans=0;
char s1[100],s2[100];

int main()
{
    scanf("%lld",&len);
    scanf("%s%s",s1,s2);
    i=0;
    while(i<len){
        if(i==len-1){
            a[cnt++]=1;
            break;
        }
        if(s1[i]==s1[i+1]){
            i+=2;
            a[cnt++]=2;
        }else{
            i++;
            a[cnt++]=1;
        }
    }
    if(a[0]==1)ans=3;
    else ans=6;
    for(i=1;i<cnt;i++){
        if(a[i]==1){
            if(a[i-1]==1){
                ans=(ans*2)%mod;
            }
        }else{
            if(a[i-1]==1){
                ans=(ans*2)%mod;
            }else{
                ans=(ans*3)%mod;
            }
        }
    }
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 384
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n;in(n);
  vector<ll> C(200, 0);
  string s;
  loop(i,0,n) {
    in(s);
    C[(int)s[0]]++;
  }
  vector<ll> A;
  ll ans = 0;
  string t = "MARCH";
  loop(i,0,3) loop(j,i+1,4) loop(k,j+1,5) {
    ans += C[t[i]] * C[t[j]] * C[t[k]];
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 3596
/*
  Aの倍数を調べた時、Bで割り切ることができるかどうか
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B; cin >> A >> B;
  long long ans;

  ans = A;
  while (1) {
    if (ans % B == 0) break;
    ans += A;
  }

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

Measured memory_bytes: 256