akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(l);i<(r);i+=(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009 
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
//snippet
//overflow...char 1e6

#define N 100009


int main() {
	int n, sup = 0;
	LL a[N] = { 0 }, s = 0;
	scanf("%d", &n);
	rep(i, n)scanf("%lld", &a[i]);
	sortupLL(a, n);
	rep(i, n) {
		s += a[i];
		if (s * 2 < a[i + 1]) sup = i + 1;
	}
	printf("%d", n - sup);
}

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

int main(){
	int n; cin>>n;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	for(int i=n-1; i>=0; i-=2){
		cout<<v[i]<<" ";
	}
	if(n%2==0){
		for(int i=0; i<n; i+=2){
			cout<<v[i]<<" ";
		}
	}else{
		for(int i=1; i<n; i+=2){
			cout<<v[i]<<" ";
		}
	}
}

Measured memory_bytes: 4032
import math
N = int(input())
M = int(math.sqrt(N))
l = [0] * N
for x in range(1,M+1):
  for y in range(1,M+1):
    for z in range(1,M+1):
      sum = x*x + y*y + z*z + x*y + y*z + z*x
      if sum <= N:
        l[sum-1] = l[sum-1] + 1        
for i in range(0,N):
  print(l[i])


Measured memory_bytes: 9356
#include <iostream>

using namespace std;

int main() {

  long long n, ans = 1e18;
  cin >> n;
  for(long long i = 1;i * i <= n;i++){
    if(n % i == 0){
      ans = min(ans, i + n / i);
    }
  }
  cout << ans - 2;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++) 
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main() 
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n,r;
	cin>>n>>r;
	if(n>=10) cout<<r<<'\n';
	else cout<<r+100*(10-n)<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;

int main(){
	ll n,a,b;
	scanf("%lld%lld%lld", &n, &a, &b);

	if(a > b) swap(a,b);

	if((b-a)%2 == 0) printf("%lld\n", (b-a)/2);
	else {
		ll ans = min<ll>(a + (b-a)/2, n-b+1 + (b-a)/2);
		printf("%lld\n", ans);
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	int n=s.size(); 
	int ret=0;
	for (int i=0; i<n; i++)
		if (s[i]!=t[i]) 
			ret++;
		cout<<ret<<endl;
	return 0;
}


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

fp = A[0]
tmp = 0
c = 1000
stock = 0
IsSearchTop = False
first = True
for i in range(1,N):
    if first:
        if fp > A[i]:
            fp = A[i]
        elif fp < A[i]:
            stock += c // fp
            c -= stock * fp
            IsSearchTop = True
            first = False
            fp = A[i]
            if i == N - 1:
                c += stock * fp
    else:
        if IsSearchTop:
            if fp <= A[i]:
                fp = A[i]
                if i == N-1:
                    c += stock * fp
            elif fp > A[i]:
                c += stock * fp
                stock = 0
                fp = A[i]
                IsSearchTop = False
        else:
            if fp >= A[i]:
                fp = A[i]
            elif fp < A[i]:
                stock += c // fp
                c -= stock * fp
                IsSearchTop = True
                fp = A[i]
                if i == N - 1:
                    c += stock * fp
print(c)














Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
int isPalindrome(string str) 
{ 
    int l = 0; 
    int h = str.length()-1;  
    while(h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return 0; 
        } 
    } 
    return 1; 
} 
int main()
{
    string s;
    cin>>s;
    int n = s.length();
    string str1 = s.substr(0,(n-1)/2);
    string str2 = s.substr((n+1)/2,(n-1)/2);
    if(isPalindrome(s) && isPalindrome(str1) && isPalindrome(str2))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;



int main(){
	int N,Q;
	cin>>N>>Q;
	ll B[MAX];
	rep1(i,N){
		cin>>B[N+1-i];
	}
	if(N%2==0){
		int h=N/2;
		ll sm[MAX];	
		sm[1]=0;
		rep1(i,N)if(i%2==1)sm[1]+=B[i];
		
		for(int i=2;i<=h;i++){
			sm[i]=sm[i-1]+B[i]-B[2*i-1];
		}
		ll pos[MAX];
		pos[h]=0;
		rep1(i,h-1)pos[i]=1+((B[i+1]+B[2*i+1])/2);
		
		rep(i,Q){
			ll x;
			cin>>x;
			int lb=0, ub=h;
			while(ub-lb>1){
				int mid=((ub+lb)/2);
				if(pos[mid]<=x)ub=mid;
				else lb=mid;
			}
			cout<<sm[ub]<<endl;
		}
	}
	else{
		int h=N/2;
		ll sm[MAX];	
		sm[1]=0;
		rep1(i,N)if(i%2==1)sm[1]+=B[i];
		
		for(int i=2;i<=h+1;i++){
			sm[i]=sm[i-1]+B[i]-B[2*i-1];
		}
		ll pos[MAX];
		pos[h+1]=0;
		rep1(i,h)pos[i]=1+((B[i+1]+B[2*i+1])/2);
		rep(i,Q){
			ll x;
			cin>>x;
			int lb=0, ub=h+1;
			while(ub-lb>1){
				int mid=((ub+lb)/2);
				if(pos[mid]<=x)ub=mid;
				else lb=mid;
			}
			cout<<sm[ub]<<endl;
		}
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i=0 ; i<n ; i++)
    cin >> d.at(i);
  
  int ans = 0;
  for (int i=0 ; i<n-1 ; i++){
    for (int j=i+1 ; j<n ; j++){
      ans += d.at(i)*d.at(j);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    while(1)
    {
        ll m,f,r;
        cin>>m>>f>>r;
        if(m==-1 && f==-1 && r==-1) break;
        else
        {
            if(m==-1 || f==-1) cout<<"F"<<endl;
            else
            {

                         if(m+f>=80)           cout<<"A"<<endl;
                    else if(65<=m+f && m+f<80) cout<<"B"<<endl;
                    else if(50<=m+f && m+f<65) cout<<"C"<<endl;
                    else if(30<=m+f && m+f<50)
                    {
                        if(r>=50) cout<<"C"<<endl;
                        else      cout<<"D"<<endl;
                    }
                    else if(m+f<30)            cout<<"F"<<endl;
            }
        }
    }
    return 0;
}



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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    ll n, ntmp; 
    cin >> n;
    map<ll,ll> ret;
    vector<ll> nsm((ll)sqrt(n)+2, 0);
    nsm[0] = 0;
    FOR(i,1,(ll)sqrt(n)+2) nsm[i] = nsm[i-1]+i;

    ntmp = n;
    for(ll i = 2; i * i <= ntmp; i++) {
        while(ntmp % i == 0) {
            ret[i]++;
            ntmp /= i;
        }
    }
    if(ntmp != 1) ret[ntmp] = 1;

    ll ans = 0;
    auto itr = ret.begin();
    while(itr != ret.end()){
        ll tmp = itr->second;
        ans += (upper_bound(nsm.begin(),nsm.end(),tmp)-nsm.begin())-1;
        itr++;
    }

    cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main () {
	long long int a, b, t, x, y;
	cin>>x >> a >> y >> b >> t;
	if(t==0)
		if(x==y) 
			return cout << "YES",0;
		else 
			return cout << "NO",0;
	else {
		long long int fa = abs(x - y), dis = a - b;
		if(dis<=0) 
			return cout << "NO",0;
		if(dis*t>=fa) 
			return cout << "YES",0;
		else 
			return cout << "NO" ,0;
	}
}


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

int main(){

    int a, b;
    cin >> a >> b;

    if (a < b){
       for (int i=0; i<b; i++){
           cout << a;
       }
       cout << endl;
    }
    else{
       for (int i=0; i<a; i++){
           cout << b;
       }
       cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int parent(int);
int left(int);
int right(int);

int main(){

  int n;
  int id;
  int k[250];
  int pk;
  int lk;
  int rk;
 
  scanf("%d", &n);
  
  for( id=1; id<=n; id++ ) {
    scanf("%d", &k[id]);
  }

  for( id=1; id<=n; id++ ) {
    printf("node %d: key = %d, ",id, k[id]);
    if( id>1 ) {
      pk = parent(id);
      printf("parent key = %d, ",k[pk]);
    }
    lk = left(id);
    rk = right(id);
    if( lk<=n ) {
      printf("left key = %d, ",k[lk]);
    }
    if( rk<=n ) {
      printf("right key = %d, ",k[rk]);
    }
    printf("\n");
  }
  return 0;
}

int parent(int i) {
  return i/2;
}

int left(int i) {
  return 2*i;
}

int right (int i) {
  return 2*i+1;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(){
    int a,b,c,d,min=0,max=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a>=c){
        min = a;
    }else{
        min = c;
    }
    if(b>=d){
        max=d;
    }else{
        max=b;
    }
    if(b<c || d<a){
        printf("0\n");
    }else{
        printf("%d\n",max-min);
    }
    return 0;
}

Measured memory_bytes: 128
from itertools import combinations

names = [input() for _ in range(int(input()))]
march = [list(filter(lambda x: x[0] == c, names)) for c in 'MARCH']
ways = 0
for combo in combinations(march, 3):
    ways += len(combo[0]) * len(combo[1]) * len(combo[2])
print(ways)

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

int main(){
   string s ;
  cin >> s ;
  if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]) cout << "No" << endl;
  else if(s[0]==s[1]&&s[2]==s[3]||s[0]==s[2]&&s[1]==s[3]||s[0]==s[3]&&s[1]==s[2]){
    cout << "Yes" << endl;
  }
    else cout << "No" << endl;
  }


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC153
{
    class MainClass
    {

        static long[] s, a;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            a = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            long ans = 0;
            for(int i = 0;i<s[1];i++){
                ans += a[i];

            }
            if(ans>=s[0]){
                WriteLine("Yes");
            }else{
                WriteLine("No");
            }
        }
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x,y,ans = 1; cin >> x >> y;
  while (2*x <= y) {x *= 2; ans+=1;} 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <stdio.h>
using namespace std;
#include <string>
#include <vector>
int main(void) {
    int n;
    cin >>n;
    vector<int> vec(2*n);
    for (int i = 0; i < 2*n; i++) {
        cin >> vec.at(i);
        }
    for(int i=0;i<n-2;i++){
        if(vec.at(2*i)==vec.at(2*i+1) and vec.at(2*i+2)==vec.at(2*i+3) and vec.at(2*i+4)==vec.at(2*i+5)){
            cout<<"Yes";
            return 0;
        }
           }
           cout << "No";
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const double eps = 1e-9;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n;
    cin >> n;
    vt<pii> a(n);
    for (pii &i : a) cin >> i.fi >> i.se;

    auto check = [&](double x, double y, double r) {
        for (int i = 0; i < n; i++) {
            if (hypot(a[i].fi - x, a[i].se - y) > r * (1 + eps))
                return false;
        }

        return true;
    };

    double l = 0, r = 710;
    while (l * (1 + eps) < r) {
        double mi = (l + r) / 2;

        bool ok = false;
        for (int i = 0; i < n && !ok; i++) {
            for (int j = i + 1; j < n && !ok; j++) {
                double mx = (a[i].fi + a[j].fi) / 2.0,
                       my = (a[i].se + a[j].se) / 2.0,
                       dx = a[i].fi - mx,
                       dy = a[i].se - my,
                       hl = hypot(dx, dy),
                       s = -dy / hl,
                       t = dx / hl;

                if (mi < hl) continue;

                double d = sqrt(mi * mi - hl * hl);
                if (check(mx - s * d, my - t * d, mi) ||
                        check(mx + s * d, my + t * d, mi)) ok = true;
            }
        }

        if (ok) r = mi;
        else l = mi;
    }

    cout << setprecision(7) << fixed << l;
}


Measured memory_bytes: 3792
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,t;
  cin >> s;
  cin >> t;
	bool res = false;
  for(int i = 0; i < s.size(); i++){
  	if(s == t) {
    	res = true;
      	break;
    }
    s = s.back() + s.substr(0,s.size()-1);
  }
  (res)? cout << "Yes\n" : cout << "No\n";
  
	return 0;
}

Measured memory_bytes: 256
H=int(input())
W=int(input())
N=int(input())

cnt=0
black=0
if H>=W:
  for i in range(W):
    black+=H
    cnt+=1
    if black>=N:
      break
elif H<W:
  for i in range(H):
    black+=W
    cnt+=1
    if black>=N:
      break
print(cnt)

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

int main(){
  int N;
  cin >> N;
  
  int t[100010] = {0};
  int x[100010] = {0};
  int y[100010] = {0};
  
  for(int i = 1;i <= N;i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  
  int sax,say,zikan,mitinori;
  int ok = 0;
  
  for(int i = 0;i < N;i++){
    if(x[i+1] - x[i] >= 0){
      sax = x[i+1] - x[i];
    }
    else{
      sax = x[i] - x[i+1];
    }
    if(y[i+1] - y[i] >= 0){
      say = y[i+1] - y[i];
    }
    else{
      say = y[i] - y[i+1];
    }
    mitinori = sax + say;
    zikan = t[i+1] - t[i];
    if((mitinori - zikan) % 2 == 0 && zikan >= mitinori){
      ok++;
    }
  }
  
  if(ok == N){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int N, M;
char s[111][111];
int dp[111][111];
int main() {
    cin >> N >> M;
    for (int i = 0 ; i < N ; i++)
        for (int j = 0 ; j < M ; j++)
            cin >> s[i + 1][j + 1];
    fill(dp[0], dp[110] + 111, 1e9);
    queue<pair<int, int>> q;

    q.push({1, 1});
    dp[1][1] = (int) (s[1][1] == '#');
    while (!q.empty()) {
        auto qf = q.front();
        q.pop();
        int x = qf.first;
        int y = qf.second;
        int z = (int) (s[x + 1][y] == '#' && s[x][y] == '.');
        int w = (int) (s[x][y + 1] == '#' && s[x][y] == '.');
        // cout << x << ' ' << y << ' ' << z << ' ' << w << '\n';
        if (x + 1 <= N && dp[x + 1][y] > dp[x][y] + z) {
            dp[x + 1][y] = dp[x][y] + z;
            q.push({x + 1, y});
        }
        if (y + 1 <= M && dp[x][y + 1] > dp[x][y] + w) {
            dp[x][y + 1] = dp[x][y] + w;
            q.push({x, y + 1});
        }
    }
    cout << dp[N][M] << '\n';
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		int w = sc.nextInt();
		long[][]a = input(n , 2 );
		long[][] dp = new long[n+1][w+1];
		for(long[] k : dp)Arrays.fill(k, Long.MIN_VALUE);
		dp[0][0]=0;
		long ans = 0 ; 
		for(int i = 1 ;i <= n ;i++) {
			for(int j = 0 ;j <= w  ;j++) {
				if(j==0) {dp[i][j]=0;continue;}
				if(j - a[i-1][0] >=0) {
						dp[i][j] =Math.max( dp[i-1][(int) (j-a[i-1][0])] + a[i-1][1]  , dp[i-1][j]) ;
					
				}else {
					dp[i][j] =dp[i-1][j];
				}
				
			}
		}
		for(int i = 0 ;i <=w ;i++) ans = Math.max(ans, dp[n][i]);
		System.out.println(ans);

		
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}
	public static long[][] input(int n , int m ) throws Exception {

		long[][] arr = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {

				arr[i][j] = sc.nextInt();
			}
		}
		return arr;
	}

}


Measured memory_bytes: 140744
#include<iostream>
using namespace std;
int main(){
	long n,k;
	cin >> n >> k;
  long ans = 0;
     for(long a = k+1;a<=n;a++){
         ans += (n/a)*(a-k);
         if(n%a>=k)ans+=n%a-k+1;
     }
     if(k==0)ans-=n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 土 10/27 21:02:12 2018

# Usage
#
"""
def main():
    IN = input()

    if len(IN) == 2:
        print(IN)

    if len(IN) == 3:
        print(''.join(reversed(IN)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int H, W;
  for (;;) {
    cin >> H >> W;
    if (!H && !W)
      break;

    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j)
        printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long ;
using namespace std;
const int nax = 1e9+5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int>a(n), dp(n, nax);
    dp[0] = 0;
    for(int& i:a){scanf("%d", &i);}
    for(int i=0; i<n; i++){
        for(int j:{i+1, i+2}){
            if(j<n){
                dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]));
            }
        }
    }
    printf("%d", dp[n-1]);
}


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

int main(){
  int a;
  int b;
  string odd = "Odd";
  string even = "Even";
  
  cin >> a >> b;
  if (a * b % 2 == 0) {
    cout << even << endl;
  } else {
    cout << odd << endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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 all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int h,w,d;cin>>h>>w>>d;
    map<int,pair<int,int>> num;
    int a;
    rep(i,h)rep(j,w){
        cin>>a;
        num[a]=mp(i+1,j+1);
    }
    vin power(h*w+1);
    rep2(i,1,d+1){
        power[i]=0;
        for(int j=i+d;j<h*w+1;j+=d){
            power[j]=power[j-d]+abs(num[j].first-num[j-d].first)+abs(num[j].second-num[j-d].second);
        }
    }
    int q;cin>>q;
    int l,r;queue<ll> ans;
    rep(i,q){
        cin>>l>>r;
        ans.push(power[r]-power[l]);
    }
    while(ans.size()){
        cout<<ans.front()<<endl;
        ans.pop();
    }
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  string s,t; cin >> s >> t;
  int ans = 0;
  REP(i,3) if (s[i] == t[i]) ans++;
  COUT(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<Integer, Integer> h = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int d = Integer.parseInt(sc.next());
            if (h.containsKey(d)) {
                h.put(d, h.get(d) + 1);
            } else {
                h.put(d, 1);
            }
        }
        int m = Integer.parseInt(sc.next());
        HashMap<Integer, Integer> g = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int t = Integer.parseInt(sc.next());
            if (g.containsKey(t)) {
                g.put(t, g.get(t) + 1);
            } else {
                g.put(t, 1);
            }
        }
        sc.close();
        boolean f = true;
        for (int k : g.keySet()) {
            if (!h.containsKey(k) || h.get(k) < g.get(k)) {
                f = false;
                break;
            }
        }
        System.out.println((f ? "YES" : "NO"));
    }
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(20) << fixed;

    int n, q;
    cin >> n >> q;
    V<ll> a(n), as(n + 1);
    V<ll> two(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i]; a[i] *= 3;
        as[i + 1] = as[i] + a[i];
        two[i] = (i >= 2 ? two[i - 2] : 0) + a[i];
    }

    for (int ph = 0; ph < q; ph++) {
        ll x;
        cin >> x;
        x *= 3; x--;

        ll lw = 0, up = TEN(10);
        while (up - lw > 1) {
            ll md = (lw + up) / 2;
            int cnt0 = upper_bound(a.begin(), a.end(), x + md) - lower_bound(a.begin(), a.end(), x - md);
            int cnt1 = a.end() - upper_bound(a.begin(), a.end(), x + md);
            if (cnt0 <= cnt1) {
                lw = md;
            } else {
                up = md;
            }
        }
        ll md = lw;
        int cnt0 = upper_bound(a.begin(), a.end(), x + md) - lower_bound(a.begin(), a.end(), x - md);
        int cnt1 = a.end() - upper_bound(a.begin(), a.end(), x + md);
        ll ans = as.back() - as[n - cnt1];
        if (cnt0 < cnt1) {
            if (n - cnt1 - cnt0 - 2 >= 0) ans += two[n - cnt1 - cnt0 - 2];
        } else {
            if (n - cnt1 - cnt0 - 1 >= 0) ans += two[n - cnt1 - cnt0 - 1];
        }
        cout << ans / 3 << endl;
    }

    return 0;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (ll)a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

void solve(ll t) {
	ll n; cin >> n ;
	while(n) { if(n%10==7) { cout << "Yes" ; return ; } n/=10; }

	cout << "No";	
}

int main() {


    fast;
	ll t=1;
	// cin>>t;
	rep(t) {
		solve(i+1) ;
	}
	return 0;
}


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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i > k) {
            ans += y;
        }
        else {
            ans += x;
        }
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 256
n = STDIN.gets.to_i
array = STDIN.gets.split.map(&:to_i)
flag = 1
counter = 0
(array.length).downto(1){ |i|
  while flag == 1 do
    flag = 0
    (n-1).downto(1){ |j|
      if array[j] < array[j-1] then
        tmp = array[j]
        array[j] = array[j-1]
        array[j-1] = tmp
        flag = 1
        counter +=1
      end
    }
  end
}

puts array.join(' ')
puts counter

Measured memory_bytes: 8652
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<map>
#include<functional>
using namespace std;
typedef long long int llint;
typedef bool izryt;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int big=1e9;
const int mod=1e9 + 7;
int main(void){
	int R,C,N,i,j,a,s,d,f;cin>>R>>C>>N;
	vector<pair<int,int>>ten;
	for(i=0;i<N;i++){
		cin>>a>>s>>d>>f;
		int lef,rig;
		if(0<a&&a<R&&0<s&&s<C){continue;}
		if(0<d&&d<R&&0<f&&f<C){continue;}
		if(s==0){lef=a;}
		else if(a==R){lef=R+s;}
		else if(s==C){lef=R+C+R-a;}
		else if(a==0){lef=R+C+R+C-s;}
		
		if(f==0){rig=d;}
		else if(d==R){rig=R+f;}
		else if(f==C){rig=R+C+R-d;}
		else if(d==0){rig=R+C+R+C-f;}
		if(lef>rig){swap(lef,rig);}
		ten.pub(mp(lef,rig));
	}
	vector<int> zam;
	sort(ten.begin(),ten.end());
	/*for(i=0;i<ten.size();i++){
		cout<<"debag"<<ten[i].fir<<" "<<ten[i].sec<<endl;
	}*/
	for(i=0;i<ten.size();i++){
		int lef=ten[i].fir;
		int rig=ten[i].sec;
		while(zam.size()>0&&zam.back()<lef){zam.pob();}
		if(zam.size()>0&&zam.back()<rig){cout<<"NO"<<endl;return 0;}
		zam.pub(rig);
	}
	cout<<"YES"<<endl;
	return 0;
}

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



int main() {
    int n;
    cin >> n;
    vector<int> nums;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        nums.push_back(x);
    }
    sort(nums.begin(), nums.end());
    int flag = 0;
    for(int i = 0; i < n - 1; i++){
        if(nums[i] == nums[i + 1]) {flag = 1; break;}
    }
    if(flag == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> P(N);
  vector<int> o(N);
  for (int i = 0; i < N; i++) {
    int p; cin >> p;
    P.at(i) = p; p--;
    o.at(p) = i;
  }
  int maxlen = 0;
  int len = 1;
  for (int i = 1; i < N; i++) {
    if (o.at(i-1) < o.at(i)) {
      len++;
    }else {
      maxlen = max(maxlen, len);
      len = 1;
    }
  }
  maxlen = max(maxlen, len);
  cout << N - maxlen << endl;

  return 0;
}



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

int N,  L;
int T[210];
int EXC[210];

int main(void){
    // Your code here!
    cin  >> N >> L;
    int total = 0;
    for(int i = 0; i < N; i++) {
        T[i] = L + i;
        total += T[i];
    }
    
    int diff = 10000000;
    int ans = -1;
    for(int i = 0; i < N; i++){
        int taste = total -  T[i];
        if(diff > abs(total - taste)) {
            diff = abs(total-taste);
            ans = taste;
        }
    }
    
    cout << ans << endl;
}


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

int main() {
	int a[100], n;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int i = n-1; i >= 0; i--){
		cout << a[i];
		if (i != 0){
			cout << " ";
		}else {
			cout << endl ;
		}	
	}
	return 0;
}


Measured memory_bytes: 3096
use std::io::*;
use std::cmp::*;

fn main() {
    let mut input = String::new();
    stdin().read_line(&mut input);
    input.clear();
    stdin().read_line(&mut input);
    let vec = input.split_whitespace()
                   .map(|x| x.parse().unwrap())
                   .collect::<Vec<i32>>();

    let mut max_val = 0;
    for e in vec.iter() {
        if max_val > e + 1 {
            println!("No");
            return;
        }
        max_val = max(max_val, *e);
    }
    println!("Yes");
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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 vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 A,B,K;
    cin >> A >> B >> K;

    i64 cnt=0;
    for(i64 i=min(A,B); i>=1; --i){
        if(A%i==0 and B%i==0) ++cnt;
        if(cnt==K){
            cout << i << endl;
            return;
        }
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 3010;
double dp[N][N];
double p[N];
bool vis[N][N];

  int n;
double solve(int id,int cara){
  if(id==n+1){
    if(cara>n-cara)return 1.0;
      return 0.0;
  }
  if(vis[id][cara])return dp[id][cara];
  vis[id][cara] = 1;
  dp[id][cara]=p[id]*solve(id+1,cara+1) + (1.0-p[id])*solve(id+1,cara);
  return dp[id][cara];
}

int32_t main(){
  fastio;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i];
  }

  cout<<setprecision(12)<<fixed;

  cout << solve(1,0)<<endl;
 
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 79872
import Data.List

main = do
    inputs <- getContents
    let probs = get2.map (map read.words).lines $ inputs
    mapM_ putStrLn $ map ((\(h,b) -> unwords [show h,show b]).(\[a,b] -> hitAndBlow a b)) $ probs
        where 
            get2 []  = []
            get2 lst = take 2 lst : get2 (drop 2 lst)

hitAndBlow :: [Int] -> [Int] -> (Int, Int)
hitAndBlow n1 n2 = (hit,blow)
    where
        hit = length.filter (== True) $ zipWith (==) n1 n2
        blow = subtract hit.length $ intersect n1 n2

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

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


#define F first
#define S second

#define ERR 1e-9

#if !ONLINE_JUDGE && !EVAL
    #define dbg_var(x) cerr << #x << ": " << x << "\n";
    #define dbg_iter(x, y) cerr  << #x << ": " << print_iterable(x, y) << "\n";
#else
    #define dbg_var(x)
    #define dbg_iter(x, y)
#endif // ONLINE_JUDGE

template <typename T1, typename T2>
string print_iterable( T1 begin_iter, T2 end_iter){
    bool first = true;
    stringstream res;
    res << "[ ";
    for(; begin_iter != end_iter; ++begin_iter){
        if(!first) res << ", ";
        first = false;
        res << *begin_iter;
    }
    res << " ]";
    return res.str();
}

void aggMax(int & res, int x){ if(x > res)res = x; }
void aggMin(int & res, int x){ if(x < res)res = x; }

int II(){ int i; cin >> i; return i; }
void OI(int i){ cout << i; }

// constraints
#define MAXN 1000000

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s; cin >> s;
    int res = 0, act = 0;

    for(int i=0; i<int(s.size()); i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'T' || s[i] == 'G') act++;
        else{
            res = max(act, res);
            act = 0;
        }
    }

    res = max(res, act);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
// atcoder/abc140/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  string s;
  while (cin >> n >> k >> s) {
    vector<string> v;
    string t;
    each (c, s) {
      if (!t.empty() && t.back() != c) {
        v.push_back(t);
        t = "";
      }
      t += c;
    }
    if (t.size()) v.push_back(t);
    // cout << v << endl;

    map<char, char> rev;
    rev['R'] = 'L';
    rev['L'] = 'R';

    // if (k && v[0][0] == 'L') {
    //   --k;
    //   v[0] = string(v[0].size(), 'R');
    // }
    // if (1 < v.size() && k && v[v.size() - 1][0] == 'R') {
    //   --k;
    //   v[v.size() - 1] = string(v[v.size() - 1].size(), 'L');
    // }

    for (int i = 1; i < v.size() && k; ++i) {
      if (v[i - 1].front() != v[i].front()) {
        v[i] = string(v[i].size(), v[i - 1].front());
        --k;
      }
    }

    t = "";
    each (i, v) t += i;
    // cout << t << endl;
    int cnt = 0;
    for (int i = 0; i + 1 < t.size(); ++i) {
      cnt += (t[i] == t[i + 1]);
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 6084
#include<cstdio>
#include<algorithm>
#include<vector>
#include<functional>
int main(){
    int n,w,w0,wi,vi;
    std::vector<int> v[4];
    scanf("%d%d",&n,&w);
    for(int i=0;i<n;i++){
        scanf("%d%d",&wi,&vi);
        if(i==0)w0=wi;
        v[wi-w0].push_back(vi);
    }
    for(int i=0;i<4;i++){
        std::sort(v[i].begin(),v[i].end(),std::greater<int>());
        for(int j=1;j<(int)v[i].size();j++)v[i][j]+=v[i][j-1];
        v[i].push_back(0);
        std::sort(v[i].begin(),v[i].end());
    }
    int w1=w0+1,w2=w0+2,w3=w0+3,vmax=0;
    for(int i0=0;i0<(int)v[0].size();i0++){
        if(w0*i0>w)break;
        for(int i1=0;i1<(int)v[1].size();i1++){
            if(w0*i0+w1*i1>w)break;
            for(int i2=0;i2<(int)v[2].size();i2++){
                if(w0*i0+w1*i1+w2*i2>w)break;
                for(int i3=0;i3<(int)v[3].size();i3++){
                    if(w0*i0+w1*i1+w2*i2+w3*i3>w)break;
                    int vnow=v[0][i0]+v[1][i1]+v[2][i2]+v[3][i3];
                    if(vmax<vnow)vmax=vnow;
                }
            }
        }
    }
    printf("%d",vmax);
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  lines = input.split("\n");
  m1 = lines[0].split(" ")[0];
  m2 = lines[1].split(" ")[0];

  if (m1 === m2) {
    console.log(0);
  } else {
    console.log(1);
  }

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


Measured memory_bytes: 21064
#include<stdio.h>
int main(){
	int field[10][10];
	int x,y,t,a,b,w=0,d=0;
	for(a=0;a<10;a++){
		for(b=0;b<10;b++){
			field[a][b]=0;
		}
	}
	for(;;){
		if(scanf("%d,%d,%d",&x,&y,&t)==EOF){break;}
		if(t>=1){
			field[x][y]++;
			if(x>0){field[x-1][y]++;}
			if(y>0){field[x][y-1]++;}
			if(x<9){field[x+1][y]++;}
			if(y<9){field[x][y+1]++;}
		}
		if(t>=2){
			if(x>0 && y>0){field[x-1][y-1]++;}
			if(x<9 && y>0){field[x+1][y-1]++;}
			if(x>0 && y<9){field[x-1][y+1]++;}
			if(x<9 && y<9){field[x+1][y+1]++;}
		}
		if(t>=3){
			if(x>1){field[x-2][y]++;}
			if(y>1){field[x][y-2]++;}
			if(x<8){field[x+2][y]++;}
			if(y<8){field[x][y+2]++;}
		}
	}
	for(a=0;a<10;a++){
		for(b=0;b<10;b++){
			if(field[a][b]==0){w++;}
			if(field[a][b]>d){d=field[a][b];}
		}
	}
	printf("%d\n%d\n",w,d);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    long long n,m,i,a[200000],total=0;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>a[i];
        total+=a[i];
    }  
    if(total>n)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<(n-total)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a, b; cin >> a >> b;
    cout << a - (a>b) << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int A,B,C,D;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  if(A*B>=C*D){
    printf("%d",A*B);
  }
  if(C*D>A*B){
    printf("%d",C*D);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>day(m);
  
  for(int i=0;i<m;i++){
    cin>>day.at(i);
  }
  
  int sum=0;
  
  for(int i=0;i<m;i++){
    sum=sum+day.at(i);
  }
  
  if(sum>n)cout<<"-1"<<endl;
  else cout<<n-sum<<endl;
}

Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll fc[225816]={1ll},nv[225816]={1ll},memo[225816],memo_rev[225816],dp[225816];
bool done[225816];
int nn,parent[225816],child[225816];
vector<int> g[225816];

ll rwpw(ll a, ll p = MOD-2){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll c(int n, int k, bool rev = false){
	ll ret;
	if(rev){
		ret = nv[n];
		mul_mod(ret,fc[k]);
		mul_mod(ret,fc[n-k]);
	}else{
		ret = fc[n];
		mul_mod(ret,nv[k]);
		mul_mod(ret,nv[n-k]);
	}
	return ret;
}

void dfs(int v, int p = -1){
	int i,u;
	memo[v] = 1ll;
	parent[v] = p;
	for(i=(g[v].l_ength()-1); i>=0; --i){
		u = g[v][i];
		if(u == p){
			continue;
		}
		dfs(u,v);
		mul_mod(memo[v],memo[u]);
		mul_mod(memo[v],c(child[u]+1+child[v],child[v]));
		child[v] += child[u]+1;
	}
	memo_rev[v] = rwpw(memo[v]);
}

ll solve(int v){
	if(done[v]){
		return dp[v];
	}
	done[v] = true;
	if(parent[v]<0){
		return dp[v] = memo[v];
	}
	dp[v] = solve(parent[v]);
	mul_mod(dp[v],c(nn-1,child[v]+1,true));
	mul_mod(dp[v],c(nn-1,child[v]));
	return dp[v];
}

int main(void){
	int n,i,a,b;
	cin >> n; nn = n;
	for(i=1; i<=n; ++i){
		fc[i] = fc[i-1]*i%MOD;
		nv[i] = rwpw(fc[i]);
	}
	for(i=1; i<n; ++i){
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	for(i=0; i<n; ++i){
		cout << solve(i) << endl;
	}
	return 0;
}


Measured memory_bytes: 26228
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    double res;
    double ac,as,bc,bs;
    ac = a * cos(2*M_PI*0.5*(h*60+m)/360);
    as = a * sin(2*M_PI*0.5*(h*60+m)/360);
    bc = b * cos(2*M_PI*(6*m)/360);
    bs = b * sin(2*M_PI*(6*m)/360);
    res = sqrt((ac-bc)*(ac-bc)+(as-bs)*(as-bs));
    printf("%.15lf\n",res);
}


Measured memory_bytes: 4036
#include<stdio.h>
int main(void)
{
    int a, b, s, l;
    
    scanf("%d",&a);
    scanf("%d",&b);
    
    s = a*b;
    l = 2*a+2*b;
    
    printf("%d %d\n", s,l);
    
    return 0;
}


Measured memory_bytes: 2140
#include <cstdio>
#include <iostream>
#include <map>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
#define pi pair<int,int>
map <pi,int> mp;
const int inf(1e5+5);
int h=read(),w=read(),n=read(),i,j;
int cnt[10];
ll ans;
void init(){
	while (n--){
		int x=read(),y=read();
		for (i=max(1,x-2);i<=min(h-2,x);++i)
			for (j=max(1,y-2);j<=min(w-2,y);++j)
				++mp[pi(i,j)];
	}
}

signed main(){
	init();
	for (auto p:mp) cnt[p.second]+=1,n+=1;
	ans=1ll*(h-2)*(w-2);
	printf("%lld\n",ans-n-1);
	for (int i(1);i<=9;++i) printf("%d\n",cnt[i]);
	return 0; 
}


Measured memory_bytes: 56448
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;
const long long MOD = 1000000007;

long long dat[2 * MAX_N - 1];

ll fact(ll n) {
	if (n == 1) return 1;
	if (n == 0) return 0;
	return n * fact(n - 1);
}

//C
int main(void) {
	ll n;
	cin >> n;
	vector<ll>p = vector<ll>(n);
	rep(i, 0, n) cin >> p[i];
	ll a = 1;
	vector<ll> unUsed = vector<ll>(n);
	rep(i, 0, n) unUsed[i] = i + 1;
	rep(i, 0, n) {
		rep(j, 0, unUsed.size()) {
			if (unUsed[j] == p[i]) {
				a += (j) * fact((n - 1 - i));
				unUsed.erase(unUsed.begin()+ j,unUsed.begin() + j + 1);
				break;
			}

		}
	}

	vector<ll>q = vector<ll>(n);
	rep(i, 0, n) cin >> q[i];
	ll b = 1;
	unUsed = vector<ll>(n);
	rep(i, 0, n) unUsed[i] = i + 1;
	rep(i, 0, n) {
		rep(j, 0, unUsed.size()) {
			if (unUsed[j] == q[i]) {
				b += (j)*fact((n - 1 - i));
				unUsed.erase(unUsed.begin() + j, unUsed.begin() + j + 1);
				break;
			}

		}
	}
	cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	string N;
	cin >> N;
	cou((N == "AAA" || N == "BBB" ? "No" : "Yes"));
	rep(i, 1000) {
		rep(j, 1005) {
			rep(k, 135) {
				N = "処理";
			}
		}
	}
}

Measured memory_bytes: 256
def dist(point):
    return (point[0]**2 + point[1]**2)**(1/2)


if __name__ == "__main__" :
    N,D = [int(i) for i in input().split()]
    count = 0
    for _ in range(N):
        point = [int(i) for i in input().split()]
        if dist(point) <= D:
            count += 1

    print(count)


Measured memory_bytes: 9644