akhauriyash/Code-Regression huggingface dataset:
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<6;i++)
	{
		if(s[i]-'0')
			cnt++;
	}
	cout<<cnt;
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


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

using namespace std;

int main() {
    int x, y;
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;

        if (x <= y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

vector<vector<double>> ins(vector<vector<double>> a, int i)
{
	a.insert(a.begin() + i + 1, { (2 * a[i][0] + a[i + 1][0]) / 3, (2 * a[i][1] + a[i + 1][1]) / 3 });
	a.insert(a.begin() + i + 2, { (a[i][0] + 2 * a[i + 2][0]) / 3, (a[i][1] + 2 * a[i + 2][1]) / 3 });
	double u, v;
	u = (a[i + 2][0] + a[i + 1][0]) / 2 - (a[i + 2][1] - a[i + 1][1]) * sqrt(3) / 2;
	v = (a[i + 2][0] - a[i + 1][0]) * sqrt(3) / 2 + (a[i + 2][1] + a[i + 1][1]) / 2;
	a.insert(a.begin() + i + 2, { u, v });

	return a;
}

int main()
{
	vector<vector<double>> a = { { 0, 0 }, { 100, 0 } };
	int n = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		for(int j = 0; j < (int)pow(4, i); j++)
			a = ins(a, 4 * j);
	}

	for (unsigned int i = 0; i < a.size(); i++)
		cout << setprecision(8) << setiosflags(ios::fixed|ios::showpoint)
		<< a[i][0] << " " << a[i][1] << endl;

	return 0;
}

Measured memory_bytes: 3900
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

tommorow = [j-i for i, j in zip(a[:-1], a[1:])]
tommorow.append(-100)
max_price = 1000
kai = True
money = 1000
stock = 0
for i in range(len(a)):
    if kai:
        if tommorow[i] > 0:
            # 株価が上がる
            stock = money // a[i]
            money %= a[i]
            kai = False
    else:
        if tommorow[i] < 0:
            # 株価が下がる
            money += stock * a[i]
            max_price = max(max_price, money)
            kai = True

print(max_price)


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

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


	int num = (int)s[0] - '0' + (int)s[1] - '0' + (int)s[2] - '0';
	
	cout << num << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

string s;

int main() {
    cin >> s;
    for(int i = 0; i < s.length(); ++i) {
        if(i == 5 || i == 13) cout << " ";
        else if(i == s.length()-1) cout << s.at(i) << endl;
        else cout << s.at(i);
    }
}

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

int main()
{
    long n, m;
    cin >> n >> m;
    vector<pair<long, long>> item(n);
    for (long i = 0; i < n; i++) {
        cin >> item[i].first >> item[i].second;
    }
    sort(item.begin(), item.end());
    long ans = 0;
    long cnt = 0;
    for (long i = 0; i < n; i++) {
        long buy = min(item[i].second, m - cnt);
        cnt += buy;
        ans += buy * item[i].first;
        if (cnt == m) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;
#define n_max 1000

//#abcde#
// 01234
int SumDigits(int n)
{
    int sum = 0;

    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    int N;
    int ans = 10000000;

    cin >> N;
    
    for(int A = 1; A < N; A++) {
        int B = N - A;    

        int tmp = SumDigits(A) + SumDigits(B);
        //printf("tmp %d A %d %d B %d %d \n", tmp, A, SumDigits(A), B, SumDigits(B));
        if(ans > tmp) {
            ans = tmp;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
(N, M, _), *PY = [list(map(int, s.split())) + [i] for i, s in enumerate(open(0))]
prev_p = 0
city_cnt = 1
PY.sort()
for i in range(M):
    p, y, _ = PY[i]
    if p != prev_p:
        city_cnt = 1
        prev_p = p
    PY[i].append(str(p).zfill(6) + str(city_cnt).zfill(6))
    city_cnt += 1
PY.sort(key=lambda x: x[2])
[print(x[-1]) for x in PY]


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

int main(){
  int n,d,x;
  cin>>n>>d>>x;
  int a,ans;
  for(int i=0;i<n;i++){
    cin>>a;
    ans+=(d-1)/a+1;
  }
  ans+=x;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, t=0;
	cin >> a >> b;
	c=b;
	do
	{
		c/=10;
		t++;
	}while(c!=0);
	for (int i=1;i<=t; i++) 
	{
		a*=10;
	}
		a+=b;
	if (int(sqrt(a))==sqrt(a))
	{
		 cout << "Yes" << endl;
	}	 
	else
	{
		 cout << "No" << endl;
	}	 
	return 0;
}


Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
s = [0]*(M+1)
for _ in range(N):
    l = list(map(int, input().split()))
    for a in l[1:]:
        s[a] += 1

ans = 0
for i in s:
    if i == N:
        ans += 1
print(ans)


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

int main() {

  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if (N <= K) {
    cout << N * X << endl;
  }
  else {
    cout << K * X + (N - K) * Y << endl;
  }
    
}


Measured memory_bytes: 256
loop do
    n = gets.chomp.to_i

    break if n == 0

    min_v, max_v, sum = 1e8, -1, 0

    n.times do |i|
        s = gets.chomp.to_i
        sum += s
        min_v = [s, min_v].min
        max_v = [s, max_v].max
    end

    puts (sum - max_v - min_v) / (n-2)

end


Measured memory_bytes: 6880
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	string s ; cin >> s ;
	vll e(n+1,0),w(n+1,0) ;
	for(int i=0;i<n;i++){
		if(s.at(i)=='E'){
			e.at(i+1) = e.at(i)+1 ;
			w.at(i+1) = w.at(i) ;
		}else{
			e.at(i+1) = e.at(i) ;
			w.at(i+1) = w.at(i)+1 ;
		}
	}
	ll ans = 10000000 ;
	for(int i=1;i<=n;i++){
		ll sub = w.at(i)+e.at(n)-e.at(i-1)-1 ;
		if(sub<ans) ans = sub ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 5380
#include <iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<vector>
#define maxn 100005
#define cle(n) memset(n,0,sizeof(n))
typedef long long  ll;
typedef unsigned long long ull;
const int inf=100000000;
using namespace std;
int n,m;   ///n个点  m个查询
int ans[maxn];
int main()
{
  cin>>n>>m;
  int mm=0;
  cle(ans);
  for(int i=0;i<m;i++)
  {
      int a,b;
      cin>>a>>b;
      ans[a]++;
      ans[b]++;

  }

  for(int i=0;i<n;i++)
    if(ans[i]%2)
    return cout<<"NO"<<endl,0;

   cout<<"YES"<<endl;


    return 0;
}



Measured memory_bytes: 640
import sys

H = int(input())

if H == 1:
  print(1)
  sys.exit()

h = 1

while(True):
  if 2**h <= H < 2**(h+1):
    break

  h += 1

ans = 3

if h == 1:
  print(ans)
  sys.exit()

for k in range(1, h+1):
  if k == 1:
    continue

  ans += 2**k

print(ans)

Measured memory_bytes: 3064
a=int(input())
b=[]
for i in range(a):
	b.append(input())
#print(b)
c=list(set(b))
#print(c)
if len(b)!=len(c):
	print("No")
else:
	hantei=True
	for i in range(a-1):
		if b[i][-1]==b[i+1][0]:
			continue
		else:
			hantei=False
			break
	if hantei:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<double,int> P;

const double INF = 1000000000;
struct edge { int to; double cost; };
vector<edge> G[1001];

void solve(int s, int g) {
    double d[1001]; fill(d, d+1001, INF);
    int prv[1001]; fill(prv, prv+1001, -1);
    priority_queue<P, vector<P>, greater<P> > q;
    d[s] = 0;
    q.push(make_pair(0, s));
    while ( ! q.empty()) {
        int v = q.top().second;
        q.pop();
        for (int i=0; i<(int)G[v].size(); ++i) {
            edge &e = G[v][i];
            if (e.cost != INF && d[v] + e.cost < d[e.to]) {
                d[e.to] = d[v] + e.cost;
                q.push(make_pair(d[e.to], e.to));
                prv[e.to] = v;
            }
        }
    }
    int k = g;
    if (prv[k] < 0) {
        cout << "NA" << endl;
    } else {
        vector<int> ret;
        while (0 <= k) {
            ret.push_back(k);
            k = prv[k];
        }
        for (int i=ret.size()-1; i>=0; --i) {
            cout << ret[i] << (i != 0 ? " " : "");
        }
        cout << endl;
    }
}

int main() {
    int n, m, s, g;
    int b[1000], x[1000], y[1000];
    while (cin >> n, n) {
        for (int i=0; i<n; ++i) {
            cin >> b[i] >> x[i] >> y[i];
        }
        for (int i=0; i<1001; ++i) {
            G[i].clear();
        }
        for (int i=0; i<n; ++i) {
            for (int j=i+1; j<n; ++j) {
                int cost = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
                if (2500 < cost) {
                    G[b[i]].push_back((edge){b[j], INF});
                    G[b[j]].push_back((edge){b[i], INF});
                } else {
                    G[b[i]].push_back((edge){b[j], sqrt(cost)});
                    G[b[j]].push_back((edge){b[i], sqrt(cost)});
                }
            }
        }
        cin >> m;
        for (int i=0; i<m; ++i) {
            cin >> s >> g;
            solve(s, g);
        }
    }
    return 0;
}

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

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

    vector<int> L(M),R(M);
    for(int i=0;i<M;i++){
        cin >> L.at(i) >> R.at(i);
    }

    int range_min=0,range_max=N;
    for(int i=0;i<M;i++){
        range_min = max(range_min,L.at(i));
        range_max = min(range_max,R.at(i));
    }
    int count;
    if(range_min<=range_max) count = range_max-range_min+1;
    else count = 0;
    cout << count << endl; 
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int a, b, c;
  	cin >> a >> b >> c;
  
  	int count5 = 0;
  	int count7 = 0;
  
  	if (a == 5) {
      count5 += 1;
    } else if (a == 7) {
      count7 += 1;
    }
  	if (b == 5) {
      count5 += 1;
    } else if (b == 7) {
      count7 += 1;
    }
  	if (c == 5) {
      count5 += 1;
    } else if (c == 7) {
      count7 += 1;
    }
  
  if (count5 == 2 and count7 == 1) {
    cout << "YES" << endl;
  } else {
  	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int N;
  cin>>N;
  vector<vector<int>>A(2,vector<int>(N));
 for(int i=0;i<2;i++){
    for(int j=0;j<N;j++){
      cin>>A.at(i).at(j);
    }
  }
 int ans1=0;int ans2=0;int sum=0;
    for(int j=0;j<N;j++){
     ans1=0;ans2=0;
     for(int i=0;i<=j;i++){ans1+=A.at(0).at(i);}
     for(int k=j;k<N;k++){ans2+=A.at(1).at(k);}
     //cout<<ans1<<" "<<ans2<<endl;
     sum=max(sum,ans1+ans2);
    }
 cout<<sum<<endl;
  
  return 0;}

Measured memory_bytes: 384
dict = {
        'a' => 0, 'b' => 0, 'c' => 0, 'd' => 0, 'e' => 0, 'f' => 0, 'g' => 0,
        'h' => 0, 'i' => 0, 'j' => 0, 'k' => 0, 'l' => 0, 'm' => 0, 'n' => 0,
        'o' => 0, 'p' => 0, 'q' => 0, 'r' => 0, 's' => 0, 't' => 0, 'u' => 0,
        'v' => 0, 'w' => 0, 'x' => 0, 'y' => 0, 'z' => 0
}
while STDIN.eof == false
        line = STDIN.gets
        line.downcase.chars {|c|
                dict[c] += 1 if c.match(/[a-z]/)
        }
        break if line.match(/^$/)
end

dict.each {|k,v|
        puts k + ' : ' + v.to_s
}

Measured memory_bytes: 6196
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
    int n,k;
    std::cin >> n >> k;
    std::vector<int> p(n);
    rep(i,n){
        std::cin >> p[i];
    }
    sort(p.begin(),p.end());
    int sum=0;
    rep(i,k){
        sum+=p[i];
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;

int n;
long long a, b, c, ans = 0;
vector<long long> h;

bool f(long long aa) {
	long long an= 0;
	for (int i = 0; i < n; i++) {
		long long d = h[i] - aa*b;
		if (d > 0) {
			an += (d+c-1) / c;
		}
	}
	return an <= aa;
}

int main() {
	cin >> n >> a >> b;
	c = a - b;
	h.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	long long mm = 0, ma = 17179869185;
	long long now = (mm + ma)/2;
	while (ma - mm > 1) {
	//	cout << mm << " " << now <<  " " <<  ma <<endl;
		if (f(now)) {
			ma = now;
		}
		else {
			mm = now;
		}
		now = (mm + ma) / 2;
	}
	cout << ma << endl;
//	cin >> n;
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<ll> a(n), hx(n);
  ll sum=0LL;
  rep(i, n){
    cin>>a[i];
    sum += a[i];
  }
  sum /= 2LL;
  hx[0] = sum;
  for(int i=1;i<=n-2;i+=2){
    hx[0] -= a[i];
  }
  for(int i=1;i<n;i++){
    hx[i] = a[i-1]-hx[i-1];
  }
  rep(i, n)cout<<hx[i]*2<<" ";
  cout<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n,0);
	ll x;
	rep(i, n-1)
	{
		cin >> x;
		a[x - 1]++;
	}
	


	rep(i, n )
	{
		cout << a[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int64_t a,b,c;
void solve(){

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

int main(){
    cin>>a>>b>>c;

    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
vector<ll> graph[1000000];ll mod=1e9+7;
pair<ll,ll> dfs(ll node,ll parent)
{
    ll a=1;ll b=1;
    for(auto x:graph[node])
    {
        
        if(x==parent)continue;
        pair<ll,ll> p=dfs(x,node);
        a=(a*p.second)%mod;
        b=b*(p.first+p.second)%mod;
        
    }
    pair<ll,ll> k;k.first=a;k.second=b;
    return k;
}
int main()
{
  ll n;cin>>n;
  for(ll i=1;i<=n-1;i++)
  {
      ll x;ll y;cin>>x>>y;
      graph[x].pb(y);
      graph[y].pb(x);
  }
  pair<ll,ll> x=dfs(1,-1);
  ll ans=(x.first+x.second)%mod;
  cout<<ans<<endl;
}
   


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

int main() {
    int x , y;
    while(1) {
    cin >> x >> y;
    if (x == 0 && y == 0) break; {
        if ( x < y ) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
         }
    }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;


bool func1(const vector<int>& ar) {
    unordered_map<int, int> map;

    for (auto a: ar) {
        if (map.count(a)==0) {
            map[a] = 1;
        } else {
            map[a]++;
        }
    }

    for (auto ite: map) {
        //printf("%d, %d\n", ite.first, ite.second);
        if (ite.second != ar.size()/3 &&  ite.second != 2*ar.size()/3) {
            //printf("exit at %d\n", __LINE__);
            return false;
        }
    }
    int r = 0;
    for (auto ite: map) {
        r = r ^ ite.first;
        //printf("r:0x%x, a:0x%x\n", r, ite.first);

        if (ite.second > ar.size()/3) {
            r = r ^ ite.first;
        }
    }

    if (r==0) {
        return true;
    } else {
        return false;
    }
}


int main(int argc, char* argv[]) {

    int n;
    cin >> n;

    vector<int> ar;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        ar.push_back(a);
    }

    bool ok = all_of(
        ar.begin(),
        ar.end(),
        [](int x) {
            return x == 0;
        });
    if (ok) {
        cout << "Yes" << endl;
        return 0;
    }

    ok = func1(ar);
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
	int R; cin >> R;
	
	if(R < 1200){
		cout << "ABC";
	}
	else if(R < 2800){
		cout << "ARC";
	}
	else{
		cout << "AGC";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y));

int main()
{
	int list[2][10];
	int i,j,k;
	for(i = 0;i < 2;i++)
	{
		for(j = 0;j < 10;j++)
		{
			scanf("%d",&list[i][j]);
		}
	}
	int pt[2] = {0,0};
	for(i = 0;i < 3;i++)
	{
		for(j = 0;j < 2;j++)
		{
			int max=0;
			int maxi;
			for(k = 0;k < 10;k++)
			{
				if(max < list[j][k])
				{
					max = list[j][k];
					maxi = k;
				}
			}
			pt[j] += max;
			list[j][maxi] = 0;
		}
	}
	printf("%d %d\n",pt[0],pt[1]);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N;
    cin >> N;
    double a[N];
    double ans;
    for(int i=0;i<N;i++){
        cin >> a[i];
        ans+=double(1/a[i]);
    }
    ans=double(1.0/ans);
    printf("%.8f\n",ans);
}


Measured memory_bytes: 256
n = gets.to_i
r = [n]

ans = -1000000000

n.times do |i|
  r[i] = gets.to_i
end

tmp = r[0]

(1..n-1).each do |i|
  ans = [ans, r[i]-tmp].max
  tmp = r[i] if tmp > r[i]
end

puts ans



Measured memory_bytes: 8908
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 1000
int a[maxn];
int n;
int Count=0;
bool flag=1;
void bubbleSort()
{
    for(int i=0;flag;i++)
    {
        flag=0;
        for(int j=n-1;j>=i+1;j--)
        {
            if(a[j]<a[j-1])
            {
                flag=1;
                Count++;
                swap(a[j],a[j-1]);
            }
        }
    }
     for(int i=0;i<n;i++)
    {
        if(i!=n-1)
            cout<<a[i]<<" ";
        else
            cout<<a[i]<<endl;
    }
    cout<<Count<<endl;
}
int main()
{
    while(cin>>n)
    {

        for(int i=0;i<n;i++)
            cin>>a[i];
        bubbleSort();
    }
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  #define int ll
  int n,d;cin>>n>>d;
  d *= d;
  int ans = 0;
  rep(i,n){
    int x,y;cin>>x>>y;
    int dis = x*x + y*y;
    if(dis <= d)ans++;
  }
  print(ans);
  return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

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

	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= M; j++){
			if(i * (M - j) + j * (N - i) == K){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class atD {
private:
    bool play(int turn, long long X, long long Y) {
        for (int i = 1; 2*i <= X; ++i) {
            if (!play(1 - turn, X - 2*i, Y + i)) {
                return true;
            }
        }
        for (int i = 1; 2*i <= Y; ++i) {
            if (!play(1 - turn, X + i, Y - 2*i)) {
                return true;
            }
        }
        return false;
    }
public:
    void solve(istream& in, ostream& out) {
        long long X, Y;
        in >> X >> Y;
        
        /*
        //bruteforce for small X,Y to find pattern
        for (int i = 0; i <= 10; ++i) {
            for (int j = 0; j <= 10; ++j) {
                out << "(" << i << "," << j << ")->" << play(0, i, j) << " ";
            }
            out << "\n";
        }*/
        
        if (abs(X - Y) > 1) {
            out << "Alice\n";
        } else {
            out << "Brown\n";
        }
    }
};


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

	atD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  
  int c = max(a,b);
  int d = min(a,b);
    
  for(int i=0; i<c; i++){
    cout << d;
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

h,w=mii()

mat=[list(ss()) for _ in range(h) ]
cnt=0
for i in range(h):
    for j in range(w):
        if mat[i][j]=="#":
            cnt+=1

if cnt==h+w-1:
    print("Possible")
else:
    print("Impossible")


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);

    bool can=true;
    for(int i=0; i<N; i++){
        if(A.at(i)%2 == 0){
            if((A.at(i)%3 != 0) && (A.at(i)%5 != 0)){
                can = false;
            }
        }
    }

    if(can) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
using System;

class Program{
	static void Main(string[] args){
    	string[] input = Console.ReadLine().Split(' ');
      	int H = int.Parse(input[0]);
      	int W = int.Parse(input[1]);
      
      	input = Console.ReadLine().Split(' ');
      	int h = int.Parse(input[0]);
      	int w = int.Parse(input[1]);
      
      	Console.WriteLine((H*W) - (h*W) - (w *H) + (h*w));
    }
}

Measured memory_bytes: 13140
import math
 
def combination(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)    

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

A = list(map(int,input().split()))

kisu = 0
gusu = 0

for a in A:
    if a%2 == 0:
        gusu += 1
    else:
        kisu += 1

sum_gu = 2**gusu

if P%2==0:
    sum_ki = 0
    for i in range(2,kisu+1, 2):
        sum_ki += combination(kisu, i)
    sum_ki *= sum_gu
    print(sum_gu+sum_ki)
else:
    sum_ki = 0
    for i in range(1,kisu+1, 2):
        sum_ki += combination(kisu, i)
    print(sum_gu*sum_ki)

Measured memory_bytes: 62112
import java.util.Scanner;

public class Main {
    static class Solution {
        public void find() {

        }

    }

    public static void main(String[] args) {
       Solution sol = new Solution();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res = 0;
        for(int i=1; i<=n; i++) {
            if(i%3 != 0 && i%5 != 0) {
                res += i;
            }
        }
        System.out.println(res);
        sol.find();
    }
}


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


    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        int n;
        cin>>n;
        ll k;
        vector<ll>a(n) , b(n);
        for(int i=0;i<n;i++){
            cin>>k;
            a[i]=i-k;
            b[i]=i+k;
        }
        sort(b.begin(),b.end());
        ll total=0;
//        for(int i=0;i<n;i++)
//            cout<<a[i]<<" ";
//        cout<<"\n";
//        for(int i=0;i<n;i++)
//            cout<<b[i]<<" ";
//        cout<<"\n";
        for(int i=0;i<n;i++){
            ll x=lower_bound(b.begin(),b.end(),a[i])-b.begin();
            ll y=upper_bound(b.begin(),b.end(),a[i])-b.begin();
            --y;
//            cout<<x<<" "<<y<<"\n";
            if(x<n && b[x]==a[i] && y<n && b[y])
                total+=(y-x+1);
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
 
int main() {
	uint N;cin >> N;
	vector<pair<uint, uint>> A(N);
	for(uint i=0; i<N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	vector<pair<uint, uint>> B(N);
	for(uint i=0; i<N; i++) {
		cin >> B[i].first;
		B[i].second = i;
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	bool dpl = false;
	for(uint i=0; i<N; i++) {
		if(A[i].first > B[i].first) {
			cout << "No";
			return 0;
		}
		dpl |= (i < N -1) && (A[i+1].first <= B[i].first);
	}

	if(dpl) {
		cout << "Yes";
		return 0;
	}
	
	vector<uint> rpl(N);
	for(uint i=0; i<N; i++) {
		rpl[B[i].second] = A[i].second;
	}
	
	uint cnt = 0;
	uint nxt = 0;
	while(rpl[nxt] != 0) {
		cnt++;
		nxt = rpl[nxt];
	}
	if(cnt < N - 1) cout << "Yes";
    else cout << "No";
	return 0;
}

Measured memory_bytes: 2176
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	vi A(n);
	take(A,0,n);
	vi H(MAX);
	ll sum=0;
	for(auto a:A)
	{
		H[a]++;
		sum+=a;
	}

	int q;
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		int how=H[b];
		sum+=how*(c-b);
		H[b]=0;
		H[c]+=how;
		cout<<sum<<endl;
	}
}		

Measured memory_bytes: 4500
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

int main()
{
    int n;
    cin >> n;
    cout << n * 2 / gcd(2, n) << endl;
}

Measured memory_bytes: 256
import Data.List
main :: IO ()
main = do
  getLine
  line <- getLine
  putStrLn $ isUniq $ sort $ words line

isUniq :: [String] -> String
isUniq [] = "YES"
isUniq [_] = "YES"
isUniq (x:y:xs) 
  | x == y  = "NO"
  | otherwise = isUniq (y:xs)

Measured memory_bytes: 143740
/* -------------------------------------------------

Author :- Vaibhav Pal
College :- Northern India Engineering College, New Delhi
Coding Handle :- underdog_eagle
Title :-

----------------------------------------------------*/
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000000000000          // 10^18
#define nl '\n'
#define sp ' '
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define fo(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)

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

int main()
{
	FAST_IO
   /* #ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
    #endif*/
	int n;
	cin >> n;
	int d = n % 10;
	n /= 10;
	int c = n % 10;
	n /= 10;
	int b = n % 10;
	n /= 10;
	int a = n % 10;

	if (a + b + c + d == 7)
		cout << a << "+" << b << "+" << c << "+" << d << "=7";
	else if(a + b + c - d == 7)
		cout << a << "+" << b << "+" << c << "-" << d << "=7";
	else if (a + b - c - d == 7)
		cout << a << "+" << b << "-" << c << "-" << d << "=7";
	else if (a - b - c - d == 7)
		cout << a << "-" << b << "-" << c << "-" << d << "=7";
	else if (a - b - c + d == 7)
		cout << a << "-" << b << "-" << c << "+" << d << "=7";
	else if (a - b + c + d == 7)
		cout << a << "-" << b << "+" << c << "+" << d << "=7";
	else if (a + b - c + d == 7)
		cout << a << "+" << b << "-" << c << "+" << d << "=7";
	else if (a - b + c - d == 7)
		cout << a << "-" << b << "+" << c << "-" << d << "=7";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = 100000000000009;
ll i;

int main(){
    ll L;
    cin>>L;
    cout<<setprecision(15)<<fixed<<L*L*L/27.0<<endl;

}

Measured memory_bytes: 256
s=input()
l=['KIHBR','AKIHBR','KIHABR','KIHBAR','KIHBRA','AKIHABR','AKIHBAR','AKIHBRA','KIHABAR','KIHABRA','KIHBARA','AKIHABAR','AKIHABRA','AKIHBARA','KIHABARA','AKIHABARA']
if s in l:print('YES')
else:print('NO')

Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;
#define MOD 1000000007

long long n;

long long modpow(long long a, long long n,long long mod)
{
    long long res = 1;
    while(n > 0){
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long ruisekiMOD(long long b,long long a)
{
    long long ans = 1;
    
    for (long long i = a;i <= b;i++){
        ans = ans*i%MOD;
    }
    return ans;
}

int main()
{
    long long a,b;
    
    cin >> n >> a  >> b;
    
    long long ax = ruisekiMOD(n,n-a+1);
    long long ay = ruisekiMOD(a,1);
    long long bx = ruisekiMOD(n,n-b+1);
    long long by = ruisekiMOD(b,1);
    
    long long ans = MOD + MOD + modpow(2,n,MOD) - ax*modpow(ay,MOD-2,MOD)%MOD - bx*modpow(by,MOD-2,MOD)%MOD - 1;
    
    cout << ans%MOD << endl;
   
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

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

    vector<int> nums;
    int now = 1; // 今見ている数
    int cnt = 0; // nowがいくつ並んでいるか
    rep(i, N) {
        if (S[i] == (char) ('0' + now)) cnt++;
        else {
            nums.push_back(cnt);
            now = 1 - now; // 0と1を切り替える計算
            cnt = 1; // 新しくカウントする
        }
    }
    if (cnt != 0) nums.push_back(cnt);

    // 1110001100111 のような配列が欲しい
    // 1110001100 のように０で終わっていたら一つ足す
    if (nums.size() % 2 == 0) nums.push_back(0);

    int add = 2 * K + 1;
    int ans = 0;

    int left = 0;
    int right = 0;
    int tmp = 0; // [left, right) のsum

    // 1110001100111 の1からカウントするので偶数番目から始める
    for (int i = 0; i < nums.size(); i += 2) {
        int nextLeft = i;
        int nextRight = min(i + add, (int) nums.size());

        while (nextLeft > left) {
            tmp -= nums[left];
            left++;
        }

        while (nextRight > right) {
            tmp += nums[right];
            right++;
        }

        ans = max(tmp, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1020
N, x = [int(i) for i in input().split(" ")]
lst = [int(i) for i in input().split(" ")]
 
lst.sort()
cnt = 0
 
for i in range(0,N-1):
  if x >= lst[i]:
    x -= lst[i]
    cnt += 1
  else:
    break

    
print(cnt+(x==lst[N-1]))


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
vector<vector<bool>> seat;

int main() {
	int n;
	cin >> n;
	ll ans = 1;
	ll a;
	//cout << 1e1 << endl;
	ll gen = 1e18;
	bool tmp = false;
	rep(i, n) {
		cin >> a;
		if (a == 0) {
			cout << 0 << endl;
			return 0;
		}
		if (gen/a<ans) {
			tmp = true;;
		}
		ans *= a;
		
		
	}
	if (tmp) {
			cout << -1 << endl;

		return 0;

	}
	cout << ans << endl;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((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 debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	map<int, int> mp;
	int r = -1;
	ll ans = 0;
	rep(i,n){ // i 左端
		int count = 0;
		if(i != 0){ // 左端の更新
			while(a[i-1] != 0){
				mp[count] -= a[i-1] % 2;
				count++;
				a[i-1] /= 2;
			}
		}
		bool ok = true;
		for(auto x:mp){
			if(x.second >= 2){
				ok = false;
			}
		}
		// 右端を伸ばす。
		// とりあえずrを追加しちゃう
		while(ok && r < n){
			r++;
			if(r >= n) break;
			ll now = a[r];
			count = 0;
			while(now != 0){
				mp[count] += now % 2;
				if(mp[count] >= 2) ok = false;
				count ++;
				now /= 2;
			}
		}
		ans += r - i;
		//printf("i = %d, r = %d, ans = %lld\n", i,r,ans);
	}
	cout << ans << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 110000
ll n,m;
vector<vector<int>>edges(MAXN, vector<int>());

ll dp1[MAXN];
void dfs1(int x, int p=-1){
  dp1[x]=1;
  for(auto c:edges[x]){
    if(c==p)continue;
    dfs1(c,x);
    dp1[x] *= dp1[c];
    dp1[x] %= m;
  }
  dp1[x]++;
  dp1[x] %= m;
}

ll dp2[MAXN];
void dfs2(int x, int p=-1){
  if(p==-1)dp2[x]=1;
  int ec=edges[x].size();

  ll pr=1;

  vector<ll> lprod;
  rep(i, ec){
    int c = edges[x][i];

    if(c==p){
      lprod.push_back(pr);
      continue;
    }

    pr *= dp1[c];
    pr %= m;
    lprod.push_back(pr);
  }

  pr=1;  

  vector<ll> rprod;
  rrep(i, ec){
    int c = edges[x][i];

    if(c==p){
      rprod.push_back(pr);
      continue;
    }
 
    pr *= dp1[c];
    pr %= m;
    rprod.push_back(pr);

  }
  reverse(rprod.begin(), rprod.end());

//for(auto c: lprod)cout<<c<<' ';cout<<endl;
//for(auto c: rprod)cout<<c<<' ';cout<<endl;


  rep(i, ec){
    int c = edges[x][i];
    if(c==p)continue;
    dp2[c] = dp2[x];
    if(i)dp2[c] *= lprod[i-1];
    dp2[c] %= m;
    if(i<ec-1)dp2[c] *= rprod[i+1];
    dp2[c] %= m;
    dp2[c]++;
    dp2[c]%=m;
    dfs2(c, x);
  }
}

ll ans[MAXN];
void dfs3(int now, int p=-1){
  ans[now] = dp2[now];
  for(auto c:edges[now]){
    if(c==p)continue;
    ans[now] *= dp1[c];
    ans[now] %= m;
    dfs3(c, now);
  }
}

int main(){
  cin>>n>>m;
  rep(i, n-1){
    int x,y;cin>>x>>y;x--,y--;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  dfs1(0);
  dfs2(0);
  dfs3(0);
 
  rep(i, n)cout<<ans[i]<<endl;

  return 0;

  rep(i, n)cout<<dp1[i]<<' ';cout<<endl;
  rep(i, n)cout<<dp2[i]<<' ';cout<<endl;

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	if(n < 1200) cout << "ABC" << endl;
	else if(n < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())
q = int(input())

head = []
tail = []

flip = 0
for _ in range(q):
    com, *query = input().split()
    if com == "1":
        flip ^= 1
    else:
        f, c = query
        f = int(f)-1
        if f ^ flip == 0:
            head.append(c)
        else:
            tail.append(c)

if flip:
    head, tail = tail[::-1], head
    s = s[::-1]
else:
    head = head[::-1]
print("".join(head+s+tail))

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::string s;
  std::cin >> n >> s;
  int count = 0;
  for (auto ch : s) {
    if (ch == 'R') {
      count++;
    } else {
      count--;
    }
  }
  std::cout << (count > 0 ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}

void solve() {

    int k; cin >> k;
	//unordered_set<int> rems = {7};
	int v = 7;
	
	for(int i=1; i < k+1; ++i) {
		if (v % k == 0) {
			cout << i << endl;
			return;
		}
		
		v = (v * 10 + 7) % k;
	}
	
	cout << -1 << endl;

}

int main() {
    
    solve();

}

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    }
}


Measured memory_bytes: 26776
#include <bits/stdc++.h>
using namespace std;
int64_t MOD = pow(10, 9) + 7;

int main()
{
  int64_t N, K, ans = 0;
  cin >> N >> K;
  vector<int64_t> S(N + 2, 0);
  for (int64_t i = 1; i <= N + 1; i++)
  {
    S.at(i) = S.at(i - 1) + i;
  }
  for (int64_t i = K; i <= N; i++)
  {
    int64_t l = S.at(i - 1);
    int64_t r = S.at(N) - S.at(N - i);
    ans = (ans + (r - l + 1)) % MOD;
  }
  cout << (ans + 1) % MOD << endl;
}

Measured memory_bytes: 4768
#include<stdio.h>
int main(){
  long long n,l[87];
  scanf("%lld",&n);
  l[0]=2;
  l[1]=1;
  for(int i=2; i<=n; i++){
    l[i]=l[i-1]+l[i-2];
  }
  printf("%lld\n",l[n]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  rep(i,s.length()){
    s[i] = 'x';
  }
  cout << s<< endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,t;
    cin>>n>>t;
    long long ans=t;
    int s[200000];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=1;i<n;i++){
        ans+=min(s[i]-s[i-1],t);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
s = gets.chomp
a = s[0,2].to_i
b = s[2,2].to_i

if (a == 0 || a > 12) && (b == 0 || b > 12)
  puts "NA"
elsif a >= 1 && a <= 12 && b >= 1 && b <= 12
  puts "AMBIGUOUS"
elsif a > 12 || a == 0
  puts "YYMM"
else
  puts "MMYY"
end


Measured memory_bytes: 1788