akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int H, W;
  while(cin>>H>>W && H){
    vector<string> grid(H);
    REP(i, H) cin>>grid[i];
    bool update = true;
    int vx[26][2], vy[26][2];
    memset(vx, -1, sizeof(vx));
    memset(vy, -1, sizeof(vy));
    REP(y, H)REP(x, W)if(isalpha(grid[y][x])){
      int idx = grid[y][x] - 'A';
      if(vx[idx][0] != -1){
        vx[idx][1] = x, vy[idx][1] = y;
      }else{
        vx[idx][0] = x, vy[idx][0] = y;
      }
    }
    int ans = 0;
    while(update){
      update = false;
      REP(c, 26)if(vx[c][0] != -1){
        //printf("%d %d %d %d\n", vx[c][0], vy[c][0], vx[c][1], vy[c][1]);
        bool ok = true;
        if(vx[c][0] == vx[c][1] && abs(vy[c][0] - vy[c][1]) <= 1) continue;
        if(vy[c][0] == vy[c][1] && abs(vx[c][0] - vx[c][1]) <= 1) continue;
        // x - 0 , y - 1
        for(int x = min(vx[c][0], vx[c][1]); x <= max(vx[c][0], vx[c][1]); x++) if(grid[vy[c][1]][x] != '.' && grid[vy[c][1]][x] != (c + 'A')) ok = false;
        for(int y = min(vy[c][0], vy[c][1]); y <= max(vy[c][0], vy[c][1]); y++) if(grid[y][vx[c][0]] != '.' && grid[y][vx[c][0]] != (c + 'A')) ok = false;
        if(ok) goto GO;

        ok = true;
        for(int x = min(vx[c][0], vx[c][1]); x <= max(vx[c][0], vx[c][1]); x++) if(grid[vy[c][0]][x] != '.' && grid[vy[c][0]][x] != (c + 'A')) ok = false;
        for(int y = min(vy[c][0], vy[c][1]); y <= max(vy[c][0], vy[c][1]); y++) if(grid[y][vx[c][1]] != '.' && grid[y][vx[c][1]] != (c + 'A')) ok = false;
        if(!ok) continue;

      GO:
        //cout<<(char)(c + 'A')<<endl;
        grid[vy[c][1]][vx[c][1]] = '.';
        grid[vy[c][0]][vx[c][0]] = '.';
        memset(vx[c], -1, sizeof(vx[c]));
        memset(vy[c], -1, sizeof(vy[c]));
        ans += 2;
        update = true;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,l,r,a,m,A[41],B[41],L,cnt,R,ans;
vector<ll> v[41],u[41];
ll ch(ll n){
    ll cnt=0;
    for(int i=0;i<20;i++){
        if(((n>>i)&1)==1)cnt++;
    }
    return cnt;
}
int main(void){
    cin>>n>>k>>l>>r;
    m=n;
    n/=2;
    m-=n;
    //cout<<n<<" "<<m<<endl;
    for(int i=0;i<m;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        cin>>B[i];
    }
    for(int i=0;i<(1<<m);i++){
        L=ch(i);
        cnt=0;
        for(int j=0;j<m;j++){
            if(((i>>j)&1)==1){
                cnt+=A[j];
            }
        }
        if(cnt<=r)v[L].push_back(cnt);
    }
    for(int i=0;i<(1<<n);i++){
        L=ch(i);
        cnt=0;
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==1){
                cnt+=B[j];
            }
        }
        if(cnt<=r)u[L].push_back(cnt);
    }
    for(int i=0;i<21;i++){
        if(v[i].size())sort(v[i].begin(),v[i].end());
        if(u[i].size())sort(u[i].begin(),u[i].end());
    }
    for(int i=0;i<=k;i++){
        for(ll x:v[i]){
            L=lower_bound(u[k-i].begin(),u[k-i].end(),l-x)-u[k-i].begin();
            R=upper_bound(u[k-i].begin(),u[k-i].end(),r-x)-u[k-i].begin();
            //cout<<L<<" "<<R<<endl;
            ans+=max(0LL,R-L);
        }
    }
    cout<<ans<<endl;
}



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

int main(void) {
	int N;
	scanf("%d", &N);
	int kouho[4] = {0};
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		if (s == "AC") {
			kouho[0]++;
		} else if (s == "WA") {
			kouho[1]++;
		} else if (s == "TLE") {
			kouho[2]++;
		} else if (s == "RE") {
			kouho[3]++;
		}
	}

	cout << "AC x " << kouho[0] << endl;
	cout << "WA x " << kouho[1] << endl;
	cout << "TLE x " << kouho[2] << endl;
	cout << "RE x " << kouho[3] << endl;

	return 0;
}


