akhauriyash/Code-Regression huggingface dataset:
def det(a,b,c):
    return a[0]*b[1]*c[2] + a[2]*b[0]*c[1] + a[1]*b[2]*c[0] - a[2]*b[1]*c[0] - a[1]*b[0]*c[2] - a[0]*b[2]*c[1]

uaz = list(map(int, input().split()))
ene = list(map(int, input().split()))
br1 = list(map(int, input().split()))
br2 = list(map(int, input().split()))
br3 = list(map(int, input().split()))

edge1 = [br2[0] - br1[0], br2[1] - br1[1], br2[2] - br1[2]]
edge2 = [br3[0] - br1[0], br3[1] - br1[1], br3[2] - br1[2]]
ray   = [uaz[0] - ene[0], uaz[1] - ene[1], uaz[2] - ene[2]]
rhs   = [uaz[0] - br1[0], uaz[1] - br1[1], uaz[2] - br1[2]]

det_abc = det(edge1, edge2, ray)
if det_abc == 0:
    print("HIT")
else:
    u = det(rhs, edge2, ray)/det_abc
    v = det(edge1, rhs, ray)/det_abc
    t = det(edge1, edge2, rhs)/det_abc
    if 0.0 <= u <= 1.0 and 0.0 <= v <= 1.0 and u+v <= 1.0 and 0.0 < t <= 1.0:
        print("MISS")
    else:
        print("HIT")



Measured memory_bytes: 5624
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;


int main(){
    string S;
  int A[5],k;

  for(int i=0;i<5;i++){
    cin>>A[i];
  }
  cin>>k;

  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(A[j]-A[i]>k){
        cout<<":("<<endl;
        return 0;
      }
    }
  }
  cout<<"Yay!"<<endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int r;
    cin>>r;
    cout<<fixed<<setprecision(10)<<2.0l*acos(-1)*r<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3800
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  double pb[100][5001];
  int x,y,z,n,m,l,ub,i,j,k;
  int v[4],e[51],a[51];

  while(scanf("%d %d %d",&x,&y,&z) && (x||y||z)){

    for(i=0;i<x;i++)scanf("%d",&v[i]);
    for(i=0;i<=y;i++)e[i] = a[i] = 0;
    ub = 0;
    for(i=0;i<z;i++){
      scanf("%d %d %d",&n,&m,&l);
      e[n] = m; a[n] = l;
      if(m==2)ub += a[n];
    }

    for(i=0;i<=y;i++)
      for(j=0;j<=ub;j++)pb[i][j] = 0.0;
    pb[0][0] = 1.0;

    for(i=0;i<y;i++)
      for(j=0;j<=ub;j++){
	if(pb[i][j] == 0.0)continue;
	for(k=0;k<x;k++){
	  n = min(y,i+v[k]),m = j;
	  if(e[n] == 1)n = min(y,n+a[n]);
	  else if(e[n] == 2)m = j + a[n];
	  else if(e[n] == 3)m = max(0,j-a[n]);
	  pb[n][m] += pb[i][j]/x;
	}
      }
    

    double ans = 0.0;
    for(i=0;i<=ub;i++)ans += pb[y][i] * i;
    printf("%d\n",(int)ans);
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> to(N);
  for (int i = 0; i < M; ++i) {
    int s, t;
    cin >> s >> t;
    --s;
    --t;
    to[s].push_back(t);
  }
  vector<double> dp(N);
  for (int u = N - 2; u >= 0; --u) {
    int deg = to[u].size();
    for (int v : to[u]) { 
      dp[u] += (dp[v] + 1.0) / deg;
    }
  }

  double ans = dp[0];

  for (int i = 0; i < N - 1; ++i) {
    if (to[i].size() == 1) continue;
    int nj = to[i][0];
    for (int j : to[i]) {
      if (dp[j] > dp[nj]) nj = j;
    }

    vector<double> dp2(N);
    for (int u = N - 2; u >= 0; --u) {
      int deg = to[u].size();
      if (u == i) --deg;
      for (int v : to[u]) {
        if (u == i && v == nj) continue;
        dp2[u] += (dp2[v] + 1.0) / deg;
      }
    }

    ans = min(ans, dp2[0]);
  }

  printf("%.10f\n", ans);
}


