akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
	int n,t,a,h,ans;
	double min_d = 100000;
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> h;
		double d;
		d = abs(a - (t - h * 0.006));
		if (d < min_d) {
			ans = i+1;
			min_d = d;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

dp = [[ 0 for _ in range(3)]for _ in range(n+10)]

for i in range(3):
    dp[0][i] = A[0][i]

for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][k] = max(dp[i][k], dp[i-1][j]+A[i][k])

print(max(dp[n-1]))

Measured memory_bytes: 74712
# 1．入力を受け取ること
# スペース区切りの入力を整数として受け取れる「2 5」　->　「a=2, B=5」となる
a, b = map(int, input().split())

# print(a)
# print(b)

# 2.受け取った結果を使って目的の計算をすること

answer = a * b

# 3.出力すること
print(answer)

Measured memory_bytes: 9092
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

#define size_t int

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  char s[N][100];
  string ss[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%s", s[i]);
    ss[i] = s[i];
  }
  for (size_t i = 0; i < N; i++) {
    if (i != 0 && ss[i][0] != ss[i - 1][ss[i - 1].size() - 1]) {
      printf("No\n");
      return 0;
    }
    for (size_t j = 0; j < i; j++) {
      if (ss[i] == ss[j]) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

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

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string S[10050];
int A = 0;
int BA = 0;
int B=0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> S[i];
        for(int j = 0; j < S[i].size(); j++) {
            if(S[i].substr(j, 2) == "AB") ans++;
        }
        if(S[i][0] == 'B' && S[i].back() == 'A') BA++;
        else if(S[i][0] == 'B') B++;
        else if(S[i].back() == 'A') A++;
    }
    if(BA >= 2) {
        ans += BA - 1;
        BA = 1;
    }
    if(BA == 1 && B >= 1) {
        BA = 0;
        ans++;
    }
    if(BA == 1 && A >= 1) {
        BA = 0;
        ans++;
    }
    ans += min(A, B);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main() {
	fast;
	int n,k;
	cin>>n>>k;
	vector<int> arr(n);
	bool dp[k+1];
	memset(dp,false,sizeof(dp));
	for(int i=0;i<n;i++) cin>>arr[i];
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
		    if(i-arr[j]>=0){
		    	if(dp[i-arr[j]]==false){
		    	   dp[i]=true;
		    	   break;
		    	}
		    }
		}
	}
	cout<<((dp[k]==false)?"Second":"First")<<"\n";
	return 0;
}

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

using namespace std;

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		x = max(x, a);
	}
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		y = min(y, a);
	}
	cout << (x < y ? "No War" : "War") << endl;
	return 0;
}


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

int main(){
  int n, m, c = 0;
  cin >> n >> m;
  if(!(n <= 1)){
    c += n*(n - 1)/2;
  }
  if(!(m <= 1)){
    c += m*(m - 1)/2;
  }
  cout << c << endl;
}

Measured memory_bytes: 3608
n = int(input())
dict = {}
for i in range(n):
  temp = input()
  if temp in dict:
    dict[temp] += 1
  else:
    dict.setdefault(temp, 1)
    
m = int(input())
for i in range(m):
  temp = input()
  if temp in dict:
    dict[temp] += -1
  else:
    dict.setdefault(temp, -1)
    
max_value = max(dict.values())
print(max(max_value, 0))
    

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

N = int(input())
robot_number = 0
arm_ranges = []
for n in range(N):
    [x, l] = [int(i) for i in input().split()]
    minimum = x - l
    maximum = x + l
    arm_ranges.append((maximum, minimum))

# 腕の届く端が小さいもの順にソート
arm_ranges_sorted = sorted(arm_ranges)

(ma, mi) = arm_ranges_sorted[0]
now_max = ma
robot_number += 1
for arm_range in arm_ranges_sorted[1:]:
    (ma, mi) = arm_range
    if mi >= now_max:
        robot_number += 1
        now_max = ma

print(robot_number)

Measured memory_bytes: 18192
import math
N=list(input())
K=int(input())
ans=0
not_zero=0
def cmb(n, r):
  if n-r>=1 and n>=1 and r>=1: 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  elif n==r or n==r:
    return 1
  elif r==0:
    return 1
  else:
    return 0
for i in range(len(N)):
  if N[i]!="0":
    ans+=cmb(len(N[i+1:]),K-not_zero) * (9**(K-not_zero))
    ans+=cmb(len(N[i+1:]), K-not_zero-1) *(int(N[i])-1)* (9**(K-not_zero-1))
    not_zero+=1
    #print(ans)
    if not_zero==K:
      ans+=1
      break
