akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
    int n;cin>>n;
    if(n%2==0)cout << setprecision(10)<<(double)1/2 << endl;
    if(n%2!=0)cout << setprecision(10)<<(double)(n+1)/(2*n) << endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,d;
int a[325252];

int main(){
  scanf("%d%d",&n,&d);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)a[i]--;
  int x = 0;
  REP(i,n)x ^= a[i] % (d+1);
  puts(x==0 ? "Second" : "First");
  return 0;
}



Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int count_two_factor(ll num) {

  int count = 0;
  while(num % 2 == 0) {
    count++;

    num /= 2;
  }

  return count;
}

int main() {
  int n;
  V<ll> a;

  cin >> n;
  a.resize(n);
  rep(i, n) {
    cin >> a[i];
  }


  int min_two_factor = 1e9;
  rep(i, n) {
    min_two_factor = min(min_two_factor, count_two_factor(a[i]));
  }

  cout << min_two_factor << endl;
}


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

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back

ll N,L;
vector<ll> a;

void solve() {
    a.clear();
    rep(i,N) {
        int aa; scanf("%d",&aa);
        a.pb((ll)aa);
    }

    int p = -1;
    rep(i,N-1) if(a[i]+a[i+1] >= L) {
        p = i;
    }
    if(p == -1) {
        cout << "Impossible" << "\n";
        return ;
    }

    cout << "Possible" << "\n";
    rep(i,p) cout << i+1 << "\n";
    for(int i=N-1; i>p; --i) cout << i << "\n";
}

int main() {
    while(cin>>N>>L) solve();
    return 0;
}


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

int main(){
    int K;
    int ans=0;
    cin >> K;
    if(K % 2 == 0){
        ans = (K / 2) * (K / 2);
    }else{
        ans = ((K-1) / 2) * ((K+1) / 2);
    }
    cout << ans << endl;
}

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

int N, K;

string solve(string s){
    int l = 1;
    char c = s.back();
    while(l < N && s[N-l-1] == c) l++;
    for(int t=0; t<K; t++){
        for(int i=0; i<N; i++) s.push_back(s[N-1-i]);
        int st = (t==K-1 ? N-l : l);
        s = s.substr(st, N);
        l *= 2;
        if(l >= N) return string(N, c);
    }
    return s;
}

int main(){
    string S;
    cin >> N >> K >> S;
    K = min(K-1, 15);
    string SS = S;
    for(int i=0; i<N; i++) SS.push_back(S[N-1-i]);

    string ans = S;
    for(int i=0; i<=N; i++){
        string s = SS.substr(i, N);
        ans = min(ans, solve(s));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <climits>
using namespace std;
int main (void) {
    int a, b, c;
    int ans = 0;

    cin >> a >> b >> c;

    ans = min(a + b, b + c);
    ans = min(ans, c + a);

    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

  int N;
  cin>>N;
  vector<vector<int>> table(N, vector<int>(N-1));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N-1; j++) {
      int t; cin>>t;
      t--;
      table[i][j] = t;
    }
  }
  vector<int> is(N, 0);
  set<int> cands;
  auto check = [&](int x) {
    if (is[x] < N-1) {
      int io = table[x][is[x]];
      if (is[io] < N-1 and table[io][is[io]] == x) {
        cands.insert(x);
        cands.insert(io);
      }
    }
  };
  for (int i = 0; i < N; i++) {
    check(i);
  }
  int d = 0;
  while (not cands.empty()) {
    vector<bool> played(N, false);
    vector<int> ncands;
    for (auto i : cands) {
      if (is[i] == N-1)
        continue;
      int o = table[i][is[i]];
      if (not played[i] and not played[o]) {
        played[i] = played[o] = true;
        ++is[i];
        ++is[o];
        ncands.push_back(i);
        ncands.push_back(o);
      }
    }
    for (auto c : ncands)
      cands.erase(c);
    for (auto c : ncands)
      check(c);
    d++;
  }
  bool suc = true;
  for (int i = 0; i < N; i++) {
    suc &= is[i] == N-1;
  }
  cout << (suc ? d : -1) << endl;

  return 0;
}