Measured memory_bytes: 1408
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    b=parseMap(split(readline()*" 100001"))
    ans=b[1]
    for i in 1:n-1
        ans+=min(b[i],b[i+1])
    end
    println(ans)
end
main()

Measured memory_bytes: 109636
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    cnt = 0
    upper_max_value = min(x - 3, n)
    lower_max_value = max(int(x / 3), 3)
    for i in range(upper_max_value, lower_max_value - 1, -1):
        for j in range(i - 1, 1, -1):
            for k in range(j - 1, 0, -1):
                if (i + j + k) == x:
                    cnt += 1
    print(cnt)

Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    double eye_r,eye_l;
    int arf=0,alf=0,brf=0,blf=0,crf=0,clf=0,drf=0,dlf=0;
    while(scanf("%lf %lf",&eye_r,&eye_l) != EOF){
        if(eye_r >= 1.1){
            arf++;
        }
        else if(eye_r >= 0.6){
            brf++;
        }
        else if(eye_r >= 0.2){
            crf++;
        }
        else if(eye_r < 0.2){
            drf++;
        }
        if(eye_l >= 1.1){
            alf++;
        }
        else if(eye_l >= 0.6){
            blf++;
        }
        else if(eye_l >= 0.2){
            clf++;
        }
        else if(eye_l < 0.2){
            dlf++;
        }
    }
    printf("%d %d\n%d %d\n%d %d\n%d %d\n",arf,alf,brf,blf,crf,clf,drf,dlf);
    return (0);
}

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