print(ans)
  

Measured memory_bytes: 3064
#include <iostream>
typedef long long ll;
using namespace std;

ll dp[3005][3005];
ll a[3005];
int n;
const ll INF = -1e14;
ll rec(int i, int j, bool AorB) {
  if(i > j) return 0;
  if(dp[i][j] > INF) return dp[i][j];
 
  ll res;
  if(AorB) {
    res = max(rec(i+1,j,false) + a[i], rec(i,j-1,false) + a[j]);
  }
  else {
    res = min(rec(i+1,j,true) - a[i], rec(i,j-1,true) - a[j]);
  }
  //cout << i <<"   "<< j << endl;
  //cout << res << endl;
 return dp[i][j] = res;
}


int main() {
  cin >> n;

  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= n; j++) {
      dp[i][j] = INF;
    }
  }
  cout << rec(0,n-1,true) << endl;
}


Measured memory_bytes: 70912
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
from collections import defaultdict
def main():
    N = S()
    N =  N[::-1]
    N += '0'
    cnt = 0
    next = 0
    for i in range(len(N)):
        num = int(N[i])
        num += next
        if num <= 4:
            cnt += num
            next = 0
        elif num >= 6:
            cnt += 10 - num
            next = 1
        else:
            if int(N[i + 1]) <= 4:
                cnt += num
                next = 0
            else:
                cnt += 10 - num
                next = 1

    print(cnt)
if __name__ == "__main__":
    main()


Measured memory_bytes: 79912
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A - B >= C) {
		cout << 0 << endl;
	}
	else {
		cout << C - (A - B) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = input()

result = "AC"
if n[0] != "A":
        result = "WA"
        print(result)
        quit()

carea = n[2:-1]
ccount = 0
for i in carea:
        if i == "C":
                ccount += 1
if ccount >= 2 or ccount == 0:
        result = "WA"
        print(result)
        quit()

for i in carea:
        if i == "A":
                result = "WA"
                print(result)
                quit()

if n[-1] == "C" or n[-1] == "A":
        result = "WA"
        print(result)
        quit()

if n[1] == "C" or n[1] == "A":
        result = "WA"
        print(result)
        quit()


for i in n:
        if i.isupper() == True:
                if i not in "AC":
                        result = "WA"
                        print(result)
                        quit()
print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>x
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve() {

}

bool ok(vll a) {
    fore(i, 1, sz(a) - 1) {
        if (a[i] < a[i - 1]) {
            return false;
        }
    }
    return true;
}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }*/
    ll n;
    cin >> n;
    vll a(n);
    forn(i, n) cin >> a[i];
    vll b = a;
    sort(all(b));
    ll cnt = 0;
    forn(i,n){
        if(a[i] != b[i]){
            cnt++;
            if(cnt > 2){
                cout << "NO";
                return 0;
            }
        }
    }
    cout <<"YES";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define lint long long
#define pb(a) push_back(a)

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;

using namespace std;

int n;
lint ans;