Measured memory_bytes: 3700
#define first f
#define second s
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	double sum = 0;
	for (int i = 0; i < n; i++) {
		sum += 1 / double(a[i]);
	}
	cout << 1 / sum;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll dp[(1<<16)+10];
ll memo[(1<<16)+10];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<(1<<16);i++)dp[i]=-inf;
    dp[0]=0;
    V<V<ll>> d(n,V<ll>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)cin>>d[i][j];
    }
    for(int bit=0;bit<(1<<n);bit++){
        ll res=0;
        for(int j=0;j<n;j++){
            if(~bit&(1<<j))continue;
            for(int k=j+1;k<n;k++){
                if(~bit&(1<<k))continue;
                res+=d[j][k];
            }
        }
        memo[bit]=res;
    }
    for(int i=0;i<=n;i++){
        for(int bit=0;bit<(1<<n);bit++){
            if(__builtin_popcount(bit)!=i)continue;
            for(int j=0;j<n;j++){
                if(~bit&(1<<j)){
                    chmax(dp[bit^(1<<j)],dp[bit]+dp[0]);
                    for(int s=bit;s>0;s=(s-1)&bit){
                        chmax(dp[bit^(1<<j)],dp[s^bit]+memo[s^(1<<j)]);
                    }
                }
            }
        }
    }
    cout<<dp[(1<<n)-1]<<"\n";
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main() {
  // input
  int n, odd, even;
  cin >> n;
  even = n/2;
  cerr << odd;
  if (n%2 == 1) odd = n/2+1;
  else odd = n/2;

  int ans = odd*even;
  cout << ans << endl;

  return 0;
}


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

int main(){
  long A,B;
  cin>>A>>B;
  
  long s=max(A,B);
  long t=min(A,B);
  long u;
  while(true){
    u=t;
  	t=s%t;
    s=u;
    if(t==0)
      break;
  }
  long X=A*B/s;
  cout<<X<<endl;
}

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

  cin >> s;
  int n = s.length();

  string s1 = s.substr(0, (n - 1) / 2);
  string s2 = s.substr((n+3)/2-1, n);
  string s3 = s;
  
  string t1 = s1;
  string t2 = s2;
  string t3 = s3;
  reverse(t1.begin(), t1.end());
  reverse(t2.begin(), t2.end());
  reverse(t3.begin(), t3.end());
  if (t1 == s1 && t2 == s2  && t3 == s3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  rep(i, K) ans += a[i];
  // bool ok = false;

  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

int main() {
  long t, a;
  long k;
  
  cin >> t >> a >> k;
  
  if (k >= t) {
    k -= t;
    t = 0;
  } else {
    t -= k;
    k = 0;
  }
  if (k >= a) {
    a = 0;
  } else {
    a -= k;
  }
  cout << t << " " << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
vector<int> edges[100005];
int mod=1e9+7;
ll mul(ll a,ll b){
	return a*b%mod;
}
pair<ll,ll> dfs(int a,int parent){
	ll allwhite=1;
	ll smblack=0;
	for(auto b:edges[a]){
		if(b!=parent){
			pair<ll,ll>p=dfs(b,a);
		
		smblack= (mul(allwhite,p.first)+mul(smblack,p.first+p.second))%mod;
		allwhite*=p.second;
		allwhite%=mod;
		}
	}
	return{allwhite,(allwhite+smblack)%mod};
}

int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	pair<ll,ll>p=dfs(1,-1);
	
	cout<<(p.first+p.second)%mod;
	
	
	
	
	return 0;
	
}


Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

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

    int b[300000], w[300000];

    int i;
    b[0] = 0;
    w[0] = 0;
    for(i = 1; i <= n; i++){
        if(s[i-1] == '.'){
            w[i] = w[i-1]+1;
            b[i] = b[i-1];
        }else{
            w[i] = w[i-1];
            b[i] = b[i-1]+1;
        }
    }

    int ans = 1000000;

    for(i = 0; i <= n; i++){
        ans = min(ans, b[i]+(w[n]-w[i]));
    }

    cout << ans << endl;

}


Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int r; cin >> r;

    if(r < 1200){
        cout << "ABC" << endl;
        return 0;
    }

    if(r < 2800){
        cout << "ARC" << endl;
        return 0;
    }

    cout << "AGC" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int n;