Measured memory_bytes: 4224
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, t; cin >> n >> t;
	vector<int> a(n); rep(i, n)cin >> a[i];
	vector<int> e(n);
	int mx = a[n - 1];
	rrep(i, n)
	{
		mx = max(mx, a[i]);
		e[i] = mx;
	}
	int mxdif = 0;
	rep(i, n)mxdif = max(mxdif, e[i] - a[i]);
	int res = 0;
	rep(i, n)if (e[i] - a[i] == mxdif)++res;
	cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

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

  if(n < s){
    cout << -1 << endl;
    return 0;
  }

  if(n==s){
    cout << n+1 << endl;
    return 0;
  }

  ll rn = sqrt(n);

  REP(i,rn-1){
    ll x = n;
    ll ans = 0;
    while(x>0){
      ans += x % (i+2);
      x /= (i+2);
    }
    if(ans == s){
      cout << i+2 << endl;
      return 0;
    }
  }

  rn = floor(sqrt(n));

  for(int p = rn; p >= 0; p--){
    if((n-s) % (p+1) == 0){
      ll b = 1 + (n-s) / (p+1);
      ll x = n;
      ll ans = 0;
      while(x>0){
        ans += x % (b);
        x /= (b);
      }
      if(ans == s){
        cout << b << endl;
        return 0;
      }

    }
  }

  cout << -1 << endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	string prev;
	string curr;

	int result = 0;

	for (int i = 0; i < S.size(); i++)
	{
		curr += S[i];
		if (curr != prev)
		{
			result++;
			prev = curr;
			curr = "";
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 720
n = int(input())
a = n // 3
a = 3*(a*(a+1))//2

b = n // 5
b = 5 *(b*(b+1))//2 

c = n // 15
c = 15*(c*(c+1))//2

print(n*(n+1)//2 - a  - b + c )

Measured memory_bytes: 9184
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	if((b - a) & 1){
		printf("Borys\n");
	}else{
		printf("Alice\n");
	}
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, len;
  cin >> n >> len;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ii = 0, mx = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] + a[i + 1] > mx) {
      mx = a[i] + a[i + 1];
      ii = i;
    }
  }
  if (mx < len) {
    cout << "Impossible\n";
    return 0;
  }
  cout << "Possible\n";
  for (int i = 0; i < ii; i++) {
    cout << i + 1 << '\n';
  }
  for (int i = n - 2; i > ii; i--) {
    cout << i + 1 << '\n';
  }
  cout << ii + 1 << '\n';
  return 0;
}


Measured memory_bytes: 1280
/// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	map<int,int> mp;
	int a[n];
	int x=INT_MAX;
	int end = INT_MIN;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>end) end=a[i];
		if(a[i]<x) x = a[i];
		mp[a[i]]++;
	}
	int ans=0;
	for(int i=x;i<=end;i++){
		int sum = mp[i-1]+mp[i]+mp[i+1];
		if(sum>ans) ans = sum;
	}
	cout<<ans<<endl;

	//cout<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 8692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && a == c) cout << "No" << endl;
    else if(a == b || a == c) cout << "Yes" << endl;
    else if(b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int bits[64];
    memset(bits, 0, sizeof(bits));
    for(int i=0;i<n;i++)
    {
        int curr = a[i], z = 0;
        while(curr > 0)
        {
            bits[z] += curr%2;
            curr /= 2;
            z++;
        }
    }
    int ans = 0, curr = 1;
    for(int i=0;i<64;i++)
    {
        int z = bits[i]*(n-bits[i]);
        z %= M;
        z = (z*curr)%M;
        curr = (curr*2)%M;
        ans = (ans + z)%M;
    }
    cout << ans <<"\n";

    
    return 0;
}



Measured memory_bytes: 2560
#include <stdio.h>