int main(){
  cin >> n;
  lint a = 1;
  lint b = 1;
  REP(i,n){
    int t,s;
    cin >> t >> s;
    lint n_a = (a-1)/t *t +t;
    lint n_b = (b-1)/s *s +s;
    if(n_a/t*s>n_b){
      a = n_a;
      b = n_a/t*s;
    }
    else{
      b = n_b;
      a = n_b/s*t;
    }
  }
  cout << a+b <<endl;
  return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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 T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
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;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long N){
    int ans=(double)N/1.08;
    REP(i,ans-5,ans+5){
        if(floor(i*1.08)==(double)N){
            cout<<i<<endl;
            return;
        }
    }
    cout<<":("<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
from bisect import bisect_left
INF = float("inf")


def solve(W: int, H: int, N: int, x: "List[int]", y: "List[int]", a: "List[int]"):
    X = [[0], [W], [0], [H]]
    for i in range(N):
        b = a[i]-1
        if b == 0 or b == 1:
            X[b].append(x[i])
        else:
            X[b].append(y[i])
    lower_x = max(X[0])
    upper_x = min(X[1])
    lower_y = max(X[2])
    upper_y = min(X[3])

    area = max(upper_x-lower_x, 0)*max(upper_y-lower_y, 0)
    print(area)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    a = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        a[i] = int(next(tokens))
    solve(W, H, N, x, y, a)


if __name__ == '__main__':
    main()


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

#define MOD (1000000007LL);

using namespace std;


int main(void){
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    for(int i = 0; i < b; i++) cout << a;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 1e2+5;
const int INF = 1e9;
const int MOD = 1e9+7;
#define int ll

int n, k;
int a[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	int f[N][k+5];
	int pre[N][k+5];
	for(int j=0; j<=a[1]; j++){
		f[1][j] = 1;
		pre[1][j]=1;
	}
	for(int j=1; j<=k; j++){
		(pre[1][j] += pre[1][j-1]) %= MOD;
	}

	for(int i=2; i<=n; i++){
		pre[i][0] = f[i][0] = 1;
		for (int j=1; j<=k; j++){
			int left = (j-a[i]-1 < 0)? 0LL : pre[i-1][j-a[i]-1];
			pre[i][j] = f[i][j] = (pre[i-1][j] + MOD - left) % MOD;
			(pre[i][j] += pre[i][j-1]) %= MOD;
		}
	}
	// for(int i=0; i<=n; i++){
	// 	for(int j=0; j<=k; j++){
	// 		cerr << f[i][j] << " ";
	// 	}
	// 	cerr << endl;
	// }
	// for(int i=0; i<=n; i++){
	// 	for(int j=0; j<=k; j++){
	// 		cerr << pre[i][j] << " ";
	// 	}
	// 	cerr << endl;
	// }
	int ans = f[n][k];
	cout << ans << endl;

	return 0;
}


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

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            int a=sc.nextInt();
            if(a%2==0){
                if(a%3!=0&&a%5!=0){
                    System.out.println("DENIED");
                    System.exit(0);
                }
            }
        }
        System.out.println("APPROVED");
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

vector<pair<int,int>> adj[100010];
int dis[100010];
bool visit[100010];

void solve(){

    int v,e,r;
    cin >> v >> e >> r;
    rep(i,e){
        int x,y,z;
        cin >> x >> y >> z;
        adj[x].emplace_back(make_pair(y,z));
        //adj[y].emplace_back(make_pair(x,z));
    }

    rep(i,v){
        dis[i]=INF;
        visit[i]=false;
    }

    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
    q.push(make_pair(0,r));
    visit[r]=true;
    dis[r]=0;
    while(!q.empty()){
        auto p = q.top();
        q.pop();
        int d = p.first;
        int node = p.second;
        if(dis[node]!=d) continue;
        visit[node] = true;
        for(auto e: adj[node]){
            if(!visit[e.first]){
                int x = e.first;
                int distance = e.second;
                dis[x]=min(dis[x],dis[node]+distance);
                q.push(make_pair(dis[x],x));
            }
        }
    }
    
    rep(i,v){
        if(dis[i]!=INF) cout << dis[i] << endl;
        else cout << "INF" << endl;
    }

}


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



Measured memory_bytes: 20564
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
//__int128


int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int a, p;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> a >> p;
	cout << (a * 3 + p) / 2;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	int a;
	a=2*d+1;
	int b;
	b=n/a;
	int c,g;
	c=b*a;
	g=n-c;
	if(g==0){
		cout<<b; 
	} 
	else{
		int f=b+1;
		cout<<f;
	}
} 

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