double a[105];
int main()
{
	cin >> n;
	double sum = 0;
	for (int i = 0; i < n; i++)cin >> a[i],sum+=a[i];
	sum =sum/(1.0* n);
	int ans = 0;
	double min = 10000000.0;
	for (int i = 0; i < n; i++)
	{
		if (fabs(a[i] - sum) < min)min = abs(a[i] - sum), ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b || a==c || b==c){
        if(a==b && b==c) {
            cout<<"No";
        }
        else {
            cout<<"Yes";
        }
    }
    else {
        cout<<"No";
    }
}   


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    temp = I()
    if temp == 0:
        print(1)
    else:
        print(0)
if __name__ == "__main__":
    main()

Measured memory_bytes: 67928
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n, t;
    double a;
    cin >> n >> t >> a;
    int h[n];
    double tem, mini=10000;
    int ans;
    for (int i = 0; i < n; i++){
        cin >> h[i];
        tem = t - 0.006*h[i];
        if (mini >= fabs(a - tem)){
            ans = i+1;
        }
        mini = min(mini, fabs(a - tem));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W, K;

  std::cin >> H >> W >> K;

  std::vector<std::string> A(H);

  std::vector<std::vector<int>> B(H, std::vector<int>(W, -1));

  for (auto& s : A)
    std::cin >> s;

  std::vector<int> a;

  for (int i = 0; i < H; i ++) {
    const auto& s = A[i];
    
    if (std::count(ALL(s), '#'))
      a.push_back(i + 1);
  }

  a.back() = H;

  for (int i = 0, size = a.size(), ind = 0; i < size; i ++) {
    int y0 = i == 0 ? 0 : a[i - 1], y1 = a[i];

    std::vector<int> a(W), b(W);

    for (int j = 0; j < W; j ++)
      for (int k = y0; k < y1; k ++)
        a[j] += A[k][j] == '#' ? 1 : 0;

    int j = 0;

    for ( ; j < W; j ++) {
      if (a[j])
        break;

      b[j] = ind;
    }

    for ( ; j < W; ind ++) {
      b[j ++] = ind;
      
      for ( ; j < W; j ++) {
        if (a[j])
          break;

        b[j] = ind;
      }
    }

    for (int j = 0; j < W; j ++)
      for (int k = y0; k < y1; k ++)
        B[k][j] = b[j];
  }

  for (const auto& i : B) {
    for (const auto& j : i)
      std::cout << j + 1 << ' ';
    std::cout << std::endl;
  }

  return 0;
}


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

