akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int minTime(vector<int> &arr) {
    int time = 24;
    vector<int> c;
    for (int i = 0; i < arr.size(); i++) {
        if (arr[i] >= 1) c.push_back(i);
    }
    for (int i = 0; i < c.size() - 1; i++) time = min(time, c[i + 1] - c[i]);
    time = min(time, 24 - c.back());
    return time;
}

int main() {

    int N;
    cin >> N;

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

    map<int, int> M;
    for (int i = 0; i < N; i++) {
        if (D[i] >= 13) D[i] = 24 - D[i];
        M[D[i]]++;
    }

    SHOW_MAP(M);

    for (auto x: M) {
        if (
                (x.first == 0 && x.second >= 1) ||
                (x.first == 12 && x.second >= 2) ||
                (x.first != 0 && x.first != 12 && x.second >= 3)
                ) {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << 11); bit++) {
        vector<int> time(24, 0);
        time[0] = 1;
        if (M.count(12)) time[12] = 1;
        bool good = true;
        for (int i = 0; i < 11; i++) {
            //置いてあげる
            if (bit & (1 << i)) {
                if (M[(i + 1)] == 2) {
                    time[(i + 1)] = 1;
                    time[(24 - (i + 1))] = 1;
                }
                if (M[(i + 1)]== 1) {
                    time[(i + 1)] = 1;
                }
            } else {
                if (M[(i + 1)] == 2) {
                    good = false;
                }
                if (M[(i + 1)]== 1) {
                    time[24 - (i + 1)] = 1;
                }
            }

        }
        if (!good)continue;
        int t = minTime(time);
        ans = max(ans, t);
    }


    cout << ans << endl;

}



























Measured memory_bytes: 256
s = input()

if s == 'hi':
  print('Yes')
elif s == 'hihi':
  print('Yes')
elif s == 'hihihi':
  print('Yes')
elif s == 'hihihihi':
  print('Yes')
elif s == 'hihihihihi':
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
print(
  [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2,
   2, 5, 4, 1, 4, 1, 51][int(input()) - 1])


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

