akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   string s,t;cin>>s>>t;
   sort(ALL(s));
   sort(ALL(t),greater<char>());
   cout<<(s<t?"Yes":"No");
}



Measured memory_bytes: 256
#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>
using namespace std;
#define int long long


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

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

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

    for(int i = 1;i < n+1;i ++){
        ans += b[i] * (b[i] - 1) / 2;
    }

    for(int i = 0;i < n;i ++){
        int t = b[a[i]];
        cout << ans - t * (t-1) / 2 + (t-1) * (t-2) /2 << endl;
    }
}



Measured memory_bytes: 5760
N = int(input())
S = input()
list1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
dic = {}
for i in range(26):
  dic[list1[i]] = (i + N) % 26

c = ''
for s in S:
  af_s = list1[dic[s]]
  c += af_s

print(c)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a[5];
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	qsort(a, 3, sizeof(int), comp);
	if(a[0] + a[1] == a[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a>b) for(int i=0; i<a; i++) cout << b;
    else for(int i=0; i<b; i++) cout << a;

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



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

using namespace std;

const int N = 1e5 + 5;
int a[N] , n;
long long c[N] , k;

pair<bool , long long> can (int m) {
    long long g = 0 , g_cnt = 0 , ge_cnt = 0;
    for (int i = 0 ;i < n ;i++) {
        int ind = upper_bound(a , a + n , m - a[i]) - a;

        int len = n - ind;
        g_cnt += len;
        g += a[i] * 1ll * len + c[ind];

        ind = lower_bound(a , a + n , m - a[i]) - a;
        ge_cnt += n - ind;
    }

    if (ge_cnt >= k)
        return {1 , g + (k - g_cnt) * m};

    return {0 , 0};
}

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

    sort(a , a + n);

    for (int i = n - 1 ;i >= 0 ;i--)
        c[i] = a[i] + c[i + 1];

    long long ans = -1;
    int l = 2 , r = 2e5 + 5;
    while (l <= r) {
        int mid = (l + r) / 2;
        auto g = can(mid);
        if (g.first) {
            ans = g.second;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }

    cout << ans;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int n;
	cin >> n;
	int total = 0;
	vector<int>L(n);
	rep(i, n) {
		cin >> L[i];
		total += L[i];
	}
	sort(L.begin(), L.end());
	int sum = total - L[n - 1];
	if (L[n - 1] >= sum)puts("No");
	else puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
int ar[100005]; 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif

    int n,ans,x;
 
    cin >> n;
    rep(i,n) gi(ar[i]);

    sort(ar+1, ar+n+1);

    ar[0] = 0;
    ans = 0;

    rep(i,n) {
        x = ar[i] - ar[i-1];
    
        if(x & 1) ans ^= n-i+1;
    }
    
    if(ans) pf("first");
    else pf("second");

    nl;
 
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
const int N=1e5+5;
int n,m;
ll res;
struct node { ll a,p; }a[N];
inline bool cmp( node a,node b ) { return a.p<b.p; }
int main() {
	cin>>m>>n;
	for( int i=1;i<=m;i++ ) cin>>a[i].p>>a[i].a;
	sort(a+1,a+m+1,cmp);
	for( int i=1;i<=m;i++ ) 
		if(n>0) {
			if(n>a[i].a) n-=a[i].a,res+=a[i].p*a[i].a;
			else res+=a[i].p*n,n-=a[i].a;
		}
	cout<<res;
}

Measured memory_bytes: 1792
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 101
#define MAX_W 100001
long long dp[MAX_N][MAX_W];

int main()
{
	long long N;
	cin >> N;
	long long W;
	cin >> W;
	vector<vector<long long>>v(N, vector<long long>(2));
	for (long long i = 0; i < N; i++)
	{
		cin >> v[i][0] >> v[i][1];

	}
	for (long long i = 0; i <= W; i++)
	{
		dp[0][i] = 0;
	}
	for (long long i = 0; i < N; i++)
	{
		for (long long j = 0; j <= W; j++)
		{
			if (j < v[i][1])
			{
				dp[i + 1][j] = dp[i][j];
			}
			else
			{
				dp[i + 1][j] = max(dp[i][j], dp[i][j - v[i][1]] + v[i][0]);
			}
		}
	}
	cout << dp[N][W] << endl;
	return 0;






}


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

using namespace std;

int N, K;
const int maxn = 100010;
int cost[maxn];
int h[maxn];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//K <= 100
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> h[i];
	}

	cost[0] = 1e9;

	for (int i = 2; i <= N; i++) {
		cost[i] = 1e9;
		for (int j = 1; j <= K; j++) {
			if (i-j > 0) {
				cost[i] = min(cost[i], cost[i-j] + abs(h[i]-h[i-j]));
			}
		}
	}

	cout << cost[N] << endl;

}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

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

	if (a > 0)
	{
		if (a >= k)
		{
			a -= k;
			k = 0;
		}
		else
		{
			k -= a;
			a = 0;
		}
	}

	if (k > 0)
	{
		if (b >= k)
		{
			b -= k;
			k = 0;
		}
		else
		{
			b = 0;
			k -= b;
		}
	}



	cout << a << ' ' << b;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