int main(){
  long long n, m;
  cin >> n >> m;
  if ( n >= m/2){
    cout << m/2 << endl;
  } else {
    long long rest = m - 2 * n;
    cout << n + rest/4 << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(c-a) < 2*d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
using namespace std;
int main(){
	string S,T="";
	cin>>S;
	for(int i=0;i<(int)S.size();i++){
		if(i%2==0){
			T+=S[i];
		}
	}
	
	cout<<T<<endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  
  for(int i = 0;i < N;i++) {
    int a;
    cin >> a;
    if(a%2!=0) {
      cout << "first" << endl;
      return 0;
    }
  }

  cout << "second" << endl;

  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);
		int N = sc1.nextInt();
		String s = sc1.next();
		int r = 0;
		int b = 0;

		for ( int i = 0 ; i < N ; i++ ) {
			if (s.charAt(i) == 'R') {
				r++;
			}
			else {
				b++;
			}
		}

		if ( r > b ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc1.close();

	}

}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int ans = 0;
		for (int i = n; i >= 1; i--) {
			i = i - 2 * d;
			ans++;
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23252
N, x = map(int,input().split())
a = sorted(list(map(int,input().split())))

flag = 0

if x > sum(a):
  print(N-1)
elif x == sum(a):
  print(N)
else:
  for i in range(N):
    if x < sum(a[:i]):
      flag = 1
      print(i-1)
      break
  if flag == 0:
    print(N-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
// << fixed << setprecision(10) <<

int main() {
int n,k;
cin >> n >> k;
double ans=0;
int temp;
int cnt;
for(int i=1;i<=n;i++) {
  temp = i;
  cnt = 0;
  for(cnt;temp<k;cnt++) {
    temp*=2;
  }
  ans+=pow(0.5,cnt);
}
ans /= (double)n;
cout << fixed << setprecision(11) << ans << endl;
return 0;
}


Measured memory_bytes: 256
//abc055_a.cpp
//Fri Oct 19 23:10:05 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,m;
	cin >> n;

	m = n/15;

	cout << n*800 - m*200<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int mem[5];
    rep(i,5) cin >> mem[i];
    int ans;
    rep(i,5) if(mem[i]==0) ans = i+1;
    cout << ans << endl;
}

Measured memory_bytes: 3616
# include "bits/stdc++.h"
using namespace std;
int n, h[101010], dp[101010];
const int INF = INT_MAX; 
int main(){
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> h[i];
    for(int i = 2;i <= n;i++){
        if(i == 2)dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        else dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]),
                         dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[n] << endl;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, dp[1000007], sum;
int main()
{
	cin >> n;
	dp[n] = n;
	dp[n - 1] = 1LL * n * n % mod;
	for (int i = n - 2; i >= 1; i--)
	{
		sum = (sum + dp[i + 3]) % mod;
		dp[i] = (sum + 1LL * (n - 1) * (n - 1) % mod + dp[i + 1] + i + 1) % mod;
	}
	cout << dp[1] << endl;
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    
    if (a > b){
        cout << "a > b" << endl;
    }
    else if (a < b){
        cout << "a < b" << endl;
    }
    else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	string s;
	while (getline(cin, s))
	{
		if (s[0] == '.') break;
		vector<int> v;
		v.push_back(100);
		REP(i, s.size())
		{
			if (s[i] == '(') v.push_back(0);
			if (s[i] == '[') v.push_back(1);
			if (s[i] == ')')
			{
				int n = v.back();
				v.pop_back();
				if (!(n == 0))
				{
					cout << "no" << endl;
					goto end;
				}
			}
			if (s[i] == ']')
			{
				int n = v.back();
				v.pop_back();
				if (!(n == 1))
				{
					cout << "no" << endl;
					goto end;
				}
			}
		}
		if (v.back() == 100) cout << "yes" << endl;
		else cout << "no" << endl;
	end:;
	}
	return 0;
}

Measured memory_bytes: 1196
first_line = [int(x) for x in input().split()]
n, m = first_line[0], first_line[1]

if n >= m:
    print(0)
    exit()

table = [int(x) for x in input().split()]

table.sort()
desk = []
for x in range(0, len(table) - 1):
    desk.append(table[x + 1] - table[x])
desk.sort()
for x in range(0, n - 1):
    if len(desk) < 2:
        break
    desk.pop(-1)
cnt = 0
for x in desk:
    cnt += x
print(cnt)


Measured memory_bytes: 13840
#include <stdio.h>

int main(void) {
	int h, w, i, j;
	while(scanf("%d %d", &h, &w)){
		if(h == 0 && w == 0)
			return 0;
			
		for(i=0;i<h;i++) {
			for(j=0;j<w;j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;
int l1,l2;
char a[12],b[12],c[12];

int main()
{
    cin>>a>>b>>c;
    if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0]) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int a,b,c; cin >>a>>b>>c;
  vector<int> vec = {a,b,c};
  sort (all(vec));
  if(((vec[2]-vec[1])%2!=0)&&((vec[2]-vec[0])%2!=0)) cout <<1+(vec[2]-vec[1])/2+(vec[2]-vec[0])/2<<endl;
  else if (((vec[2]-vec[1])%2==0)&&((vec[2]-vec[0])%2==0))  cout <<(vec[2]-vec[1])/2+(vec[2]-vec[0])/2<<endl;
  else cout <<2+(vec[2]-vec[1])/2+(vec[2]-vec[0])/2<<endl;
}

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

using namespace std;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint a(n);
    int max1=0;
    int max2=0;
    REP(i,n){
        cin >> a[i];
        if(a[i]>=max1){
            max2=max1;
            max1=a[i];
        }else if(a[i]>=max2){
            max2=a[i];
        }
    }
    REP(i,n){
        if(a[i]==max1){
            cout << max2 << endl;
        }else{
            cout << max1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
    
    static int count;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] s = new int[n];
        for(int i = 0; i < n; i++){
            s[i] = Integer.parseInt(sc.next());
        }
        count = 0;
        
        mergeSort(s, 0, n);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(s[i]).append(" ");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb);
        System.out.println(count);
    }
    
    static void merge(int[] a, int left, int mid, int right){
        
        int n1 = mid - left;
        int n2 = right - mid;
        int[] l = new int[n1 +1];
        int[] r = new int[n2 +1];
        for(int i = 0; i < n1; i++){
            l[i] = a[left +i];
        }
        for(int i = 0; i < n2; i++){
            r[i] = a[mid +i];
        }
        l[n1] = Integer.MAX_VALUE;
        r[n2] = Integer.MAX_VALUE;
        int i = 0;
        int j = 0;
        for(int k = left; k < right; k++){
            if(l[i] <= r[j]){
                a[k] = l[i];
                i++;
            }else{
                a[k] = r[j];
                j++;
            }
        }
        count += right - left;
    }
    
    static void mergeSort(int[] a, int left, int right){
        
        if(left+1 < right){
            int mid = (left + right)/2;
            mergeSort(a, left, mid);
            mergeSort(a, mid, right);
            merge(a, left, mid, right);
        }
    }
}


Measured memory_bytes: 112300
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;
  return 0;
}


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

int main(){
  int A[4][4];
  int N, B[11];
  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++)
      cin >> A[i][j];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> B[i];
  
  for(int h = 0; h < N; h++){
    for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++)
        if(A[i][j] == B[h]) A[i][j] = -1;
  }
  bool ans = false;
  for(int i = 0; i < 3; i++){
    if(A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1) ans = true;
    if(A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1) ans = true;
  }
  if(A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) ans = true;
  if(A[2][0] == -1 && A[1][1] == -1 && A[0][2] == -1) ans = true;
  
  if (ans) cout <<"Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