using namespace std;
int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int count = 0;
    int max = 0;
    int i = 1;
        while(i <= n-1){
            if(h[i] <= h[i-1]){
                count++;
                if(count > max) max = count;
            }else if(h[i] > h[i-1]){
                count = 0;
            }
            i++;
        }
    cout << max;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct edge{
  int to,w,p;
};
vector<edge>x[110];
int N,M,a,b,c,used[110];
int dfs(int s,int t,int r){
	if(s==t) return r;
    used[s]=1;
	for(int i=0;i<x[s].size();i++){
		if(used[x[s][i].to]==0 && x[s][i].w>0){
			int F=dfs(x[s][i].to,t,min(r,x[s][i].w));
			if(F>0){
              x[s][i].w-=F;
              x[x[s][i].to][x[s][i].p].w+=F;
              return F;
            }
		}
	}
	return 0;
}
int main(){
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>a>>b>>c;
		edge p={b,c,x[b].size()};x[a].push_back(p);
		edge q={a,0,x[a].size()-1};x[b].push_back(q);
	}
	int res=0;
	while(true){
		for(int i=0;i<110;i++)used[i]=0;
		int P=dfs(0,N-1,1<<30);
		if(P==0)break;res+=P;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3188
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

x = gets_i
pi2 = 360

if pi2 % x == 0
  puts pi2 / x
else
  puts pi2.lcm(x) / x
end


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

const ll M=1e9+7;

ll mod(ll n){
	return (n%M + M)%M;	
}
ll add(ll a, ll b){
	return mod(mod(a)+mod(b));
}

ll mul(ll a, ll b){
	return mod(mod(a)*mod(b));
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   
    int t;
  	t=1;


    while(t--){
    	int n;
    	cin>>n;

    	vector<int> data(n);
    	for(int i=0;i<n;i++)
    		cin>>data[i];

    	vector<ll> suffix(n);
    	suffix[n-1]=data[n-1];

    	for(int i=n-2;i>=0;i--)
    		suffix[i]=data[i]+suffix[i+1];

    	ll ans=0;
    	for(int i=0;i<n-1;i++)
    		ans=add(ans,mul(data[i],suffix[i+1]));
    	
    	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 5560
#include <iostream>
using namespace std;
int main(void){
    int N;
    int t[110000], x[110000], y[110000];
    
    t[0] == x[0] == y[0] == 0;
    
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];
    
    bool can = true;
    for(int i = 0; i < N; ++i){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        
        if(dist > dt) can = false;
        if(dt % 2 != dist % 2) can = false;
    }
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int x, y, ans=0;
  cin >> x >> y;

  if (x==1) ans+=300000;
  else if (x==2) ans+=200000;
  else if (x==3) ans+=100000;

  if (y==1) ans+=300000;
  else if (y==2) ans+=200000;
  else if (y==3) ans+=100000;

  if (x==1 && y==1) ans+=400000;

  cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

void solve() {
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) {
		cin >> a[i];
		a[i]--;
	}
	rep(i,n) {
		to[0][i] = a[i];
	}
	rep(i,D - 1) {
		rep(j, n) {
			to[i+1][j] = to[i][to[i][j]];
		}
	}
	int cur = 0;
	for (int i = D - 1; i >= 0; i--) {
		ll p = 1ll << i;
		if (k < p) continue;
		// cout << p << " " << cur << endl;
		cur = to[i][cur];
		k -= p;
	}
	cout << cur + 1 << endl;
}

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

Measured memory_bytes: 51040
#include<stdio.h>
#include<math.h>
int main(){
  double x[2],y[2],kyori,datax,datay,tate,yoko;
  scanf("%lf %lf %lf %lf",&x[0],&x[1],&y[0],&y[1]);
  if(x[0]>y[0])yoko=x[0]-y[0];
  else yoko=y[0]-x[0];
  if(x[1]>y[0])tate=x[1]-y[1];
  else tate=y[1]-x[1];
  kyori=hypot(tate,yoko);
  printf("%f\n",kyori);
  return(0);
}
  

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

int main(){
  int n;
  cin >> n;
  int c=n;
  int count=0;
  while(n){
    count+=n%10;
    n/=10;
  }
  if(c%count==0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string T;
  cin>>T;
  int n=T.size(),i=0;
  bool a=true;
  while(i<(n+1)/2){
    if(T[i]!=T[n-1-i]){
      a=false;
    }
    i++;
  }
  i=0;
  while(i<((n-1)/2-1-i)){
   if(T[i]!=T[(n-1)/2-1-i]){
     a=false;
   }
    i++;
  }
  i=0;
  while((i+(n+3)/2-1)<n-1-i){
    if(T[i+(n+3)/2-1]!=T[n-1-i]){
      a=false;
    }
    i++;
  }
  if(a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
  
  
}


Measured memory_bytes: 256
S=int(input())
K=int(input())

a=[]
while S !=0:
  s=S%10
  a.append(s)
  S //=10
m=0

for i in range(1,len(a)+1):
  if a[-i]!=1:
    if i>K:
      ans=1
    else:
      ans=i
    break
  else:
    ans=1

print(a[-ans])

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int C = in.nextInt();
		int[] B = new int[M];
		for (int i = 0; i < M; ++i) {
			B[i] = in.nextInt();
		}
		int[][] A = new int[N][M];
		for (int h = 0; h < N; ++h) {
			for (int w = 0; w < M; ++w) {
				A[h][w] = in.nextInt();
			}
		}
		in.close();
		int count = 0;
		for (int i = 0; i < N; ++i) {
			if (isValid(A[i], B, C)) {
				++count;
			}
		}
		System.out.println(count);
	}

	static boolean isValid(int[] A, int[] B, int C) {
		int result = C;
		for (int i = 0; i < A.length; ++i) {
			result += A[i] * B[i];
		}
		if (result > 0) {
			return true;
		} else {
			return false;
		}
	}

}


Measured memory_bytes: 23508
n=int(input())
num6=6
num9=9
l=[]
while num6<=n:
  l.append(num6)
  num6*=6
while num9<=n:
  l.append(num9)
  num9*=9
count=[0,1,2,3,4,5,1,2,3,1,2,3]
for i in range(12,n+1):
  min=100000
  for j in l:
    if i-j<0:
      pass
    else:
      if min>count[i-j]+1:
        min=count[i-j]+1
  count.append(min)
print(count[n])


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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            while (N-- != 0)
            {
                var n1 = Console.ReadLine();
                var n2 = Console.ReadLine();
                var r = f(n1, n2);
                Console.WriteLine(r.Length > 80 ? "overflow" : r);
            }
        }

        static string f(string n1, string n2)
        {
            var r = new List<int>();
            int f = 0;
            for (int i = 0; i < 82; i++)
            {
                if (i >= n1.Length && i >= n2.Length && f != 1) break;
                int c = f;
                f = 0;
                if (i < n1.Length) c += n1[n1.Length - i - 1] - '0';
                if (i < n2.Length) c += n2[n2.Length - i - 1] - '0';
                if (c > 9) f = 1;
                r.Add(c % 10);
            }
            r.Reverse();
            return new string(r.Select(i => (char)('0' + i)).ToArray());
        }
    }
}

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