int main(){
    int i,n,ans=0;
    map<string,int> Map;
    cin >> n;
    for(i=0;i<n;i++){
        string s;
        cin >> s;
        if(Map[s]==0){ans++;Map[s]=1;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19120
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))

    ans = 0
    for i in range(0,N,2):
        if A[i]%2==1:
            ans += 1

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


Measured memory_bytes: 9180
//My_Template

#include<bits/stdc++.h>

#define ll long long int
#define vec vector<long long int>
#define pb(a) push_back(a)
#define myfor(n) for(long long int i = 0; i < n; i++)
#define tc(t) long long int t; cin>>t; while(t--)
#define sortt(a) sort(a.begin(), a.end())
#define summ(a) accumulate(a.begin(), a.end(), 0ll)
#define M 1000000007ll

using namespace std;


int main() {

	//code_goes_here-->

	ll x;
	cin>>x;

	ll k =  1;

	while((k*x) % 360 != 0){
		k++;
	}

	cout<<k;

	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main()
{
    int x, y, z, tmp;

    cin >> x >> y >> z;

    if (x > y)
    {
        tmp = x;
        x = y;
        y = tmp;
    }
    if (y > z)
    {
        tmp = y;
        y = z;
        z = tmp;
    }
    if (x > y)
    {
        tmp = x;
        x = y;
        y = tmp;
    }

    cout << x << " " << y << " " << z << endl;
}


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

int main(){
  string s;
  ll k;
  cin >>s >>k;
  for(ll i = 0; i<min((ll)s.size(), k); i++){
    if(s[i]>='2') {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0; 
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,A,B;cin>>N>>A>>B;
  if(A*B<N)fin(-1);
  if(A+B>N+1)fin(-1);
  std::vector<int> ans(N);
  for(int i=0;i<A;i++)ans[i]=N-A+1+i;
  int res=N-(A+B-1);
  int now=A,mx=N-A;
  for(int i=1;i<B;i++){
    int p=min(res,A-1);
    for(int j=0;j<=p;j++)ans[now+j]=mx-p+j;
    mx-=p+1;now+=p+1;res-=p;
  }
  for(int i=0;i<N;i++)cout<<ans[i]<<" ";cout<<endl;
}


Measured memory_bytes: 4480
#include <iostream>
#include <set>
using namespace std;
int main() {
  int N; cin>>N;
  set<string> S;
  for (int i=0; i<N; i++) {
    string tmp; cin>>tmp;
    S.insert(tmp);
  };
  cout << S.size() << endl;
  return 0;
}

Measured memory_bytes: 19256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner myInput = new Scanner( System.in );
        int n;
        n = myInput.nextInt();
        n %= 10;
        if(n == 3){
            System.out.println("bon");
        }
        else if(n == 0 || n == 1 || n == 6 || n == 8){
            System.out.println("pon");
        }
        else
            System.out.println("hon");


    }
}


Measured memory_bytes: 35580
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long M = sc.nextLong();
        long count_opt =0;
        long price_opt =0;
        ArrayList<Drink> List = new ArrayList<>();
        for(int a=0;a<N;a++){
            long price = sc.nextLong();
            long count = sc.nextLong();
            Drink d = new Drink(price,count);
            List.add(d);
        }
        List.sort(Comparator.comparing(e -> e.price));
        for(Drink d:List){
            if(count_opt+d.count>=M){
                price_opt += (M-count_opt)*d.price;
                break;
            }
            count_opt+=d.count;
            price_opt+=d.count*d.price;
        }
        System.out.println(price_opt);
    }
}

class Drink{
    long price;
    long count;
    public Drink(final long price,final long count){
        this.price = price;
        this.count = count;
    }
}

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

using namespace std;

typedef long long ll;

int main(){
    ll N_, K, Test;

    cin >> N_ >> K;

    priority_queue<ll> H;

    rep(i, N_) {
        cin >> Test;
        H.push(Test);
    }

    if(N_ <= K) cout << 0;
    else{

    rep(i, K) {
        H.pop();
    }
    Test=0;
    while(!H.empty()){
        Test += H.top();
        H.pop();
    }

    cout << Test;

    }
    return 0;
}

Measured memory_bytes: 2420
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


