akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);
const ll mod = 998244353;

int main() {
  int N; cin >> N;
  vector<ll> D(N, 0LL);
  bool isPos = true;

  ll fst;
  cin >> fst;
  if (fst > 0LL) isPos = false;

  rep(i, N-1) {
    ll idx; cin >> idx;
    D[idx]++;
  }

  if (D[0] > 0LL) isPos = false;

  int cnt = 0;
  for (int i = 1; i < N; i++) {
    cnt += D[i];
    if ((D[i] == 0LL) && (cnt < N-1)) isPos = false;
  }

  ll ans = 1LL;
  for (int i = 2; i < N; i++) {
    if (D[i] == 0LL) break;
    rep(j, D[i]) {
      ans *= D[i-1];
      ans %= mod;
    }
  }

  if (!isPos) ans = 0LL;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
import sys
import numpy as np
a, b, x = map(int, input().split(" "))
if x >= a**2 * b / 2:
    print(np.arctan(2 * (a**2 * b - x) / (a ** 3)) * 180 / np.pi)
else:
    print(np.arctan((a*b**2)/ (2 * x)) * 180 / np.pi)

Measured memory_bytes: 12396
#include <stdio.h>
#define N 100
int selectionsort(int *,int);
int main(){
  int n,A[N],i,j,count;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
 count =  selectionsort(A,n);
  for(i=0;i<n-1;i++)printf("%d ",A[i]);
  printf("%d",A[n-1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}

int  selectionsort(int *A,int n){
  int i,j,p,tmp,count=0;
  for(i=0;i<n;i++){
    p = i;
    for(j=i;j<n;j++){
      if(A[j]<A[p]){
	p = j;
      }
    }
    if(p!=i){
      tmp=A[i];
      A[i]=A[p];
      A[p]=tmp;
    count++;
    }
  }
  return count;
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

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

	int a,b,c;cin>>a>>b>>c;
	cout<<a*c/2+b*c/2<<endl;

	return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 10.05.2020 20:16:09       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
  }
  const int LOG = 62;
  vector<vector<int>> go(n, vector<int>(LOG));
  for (int i = 0; i < n; i++) {
    go[i][0] = a[i];
  }
  for (int j = 1; j < LOG; j++) {
    for (int i = 0; i < n; i++) {
      go[i][j] = go[go[i][j - 1]][j - 1];
    }
  }
  int x = 0;
  for (int j = LOG - 1; j >= 0; j--) {
    if (k & (1LL << j)) {
      x = go[x][j];
    }
  }
  cout << x + 1 << '\n';
  return 0;
}


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

#define int long long
#define double long double

using namespace std;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e9;

signed main() {

	int h, w;
	cin >> h >> w;
	
	int ans = INF;

	rep(i, 2){

		for(int x = 1; x < w; x++){
			int s0 = x * h;
			int l = (w - x);

			int s1, s2;
			if(l % 2){
				s1 = (l / 2) * h;
				s2 = (l / 2 + 1) * h;
			}else{
				s1 = s2 = (l / 2) * h;
			}
			
			ans = min(ans, max({s0, s1, s2}) - min({s0, s1, s2}));
		}	

		for(int x = 1; x < w; x++){
			int s0 = x * h;
			int l = (w - x);

			int s1, s2;
			if(h % 2){
				s1 = (h / 2) * l;
				s2 = (h / 2 + 1) * l;
			}else{
				s1 = s2 = (h / 2) * l;
			}

			ans = min(ans, max({s0, s1, s2}) - min({s0, s1, s2}));
		}

		swap(w, h);
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
f=[0]*n
cnt=0
while 1:
    flag=0
    for i in range(n):
        if h[i]!=f[i]:
            f[i]+=1
            flag=1
        elif h[i]==f[i] and flag==1:
            cnt+=1
            flag=0
    if flag==1:
        cnt+=1

    if h==f:
        break

print(cnt)


Measured memory_bytes: 3060
#include<cstdio>

int main(){
	long long N, K;
	scanf("%lld %lld", &N, &K);
	if(!K){
		printf("%lld\n", N*N);
		return 0;
	}
	long long answer = 0;
	for (int b = K + 1; b <= N; ++b){
		int m = N/b;
		answer += m*(b - K);
		int remain = N % b - K + 1;
		if(remain >= 0)
			answer += remain;
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(i) for i in input().split()]
odd, two, four = 0, 0, 0
for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        two += 1
    else:
        odd += 1

if (four + odd) % 2 == 0:
    if four >= odd:
        print("Yes")
    else:
        print("No")
else:
    if four > odd:
        print("Yes")
    elif four == (four + odd)//2 and two == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder0928
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            double n = Int32.Parse(str);
            if (n % 2 == 0)
            {
                Console.WriteLine(0.5);
            }
            else
            {
                double d = ((n + 1) / 2) / n;
                Console.WriteLine(d);
            }
            //Console.ReadKey();
        }
        
    }
}


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

int main(){
	ios::sync_with_stdio(false);
	LL a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	puts(a+t*v>=b+t*w&&a-t*v<=b-t*w?"YES":"NO");
	return 0;
}

Measured memory_bytes: 3656
N = int(input())
B = input().split()

history = []
while len(B):

    if B[0] != '1':
        print(-1)
        exit(0)

    bef_kick_len = len(B)
    # if failed, go to kill original

    for ind in range(len(B))[::-1]:
        # print("index {} value {}".format(ind+1, B[ind]))
        if int(B[ind]) == ind + 1:
            history.append(B.pop(ind))
            break

    if len(B) == bef_kick_len:
        for state in range(len(B) - 1):
            # print("state {} state+1 {}".format(state,B[state]))
            if B[state] == B[state + 1]:
                history.append(B.pop(state))
                break

# print(history)

rev_his = reversed(history)
for i in rev_his:
    print(i)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > 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;
}


int main() {
  ll N;
  cin >> N;
  set<ll> st;
  vector<ll> countbox;
  ll last = -1,count=0;
  for(auto p : prime_factor(N)) {
    while(p.second--) {
        ll hoge = p.first;
        if(hoge != last){
            if(last != -1)countbox.push_back(count);
            last = hoge;
            count = 0;
        }
        count++;
    }
  }
  countbox.push_back(count);
  ll ans=0;
  for(auto itr = countbox.begin();itr != countbox.cend();++itr){
      ll now = *itr;

      ll hoge = now,anscount=0;
      for(ll j = 1;j<=now;j++){
          hoge -= j;
          if(hoge >= 0){
              anscount++;
          }
      }
      ans += anscount;
  }
  cout << ans << endl;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> a(H);
  set<int> h,w;
  for(int i=0;i<H;i++){
    bool flag=true;
    cin >> a.at(i);
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)!='.'){
        flag=false;
        break;
      }
    }
    if(flag){
      h.insert(i);
    }
  }
  for(int j=0;j<W;j++){
    bool flag=true;
    for(int i=0;i<H;i++){
      if(a.at(i).at(j)!='.'){
        flag=false;
        break;
      }
    }
    if(flag){
      w.insert(j);
    }
  }
  for(int i=0;i<H;i++){
    if(h.count(i)){
      continue;
    }
    for(int j=0;j<W;j++){
      if(w.count(j)){
        continue;
      }
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    string s;
    cin>>s;
    if(s == "ABC") {
        cout<<"ARC";
    }
    else {
        cout<<"ABC";
    }
    cout<<"\n";
    return ;
}

/*
*/

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

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


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main()
{
    int A,B,C,D,R1,R2;
    cin >> A >> B >> C >> D;
    R1 = A * B;
    R2 = C * D;
    if (R1 > R2) cout << R1;
    else if (R1 < R2) cout << R2;
    else cout << R1;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
typedef struct{
	int a,b,c,d;
}Coin;
int comp(const void* a,const void* b){
	return ((Coin*)a)->d - ((Coin*)b)->d;
}
Coin heap[100000];
int heap_size=0;
void push(Coin x){
 	int i=heap_size++;
 	while(i>0){
 		int p=(i-1)/2;
 		if(heap[p].d<=x.d) break;
 		heap[i]=heap[p];
 		i=p;
 	}
 	heap[i]=x;
 	return;
}
Coin pop(void){
 	Coin data=heap[0];
 	Coin n=heap[--heap_size];
 	int pos=0;
 	while(pos*2+1<heap_size){
 		int a=pos*2+1;
 		int b=pos*2+2;
 		if(b<heap_size&&heap[a].d>heap[b].d) a=b;
 		if(n.d<=heap[a].d) break;
 		heap[pos]=heap[a];
 		pos=a;
 	}
 	heap[pos]=n;
 	return data;
}
Coin coin[100000];
ll sum[100000];
int main(void)
{
	int x,y,z,size,i;
	ll s,res;
	Coin p;
	scanf("%d%d%d",&x,&y,&z);
	size=x+y+z;
	FOR(i,0,size){
		scanf("%d%d%d",&coin[i].a,&coin[i].b,&coin[i].c);
		coin[i].d=coin[i].a-coin[i].b;
	}
	qsort(coin,size,sizeof(Coin),comp);
	s=0;
	FOR(i,0,y){
		s+=coin[i].b;
		p.b=coin[i].b,p.c=coin[i].c,p.d=coin[i].b-coin[i].c;
		push(p);
	}
	sum[0]=s;
	FOR(i,y,y+z){
		p.b=coin[i].b,p.c=coin[i].c,p.d=coin[i].b-coin[i].c;
		s+=p.b;
		push(p);
		p=pop();
		s-=p.d;
		sum[i-y+1]=s;
	}
	//FOR(i,0,x+y+z) printf("%d %d %d\n",coin[i].a,coin[i].b,coin[i].c);
	heap_size=0,s=0;
	FOR(i,0,x){
		s+=coin[size-i-1].a;
		p.a=coin[size-i-1].a,p.c=coin[size-i-1].c,p.d=coin[size-i-1].a-coin[size-i-1].c;
		push(p);
	}
	res=s+sum[z];
	FOR(i,x,x+z){
		p.a=coin[size-i-1].a,p.c=coin[size-i-1].c,p.d=coin[size-i-1].a-coin[size-i-1].c;
		s+=p.a;
		push(p);
		p=pop();
		s-=p.d;
		res=MAX(res,s+sum[z-(i-x+1)]);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3324
N=int(input())

R=[]
for i in range(N):
    a,b=map(int,input().split())
    R.append([a,b])
R.sort()
    
B=[]
for j in range(N):
    c,d=map(int,input().split())
    B.append([c,d])
B.sort()

cnt=0
K=[]
for x in range(N):
    for y in range(N):
        if B[x][0]>R[y][0] and B[x][1]>R[y][1]:
            K.append([R[y][1],R[y][0],y])
    if K==[]:
        pass
    else:
        K.sort(reverse=True)
        R[K[0][2]]=[1000,1000]
        cnt+=1
        K=[]
print(cnt)

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

ll n, m, k;

int main() {
	cin>>n>>m>>k;
	ll a[n+1], b[m+1], psb[m+1];
	for (int i=1; i<=n; i++) {
		cin>>a[i];
	}
	a[0]=0;
	for (int i=1; i<=m; i++) {
		cin>>b[i];
	}
	b[0]=0, psb[0]=b[0];
	for (int i=1; i<=m; i++) {
		psb[i]=psb[i-1]+b[i];
	}
	ll mina=0, ans=0, maxb;
	for (int i=0; i<=n; i++) {
		mina+=a[i];
		if (mina<=k) {
			ll sisa=k-mina;
			//cout<<"sisa: "<<sisa<<endl;
			ll l=0, r=m, mid;
			while (r-l>=0) {
				mid=(l+r)/2;
				if(psb[mid]>sisa) r=mid-1;
				else {
					maxb=mid;
					l=mid+1;
				}
			}
			ll jwb=i+maxb;
			//cout<<i<<" "<<maxb<<" "<<jwb<<endl;
			ans=max(ans, jwb);
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 8188
#include<iostream>
using namespace std;
int main(){
	int n,sum,h,w,x,y,X,Y,N;
	cin>>n;
	while(n-->0){
		sum=0;
		cin>>x>>y>>w>>h;
		cin>>N;
		for(int i=0;i<N;i++){
			cin>>X>>Y;
			if(X>=x&&X<=x+w&&Y>=y&&Y<=y+h)
				sum++;
		}
		cout<<sum<<endl;
	}
	return 0;
}
		

Measured memory_bytes: 0
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
           int h,t=0;
           cin>>h;
            while(h!=1){
                h=h/2;
                t++;
            }
            cout<<(1ll<<(t+1))-1;


           return 0;

        }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x,y,sum=0,i,j,k;
    cin>>n>>k>>x>>y;
    if(n<=k)
    {
        sum=n*x;
        cout<<sum<<endl;
        return 0;
    }
    i=n-k;
    j=k*x;
    long long p=i*y;
    sum=p+j;
    cout<<sum<<endl;


}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(std::string S){
    ll len_max = 0;
    ll len = 0;

    rep(i, 3) {
        // cout << S[i] << endl;
        if (S.at(i) == 'R') {
            len++;
        } else {
            len = 0;
        }
        if (len > len_max) {
            len_max = len;
        }
    }
    if (len > len_max) {
        len_max = len;
    }
    cout << len_max << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    func(S);
    return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#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 repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
} 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
int get(char c){
	if(c >= 'A') c = tolower(c);
	return c;
}
int p[N];
void solve()
{ 
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j * i <= n; ++j) p[i * j] += 1;
	int res = 0;
	for(int i = 1; i < n; ++i){
		res += p[n - i];
	}
	cout << res;
}
	


int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 7424
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, a, b, c, d, e;

int main(){
    INIT;
    cin >> n >> a >> b >> c >> d >> e;
    LL m = min({a, b, c, d, e});
    cout << 5 + n/m - (n % m == 0 ? 1 : 0) << endl;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &&ai : a)
    {
        cin >> ai;
    }

    // 解
    int overallsum = 0;
    for (int i = 0; i < n; i++)
    {
        overallsum ^= a[i];
    }
    vector<int> x(n, overallsum);
    for (int i = 0; i < n; i++)
    {
        x[i] ^= a[i];
    }
    
    printvec(x);

    return 0;
}

Measured memory_bytes: 4792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    res = accumulate(a.begin(),a.end(),0LL) - N;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    

    int x,y,s;
    while(cin >> x >> y >> s,x){
        int ans = 0;
        auto tax = [&](int c1,int c2,int t){
            return c1*(100+t)/100 + c2*(100+t)/100;
        };
        for(int c1 = 1; c1 < s; c1++){
            for(int c2 = 1; c2 < s; c2++){
                if(tax(c1,c2,x) == s) ans = max(ans,tax(c1,c2,y));
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include "math.h"

using namespace std;

int main() {
    
    int n, k;
    
    cin >> n >> k;
    
    if (2*k-1 <= n) {
        cout << "YES" <<endl;
    } else {
        cout << "NO" <<endl;
    }

    return 0;
    
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<int>>bingo(3, vector<int>(3));
  vector<vector<int>>atari(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      int a;
      cin>>a;
      bingo.at(i).at(j)=a; //ビンゴカード
    }
  }
  int N;
  cin>>N;
  vector<int> number(N);
  for(int k=0; k<N; k++){
    int b;
    cin>>b;
    number.at(k)=b;
  }
  for(int k=0; k<N; k++){
    for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(bingo.at(i).at(j)==number.at(k)){
        atari.at(i).at(j)=1;
      }
    }
  }
  }
  int tate1=(atari.at(0).at(0)+atari.at(1).at(0)+atari.at(2).at(0));
  int tate2=(atari.at(0).at(1)+atari.at(1).at(1)+atari.at(2).at(1));
  int tate3=(atari.at(0).at(2)+atari.at(1).at(2)+atari.at(2).at(2));
  int yoko1=(atari.at(0).at(0)+atari.at(0).at(1)+atari.at(0).at(2));
  int yoko2=(atari.at(1).at(0)+atari.at(1).at(1)+atari.at(1).at(2));
  int yoko3=(atari.at(2).at(0)+atari.at(2).at(1)+atari.at(2).at(2));
  int naname1=(atari.at(0).at(0)+atari.at(1).at(1)+atari.at(2).at(2));
  int naname2=(atari.at(0).at(2)+atari.at(1).at(1)+atari.at(2).at(0));
  if(tate1==3 || tate2==3 || tate3==3 || yoko1==3 || yoko2==3 || yoko3==3 || naname1==3 || naname2==3){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

void z_algo(const string& s, vector<int>& z)
{
  const int n = s.size();
  z.assign(n, 0);
  int R, L;
  R = L = 0;
  for (int i = 1; i < n; i++){
    if (i > R){
      L = R = i;
      while (R < n && s[R - L] == s[R]) R++;
      z[i] = R - L;
      R--;
    }
    else {
      int k = i - L;
      if (z[k] < R - i + 1) z[i] = z[k];
      else {
        L = i;
        while (R < n && s[R - L] == s[R]) R++;
        z[i] = R - L;
        R--;
      }
    }
  }
}


int main()
{
  string s, t;
  while (cin >> s >> t){
    const string S = s + '$' + t;
    const int sl = s.size();
    int maxi = 0;
    for (int i = 0; i < sl; i++){
      vector<int> z;
      z_algo(S.substr(i), z);
      maxi = max(maxi, *max_element(begin(z) + (sl - i), end(z)));
    }
    cout << maxi << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <algorithm>
#include <iostream>
#include <string.h>
#include <map>
#include <queue>

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const ll N=10005;
ll n,m,c[10][N];

int main()
{
    while (true) {
        scanf("%lld%lld",&n,&m);
        if (n==0&&m==0) break;
        for (ll i=0;i<n;i++) {
            for (ll j=0;j<m;j++) {
                scanf("%lld",&c[i][j]);
            }
        }
        vector<ll> vec;
        for (ll i=0;i<m;i++) {
            ll tmp=0;
            for (ll j=0;j<n;j++) {
                tmp|=(c[j][i]<<j);
            }
            vec.pb(tmp);
        }
        ll ans=0;
        for (ll i=0;i<(1ll<<n);i++) {
            ll tmp=0;
            for (ll j:vec) {
                ll ones=__builtin_popcount(i^j);
                tmp+=max(ones,n-ones);
            }
            ans=max(ans,tmp);
        }
        printf("%lld\n",ans);
    }
}


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

int main() {
    int q;cin>>q;
    list<int > v;
    auto it=v.end();
    while(q--){
        int a;cin>>a;
        if(a==0){
            int x;cin>>x;
            it=v.insert(it,x);
        }
        else if(a==1){
            int d;cin>>d;
            if(d>0) {
                for(int i=0;i<d;++i){
                    it++;
                }
            }
            else if(d<0){
                for(int i=0;i < (d*(-1)); ++i){
                    it--;
                }
            }
        }
        else if(a==2){
            /*if(*it==v.back()){
                v.erase(it);
                it=v.end();
                continue;
            }*/
            it=v.erase(it);

        }
    }
    for(auto i:v){
        cout<<i<<endl;
    }
    return 0;
}



Measured memory_bytes: 18636
#include<stdio.h>
int main(){
	char s[1100];
	int n;
	scanf("%d",&n);
	getchar();
	for(int i=0;i<n;i++){
		fgets(s,1100,stdin);
		int j;
		for(j=0;s[j]!='\0';j++)
			if(s[j]=='H'&&s[j+1]=='o'&&s[j+2]=='s'&&s[j+3]=='h'&&s[j+4]=='i'&&s[j+5]=='n'&&s[j+6]=='o')s[j+6]='a';
		printf("%s",s);
		s[0]='\0';}
	return 0;}


Measured memory_bytes: 2624
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	lli n, ans;
	vector<lli> a(200, 0);
	string s;
	cin >> n >> s;
 	rep(i,n) a[s[i]]++;

	ans = a['R'] * a['B'] * a['G'];

	rep(i,n){
		loop(j, i+1, n){
			int k = j+(j-i);
			if(k < n){
				if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--;
			}
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int mod(int a,int b)
{
    if(a-b<0)
      return b-a;
    else
    {
        return a-b;
    } 
}
int main()
{
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
vector<int> dist(n);
dist[0]=0;
int s=mod(arr[0],arr[1]);
dist[1]=s;
for(int i=2;i<n;i++)
{
    dist[i]=min(dist[i-1]+mod(arr[i],arr[i-1]),dist[i-2]+mod(arr[i],arr[i-2]));
}
 cout<<dist[n-1];
    return 0;
}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    int mx=0;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mx=max(mx,++mp[s]);
    }
    for(auto e:mp){
        if(mx==e.second){
            cout<<e.first<<endl;
        }
    }
}


Measured memory_bytes: 25216
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    ll n,m; cin>>n>>m;
    vector<ll>h(n);
    rep(i,n)cin>>h[i];
    Graph G(n);
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll ans=0;
    ll sum=0;
 
      rep(i,n){
          bool b=false;
        ll mx=h[i];
            for(auto nv:G[i]){
                if(h[i]<=h[nv]){
                    b=true;
                }
            }
            if(!b)sum++;
        }
 
    
    cout<<sum<<endl;
}






Measured memory_bytes: 9028
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        v = 0
        for k in range(D):
            v += (X[j][k] - X[i][k]) ** 2
        sr = v ** 0.5
        a = int(sr)
        b = a + 1
        if a * a == v or b * b == v:
            ans += 1

print(ans)

Measured memory_bytes: 3188
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll n, x, cnt = 0;
    cin >> n >> x;
    ll v[n];
    fore(i,0,n) {
        cin >> v[i];
        if (i) {
            ll sum = v[i-1]+v[i];
            if (sum > x) {
                sum -= x;
                ll mn = min(v[i], sum);
                v[i] -= mn;
                cnt += sum;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
// review
#include <iostream>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MAXN = 100010;
ll h, w, n;
ll a[MAXN], b[MAXN];
ll _count[10];
map<P, int> m;
void solve() {
  for (int i=0;i<n;i++) {
    for (int x=0;x<=2;x++) {
      for (int y=0;y<=2;y++) {
        int nx = b[i] - x;
        int ny = a[i] - y;
        if (nx >=0 && nx < w-2 && ny >= 0 && ny < h-2) {
          m[P(nx, ny)]++;
        }
      }
    }
  }
  ll tot = 0;
  for (auto const& x : m) {
    _count[x.second]++;
    tot++;
  }
  _count[0] = (h-2) * (w-2) - tot;
  for (int i=0;i<10;i++) {
    cout << _count[i] << endl;
  }
}

int main() {
  cin >> h >> w >> n;
  for (int i=0;i<n;i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  solve();
}


Measured memory_bytes: 58112
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:], i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if a[idx] >= key:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8(i8, i8[:])", cache=True)
def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = binary_search(L, L[a] + L[b]) - 1
            ans += c - b
    return ans


def main():
    N = int(input())
    L = np.array(input().split(), dtype=np.int64)

    ans = solve(N, L)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106828
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[300010];
std::map<ll, ll> cnt, mp;
ll S[300010];

ll sum;

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

  rep( i, N )
    std::cin >> A[i], ++cnt[A[i]], sum += A[i];

  rep( i, 300001 ) if( cnt.count( i ) ) repi( j, 1, cnt[i]+1 )
    ++mp[j];

  rep( i, N+2 )
    S[i+1] = S[i]+mp[i];

  repi( K, 1, N+1 )
  {
    ll ng = -1, ok = N+1;

    while( ok-ng > 1 )
    {
      ll mid = (ng+ok)/2;

      auto C = [&]( ll x, ll k ) {
        return S[x+1] < k*x;
      };

      (C(mid, K) ? ok : ng) = mid;
    }

    std::cout << ok-1 << std::endl;
  }

  return 0;
}

Measured memory_bytes: 41600
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define float double
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>;
using vf = vector<float>; using vvf = vector<vf>; using vd = vector<double>; using vvd = vector<vd>;
using str = string; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pff = pair<float, float>; using pdd = pair<double, double>;
using psl = pair<string, ll>; using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline int ord(char c) {return (int)c;}
static inline char chr(int n) {return (char)n;}
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int N; cin>>N;
    vs S(N); REP(i,N) cin>>S[i];

    set<str> st;
    REP(i,N)
        st.insert(S[i]);

    int ans = st.size();
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 25096
#! -*- coding: utf-8 -*-

n = int(raw_input())
a = map(int,raw_input().split())

a.insert(0,0)
a.append(0)

moto = 0
for i in range(n+1):
    moto += abs(a[i]-a[i+1])

for i in range(n):
    ans = moto - abs(a[i]-a[i+1]) - abs(a[i+1]-a[i+2]) + abs(a[i]-a[i+2])
    print ans


Measured memory_bytes: 11108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

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

    vector<bool> dp(K+1, false);

    for (int i = 1; i <= K; ++i) {
        bool f=false;
        for(auto v:a){
            if(i-v>=0&&!dp[i-v]){
                f=true;
                break;
            }
        }
        if(f) dp[i]=true;
    }

    cout<<(dp[K]?"First":"Second")<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<ll> explode(string const & s, char delim) {
    vector<ll> result;
    string token;
    for (istringstream iss(s); getline(iss, token, delim);) result.push_back(stoll(token));
    return result;
}

void solve() {
    int h, w;
    cin >> h >> w;
    int t = 0;
    string s;
    REP(i, h) {
        cin >> s;
        REPS(c, s) if (c == '#') t++;
    }
    cout << (t == h + w - 1 ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
S=input()

ans=0
for i in range(1 << len(S)-1):
    s=S[:]
    for j in reversed(range(len(S)-1)):
        if ((i >> j) & 1) == 1:
            s=s[:j+1] + "+" + s[j+1:]
    ans+=eval(s)
print(ans)

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

ll power(ll n, ll k){
	ll res = n;
	k--;
	while(k){
		res *= n;
		k--;
	}
	return res;
}

int main() {
	
	ll n;
	cin >> n;
	if(n % 2 == 1){
		cout << 0 << endl;
		return 0;
	}
	n /= 2;
	ll div5 = 0;
	int pow = 1;
	while(power(5, pow) <= n){
		div5 += n / power(5, pow);
		pow++;
	}
	cout << div5 << endl;
	
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long

void solve()
{
    int n;
    cin>>n;
    if(n==(int)1) cout<<0;
    else cout<<1;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++) solve();
    return 0;
}



Measured memory_bytes: 3636
/*
 * CircleinaRectangle.c
 *
 *  Created on: 2015/02/12
 */

#include <stdio.h>

int main(void){
	int W,H,x,y,r;

	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if(0 > y - r) printf("No\n");
	else if(H < y + r) printf("No\n");
	else if(0 > x - r) printf("No\n");
	else if(W < x + r) printf("No\n");
	else printf("Yes\n");

	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
int gcd(int x, int y) {
    if (y == 0)return x;
    else return gcd(y, x % y);
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;
}


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

static const int MAX = 200;
static const int INF = 1e9;

// 階乗
int factorial(int n) {
  if(n == 0) return 1;
  return n * factorial(n - 1);
}

// ワ―シャルフロイド法 O(V^3)
int n, M[MAX][MAX];
// main関数からこれらを削除すること

void warshall_floyd() { // 隣接行列Mを書き換える
  for(int i = 0; i < n; i++) // 経由する頂点
    for(int j = 0; j < n; j++) // 始点
      for(int k = 0; k < n; k++) // 終点
        M[j][k] = min(M[j][k], M[j][i] + M[i][k]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 重み付き無向(有向)グラフの隣接行列
  int m, r, u, v, w;
  cin >> n >> m >> r;
  
  vector<int> p(r);
  for(int i = 0; i < r; i++) cin >> p.at(i);
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      M[i][j] = INF; // 大きな数で初期化
    }
  }
  
  for(int i = 0; i < m; i++){
    cin >> u >> v >> w;
    u--;
    v--;
    M[u][v] = w;
    M[v][u] = w; // 重み付き有向グラフではこの行をコメントアウト
  }
  
  warshall_floyd();
  
  long long ans = 1e15;
  for(int i = 0; i < factorial(r); i++){
    long long keep = 0;
    for(int j = 0; j < r - 1; j++){
      keep += M[p.at(j) - 1][p.at(j + 1) - 1];
    }
    ans = min(ans, keep);
    next_permutation(p.begin(), p.end());
  }
  
  cout << ans << "\n";
}

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

def main():
    N = int(input())
    F = [int(input().replace(" ", ""), 2) for _ in range(N)]
    P = [list(map(int, input().split())) for _ in range(N)]

    ans = -10**7*N
    for i in range(1, 1<<10):
        tmp = 0
        for j,f in enumerate(F):
            c = bin(i&f).count("1")
            tmp += P[j][c]
        ans = max(ans, tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    a.insert(n, 0)
    a.insert(0, 0)

    all_cost = 0
    for i in range(1, n+2):
        all_cost += abs(a[i] - a[i-1])

    for i in range(1, n+1):
        diff_cost = abs(a[i+1] - a[i-1]) - ( abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) )
        print(all_cost + diff_cost)

if __name__ == '__main__':
    main()


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

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> A(a), B(b);
  rep(i,a) cin >> A[i];
  rep(i,b) cin >> B[i];
  
  int amin = 1001001001, bmin = 1001001001;
  rep(i,a) amin = min(amin,A[i]);
  rep(i,b) bmin = min(bmin,B[i]);
  int ans = amin + bmin;
  
  rep(i,m) {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans,A[x]+B[y]-c);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024