/*
Euclidean Algorithm
 */
ll euclid(ll a, ll b){
  while (b>0){
    a = a % b;
    swap(a, b);
  }
  return a;
}



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

  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i,N){ cin >> A[i];}

  unordered_map<ll, ll> seen_map;
  vector<ll> primes(0);
  REP(i,N){
    ll ai = A[i];
    if (seen_map.find(ai) != seen_map.end()) continue;
    seen_map[ai] = 1;
    bool seen = false;
    for(ll& p : primes){
      if (ai%p==0){
        ai /= p;
        //if (seen_map.find(ai) != seen_map.end()){
        //  seen = true;
        //  break;
        //}
      }
      if (ai==1) break;
    }

    if (seen) continue;

    if (ai>0){
      /*
      Prime factorization
      */
      for(ll i=2; i*i<=ai; i++) {
        if (ai%i == 0) {
          while(ai%i==0) {
            ai/=i;
            seen_map[ai] = 1;
            primes.push_back(i);
          }
        }
      }
    }
    if(ai>1){
      primes.push_back(ai);
      seen_map[ai] = 1;
    }
  }

  sort(primes.begin(), primes.end());
  //for (ll& p : primes){ cout << p << " "; }
  //cout << "\n";

  ll ans = 0;
  REP(i,N){
    ll ai = A[i];
    ll bi = 1;
    for (ll& p : primes){
      if (ai%p==0){
        ai /= p;
      } else {
        bi *= p;
        bi %= MOD;
      }
    }
    ans += bi;
    ans %= MOD;
  }


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


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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vec;
typedef std::vector<ld> vecld;
typedef std::vector< std::vector<ll> > vecvec;
typedef std::pair<ll, ll> pr;
typedef std::vector< pr > vpr;

#define tin ll t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define sz(a) (ll)((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define ff first
#define ss second
#define mk make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define mst(c) memset((c),0,sizeof((c)))


int main(){


	//fio;

	/////////////////////////////////////////

	ll n;
	cin>>n;
	ll arr[100000][3]={0};
	rep(i,1,n){
		ll x,y,z;
		cin>>x>>y>>z;
		arr[i][0] = max(arr[i-1][1],arr[i-1][2])+x;
		arr[i][1] = max(arr[i-1][0],arr[i-1][2])+y;
		arr[i][2]=max(arr[i-1][1],arr[i-1][0])+z;
	}
	ll maxx = max(arr[n][0],arr[n][1]);
	
	cout<<max(maxx,arr[n][2])<<"\n";





	////////////////////////////////////////////////




    return 0;












}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int a,b,c;	cin >> a >> b >> c;
    bool ok=false;
    for(int i = 1; i <= b && !ok; i++){
	if(c==((a%b)*i)%b)ok=true;
    }
    if(ok){
	cout << "YES" << endl;
    }else{
	cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	int n,ans[55];
	cin >> n;
	int count = 0;

	for (int i = 11; count<n; i++) {
		if (i % 5 != 1) {
			continue;
		}
		bool flg = true;
		for (int j = 2; j <= sqrt(i); j++) {
			if (i%j == 0) {
				flg = false;
				break;
			}
		}
		if (flg) {
			ans[count] = i;
			count++;
		}
	}
	cout << ans[0];
	for (int i = 1; i < n; i++) {
		cout << ' ' << ans[i];
	}
	cout << endl;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    int count = 0;
    for(int i=0; i<n ; i++){
        cin >> array.at(i);
    }
    for(int i=0; i<n; i++){
        int minv = array.at(i);
        int minindex = i;
        for(int j=i; j<n; j++){
            if(minv > array.at(j)){
                minv = array.at(j);
                minindex = j;
            }
        }
        swap(array.at(i),array.at(minindex));
        if(array.at(i) != array.at(minindex)){
            count++;
        }
    }

    for(int i=0; i<n; i++){
        if(i != n-1){
            cout << array.at(i) << " ";
        }else{
            cout << array.at(i) << endl;
        }
        
    }
    cout << count << endl;
}


