akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

std::map<char, int > mp;
long long mod = 1e9+7;

int main(){
  int N;
  scanf("%d", &N);
  std::string S;
  std::cin >> S;
  for (int i=0; i<S.length(); i++){
    int value = int(S[i])-int('a');
    mp[value]++;
  }
  long long ans = 1;
  for (auto &entry : mp){
    ans *= entry.second+1;
    ans %= mod;
  }
  ans--;
  //std::cout << dfs(3, 0, 0) << std::endl;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1144
#include <stdio.h>

int main()
{
    int n, m, i, j, k, l, count;
    char a[51][51], b[51][51];
    scanf("%d%d", &n, &m);
    for (i=0; i<n; i++)
    {
        scanf("%s", a[i]);
    }
    for (i=0; i<m; i++)
    {
        scanf("%s", b[i]);
    }
    for (i=0; i<=n-m; i++)
    {
        for (j=0; j<=n-m; j++)
        {
            count = 0;
            for (k=0; k<m; k++)
            {
                for (l=0; l<m; l++)
                {
                    if (b[k][l] == a[k+i][l+j])
                    count ++;

                }
            }
            if (count == m*m) {
                break;
            }
        }
        if (count == m*m) {
            break;
        }
    }
    if (count == m*m) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	map<int,int> A;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[a]++;
	}
	int M = A.rbegin()->first;
	vector<int> B(M + 1, 0);
	for (auto it = A.begin(); it != A.end(); it++) {
		int a = it->first;
		int d = it->second;
		while (a <= M) {
			B[a] += d;
			a += it->first;
		}
	}



	int count = 0;
	for (auto it = A.begin(); it != A.end(); it++){
		if (B[it->first] == 1) {
			count++;
		}
	}

	cout << count << endl;
	return(0);
}


Measured memory_bytes: 16340
#include<stdio.h>

int n, A[20];

int solve(int i, int m){
  if( m == 0 ) return 1;
  if( i >= n ) return 0;
  int res = solve(i+1, m) || solve(i+1, m-A[i]);
  return res;
}

int main(){
  int q, M, i;

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

  scanf("%d", &q);
  for( i = 0 ; i < q ; i++ ){
    scanf("%d", &M);
    if( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        String alpha = sc.next();
        if (Character.isUpperCase(alpha.charAt(0))) {
            System.out.println('A');
        } else {
            System.out.println('a');
        }
    }
}

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

int main(void) {
    string S;
    cin >> S;
    int N = count(S.begin(), S.end(), 'N');
    int SI = count(S.begin(), S.end(), 'S');
    int E = count(S.begin(), S.end(), 'E');
    int W = count(S.begin(), S.end(), 'W');

    if ((N > 0 && SI == 0) || (N == 0 && SI > 0) || (E > 0 && W == 0) || (E == 0 && W > 0)) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll a[m],b[m],c[m];
    vector<vector<ll> >  g(n,vector<ll> (n));  
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                g[i][j]=0;
            }
            else{
                g[i][j]=1e9;
            }
        }
    }

    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        g[a[i]][b[i]]=min(g[a[i]][b[i]],c[i]);
        g[b[i]][a[i]]=min(g[b[i]][a[i]],c[i]);
    }

    for(int k=0;k<n;k++){
        for(int j=0;j<n;j++){
            for(int i=0;i<n;i++){
                g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
            }
        }
    }
    bool maki;
    ll ans=m;
    for(int i=0;i<m;i++){
        maki=false;
        for(int j=0;j<n;j++){
            if(g[j][a[i]]+c[i]==g[j][b[i]])maki=true;
        }
        if(maki)ans--;
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 384
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
cd = Counter(D)
ct = Counter(T)

for k, v in ct.items():
  if cd[k] < v:
    print('NO')
    exit()
    
print('YES')

Measured memory_bytes: 57048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    string s;
    int ans=0;
    cin >> n >> s;
    bool hantei = false;

    for(int i=0; i+3<=n; i++){
        if("ABC" == s.substr(i,3)) ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s; cin >> s; // |s| <= 10^6
    int n = s.size();
    reverse(all(s));

    vector<vi> dp(n+1,vi(2,(1<<29)));
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        int x = s[i] - '0';
        dp[i+1][0] = min(dp[i][0]+x, dp[i][1]+x);
        dp[i+1][1] = min(dp[i][0]+1+10-x, dp[i][1]-1+1+10-x-1);
    }

    cout << min(dp[n][0], dp[n][1]) << endl;
    /* for(int i=0;i<=n;i++){ */
    /*     cout << dp[i][0] << " " << dp[i][1] << endl; */
    /* } */
}