int n,k,s;

void solve(){
    int i,j;
    string str;
    cin >> n >> k >> s;
    long long ans = 1000000000;
    if(s == 1000000000) ans = 1;
    for(i = 0;i < k;i++) cout << s << ' ';
    for(;i < n;i++) cout << ans << ' ';
    cout << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 1280
object Main {
  def main(args: Array[String]) {
    val n = scala.io.StdIn.readLine().toInt
    val as = scala.io.StdIn.readLine().split(' ').map(_.toInt).toList
    val hist = as.groupBy(a=>a).map(_._2.length)
    val m = hist.map(a=>a-1).max
    val s = hist.map(a=>a-1).sum
    val ans = n - (s+1)/2*2
    println(ans)
  }
}


Measured memory_bytes: 73092
s = input()
n = int(s)

v = input()
k = int(v)

locations = []

sub = []

answer = 0

x = input().split()
for i in range(n):
    y = int(x[i])
    locations.append(y)

for i in range(len(locations)):
    sub.append(min(locations[i], k - locations[i]) * 2)

for i in range(len(sub)):
    answer += sub[i]

print(answer)

Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll a,b,c;

int main(){
  cin>>a>>b>>c;
  ll ans = abs((a*b*(c/2))-(a*b*(c-c/2)));
  ans = min(ans,abs((a*c*(b/2))-(a*c*(b-(b/2)))));
  ans = min(ans,abs((b*c*(a/2))-(b*c*(a-(a/2)))));

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int i, j, k, m, n, l;
	long long sum[101][101], a[101][101], b[101][101];
	cin >> n >> m >> l;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			cin >> a[i][j];
	for(j=0;j<m;j++)
		for (k = 0; k < l; k++)
			cin >> b[j][k];
	for (i = 0; i < n; i++)
	{
		for (k = 0; k < l; k++)
		{
				for (j = 0; j < m; j++)
				sum[i][k] += a[i][j] * b[j][k];
		if(k==l-1)cout << sum[i][k];
		else cout<<sum[i][k]<<" ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {

    string S;
    cin >> S;

    lli length = S.size();
    lli counter = 0;
    for (unsigned long i = 0; i < length / 2; ++i) {
        if (S[i] != S[length - 1 - i]) {
            ++counter;
        }
    }
    cout << counter << endl;
}


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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static long[] ans = new long[]{-1,-1,-1};
	public static void main(String[] args) throws Exception {


		long A = nextLong();
		long B = nextLong();

		long ans =Math.max(Math.max(A+B, A-B),A*B);
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<bitset>
using namespace std;
#define ll long long
#define db double
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
const int maxn=400+7,maxm=1e5+7;
int n,m,X[maxm],Y[maxm],ans;
bool ok[maxn];
bitset<maxn> G[maxn];

char cc; ll ff;
template<typename T>void read(T& aa) {
	aa=0;cc=getchar();ff=1;
	while((cc<'0'||cc>'9')&&cc!='-') cc=getchar();
	if(cc=='-') ff=-1,cc=getchar();
	while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
	aa*=ff;
}

int main() {
	read(n); read(m);
	For(i,1,m) read(X[i]),read(Y[i]);
	For(i,1,n) {
		G[i].reset(); G[i].set(i);
		Rep(j,m,1) {
			if(G[i][X[j]]&&G[i][Y[j]]) {ok[i]=1;break;}
			if(G[i][X[j]]) G[i].set(Y[j]);
			if(G[i][Y[j]]) G[i].set(X[j]);
		}
	}
	For(i,1,n) if(!ok[i]) For(j,i+1,n) if(!ok[j])
		if((G[i]&G[j]).count()==0) ans++;
	printf("%d\n",ans);
	return 0;
}


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

int main() {
  int N,K;
  cin>>N>>K;
  int ans=1;
  
  for(int i=0;i<N;i++){
    if(ans>K) ans+=K;
    else ans*=2;
   
   }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s,t="YAKI";
int main()
{
    cin>>s;
    if ((int)s.length()<4)
        puts("No");
    else if (s.substr(0,4)==t)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
edge=[]
graph=[[] for i in range(n)]
point=[-1]*n
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1;b-=1
  edge.append([a,b])
  graph[a].append(b)
  graph[b].append(a)
num=list(map(int,input().split()));num.sort()
start=0
for i in range(n):
  if len(graph[i])==1:
    start=i
    break
dfs=deque([start])
while dfs:
  v=dfs.popleft()
  point[v]=num.pop()
  for i in graph[v]:
    if point[i]!=-1:continue
    dfs.appendleft(i)
ans=0
for i in edge:
  ans+=min(point[i[0]],point[i[1]])
print(ans)
print(*point)

Measured memory_bytes: 52184
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n,c,k;
    cin >> n >> c >> k;
    vector<int>t(n);
    rep(i,n)cin >> t[i];
    sort(t.begin(),t.end());
    int limit = t[0]+k;
    int cnt = 0;
    int ans = 1;
    rep(i,n){
        if(t[i]<=limit){
            cnt++;
            if(cnt == c){
                if(i+1<n){
                    ans++;
                    limit = t[i+1] + k;
                    cnt = 0;
                }
            }
        }else{
            limit = t[i]+k;
            ans++;
            cnt = 0;
            i--;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    
    if(a == 0){
        cout << "1" << endl;
    }
    if(b == 0){
        cout << "2" << endl;
    }
    if(c == 0){
        cout << "3" << endl;
    }
    if(d == 0){
        cout << "4" << endl;
    }
    if(e == 0){
        cout << "5" << endl;
    }
} 

Measured memory_bytes: 3524
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    for(int i=0;i<m;i++){
        ll a;
        cin>>a;
        sum+=a;
    }
    if(sum>n)cout<<-1<<"\n";
    else cout<<n-sum<<"\n";
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

ll const mod = 1e9+7;

int main(){
    string l; cin >> l;
    vector<vector<ll>> dp(l.size()+1, vector<ll>(2, 0));
    dp[0][1] = 1;
    REP(i, 0, l.size()){
        if(l[i] == '0'){
            dp[i+1][1] = dp[i][1];
            dp[i+1][0] = dp[i][0]*3;
            dp[i+1][1] %= mod;
            dp[i+1][0] %= mod;
        }else{
            dp[i+1][1] = dp[i][1] * 2;
            dp[i+1][0] = dp[i][0]*3 + dp[i][1];
            dp[i+1][1] %= mod;
            dp[i+1][0] %= mod;
        }
    }
    cout << (dp[l.size()][0] + dp[l.size()][1] )%mod << endl;
}

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

int main() {
  int d,t,s;
  cin >> d >> t >> s;
  
  if(d <= s*t) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return(0);
}

Measured memory_bytes: 3632
from sys import stdin, setrecursionlimit
from bisect import bisect_right


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()

    idx = bisect_right(a, 0)

    if idx % 2 == 0:
        print(sum(a[idx:]) - sum(a[:idx]))
    elif idx == n:
        print(a[idx - 1] - sum(a[:idx - 1]))
    else:
        print(sum(a[idx:]) - sum(a[:idx]) - 2 * min(-a[idx - 1], a[idx]))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 59504
#include <iostream>
#include <map>

using namespace std;
#define REP(i,n) for (int i = 0; i < n; ++i)

int N;
string S;
map<pair<string, string>, int> m;

int main() {
    cin >> N >> S;
    int all = (1<<N) - 1;
    REP (i, 1<<N) {
        string s, t;
        REP (j, N) {
            if (i>>(N-j-1) & 1) s += S[j];
            else t += S[j];
        }
        m[make_pair(s, t)]++;
    }

    long long ans = 0;
    REP (i, 1<<N) {
        string s, t;
        REP (j, N) {
            if (i>>(N-j-1) & 1) s += S[2*N-1-j];
            else t += S[2*N-1-j];
        }
        ans += m[make_pair(s, t)];
    }

    cout << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  
  for (int i=0;i<N;i++) {
    string a;
    cin>>a;
    
    if (a == "Y") {
      cout<<"Four"<<endl;
      break;
    }
    
    else if (i == N-1) {
      cout<<"Three"<<endl;
    }
    
    else if (a != "Y") {
      continue;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  int maxA=0, maxB=0, maxC=0, tmp, i;

  for(i=0; i<10; i++) {
    scanf("%d", &tmp);
    if(maxA<tmp) {
      maxC = maxB;
      maxB = maxA;
      maxA = tmp;
    }
    else if(maxB<tmp) {
      maxC = maxB;
      maxB = tmp;
    }
    else if(maxC<tmp) {
      maxC = tmp;
    }
  }
  printf("%d\n%d\n%d\n", maxA,maxB,maxC);

  return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <fstream>

#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>

#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>

#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */


void solve(istream &cin) {
    ll N, K;
    cin >> N >> K;
    if(!cin) return;
    vector<ll> best(N, -1), bestk(N, -1);
    vector<pair<ll, ll>> sushi;
    priority_queue<pair<ll, ll>> pq;
    for (int i = 0; i < N; ++i) {
        ll t, d;
        cin >> t >> d;
        t--;
        sushi.emplace_back(t, d);
        pq.emplace(d, i);
        bestk[t] = max(bestk[t], d);
    } // end i
    priority_queue<ll> dont_need;
    ll eat = 0;
    ll sum = 0, kind = 0;
    while(eat < K){
        auto s = pq.top(); pq.pop();
        ll i = s.second;
        ll t = sushi[i].first;
        ll d = s.first;
        sum += d;
        if(best[t] == -1){
            kind++;
            best[t] = d;
        }
        else if(best[t] > d){
            dont_need.push(-d);
        }
        else{
            dont_need.push(-best[t]);
            best[t] = d;
        }
        eat++;
    }
    ll ans = sum + kind * kind;
    priority_queue<ll> top_of_k;
    for (int i = 0; i < bestk.size(); ++i) {
        if(bestk[i] != -1 and best[i] == -1){
            top_of_k.push(bestk[i]);
        }
    } // end i
    while(!dont_need.empty() and !top_of_k.empty()){
        auto pop = dont_need.top(); dont_need.pop();
        auto add = top_of_k.top(); top_of_k.pop();
        sum += pop + add;
        kind++;
        ans = max(ans, sum + kind*kind);
    }
    cout << ans << endl;



}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 5860
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m;
string str;

int dp[1001000];

int main() {
    while (cin >> n) {
        if (n == 0) break;
        
        cin >> m;
        cin >> str;
        str += "XXXXXXX";
        
        memset(dp, -1, sizeof (dp));
        for (int i = 0; i < m; ++i) if (str[i] == 'I') dp[i] = 1;
        
        for (int i = m-1; i >= 0; --i) {
            if (str[i] == 'I' && str[i+1] == 'O' && dp[i+2] != -1)
                chmax(dp[i], dp[i+2] + 1);
        }
        
        int res = 0;
        for (int i = 0; i < m; ++i) if (dp[i] > n) ++res;
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 6020
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:44:21 2020

@author: Paras
"""

x,k,d = map(int, input().split())

moves = abs(x)//d
if moves>=k:
    print(abs(x)-(k*d))
    
else:
    closest1 = abs(x)-moves*d
    closest2 = closest1-d
    if closest1==abs(closest2):
        if closest1==0:
            leftmoves = k-moves
            if leftmoves%2==0:
                print("0")
            else:
                print(d)
        else:
            print(closest1)
    else:
        if (k-moves)%2==0:
            print(abs(closest1))
        else:
            print(abs(closest2))

    

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

const int maxn=5001;
const double EPS =1e-6;
const double PI =3.141592653589793;
using namespace std;
const int MOD=998244353;
typedef long long ll;
typedef long double ld;
ll fac[maxn];
ll rev[maxn];
ll inv[maxn];
ll pw[maxn];
ll ans[maxn];
void prep(){
    fac[0]=1;
    rev[1]=1;
    fac[1]=1;
    inv[0]=inv[1]=1;
    pw[0]=1;
    pw[1]=2;
    for(int i=2; i<maxn; ++i){
        pw[i]=pw[i-1]*2%MOD;
        fac[i]=fac[i-1]*i%MOD;
        rev[i]=(MOD-MOD/i)*rev[MOD%i]%MOD;
        inv[i]=inv[i-1]*rev[i]%MOD;
       // cout<<i<<" "<<fac[i]<<" "<<rev[i]<<endl;
        assert(fac[i]*inv[i]%MOD==1);
    }
}
ll C(int n,int k){
    if (k<0 || k>n)
        return 0;
    return fac[n]*inv[k]%MOD*inv[n-k]%MOD;
}
ll C_povt(int n,int k){
    return C(n+k-1,n-1);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    prep();
    int k,n;
    cin>>k>>n;
    for(int i=2; i<=2*k; ++i){
        if (i&1){
            int col=i/2;
            if (i>k){
                int mn=i-k;
                col=(k-mn+1)/2;
            }
            for(int j=0; j<=col; ++j){
                ans[i]+=C(col,j)*pw[j]%MOD*C_povt(k-j-2*(col-j),n-j)%MOD;
                ans[i]%=MOD;
            }
        }
        else{

            int col=(i-1)/2;
            if (i>k){
                int mn=i-k;
                col=(k-mn+1)/2;
            }
          //  cout<<i<<" "<<col<<endl;
         //   cout<<"brute\n";
            for(int j=0; j<=col; ++j){
             //   cout<<j<<" "<<k-j-2*(col-j)-1<<"\n";
                ans[i]+=C(col,j)*pw[j]%MOD*C_povt(k-j-2*(col-j)-1,n-j)%MOD;
                ans[i]+=C(col,j)*pw[j]%MOD*C_povt(k-j-2*(col-j)-1,n-1-j)%MOD;
                ans[i]%=MOD;
            }
        }
    }
    for(int i=2; i<=2*k; ++i)
        cout<<ans[i]<<"\n";
}


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

#define nl cout<<"\n";
double arr[3005];
double dp[3005][3005];

int main()
{
		
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>arr[i];
	}
	dp[1][0]=(1-arr[1]);
	dp[1][1]=arr[1];
	for(int i=2; i<=n; i++)
	{
		for(int j=0; j<=i; j++)
		{
			if(j==0)
			{
				dp[i][j]=dp[i-1][j]*(1-arr[i]);
			}
			else if(j==i)
			{
				dp[i][j]=dp[i-1][j-1]*arr[i];
			}
			else
			{
				dp[i][j]=(dp[i-1][j]*(1-arr[i]))+(dp[i-1][j-1]*arr[i]);
			}
		}
	}
	double ans=0;
	for(int i=(n+1)/2; i<=n; i++)
	{
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(11)<<ans;
	
}

Measured memory_bytes: 68992
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

////// Mod int //////
struct mint {
	ll x;
	mint() :x(0) {}
	mint(ll x) :x((x% MOD + MOD) % MOD) {}
	// mint(ll x):x(x){}
	mint& fix() { x = (x % MOD + MOD) % MOD; return *this; }
	mint operator-() const { return mint(0) - *this; }
	mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
	mint& operator-=(const mint& a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; }
	mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
	mint operator+(const mint& a)const { return mint(*this) += a; }
	mint operator-(const mint& a)const { return mint(*this) -= a; }
	mint operator*(const mint& a)const { return mint(*this) *= a; }
	bool operator<(const mint& a)const { return x < a.x; }
	bool operator==(const mint& a)const { return x == a.x; }
};
istream& operator>>(istream& i, mint& a) { i >> a.x; return i; }
ostream& operator<<(ostream& o, const mint& a) { o << a.x; return o; }
typedef vector<mint> Vm;

/////////////////////

string s;
int n;
vector<Vm> dp;

void init()
{
	cin >> s;
	n = SZ(s);

	dp.resize(n + 1, Vm(13));
	dp[0][0] = 1;
}

int main()
{
	init();

	Vm dp(13);
	dp[0] = 1;

	REP(i, n)
	{
		Vm tmpdp(13);
		REP(d, 10)
			REP(j, 13)
			if (s[i] == '?' || s[i] - '0' == d)
				tmpdp[(10 * j + d) % 13] += dp[j];

		dp = tmpdp;
	}

	cout << dp[5] << endl;
}

//// solved A-D in 38min on Sep 26, 2019 ////


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解説AC
int dist[55][55];
char masu[55][55];
int vx[4]={0,1,0,-1};
int vy[4]={1,0,-1,0};
int r,c,sy,sx,gy,gx;
int main() {
  int batu=0;
  
  cin >>r>>c;
  sy=0;
  sx=0;
  gy=r-1;
  gx=c-1;
  rep(i,r){
    rep(j,c){
      cin>>masu[i][j];
      dist[i][j]=-1;
      if(masu[i][j]=='#')batu++;
    }
  }
  dist[sy][sx]=0;
  queue<pair<int,int>>q;
  q.push(make_pair(sy,sx));
  while(!q.empty()){
    pair<int,int>p=q.front();q.pop();
    int y=p.first;
    int x=p.second;
    rep(i,4){
      int ny=y+vy[i];
      int nx=x+vx[i];
      if(nx<0||nx>c||ny<0||ny>r)continue;
      if(masu[ny][nx]=='#')continue;
      if(dist[ny][nx]==-1){
        dist[ny][nx]=dist[y][x]+1;
        q.push(make_pair(ny,nx));
      }
    }
  }
  if(dist[gy][gx]==-1){
    cout<<-1<<endl;
    return 0;
  }
  int kotae=r*c-dist[gy][gx]-batu-1;
  cout<<kotae<<endl;
  /*rep(i,r){
    rep(j,c){
      cout<<masu[i][j]<<" ";
    }
    cout<<endl;
  }
  rep(i,r){
    rep(j,c){
      cout<<dist[i][j]<<" ";
    }
    cout<<endl;
  }*/
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n,m;cin>>n>>m;
    ll a[n];
    ll sum=0;
    rep(i,0,n-1){
        cin>>a[i];
        sum+=a[i];
    }
    ll k=0;
    rep(i,0,n-1){
        if(a[i]*4*m>=sum){
            k++;
        }
    }
    if(k>=m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b;
    char op;
    
    while (cin >> a >> op >> b) {
        
        if (op == '?') {
            break;
        }

        switch (op)
        {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  char S;
  bool b=false;
  cin >> N;
  
  for(int n = 0; n < N; n++){
  	cin >> S;
	if(S=='Y'){
    	b=true;
      	break;
    }
  }
  
  if(b){
  	cout << "Four" << endl;
  }else{
  	cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
A = list(map(int, input().split()))
A.sort()
ans = A[2]-A[1]
if (A[2]-(A[2]-A[1]+A[0]))%2==1:
  ans = ans + 2 + (A[2]-(ans+A[0]))//2
else:
  ans = ans + (A[2]-(ans+A[0]))//2
print(ans)

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

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 1e6+5;

void solve(){
    int n;
    cin>>n;
    vi a(n);
    map<int,int> m;
    loop(i,0,n) cin>>a[i],m[a[i]]++;
    sort(all(a));
    int cnt = 0;
    bool visited[N];
    mset(visited,0);
    loop(i,0,n){
        if(visited[a[i]]){
            continue;
        }else{
            if(m[a[i]]==1){
                cnt++;
            }
            visited[a[i]] = 1;
            for(int j=a[i];j<N;j+=a[i]){
                visited[j] = 1;
            }
        }
    }
    cout<<cnt<<endl;

}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


Measured memory_bytes: 18248
#include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
int sum = 0, maxL = 0;
for (int i = 0; i < n; ++i) {
int L; cin >> L;
sum += L;
maxL = max(maxL , L);
}
if (maxL < sum - maxL) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}


Measured memory_bytes: 256