Measured memory_bytes: 3092
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,a;
	cin>>n>>a;
	for(int ff=1;ff<=200000;ff++) {
		int xx;
		xx++;
	}
	if((n%500)>a) cout<<"No";
	else cout<<"Yes";
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1){
		a=14;
	  }
	if(b==1){
		b=14;
	  }
	  if(a<b){
		  cout<<"Bob"<<endl;
		}
		else if(a>b){
		  cout<<"Alice"<<endl;}
		  else{
			  cout<<"Draw"<<endl;
			}}
	 


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
ll gcd(ll a,ll b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
bool isprime(ll n)
{
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
	ll n,i;
	cin>>n;
	ll a[n+1];
	ll b[n];
	for(i=0;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		cin>>b[i];
	}
	ll ctr=0;
	for(i=0;i<n;i++)
	{
		if(a[i]+a[i+1]<=b[i])
		{
			ctr+=a[i]+a[i+1];
			a[i+1]=0;
		}
		else
		{
			if(a[i]<=b[i])
			{
				ctr+=a[i];
				b[i]=b[i]-a[i];
				ctr+=(b[i]);
				a[i+1]=a[i+1]-b[i];
			}
			else
			{
				ctr+=(b[i]);
			}
		}
	}
	cout<<ctr;
	return 0;
}

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

using namespace std;
using ll = long long;


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

    if(m % 2) {
        for(int i = 0; i < (m + 1) / 2; i++) {
            cout << i + 1 << " " << (m + 1) - i << endl;
        }
        for(int i = 0; i < m - (m + 1) / 2; i++) {
            cout << m + 2 + i << " " << (2*m+1) - i << endl;
        }
    } else {
        for(int i = 0; i < m / 2; i++) {
            cout << i + 1 << " " << m - i  << endl;
        }
        for(int i = 0; i < m - m / 2; i++) {
            cout << m + 1 + i << " " << (2*m+1)-i << endl;
        }
    }
}

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

int main(){
  int i,out=0;
  string S,T;
  cin >> S;
  T=S;
  T[S.length()]='N';
  i=0;
  while(T[i]!='N'){
    if(S[i]=='d' && S[i+1]=='r' && S[i+2]=='e' && S[i+3]=='a' && S[i+4]=='m' && S[i+5]=='e' && S[i+6]=='r' && S[i+7]!='a'){
      i+=7;
    }else if(S[i]=='d' && S[i+1]=='r' && S[i+2]=='e' && S[i+3]=='a' && S[i+4]=='m'){
      i+=5;
    }else if(S[i]=='e' && S[i+1]=='r' && S[i+2]=='a' && S[i+3]=='s' && S[i+4]=='e' && S[i+5]=='r'){
      i+=6;
    }else if(S[i]=='e' && S[i+1]=='r' && S[i+2]=='a' && S[i+3]=='s' && S[i+4]=='e'){
      i+=5;
    }else{
      out=1;
      break;
    }
  }
  if(out==0){cout << "YES" << endl;}
  else{cout << "NO" << endl;}
  return 0;
}


Measured memory_bytes: 512
using AtCoderBeginnerContest155.Questions;
using AtCoderBeginnerContest155.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest155.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var abc = inputStream.ReadIntArray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];

            if ((a == b && b != c) ||
                (b == c && c != a) ||
                (c == a && a != b))
            {
                yield return "Yes";
            }
            else
            {
                yield return "No";
            }
        }
    }
}


namespace AtCoderBeginnerContest155
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest155.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest155.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        var (N, H) = ReadStream<int,long>();
        var a = new long[N];
        var b = new long[N];
        for (int i = 0; i < N; i++)
        {
            (a[i],b[i]) = ReadStream<long,long>();
        }
        long amax = a.Max();
        Array.Sort(b);
        Array.Reverse(b);

        long ans = 0;
        long h = H;
        for (int i = 0; i < N; i++)
        {
            if (b[i] <= amax||h<=0) break;
            ans++;
            h -= b[i]; 
        }
        if(h>0)
            ans += (long)Ceiling((decimal)h / amax);
        WriteLine(ans);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 48208
n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[float("inf")]*(n)
cost[0]=0
for i in range(n):
    for j in range(k):
        if i+j>=n-1:
            break
        cost[i+j+1]=min(cost[i+j+1],abs(h[i+j+1]-h[i])+cost[i])