// 555
// 0 1
// 5 6
// 10 10      // 100 - 55 = 45, 105-55=50


Measured memory_bytes: 55940
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

class UFTree {
  vector<int> m_parent;
  vector<int> m_height;
  vector<int> m_size;

 public:
  UFTree(int size) {
    for (int i = 0; i < size; i++) {
      m_parent.push_back(i);
      m_height.push_back(0);
      m_size.push_back(1);
    }
  }

  int root(int node) {
    if (m_parent[node] == node) {
      return node;
    }
    return m_parent[node] = root(m_parent[node]);
  }
  void merge(int n0, int n1) {
    int r0 = root(n0), r1 = root(n1);
    if (r0 == r1) {
      return;
    }
    if (m_height[r0] < m_height[r1]) swap(r0, r1);
    if (m_height[r0] == m_height[r1]) m_height[r0]++;
    m_parent[r1] = r0;
    m_size[r0] += m_size[r1];
  }
  int size(int node) { return m_size[root(node)]; }
};

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

  vector<int> p(N), c(N);
  UFTree uft(N);
  rep(i, p.size()) {
    cin >> p[i];
    p[i]--;
    uft.merge(i, p[i]);
  }
  for (auto &elm : c) {
    cin >> elm;
  }

  vector<int64_t> s(N, 0);
  rep(i, N) { s[uft.root(i)] += c[i]; }

  int64_t result = numeric_limits<int64_t>::min();
  rep(i, N) {
    int curr = p[i];
    int T = uft.size(curr);
    int64_t score = c[curr];
    int R = K % T;
    rep(j, T) {
      if (j <= R) {
        chmax(result, score + max((int64_t)0, s[uft.root(curr)]) * (K / T));
      } else if (K >= T) {
        chmax(result, score);
      }
      curr = p[curr];
      score += c[curr];
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i,H;

  scanf("%d",&H);

  int a[H+1];

  for(i=1; i<=H; i++)
    scanf("%d",&a[i]);

  if(H <= 1){
    printf("node %d: key = %d, ",1,a[1]);
    exit(0);
  }
  printf("node %d: key = %d, ",1,a[1]);
  if(H >= 2)
    printf("left key = %d, ",a[2]);
  if(H >= 3)
    printf("right key = %d, ",a[3]);
  printf("\n");
  
  for(i=2; i<=H; i++){
    printf("node %d: key = %d, parent key = %d, ",i,a[i],a[i/2]);
    if(i*2 <= H)
      printf("left key = %d, ",a[i*2]);
    if(i*2+1 <= H)
      printf("right key = %d, ",a[i*2+1]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2104
/*
	直接想贪心
	序列是从祖先到子树里扩展的
	把一个点弄开后，肯定先把所有的 0 给弄进序列里
	这启发我们将点合在一起，即选择了父亲一定再选儿子
	考虑两端序列那个放在前面更优
	发现结果是只要让 cnt_1 / cnt_0 尽量小就行 
*/
#include <bits/stdc++.h>
#define N 200005

using namespace std;

int n;
int fa[N], x[N], y[N]; // x : cnt_1, y : cnt_0
int val[N], o;

namespace UFS {
	int fa[N];
	inline void init() { for(int i = 1; i <= n; ++i) fa[i] = i; }
	inline int find(int u) { return fa[u] == u ? u : fa[u] = find(fa[u]); }
}

struct cmpNode {
	bool operator () (const int &lhs, const int &rhs) {
		if(lhs == 1 || rhs == 1) {
			return lhs > rhs;
		} else if(1LL * x[lhs] * y[rhs] == 1LL * x[rhs] * y[lhs]) {
			return lhs < rhs;
		} else {
			return 1LL * x[lhs] * y[rhs] < 1LL * x[rhs] * y[lhs];
		}
	}
};
set<int, cmpNode> se;

int main() {
	scanf("%d", &n);
	for(int i = 2; i <= n; ++i)
		scanf("%d", &fa[i]);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &val[i]);
	
	UFS::init();
	for(int i = 1; i <= n; ++i) {
		if(val[i]) {
			++x[i];
		} else {
			++y[i];
		}
		se.insert(i);
	}
	
	long long ans = 0;
	set<int, cmpNode>::iterator it;
	for(int i = n; i > 1; --i) {
		it = se.begin();
		int u = *it, v = UFS::find(fa[u]);
		UFS::fa[u] = v;
		se.erase(u), se.erase(v);
		ans += 1LL * y[u] * x[v];
		x[v] += x[u], y[v] += y[u];
		se.insert(v);
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 13568
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int sum = 0;
        for (int i=1; i<=N; i++){
            int n = i;
            int digSum = 0;
            while (n>0){
                digSum += n %10;
                n /= 10;
            }
            if (digSum >= A && digSum <= B)
                sum += i;
        }
        System.out.println(sum);

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
             
using namespace std;

int main(){

	int N;
	cin >> N;
	vector<int> L(N);
	for(int i=0;i<N;i++){
		int x;
		cin >> x;
		L.push_back(x);		
	}

	std::sort(L.begin(), L.end(), std::greater<int>() );
	

	int max = L[0];

	L.erase(L.begin() + 0);

	int sum = std::accumulate(L.begin(), L.end(), 0);

	if(max<sum){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
alpha = "abcdefghijklmnopqrstuvwxyz"
count = 1
while True:
    if 26 ** count >= n:
        break
    else:
        n -= 26 ** count
        count += 1
n -= 1
num = []
for i in range(count):
    num.append(n % 26)
    n //= 26
num.reverse()
name = ""
for i in num:
    name += alpha[i]
print(name)

Measured memory_bytes: 9180
N= int(input())
if N%2==0:
    cand = list(range(1,N,2))
else:
    cand = list(range(1,N+1,2))

ans = 0
num = 0
for n in range(1,N+1):
    num = 0
    for c in cand:
        if n%c==0:
            num+=1
    if num ==8:
        ans+=1
print(ans)

    

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
  int A,B,C,D,i;

  scanf("%d%d%d%d",&A,&B,&C,&D);

  while(1){
   C=C-B;
   if(C<=0){
    printf("Yes\n");
   break;
   }

   A=A-D;
   if (A<=0){
    printf("No\n");
    break;
   }
  }
  return 0;
}


Measured memory_bytes: 1648
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>



int main() {
  long i, N, K, A[200005], s = 0;
  scanf("%ld %ld", &K, &N);
  scanf("%ld", A);
  for (i = 1; i < N; i++) {
    scanf("%ld", A + i);
    if (A[i] - A[i - 1] > s) {
      s = A[i] - A[i - 1];
    }
  }
  if (A[0] - A[N - 1] + K > s) {
    s = A[0] - A[N - 1] + K;
  }
  printf("%ld", K - s);
  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main() {
    int k[40]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    scanf("%d", &n);
    printf("%d\n",k[n-1]);
    return 0;
}


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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef unsigned long long int lli; 

int main(){
    
    lli i,x,j,n,m,t,k; 	
    AndIamIronMan;
//    cin>>n;
//    lli arr[n];
    x=1;
    long double a,b;
  	cin>>a>>b;
  	printf("%llu",(lli)floor(a*b));
//	cout<<x;
    return 0;
}    

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

const int D = 80*160 + 10;
using bs = bitset<2*D>;
bs dp[85][85];
int a[85][85];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int h, w;
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) {
    int x;
    cin >> x;
    a[i][j] = abs(x-a[i][j]);
  }
  dp[0][0][D-a[0][0]] = 1;
  dp[0][0][D+a[0][0]] = 1;
  rep(i, h) rep(j, w) {
    if (i) {
      dp[i][j] |= dp[i-1][j]<<a[i][j];
      dp[i][j] |= dp[i-1][j]>>a[i][j];
    }
    if (j) {
      dp[i][j] |= dp[i][j-1]<<a[i][j];
      dp[i][j] |= dp[i][j-1]>>a[i][j];
    }
  }
  rep(i, D) {
    if (dp[h-1][w-1][D-i] || dp[h-1][w-1][D+i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 22656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

long gcd (long x, long y){
 
    if (x % y == 0) return y;
    return gcd(y,x % y);
 
}

  
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	long A[N];
	int index = 0;
	//単純にユークリッド互除法を繰り返しても間に合わないのでは
	while(cin >> A[index])
  {
      index++;
  }
	if(N == 2)
  {
      cout << max(A[0],A[1]) << endl;
      return 0;
  }
  
  long L[N];
  long R[N];
  L[0] = A[0];
  R[N-1] = A[N-1];
  for(int i=1;i<N-1;i++)
  {
    L[i] = gcd(L[i-1],A[i]);
    R[N-i-1] = gcd(R[N-i],A[N-i-1]);
  }
  long max_num=0;
  for(int i=0;i<N;i++)
  {
    if(i==0) max_num = max(max_num,R[1]);
    else if(i==N-1) max_num = max(max_num,L[i-1]);
    else max_num = max(max_num, gcd(L[i-1],R[i+1]));
  }
  cout << max_num << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin>>N;
    N=N%1000;
    if(N==0)
    {
        cout<<"0"<<endl;
    } 
    else
    {
        cout<<abs(N-1000)<<endl;
    }
}


Measured memory_bytes: 3612
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    ll A;
    long double B;
    cin >> A >> B;

    ll ans = A * (ll)floor(100 * B + 0.001) / 100;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
class Main{
  public static void main(String[] args)throws IOException{
      
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
  
    String[] strAry = str.split(" ");
    int a = Integer.parseInt(strAry[0]);
  	int b = Integer.parseInt(strAry[1]);
  	int c = Integer.parseInt(strAry[2]);
  	
  	if ( a < b && b < c) {
  		System.out.println( "Yes");
  	}
  	else {
  		System.out.println( "No");
  	}
  	
  } 
}

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

using namespace std;
#define int long long
#define double long double
#define all(a) a.begin(), a.end()

template <typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (y > x) x = y;}
template <typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}

void read() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a)
		cin >> i;
	a[0]--;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] < a[i]) {
			a[i]--;
		}
		if (a[i - 1] > a[i]) {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

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

int main()
{
    int M, D, c=0, i, j, x, fl=0, sum;
    cin >> M >> D;
    for(i=2;i<10;i++)
    {
        for(j=2;j<10;j++)
        {
            sum = (i*10)+ j;
            if(sum>D)
            {
                fl = 1;
                break;
            }
            x = i*j;
            if(x<=M)
            {
                c++;
            }
            else if(x>M)
            {
                break;
            }
        }
        if(fl==1)
        {
            break;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
N, M = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

inf = float('inf')
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0] + [-inf] * N
for i in range(N + 1)[1::]:
    for x in A:
        if i >= num[x]:
            dp[i] = max(dp[i], dp[i - num[x]] + 1)

ans = ''
while N > 0:
    for x in A:
        if N >= num[x] and dp[N - num[x]] == dp[N] - 1:
            ans += str(x)
            N -= num[x]
            break

print(ans)


Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    ll N; cin >> N;
    char s = 'a';
    string S;
    ll i=26,j=1;
    while(N > i){
        N -= i;
        i *= 26;
        j++;
    }
    N--;
    while(j>0){
        s = 'a';
        s += N%26;
        N/=26;
        S = s + S;
        j--;
    }
    AA(S);
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans;
    if(105 > N){
        ans = 0;
    }
    else if(135 > N){
        ans = 1;
    }
    else if(165 > N){
        ans = 2;
    }
    else if (189 > N){
        ans = 3;
    }
    else if (195 > N){
        ans = 4;
    }
    else{
        ans = 5;
    }
    cout << ans << endl;

}

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

int main()
{
	int x, y;
	scanf("%d%d", &x, &y);
	int ans{(std::max(0, 4 - x) + std::max(0, 4 - y)) * 100'000};
	if (x == 1 && y == 1) ans += 400'000;
	printf("%d\n", ans);

	return 0;
}

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

int main(){
    int sum=0;
string x;
cin>>x;
for(int i=0;i<x.size();i++){
for(int j=0;j<x.size();j++){
    if(x[i]==x[j]){
        sum++;
    }
}

if(sum%2!=0){
    cout<<"No"<<endl;
    return 0;
}
sum=0;
}
cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())


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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ta = (c+b-1)/b;
    ll ao = (a+d-1)/d;
    if(ta<=ao) cout<<"Yes";
    else cout<<"No";
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int s, w;
    cin >> s >> w;
    if (w >= s)
        out("unsafe");
    else
        out("safe");
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
void  dv13(int n,double p1[],double p2[]){
  double s[2]={},u[2]={},t[2]={};
  if(n<=0)return;
  s[0]=(2*p1[0]+p2[0])/3;
  s[1]=(2*p1[1]+p2[1])/3;
  t[0]=(p1[0]+2*p2[0])/3;
  t[1]=(p1[1]+2*p2[1])/3;
  u[0]=(t[0]-s[0])*(0.5)-(t[1]-s[1])/2*(sqrt(3))+s[0];
  u[1]=(t[0]-s[0])/2*(sqrt(3))+(t[1]-s[1])*(0.5)+s[1];
  dv13(n-1,p1,s);
  cout<<s[0]<<" "<<s[1]<<endl;
  dv13(n-1,s,u);
  cout<<u[0]<<" "<<u[1]<<endl;
  dv13(n-1,u,t);
  cout<<t[0]<<" "<<t[1]<<endl;
  dv13(n-1,t,p2);
}
int main(){
  int n;
  cin>>n;
  double p1[2]={0.0,0.0},p2[2]={100.0,0.0};
  cout<<p1[0]<<" "<<p1[1]<<endl;
  dv13(n,p1,p2);
  cout<<p2[0]<<" "<<p2[1]<<endl;

  return 0;
}



Measured memory_bytes: 3272
n = int(input())
a = []
b = []
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
ans = 0
c = a[::-1]
d = b[::-1]
for i in range(n):
    ans += (d[i] - (c[i]+ans)%d[i]) % d[i]
print(ans)

Measured memory_bytes: 18500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

priority_queue<ll>q;
int main() {
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll>>a;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}
	a.push_back(make_pair(inf,0));
	sort(a.begin(),a.end());
	ll j=0,ans=0;
	for(int i=1;i<=m;i++){
		ll nowd=a[j].first;
		while(nowd<=i){
			q.push(a[j].second);
			j++;
			nowd=a[j].first;
		}
		if(!q.empty()){
			ans+=q.top();
			q.pop();
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

double r;
ll n;
ll ymax[100][2];

int main(){
	while(cin >> r >> n && r){
		rep(i,100)rep(j,2)ymax[i][j] = 0;
		double ans = INF;
		rep(i,n){
			ll lb,ub,h;
			cin >> lb >> ub >> h;
			lb += 50;
			ub += 50;
			FOR(i,lb,ub+1){
				if(i != lb)ymax[i][0] = max(ymax[i][0],h);
				if(i != ub)ymax[i][1] = max(ymax[i][1],h);
			}
		}
		FOR(i,50-r+1,50+r){
			double y = min(ymax[i][0],ymax[i][1]);
			double absx = abs(i-50);
			double g = sqrt(r*r - absx*absx);
			// cout << i << " " << y << endl;
			ans = min(ans,r + y - g);
		}
		printf("%.10lf\n",ans);
	}

}


Measured memory_bytes: 3172
import math
import collections
import itertools
import heapq
import bisect
import sys


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

    c = [0] * 40
    res = 0
    for a in A:
        for bit in range(40):
            if a & (1<<bit):
                c[bit] += 1

    x = 0
    for k in range(39,-1,-1):
        if x + (1<<k) > K:
            continue
        if c[k] <= N // 2:
            x += (1<<k)

    for a in A:
        res += x^a

    print(res)
  

if __name__ == "__main__":
    main()

Measured memory_bytes: 91772
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef double db;

const int N=5*1e5+5;

db T[N],all;
int n,L,V[N],v,t,l,r,sum;

void pop() {
	T[r-1]=(T[r-1]*V[r-1]+T[r]*V[r])/(V[r-1]+V[r]);
	V[r-1]+=V[r];
	r--;
}

int main() {
	scanf("%d%d",&n,&L);
	l=1,r=0,sum=0;
	fo(i,1,n) {
		scanf("%d%d",&t,&v);
		sum+=v;all+=(db)t*v;
		while (sum>L) {
			int res=min(sum-L,V[l]);
			V[l]-=res;sum-=res;all-=res*T[l];
			if (!V[l]) l++;
		}
		V[++r]=v;T[r]=t;
		while (l<r&&T[r]<T[r-1]) pop();
		printf("%.7lf\n",all/L);
	}
}

Measured memory_bytes: 14848
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
	int A =sc.nextInt();
	int B =sc.nextInt();
	int C =sc.nextInt();
	int D =sc.nextInt();
	if(A*B<=C*D)System.out.println(C*D);
	if(C*D<A*B)System.out.println(A*B);
	}
	}

Measured memory_bytes: 21844
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;

LL f[2019];

int main(){


    LL L,R;
    SL(L); SL(R);

    for( LL i = L ; i<= min(R,L+2019-1) ;i++ ) f[ i % 2019 ]++;

    LL mn = 1e18;
    for( LL i = 0 ; i<2019 ; i++ ){
        for( LL j = i+1 ; j<2019 ; j++ ){
            if( f[i] && f[j] ) mn = min(mn,(i*j)%2019);
        }
    }
    cout<<mn<<endl;
    
return 0;}

Measured memory_bytes: 3768
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
	static double s;
	
    public static void main(String[] args)   throws Exception, IOException{        
//        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        boolean d[]=new boolean[110000];
        d[0]=true;
        
        for (int i = 0; i+105 < d.length; i++) {
			if(d[i]) {
				for (int j = 0; j < 6; j++) {
					d[i+100+j]=true;
				}
			}
		}

        out.println(d[n]?1:0);
     	out.flush();
    }


    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//
//class P {
//	int x, y, d;
//	P(int  x, int y, int d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return -p.a+a;//as
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    long long sum=0;
    for(int i=0;i<n-k;i++)
        sum+=a[i];    
    cout<<sum;
}

Measured memory_bytes: 1024
#include<cstdio>
    int main()
    {
    	char a,b,c,d,e,f;
    	scanf("%c%c%c %c%c%c",&a,&b,&c,&d,&e,&f);
    	if(a==f&&b==e&&c==d)
    	{
    	 	printf("YES\n");
    	}
    	else
    	{
            printf("NO\n");
    	}
    }

Measured memory_bytes: 128
"use strict";
function Main(input) {
    let s = input.split("\n")[0].split('').map((v) => +v);
    let ans = 0;
    for (let n = 0; n < s.length - 1; n++) {
        if (s[n] + s[n+1] == 1) {
            ans += 2;
            s.splice(n, 2);
            n -= 2;
        }
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15052
#include <iostream>
using namespace std;
int main() {
  int n, m, p, ac = 0, wa = 0;
  string s;
  cin >> n >> m;
  int q[n+1];
  for(int i=0; i<n+1; i++) {
    q[i] = 0;
  }
  for(int i=0; i<m; i++) {
    cin >> p >> s;
    if (q[p] == -1) continue;
    if (s == "WA") {
      q[p]++;
    } else {
      ac++;
      wa += q[p];
      q[p] = -1;
    }
  }
  cout << ac << ' ' <<  wa << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=1000)
    {
        cout<<1000-n<<endl;
    }
    else if(n>1000&&n<=2000)
    {
        cout<<2000-n<<endl;
    }
    else if(n>2000&&n<=3000)
    {
        cout<<3000-n<<endl;
    }
    else if(n>3000&&n<=4000)
    {
        cout<<4000-n<<endl;
    }
    else if(n>4000&&n<=5000)
    {
        cout<<5000-n<<endl;
    }
    else if(n>5000&&n<=6000)
    {
        cout<<6000-n<<endl;
    }
    else if(n>6000&&n<=7000)
    {
        cout<<7000-n<<endl;
    }
    else if(n>7000&&n<=8000)
    {
        cout<<8000-n<<endl;
    }
    else if(n>8000&&n<=9000)
    {
        cout<<9000-n<<endl;
    }
    else if(n>9000&&n<=10000)
    {
        cout<<10000-n<<endl;
    }
}


Measured memory_bytes: 3648
N, K = map(int, input().split())
A = list(map(int, input().split()))

visited = [-1] * (N)
ans = [0] * (N + 1)
ans[0] = 1

for i in range(N):
    if visited[A[ans[i] - 1] - 1] == -1:
        visited[A[ans[i] - 1] -1 ] = 1
        ans[i+1] = A[ans[i] - 1]
    else:
        break

ans.pop(0)

for i in range(len(ans)):
    if ans[i] == 0:
        ans = ans[:i]
        break
    


check = [0] * (len(ans) + 1)
check[0] = ans[-1]

visited = [-1] * (N)
for i in range(N):
    if visited[A[check[i] - 1] - 1] == -1:
        visited[A[check[i] - 1] -1 ] = 1
        check[i+1] = A[check[i] - 1]
    else:
        break
check.pop(0)
for i in range(len(check)):
    if check[i] == 0:
        check = check[:i]
        break



if K <= len(ans):
    print(ans[K - 1])
else:
    print(check[(K - len(ans)) % len(check) - 1])


Measured memory_bytes: 92864
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    string youbi[] = {"sat", "sun", "mon", "tue", "wed", "thu", "fri"};
    if (x < 9)
    {
        int tmp = 7 - abs(x - 9) % 7;
        if (tmp == 7)
        {
            cout << youbi[0] << endl;
        }
        else
        {
            cout << youbi[tmp] << endl;
        }
    }
    else
    {
        cout << youbi[abs(x - 9) % 7] << endl;
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    map<char, char> m{{'A', 'T'}, {'C', 'G'}, {'T', 'A'}, {'G', 'C'}};
    string b;
    cin >> b;
    iter(c, b) cout << m[c];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  ll A,B,K;
  cin>>A>>B>>K;
  A-=K;
  if(A<0){
    B+=A;
    A=0;
    if(B<0)B=0;
  }
  cout<<A<<" "<<B<<endl;
}


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

int main() {
  int y;
  double x, a, b, z;
  cin  >> a >> b;
  x = (a + b) / 2;
  y = (a + b) / 2;
  z = x - y;
  cout << y + z * 2 << endl;
}

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



int single[100010] = {};
int multi[100010] = {};
int hp[110];
int main(){
	int N;
	while(cin >> N && N){
		for(int i = 0 ; i < 100010 ; i++) single[i] = 1e9;
		for(int i = 0 ; i < 100010 ; i++) multi[i] = 1e9;
		single[0] = multi[0] = 0;
		for(int i = 0 ; i < N ; i++)
			cin >> hp[i];
		int M;
		cin >> M;
		for(int i = 0 ; i < M ; i++){
			string name;
			int mp;
			string target;
			int dmg;
			cin >> name >> mp >> target >> dmg;
			if( target == "Single" ){
				for(int j = 0 ; j <= 100000 ; j++){
					int t = min(100000,j+dmg);
					single[t] = min(single[t],single[j]+mp);
				}
			}else{
				for(int j = 0 ; j <= 100000 ; j++){
					int t = min(100000,j+dmg);
					multi[t] = min(multi[t],multi[j]+mp);
				}
			}
		}
		for(int j = 100000 ; j >= 0 ; j--){
			single[j] = min(single[j+1],single[j]);
			multi[j] = min(multi[j+1],multi[j]);
		}
			
		long long ans = 1e9;
		for(int i = 0 ; i <= 100000 ; i++){
			long long sub = multi[i];
			for(int j = 0 ; j < N ; j++){
				int r = max(0,hp[j]-i);
				sub += single[r];
			}
			ans = min(sub,ans);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1992
n=int(input())
d,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(int(input()))
#print(a)
sum=0
for i in range(n):
    for j in range(100):
        if a[i]*j+1<=d:
            sum+=1
print(x+sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
int scanint() { 
	char c = getchar_unlocked();
	int x = 0;
	for(; (c<48)||(c>57);c = getchar_unlocked());
	for(; (c>47)&&(c<58);c = getchar_unlocked())
		x = 10 * x + c - 48;
    return x;
} 
 
int main() {
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    constexpr int A_MAX = 1000000;
 
    vector<int> min_factor(A_MAX);
    // q[n] = i where n = i * p^e, p = min_factor[n], p does not divide i. + 1);
    vector<int> q(A_MAX + 1, 1);
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        min_factor[i] = i;
    }
    for (int i = 2; i <= A_MAX; ++i) {
        if (min_factor[i] == i) {
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = scanint();
    vector<int> a(A_MAX + 1);
    int Q = N >> 3;
    int R = N & 7;
    for (int i = 0; i < Q; ++i) {
        ++a[scanint()];
        ++a[scanint()];
        ++a[scanint()];
        ++a[scanint()];
        ++a[scanint()];
        ++a[scanint()];
        ++a[scanint()];
        ++a[scanint()];
    }
    for (int i = 0; i < R; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        if (a[n] > 1) {
            if (a[n] == N) {
                cout << "not coprime" << endl;
                return 0;
            }
            is_pairwise_coprime = false;
        }
        a[min_factor[n]] += a[n];
        a[q[n]] += a[n];
    }
    if (is_pairwise_coprime) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 15496
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
    int n,m;
    cin>>n>>m;
    int sum = 0;
    int arr[n];
    for(int i = 0;i<n;i++){
        cin>>arr[i];
        sum = sum + arr[i];
    }
    sum = (sum%(4*m)==0)?(sum/(4*m)):(sum/(4*m)+1);
    sort(arr,arr+n);
    reverse(arr,arr+n);
    int flag = 0;
    for(int i = 0;i<m;i++){
        if(arr[i]<sum)
            flag++;
    }

    if(flag==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

//Total solved problems:-3


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a[200005],b[200005];
ll ans=1000000000000000000;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i+1]=b[i]+a[i];
    }
    for(int i=1;i<n;i++){
        ans=min(ans,abs((b[n]-b[i])-b[i]));
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 6716
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cctype>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define in_range(x,l,r) (l<=x && x<r)
using namespace std;
typedef vector<int> vi;

inline int CtoI(char c){
  if(isdigit(c))return c-'0';
  return c-'A'+10;
}

inline char ItoC(int a){
  if(a<10)return '0'+a;
  return 'A'+a-10;
}

inline vi red(string s){
  int n = s.size()/2;
  vi r(n);
  int nonzero = 0;
  rep(i,n){
    r[i] = CtoI(s[2*i])*16 + CtoI(s[2*i+1]);
    if(r[i])nonzero++;
  }

  for(int i=n;i>0;i--){
    if(n%i==0){
      int vals = 0;
      for(int j=0;j<n;j+=i){
	if(r[j])vals++;
      }
      if(nonzero==vals){
	vi res(n/i);
	for(int j=0;j<n;j+=i){
	  res[j/i] = r[j];
	}
	return res;
      }
    }
  }
  return r;
}
      

int main(){
  int t;
  cin >> t;
  while(t--){
    int n;
    cin >> n;
    vector< vi > r(n);
    rep(i,n){
      string s;
      cin >> s;
      r[i] = red(s);
    }

    int len = 1;
    rep(i,n){
      int s = r[i].size(), gcd = __gcd(len,s);
      if(len/gcd > 1024/s)len = 1025;
      else len = len/gcd*s;
    }

    if(len>1024){
      cout << "Too complex." << endl;
    }else{
      vi res(len,0);
      rep(i,n){
	rep(j,r[i].size()){
	  res[j*len/r[i].size()] |= r[i][j];
	}
      }

      rep(i,len){
	cout << ItoC(res[i]/16) << ItoC(res[i]%16);
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(;;){
        int n;
        cin>>n;
        if(!n) return 0;
        int w[310];
        rep(i,0,n) cin>>w[i];
        int dp[310][310];
        rep(i,0,n){
            dp[i][i+1]=0;
            dp[i][i+2]=0;
            if(abs(w[i]-w[i+1])<=1) dp[i][i+2]=2;
        }
        rep(j,3,n+1){
            rep(i,0,n+1-j){
                dp[i][i+j]=dp[i][i+j-1];
                if(abs(w[i]-w[i+j-1])<=1&&dp[i+1][i+j-1]==j-2) dp[i][i+j]=j;
                rep(k,i+1,i+j){
                    if(abs(w[k]-w[i+j-1])<=1&&dp[k+1][i+j-1]==i+j-k-2) dp[i][i+j]=max(dp[i][i+j], int(i+j-k+dp[i][k]));
                }
            }
        }
        cout <<dp[0][n]<<"\n";
    }
}


Measured memory_bytes: 3512
#include <cstdio>
#include <cstring>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

char buf[2][200];
const int N = 110;

int main(void) {
  REP(i, 2) {
    scanf("%s", buf[i]);
    int len = strlen(buf[i]);
    REP(j, len) {
      buf[i][N-1-j] = buf[i][len-1-j];
    }
    REP(j, N-len) {
      buf[i][j] = '0';
    }
  }
  REP(i, N) {
    if(buf[0][i] < buf[1][i]) {
      puts("LESS");
      return 0;
    } else if(buf[0][i] > buf[1][i]) {
      puts("GREATER");
      return 0;
    }
  }
  puts("EQUAL");
  return 0;
}


Measured memory_bytes: 128