akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	vt n, m;
	cin >> n >> m;
	priority_queue<vt> a;
	rep(i, n) {
		vt x;
		cin >> x;
		a.push(x);
	}
	rep(i, m) {
		vt x;
		x = a.top() / 2;
		a.pop();
		a.push(x);
	}
	vt s = 0;
	rep(i, n) {
		s += a.top();
		a.pop();
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



#define INF INT_MAX/2
int N, K;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;

    queue<int> que;
    que.push(1);

    rep(i, 0, N) {
        queue<int> q;

        while (!que.empty()) {
            int x = que.front(); que.pop();
            q.push(x * 2);
            q.push(x + K);
        }

        swap(que, q);
    }

    int ans = INF;
    while (!que.empty()) {
        int x = que.front(); que.pop();
        ans = min(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
A=[[0,0,0] for i in range(0,3)]
for i in range(0,3):
  A[i]=list(map(int,input().split()))
N=int(input())
b=[0 for i in range(0,N)]
for i in range(0,N):
  b[i]=int(input())
 
bingo=[[0,0,0] for i in range(0,3)]
for i in range(0,3):
  for j in range(0,3):
    if A[i][j] in b:
      bingo[i][j]=1

flag=0
for i in range(0,3):
  if bingo[i][0]*bingo[i][1]*bingo[i][2]==1:
    flag=1
for i in range(0,3):
  if bingo[0][i]*bingo[1][i]*bingo[2][i]==1:
    flag=1
if bingo[0][0]*bingo[1][1]*bingo[2][2]==1:
  flag=1
if bingo[0][2]*bingo[1][1]*bingo[2][0]==1:
  flag=1

if flag==1:
  print('Yes')
else:
  print('No')

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

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

long long MOD = 1000000000 + 7;
template<class T>
using MaxHeap = std::priority_queue<T>;

int main(){
  cout << setprecision(10);

  MaxHeap<ll> pq;
  int N, M; cin >> N >> M;

  vector<pair<ll,ll>> v(N);

  for(int i = 0; i < N; i++){
    ll x,y; cin >> x >> y;
    v[i] = make_pair(x,y);
  }

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

  int index = 0;
  ll ans = 0;
  for(int i = 0; i <= M; i++){
    // i日以下の仕事をpqに追加する
    while(v[index].first <= i && index <= N-1){
      pq.push(v[index].second);
      index++;
    }

    if(pq.empty()) continue;

    ans += pq.top();
    // cerr << i << " " << pq.top() << endl;
    pq.pop();
  }
  cout << ans << endl;

}


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

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

    int aa = 1;
    int bb = 1;

    for(int i = 0; i < a; i++){
        aa *= 10;
    }
    for(int i = 0; i < b; i++){
        bb *= 10;
    }
    aa /= 10;
    bb /= 10;

    int ans_a = 0;
    int ans_b = 0;

    for(int i = b; 0 < i; i--){
        ans_a += bb * a;
        bb /= 10;
    }
    for(int i = a; 0 < i; i--){
        ans_b += aa * b;
        aa /= 10;
    }

    int ans;
    ans = max(ans_a, ans_b);
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k: i64 = read();
    let q: i64 = read();

    let a: Vec<usize> = (0..q).map(|_| read()).collect();

    let mut ans: Vec<i64> = vec![k-q;n];

    for i in a.iter() {
        ans[*i-1] += 1;
    }

    for i in ans.iter() {
        if *i > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 6780
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

ans = 0
hands = []
for i in range(N):
    if i < K:
        # グー
        if T[i] == 'r':
            ans += P
            hands.append('p')
        # チョキ
        elif T[i] == 's':
            ans += R
            hands.append('r')
        # パー
        else:
            ans += S
            hands.append('s')
    else:
        if T[i] == 'r':
            if hands[i-K] != 'p':
                ans += P
                hands.append('p')
            else:
                if i + K <= N - 1:
                    hands.append('-')
                else:
                    hands.append('-')
        # チョキ
        elif T[i] == 's':
            if hands[i-K] != 'r':
                ans += R
                hands.append('r')
            else:
                if i + K <= N - 1:
                    hands.append('-')
                else:
                    hands.append('-')
        # パー
        else:
            if hands[i-K] != 's':
                ans += S
                hands.append('s')
            else:
                if i + K <= N - 1:
                    hands.append('-')
                else:
                    hands.append('-')

print(ans)

Measured memory_bytes: 4792
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <bitset>
#include <iostream>
using namespace std;




int main()
{   
    // freopen("in","r",stdin);
    int n;
    while(scanf("%d",&n)&&n){
        int dist[10][10];
        int a,b,c,V = 0;
        memset(dist,0x3f,sizeof(dist));
        for(int i=0;i<n;i++){
            scanf("%d%d%d",&a,&b,&c);
            dist[a][b]=dist[b][a]=c;
            V = max(V,max(a+1,b+1));
        }
        for(int i=0;i<V;i++)
            dist[i][i] = 0;

        for(int k=0;k<V;k++){
            for(int i=0;i<V;i++){
                for(int j=0;j<V;j++){
                    if(dist[i][k]+dist[k][j]<dist[i][j]){
                        // printf("%d = %d + %d\n",dist[i][j],dist[i][k],dist[k][j]);
                        dist[i][j] = dist[i][k]+dist[k][j];
                    }
                }
            }
        }
        int ans = 1e8,id;
        for(int i=0;i<V;i++){
            int res = 0;
            for(int j=0;j<V;j++){
                res += dist[i][j];
            }
            if(res < ans){
                ans = res;
                id = i;
            }
        }
        printf("%d %d\n",id,ans);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   ll a;
   cin>>a;
   cout<<3*(a*a)<<endl;
   return 0;
   
}


Measured memory_bytes: 256
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


x,y=MAP()
if y>=2*x and y<=4*x and y%2==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s;
int ok[200005];
vector<P>vec;
ll ans;
int main(){
	cin >> s;
	if(s.size() <= 2){
		puts("0"); return 0;
	}
	rep(i,s.size()) if(s[i] == 'A') ok[i] = 1;
	rep(i,s.size()-1) if(s[i] == 'B' && s[i+1] == 'C') ok[i] = ok[i+1] = 2;
	
	int beg = INF,en = -INF;
	rep(i,s.size()){
		if(!ok[i]){
			if(beg <= en) vec.pb(P(beg,en));
			beg = INF,en = -INF;
		}
		else{
			beg = min(beg,i);
			en = max(en,i);
		}
	}
	if(beg <= en) vec.pb(P(beg,en));
	
	rep(i,vec.size()){
		int cur = 0;
		for(int j=vec[i].sc;j>=vec[i].fi;j--){
			if(ok[j] == 2) cur++;
			else ans += cur/2;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1920
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	double N, T, A;
	double H[10000];
	double near = 10000;
	int ans = 0;
	cin >> N >> T >> A;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		if (fabs(A - (T - H[i] * 0.006)) < near) {
			near = fabs(A - (T - H[i] * 0.006));
			ans = i + 1;
		}
	}
	cout << ans << endl;

	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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 const INF = 1 << 30;


int main()
{
    ll k;
    cin >> k;
    int x,n;
    cin >> x >> n;
    vector<int> to(n);
    rep(i,n) to[i] = ((ll)i*i) % n;

    vector<int> seen(n,-1);
    vector<int> path(n);
    int s;
    int cur = x;
    int sz = 0;
    for(;;sz++) {
        if(seen[cur] != -1) {
            s = seen[cur];
            break;
        }
        else {
            seen[cur] = sz;
            path[sz] = cur;
            cur = to[cur];
        }
    }

    ll res = 0;
    if(k <= s) {
        rep(i,k) res += path[i];
        cout << res << endl;
    }
    else {
        rep(i,s) res += path[i];
        k = k - s;
        ll sum = 0;
        ll h = k / (ll)(sz-s);
        for(int i = s; i < sz; ++i) sum += path[i];
        res += (sum * h);
        ll w = k % (sz-s);
        for(int i = s; i < s + w; ++i) res += path[i];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4288
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
agc012 C
"""


n = int(input())
m = len(bin(n+1))-2
n = n-(2**(m-1)-1)


fact = []
tmp = 1
for i in range(1, m+2):
    fact.append(tmp)
    tmp = tmp*i

binom = [[0]*(m+1) for i in range(m+1)]
for i in range(m+1):
    for j in range(i+1):
        binom[i][j] = (fact[i]//(fact[j]*fact[i-j]))

binomsums = []
for j in range(m//2+1):
    tmp = 1
    for i in range(1, j+1):
        tmp += binom[j][i]*binom[m-j][i]
    binomsums.append(tmp)

a = [0]*(m//2+1)
ind = m//2
while n != 0:
    b = binomsums.pop()
    c, n = divmod(n, b)
    a[ind] = c
    ind -= 1

ans = []
i = 2
for j in range(m//2+1):
    for k in range(a[j]):
        ans.append(i)
        i += 1
    ans.append(1)
ans = ans + [1 for j in range(m-m//2-1)]
i -= 1
while i >= 2:
    ans.append(i)
    i -= 1
print(len(ans))
print(" ".join(map(str, ans)))


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

int main() {
  int N, cnt = 0;
  bool odd_flg = false;
  cin >> N;

  vector<int> vec(N, 0);
  
  for(int i = 0; i < N; i++) {
    cin >> vec[i];
  }

  while(true) {
    for(int i = 0; i < N; i++) {
      if(vec[i] % 2 != 0) {
        odd_flg = true;
      }
    }
    if(odd_flg == true) {
        break;
    }
    
    for(int i = 0; i < N; i++) {
      vec[i] /= 2;
    }

    cnt++;
  }
 cout << cnt << endl;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  if (n == 1) {
    std::cout << "Hello World" << "\n";
  } else {
    int a, b; std::cin >> a >> b;
    std::cout << a+b << "\n";
  }
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
		long startCpuTime = threadMXBean.getCurrentThreadCpuTime(), stopCpuTime = 0;

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\2008-input.txt"));

		while (scan.hasNext()) {

			int n = scan.nextInt();
			int hx = scan.nextInt();
			int hy = scan.nextInt();
			int dx = scan.nextInt();
			int dy = scan.nextInt();
			if (n == 0)
				break;
			Map mp = new Map(n, hx, hy, dx, dy);
			for (int i = 0; i < n; i++)
				mp.add(i, scan.nextInt(), scan.nextInt());
			if (mp.result(0, n, hx, hy))
				System.out.println("YES");
			else
				System.out.println("NO");
			// stopCpuTime = threadMXBean.getCurrentThreadCpuTime();

		}

		scan.close();
		// stopCpuTime = threadMXBean.getCurrentThreadCpuTime();
		// System.out.println("CPU=" + (stopCpuTime - startCpuTime) / 1000000);

		System.exit(0);
	}
}

class Map {
	int Dx, Dy;
	int[] Cx, Cy;
	boolean[] Cs;
	double[] Ct;

	public Map(int n, int hx, int hy, int dx, int dy) {

		Dx = dx;
		Dy = dy;
		Cx = new int[n];
		Cy = new int[n];
		Cs = new boolean[n];
		Ct = new double[n];
	}

	public boolean result(double t, int n, int hx, int hy) {
		// System.out.println(n + ":" + hx + " " + hy);
		if (n == 0)
			return true;

		for (int i = 0; i < Cs.length; i++)
			if (Cs[i]) {
				double nt = Math.sqrt(Math.pow(Cx[i] - hx, 2) + Math.pow(Cy[i] - hy, 2));
				if (t + nt >= Ct[i])
					return false;
			}

		for (int i = 0; i < Cs.length; i++)
			if (Cs[i]) {
				double nt = Math.sqrt(Math.pow(Cx[i] - hx, 2) + Math.pow(Cy[i] - hy, 2));
				Cs[i] = false;
				if (result(t + nt, n - 1, Cx[i], Cy[i]))
					return true;
				Cs[i] = true;
			}

		return false;
	}

	public void add(int i, int cx, int cy) {
		Cx[i] = cx;
		Cy[i] = cy;
		Cs[i] = true;
		Ct[i] = Math.sqrt(Math.pow(cx - Dx, 2) + Math.pow(cy - Dy, 2));
	}
}

Measured memory_bytes: 32064
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
// const int imax = 100000;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	rep(i,n) cin >> a[i];
	sort(a,a+n);
	int mina;
	int cnt = n;
	while(a[1]!=mina+1){
		mina = a[0];
		for(int i = 1; i < n; i++){
			a[i] %= mina;
			if(a[i]==0){
				cnt--;
				a[i] += mina + 1;
			}
		}
		sort(a,a+n);
		n = cnt;
	}
	printf("%lld\n",a[0]);
	return 0;
}




Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint N, K;
  cin >> N >> K;

  vector<lint> p(N);
  for(auto& elem : p) cin >> elem;

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

  cout << accumulate(p.begin(), p.begin() + K, 0LL) << endl;
}

Measured memory_bytes: 3604
public class Main {
  private static void solve() {
    char[] n = ns();
    int[] count = new int[10];
    
    for (char c : n) {
      count[c - '0'] ++;
    }
    for (int v : count) {
      if (v == 4 || (v == 3 && n[1] == n[2])) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

int main(){
int a,b,c;
int count = 0;

cin >> a >> b >> c;

for(int i = b; i >= a; i--){
if(c % i == 0){
count++;
}
}

cout << count << endl;

return 0;
}


Measured memory_bytes: 3104
//ABC045B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	char p = 'a';
	int i = -1, j = -1, k = -1;
	while(1){
		if(p == 'a'){
			i++;
			if(i == sa.size()){
				cout << "A" << endl;
				return 0;
			}
			p = sa.at(i);
		}else if(p == 'b'){
			j++;
			if(j == sb.size()){
				cout << "B" << endl;
				return 0;
			}
			p = sb.at(j);
		}else{
			k++;
			if(k == sc.size()){
				cout << "C" << endl;
				return 0;
			}
			p = sc.at(k);
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   double d,t,s;
   cin>>d>>t>>s;
   if((d/s)<=t)
   {
       cout<<"Yes"<<endl;
   }
   else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3732
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    L=[0]*N
    
    #売り:1
    for i in range(1,N):
        if A[i]>A[i-1]:
            L[i]=1
            if L[i-1]==1:
                L[i-1]=0
            else:
                L[i-1]=2
                
    mon=1000
    kabu=0
    
    for i in range(N):
        if L[i]==2:
            kabu=mon//A[i]
            mon-=kabu*A[i]
        elif L[i]==1:
            mon+=kabu*A[i]
            kabu=0
            
    print(mon)
                
    

main()


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

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

    set<int> pool;
    for (int i = 0; i < N; ++i) {
        int temp;
        cin >> temp;
        pool.insert(temp);
    }

    cout << pool.size() << endl;
    return 0;
}

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

int main(){
  int n;string x;
  cin >> n;
  vector<string> music(n);
  vector<int> time(n);
  for(int i=0;i<n;i++){
    cin >> music.at(i) >> time.at(i);
  }
  cin >> x;
  for(int i=0;i<n;i++){
    if(x == music.at(i)){
      int totaltime = 0;
      for(int j=n-1;j>i;j--){
        totaltime += time.at(j);
      }
      cout << totaltime << endl;
      break;
    }
    else {
      continue;
    }
  }
}
    
  
  

Measured memory_bytes: 256
using System;

namespace _0592
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[5];
            for (int i = 0; i < 5; i++)
            {


                a[i] = int.Parse(Console.ReadLine());
                if (a[i] < 40) { a[i] = 40; }
            }
            Console.WriteLine((a[0] + a[1]+a[2]+a[3]+a[4]) / 5);
        }
    }
}

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   string s;
   cin >> s;
   if (s.size() == 1) {
      cout << s[0];
      return 0;
   }
   int kol = s[0] - '1' + (s.size() - 1) * 9, sum = 0;
   for (int i = 0; i < s.size(); i++) {
      sum+= s[i] - '0';
   }
   cout << max(kol, sum);
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <unordered_map>
#include <iomanip>
#include <math.h>
#include <cmath>

#define PI 3.14159265359

using namespace std;
#define ASCII 97


int main() {
	long double A;
	int N, M;
	cin >> N >> M;

	std::map <std::pair<long double,int>, std::pair<long int, int >> money;

	for (int i = 0; i < N; i++) {
		cin >> A;
		money[{A, i}] = { A,0 };
	}

	for (int i = 0; i < M; i++) {
		int huda = (--money.end())->second.second;
		long int motone = (--money.end())->second.first;
		int index = (--money.end())->first.second;
		huda++;
		long double pal = (--money.end())->first.first;
		pal /= 2.0;
		money.erase(--money.end());
		money[{pal,index}] = { motone,huda };
	}

	long long int allSum = 0;
	for (auto m : money) {
		allSum += m.second.first /(int)std::pow(2.0, (double)m.second.second);
	}
	cout << allSum << endl;

}



Measured memory_bytes: 9600
#include<iostream>
using namespace std;
long long a[300010];
int main()
{
	long long n,t=1;	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	long long ans=0 , mod=1000000007;
	for(int i=62;i>=0;i--)
	{
		long long one=0 , zero=0;
		for(int j=1;j<=n;j++){
			if(a[j]&1) one++;
			else zero++;
			a[j]/=2;
		}
		ans+=(((one*zero)%mod)*t)%mod , ans%=mod , t*=2 , t%=mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;

struct Edge { int to; ll cost; };
vector<Edge> G[100010];
ll INF = 1e18;

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

  int V, E; cin >> V >> E;
  vector<ll> d(V, INF);
  int v0; cin >> v0;

  for (int i = 0; i < E; i++) {
    int a, b; cin >> a >> b; // a--; b--;
    ll c; cin >> c;
    G[a].emplace_back(Edge({b, c}));
    // G[b].emplace_back(Edge({a, c}));
  }

  priority_queue<P, vector<P>, greater<P>> q;
  d[v0] = 0;
  q.push(P(0, v0));

  while (!q.empty()) {
    P p = q.top(); q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      Edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        q.push(P(d[e.to], e.to));
      }
    }
  }

  for (int i = 0; i < V; i++) {
    if (d[i] == INF) cout << "INF\n";
    else cout << d[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 19528
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q5(){
	int n;
	cin>>n;
	if(n<10 || n&1){
		cout<<"0\n";
		return ;
	}
	int ans=0;
	int num=10;
	int xp=num;
	while(num<=n){
		ans+=n/num;
		num*=5;
	}
	cout<<ans<<endl;
}
void q3(){
	int a,b;
	cin>>a>>b;
	int g=__gcd(a,b);
	a*=b;a/=g;
	cout<<a;
}
void q1(){
	int a,b;
	cin>>a>>b;
	cout<<6-a-b;
}
void q2(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;++i)
	cout<<s[i]<<t[i];
}
void solve(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;++i)
	cin>>arr[i];
	int idx=-1;
	int ans=0;
	for(int i=0;i<n;++i){
		if(arr[i]==1){
			idx=i;
			break;
		}
	}
	if(idx==-1){
		cout<<idx;
		return ;
	}
	ans+=idx-0;
	int num=2;
	int pre=idx;
	for(int i=idx;i<n;++i){
		if(arr[i]==num){
			num++;
			ans+=i-pre-1;
			pre=i;
		}
	}
	ans+=n-1-pre;
	cout<<ans;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;//cin>>t;
	t=1;
	while(t--)//
	solve();
	return 0;
}


Measured memory_bytes: 1792
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int> > connected(n,std::vector<int>());
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		connected[a].emplace_back(b);
	}
	std::vector<std::vector<int> >dist(n,std::vector<int>(3,0));
	int s,t;
	std::cin >> s >> t;
	s--;t--;
	std::queue<std::pair<int,int> > que;
	que.emplace(s,0);
	while(!que.empty()) {
		auto current = que.front();
		que.pop();
		if(current.second==0&&current.first==t) {print(dist[current.first][current.second]/3);return 0;}
		for(auto& p:connected[current.first]) {
			if(dist[p][(current.second+1)%3])continue;
			dist[p][(current.second+1)%3] = dist[current.first][current.second]+1;
			que.emplace(p,(current.second+1)%3);
		}
	}
	print(-1);
	return 0;
}


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

int main()
{
  int n, ans = 0, m = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    int p;
    cin >> p;
    ans += p;
    m = max(m, p);
  }

  ans -= m/2;
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)


int main()
{
	long long x, y;
	cin >> x >> y;
	int res = 0;
	for (long long i = x; i <= y; i*=2) res++;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int input(int n){
    string ss[] = {"Vacent", "Male", "Female"};
    cout << n << endl;
    string str;
    cin >> str;
    if(str == ss[0])exit(0);
    if(str == ss[1])return 1;
    else return 2;
    
}
main(){
    int N;
    cin >> N;
    
    int l = 0, r = N-1;
    int vl = input(l), vr = input(r);
    while(r - l >= 3){
        //[l,r]→[l,k], [k,r]
        int k = (l + r) / 2;
        int vk = input(k);
        //[l,k]にVacentがあるとき
        if(((k-l) % 2 == 0) ^ (vl == vk) ){
            r = k;
            vr = vk;
        }else{
            l = k;
            vl = vk;
        }
    }
    cout << l << "," << vl << ":" << r << "," << vr << endl;
    input((l + r) / 2);
    cerr << "error!" << endl;
}

Measured memory_bytes: 852
n,c,k = gets.chomp.split.map(&:to_i)
ts = n.times.map{gets.to_i}.sort
i = 0
ans = 1
while ts[i]
  if ts[0] + k < ts[i]  || i >= c
    ans += 1
    ts.slice!(0,i)
    i = 0
  else
    i += 1
  end
end
puts ans


Measured memory_bytes: 4216
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double cx = w / 2;
    double cy = h / 2;
    cout << fixed << setprecision(10) << w * h / 2 << ' ';
    cout << (cx == x && cy == y ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    ll N, D;
    cin>>N>>D;
    vector<ll> X(N), Y(N);
    for(int i=0; i<N; ++i) cin>>X[i]>>Y[i];
    ll count = 0;
    for(int i=0; i<N; ++i){
        if(D*D>=(X[i]*X[i] + Y[i]*Y[i])) count++;
    }
    cout<<count<<endl;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long dp[3002][3002];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(s[i] == t[j]){
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }

    vector<int> arr = {};

    for(int x = n, y = m; x > 0 && y > 0;){
        //cout << x << " " << y << endl;
        if(s[x - 1] == t[y - 1]){
            arr.push_back(x - 1);
            --x; --y;
        } else if(dp[x][y - 1] > dp[x - 1][y]){
            --y;
        } else {
            --x;
        }
    }

    reverse(arr.begin(), arr.end());

    for(auto i : arr)
        cout << s[i];

    cout << "\n";

    return 0;

}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    int n;
    cin >> n;

    string s[n];
    int t[n];
    for(int i = 0; i < n; i++) {
        cin >> s[i] >> t[i];
    }

    string trg;
    cin >> trg;

    int f = 0, ans = 0;
    for(int i = 0; i < n; i++) {
        if(f) ans += t[i];

        if(s[i] == trg) f = 1;
    }
    cout << ans;
}








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

int main() {
    using Int = long long;
    
    Int t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    
    Int d1 = t1 * (b1 - a1);
    Int d2 = t2 * (b2 - a2);
    
    if (d1 + d2 == 0) {
        cout << "infinity" << endl;
        return 0;
    }
    
    if (d1 < 0) {
        d1 *= -1;
        d2 *= -1;
    }
    
    if (d1 + d2 > 0) {
        cout << 0 << endl;
        return 0;
    }
    
    Int m = -(d1 + d2);
    
    if (d1 % m == 0) {
        cout << 2 * (d1 / m) << endl;
    } else {
        cout << 2 * (d1 / m) + 1 << endl;
    }
}

Measured memory_bytes: 888
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
#define int long long

int n;
vector<int> g[55];

vector<int> pre;

int _pow(int x, int n) {
    int res = 1LL;
    while(n > 0) {
        if(n & 1) res = res * x;
        x = x * x;
        n >>= 1;
    }
    return res;
}

void dfs(int v, int p) {
    pre[v] = p;
    for(auto nv: g[v]) {
        if(nv == p) continue;
        dfs(nv, v);
    }
}

void solve() {
	cin >> n;
    map<pair<int, int>, int> mp;
    rep(i, n - 1) {
        int a, b; cin >> a >> b;
        --a; --b;
        mp[make_pair(a, b)] = i;
        mp[make_pair(b, a)] = i;
        g[a].pb(b);
        g[b].pb(a);
    }
    int m; cin >> m;
    set<int> se[55];
    vector<ll> b(m, 0);
    rep(i, m) {
        int u, v; cin >> u >> v;
        --u; --v;
        pre.resize(n);
        pre[u] = -1;
        dfs(u, -1);
        while(pre[v] != -1) {
            se[i].insert(mp[make_pair(v, pre[v])]);
            v = pre[v];
        }
        for(auto k: se[i]) {
            b[i] |= (1LL<<k);
        }
    }

    int ans = 0;
    //cerr << _pow(2, 10) << endl;

    //vector<int> dp(1<<22, 0);

    for(int bit = 0; bit < (1<<m); ++bit) {
        int cnt = __builtin_popcount(bit);
        set<int> s;
        ll dp = 0;
        rep(i, m) {
            if(bit & (1<<i)) {
                dp |= b[i];
            }
        }
        int co = 0;
        rep(i, n - 1) {
            if(dp & (1LL<<i)) ++co;
        }
        if(cnt % 2 == 0) {
            ans += _pow(2LL, n - 1 - co);
        } else {
            ans -= _pow(2LL, n - 1 - co);
        }
    }

    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';
 
 
int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	vector<char> s(n+2);
	rep(i, n) scanf("%s", &s[i]); '\n';
	a -= 1;
	b -= 1;
	c -= 1;
	d -= 1;
	s[a] = 'A';
	s[b] = 'B';
	if (c < d) {
		while (true) {
			int tmpa = a;
			int tmpb = b;
			if (s[b + 2] == '.'&&b + 2 <= d) {
				b += 2;
				s[b] = 'B';
				s[b - 2] = '.';
			}
			if (s[b + 1] == '.'&&b + 1 <= d) {
				b += 1;
				s[b] = 'B';
				s[b - 1] = '.';
			}
			if (s[a + 2] == '.'&&a + 2 <= c) {
				a += 2;
				s[a] = 'A';
				s[a - 2] = '.';
			}
			if (s[a + 1] == '.'&&a + 1 <= c) {
				a += 1;
				s[a] = 'A';
				s[a - 1] = '.';
			}
			if (a == c && b == d) { cout << "Yes"; return 0; }
			if (a == tmpa && b == tmpb) { cout << "No"; return 0; }
		}
	}
	else{
		while (true) {
			int tmpa = a;
			int tmpb = b;
			if (s[a + 2] == '.'&&a + 2 <= c) {
				a += 2;
				s[a] = 'A';
				s[a - 2] = '.';
			}
			else if (s[a + 1] == '.'&&a + 1 <= c) {
				a += 1;
				s[a] = 'A';
				s[a - 1] = '.';
			}
			else if (s[b + 1] == '.'&&b + 1 <= d) {
				b += 1;
				s[b] = 'B';
				s[b - 1] = '.';
			}
			else if (s[b + 2] == '.'&&b + 2 <= d) {
				b += 2;
				s[b] = 'B';
				s[b - 2] = '.';
			}
			if (a == c && b == d) { cout << "Yes"; return 0; }
			if (a == tmpa && b == tmpb) { cout << "No"; return 0; }
		}
	}
}

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll; 
using Graph = vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph &G, int v){
	seen[v] = true;
	for(auto next_v : G[v]){
		if(seen[next_v]){
			continue;
		}
		dfs(G, next_v);
	}
}
 
int main(void){
	
	//N:頂点の数、M:辺の数
	int N, M;
	int ans = 0;
	
	cin >> N >> M;
	
	int a[M], b[M];
	Graph G(N);
	for(int i=0; i<M; i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	
	rep(i, M){
		seen.assign(N, false);
		G[a[i]].erase(remove(G[a[i]].begin(), G[a[i]].end(), b[i]), G[a[i]].end());
		G[b[i]].erase(remove(G[b[i]].begin(), G[b[i]].end(), a[i]), G[b[i]].end());
		dfs(G, 0);
		int count = 0;
		rep(v, N)
			if(seen[v])
				count++;
		if(count != N)
			ans++;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int K;
	while(~scanf("%d%d", &N, &K)) {
		int ans = K;
		rep(i, N - 1) ans *= K - 1;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
s_list = list(s)
alphabet = [chr(ord('a') + i) for i in range(26)]

for i in range(len(s)):
  if(ord(s[i]) + n >= 91):
    s_list[i] = chr(ord(s[i]) + n -26)
  
  else:
    s_list[i] = chr(ord(s[i]) + n)
  
s = "".join(s_list)
print(s)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
    vector<int> h;
    for(int i=0;i<10;i++){
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }

    sort(begin(h),end(h));

    for(int i=0;i<3;i++){
        cout << h[9-i] << endl;
    }
    return 0;

}

Measured memory_bytes: 3088
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

using namespace std;

int main()
{
	int n, m;

	scanf("%d %d", &n, &m);

	printf("%d\n", n*(n - 1)/2 + m*(m - 1)/2);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ld long double
#define f(i,from,to) for(int i=from;i<to;++i)
#define endl '\n'
#define tie() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    //tie();
    ll t=1;
    //cin>>t;
    while(t--)
    {
      ll n,sum=0,ct=0,m,l,r,k,ans=0;
      string s;
      string ss;
      cin>>s>>ss;
      for(ll i=0;i<s.size();i++) if(s[i]!=ss[i]) ct++;
      cout<<ct<<endl;

    }
    return 0;
}


Measured memory_bytes: 3864
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=2005;
struct node{
	ll id,v;
};
node a[N];
bool cmp(node a,node b){
	return a.v>b.v;
}
ll dp[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		a[i].id=i;
		scanf("%lld",&a[i].v);
	}
	sort(a+1,a+n+1,cmp);
	ll l=1,r=n;
	for(int i=1;i<=n;i++){
		for(int j=i-1;j>=0;j--){
			dp[j+1]=max(dp[j+1],dp[j]+1ll*abs(a[i].id-(j+1))*a[i].v);
			dp[j]+=1ll*abs(a[i].id-(n-i+1+j))*a[i].v;
			
//			dd(i),dd(j+1),de(dp[j+1]);
		}
//		de(dp[0]);
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		ans=max(ans,dp[i]);
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3872