print(cost[n-1])


Measured memory_bytes: 55136
import java.io.*
import java.lang.*


fun solve() {
    val N = rd.readInt()
    val A = rd.readIntArray()

    val mp = mutableMapOf<Int, Int>()
    for (i in 0 until N) {
        mp[A[i]] = (mp[A[i]]?:0) + 1
    }
    val dmp = mutableMapOf<Int, Int>()
    for ((k, v) in mp) {
        if (v>1) dmp[k] = v
    }

    while (true) {
        if (dmp.isEmpty()) break

        val min = dmp.minBy { it.key }
        if (min!!.value > 2) {
            dmp[min.key] = dmp[min.key]!! - 1
        } else {
            dmp.remove(min.key)
        }

        if (dmp.isNotEmpty()) {
            val max = dmp.maxBy { it.key }
            if (max!!.value > 2) {
                dmp[max.key] = dmp[max.key]!! - 1
            } else {
                dmp.remove(max.key)
            }
        } else {
            val mx = mp.maxBy { it.key }
            mp.remove(mx!!.key)
        }
    }

    var ans = mp.size
    println(ans)
}


//val rd = debug.Reader("arc", "068", "b", "sample-2")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 60576
MAX = 2*10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

N, M, K = map(int, input().split())
ans = 0

for i in range(1, N):
    ans += i*(N-i)*M*M*C(N*M-2, K-2)
    ans %= MOD

for i in range(1, M):
    ans += i*(M-i)*N*N*C(N*M-2, K-2)
    ans %= MOD

print(ans)

Measured memory_bytes: 79728
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

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

using namespace std;

typedef pair<int ,int > P;


int main()
{
	
	rep(i,10) rep(j,10) if(!i||!j) continue; else printf("%dx%d=%d\n",i,j,i*j);


	return 0;
}

Measured memory_bytes: 1096
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n, p;
	long long int ans;
	cin >> n >> p;
	int odd = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(x % 2 == 1) odd++;
	}
	long long int comb[odd+1];
	comb[0] = 1;
	for(int i = 1; i <= odd; i++){
		comb[i] = comb[i-1] * (odd - i + 1) / i;
	}
	ans = 0;
	for(int i = p; i <= odd; i += 2){
		ans += comb[i];
	}
	ans *= (long long int)pow(2, n - odd);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n = int(input())
    s = [input() for _ in range(n)]
    end_a = []
    start_b = []
    both = []
    other = []
    for si in s:
        if si[-1] == 'A':
            if si[0] == 'B':
                both.append(si)
            else:
                end_a.append(si)
        elif si[0] == 'B':
            start_b.append(si)
        else:
            other.append(si)

    res = ''.join(both)

    if start_b:
        res += start_b.pop()
    if end_a:
        res = end_a.pop() + res

    tmp = []
    while end_a and start_b:
        tmp.append(end_a.pop() + start_b.pop())

    res += ''.join(tmp) + ''.join(end_a) + ''.join(start_b) + ''.join(other)
    print(res.count('AB'))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 33820
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

struct Node *find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  struct Node *x=root,*y=NIL,*z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->right=NIL;
  z->left=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL)root=z;
  else {
     if(z->key < y->key){
       y->left=z;
     }
     else y->right=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){

  int n,i,x;
  char com[100];
  char str1[]="insert";
  char str2[]="print";
  char str3[]="find";

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,str3)==0){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(com,str1)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,str2)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;

}


Measured memory_bytes: 20608
#include <iostream>
#include <vector>
using namespace std;
int N,M;
bool *visited=0;
void dfs(vector<vector<int>> &Graph,int startV)
{
	int endV;
	visited[startV]=true;
	for (endV=0;endV<N;endV++){
		if (Graph[startV][endV]==0){
			continue;
		}
		if (visited[endV]){
			continue;
		}
		dfs(Graph,endV);
	}
}

int main(int argc, char* argv[])
{
	cin>>N>>M;
	vector<int> A(M),B(M);
	vector<vector<int>> Graph(N,vector<int>(N));
	visited = new bool[N];
	int i,j;
	for (i=0;i<M;i++){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		Graph[A[i]][B[i]]=1;
		Graph[B[i]][A[i]]=1;
	}
	int aw=0;
	for (i=0;i<M;i++){
		for (j=0;j<N;j++){
			visited[j]=false;
		}
		Graph[A[i]][B[i]]=0;
		Graph[B[i]][A[i]]=0;
		dfs(Graph,0);
		for (j=0;j<N;j++){
			if (visited[j]==false){
				aw++;
				break;
			}
		}
		Graph[A[i]][B[i]]=1;
		Graph[B[i]][A[i]]=1;
	}
	delete[] visited;
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
A, B, C = ri_()
print('Yes' if A <= C <= B else 'No')

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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;

  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B == C+D){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right"<<endl;
  }
}