int main() {
	char name[5];
	scanf("%s", &name);
	
	if(name[1] == 'R'){
		name[1]= 'B';
		printf("%s", name);
	}else if (name[1]=='B'){
		name[1]= 'R';
		printf("%s", name);
	}
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c,d;
 cin >> a>> b>> c>> d;
 if((a*b)>(c*d)){
     cout << a*b << endl;
 }else if((a*b)<(c*d)){
     cout << c*d << endl;
 }else{
     cout << a*b << endl;
 }
 return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            //String s = br.readLine();
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            if(h == 0 || w == 0) break;
            for(int i=0;i<h; i++){
                System.out.print("");
                for(int j=0; j<w-1; j++){
                    System.out.print("#");
                }
                System.out.println("#");
            }
            System.out.print("\n");
            //System.out.println(h+" "+w);
        }
    }
}

Measured memory_bytes: 25952
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>

using namespace std;

void Solution()
{
     int n;
    
    string a;
    int b;
    int c;
    
    cin>>n;
    
    while (n--)
    { 
        cin>>a;
        
        sort(a.begin(), a.end());
        b = atoi(a.c_str()); //string to int
        
        reverse(a.begin(), a.end());
        c = atoi(a.c_str());
        
        cout<<c - b<<endl;
    }
    
}

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

Measured memory_bytes: 1228
// A - Task Scheduling Problem
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()

int main(){
	vi A(3); cin>>A[0]>>A[1]>>A[2];
	sort(all(A));
	cout<< A[2] - A[0] <<endl;
}

Measured memory_bytes: 256
#0除算
import math
def popcount(x):
    s=0
    y=int(math.log2(x))+2
    for i in range(y):
        if(x>>i)&1:
            s+=1
    return x%s
