akhauriyash/Code-Regression huggingface dataset:
import math
A, B, H, M = map(int, input().split())
ang1 = 30*H + M/2
ang2 = 6*M
#print(ang1, ang2)

#針のなす角度
ang = abs(ang1- ang2)/180*math.pi

# 余弦定理
out =math.sqrt(A*A + B*B - 2*A*B*math.cos(ang))
print(str(out))

Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int x=m/n,ans=1;
  while(0<x){
    if(m%x==0){
      ans=x;
      break;
    }
    x--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
long long n;
vector<int> a(100005);
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.begin() + n);
	int l = a[n - 1];
	int r = -1;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] > (l / 2)) {
			if (r < l - a[i]) {
				r = a[i];
			}
		}
		else {
			r = max(r, a[i]);
		}
	}
	cout <<  l<< " " << r<< endl;;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int ans = -1;
	for (int i = 0; i <= 1250; i++) {
		int ta = i * 8 / 100;
		int tb = i / 10;
		if (ta == a && tb == b) {
			ans = i;
			break;
		}
	}
	cout << ans << "\n";
	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=;



int main(){
	int N,M;
	cin>>N>>M;
	char V[500][500];
	rep(i,N)rep(j,M)cin>>V[i][j];
	
	char R[500][500], B[500][500];
	bool ex[500];
	rep(j,M)ex[j]=false;
	rep1(j,M-2){
		rep(i,N){
			if(V[i][j]=='#')ex[j]=true;
		}
		if(ex[j])j++;
	}
	rep(i,N)rep(j,M)R[i][j]='.';
	
	rep(i,N)rep(j,M){
		if(i==0 || i==N-1)R[i][j]='#';
		if(ex[j])R[i][j]='#';
		if(V[i][j]=='#')R[i][j]='#';
	}
	rep(i,N)rep(j,M){
		if(R[i][j]=='#' && V[i][j]=='.')B[i][j]='.';
		else B[i][j]='#';
	}
	
	rep(i,N){
		rep(j,M)cout<<R[i][j];
		cout<<endl;
	}
	cout<<endl;
	rep(i,N){
		rep(j,M)cout<<B[i][j];
		cout<<endl;
	}
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

constexpr int mod = (int)1e9 + 7;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> mp(h + 1);
    mp[0] = string('#', w + 1);
    for (int i = 1; i <= h; ++i) {
        string s;
        cin >> s;
        s = '#' + s;
        mp[i] = s;
    }
    vector<vector<int>> dp(h + 1, vector<int>(w + 1));
    dp[1][1] = 1;
    for (int y = 1; y <= h; ++y) {
        for (int x = 1; x <= w; ++x) {
            if (mp[y][x] == '#') continue;
            if (mp[y - 1][x] == '.') {
                dp[y][x] += dp[y - 1][x];
                dp[y][x] %= mod;
            }
            if (mp[y][x - 1] == '.') {
                dp[y][x] += dp[y][x - 1];
                dp[y][x] %= mod;
            }
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}


Measured memory_bytes: 5248
#include<stdio.h>
#define N 100
#define INF 1<<21
  
int B[N][N],p[N],H[N],L[N]; 
int Min(int d,int r){
  if(d<r) return d;
  else return r;  
}
  
int main(){
  int x,i,j,l;
  int a,b;
    
  scanf("%d",&x);
    
  for(i=1;i<=x;i++){
    B[i][i]=0;
  }
  for(i=1;i<=x;i++){
    scanf("%d%d",&H[i],&L[i]);
  }
  
  p[0] = H[1];
  p[1] = L[1];
  
  for(i=2;i<=x;i++){
    p[i] = L[i];
  }
    
  for(i=2;i<=x;i++){
    for(j = 1;j<=x-i+1;j++){
      a=j+i-1;
      B[j][a] = INF;
      for(l = j;l<=a-1;l++){
        b = B[j][l] + B[l+1][a] + p[j-1]*p[l]*p[a];
        B[j][a] = Min(B[j][a],b);
      }
    }
  }       
  printf("%d\n",B[1][x]); 
  return 0;
}

Measured memory_bytes: 636
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 1e5 + 1;
vi gp[N]; 
lli dp[N], n, m, a, b, mx = 0;

lli dfs(lli nd){
    if(dp[nd]!=-1) return dp[nd];
    lli res = 0;
    for(lli i:gp[nd]) remax(res, 1+dfs(i));
    return dp[nd] = res;
}

void solve(){
    cin >> n >> m;
    NA(i,0,m){
        cin >> a >> b;
        gp[a].pb(b);
    }
    memset(dp, -1, sizeof dp);
    lli ans = 0;
    NA(i,1,n+1) remax(ans, dfs(i));
    cout << ans ;
    return;
}
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;

}


Measured memory_bytes: 8576
#include<math.h>
n,t,r;
float S;
main(i){
	for(;scanf("%d",&n),n;i=-i){
		r=360;
		for(;--n;){
			scanf("%d",&t);
			r-=t;
			S+=sin(t*M_PI/180)*i;
		}
		S+=sin(r*M_PI/180)*i;
		if(i<0){
			puts(fabs(S)>1e-6?S>0?"1":"2":"0");
			S=0;
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

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

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int a[10101],b[10101];

int main(void){
	int n,s,i,j,m=0;
	cin >> n;
	s = ((n%2)?n:(n+1));
	for(i=1; i<=n; ++i){
		for(j=(i+1); j<=n; ++j){
			if(i+j==s){
				continue;
			}
			a[m] = i;
			b[m] = j;
			++m;
		}
	}
	cout << m << endl;
	for(i=0; i<m; ++i){
		cout << a[i] << " " << b[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/*
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0025
 *
 */

  
    
int main(){
  int i, j;
  int hit, blow;
  int a[4];
  int b[4];
  int x[4];
  int isa;
  isa = 1;

  while(scanf("%d %d %d %d", x, x+1, x+2, x+3) == 4){
    hit = 0;
    blow = 0;
    if(isa){
      for(i=0; i< 4;i++){
        a[i]=x[i]; 
      }
      isa = 0;
    }else{
      for(i=0; i< 4;i++){
        b[i]=x[i]; 
      }
      isa = 1;
      for(i=0; i<4;i++){
        for(j=0;j<4;j++){
          if(a[i] == b[j])
            if (i==j){
              hit+=1;
            }else{
              blow+=1;
            }
        }
      }
      printf("%d %d\n", hit, blow);
    }
  }
  return 0;
}

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

int main()
{
  string s;
  cin >> s;
  vector<char> v;
  int ans = 0;
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
    {
      v.push_back(s[i]);
    }
    else
    {
      v.clear();
    }
    ans = max(ans, (int)v.size());
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n;

int tot,go[2*maxn],nxt[2*maxn],f1[maxn];
void ins(int x,int y)
{
	go[++tot]=y;
	nxt[tot]=f1[x];
	f1[x]=tot;
}

int dis[maxn],d[maxn];
int bfs(int x)
{
	memset(dis,0,sizeof(dis));
	d[1]=x;
	dis[x]=1;
	for(int i=1, j=1; i<=j; i++)
	{
		for(int p=f1[d[i]]; p; p=nxt[p]) if (!dis[go[p]])
		{
			dis[go[p]]=dis[d[i]]+1;
			d[++j]=go[p];
		}
	}
	
	int re=0;
	fo(i,1,n) if (dis[i]>dis[re]) re=i;
	return re;
}

int main()
{
	scanf("%d",&n);
	fo(i,1,n-1)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		ins(x,y), ins(y,x);
	}
	
	int x=bfs(1), y=bfs(x), ds=dis[y]-2;
	
	puts((ds>0 && ds%3==0) ?"Second" :"First" );
}

Measured memory_bytes: 5760
#include<stdio.h>

int main()
{

    int n,p,i;
    long long
    int x[4],y[4],s1x,s2x,s1y,s2y;
    scanf("%d",&n);
    while(n--){
        for(i=0;i<4;i++)
            scanf("%lld %lld",&x[i],&y[i]);
        s2x=x[3]-x[2];
        s1x=x[1]-x[0];
        s2y=y[3]-y[2];
        s1y=y[1]-y[0];
        if(s1y*s2y + s1x*s2x==0)
            printf("1\n");
        else if(s1x*s2y - s1y*s2x==0)
            printf("2\n");

        else
            printf("0\n");




    }

    return 0;

}



Measured memory_bytes: 2124
#include<stdio.h>
int main()
{
   int n,r;
   scanf("%d",&n);
   r=n%10;
   if(r==2||r==4||r==5||r==7||r==9)
      printf("hon");
      else if(r==0||r==1||r==6||r==8)
        printf("pon");
      else
        printf("bon");
  return 0;
}

Measured memory_bytes: 1672
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

void quicksort_des(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] > x) i++;
        while (x > a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort_des(a, first , i - 1);
    if (j + 1 < last) quicksort_des(a, j + 1, last);
}

int main(){
    int n, m;
    int a[1000];

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

    quicksort_des(a, 0, n-1);
    int cnt = 0;
    for(int i = 0; i < m; ++i){
        if(a[i] * (4 * m) >= sum) cnt++;
    }

    if(cnt == m) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 1620
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{
	int x, t;
	cin >> x >> t;
	if ((x - t) < 0) {
		cout << 0 << endl;
	}
	else {
		cout << x - t << endl;
	}
	return (0);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int 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;
typedef pair<dd,dd> d_d;
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;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

// find min(ax + b)
struct CHT {
    deque<l_l> v;
    CHT() {}
    void add(ll a, ll b) {
        l_l t(a, b);
        while(v.size() > 1 && check(v[v.size()-2], v[v.size()-1], t)) v.pop_back();
        v.pb(t);
    }//aは単調減少
    ll query(ll x) {
        if(v.empty()) return 0;
        ll l = -1, r = v.size() - 1;
        while(l+1<r) {
            ll mid = (l+r)/2;
            if (f(v[mid], x) >= f(v[mid+1], x)) l = mid;
            else r = mid;
        }
        return f(v[r], x);
    }
    ll query_incr(ll x) {
        if(v.empty()) return 0;
        while(v.size() > 1 && f(v[0], x) >= f(v[1], x)) v.pop_front();
        return f(v[0], x);
    }
    bool check(const l_l &p1, const l_l &p2, const l_l &p3) {
        return (__int128)(p2.first-p1.first)*(p3.second-p2.second) >= (__int128)(p2.second-p1.second)*(p3.first-p2.first);
    }
    ll f(l_l a, ll x){
        return a.first * x + a.second;
    }
};
//////////////////////////////////

int main(){fastio
    ll n,c;cin>>n>>c;
    ll h[n];rep(i,0,n-1)cin>>h[i];
    ll dp[n];
    CHT u;
    rep(i,0,n-1){
        if(i==0)dp[i]=0;
        else{
            dp[i]=u.query(h[i])+h[i]*h[i]+c;
        }
        u.add(-2*h[i],dp[i]+h[i]*h[i]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

signed main(){
	int  c[5][5];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c[i][j];
		}
	}
	if(c[0][1]-c[0][0]!=c[1][1]-c[1][0]||c[1][1]-c[1][0]!=c[2][1]-c[2][0]){
		cout<<"No"<<endl;
	}
	else if(c[0][2]-c[0][1]!=c[1][2]-c[1][1]||c[1][2]-c[1][1]!=c[2][2]-c[2][1]){
		cout<<"No"<<endl;
	}
	else if(c[1][0]-c[0][0]!=c[1][1]-c[0][1]||c[1][1]-c[0][1]!=c[1][2]-c[0][2]){
		cout<<"No"<<endl;
	}
	else if(c[2][0]-c[1][0]!=c[2][1]-c[1][1]||c[2][1]-c[1][1]!=c[2][2]-c[1][2]){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
import java.math.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long []a = new long[n];
		long ans = 1;
		int i,k=0;
		for(i=0; i<n; i++)
		{
		    a[i] = sc.nextLong();
		    if(a[i] == 0)
		        k = 1;
		}
		if(k == 1)
		{
		    System.out.println(0);
		}
		else
		{
		    
		BigInteger b = new BigInteger("10");
		int ex = 18;
		b = b.pow(ex);
		int p = 0;
		BigInteger f = new BigInteger("1");
		for(i=0; i<n; i++)
		{
		    long x = a[i];
		    f = f.multiply(BigInteger.valueOf(x));
		    int com = f.compareTo(b);
		    if(com == 1)
		    {
		        p = 1;
		        break;
		    }
		    
		}
	    if(p == 1)
	        System.out.println("-1");
	    else
	        System.out.println(f);
		}
	}
}


Measured memory_bytes: 61124
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//input
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//solve
var n int

func printList(A []int, n int) {
	for i := 1; i <= n; i++ {
		buf := bufio.NewWriter(os.Stdout)
		buf.Write([]byte(fmt.Sprintf("node %d: ", i)))
		buf.Write([]byte(fmt.Sprintf("key = %d, ", A[i])))
		if i/2 > 0 {
			buf.Write([]byte(fmt.Sprintf("parent key = %d, ", A[i/2])))
		}
		if 2*i <= n {
			buf.Write([]byte(fmt.Sprintf("left key = %d, ", A[2*i])))
		}
		if 2*i+1 <= n {
			buf.Write([]byte(fmt.Sprintf("right key = %d, ", A[2*i+1])))
		}
		buf.Write([]byte("\n"))
		buf.Flush()
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	A := make([]int, n+1)
	for i := 1; i <= n; i++ {
		A[i] = nextInt()
	}

	printList(A, n)
}



Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n;
  cin >> n;
  int t0=0;
  int x0=0;
  int y0=0;
  for(int i=0;i<n;i++){
    int t,x,y;
    cin >> t >> x >> y;
    t=t-t0;
    x=x-x0;
    y=y-y0;
    int sum=abs(x)+abs(y);
    if(sum>t || sum%2!=t%2){
      cout << "No" << endl;
      return 0;
    }
    t0=t;
    x0=x;
    y0=y;
  }
  cout << "Yes" << endl;
}



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

using namespace std;

int
main ()
{
  int a, b;
  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;
int m,n,a;
long long sum;
int main() {
    while(cin>>n>>m)
    {
        map<int,int> di;
        sum=0;
        long long ans=0;
        di[0]=1;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            sum=(sum+a)%m;
            ans+=di[sum];
            di[sum]++;
        }
        cout<<ans<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int H,W;
	char A[100][100];
	bool Hf[100], Wf[100];
	cin >> H >> W;
	for (int j = 0;j < H;j++) {
		for (int i = 0;i < W;i++) {
			char c;
			cin >> A[j][i];
		}
	}

	for (int j = 0;j < H;j++) {
		bool flag = true;
		for (int i = 0;i < W;i++) {
			if (A[j][i] == '#')
				flag = false;
		}
		Wf[j] = flag;
	}
	for (int j = 0;j < W;j++) {
		bool flag = true;
		for (int i = 0;i < H;i++) {
			if (A[i][j] == '#')
				flag = false;
		}
		Hf[j] = flag;
	}

	for (int j = 0;j < H;j++) {
		if (Wf[j] == false) {
			for (int i = 0;i < W;i++) {
				if (Hf[i] == false)
					cout << A[j][i];
			}
			cout << endl;
		}
	}
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define base 2010
#define N 200010
ll fac[N],inv[N],ivf[N];
ll C(ll n,ll k){
    if(n<k)return 0;
    return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll H(ll n,ll k){
    //if(k==0)return 1;
    return C(n+k-1,k);
}
ll P(ll n,ll k){
    return fac[n]*ivf[n-k]%mod;
}

ll f[2*base][2*base];
ll n,a[N],b[N];
int main(){
    fac[0]=ivf[0]=inv[1]=1;
    for(int i=1;i<N;i++){
	if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
	fac[i]=fac[i-1]*i%mod;
	ivf[i]=ivf[i-1]*inv[i]%mod;
    }
  for(int i=0;i<2*base;i++)for(int j=0;j<2*base;j++){
      f[i][j]=0;
  }
  cin>>n;
  for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
      f[base-a[i]][base-b[i]]++;
  }
  for(int i=1;i<2*base;i++)for(int j=1;j<2*base;j++){
      mad(f[i][j],f[i-1][j]);
      mad(f[i][j],f[i][j-1]);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
      mad(ans,f[base+a[i]][base+b[i]]);
      mad(ans,-C(a[i]*2+b[i]*2,a[i]*2));
  }
  ans=ans*500000004%mod;
  if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 134272
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define test_ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> in <<<<<<<<<<<<<<<<<<<<\n")
#define deb(x) cerr << ">>>>>>>>>>>>>>>>>>>> " << #x << " = " << x << " <<<<<<<<<<<<<<<<<<<<\n"
#define debd(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %d <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define debs(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %s <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define debll(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %lld <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define deblf(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %lf <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define fr(i, a, b) for(int i = a ; i < (int)b ; i++)
#define frr(i, a, b) for(int i = a ; i >= (int)b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ln puts("")
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
//bitmask
int on_bit(int x, int pos) {x |= (1 << pos); return x;}
int off_bit(int x, int pos) {x &= ~(1 << pos); return x;}
bool is_on_bit(int x, int pos) {return ((x & (1 << pos)) != 0);}
int flip_bit(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int on_bit_all(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

int main() {
//  freopen("C:\\Users\\user\\Desktop\\cp\\input.in", "r", stdin);
  int a, b;
  sf("%d %d", &a, &b);
  bool ok1 = (a*b) & 1;
  bool ok2 = (a*b*2) & 1;
  bool ok3 = (a*b*3) & 1;
  puts(ok1 || ok2 || ok3 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<ll,ll> Pi;
typedef map<string,int> si;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}


int atcoder() {
    string s,t;
    map<char,char> mp,mpz;
    cin >> s >> t;
    bool ans=true;
    
    REP(i,0,s.size()){
        char tmp=s[i];
        if(mp[tmp]==0){
            mp[tmp] = t[i];
        }else{
            if(mp[tmp]!=t[i]) ans=false;
        }
    }
    REP(i,0,t.size()){
        char tmp=t[i];
        if(mpz[tmp]==0){
            mpz[tmp] = s[i];
        }else{
            if(mpz[tmp]!=s[i]) ans=false;
        }
    }
    
    YesNo(ans);
    
    return 0;
}

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


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

#define rep(i,x) for(int i=0;i<(int)(x);++i)

using Int = long long;
const int mo = 1e9+7;

Int N;
int a[200010];

signed main()
{
    cin >> N;
    rep(i, N) cin >> a[i];

    int cnt = 0;
    int cur = 1;

    rep(i, N) {
        if (a[i] == cur) {
            cnt++;
            cur++;
        }
    }

    if (cnt == 0) cout << -1 << endl;
    else cout << N - cnt << endl;

    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b == c || a + c == b || b + c == a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	long double a,b;
	cin>>a>>b;
	a *= b;
	cout<<(ll)a<<endl;
	return 0;
}

Measured memory_bytes: 3808
package main
 
import (
	"fmt"
)
 
var n, a int
var m map[int]int
func main() {
	fmt.Scan(&n)
	m = make(map[int]int, n)
	for i := 0; i < n - 1; i++ {
		fmt.Scan(&a)
		m[a]++
	}
	for i := 0; i < n; i++ {
	  fmt.Println(m[i + 1])
	}
}



Measured memory_bytes: 12296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            var set = new HashSet<long>();
            long N = cin.nextLong();

            for (int i = 0; i < N; i++)
            {
                long A = cin.nextLong();
                if (set.Contains(A))
                {
                    Console.WriteLine("NO");
                    return;
                }
                else
                {
                    set.Add(A);
                }
            }

            Console.WriteLine("YES");
        }

    }
}


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

int main(){
  int a, b; string s; cin >> a >> b >> s;
  for(int i=0; i<a; i++) {
    if(isdigit(s[i])) continue;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  if(s[a]!='-') {
    cout << "No" << endl; return 0;
  } else {
    for(int i=a+1; i<a+b+1; i++) {
      if(isdigit(s[i])) continue;
      else {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
	return 0;
  }
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int cnt = 1;
    while (cnt < b) {
        cnt += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

const int _ = 103;
int dp[_][_][_][2] , C[_][_] , coef[_][_][_][2] , N , M , K , D;

int poww(long long a , int b){
	int times = 1;
	while(b){if(b & 1) times = times * a % D; a = a * a % D; b >>= 1;}
	return times;
}

int main(){
	cin >> N >> M >> K >> D;
	for(int i = 0 ; i <= max(N , M) ; ++i){
		C[i][0] = 1;
		for(int j = 1 ; j <= i ; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % D;
	}

	for(int k = 0 ; k < K ; ++k)
		for(int i = 0 ; i <= M ; ++i)
			for(int j = 0 ; j <= N ; ++j){
				coef[k][i][j][0] = 1ll * poww(K - k , i) * (poww(k + 1 , M - i) - poww(k , M - i) + D) % D;
				coef[k][i][j][1] = 1ll * (poww(K - k , j) - poww(K - k - 1 , j) + D) * poww(k + 1 , N - j) % D;
			}
					
	dp[0][0][0][0] = 1;
	for(int k = 0 ; k < K ; ++k){
		for(int p = 0 ; p <= M ; ++p)
			for(int q = 0 ; q <= N ; ++q)
				if(dp[k][p][q][0])
					for(int tms = 1 , m = 0 ; m + q <= N ; ++m , tms = 1ll * tms * coef[k][p][q][0] % D)
						dp[k][p][q + m][1] = (dp[k][p][q + m][1] + 1ll * dp[k][p][q][0] * tms % D * C[N - q][m]) % D;
		for(int p = 0 ; p <= M ; ++p)
			for(int q = 0 ; q <= N ; ++q)
				if(dp[k][p][q][1])
					for(int tms = 1 , m = 0 ; m + p <= M ; ++m , tms = 1ll * tms * coef[k][p][q][1] % D)
						dp[k + 1][p + m][q][0] = (dp[k + 1][p + m][q][0] + 1ll * dp[k][p][q][1] * tms % D * C[M - p][m]) % D;
	}
	
	cout << dp[K][M][N][0];
	return 0;
}


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

int main() {
  int K, N, x = 0;
  
  cin >> K >> N;
  
  vector<int> vec(N);
    for(int i = 0 ; i < N ; i++) {
    	cin >> vec.at(i) ;
    }
  //受け取り終わり
  
  int max = 0 ;//最大間隔と始点終点
  
  for(int i = 0 ; i < N - 1 ; i++) {
    if(vec.at(i + 1) - vec.at(i) > max) {
      max = vec.at(i+1) - vec.at(i);
    }
  }
  if(vec.at(0) - (vec.at(N - 1) - K) > max) {
    max = vec.at(0) - (vec.at(N - 1) - K);
  }
  
  
  cout << K - max << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int i,ans=0;
  char s[5],t[5];
  for (i=1;i<=3;i++){
    cin >> s[i];
  }
  for (i=1;i<=3;i++){
    cin >> t[i];
  }
  for (i=1;i<=3;i++){
    if (s[i]==t[i]) ans++;
  }
  cout << ans << endl;
}

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

class Box {
public:
  int x, y, h, w;
  int cost() {
    int sum = x + y + h;
    if(sum <= 60 && w <= 2) return 600;
    if(sum <= 80 && w <= 5) return 800;
    if(sum <= 100 && w <= 10) return 1000;
    if(sum <= 120 && w <= 15) return 1200;
    if(sum <= 140 && w <= 20) return 1400;
    if(sum <= 160 && w <= 25) return 1600;
    return 0;
  }
};

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    Box b[n];
    int sum = 0;
    for(int i = 0; i < n; i++) {
      cin >> b[i].x >> b[i].y >> b[i].h >> b[i].w;
      sum += b[i].cost();
    }
    cout << sum << endl;
  }
  return 0;
}

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

int main()
{
    long long a,b,k,c,d;
    scanf("%lld %lld %lld",&a,&b,&k);

    if(a>k)
    {
        c=a-k;
        printf("%lld %lld",c,b);
    }
    else if(a<k)
    {
        c=k-a;
        if(c>b)
        {
            printf("0 0");
        }
        else{
        printf("0 %lld",b-c);}
    }
    else  if(a==k)
    {
        printf("0 %lld",b);
    }
    else if(a==0 && b==0)
    {
        printf("0 0");
    }

    printf("\n");
    return 0;
}


Measured memory_bytes: 1700
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n;
int num[4];
double dp[305][305][305];
void dfs(int b,int c,int d)
{
	if(b+c+d==0) return;
	dp[b][c][d]=(double)n/(b+c+d);
	if(b)
	{
		if(dp[b-1][c][d]==0) dfs(b-1,c,d);
		dp[b][c][d]+=dp[b-1][c][d]*b/(b+c+d);
	}
	if(c)
	{
		if(dp[b+1][c-1][d]==0) dfs(b+1,c-1,d);
		dp[b][c][d]+=dp[b+1][c-1][d]*c/(b+c+d);
	}
	if(d)
	{
		if(dp[b][c+1][d-1]==0) dfs(b,c+1,d-1);
		dp[b][c][d]+=dp[b][c+1][d-1]*d/(b+c+d);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int t;
		scanf("%d",&t);
		num[t]++;
	}
	dfs(num[1],num[2],num[3]);
	printf("%.10lf",dp[num[1]][num[2]][num[3]]);
	return 0;
}



Measured memory_bytes: 219392
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, M;

ll count(vector<ll> &A) {
    ll lx = 0, lt;
    ll n = A.size();
    for(ll i=1; i<=n; i++) {
        lt = A[i]-A[i-1];
        lt = lt*(n-i)%MOD;
        lt = lt*i%MOD;
        lx = (lx+lt)%MOD;
    }
    return lx;
}

int main() {
    cin >> N >> M;
    vector<ll> X(N), Y(M);
    REP(i, N) cin >> X[i];
    REP(i, M) cin >> Y[i];
    ll ans = count(X)*count(Y)%MOD;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int list[110];
  cin>>n;
  for(int i=0;i<n;i++)cin>>list[i];
  
  int num[110] = {0};
  for(int i=0;i<n;i++){
    num[list[i]]++;
  }
  
  int ans=0;
  for(int i=1;i<110;i++){
    if(num[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main(){

  int i, N, ans=0; cin>>N;
  int a[N];
  for(i=0; i<N; i++) cin>>a[i];
  for(i=0; i<N; i++) ans=ans^a[i];
  
  for(i=0; i<N; i++){
    cout<<(ans^a[i])<<" ";
  }
  cout<<endl;
  return 0;
}


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

int main(){
	int K, S, sum = 0;  cin >> K >> S;
	for(int i = 0; i <= K; i++){
		for(int j = 0; j <= K; j++){
			if((S - (i + j) >= 0) && ((S - (i + j) <= K))){
				sum++;
			}
		}
	}
	cout << sum;
}


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int n,g;
bool a[200001],b[200001],f[200001];
void init(int n){
	int t=sqrt(n);
	for(int i=2;i<=t;i++){
		if(n%i==0){
			f[i]=!f[i];
			f[n/i]=!f[n/i];
		}
	}
	if(t*t==n&&t!=1){
		f[t]=!f[t];
	}
	f[1]=!f[1];
	return;
}
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	for(int i=n;i>=1;i--){
		if(a[i]!=f[i]){
			b[i]=1;
			init(i);
			g++;
		}
	}
	cout<<g<<endl;
	rep(i,n){
		if(b[i]){
			cout<<i<<' ';
		}
	}
	return 0;
}

Measured memory_bytes: 1536
n, k = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * n
a[0] = 0
for i in range(1, n):
      hi = h[i]
      a[i] = min(a[j] + abs(hi - h[j]) for j in range(max(0, i - k), i))
print(a[-1])

Measured memory_bytes: 53600
#include<bits/stdc++.h> //ABC 163_c
#define ll long long
using namespace std;
int n,t,v[200005];
int main(){
	cin>>n;
	for (int i=2;i<=n;i++){
		cin>>t;
		v[t]++;
	}
	for(int i=1;i<=n;i++)
		cout<<v[i]<<endl;
	return 0;
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
int n,m,k,ans;
int c[40],num[10][10],b[10][10];
string s[10];
int main()
{
cin>>n>>m>>k;
for(int i=1;i<=n;i++)cin>>s[i];
for(int i=1;i<=n;i++)
	for(int j=0;j<m;j++)
	if(s[i][j]=='.')num[i][j+1]=0; else num[i][j+1]=1;
ans=0;
int maxi=1;
for(int i=1;i<=n+m;i++) maxi=maxi*2;
for(int l=0;l<maxi;l++)
	{
	int opt=l,top=0;
	memset(c,0,sizeof(c));
	while(opt>0)
		{
		c[++top]=opt&1;
		opt>>=1;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)b[i][j]=num[i][j];
	for(int i=1;i<=top;i++)
		if(i<=n){
			if(c[i]==1)
			for(int j=1;j<=m;j++)b[i][j]=2;
		}
		else if(c[i]==1)
			for(int j=1;j<=n;j++)b[j][i-n]=2;
	int tot=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(b[i][j]==1)tot++;
	if(tot==k)ans++;
	}
cout<<ans;
return 0;
}

Measured memory_bytes: 3544
def main():
    a,b,c,d = map(int, input().split())
    if abs(a-c)<=d:
        return "Yes"
    elif abs(a-b)<=d and abs(b-c)<=d:
        return "Yes"
    else:
        return "No"

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}





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


  ll N , K; cin >> N >> K;
  bool check[10] ;
  rep(i,10) check[i] = true;
  rep(i,K){
    ll inp; cin >> inp;
    check[inp] = false;
  }
  ll ans = N;

  while(1){
    ll num = ans ; 
    bool flag = true;
    
    while(num >0){
      if(!check[num%10]){ flag = false; break;}
      num/=10;
    }

    if(flag){ cout << ans << endl; return 0;}
    ans ++;
  }
  
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  long long sum = 0;
  for (int i=1; i<=N; i++){
    if (i%3 == 0);
    else if (i%5 == 0);
    else sum += i;
  }
  cout << sum << endl;
  return 0;
}

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

# define F first    
# define S second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r"))
    freopen (in, "r", stdin);
  else
    cerr << "Warning: Input file not found" << endl;
}
string s;

int n;

int cnt[Sz];
         
   
int main()
{
  # ifdef Local
    localInput();
  # endif
  Read_rap();
  cin >> s;
  for (char c : s)
    cnt[(int)c]++;
                         
  if ((cnt['N'] > 0) ^ (cnt['S'] > 0) || (cnt['W'] > 0) ^ (cnt['E'] > 0)) {
    cout << "No";
  }
  else
    cout << "Yes";  
 
  return 0;
}






// Coded by Z..


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;
const int INF = 1000000;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

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

    vector<int> dp(100001, INF);
    for (int i=0; i<=N; ++i) {
        dp[i] = i;
    }
    for (int i=6; i<=N; i*=6) {
        for (int j=0; j+i<=N; ++j) {
            dp[j+i] = min(dp[j+i], dp[j]+1);
        }
    }
    for (int i=9; i<=N; i*=9) {
        for (int j=0; j+i<=N; ++j) {
            dp[j+i] = min(dp[j+i], dp[j]+1);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int ans=0;
	int v[n],c[n];
	for(int i=0;i<n;i++) cin >> v[i];
	for(int i=0;i<n;i++) cin >> c[i];
	for(int i=0;i<n;i++){
		if(v[i]>c[i]) ans+=v[i]-c[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

H,W,D = map(int,input().split())

x = np.arange(H); y = np.arange(W)
plus = x[:,None] + y[None,:]
minus = x[:,None] - y[None,:]
plus //= D; plus %= 2
minus //= D; minus %= 2

x = plus + 2*minus
grid = np.zeros((H,W),dtype='U1')
grid[x==0] = 'R'
grid[x==1] = 'B'
grid[x==2] = 'G'
grid[x==3] = 'Y'

print('\n'.join(''.join(x for x in row) for row in grid))

Measured memory_bytes: 20324
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0;
  cin>>n;
  char a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(int i=0;i<n;i++)
  {
    if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
    count++;
    else continue;
  }
  cout<<count;
}

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

struct UnionFind {
  vector<int> par;
  vector<int> size;

  UnionFind(int N) {
    for (int i=0; i<N; i++) {
      par.push_back(i);
      size.push_back(1);
    }
  }

  int getSize(int x) {
    int rx = root(x);
    return size[rx];
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
    size[ry] += size[rx];
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  long long N, M;
  cin >> N >> M;
  int edges[M][2];
  UnionFind tree(N);
  for (int i=0; i<M; i++) {
    int u, v;
    cin >> u >> v;
    edges[i][0] = u-1;
    edges[i][1] = v-1;
  }

  long long ans[M];
  ans[M-1] = N * (N-1) / 2;
  for (int i=M-1; i>0; i--) {
    int u = edges[i][0];
    int v = edges[i][1];
    if (!tree.same(u, v)) {
      ans[i-1] = ans[i] - tree.getSize(u) * tree.getSize(v);
      tree.unite(u, v);
    } else {
      ans[i-1] = ans[i];
    }
  }
  for (int i=0; i<M; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, k, n) for(int i = (int)(k);i < (int)(n);i++)
int K, a = 1, b = 1;
vector<map<int, int>> dp(11);
void c() {
  while(K > dp[a][b]) {
    K -= dp[a][b];
    b++;
  }
  cout << b;
  if(0 < b) b--;
  a--;
}
int main() {
  cin >> K;
  vector<int> S(11);
  rep(i, 0, 10) dp[1][i] = 1;
  S[1] = 9;
  rep(i, 2, 11) rep(j, 0, 10) rep(k, -1, 2) {
    dp[i][j] += dp[i-1][j+k];
    if(j > 0) S[i] += dp[i-1][j+k];
  }
  while(K > S[a]) {
    K -= S[a];
    a++;
  }
  while(a > 0) c();
  cout << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <climits>

using namespace std;

int *A;
int N;

void CountingSort(int k)
{
  int *C = new int[10000 + 1];
  int *B = new int[N];

  for(int i = 0; i <=k; ++i)
    C[i] = 0;
  for(int i = 0; i < N; ++i)
    C[A[i]]++;

  for(int i = 0; i <= k; ++i)
    C[i] = C[i] + C[i - 1];

  for(int i = N - 1; i >= 0; --i)
  {
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }

  for(int i = 0; i < N; ++i)
    A[i] = B[i];

  delete [] B;
  delete [] C;
}

int main()
{
  cin >> N;

  A = new int[N];
 
  for(int i = 0; i < N; ++i)
    cin >> A[i];

  int k = 0;
  for(int i = 0; i < N; ++i)
    k = k < A[i] ? A[i] : k;

  CountingSort(k);

  cout << A[0];
  for(int i = 1; i < N; ++i)
    cout << " " << A[i];
  cout << endl;
 
  delete [] A;


}


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

"""
・座標圧縮
・2次元累積和
"""

N, K = map(int, input().split())

X, Y = [0]*N, [0]*N
for i in range(N):
    X[i], Y[i] = map(int, input().split())

# 座標圧縮
zip_x, zip_y, unzip_x, unzip_y = {}, {}, {}, {}
X2 = sorted(set(X))
Y2 = sorted(set(Y))
# この後の処理のために添字は1-indexedにする
for i in range(len(X2)):
    zip_x[X2[i]] = i+1
    unzip_x[i+1] = X2[i]
for i in range(len(Y2)):
    zip_y[Y2[i]] = i+1
    unzip_y[i+1] = Y2[i]

# 圧縮した座標に点を割り当て(グリッドは累積和用に一回り大きく作る)
grid = [[0] * (len(X2)+1) for _ in range(len(Y2)+1)]
for i in range(N):
    grid[zip_y[Y[i]]][zip_x[X[i]]] += 1

# 2次元累積和
for i in range(len(Y2)+1):
    for j in range(1, len(X2)+1):
        grid[i][j] += grid[i][j-1]
for i in range(1, len(Y2)+1):
    for j in range(len(X2)+1):
        grid[i][j] += grid[i-1][j]

ans = float('inf')
for i in range(1, len(Y2)+1):
    for j in range(1, len(X2)+1):
        # 終点がK以上あれば始点を動かし始める
        if grid[i][j] >= K:
            for k in range(i):
                for l in range(j):
                    # 部分累積和を出して、点がK以上あるか確認
                    if grid[i][j] - grid[i][l] - grid[k][j] + grid[k][l] >= K:
                        # 長方形の面積を出して最小を保持
                        ans = min((unzip_x[j]-unzip_x[l+1]) * (unzip_y[i]-unzip_y[k+1]), ans)
print(ans)


Measured memory_bytes: 3188