Measured memory_bytes: 256
from collections import Counter

mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

def main():
    m = int(input())
    ans = 0
    a = 0
    for i in range(m):
        d, c = map(int, input().split())
        ans += c
        a += d * c
    print(ans + (a - 1) // 9 - 1)

main()


Measured memory_bytes: 3316
def main():

    N, K = map(int, input().split())
    mod = pow(10, 9) + 7

    u = N*(N+1) // 2 % mod
    ans = 0
    for i in range(K, N+2):
        v = u - (N-i)*(N-i+1)//2 % mod + 1 - i*(i-1) //2
        v %= mod
        ans += v
        ans %= mod

    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

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

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

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] <= b[i]){
            b[i] -= a[i];
            ans += a[i];
            a[i] = 0;

            ll num = min(a[i+1], b[i]);
            ans += num;
            b[i] -= num;
            a[i+1] -= num;
        }else{
            ans += b[i];
            b[i] = 0;
        }
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;cin>>N;
  int C[200010];
  ll dp[200010];
  for (int i=0;i<N;++i){int c;cin>>c;C[i]=c;}
  ll cum[200010];
  memset(cum, 0, sizeof(cum));
  dp[0]=1;
  cum[C[0]]=1;

  if(N==1) {cout << 1 << endl;return 0;}

  for (int i=1;i<N;++i){
    if(C[i]!=C[i-1]) (cum[C[i]]+=dp[i-1])%=MOD;
    dp[i]=cum[C[i]];
  }

  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 4224
import math

N, M = map(int, input().split())

if N == M:
    k = math.factorial(N)
    count = k * k * 2 % (10**9 + 7)
    print(count)
elif N + 1 == M:
    k = math.factorial(N)
    count = k * (k * M) % (10**9 + 7)
    print(count)
elif N == M + 1:
    k = math.factorial(M)
    count = k * (k * N) % (10**9 + 7)
    print(count)
else:
    print(0)