def main():
    N, M = map(int, input().split())
    A, K = [], []
    lst = [list(map(int, input().split())) for _ in range(N)]
    for l in lst:
        A.append(l[0])
        if type(l[1:]) is list:
            K.extend(l[1:])
        else:
            K.append(l[1:])
    print(sum([1 for c in Counter(K).values() if c == len(A)]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007


int main(void)
{
	CIN;
	ll tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>x>>y>>z>>n>>m;
	y=min(x+x,y);
	z=min(y+y,z);
	n=min(n,z+z);
	cout<<m/2*n+(m%2)*z;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int x;
    cin >> x;
    x /= 100;
    string ans = "ai1333";
    ans += string(x,'3');
    cout << ans << endl;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int a,b;cin>>a>>b;
    if(max(a,b)>8)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

int a, b;
int main()
{
	std::cin >> a >> b;

	int k = 50;
	std::cout << k * 2 << " " << k * 2 << std::endl;

	for (int i = 0; i < k - 1; ++i) {
		for (int j = 0; j < 2 * k; ++j) {
			if (i % 2 == 0 && j % 2 == 0 && a > 1) {
				std::cout << ".";
				--a;
			}
			else
				std::cout << "#";
		}
		std::cout << std::endl;
	}

	for (int i = 0; i < 2 * k; ++i)
		std::cout << "#";
	std::cout << std::endl;
	for (int i = 0; i < 2 * k; ++i)
		std::cout << ".";
	std::cout << std::endl;

	for (int i = 0; i < k - 1; ++i) {
		for (int j = 0; j < 2 * k; ++j) {
			if (i % 2 == 0 && j % 2 == 0 && b > 1) {
				std::cout << "#";
				--b;
			}
			else
				std::cout << ".";
		}
		std::cout << std::endl;
	}

	return 0;
}


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



int main(void) {

	int n;
	cin >> n;

	int x;
	for(int i=1;i<=n;i++) {
		if(i % 3 == 0)	cout << " " << i;
		else {
			x = i;
			while(x != 0) {
				if(x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;

	return 0;
}

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

#define ll long long

string N;

int main(){
	cin >> N;
	int sm = 0;
	for (auto n : N){
		sm += (n - '0')%9;
		sm %= 9;
	}
	cout << (sm == 0 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = ll;

using namespace std;
int amin(int* array, int length) {
	int ret = INF;
	rep(i, 0, length)
		ret = min(ret, array[i]);
	return ret;
}
template<typename T>
void acin(T* array, int length){
	rep(i, 0, length){
		cin >> array[i];
	}
}
int main() {
	vint w(10), k(10);
	rep(i, 0, 10)
		cin >> w[i];
	rep(i, 0, 10)
		cin >> k[i];
	vsort(w);
	vsort(k);
	cout << w[9] + w[8] + w[7] << " " << k[9] + k[8] + k[7] << endl;

	return 0;
}

Measured memory_bytes: 3140
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
long gcd(long m,long n){if(n==0)return m;return gcd(n,m%n);}
int main()
{
	long n,a,s;
	cin>>n>>s;
	for(int i=1;i<n;i++)
	{
		cin>>a;
		s=gcd(s,a);
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
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;
}
using namespace std;

template<typename T>
struct SegmentTree{//セグ木によるRMQ
  private:
      int n;
      vector<T>node;
      T MAXV=numeric_limits<T>::max();

  public:
      SegmentTree(vector<T>v){
        //構築O(N)

        int sz=v.size();
        n=1;
        while(n<sz)n*=2;//nは配列のサイズ以上となる最小の2の冪
        node.resize(2*n-1,MAXV);

        //最下段から順番に値を代入していく
        for(int i=0;i<sz;i++)node[i+n-1]=v[i];
        //最下段までにn-1個のノードがある

        for(int i=n-2;i>=0;i--)node[i]=min(node[2*i+1],node[2*i+2]);
        //自分の子を参照
      }

      void update(int k,T val){//値の更新
        //最下段のノードにアクセス
        k+=(n-1);

        node[k]=val;
        //あとはのぼりながら更新
        while(k>0){
          k=(k-1)/2;//親
          node[k]=min(node[2*k+1],node[2*k+2]);
        }
      }

      T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        //クエリ[a,b),今見ている節点番号k,それに対応する区間[l,r)

        //[a,b)と[l,r)が交差しないとき
        if(r<=a||l>=b)return MAXV;

        //[a,b)が[l,r)を完全に被覆するとき
        if(a<=l&&b>=r)return node[k];//対象区間のノードの値を返す

        //一部を被覆するとき,子について探索を行う
        T vl=query(a,b,2*k+1,l,(l+r)/2);
        T vr=query(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
      }
};


void solve(){
  int n,q;
  cin>>n>>q;
  ll val=(ll)pow(2,31);
  val--;
  vector<ll>v(n,val);
  SegmentTree<ll>sg(v);
  while(q--){
    int com;
    int x;
    ll y;
    cin>>com>>x>>y;
    if(com==0)sg.update(x,y);
    else {
      ll ans=sg.query(x,y+1,0,0,-1);//yの区間に注意
      cout<<ans<<"\n";
    }
  }
  return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}


Measured memory_bytes: 6564
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  int N, D;
  cin >> N >> D;
  int k {};
  for (int c = 0;c < N;) {
    c += 2*D+1;
    ++k;
  }
  cout << k << '\n';
}


Measured memory_bytes: 256
from string import ascii_lowercase as alph
N = int(input())
A = list(alph)

ans = []

def sol(n):
    global ans

    q, r = divmod(n, 26)
    ans.append(A[r])
    if q > 0:
        sol(q - 1)

sol(N - 1)
print(''.join(ans[::-1]))


Measured memory_bytes: 9960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    bool chk = 1;
    int cnt = 0;
    for (int i = 1; i * (i + 1) <= 2 * n; i++) {
        if (i * (i + 1) == 2 * n) {
            chk = 0;
            cnt = i + 1;
        }
    }
    if (chk) {
        cout << "No\n";
        return 0;
    }
    vector<vector<int>> vec(cnt);
    bool seen[n] = {};
    int now = 0;
    rep(i, 0, cnt) {
        rep(j, 0, i) {
            rep(k, 0, cnt - 1) {
                if (!seen[vec[j][k] - 1]) {
                    vec[i].push_back(vec[j][k]);
                    seen[vec[j][k] - 1] = 1;
                    break;
                }
            }
        }
        rep(j, i, cnt - 1) { vec[i].push_back(++now); }
    }
    cout << "Yes\n" << cnt << "\n";
    rep(i, 0, cnt) {
        cout << cnt - 1 << " ";
        rep(j, 0, cnt - 1) { cout << vec[i][j] << " "; }
        cout << "\n";
    }
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n, m, x;
    cin >> n >> m >> x;
    vector<vector<Int>> v(n, vector<Int>(m));
    vector<Int> c(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> c[i];
        for (Int j = 0; j < (Int)m; j++) {
            cin >> v[i][j];
        }
    }
    Int res = INF;
    for (Int bit = 0; bit < (Int)(1<<n); bit++) {
        vector<Int> skill(m, 0);
        for (Int i = 0; i < (Int)n; i++) {
            if (bit & (1<<i)) {
                for (Int j = 0; j < (Int)m; j++) {
                    skill[j] += v[i][j];
                }
            }
        }
        bool check = true;
        for (Int i = 0; i < (Int)m; i++) {
            if (skill[i] < x) {
                check = false;
            }
        }
        if (check) {
            Int cost = 0;
            for (Int i = 0; i < (Int)n; i++) {
                if (bit & (1<<i)) {
                    cost += c[i];
                }
            }
            res = min(res, cost);
        }
    }
    print(res == INF ? -1 : res);
    return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (auto& h: H) {
        cin >> h;
    }
    vector<ll> dp(N, LLONG_MAX);
    dp[0] = 0;
    for (ll i = 1; i < N; ++i) {
        for (ll j = max(0ll, i - K); j < i; ++j) {
            dp[i] = min(dp[i], dp[j] + abs(H[i]-H[j]));
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
L, R = map(int,input().split())
mod = 2019

ans = 2019
if R - L >= 2019:
  print(0)
else:
  for i in range(L, R):
    for j in range(i+1, R+1):
      val = ((i%mod) * (j%mod))%mod
      ans = min(ans, val)
  print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int a,i,k=0,j=0;
    for(i=0;i<3;i++)
    {
        cin>>a;
        if(a==5)
            k++;
        if(a==7)
            j++;
    }
    if(k==2&&j==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;

}


Measured memory_bytes: 256
function Main(input){
	input = ""+input.split("\n")[0]*1;
  if(input[1]==input[2]){
  	if(input[0]==input[1] || input[2]==input[3]){
    	return "Yes"
    }
  }
  return "No"
}

console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 11468
function main()
	N,M,K=map(x->parse(Int,x),split(readline()))
	ans=0
	md=998244353
	fac=Int[1]
	for i=1:N
		push!(fac,fac[end]*i%md)
	end
	for i=0:K
		ans+=M*powermod(M-1,N-i-1,md)%md*fac[N]%md*powermod(fac[N-i]*fac[i+1]%md,md-2,md)%md
	end
	println(ans%md)
end
main()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<pll> p(N);
    REP(i, N){
    	cin >> p[i].first >> p[i].second;
    }

    ll M = 5000000;
    double kaku = 2*M_PI/M;
    double res = -1;
    REP(i, M){
    	double now = 0.01 + i*kaku;
    	double x = sin(now);
    	double y = cos(now);
    	double x_tmp = 0, y_tmp = 0;
    	//dump(now)
    	//dump(x)
    	//dump(y)
    	REP(j, N){
    		if(p[j].first * x + p[j].second * y >=0 ) x_tmp += p[j].first, y_tmp += p[j].second;
    	}
    	res = max(res, sqrt(x_tmp * x_tmp + y_tmp * y_tmp));
    	//dump(res)
    }
    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 512
#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 << "Balanced" << endl;
  }
  else if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B < C+D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,q,i,j,fa[100005],typ[100005],px[100005],py[100005],pz[100005],u,v,f,l;
long long fnd(long long x)
{
	if(fa[x]==x) return x;
	return fa[x]=fnd(fa[x]);
}
int main()
{
	scanf("%lld%lld%lld",&n,&m,&q);
	fz1(i,n){
		fa[i]=i;
	}
	fz1(i,q){
		scanf("%lld%lld%lld",&px[i],&py[i],&pz[i]);
		px[i]++;py[i]++;
		if(pz[i]==0){
			long long x=fnd(px[i]),y=fnd(py[i]);
			if(x!=y){
				fa[x]=y;
				u++;
			}
		}
	}
	fz1(i,q){
		if(pz[i]==1){
			if(fnd(px[i])==fnd(py[i])){
				puts("No");
				return 0;
			}
			typ[fnd(px[i])]=typ[fnd(py[i])]=1;
		}
	}
	fz1(i,n){
		if(fnd(i)==i){
			l++;
			if(typ[i]){
				f=1;
			}
		}
	}
	if(l==2&&f==1){
		puts("No");
		return 0;
	}
	v=l*(l-1)/2+u;
	u+=l-1+f;
	if(u<=m&&m<=v) puts("Yes"); else puts("No");
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 2e5+9;
int s[N],f[N];

int main(void) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for(int i =0; i < n; ++i) cin >>s[i],f[i]=s[i];
  sort(f,f+n,greater<int>());
  int a = f[0],b=f[1];
  for(int i =0; i < n; ++i){
    cout << (s[i]!=a?a:b) <<endl;
  }
  return 0;
}


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

int main() {
    string A, B;
    cin >> A >> B;

    int ans = 0;
    if (A[0] == B[0]) ans++;
    if (A[1] == B[1]) ans++;
    if (A[2] == B[2]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

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

    vector<vector<int>> bit(N, vector<int>(20, 0));
    for(int i=0; i<N; ++i){
        for(int j=0; j<20; ++j){
            if(a[i]&1<<j) bit[i][j] = 1;
        }
    }

    ll ans = 0;
    vector<int> tmp(20, 0);
    int right = 0;
    for(int left=0; left<N; ++left){
        while(right < N){
            bool ok = true;
            for(int i=0; i<20; ++i) if(bit[right][i] && tmp[i]) ok = false;

            if(ok == false){
                break;
            }
            else{
                for(int i=0; i<20; ++i) if(bit[right][i] == 1) tmp[i] = 1;
                ++right;
            }
        }
        ans += right - left;
        for(int i=0; i<20; ++i) if(bit[left][i] == 1) tmp[i] = 0;
        // cout << "left: " << left << endl;
        // cout << "right: " << right << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 24448
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int a[] = {0,2,0,1,0,1,0,0,1,0,1,0};
    int x, y;
    cin >> x >> y;
    cout << (a[x-1] == a[y-1] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

ll cal(ll num)
{
  ll res=0;
  while(num>0)
  {
    res+=num%10;
    num/=10;
  }
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<ll>res;
  ll k;cin>>k;
  rep(i,13)
  {
    ll ten=pow(10,i);
    rep(j,1000)res.push_back(ten*j+ten-1);
  }
  sort(all(res));
  res.erase(unique(all(res)),res.end());
  double mi=1e15;
  for(ll i=res.size()-1;i>=0;i--)
  {
    if(mi>=(double)res[i]/cal(res[i]))mi=(double)res[i]/cal(res[i]);
    else res[i]=0;
  }
  rep(i,k){if(res[i]>0)cout<<res[i]<<endl;else k++;}

  return 0;

}


Measured memory_bytes: 640
program main
  implicit none
  
  integer :: a(3),i,n,big,t,j
  read(*,*)a(1),a(2),a(3)
  read(*,*)n
  
  do i=1,2
     do j=i+1,3
        if(a(i) .gt. a(j))then
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  
  do i = 1, n
    a(3) = a(3)*2
  end do
  
  write(*,*)sum(a)
end program main
  

Measured memory_bytes: 512
from math import ceil


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    target = float("inf")
    target_index = []
    for i in range(n):
        if a[i] < target:
            target = a[i]
            target_index.append(i)
    answer = float("inf")
    for t in target_index:
        answer = min(answer, ceil(t / (k - 1)) + ceil((n - t - 1) / (k - 1)))
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 13812
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print (0)
    exit(0)
p = 1
for i in range(n):
    p *= a[i]
    if p>10**18:
        break
if p>10**18:
    p = -1
print (p)


Measured memory_bytes: 21592
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner scanner = new Scanner(System.in);
      
      	int five = 0;
      	int seven = 0;
      
      	for(int i = 0; i < 3; i++) {
        	int number = scanner.nextInt();
          
          	if(number == 5) {
            	five = five + 1;
            } else if(number == 7) {
            	seven = seven + 1;
            }
        }
         
      	if(five == 2 && seven == 1) {
        	System.out.println("YES");
          	return;
        }
          
       	System.out.println("NO");  	
	}
}
 

 



Measured memory_bytes: 23124
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
M = max(d.values())
keys = [k for k, v in d.items() if v == M]
keys.sort()
for key in keys:
    print(key)

Measured memory_bytes: 94424
extern crate core;

use std::io::{self, Read};
use std::cmp::{max, min};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split_whitespace()
        .map(|x| x.parse::<i64>().unwrap())
        .collect::<Vec<_>>();
    let n = list[0];
    let m = list[1];
    if n == 1 && m == 1 {
        1
    } else if n == 1 || m == 1 {
        //1でない辺
        let l = max(n, m);
        l - 2
    } else {
        //両方2以上
        //囲まれている個数
        let a = (n - 2) * (m - 2);
        //辺の個数
        let b = (n - 2) * 2 + (m - 2) * 2;
        //角の個数
        let c = 4;
        a
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "2 2" => "0",
    test2: "1 7" => "5",
    test3: "314 1592" => "496080",
}


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

int main() {
  int a,b,c,d;
  string l="Left",m="Balanced",r="Right";
  cin >> a >> b >> c >> d;
  if ((a+b)>(c+d)) {
    cout << l << endl;
  }
  else if ((a+b)<(c+d)) {
    cout << r << endl;
  }
  else {
    cout << m << endl;
  }
}

Measured memory_bytes: 256
import math


def main():
    a, b = map(int, input().split())
    array = list(map(int, input().split()))

    cnt = 1
    ans = 0
    array2 = []
    zero_flg = 0

    if len(array) != 0:
        for i in range(len(array)):
            if a == array[i]:
                zero_flg = 1

    if zero_flg == 0:
        ans = a
    else:
        if ans == 0:
            while True:
                for i in range(len(array)):
                    if (a + cnt == array[i]) or (a - cnt == array[i]):
                        array2.append(array[i])
                if len(array2) != 2:
                    break
                cnt += 1
                array2.clear()

        if len(array2) == 0:
            if a + cnt < a - cnt:
                ans = a + cnt
            else:
                ans = a - cnt
        elif len(array2) == 1:
            if array2[0] == a + cnt:
                ans = a - cnt
            else:
                ans = a + cnt

    print(ans)


if __name__ == "__main__":
    main()

   

Measured memory_bytes: 9060
#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()
{
	int n;
	string s;
	cin >> n >> s;
	int ans=0;
	rep(i, n - 2)
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
		{
			ans++;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3576
N = int(input())
P = list( map( int, input().split()))
P.insert(0,0)
ans = 0
cnt = 0
for i in range(1,N+1):
    if P[i] == i:
        cnt += 1
        if cnt == 2:
            ans += 1
            cnt = 0
    elif cnt == 1:
        ans += 1
        cnt = 0
if cnt == 1:
    ans += 1
print(ans)

Measured memory_bytes: 14008