int main(){
	int k,n;
	cin >> k >> n;
	int a[n];
	for(int i =0;i<n;i++){
		cin >> a[i];
	}
	int sum = 0;
	vector<int> dis(n);
	for(int i =0;i<n;i++){
		dis[i] = (a[(i+1)%n] - a[i]+k)%k;
		sum+=dis[i];
	}
	sort(dis.begin(),dis.end());
	sum-=dis[n-1];
	cout << sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
signed main(){
  long long n,ans[1050000],mem,ans1=0,e,a,b,c,d=0,ans2=0;
  vector<long long> day;
  long long day2[100000];
  cin>>n;
  for(int l=0;l<n;l++){
    cin>>mem;
    day.push_back(mem);
  }
  for(int bit =1;bit<(1<<n);bit++){
    vector<long long > S;
    for(int i=0;i<n;i++){
      if(bit & (1<<i)){
	S.push_back(day[i]);
      }
    }
    ans[bit]=1;
    for(int j=0;j<(int)S.size();j++){
      a=S[j];
      b=ans[bit];
      for(;;){
	if(a<b)
	  swap(a,b);
	if(a%b==0){
	  e=b;
	  break;
	}
	else{
	  c=a;
	  a=b;
	  b=c%b;
	}
      }
      ans[bit]=ans[bit]*S[j]/e;
    }
    for(int k=0;k<n;k++){
      if(ans[bit]%day[k]==0)
	ans2++;
    }
    if(ans2>(int)S.size())
      ans1++;
    ans2=0;
  }
  cout<<(1<<n)-1-ans1<<endl;
  return(0);
}  


Measured memory_bytes: 11336
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define INF 1e9

int main(){
  int n;
  cin >> n;
  long long dp[101][64];
  for(int i=0;i<101;i++){
    for(int j=0;j<64;j++){
      dp[i][j] = 0;
    }
  }
  for(int i=0;i<64;i++){
    dp[3][i] = 1;
  }

  int c1,c2,c3;
  long long count;
  int A,C,G,T;
  A = 3;
  C = 2;
  G = 1;
  T = 0;
  dp[3][16*A+4*G+C] = 0;
  dp[3][16*A+4*C+G] = 0;
  dp[3][16*G+4*A+C] = 0;

  for(int i=3;i<n;i++){
    for(int j=0;j<64;j++){
      count = dp[i][j]%1000000007;
      c1 = j/16;
      c3 = j%4;
      c2 = (j - 16*c1 - c3)/4;
      if(c2 == A && c3 == G){
        dp[i+1][16*A+4*G+A] += count;
        dp[i+1][16*A+4*G+G] += count;
        dp[i+1][16*A+4*G+T] += count;
      }
      else if(c2 == A && c3 == C){
        dp[i+1][16*A+4*C+A] += count;
        dp[i+1][16*A+4*C+C] += count;
        dp[i+1][16*A+4*C+T] += count;
      }
      else if(c2 == G && c3 == A){
        dp[i+1][16*G+4*A+A] += count;
        dp[i+1][16*G+4*A+G] += count;
        dp[i+1][16*G+4*A+T] += count;
      }

      else if(c1 == A && c3 == G){
          dp[i+1][16*c2+4*c3+A] += count;
          dp[i+1][16*c2+4*c3+G] += count;
          dp[i+1][16*c2+4*c3+T] += count;
      }

      else if(c1 == A && c2 == G){
          dp[i+1][16*c2+4*c3+A] += count;
          dp[i+1][16*c2+4*c3+G] += count;
          dp[i+1][16*c2+4*c3+T] += count;
      }

      else {
        for(int k=0;k<4;k++){
          dp[i+1][16*c2+4*c3+k] += count;
        }
      }

    }
  }

  count = 0;
  for(int i=0;i<64;i++){
    count += dp[n][i]%1000000007;
  }

  cout << count%1000000007 << endl;



  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char input[11] = {0};
  char *ptr = input;
  int max = 0;
  int ctr = 0;
  scanf("%s",input);
  while (*ptr != 0){
    if (*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
      ctr += 1;
    } else {
      ctr = 0;
    }
    if (max < ctr){
      max = ctr;
    }
    ptr++;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    ll A, B, K; cin >>A>>B>>K;

    if (A>=K) {
        A-=K;
    } else {
        K-=A;
        A=0;
        B= max(0LL, B-K);
    }

    cout << A << " " << B<< endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define fi first
# define se second
# define ll long long

using namespace std ;

int N, d ;
vector < int > vc ;
int main() {
    cin >> N ;
    for( int i = 0 ; i < N ; i ++ ) {
        cin >> d ;
        vc.push_back(d) ;
    }
    if( N % 2 ) cout << 0 << endl;
    else {
        sort(vc.begin(), vc.end() ) ;
        cout << vc[N/2] - vc[N/2-1] << endl;
    }
}


Measured memory_bytes: 892
c = []
while True:
    n, x = [int(i) for i in input().split()]
    if n == 0 and x == 0:
        break
    else:
        b = {}
        for i in range(1,n+1):
            for j in range(1,n+1):
                for k in range(1,n+1):
                    if i == j or j == k or i == k:
                        break
                    elif i + j + k == x:
                        c = [i,j,k]
                        b[" ".join(map(str, sorted(c)))] = i + j + k
    print(len(b))



Measured memory_bytes: 5648
import java.util.Scanner



object Main extends App {

  def read() = {
    val sc: Scanner = new Scanner(System.in)
    val a, k, q = sc.nextInt
    val correctAnswers = (1 to q).map { _ =>
      sc.nextInt
    }
    sc.close()
    (a, k, q, correctAnswers)
  }



  def solve(): String = {
    val (a, k, q, correctAnswers) = read()
    val defaultArr = Array.fill(a)(k-q)
    val correctCount = Array.fill(a)(0)
    correctAnswers.foreach { v =>
      correctCount(v-1) += 1
    }
    val resultArr = for(i <- 0 until defaultArr.length) yield {
      defaultArr(i) + correctCount(i)
    }
    val ans = resultArr.map { point =>
      if(point > 0) "Yes" else "No"
    }
    ans.mkString("\n")
  }

  println(solve)

}


Measured memory_bytes: 59372
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int A, B, C;
		cin >> A >> B >> C;

		int ans = 0;
		if( B >= C ) {
			ans += B + C;
		}
		else {
			ans += B + B;
			C -= B;
			ans += min( A, C );
			C -= min( A, C );
			ans += C > 0;
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();

	return 0;
}


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

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  set<int> is[26];
  rep(i,n) is[s[i]-'a'].insert(i);
  rep(qi,q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      int i; char c;
      cin >> i >> c;
      --i;
      is[s[i]-'a'].erase(i);
      s[i] = c;
      is[s[i]-'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      --l;
      int ans = 0;
      rep(i,26) {
        auto it = is[i].lower_bound(l);
        if (it != is[i].end() && *it < r) ++ans;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}


Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

int N;
vector<int> fact;
vector<int> factIE;
int I2;

long long power(long long b,long long e){
  long long r=1;
  while(e){
      if(e&1){
          r=(r*b)%MOD;
      }
      b=(b*b)%MOD;
      e >>=1;
  }
  return r;
}

long long inverse(long long b){
  long long r=1,e=MOD-2;
  while(e){
      if(e&1){
          r=(r*b)%MOD;
      }
      b=(b*b)%MOD;
      e >>=1;
  }
  return r;
}


int comb(int n,int r){
    int R = fact[n];
    R = (R*factIE[r])%MOD;
    R = (R*factIE[n-r])%MOD;
    return R;
}

int calc(int a,int b){
    int A=0,B=0;
    int k = I2;
    OREP(i,a){
        int c = comb(a,i);
        int d = (c*k)%MOD;
        if(i%2==1){d = (MOD-d)%MOD;}
        A = (A+d)%MOD;
        k = (k*I2)%MOD;
    }
    k = I2;
    OREP(i,b){
        int c = comb(b,i);
        int d = (c*k)%MOD;
        if(i%2==1){d = (MOD-d)%MOD;}
        B = (B+d)%MOD;
        k = (k*I2)%MOD;
    }
    int R = (A*B)%MOD;
    return R;
    
}


signed main(void){
    int N,a,b;
    vector<pair<int,int>> AB;
    map<pair<int,int>,int> M;
    
    cin >> N;
    int ng = 0;
    REP(i,N){
        cin >> a >> b;
        if(a==0 && b==0){
            ng++;
            continue;
        }
        int sign=1;
        if(a<0){a*=-1;sign*=-1;}
        if(b<0){b*=-1;sign*=-1;}
        int g = std::gcd(a,b);
        a/=g;b/=g;
        a*=sign;
        AB.push_back({a,b});
        M[{a,b}]++;
    }
    N-=ng;
    
    
    fact.push_back(1);
    REP(i,N){
        int r = fact[i];
        r = (r*(i+1))%MOD;
        fact.push_back(r);
    }
    
    REP(i,N+1){
        int r = fact[i];
        factIE.push_back(inverse(r));
    }
    
    I2 = inverse(2);
    
    
    int P = power(2,N);
    int Ans = P;
    
    map<pair<int,int>,int> visited;
    
    REP(i,N){
        int A = AB[i].first;
        int B = AB[i].second;
        if(A<0)continue;
        if(visited[AB[i]]!=0)continue;
        visited[AB[i]]=1;
        
        int p = M[{A,B}];
        int q = M[{-B,A}];
        int r = calc(p,q);
        //cout << p MM q MM r << endl;
        //r = (r)%MOD;
        r = (1LL+MOD-r)%MOD;
        
        Ans = (Ans*r)%MOD;
    }
    Ans = (Ans+MOD-1) %MOD;
    Ans = (Ans+ng) % MOD;
    cout << Ans << endl;
    
    
    return 0;
}




Measured memory_bytes: 34388
#include <bits/stdc++.h>
using namespace std;
#define maxn 4096
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int no_of_boxes,no_of_input;
  vector<int> boxes;
  vector<int> cost;
  int input1,input2,input3,input;
  cin >> no_of_boxes >> no_of_input;
  for(int i=0;i<no_of_input;i++){
    cin >> input1 >> input2;
    cost.push_back(input1);
    int idk = 0;
    for(int j=0;j<input2;j++){
      cin >> input;
      input--;
      idk |= (1<<input);
    }
    boxes.push_back(idk);
    //cout << idk << endl;
  }
  int dp[maxn][no_of_input+2];
  for(int i=0;i<maxn;i++){
    for(int j=0;j<no_of_input+2;j++){
      dp[i][j] = 100000000;
    }
  }
  dp[0][0] = 0;
  for(int i=0;i<no_of_input;i++){
    
    for(int j=0;j<maxn;j++){
      int curr = j;
      curr |= boxes[i];
      dp[curr][i+1] = min(dp[curr][i+1],dp[j][i]+cost[i]);
      dp[j][i+1] = min(dp[j][i+1],dp[j][i]);
    }
  }
  /*for(int i=0;i<=no_of_input;i++){
    for(int j=0;j<4;j++){
      cout << dp[j][i] << ' ';
    }
    cout << endl;
  }*/
  if(dp[(1<<no_of_boxes)-1][no_of_input]==100000000){
    cout << -1;
    return 0;
  }
  cout << dp[(1<<no_of_boxes)-1][no_of_input];

}

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

const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
#define L 2
#define U 3
#define R 0
#define D 1

int cost[40][40];
bool wall[5][40][40];
bool visited[40][40];
int w, h;

int bfs(int sx, int sy, int gx, int gy) {
  fill(cost[0], cost[32], 0);
  fill(visited[0], visited[32], false);
  cost[0][0] = 1;
  
  queue<pair<int, int> > Q;
  Q.push(make_pair(0, 0));
  visited[0][0] = true;
  while(!Q.empty()) {
    pair<int, int> st = Q.front(); Q.pop();
    
    if(st.first == gx && st.second == gy) {
      return cost[gy][gx];
    }
    
    for(int i=0; i<4; i++) {
      int nx = st.first + dx[i], ny = st.second + dy[i];
      if(0<= nx && nx < w && 0<= ny && ny < h) {
	if(!visited[ny][nx] && !wall[i][st.second][st.first]) {
	  visited[ny][nx] = true;
	  cost[ny][nx] = cost[st.second][st.first] + 1;
	  Q.push(make_pair(nx, ny));
	}
      }
    }
  }
  return 0;
}

int main() {
  while(cin >> w >> h && w+h) {
    for(int i=0; i<4; i++) for(int j=0; j<32; j++) for(int k=0; k<32; k++) wall[i][j][k] = 0;
    
    for(int i=0; i<h; i++) {
      wall[R][i][0] = wall[L][i][w-1] = 1;
    }
    for(int i=0; i<w; i++) {
      wall[D][0][i] = wall[U][h-1][i] = 1;
    }
    
    for(int i=0; i<h; i++) {
      
      for(int j=0; j<w-1; j++) {
	cin >> wall[L][i][j];
	wall[R][i][j+1] = wall[L][i][j];
      }
      
      if(i < h-1) {
	for(int j=0; j<w; j++) {
	  cin >> wall[U][i][j];
	  wall[D][i+1][j] = wall[U][i][j];
	}
      }
    }

    /*
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
	cout << "R: " << wall[R][i][j] << " L: " << wall[L][i][j] << " U: " << wall[U][i][j] << " D: " << wall[D][i][j] << endl;
      }
    }
    */
    
    cout << bfs(0, 0, w-1, h-1) << endl;
    /*
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) 
	cout << cost[i][j] << " "; 
      cout << endl; 
    }
    */
  }
  
  return 0;
}

Measured memory_bytes: 1232
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] xy = Console.ReadLine().Split(' ');
        long x = long.Parse(xy[0]);
        long y = long.Parse(xy[1]);

        int gifts = 0;
        while (x <= y)
        {
            x *= 2;
            gifts++;
        }
        Console.WriteLine(gifts);
    }
}


Measured memory_bytes: 11092
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int unsigned long long
#define hh putchar('\n')
#define kg putchar(' ')
#define lowbit(x) ((x)&(-x))
using namespace std;
const int maxn=3005,mod=998244353;
const long double pi=acos(-1.0);
long double shizhen,fenzhen,shi,fen;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		putchar('-');
		putchar('1');
//		write(-a);
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}
int quickmi(int a,int b)
{
	int kotae=1;
	while(b)
	{
		if(b&1)
			kotae=kotae*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return kotae;
}
signed main()
{
	cin>>shizhen>>fenzhen>>shi>>fen;
	printf("%.15Lf\n",sqrt(shizhen*shizhen+fenzhen*fenzhen-2*shizhen*fenzhen*cos(fabs(2*pi*((shi+fen/60.0)/12.0-fen/60.0)))));;
	return 0;
}





Measured memory_bytes: 4188
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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() {
    static ll a[5002] = {};
    static ll b[5002] = {};
    int N;
    ll A;
    ll B;
    ll ans = 0;


    cin >> N >> A >> B;
    FORq(i,1,N){
        cin >> a[i];
        b[a[i]] = i;
    }

    static ll dp[5003][10005] = {};
    static ll dpS[5003][10005] = {};
    REP(i,5003){
        REP(j,10005){
            if (i != 0) {
                dp[i][j] = 1e16;
                dpS[i][j] = 1e16;
            }
            else {
                dp[i][j] = 0;
                dpS[i][j] = 0;
            }

        }
    }

    FORq(i,1,N){
        FORq(j,1,2*N+1){
            ll mini = dpS[i-1][j];

            if (j < b[i] * 2) dp[i][j] = mini + B;
            if (j > b[i] * 2) dp[i][j] = mini + A;
            if (j == b[i] * 2) dp[i][j] = mini;


            dpS[i][j] = min(dpS[i][j-1],dp[i][j]);
        }


    }

//    FORq(i,1,N){
//        FORq(j,1,2*N+1){
//            printf("dp[%d][%d] = %lld\n",i,j,dp[i][j]);
//        }
//    }
    cout << dpS[N][2*N+1] << endl;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int N;
  scanf("%d", &N);
  int x = N % 100;
  N /= 100;
  int y = N;

  int z = 0;
  if (0 < x && x <= 12) z = 1;
  if (0 < y && y <= 12) z += 2;
  if (z == 0) puts("NA");
  if (z == 1) puts("YYMM");
  if (z == 2) puts("MMYY");
  if (z == 3) puts("AMBIGUOUS");
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  solve();
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b;cin>>k>>a>>b;
	for(int i=a;i<=b;i++)if(i%k==0)
	{
		cout<<"OK"<<endl;
		return 0;
	}
	cout<<"NG"<<endl;
	return 0;
}


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

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

int main()
{
    const char *arr[] = {"Sunny", "Cloudy", "Rainy"};
    char inp[100];
    scanf("%s", inp);

    for (int i = 0; i < 3; i++)
        if (strcmp(inp, arr[i]) == 0)
            printf("%s\n", arr[(i + 1) % 3]);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
typedef unsigned char U1;
typedef int S4;

#define NUM_MOUNTAINS	(10) 
#define INVALID_DATA	(-1)
#define NUM_OUTPUTS	(3)


S4 main()
{
	S4 s4_t_i;	/* loop counter */
	S4 s4_t_j;	/* loop counter */
	S4 s4_tp_height[NUM_MOUNTAINS];
	U1 u1_t_delimiter;
	S4 s4_t_tmp;	/* temp variable for sort */

	/* Initialize array */
	for(s4_t_i = (S4)0; s4_t_i < (S4)NUM_MOUNTAINS; s4_t_i++)
	{
		s4_tp_height[s4_t_i] = (S4)INVALID_DATA;
	}

	/* Input height of mountains */
	for(s4_t_i = (S4)0; s4_t_i < (S4)NUM_MOUNTAINS; s4_t_i++)
	{
		(void)scanf("%d%c", &s4_tp_height[s4_t_i], &u1_t_delimiter);
	}

	/* Sort height of mountains */
	for(s4_t_i = (S4)0; s4_t_i < (S4)NUM_MOUNTAINS; s4_t_i++)
	{
		for(s4_t_j = (S4)0; s4_t_j < (S4)NUM_MOUNTAINS - (S4)s4_t_i - (S4)1; s4_t_j++)
		{
			if(s4_tp_height[s4_t_j] < s4_tp_height[s4_t_j + 1])
			{
				s4_t_tmp = s4_tp_height[s4_t_j];
				s4_tp_height[s4_t_j] = s4_tp_height[s4_t_j + 1];
				s4_tp_height[s4_t_j + 1] = s4_t_tmp;
			}
		}
	}

	for(s4_t_i = (S4)0; s4_t_i < (S4)NUM_OUTPUTS; s4_t_i++)
	{
		printf("%d\n", s4_tp_height[s4_t_i]);
	}

	return ((S4)0);
}

Measured memory_bytes: 1752
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>
#include <iomanip>

using namespace std;

using ll = long long;

typedef pair<int, int> P;

#define rep(i,N) for(long long i = 0;i < (long long)N; ++i)

static int mod = 1000000007;
static int large = 1000000000;

int dx[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };

string s;
int ans;
int numf, nums;

int main() {
	cin >> s;
	bool flag = true;
	rep(i, s.length()) {
		if (s[i] == '0') {
			numf++;
		}
		else {
			nums++;
		}
	}
	int mnum, snum;
	mnum = max(numf, nums);
	snum = min(numf, nums);
	ans = snum * 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
struct card
{
    char suit;
    int num;
};
void bubble_sort(struct card A[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>i;j--)
        {
            if(A[j].num<A[j-1].num)
            {
                card t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
               
            }
        }
       
    }
}
void selection_sort(struct card A[],int n)
{
    for(int i=0;i<n;i++)
    {
        int mini=i;
        for(int j=i;j<n;j++)
        {
            if(A[j].num<A[mini].num)
            {
                mini=j;
            }
        }
        card t=A[i];
        A[i]=A[mini];
        A[mini]=t;
    }
}
void print(struct card A[],int n)
{
    for(int i=0;i<n;i++)
    {
        cout << A[i].suit<<A[i].num;
        if(i!=n-1)
        {
            cout <<' ';
        }
    }
    cout<<endl;
}
bool is_stable(struct card A[],struct card B[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(A[i].suit!=B[i].suit)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    struct card cards1[36],cards2[36];
    for(int i=0;i<n;i++)
    {
        cin>>cards1[i].suit>>cards1[i].num;
        cards2[i]=cards1[i];
    }
    bubble_sort(cards1,n);
    selection_sort(cards2,n);

    print(cards1,n);
    printf("Stable\n");
    print(cards2,n);
    if(is_stable(cards1,cards2,n)==true)
        printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>

int main(void){
  int i,j,num;
  int d[10000]={0},sum;

  for(i=0;(scanf("%d",&d[i])==1);i++){}
  num=i;
  for(i=0;i<num;i++){
    sum=0;
    for(j=0;j<600;j+=d[i]){
      sum+=d[i]*(j*j);
    }
    printf("%d\n",sum);
  }
  return 0;
}

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

template<class T>
class SegmentTree {
public:
    SegmentTree(int n_, T init_, std::function<T(T, T)> comp_) : n(1), init(init_), comp(comp_) {
        while (n < n_) n *= 2;
        d.resize(2 * n - 1, init);
    }
    // d[k] = a
    void update(int k, T x) {
        k += n - 1;
        d[k] = x;
        while (k > 0) {
            k = (k - 1) >> 1;
            d[k] = comp(d[2 * k + 1], d[2 * k + 2]);
        }
    }
    // comp() [a,b)
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return init;
        if (a <= l && r <= b) return d[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) >> 1);
        T vr = query(a, b, 2 * k + 2, (l + r) >> 1, r);
        return comp(vl, vr);
    }
private:
    int n;
    const T init;
    std::function<T(T, T)> comp;
    vector<T> d;
};

int n;
int h[200005];
ll a[200005];
void solve() {
    cin >> n;
    rep(i, n) cin >> h[i];
    rep(i, n) cin >> a[i];

    SegmentTree<ll> st(n + 1, 0LL, [](ll a, ll b) {return max(a, b); });
    rep(i, n) {
        auto val = st.query(0, h[i]);
        st.update(h[i], val + a[i]);
    }
    cout << st.query(0, n + 1) << endl;
}

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


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

using namespace std;
bool passed[410][410];
int ans;
int dir[] = {0, -1, 0, 1, 0};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    queue<pair<int, int>> q;
    for (auto &s : S) cin >> s;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') continue;
            q.push({i, j});
            int dist = 0;
            passed[i * W + j][i * W + j] = true;
            while (!q.empty()) {
                int size = q.size();
                ans = max(dist++, ans);
                while (size--) {
                    auto fi = q.front().first, fj = q.front().second;
                    q.pop();
                    for (int k = 0; k < 4; ++k) {
                        if (fi + dir[k] < 0 || fi + dir[k] >= H) continue;
                        if (fj + dir[k + 1] < 0 || fj + dir[k + 1] >= W) continue;
                        if (passed[i * W + j][(fi + dir[k]) * W + fj + dir[k + 1]]) continue;
                        if (S[fi + dir[k]][fj + dir[k + 1]] == '#') continue;
                        q.push({fi + dir[k], fj + dir[k + 1]});
                        passed[i * W + j][(fi + dir[k]) * W + fj + dir[k + 1]] = true;
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
   int n; cin>>n;
   int a[n];
   rep(i,n) cin>>a[i];
   //input
   map<int ,int> m;
   rep(i,n){
       m[a[i]-1]++;
       m[a[i]]++;
       m[a[i]+1]++;
   }//1つの数字で3つの数に慣れる可能性があるため全部数える
   int ans = 0;
   for(auto i: m){
       ans = max(ans,i.second);
   } //max number
   cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
  int h,n,i;
  cin >> h >> n;
  vector<int> a(n);
  int ans;
  for(i=0;i<n;i++) cin >> a[i];
  ans = accumulate(a.begin(),a.end(),0);
  if(ans >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640