Measured memory_bytes: 5176
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int vis[maxn];
int init(int n)
{
	int k=sqrt(n);
	int ans=0;
	for(int i=1;i<=k;i++)
	{
		if(n%i==0)
			ans+=2;
	}
	return ans;
	// if(k*k==n)
	// 	ans+=1;
	// return ans;
}
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	ms(vis);
	for(int i=0;i<1000;i++)
	{
		if(i%2&&init(i)==8)
			vis[i]=1;
	}
	int n;
	cin>>n;
	int res=0;
	for(int i=0;i<=n;i++)
	{
		if(vis[i]==1)
			res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4224
/* ex9_2
   Graku */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node {
    struct node *next;
    char binary;
}node;

int get_last(node *l);
node* pop(node *l);
node* push(node *l, char n);

int main(void) {
    node *list = NULL;
    int count = 0;
    char s[100000];
    scanf("%s", s);

    for (int i = 0; i < strlen(s); i++) {
        if (list == NULL) { //list is empty
            list = push(list, s[i]);
        }
        else if (list->binary != s[i]) { //end of list is "01" or "10"
            list = pop(list);
            count += 2;
        }
        else { //end of list is "00" or "11"
            list = push(list, s[i]);
        }
    }

    printf("%d\n", count);
    return 0;
}

node* pop(node *list) {
    if (list == NULL) { //list is empty
        printf("Error: list is NULL\n");
        exit(1);
    }
    if (list->next == NULL) { //list has one element
        return NULL; //list is empty
    }
    node *head = list->next;
    free(list);
    return head;
}

node* push(node *list, char c) {
    node *new = malloc(sizeof(node)); //new element
    new->next = list; //new is end of list
    new->binary = c;
    return new;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n,m,ansor;
  cin>>n>>m;
  vector<int> vec(n);
  vector<int> ans(n);
  for (int i=0;i<n;i++){
    int h;
    cin>>h;
    vec.at(i)=h;
  }
  for(int j=0;j<m;j++){
    long long int a,b;
    cin>>a>>b;
    if(vec.at(a-1)==vec.at(b-1)){
      ans.at(a-1)=1;
      ans.at(b-1)=1;
    } else if (vec.at(a-1)<vec.at(b-1)){
      ans.at(a-1)=1;
    } else if (vec.at(a-1)>vec.at(b-1)){
      ans.at(b-1)=1;
    }
  }
  ansor=0;
  for(int i=0;i<n;i++){
    if(ans.at(i)!=1){
      ansor++;
    }
  }
  cout<<ansor<<endl;
}

Measured memory_bytes: 4052
N = int(input())
s = []
for _ in range(N):
    si = int(input())
    s.append(si)

s.sort()
# print(s)

not_10 = []

for si in s:
    if si % 10 != 0:
        not_10.append(si)

ans = sum(s)

while ans % 10 == 0:
    if len(not_10) > 0:
        ans -= not_10.pop(0)
    else:
        print(0)
        exit()

print(ans)


Measured memory_bytes: 9180
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    mod = 10**9 + 7
    b = 1
    c = 0
    for k in range(60):
        s = sum(ai & b for ai in a) // b
        c = (c + s * (n - s) * b) % mod
        b *= 2
    print(c)

if __name__ == '__main__':
    main()

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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	ll a, b, c, d;
	sll(a, b);
	sll(c, d);

	ll v1 = (a-1)/c + (a-1)/d - (a-1)/((c*d)/__gcd(c, d));
	ll v2 = (b)/c + (b)/d - (b)/((c*d)/__gcd(c, d));
	v2 -= v1;
	printf("%lld\n",b-a+1 - v2);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

bitset<12801> dp[80][80];

void solve() {
  int h, w;
  cin >> h >> w;
  vector<vi32> a(h, vi32(w));
  vector<vi32> b(h, vi32(w));
  cin >> a >> b;
  vector<vi32> c(h, vi32(w));
  rep(i, h) rep(j, w) c[i][j] = abs(a[i][j] - b[i][j]);
  dp[0][0][6400 + c[0][0]] = 1;
  dp[0][0][6400 - c[0][0]] = 1;
  rep(i, h) rep(j, w) {
    if (i + 1 < h) {
      dp[i + 1][j] |= (dp[i][j] << c[i + 1][j]);
      dp[i + 1][j] |= (dp[i][j] >> c[i + 1][j]);
    }
    if (j + 1 < w) {
      dp[i][j + 1] |= (dp[i][j] << c[i][j + 1]);
      dp[i][j + 1] |= (dp[i][j] >> c[i][j + 1]);
    }
  }
  int ans = 1e9;
  repc(i, 12800) if (dp[h - 1][w - 1][i]) {
    amin(ans, abs(i - 6400));
  }
  cout << ans << endl;
}


Measured memory_bytes: 10368
//int -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(int i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	int n;cin>>n;
	string a,b,c;
	cin>>a>>b>>c;
	int ans=0;
	REP(i,0,n-1)
	{
		if(a[i]==b[i]&&b[i]==c[i]){continue;}
		if(a[i]==b[i]||b[i]==c[i]||a[i]==c[i])
		{
			++ans;continue;
		}
		else{ans+=2;}
	}
	cout<<ans<<"\n";
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int d = a/b;
  int r = a%b;
  double f = ((double)a/b);
  printf("%d %d %f",d, r, f);
  return 0;
}

Measured memory_bytes: 3224
/* AOJ 0006 Reverse Sequence */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LEN 21

int
main(void)
{
    char s[32];
    int len, i;

    if (!fgets(s, MAX_LEN, stdin)) exit(EXIT_FAILURE);

    len = strnlen(s, MAX_LEN);
    for (i = len - 1; i >= 0; i--)
        putchar(s[i]);
    putchar('\n');

    exit(EXIT_SUCCESS);
}

Measured memory_bytes: 524
x,n = gets.chomp.split.map(&:to_i)
ps = gets.chomp.split.map(&:to_i)

ans = -1

xp = x
xm = x
while xp <= 101 || xm >= -1
  if ps.count(xm) == 0
    ans = xm
    break
  elsif ps.count(xp) == 0
    ans = xp
    break
  end
  xp += 1
  xm -= 1
end

puts ans

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i <= X + K - 1; i++)
    {
        cout << i;
        if (i == X + K - 1)
            cout << endl;
        else
            cout << " ";
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256