a = np.array(input().split(), np.int64)

a = np.sort(a)

u = a[a > 0]
d = a[a < 0]
z = len(a[a == 0])

if len(u) * len(d) < k <= len(u) * len(d) + z * (n-z) + z * (z-1) // 2:
    print(0)
    exit()

L = - 10 ** 18
H = 10 ** 18

while H - L > 1:
    M = (H + L) // 2
    count = 0
    if M > 0:
        count += z * n
    count += np.searchsorted(a, M // u, side='right').sum()
    count += (n - np.searchsorted(a, (- M - 1) // (- d), side='right')).sum()
    count -= np.count_nonzero(a * a <= M)
    count //= 2
    #print(count)
    if count >= k:
        H = M
    else:
        L = M

print(H)

Measured memory_bytes: 34568
#include<stdio.h>
int main()
{int a,b;
int m,n;
scanf("%d%d",&m,&n);
if(m<n)
{b=m;
m=n;
n=b;
	}
while(n)
{  a=m%n;
   m=n;
   n=a;
}
printf("%d\n",m);
return 0;}


Measured memory_bytes: 2144
program ccc
implicit none

integer :: n, m, p, i
character(2) :: s
integer,allocatable,dimension(:) :: q, r

read*, n, m
allocate(q(n),r(n))
q = 0
r = 0

do i = 1, m
read*, p, s
	if (s=='AC') then
    	if (q(p)==0) then
        q(p) = 1
        end if
    else
    	if (q(p)==0) then
	    r(p) = r(p) + 1
        end if
    end if
end do

do i = 1, n
	if (q(i)==0) r(i)=0
end do

print*, sum(q), sum(r)

end program

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n, arr[101], k;
bool dp[100001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	for(int i=1;i<=k;i++){
		for(int j=1;j<=n;j++){
			if(arr[j]>i){
				break;
			}
			if(!dp[i-arr[j]]){
				dp[i]=true;
				break;
			}
		}
	}
	if(dp[k]){
		cout << "First" << '\n';
	}
	else{
		cout << "Second" << '\n';
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	
	int ans = 0;
	for(int i = 0; i < s.size(); i++) if(s[i] == '2') ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys

# import bisect
# import numpy as np
# from collections import deque
from collections import deque
# map(int, sys.stdin.read().split())
# import heapq
import bisect
import math

def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())
    S = input()
    pre ="A"
    count=0
    for i in S:
        if i !=pre:
            count+=1
        pre = i
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9456
#include <stdio.h>

int main() {
  int n;
  int i,j,k;
  int G[101][101];
  for(i = 0; i < 101; ++i)  {
    for(j = 0; j < 101; ++j) {
      G[i][j] = 0;
    }
  }
  int src, dst;
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf("%d %d", &src, &k);
    while(k--) {
      scanf("%d", &dst);
      G[src][dst] = 1;
    }
  }
  for(i = 1; i <= n; ++i) {
    for(j = 1; j <= n; ++j) {
      printf(j-1?" %d":"%d", G[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

int main(){

int A,V,B,W,T;
cin>>A>>V>>B>>W>>T;
//少なくとも鬼の方が早い
//(A-B)の絶対値を　V-Wで割った値を参照
//yes: dif/speed<=T    no:dif/speed>T
double dif;
if(A-B>0){
    dif=A-B;
}else{
    dif=B-A;
}

double speed;
speed=V-W;

if(V>W){
    if(dif/speed>T){
        cout << "NO"<<endl;
    }else{
        cout <<"YES"<<endl;
    }
}else{
    cout<<"NO"<<endl;
}




}


Measured memory_bytes: 3672
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  A = readint()


  Table = Vector{Vector{int}}(undef,10^6)
  for i in 1:10^6
    Table[i] = Vector{int}(undef,0)
  end
  
  for i in 2:10^6
    if length(Table[i]) != 0
      continue
    end
    for j in i:i:10^6
      append!(Table[j],[i])
    end
  end

  V = zeros(int,10^6)

  flag = true
  for i in 1:N
    for m in Table[A[i]]
      V[m] += 1
      if V[m] > 1
        flag = false
        break
      end
    end
    if ! flag 
      continue
    end
  end

  r = A[1]
  for i in 2:N
    r = gcd(r,A[i])
  end
  
  if r != 1
    println("not coprime")
  else
    if flag 
      println("pairwise coprime")
    else
      println("setwise coprime")
    end
  end

  
end

main()


Measured memory_bytes: 437000
#include <stdio.h>
int main(void){
  char b[2];
  scanf("%s",&b);
  switch(b[0]){
    case 'A' : printf("T"); break;
    case 'T' : printf("A"); break;
    case 'G' : printf("C"); break;
    case 'C' : printf("G"); break;
  }
  return 0;
  
  
}

Measured memory_bytes: 128
import numpy as np
from collections import Counter
n, m = map(int, input().split())
mistake = [0] * (n + 1)
done = [False] * (n + 1)
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if done[p] == False:
            mistake[p] += 1
    else:
        done[p] = True
counter = Counter(done)
print(counter[True], sum(np.multiply(mistake, done)))


Measured memory_bytes: 15912
/*
g++ -std=c++11 -o2 -Wall ABC113A1.cpp -o .\out\ABC113A1.out
.\out\ABC113A1.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int a[100000];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int s;
  cin >> s;
  a[s] = 1;
  int prev = s;
  for (int i = 2; i <= 1000000; ++i) {
    int temp;
    if (prev % 2 == 0) {
      temp = prev / 2;
    } else {
      temp = 3 * prev + 1;
    }
    if (a[temp] > 0) {
      cout << i << "\n";
      return 0;
    }
    prev = temp;
    a[temp] = 1;
  }
}


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

using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
	int n;
	while(cin >> n, n!=-1){
		int ans = 0;
		if(30 < n){ans += (n-30) * 160; n = 30;}
		if(20 < n){ans += (n-20) * 140; n = 20;}
		if(10 < n){ans += (n-10) * 125; n = 10;}
		ans += 1150;
		cout << 4280-ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
  
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, ll> mll;
  
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18 + 100;

  
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif	
}

template <typename T>
void scerr(T nums) {
    for (auto it : nums)
        cerr << it << " | ";
    cerr << "\n";
}

string s, t, ans = "";
int d[3001][3001];
pii p[3001][3001];

int main() {
	data();
	cin >> s >> t;
	int n = sz(s), m = sz(t);
	s = '#' + s;
	t = '#' + t;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i] == t[j]) {
				d[i][j] = d[i - 1][j - 1] + 1;
				p[i][j] = {i - 1, j - 1};
			}
			else {
				if (d[i - 1][j] > d[i][j - 1]) {
					d[i][j] = d[i - 1][j];
					p[i][j] = {i - 1, j};
				}
				else {
					d[i][j] = d[i][j - 1];
					p[i][j] = {i, j - 1};
				}
			}
		}
	}
	int i = n, j = m;
	while (d[i][j]) {
		if (p[i][j] == mp(i - 1, j - 1)) {
			ans += s[i];
			--i, --j;
		}
		if (p[i][j] == mp(i - 1, j))
			--i;
		if (p[i][j] == mp(i, j - 1))
			--j;
	}
	reverse(all(ans));
	cout << ans;
}
  
/*
    Timus: 288481RF
    CodeForces: fractal
*/

Measured memory_bytes: 105856
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 1) {
        cout << (a + b) / 2 + 1 << endl;
    }
    else cout << (a + b) / 2 << endl;
}

Measured memory_bytes: 256
inputstr = input()
check = True
for i in range(len(inputstr)):
  if i == len(inputstr) - 1:
    break
  else:
    for j in range(i + 1, len(inputstr)):
      if inputstr[i] == inputstr[j]:
        check = False
        break
  if not check:
    break
if check:
  ans = "yes"
else:
  ans = "no"
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println((H-h)*(W-w));
	}
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <queue>


using namespace std;

using ll = long long;

int main() {
  ll r, d, x2k;
  cin >> r >> d >> x2k;
  for (auto i = 1; i <=10; i++) {

    x2k = r * x2k - d;
    cout << x2k << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(_) for _ in input().split()]
M = max(a)
p = len(format(M, 'b'))
l = [0 for _ in range(p)]
ans = 0
for i in range(n):
    a_s = format(a[i], '0' + str(p) + 'b')
    for c in range(p):
        if a_s[c] == '1':
            l[c] += 1
for i in range(p):
    c1 = l[i]
    ans += (2**(p - i - 1)) * c1 * (n - c1)
    ans %= (10**9 + 7)
print(ans)



Measured memory_bytes: 125624
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (n, m) = Read2Longs();
            return (n - 1) * (m - 1);
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<int, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e2 + 5;

int n, ans;
int freq[N];

void solve() {
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++) {
        cin >> n;
        for(int i = 1, x; i <= n; i++) {
            cin >> x;
            freq[x]++;
            if(freq[x] == 1) ans++;
        }
        cout << ans << "\n";
    }
}

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

Measured memory_bytes: 3656
import numpy as np


def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    sol_tot, sol_tracker = int(-1e10), []
    for p in range(2):
        c = a.copy()

        idx = list(range(p, n, 2))
        if not idx:
            continue

        pick = max(idx, key=lambda i: c[i])
        if c[pick] <= 0:
            chosen = set([pick])
        else:
            chosen = set(filter(lambda i: c[i] > 0, idx))

        is_chosen, tot, tracker = [False] * n, 0, []
        for i in chosen:
            is_chosen[i] = True
            tot += c[i]

        for i in reversed(range(n)):
            if not is_chosen[i]:
                if i == 0 or i + 1 == len(c):
                    tracker += [i]
                    del c[i], is_chosen[i]
                elif is_chosen[i - 1] == is_chosen[i + 1]:
                    tracker += [i]
                    c[i - 1] += c[i + 1]
                    del c[i + 1], c[i], is_chosen[i + 1], is_chosen[i]

        if len(c) > 1 and not is_chosen[0]:
            tracker += [0]
            del c[0], is_chosen[0]

        if tot > sol_tot:
            sol_tot, sol_tracker = tot, np.array(tracker) + 1

    print(sol_tot, len(sol_tracker), *sol_tracker, sep='\n')


if __name__ == '__main__':
    main()


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

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

	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	rep(i, m)
		cin >> b.at(i);
	int count = 0;
	rep(i, n)
	{
		int a;
		int sum = 0;
		rep(j, m)
		{
			cin >> a;
			sum += b.at(j) * a;
		}
		if (sum + c > 0)
			count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		// スペース区切りの整数の入力
		int N = sc.nextInt();

		int len = String.valueOf( N ).length();//Nの桁数
		
		int wk = N;
		int ai = 0;
		
		//最大の数から素数を探す
		for(int i = 0;i < len;i++)
		{
			ai += wk % 10;
			wk = wk / 10;
		}

        if (N % ai ==0){
    		System.out.println("Yes");
        	
        }else{
    		System.out.println("No");
        }
        return ;

    }
    
}



Measured memory_bytes: 23764
N,M = map(int,input().split())
ans = 0
dic = {str(i):0 for i in range(1,N)}
for _ in range(M):
    a,b = map(int,input().split())
    if a == 1:
        dic[str(b)] += 1
        if dic[str(b)] == 2:
            ans = 1
    if b == N:
        dic[str(a)] += 1
        if dic[str(a)] == 2:
            ans = 1
if ans == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 998244353;
const int mxn = 2e5 + 10;

int fact[mxn];

template<typename T>
T binpow(T a,T b){
	T res = 1;
	while(b){
		if(b&1){
			res = (res * a)%mod;
		}
		b = b/2;
		a = (a*a)%mod;
	}
	return res%mod;
}

template<typename T>
T inv(T a){
	return binpow(a,mod - 2);
}
template<typename T>
T add(T a,T b){
	return (a + b)%mod;
}
template<typename T>
T sub(T a,T b){
	return add(a,mod - b);
}
template<typename T>
T mul(T a,T b){
	return (a*b)%mod;
}
template<typename T>
T nCk(T n,T k){
	return (mul(fact[n],inv(mul(fact[k],fact[n - k]))));
}

void facto(){
	fact[0] = 1;
	for(int i = 1;i < 2e5 + 2; ++i){
		fact[i] = mul(fact[i - 1],i);
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	facto();
	int n,m,k;
	cin >> n >> m >> k;
	int ans = 0;
	ffor(i,k + 1){
		int x = nCk(n - 1,i);
		x = mul(x,m);
		x = mul(x,binpow(m - 1,n - i - 1));
		ans = add(ans,x);
		// cout << ans;
	}
	cout << ans;
}	

Measured memory_bytes: 5216
#include <iostream>
#include <cstdio>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) <-EPS) return -1; //cw
    if(dot(b,c) < EPS) return +2; //c-a-b
    if(norm(b) < norm(c)) return -2; //a-b-c
    return 0; //a-c-b
}

int main(){
	double x[4], y[4];
	while(scanf("%lf,%lf", &x[0], &y[0])!=EOF){
		for(int i=1; i<4; i++){
			scanf(",%lf,%lf", &x[i], &y[i]);
		}
		VP quad(4);
		for(int i=0; i<4; i++){
			quad[i] = P(x[i], y[i]);
		}
		
		int judge=1;
		for(int i=0; i<4; i++){
			judge *= ccw(quad[i], quad[(i+1)%4], quad[(i+2)%4]);
		}
		if(judge==1){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3212
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

int n, m, k;
const int MAXN = 1e5 + 1;

int used[MAXN];
vector<int> g[MAXN];
vector<int> b[MAXN];
int s[MAXN];

int t = 0;

void dfs(int v) {
    used[v] = t;
    s[t]++;
    for (auto u : g[v]) {
        if (!used[u]) {
            dfs(u);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    cin >> n >> m >> k;
    int u, v;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 0; i < k; i++) {
        cin >> u >> v;
        u--, v--;
        b[u].pb(v);
        b[v].pb(u);
    }
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            t++;
            dfs(i);
        }
    }
    int cnt;
    for (int i = 0; i < n; i++) {
        cnt = 0;
        for (auto u : b[i]) {
            if (used[u] == used[i]) cnt++;
        }
        cout << s[used[i]] - 1 - cnt - (int)g[i].size() << " ";
    }
}
/*

*/


Measured memory_bytes: 14080
# input
n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]

inf=10**9

# cur + 1 本目までの竹を合成して長さx, y, zの竹を作る -> この3本を短縮, 延長して長さa, b, cの竹を得る
# x, y, z > 0が必要

def dfs(cur, x, y, z):
    if cur == n:
        if min(x, y, z) > 0:
            return abs(x - a) + abs(y - b) + abs(z - c) - 30 # x, y, z = 0, 0, 0 からスタートしているので, 余分な合成が3回ある 
        else:
            return inf
    ret0 = dfs(cur + 1, x, y, z) # cur + 1 本目の竹 = L[cur] を使わない
    ret1 = dfs(cur + 1, x + L[cur], y, z) + 10 # cur + 1 本目の竹を x と合成
    ret2 = dfs(cur + 1, x, y + L[cur], z) + 10 # cur + 1 本目の竹を y と合成
    ret3 = dfs(cur + 1, x, y, z + L[cur]) + 10 # cur + 1 本目の竹を z と合成
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define vecin1(n) vector<int> vec1(n); rep(i,n) cin >> vec1.at(i)
#define vecin2(n) vector<int> vec2(n); rep(i,n) cin >> vec2.at(i)
typedef long long ll;

int main() {
    int a,b,c,d,e,k,l;
    cin >> a >> b >> c >> d >> e >> k;
    l = e-a;
    if (l > k)
    cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <bitset>
using namespace std;
int main(void){
    int n,k=3,l=1000,m=0,f[10],w=27;
    cin>>n;
    f[0]=1;
    for(int i=1;i<10;i++){
        f[i]=i*f[i-1];
    }
    while(n>l-1){
        for(int i=1;i<=k-2;i++){
            for(int j=1;j<=k-1-i;j++){
                m+=f[k]/(f[i]*f[j]*f[k-i-j]);
            }
        }
        l*=10;
        k++;
        w*=3;
    }
    for(int i=0;i<w;i++){
        int s=i,t=0,v=1;
        bool a,b,c;
        a=b=c=false;
        for(int i=0;i<k;i++){
            if(s%3==0)t+=v*3,a=true;
            if(s%3==1)t+=v*5,b=true;
            if(s%3==2)t+=v*7,c=true;
            v*=10;
            s/=3;
        }
        //cout<<t<<endl;
        if(n>=t&&a&&b&&c)m++;
    }
    cout<<m<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}

//1つ目の要素の最大値に応じて調整
const ll MX = 100010;

struct UnionFind{
    vector<ll> par;
    vector<ll> sz;
    //type1, type2の数
    vector<ll> tp[2];

    UnionFind(ll n){
        par.resize(n);
        sz.resize(n);
        tp[0].resize(n);
        tp[1].resize(n);
        for (ll i = 0; i < n; i++){
            par[i] = i;
            sz[i] = 1;
            tp[i >= MX][i]++;
        }
    }

    ll find(ll x){
        if (par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sz[x] > sz[y])
            swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        tp[0][y] += tp[0][x];
        tp[1][y] += tp[1][x];
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    ll size(ll x){
        return sz[find(x)];
    }
};


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    ll n;
    cin>>n;
    ll ans = 0;
    UnionFind uni(2*MX);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        y += MX;
        uni.unite(x,y);
    }
    for(int i=0;i<2*MX;i++){
        if(i == uni.find(i)){
            ans += uni.tp[0][i] * uni.tp[1][i];
        }
    }
    ans -= n;
    cout << ans << endl;

    
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    V(string) S(N);
    rep(i, N) cin >> S[i];

    int res = -1;
    rep(i, N) {
        bool can = true;
        int tres = -1;
        vi nums(N, 0);
        queue<P> q;
        nums[i] = 1;
        q.push(P(i, 1));
        while(!q.empty()) {
            P p = q.front();
            q.pop();
            rep(j, N) {
                if(S[p.fi][j]=='1') {
                    if(nums[j]==0) {
                        nums[j] = p.se+1;
                        tres = max(tres, nums[j]);
                        q.push(P(j, nums[j]));
                    } else {
                        if(abs(p.se-nums[j])!=1) {
                            can = false;
                            break;
                        }
                    }
                }
            }
            if(!can) break;
        }
        if(can) res = max(res, tres);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	int i;
	vector<int> a(n + 1);
	ll sum = 0;
	vector<ll> Lsum(n + 1);
	vector<ll> Rsum(n + 1);
	Lsum[0] = 0;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		Lsum[i] = Lsum[i - 1] + a[i];
		sum += a[i];
	}
	for (i = 1; i <= n; i++) {
		Rsum[i] = sum - Lsum[i];
	}
	ll ans = inf;
	for (i = 1; i < n; i++) {
		ans = min(ans, abs(Lsum[i] - Rsum[i]));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    DRI(n);
    VI d;
    REP(i,n){
        DRI(x);d.PB(x);
    }
    sort(ALL(d));
    cout<<d.back()-d[0];
    return 0;
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, p, y;
vector<int> a[N];
int cnt[N];
ll ans[N];

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> p >> y;
        a[i] = {y, p, i};
    }
    sort(a, a + m);
    for (int i = 0; i < m; ++i) {
        // cout << a[i][0] << ' ' << a[i][1] << ' ' << a[i][2] << endl;
        int p = a[i][1];
        int num = ++cnt[p];
        int oi = a[i][2];
        ans[oi] = p * 1000000LL + num;
    }
    for (int i = 0; i < m; ++i) {
        cout << setfill('0') << setw(12) << ans[i] << endl;
    }
    return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    if (n % k == 0)
    {
        cout << 0 << "\n";
    }
    else
    {
        cout << 1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def convtobit(x):
    b = bin(x)
    bits = list(map(int, b[2:]))
    bits = [0] * (32 - len(bits)) + bits
    return tuple(bits)

def minus(x, y):
    b = []
    for xb, yb in zip(x, y):
        bit = 1 if xb != yb else 0
        b.append(bit)
    return tuple(b)

def main():
    #A, B, C, K = map(int, input().split())
    N = int(input())
    As = list(map(int, input().split()))

    # find N-th and 2nd number
    Adict = defaultdict(int)
    for a in As:
        b = convtobit(a)
        Adict[b] += 1

    assert convtobit(2) == tuple([0]*30 + [1, 0])
    assert convtobit(7) == tuple([0]*29 + [1, 1, 1])

    if len(Adict) > 3:
        print("No")
        return

    for first in Adict:
        for second in Adict:
            third = minus(first, second)
            if not third in Adict:
                continue
            forth = minus(second, third)
            if forth != first:
                continue

            if N % 3 == 0:
                adict = dict(Adict)
                for elem in [first, second, third]:
                    adict[elem] -= N // 3
                if all([adict[elem] == 0 for elem in [first, second, third]]):
                    print("Yes")
                    return

            if N % 3 == 1:
                adict = dict(Adict)
                for elem in [first, second, third]:
                    adict[elem] -= (N - 1) // 3
                adict[first] -= 1
                if all([adict[elem] == 0 for elem in [first, second, third]]):
                    print("Yes")
                    return

            if N % 3 == 2:
                adict = dict(Adict)
                for elem in [first, second, third]:
                    adict[elem] -= (N - 2) // 3
                adict[first] -= 1
                adict[second] -= 1
                if all([adict[elem] == 0 for elem in [first, second, third]]):
                    print("Yes")
                    return

    print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 123324
h, w = map(int, input().split())
A = [ input() for _ in range(h) ]
whitew, whiteh = "." * w, "." * h
temph, tempw = 0, 0
for i in range(h):
  if A[i-temph] == whitew:
    A.pop(i-temph)
    temph += 1
    h -= 1
for i in range(w):
  b = True
  for j in range(h):
    if A[j][i-tempw] != ".":
      b = False
  if b:
    for j in range(h):
      A[j] = A[j][:i-tempw] + A[j][i-tempw+1:]
    tempw += 1
    w -= 1
for i in range(h):
  print(A[i])

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

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

    vector<string> ss(n);
    unordered_map<string, int> mp;

    for (int i = 0; i < n; i++) {
        cin >> ss[i];
        sort(ss[i].begin(), ss[i].end());
        mp[ss[i]]++;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += mp[ss[i]] - 1;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17700
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    for (int i = 0; i < s.length(); i++)
    {
        s.pop_back();
        if (s.length() % 2 != 0)
        {
            continue;
        }
        
        int splitNum = s.length() / 2;
        string s1 = s.substr(0, splitNum);
        string s2 = s.substr(splitNum);

        if (s1 == s2)
        {
            cout << s.length() << endl;
            return 0;
        }
    }
    
    cout << 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  string S[N];
  rep(i,N) cin>>S[i];
  ll ans=0,A=0,B=0,AB=0;
  rep(i,N){
    rep(j,S[i].size()-1) if(S[i][j]=='A'&&S[i][j+1]=='B') ans++;
    if(S[i][S[i].size()-1]=='A'&&S[i][0]!='B') A++;
    if(S[i][S[i].size()-1]!='A'&&S[i][0]=='B') B++;
    if(S[i][S[i].size()-1]=='A'&&S[i][0]=='B') AB++;
  }
  if(A==0&&B==0&&AB>0) cout<<ans+AB-1<<endl;
  else if(A==0&&B==0&&AB==0) cout<<ans<<endl;
  else cout<<ans+AB+min(A,B)<<endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(int *,int *, int);
int n,C[VMAX+1];

int main(){

 int *A, *B;
 int i, j;

scanf("%d",&n);

A = malloc(sizeof(int)*n+1);
B = malloc(sizeof(int)*n+1);

for(i=0;i<n;i++)               //Aの格納
{
  scanf("%d",&A[i]);
}

CountingSort(A,B,VMAX);
for(i=1;i<=n;i++)
{
  if(i!=n)printf("%d ",B[i]);
  else printf("%d\n",B[i]);
}

  return 0;
}

void CountingSort(int *A,int *B,int k)
{
  int i,j,C[k+1];
  for(i=0;i<k;i++) C[i] = 0;

  for(i=0;i<n;i++)  C[A[i]]++;/* C[i] に i の出現数を記録する */

  for(i=0;i<k;i++) C[i] = C[i] + C[i-1];    /* C[i] に i 以下の数の出現数を記録する*/

  for(j=n;j>=0;j--)
  {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 17412
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
using p = pair<int,int>;
#define ll long long
#define ar array

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

	double D,T,S;
	cin >> D >> T >> S;

	if (D/S<=T) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

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


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

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

  if(A % 2==B % 2){
      ans = (B-A)/2;

  }
  else{
      if((A-1)>=(N-B)){
          ans = N-B+1 + (B-A-1)/2;
      }
      else{
          ans = A-1+1 + (B-A-1)/2;
      }
  }
  cout << ans;
  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

const int MAXN = 100100;
const int MOD7 = 1000000007ll;
const int MOD9 = 1000000009ll;
const int INF = 2000000000;
const double ESP = 1e-9;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main()
{
	int q, h, s, d, n;
	scanf("%d%d%d%d%d", &q, &h, &s, &d, &n);
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	d = min(d, 2 * s);
	long long a = n / 2;
	n -= a * 2;
	long long b = n;
	long long ans = a * d + b * s;
	printf("%lld\n", ans);

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
// Gaurav Aggarwal
 
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
typedef pair<double,double> pdd;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;
    ll ans = 180*(n-2);
    cout<<ans<<"\n";
    
    return 0;
}



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

using namespace std;

int main()
{
    int n,k,s;
    cin >> n >> k >> s;
    srand((int)time(NULL));
    int rd=rand()%1000000000;
    for(int i=0;i<n;i++)
    {
        if(i<k)
            printf("%d ",s);
        else
            printf("%d ",rd);
    }
    return 0;
}


Measured memory_bytes: 1280
import sys
import bisect

input = sys.stdin.readline

N,Q=map(int,input().split())
A=list(map(int,input().split()))
X=[int(input()) for i in range(Q)]

XLIST=[]
for i in range(1,N//2+1):
    if i+1<=N and 2*i+1<=N:
        XLIST.append((A[-i-1]+A[-2*i-1])/2)



SUM=[0]
for a in A:
    SUM.append(SUM[-1]+a)

SUMODD=[0]
for i in range(N-1,-1,-2):
    SUMODD.append(SUMODD[-1]+A[i])

ANSLIST=[]
ANSLEN=(N+1)//2

for i in range(ANSLEN):
    ANS=0

    ANS+=SUM[-1]-SUM[-1-ANSLEN+i]

    ANS+=SUMODD[-1]-SUMODD[-1-i]

    ANSLIST.append(ANS)
    
XLIST.reverse()

for x in X:
    print(ANSLIST[bisect.bisect_left(XLIST,x)])


Measured memory_bytes: 23840