n=int(input())
x=input()[::-1]
#1がなんこ出るのか
c=x.count("1")
#c+1とc-1だけ考えれば良い
#c=1の時場合分け
#m[i][j]:2^iまで考えたときのmod(c+j-1)
if c!=1:
    m=[[1%(c-1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c-1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c-1)
            l[1]%=(c+1)
else:
    m=[[1%(c+1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c+1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c+1)
            l[1]%=(c+1)
#一個だけ変えたいので全体を求める

#最初以外はpopcount使って間に合う
ans=[0]*n
for i in range(n):
    if x[i]=="1":
        if c-1==0:
            ans[i]=0
            continue
        p=(l[0]+(c-1)-m[i][0])%(c-1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
    else:
        p=(l[1]+m[i][1])%(c+1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
ans=ans[::-1]
for i in range(n):
    print(ans[i])






Measured memory_bytes: 42604
#include <stdio.h>
#include <math.h>
int main(void){
    int a,n,c=0,i,j,f,ar;
    scanf("%d",&n);
    for(i=0;i<n;i++){
    	f=1;
    	scanf("%d",&a);
    	if(a==2){
    		f=1;
    		goto a;
    	}
    	ar=sqrt(a);
    	if(a%2==0||a<2){
    		f=0;
    		goto a;
    	}
    	
    	for(j=3;j<=ar;j+=2){
    		if(a%j==0){
    			f=0;
    			break;
    		}
    	}
    	a:
    	if(f){
    		c++;
    		//printf("aaaaaa%d\n",a);
    	}
    }
    	
    printf("%d\n",c);
    
    return 0;
}


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

int main() {
  map <string, int> card;
  int N, M;

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

  cin >> M;
  for (int i = 0; i < M; ++i) {
    string t;
    cin >> t;
    --card[t];
  }
  int ans = 0;
  map <string, int>::iterator itr;
  for (itr = card.begin(); itr != card.end(); ++itr) {
    ans = max(ans, itr->second);
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a,b;
        cin >> a >> b;
     	
      	if ((a+b)%2 == 0){     	
      		cout << (a + b) / 2  << endl;}
      	else if ((a+b)%2 !=0){
          	cout << (a + b) / 2 + 1  << endl;}
      
    }

Measured memory_bytes: 256
#!/usr/bin/env python3
# coding=utf-8

import sys
import math
import numpy as np
n, h = map(int, sys.stdin.readline().strip().split(" "))
a = []
b = []
for _ in range(n):
    _a, _b = map(int, sys.stdin.readline().strip().split(" "))
    a.append(_a)
    b.append(_b)
max_a = max(a)
cnt = 0
b = np.asarray(sorted(b))
b = b[b > max_a]
while h > 0 and len(b) > 0:
    cnt += 1
    h -= b[-1]
    b = b[:-1]
if h > 0:
    cnt += math.ceil(h / max_a)
print(cnt)


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

Measured memory_bytes: 65132
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i,j;
  for(i=s.size()-1;i>0;i--){
    if(i%2==1) continue;
    else{
      vector<char> a(i/2),b(i/2);
      for(j=0;j<i/2;j++) a[j] = s[j];
      for(j=0;j<i/2;j++) b[j] = s[j+i/2];
      for(j=0;j<i/2;j++) if(a[j]!=b[j]) break;
      if(j*2==i){
        cout << i << "\n";
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){

    int n;
    cin >> n;

    map<string, int> mp;

    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        if(mp[s])++mp[s];
        else mp[s] = 1;
    }

    vector<string> out;
    int ma = 0;

    for(auto i = mp.begin(); i != mp.end(); ++i){
        if(ma == i -> second)out.push_back(i->first);
        else if(ma < i->second){
            ma = i->second;
            out.clear();
            out.push_back(i->first);
        }
    }

    for(int i = 0; i < out.size(); ++i){
        cout << out[i] << endl;
    }

}

Measured memory_bytes: 28656
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

print(sum(a)-N)

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

#define F first
#define S second
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define circ_inc(i, n) (i + 1) % int(n)
#define circ_dec(i, n) (i + int(n) - 1) % int(n)
#define round(x) (int)((double)int(x) + 0.5)

void println() { cout << '\n'; }
template <typename Head, typename... Tail>
void println(Head H, Tail... T) {
    cout << " " << H;
    println(T...);
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef map<string, int> msi;
typedef istringstream iss;

const int INF = 1e9;
const ll MOD = 1e9 + 7;

int n, m, q;
ll ans = 0;
vll A;
vvi quads;

ll evaluate(vll A) {
    ll value = 0;
    rep(i, 0, q-1) {
	int a = quads[i][0];
	int b = quads[i][1];
	int c = quads[i][2];
	int d = quads[i][3];

	if(A[b] - A[a] == c) value += d;
    }
    return value;
}

void recurse(int pos) {
    if(pos == n) {
	ans = max(ans, evaluate(A));
	return;
    }

    int start = (pos > 0) ? A[pos-1] : 1;
    rep(x, start, m) {
	A[pos] = x;
	recurse(pos+1);
    }
}

int main() 
{
    FASTIO;
    cin >> n >> m >> q;

    quads.assign(q, vi(4));
    rep(i, 0, q-1) {
	rep(j, 0, 3) cin >> quads[i][j];
	quads[i][0]--;
	quads[i][1]--;
    }

    A.assign(n, -1);
    recurse(0);
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2001*2001+3;
ll mod=1e9+7;
ll dp[2001][2001];
ll fac[N];
ll power(ll n, ll k){
    if (k==0){
        return 1;
    }
    else{
        if (k%2==0){
            ll x=power(n,k/2);
            return x*x%mod;
        }
        else{
            ll x=power(n,k/2);
            x=x*x%mod;
            return x*n%mod;
        }
    }
}
ll fm[N];
ll ent(ll k, ll n){
	if (k==0 || k==n){
        return 1;
	}

	return (((fac[n]*fm[k])%mod)*fm[n-k])%mod;
}
ll pd[N];
int32_t main(){
    sync;
    fac[0] = 1;

	for(int i=1;i<N;i++) {
        fac[i]=(fac[i-1]*i)%mod;
	}
	fm[N - 1] = power(fac[N - 1], mod - 2);
    for(int i = N - 2; i >= 0; i--) fm[i] = (fm[i + 1] * (i + 1)) % mod;
	ll ans=1;
    ll n,k;
    cin >> n >> k;
    if (k==1){
        cout << 1 << endl;
        return 0;
    }
 //   dp[0]=1;
   // dp[1]=1;
    dp[0][0]=1;
    for (int i=1;i<=n;i++){
        for (int j=i;j>0;j--){
            dp[i][j]=dp[i][j+1];
            dp[i][j]+=dp[i-1][j-1]*ent(k-2,i*k-j-1)%mod*i%mod;
            dp[i][j]%=mod;
        //cout << i << " " << j << " " << dp[i][j] << endl;
        }
        dp[i][0]=dp[i][1];
    }
    cout << dp[n][1] << endl;
    /*
    for (int i=2;i<=n;i++){
        ll p1=1;
        for (int j=1;j<=i;j++){
            dp[i]+=ent(j,i)*ent((k-1)*j-1,i*k-j-1)%mod*pd[j]%mod*dp[i-j]%mod;
           // dp[i]+=(n-i+1)*ent(k-2,i*k-2)%mod*dp[i-1]%mod;
            //dp[i]+=(n-i+1)*ent(k-1,i*k-2)%mod*dp[i-1]%mod*fm[2]%mod;
            cout << i << " " << j << " " << dp[i] << endl;
            dp[i]%=mod;
        }
    }
    cout << dp[n] << endl;
    */
}


Measured memory_bytes: 94720
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner();
			long n = cin.Long();
			var divs = GetDivisors(n);
			divs.Add(1);
			divs.Add(n);
			long ans = long.MaxValue;
			foreach (long div in divs) {
				long p = n / div;
				ans = Math.Min(ans, p + div);
			}

			Console.WriteLine(ans - 2);
		}

		public static List<long> GetDivisors(long value)
		{
			long max = (long)Math.Ceiling(Math.Sqrt(value));
			var divisors = new List<long>();
			for (int i = 1; i <= max; i++) {
				if (value % i == 0) {
					divisors.Add(i);
					divisors.Add(value / i);
				}
			}

			divisors.Sort();
			return divisors;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define Android ios::sync_with_stdio(false), cin.tie(NULL)
#define F(i, n) for(int i=0, _iter_max=(n); i<_iter_max; i++)
#define range(i, l, r) for(int i=(l), _iter_max=(r); i<_iter_max; i++)
#define debug(s, r) std::cerr << #s << ": " << (s) << (r==0?' ':'\n')
#define pii pair<int, int>  

using namespace std;

void redirect_input() { freopen("./input.txt", "r", stdin); }
void redirect_output() { freopen("./output.txt", "w", stdout); }

const int N = 120;
const int inf = 0x3f3f3f3f;

int h, w;
char grid[N][N];
int dp[N][N];


void solve(){
    memset(dp, 0x3f, sizeof dp);
    dp[0][1] = 0;
    cin >> h >> w;
    F(i, h) cin >> (grid[i+1] + 1);
    for(int r=1; r<=h; r++){
        for(int c=1; c<=w; c++){
            int & val = dp[r][c];
            if(grid[r][c] == '#'){
                val = min((grid[r-1][c]=='#'?0:1) + dp[r-1][c], val);
                val = min((grid[r][c-1]=='#'?0:1) + dp[r][c-1], val);
            }else{
                val = min(dp[r-1][c], dp[r][c-1]);
            }
        }
    }
    cout << dp[h][w] << endl;

}

signed main(){
    Android;
    solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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 main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;cin>>k;
    string s;cin>>s;
    if (s.size()<=k) {
        cout << s << endl;
    }
    else {
        cout << s.substr(0,k) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int solve(vector<int> data,int white,int n){
	int dp[100001] = {0};
	rep(i,100001)dp[i] = 1;
	rep(i,data.size()) dp[data[i]] = 0;
	
	dp[0] = 0;
	for(int i=1;i<=n;i++)
		dp[i] = dp[i-1] + dp[i];
	
	int l = 1 , r = 1 , ans = 0;
	while(r <= n){
		if(dp[r]-dp[l-1] <= white){
			ans = max(ans,r-l+1);
			r++;
		}else{
			l++;
		}
	}
	return ans;
}
int main(){
	int n,k;
	while(cin >> n >> k , n){
		vector<int> data;
		int e = 0;
		rep(i,k){
			int t; cin >> t;
			if(t)data.push_back(t);
			else e++;
		}
		cout << solve(data,e,n) << endl;
	}
	
}

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

int main(){
	int K, T, a, i, maxa = 0, suma = 0;
	scanf("%d%d", &K, &T);
	for(i = 0; i < T; i++){
		scanf("%d", &a);
		maxa = max(maxa, a);
		suma += a;
	}
	printf("%d\n", max(0, 2 * maxa - suma - 1));
	return 0;
}

Measured memory_bytes: 256
//abc097_b.cpp
//Sat May 12 20:38:54 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	double x;
	cin >> x;

	double i= 2;
	double ansnum = 1;
	while (log(x)/log(i)>=2){
		float power = log(x)/log(i);
		int tempnum = pow(i,int(power));
//		cout << i << " " << tempnum << " " << int(power) << endl;
		if (ansnum <= tempnum && tempnum <=x){
			ansnum = tempnum;
		}
		i++;
	}

	cout << ansnum << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    A = [int(i) for i in input().split()]
    ans = [False] * 2001
    for i in range(2**n):
        sumA = 0
        for j in range(n):
            if (i >> j) & 1:
                sumA += A[j]
        ans[sumA] = True
    q = int(input())
    M = [int(i) for i in input().split()]
    for m in M:
        if ans[m]:
            print("yes")
        else:
            print("no")


resolve()



Measured memory_bytes: 5628
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n):
        a = I()
        for j in range(a):
            x,y = LI()
            x -= 1
            v[i].append((x,y))
    m = 1<<n
    ans = 0
    for b in range(m):
        f = [1 if b&(1<<i) else 0 for i in range(n)]
        for i in range(n):
            for x,y in v[i]:
                if f[i]:
                    if f[x] != y:
                        break
            else:
                continue
            break
        else:
            na = sum(f)
            if ans < na:
                ans = na
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 44780
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC";
    else
        cout << "ABC";

    return 0;
}


Measured memory_bytes: 3620
a, b, c = gets.chop.split(" ").map(&:to_s)
ary = [a, b, c]
ans = []

ary.each do |i|
	ans << i.split(//)
end

if ans[0].last == ans[1].first && ans[1].last == ans[2].first
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,D;
  cin >> N >> D;
  ll X[N],Y[N];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    X[i] = abs(X[i]);
    Y[i] = abs(Y[i]);
  }
  for (int i = 0; i < N; i++) {
    if ((X[i] * X[i]) + (Y[i] * Y[i]) <= D * D) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int student[N][2], check[M][2];
    for (int i = 0; i< N; i++)
        cin >> student[i][0] >> student[i][1];
    for (int i = 0; i< M; i++)
        cin >> check[i][0] >> check[i][1];
    int distance[N][M];
    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
            distance[i][j] = abs(student[i][0] - check[j][0]) + abs(student[i][1] - check[j][1]);
    for (int i = 0; i < N; i++) {
        int minD = distance[i][0];
        int res = 1;
        int j = 1;
        for (; j < M; j++)
            if (distance[i][j] < minD) {
                minD = distance[i][j];
                res = j+1;
            }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;
#define REP(i, o, n) for (ll i = o; i < n; i++)
#define rep(i, n) REP(i, 0, n)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(b, a % b) * b; }

void actual() {
    ll l, r, ans;
    cin >> l >> r;
    ll diff = r - l;
    bool flag = diff > 2019;

    ans = 2000000000;
    if (flag) {
        for (ll i = l; i <= l + 2019; i++) {
            for (ll j = r - 2019; j <= r; j++) {
                ans = min(i * j % 2019, ans);
            }
        }
    } else {
        for (ll i = l; i <= r; i++) {
            for (ll j = i + 1; j <= r; j++) {
                ans = min(i * j % 2019, ans);
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    actual();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main {
    public static void main(String args[]) {
     Scanner sc = new Scanner(System.in);
     int i,j,k,l,m,n,x,y,z;
     double s=0,f=0;
     n=sc.nextInt();
     m=sc.nextInt();
     int a[] = new int[n];
     for(i=0;i<n;i++)
     {
         a[i] = sc.nextInt();
         s=s+a[i];
         
     }
     Arrays.sort(a);
     s=(Math.ceil(s/(4*m)));
    
     for(j=n-1;j>=(n-m);j--)
     {
         if(a[j]<(int)s)
         {
             f=1;
             System.out.print("No");
             break;
         }
     }
     if(f!=1)
     {
         System.out.println("Yes");
     }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 3e5+10;
const ll bits = 63;
const ll mod = 1e9+7;

ll power(ll x, ll n){

    if(n==0){
        return 1;
    }

    ll ans = power(x,n/2);
    ans*=ans;
    ans%=mod;

    if(n%2){
        ans*=x;
        ans%=mod;
    }
    return ans;
}

ll modInv(ll n){
    return power(n,mod-2);
}

int main(){

    ll n;
    cin>>n;

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

    // vector<vector<ll>>store(bits+1);


    ll ans = 0;

    for(int x=0;x<bits;x++){
        ll var = pow(2,x);
        // ll var2 = pow(2,x);
        // cout<<x<<" "<<var<<" "<<var2<<"\n";

        ll e=0;

        for(int i=0;i<n;i++){
            if((arr[i]&var)==var){
                e++;
            }
        }

        // store[x].push_back((((e*(n-e))%mod) *var)%mod);
        var%=mod;
        
        ans+= (((e*(n-e))%mod) *var)%mod;
        ans%=mod;
    }

    // ans*=modInv(2);
    // ans%=mod;

    // ll ans2=0;

    // for(int x=0;x<=bits;x++){
    //     ll sum = 0;
    //     ll var = 1<<x;
    //     for(int i=0;i<n;i++){
    //         for(int j=i+1;j<n;j++){
    //             ans2+= arr[i] ^ arr[j];
    //             ans2%=mod;
    //             sum+= (arr[i] ^ arr[j])&var;
    //             sum%=mod;
    //         }
    //     }

    //     store[x].push_back(sum);
    // }

    // for(int i=0;i<store.size();i++){
    //     cout<<i<<" "<<store[i][0]<<" "<<store[i][1]<<"\n";
    // }

    
    cout<<ans<<"\n";

}


Measured memory_bytes: 2560
#include<stdio.h>
#include<algorithm>
using namespace std;
int is[110001];
int prime[100000];
int use[10000];
int main(){
	is[0]=is[1]=-1;
	for(int i=2;i<110001;i++){
		if(!is[i]){
			is[i]=1;
			for(int j=i*2;j<110001;j+=i)is[j]=-1;
		}
	}
	int now=0;
	for(int i=0;i<110001;i++)if(~is[i])prime[now++]=i;
	int a,b;
	while(scanf("%d%d",&a,&b),~b){
		int at=upper_bound(prime,prime+now,a)-prime;
		int ind=0;
		for(int i=0;i<b;i++){
			for(int j=i;j<b;j++){
				use[ind++]=prime[at+i]+prime[at+j];
		//		printf("%d ",use[ind-1]);
			}
		}
		std::sort(use,use+ind);
		printf("%d\n",use[b-1]);
	}
}

Measured memory_bytes: 1252
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 300100;

int n, x;
int p[MAXN], bio[MAXN];

int main() {
  scanf("%d %d",&n,&x);
  if (x == 1 || x == 2 * n - 1) {
    puts("No");
    return 0;
  }

  p[n - 1] = x;
  p[n - 2] = 1;
  p[n + 1] = 2;
  p[n] = 2 * n - 1;

  if (x == 2) {
    p[n - 2] = 2 * n - 1;
    p[n + 1] = 2 * n - 2;
    p[n] = 1;
  }

  REP(i, 2 * n - 1) bio[p[i]]++;
  int cnt = 1;
  REP(i, 2 * n - 1) {
    if (!p[i]) {
      while (bio[cnt]) cnt++;
      p[i] = cnt;
      bio[cnt] = 1;
    }
  }

  puts("Yes");
  REP(i, 2 * n - 1) printf("%d\n",p[i]);
  return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

map<ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  int n;
  cin >> n;
  vi a(n), check(2000000,0);
  rep(i,n){
    cin >> a[i];
    check[a[i]] += 1;
  }
  int ans = 0;
  rep(i,n){
    if(check[a[i]]>=2)continue;
    auto res = divisor(a[i]);
    bool ok = true;
    for(auto e:res){
      if(e == a[i])continue;
      ok&=(check[e]==0);
    }
    if(ok)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int judge=0;
  if(a==1||b==1||c==1||d==1){
    judge+=1;
  }
  if(a==9||b==9||c==9||d==9){
    judge+=1;
  }
  if(a==7||b==7||c==7||d==7){
    judge+=1;
  }
  if(a==4||b==4||c==4||d==4){
    judge+=1;
  }
  if(judge==4){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
return 0;
}


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

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

    string s;
    cin >> s;
    if (s[0] == 'A' || s[1] == 'A' || s[2] == 'A')
    {
        if (s[0] == 'B' || s[1] == 'B' || s[2] == 'B') cout << "Yes\n";
        else cout << "No\n";
    }
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int n, i, j, sum=0;
    cin >> n;
    
    int *A = new int[n];
    for(i=0; i<n; i++){
        cin >> A[i];
        sum += A[i];
    }
    
    bool flag = true;
    
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            if(A[i] >= sum - A[i]){
                flag = false;
            }
        }
    }
    
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    delete [] A;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

ll dp[2001][2001];
int main(){
    int n,k;
    cin >> n >> k;
    dp[0][0] = 1;
    for(int i=1;i<=k-1;i++){
        for(int j=0;j<=n-i-1;j++){
            if(j==0){
                dp[i][j] = dp[i-1][j] + dp[i-1][j+1];
                dp[i][j] %= mod;
            }else{
                dp[i][j] = dp[i][j-1] + dp[i-1][j+1];
                dp[i][j] %= mod;
            }
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<n;j++){
    //         cerr << dp[i][j] << " ";
    //     }
    //     cerr << endl;
    // }
    ll sm = 0;
    for(int j=0;j<n;j++){
        sm += dp[k-1][j];
        sm %= mod;
    }
    //cerr << sm << endl;
    rep(i,n-k-1){
        sm *= 2;
        sm %= mod;
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 31104
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int solve(int L, int N, const vector<int>& X)
{
    vector<Int> Y(N+1), Z(N+1);
    Y[0] = Z[0] = 0;
    for (int i = 0; i < N; i++) {
        Y[i+1] = Y[i] + X[i];
        Z[i+1] = Z[i] + L - X[N-1-i];
    }
    Int ans = 0;
    for (int i = 1; i <= N; i++) {
        int r = i + (N - i) / 2;
        int l = N - r;
        Int d = -2*Y[i-1] + 2*Y[r] + 2*Z[l] - ((N - i) % 2 ? L - X[N-l] : X[r-1]);
        ans = max(ans, d);
    }
    return ans;
}
int main()
{
    int L, N; cin >> L >> N;
    vector<int> X(N);
    for (int& x : X) cin >> x;
    Int a = solve(L, N, X);
    reverse(begin(X), end(X));
    for (auto& x : X) x = L - x;
    Int b = solve(L, N, X);
    cout << max(a, b) << endl;
    return 0;
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

bool visited[MAXN];

void dfs(int here)
{
    visited[here] = true;

    int there;

    for(int i=0;i<graph[here].size();i++)
    {
        there = graph[here][i];
        if(visited[there])continue;
        dfs(there);
    }
    return;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>m;

    graph = vector<vector<int> > (n+1);

    for(int i=0;i<m;i++){
        cin>>x>>y>>a;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    for(int i=1;i<=n;i++){
        if(visited[i])continue;
        dfs(i);
        cnt++;
    }

    cout<<cnt<<"\n";

    return 0;
}


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

int main(void){
char w[105];
int al[36];
for(int i=0;i<=35;i++){
    al[i]=0;
}
scanf("%s",w);
for(int i=0;w[i]!='\0';i++){
    al[w[i]-'a']++;
}
for(int i=0;i<=35;i++){
    if(al[i]%2==1){printf("No");return 0;}
}
printf("Yes");return 0;
}


Measured memory_bytes: 128
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    if A[i] <= 2*(10**5):
        H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)


Measured memory_bytes: 51020