akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,a[100],m=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		m+=a[i]; 
	}
	for(int i=0;i<n;i++){
		if(a[i]*2>=m){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t;cin >> n >> t;
  int a[n];
  int ans = 0;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n-1;i++){
    int sa = a[i+1]-a[i];
    if(sa<=t) ans+=sa;
    else{
      ans+=t;
    }

  }
  ans+=t;
  cout << ans << endl;
}


Measured memory_bytes: 1024
package main
 
import (
	"fmt"
	"sort"
)
 
type ivec []int
 
func (v ivec) Len() int           { return len(v) }
func (v ivec) Less(i, j int) bool { return v[i] > v[j] }
func (v ivec) Swap(i, j int)      { v[i], v[j] = v[j], v[i] }
 
func main() {
	var n int
	fmt.Scan(&n)
	a := make(ivec, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
 
	sort.Sort(a)
 
	alice := 0
	bob := 0
	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			alice += a[i]
		} else {
			bob += a[i]
		}
	}
 
	fmt.Println(alice - bob)
 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long
#define pii pair<int,int>
#define x first
#define y second

const int N=2e5+5;
int n,d,k;
long long tr[N],ans;
pii a[N];

#define lowbit(x) (x&(-x))

void up(int x,int v){
	while(x<=n){
		tr[x]+=v;
		x+=lowbit(x);
	}
}

long long que(int x){
	int res=0;
	while(x){
		res+=tr[x];
		x-=lowbit(x);
	}
	return res;
}

signed main(){
	read(n);read(d);read(k);d<<=1;
	for(int i=1;i<=n;i++) read(a[i].x),read(a[i].y);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		long long path=que(i);
		if(1ll*path*k>=a[i].y) continue;
		int ned=(a[i].y-path*k-1)/k+1;
		ans+=ned;
		int l=i,r=n,lim=i;
		while(l<=r){
			int mid=l+r>>1;
			if(a[i].x+d>=a[mid].x) l=mid+1,lim=mid;
			else r=mid-1;
		}
//		printf("%d %d %d %d\n",i,lim,ned,path);
		up(i,ned);up(lim+1,-ned);
	}
	write(ans);
}


Measured memory_bytes: 4992
num=0
flag=0
seisu=""
while(1):
    try:str=input("")
    except: break
    for moji in str:
        if moji.isdigit():
            seisu=seisu+moji
            flag=1
        elif flag==1:
            flag=0
            num=int(seisu)+num
            seisu=""
print(num)



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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<int>>c(10,vector<int>(10));
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++) cin>>c[i][j];
  }
  vector<vector<int>>a(h,vector<int>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cin>>a[i][j];
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        if(c[j][k]>c[j][i]+c[i][k]) c[j][k]=c[j][i]+c[i][k];
      }
    }
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) {
      if(a[i][j]!=-1) ans+=c[a[i][j]][1];
    }
  }
  cout<<ans<<endl;
}   


Measured memory_bytes: 384
import collections
import numpy as np
N, K =map(int,input().split())
a=list(map(int,input().split()))
c = collections.Counter(a)
c_=c.most_common()
c__=np.array(c_)
ans=0
for i in range (K,c__.shape[0]):
    ans+=c__[i][1]
print(ans)

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

int main() {
    int n;
    cin >> n;
    
    vector<int> p(n);
    for(int i  = 0; i < n; i++) cin >> p.at(i);
    
    int ans = 0;
    int max_p = 0;
    int min_p = 0;
    
    for(int i  = 1; i < n - 1; i++) {
        max_p = max(p.at(i-1), max(p.at(i), p.at(i+1)));
        min_p = min(p.at(i-1), min(p.at(i), p.at(i+1)));
        if((max_p != p.at(i)) && (min_p != p.at(i))) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
int N;
int A[100001];
const int MOD=1000000007;
int main(){
    std::cin>>N;
    for(int i=0;i<N;++i){
        std::cin>>A[i];
    }
    std::sort(A,A+N);
    if(N%2==0){
        bool f=true;
        int ans=1;
        for(int i=0;i<N;i+=2){
            if(A[i] != A[i+1]){
                f=false;
                break;
            }
            ans*=2;
            ans%=MOD;
        }
        if(f)std::cout<<ans<<std::endl;
        else std::cout<<0<<std::endl;
    }else{
        bool f=true;
        int ans=1;
        for(int i=1;i<N;i+=2){
            if(A[i] != A[i+1]){
                f=false;
                break;
            }
            ans*=2;
            ans%=MOD;
        }
        if(f)std::cout<<ans<<std::endl;
        else std::cout<<0<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define mem(a, x) memset(a, x, sizeof a)
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/*
	----------------------------------------------------------------------
	Things to remember : check for coners n = 1, pass references instead
*/
/* -------------------------------Solution Sarted--------------------------------------*/

//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5
const int INF = 100000000000005; // 1e15 +5

bool cmp(pii &p1, pii &p2){
	if(p1.first == p2.first)
		return p1.second < p2.second;
	return p1.first < p2.second;
}

void solve(){
	int n;
	cin >> n;
	vii a(n);
	for(int i = 0; i < n; ++i)
		cin >> a[i].first >> a[i].second;
	sort(all(a));
	vi one, two;
	for(int i = 0; i < n; ++i)
		one.push_back(a[i].first + a[i].second);
	for(int i = 0; i < n; ++i)
		two.push_back(a[i].first - a[i].second);

	sort(all(one));
	sort(all(two));

	cout << max(one[n -1] - one[0], two[n -1] - two[0]);

}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/


Measured memory_bytes: 11048
s = gets.chomp
t = gets.chomp

array = []
(s.length - t.length + 1).times do |i|
#   puts "#{s[i..t.length - 1 + i]} #{t}"
  cnt = 0
  t.length.times do |j|
    # puts "#{s[i..t.length - 1 + i][j]} #{t[j]}"
    if s[i..t.length - 1 + i][j] != t[j]
      cnt += 1
    end
  end
  array << cnt
end

puts array.min

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

int main()
{
    int n;
    cin >> n;
    vector<bool> S(13),H(13),C(13),D(13);
    char Egara;
    int num;
    for (int i = 0; i<n; i++){
        cin >> Egara >> num;
        if (Egara == 'S'){
            S[num-1] = true;
        }else if (Egara == 'H')
        {
            H[num-1] = true;
        }else if (Egara == 'C')
        {
            C[num-1] = true;
        }
        else
        {
            D[num-1] = true;
        }
    }
    for (int i = 0; i<13; i++){
        if (S[i]==false){
            cout << "S "<< i+1 <<endl;
        }
    }
    for (int i = 0; i<13; i++){
        if (H[i]==false){
            cout << "H "<< i+1 <<endl;
        }
    }
    for (int i = 0; i<13; i++){
        if (C[i]==false){
            cout << "C "<< i+1 <<endl;
        }
    }
    for (int i = 0; i<13; i++){
        if (D[i]==false){
            cout << "D "<< i+1 <<endl;
        }
    }

}


Measured memory_bytes: 3104
#include <cstdio>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;

int h,w,n;
int ww,hh;
vector< pair< pair<int,int>,pair<int,int> > > tp;
map<int,int> xx;
map<int,int> yy;

bool** d;

bool** newd(int w,int h){
	bool** r = new bool*[w];
	for(int i=0;i<w;i++){
		r[i] = new bool[h];
	}
	return r;
}

void deld(bool** r,int w,int h){
	for(int i=0;i<w;i++){
		delete[] r[i];
	}
	delete[] r;
}

void paint(int x,int y,int w,int h,bool c){
	//printf("paint:(%d,%d),%dx%d\n",x,y,w,h);
	for(int i=0;i<w;i++){
		for(int j=0;j<h;j++){
			//printf("%d+%d,%d+%d\n",x,i,y,j);
			d[x + i][y + j] = c;
		}
	}
}
void paint(pair< pair<int,int>,pair<int,int> > p,bool c){
	int x,y,w,h;
	x = xx[p.first.first];
	y = yy[p.first.second];
	w = xx[p.second.first] - x;
	h = yy[p.second.second] - y;
	paint(x,y,w,h,c);
}

void solve(int x,int y){
	queue< pair<int,int> > que;
	que.push( pair<int,int>(x,y) );
	pair<int,int> v[4] = {
		pair<int,int>(1,0),
		pair<int,int>(-1,0),
		pair<int,int>(0,1),
		pair<int,int>(0,-1)
	};
	pair<int,int> p,pp;
	while(que.size()>0){
		p = que.front();
		//printf("%d,%d\n",p.first,p.second);
		que.pop();
		for(int i=0;i<4;i++){
			pp.first = p.first + v[i].first;
			pp.second = p.second + v[i].second;
			if(pp.first < 0 || pp.first >= w || pp.second < 0 || pp.second >= h){continue;}
			if(d[pp.first][pp.second] == false){
				d[pp.first][pp.second] = true;
				que.push(pp);
			}
		}
	}
}

void dep(){
	for(int j=0;j<h;j++){
		for(int i=0;i<w;i++){
			if(d[i][j] == false){
				printf(".");
			}else{
				printf("#");
			}
		}
		printf("\n");
	}
	printf("\n");
}

int main(){
	int a,b,c,dd;
	while(scanf("%d %d",&ww,&hh) && (ww || hh)){
		tp.clear();
		scanf("%d",&n);
		vector<int> vx;
		vector<int> vy;
		for(int i=0;i<n;i++){
			scanf("%d %d %d %d",&a,&b,&c,&dd);
			tp.push_back(
				pair< pair<int,int>,pair<int,int> >(
					pair<int,int>(a,b),
					pair<int,int>(c,dd)
				)
			);
			vx.push_back(a);
			vx.push_back(c);
			vy.push_back(b);
			vy.push_back(dd);
		}
		vx.push_back(0);
		vy.push_back(0);
		vx.push_back(ww);
		vy.push_back(hh);
		sort(vx.begin(),vx.end());
		sort(vy.begin(),vy.end());
		vx.erase(unique(vx.begin(),vx.end()),vx.end());
		vy.erase(unique(vy.begin(),vy.end()),vy.end());
		xx.clear();
		yy.clear();
		for(int i=0;i<vx.size();i++){
			//printf("x %d:%d\n",vx[i],i);
			xx[vx[i]] = i;
		}
		for(int i=0;i<vy.size();i++){
			//printf("y %d:%d\n",vy[i],i);
			yy[vy[i]] = i;
		}
		w = xx[ww];
		h = yy[hh];
		
		d = newd(w,h);
		//printf("%dx%d\n",w,h);
		paint(0,0,w,h,false);
		
		for(int i=0;i<n;i++){
			paint(tp[i],true);
		}
		//puts("A");
		int ans = 0;
		//dep();
		for(int j=0;j<h;j++){
			for(int i=0;i<w;i++){
				if(d[i][j] == false){
					solve(i,j);
					ans++;
					//dep();
				}
			}
		}
		printf("%d\n",ans);
		deld(d,w,h);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main() {
    lli n,a,b,c,sum=0;
    vector<lli> up,mid,down;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        up.push_back(a);
    }
    rep(i,0,n){
        cin>>b;
        mid.push_back(b);
    }
    rep(i,0,n){
        cin>>c;
        down.push_back(c);
    }
    sort(up.begin(),up.end());
    sort(down.begin(),down.end());
    rep(i,0,n){
        lli low,upp;
        low=lower_bound(up.begin(),up.end(),mid[i])-up.begin();
        upp=down.end()-upper_bound(down.begin(),down.end(),mid[i]);
        sum+=low*upp;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3440
#include<iostream>
#include<string> 
using namespace std;
int a[26];
int main()
{
	string s;
	char x;
	int n;
	cin>>s;
	n=s.size();
	for(int i=0;i<n;i++){
		x=s[i];
		for(int j=0;j<26;j++){
			if(x=='a'+j) a[j]+=1;
		}
	}
	x=' ';
	for(int i=0;i<26;i++){
		if(a[i]==0) {x='a'+i;break;}}
	if(x==' ')cout<<"None";else cout<<x;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
int h,w,d[1010][1010];
char mp[1010][1010];
queue<pair<int,pair<int,int>>> que0,que1;
void bfs(int s,int t){
    que0.push({0,{s,t}});
    while(que0.size() || que1.size()){
        while(que0.size()){
            auto p = que0.front();
            que0.pop();
            int x = p.second.first,y = p.second.second,dist = p.first;
            if(d[x][y]!=-1) continue;
            d[x][y] = dist;
            for(int i=0;i<4;i++){
                int nx = x + dx[i],ny = y + dy[i];
                if(nx<0 || nx>=h || ny<0 || ny>=w || mp[nx][ny]!='.') continue;
                que0.push({dist,{nx,ny}});
            }
            for(int i=x - 2;i<=x + 2;i++){
                for(int j=y - 2;j<=y + 2;j++){
                    if(i<0 || i>=h || j<0 || j>=w || mp[i][j]!='.') continue;
                    que1.push({dist + 1,{i,j}});
                }
            }
        }
        if(que1.size()){
            auto p = que1.front();
            que1.pop();
            int dist = p.first,x = p.second.first,y = p.second.second;
            if(d[x][y]!=-1) continue;
            d[x][y] = dist;
            for(int i=0;i<4;i++){
                int nx = x + dx[i],ny = y + dy[i];
                if(nx<0 || nx>=h || ny<0 || ny>=w || mp[nx][ny]!='.') continue;
                que0.push({dist,{nx,ny}});
            }
            for(int i=x - 2;i<=x + 2;i++){
                for(int j=y - 2;j<=y + 2;j++){
                    if(i<0 || i>=h || j<0 || j>=w || mp[i][j]!='.') continue;
                    que1.push({dist + 1,{i,j}});
                }
            }
        }
    }
}

int main(){
    int i,j,cx,cy,gx,gy; cin >> h >> w >> cx >> cy >> gx >> gy; cx--; cy--; gx--; gy--;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++) cin >> mp[i][j];
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++) d[i][j] = -1;
    }
    bfs(cx,cy);
    cout << d[gx][gy] << endl;
}

Measured memory_bytes: 9960
def gcd(x,y):
    if x % y == 0:
        return y
    else:
        x %= y
        return gcd(y, x)

N = int(input())
blackboard = list(map(int,input().split()))

l_gcd = [-1] * N
r_gcd = [-1] * N

for i in range(N):
    if i == 0:
        l_gcd [0] = blackboard[0]
    else:
        l_gcd[i] = gcd(l_gcd[i-1],blackboard[i])


for i in reversed(range(N)):
    if i == N - 1:
        r_gcd[N-1] = blackboard[N-1]
    else:
        r_gcd[i] = gcd(r_gcd[i+1],blackboard[i])


#左端と右端のときの値を予め比較しておく。
ans = max(l_gcd[-2],r_gcd[1])

for i in range(1,N-1):
    ans = max(ans,gcd(l_gcd[i-1],r_gcd[i+1]))
print(ans)

Measured memory_bytes: 14588
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        for(int n=1; n<=N; n++){
            if(Integer.toString(n).length()%2==1) ans++;
        }
        System.out.println(ans);
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, m, c, a, b[100];

int main(int argc, char **argv) {
	cin >> n >> m >> c;
	REP(i, m) cin >> b[i];
	ll res = 0;
	REP(i, n) {
		ll s = c;
		REP(j, m) {
			cin >> a;
			s += a * b[j];
		}
		if (s > 0) ++res;
	}
	cout << res << endl;
	return 0;
}


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

public class Main {
    public static void main(String [] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        for(;;) {
            char [] inc = br.readLine().toCharArray();
            if (inc[0] == '#') break;
            final int n = inc.length;
            int [] in = new int[n];
            int [] tmp = new int[n];
            char [] ans = new char[n];
            LinkedList<String> hs = new LinkedList<String>();
            LinkedList<String> ts = new LinkedList<String>();
            int count = 0;
            for(int i = 0; i < n; i++) in[i] = inc[i];
            // Brute Force Attack!
            for(int i = 0; i < 1 << n; i++) {
                for(int k = 0, f = 1<<(n-1); k < n; k++, f>>=1) {
                    tmp[k] = ((i & f) != 0) ? in[k] + 1 : in[k];
                    ans[k] = (char)tmp[k];
                }
                for(char c = 'b'; c <= 'z'; c++) {
                    for(int k = 0; k < n; k++) {
                        if(tmp[k] == c) {
                            tmp[k]--;
                            break;
                        }
                    }
                }
                boolean ok = true;
                for(int k = 0; k < n; k++) {
                    if((in[k] != tmp[k]) || ans[k]>'z') ok = false;
                }
                if(ok) {
                    count++;
                    if(hs.size()<5) {
                        hs.add(new String(ans));
                    } else {
                        if(ts.size() >= 5) {
                            ts.remove(0);
                        }
                        ts.add(new String(ans));
                    }
                }
            }
            System.out.println(count);
            for(int i = 0; i < hs.size(); i++) {
                System.out.println(hs.get(i));
            }
            for(int i = 0; i < ts.size(); i++) {
                System.out.println(ts.get(i));
            }
        }
    }
}

Measured memory_bytes: 37924
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    int n,a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i,n) {
        cin >> x[i];
        x[i]-=a;
    }
    vector<vector<ll>> dp(n+1,vector<ll>(10000));
    int st=5000;
    dp[0][st]=1;
    rep(i,n) {
        rep(j,10000){
            if (j+x[i]>=0 && j+x[i]<10000) dp[i+1][j]+=dp[i][j]+dp[i][j+x[i]];
            else dp[i+1][j]+=dp[i][j];
        }
    }
    cout << dp[n][st]-1 << endl;

    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 20

int main() {
    int n;
    int c[20], v[20];

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> v[i];
    }
    for(int i=0; i<n; i++) {
        cin >> c[i];
    }

    int ans =0;

    for(int i=0; i<n; i++) {
        if ((v[i] - c[i]) > 0 ) ans += (v[i] - c[i]);
    }

    cout << ans << endl;
}
        


Measured memory_bytes: 256
from itertools import permutations
n,m = map(int,input().split())
lrx = [list(map(int,input().split())) for i in range(m)]
lrx.sort(key = lambda x:x[1])
mod = 10**9+7
dp = [[[0 for b in range(max(1,g))] for g in range(max(1,r))] for r in range(n+1)]
dp[0][0][0] = 1
for l,r,t in lrx:
  if t != 1:
    for g in range(l):
      for b in range(max(1,g)):
        dp[r][g][b] = -1
  if t != 2:
    for g in range(l,r):
      for b in range(l):
        dp[r][g][b] = -1
  if t != 3:
    for g in range(l,r):
      for b in range(l,g):
        dp[r][g][b] = -1

for r in range(n):
  for g in range(max(1,r)):
    for b in range(max(1,g)):
      v = dp[r][g][b]
      if v == -1:
        continue
      if dp[r+1][g][b] >= 0:
        dp[r+1][g][b] += v
        dp[r+1][g][b] %= mod
      if dp[r+1][r][b] >= 0:
        dp[r+1][r][b] += v
        dp[r+1][r][b] %= mod
      if dp[r+1][r][g] >= 0:
        dp[r+1][r][g] += v
        dp[r+1][r][g] %= mod
ans = 0
for i in range(n):
  for j in range(max(1,i)):
    if dp[n][i][j] >= 0:
      ans += dp[n][i][j]
      ans %= mod
print(ans%mod)


Measured memory_bytes: 92380
#include <iostream>
#include <cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
using namespace std;
const long long MOD = 1000000007;
int N;
long long dp[4][4][4][101];

long long rec(int x, int y, int z, int i)
{
	if (dp[x][y][z][i] > 0)
	{
		
	}
	else if (i == 0)
	{
		dp[x][y][z][i] = 1;
	}
	else if ((x == 0||y == 0)&&z == 2)
	{
		dp[x][y][z][i] = (rec(y, z, 0, i - 1) + rec(y, z, 2, i - 1) + rec(y, z, 3, i - 1))%MOD;
	}
	else if (y == 2 && (x == 0 || z == 0))
	{
		dp[x][y][z][i] = (rec(y, z, 0, i - 1) + rec(y, z, 2, i - 1) + rec(y, z, 3, i - 1))%MOD;
	}
	else if (y == 0 && z == 1)
	{
		dp[x][y][z][i] = (rec(y, z, 0, i - 1) + rec(y, z, 1, i - 1) + rec(y, z, 3, i - 1))%MOD;
	}
	else
	{
		dp[x][y][z][i] = (rec(y, z, 0, i - 1) + rec(y, z, 1, i - 1) + rec(y, z, 2, i - 1) + rec(y, z, 3, i - 1))%MOD;
	}
	return dp[x][y][z][i] % MOD;
}

int main()
{
	cin >> N;
	memset(dp, 0, sizeof(dp));
	long long ans = rec(3, 3, 3, N);
	cout << dp[3][3][3][N] % MOD;
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.math.BigDecimal
import kotlin.math.floor

// Helper
private val pw = PrintWriter(System.out)
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readLongs() = readStrings().map(String::toLong)
private fun readDoubles() = readStrings().map(String::toDouble)
private fun readStrings2() = readLn().split("").filter { it.isNotEmpty() }
private fun readInts2() = readStrings2().map(String::toInt)
private fun initArray(n:Int, v:String) = Array(n) { v }
private fun initIntArray(n:Int, v:Int) = IntArray(n) { v }
private fun println(value : Any) = pw.println(value)

internal fun abc169c() {
    val (A, B) = readStrings()
    val aNum = A.toBigDecimal()
    val bNum = B.replace(".", "").toBigDecimal()
    println(aNum.multiply(bNum).divide(BigDecimal(100)).toLong())
}

fun main(args: Array<String>) {
    abc169c()
    pw.flush()
}


Measured memory_bytes: 40232
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000009
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// ============================================================

int main() {
        
    get2(H,A);
    printf("%lld\n", (ll)ceil(H/(double)A));

    return 0;  
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){
  
  ll n;
  cin>>n;
  
  vector<ll> data(n+1);
  for (ll i=0;i<=n;i++){
    ll tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  vector<ll> afford(n+1);
  vector<ll> cnt(n+1);
  
  afford.at(0)=1-data.at(0);
  
  for (ll i=1;i<=n;i++){
    ll tmp=100000000000000;
    afford.at(i)=min(2*afford.at(i-1)-data.at(i),tmp);
  }
  
  ll answer=0;
  
  for (ll i=0;i<=n;i++){
    if (afford.at(i)<0){
      answer=-1;
      break;
    }
  }
  
  if (answer==0){
    cnt.at(n)=data.at(n);
    for (ll i=n-1;i>=0;i--){
      cnt.at(i)=min(afford.at(i),cnt.at(i+1))+data.at(i);
    }
    for (ll i=0;i<=n;i++){
      answer+=cnt.at(i);
    }
  }
  
  cout<<answer<<endl;
  

}























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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define over(msg)          cout << msg << endl, exit(0);
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int a, b;

int main() {
    cin >> a >> b;
    if (b % a) {
        cout << b - a;
    } else {
        cout << a + b;
    }
}

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

int N;

int main() {
    cin >> N; 
    int cost = 800 * N;
    int back = (N / 15) * 200;

    printf("%d\n", cost - back);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	int a[100];
	int total = 0;
	ll tmp = INF;
	int coordinate;
	FOR(i,0,n){in(a[i]);}
	FOR(i,1,101){
		total = 0;
		FOR(i1,0,n){
			total+=abs(a[i1]-i)*abs(a[i1] - i);
		}
		if(total<tmp){
			coordinate = i;
			tmp = total;
		}
	}
	out(tmp);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    std::cin >>n;
    vector<tuple<string,int,int>>a;
    for(int i=1;i<=n;i++){
        int p;
        string s;
        std::cin >> s>>p;
        a.push_back(make_tuple(s,-p,i));
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        std::cout << get<2>(a.at(i)) << std::endl;
    }
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	string n;

	cin >> n;

	if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,M;ll off; cin >> N >> M >> off;
	using P = pair<int,ll>;
	VV<P> G(N);
	rep(i,M){
		int x,y;ll c;
		cin >> x >> y >> c;
		x--,y--,c-=off;
		G[x].pb(P(y,-c));
	}
	ll inf = 1e18;
	V<ll> d(N,inf); d[0] = 0;
	rep(t,N+N+N+10){
		rep(v,N) if(d[v] != inf){
			for(auto e: G[v]){
				int u = e.fs; ll c = e.sc;
				if(d[u] > d[v]+c){
					if(t >= N) d[u] = -inf;
					else d[u] = d[v]+c;
				}
			}
		}
	}
	show(d);
	if(d[N-1] < -1e17) cout << -1 << endl;
	else cout << max(-d[N-1],0LL) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    VI a(3); VIin(a);
    SORT(a);
    OUT((a[1] - a[0]) + (a[2] - a[1]));

    return 0;
}



Measured memory_bytes: 256
#include "iostream"
using namespace std;
 
int main(){
 
 char A[3]={0} ;
  
  cin >> A[0] >> A[1] >>  A[2];
  
  
	if(A[1] == 'R')cout <<"ABC";
  	else cout <<"ARC";
  
  return 0;
}

Measured memory_bytes: 3636
#include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll a, b;

void solve();

int main() {
   solve();
   return 0;
}

void solve() {
	cin >> a >> b;
	if (a < 0 && 0 < b) {
		cout << "Zero" << endl;
	}
	else if (b < 0) {
		cout << ((abs(a - b) + 1) % 2 == 0 ? "Positive" : "Negative") << endl;
	}
	else {
		cout << "Positive" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    int ct[9]={};

    int n,a;
    cin >>n;
    rep(i,n)
    {
        cin >>a;
        a = min(8,a/400);
        ++ct[a];
    }

    int x=0;
    rep(i,8) x+=(ct[i]>0);

    if(x==0)
    {
        x = 1;
        if(ct[8]>0) --ct[8];
    }

    printf("%d %d\n", x,x+ct[8]);
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);

    int ans = 1000000000, cnt;
    bitset<32> b;
    for (int i = 0; i < N; i++) {
        b = A.at(i);
        cnt = 0;
        while (!b.test(0)) {
            cnt++;
            b >>= 1;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v;
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y; y--;
        v.emplace_back(x, y);
    }
 
    sort(v.begin(), v.end());    
     
    vector<int> cnt(N, 1);
    vector<vector<int>> prev(N, vector<int>(2));
 
    for (int i = 0; i < M; i++) {
        int p = v[i].second;
        int c1 = cnt[p], c2 = cnt[p + 1];
         
        cnt[p]     += c2 - prev[p][0];
        cnt[p + 1] += c1 - prev[p][1];
 
        prev[p][0] = cnt[p];
        prev[p][1] = cnt[p + 1];
    }
 
    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << cnt[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 15116
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int n; readV(n);
  int a; readV(a);
  writeln(n*n-a);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<string>
using namespace std;
int sort(char str[8], bool grater) {
	for (int i = 0; i < 7; ++i) {
		for (int k = i + 1; k < 8; ++k) {
			if ((grater)?str[i]<str[k]:str[i]>str[k]) {
				swap(str[i], str[k]);
			}
		}
	}
	return atoi(str);
}
int main() {
	char str[8];
	int time;
	cin >> time;
	for (int i = 0; i < time; ++i) {
		cin >> str;
		cout << sort(str, true) - sort(str, false) << endl;
	}
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);

    FOR(i, 1, 10) {
        FOR(j, 1, 10) {
            int x = i * j;
            if (x == N) {
                print("Yes");
                return 0;
            }
        }
    }
    print("No");

    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
XY=[[int(j)for j in input().split()]for _ in range(M)]
cnt=[1]*(N+1)
ans=[False]*(N+1)
ans[1]=True
for x,y in XY: 
  cnt[x]-=1
  cnt[y]+=1
  if ans[x] and not ans[y]: 
    ans[y]=True
  if ans[x] and cnt[x]==0:
    ans[x]=False
print(sum(ans))

Measured memory_bytes: 62424
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let mut ans = 0;
    let mut md = 0;
    for _ in 0..5 {
        let a: usize = read_line().trim().parse().unwrap();
        ans += (a + 9)/10 * 10;
        if a%10 > 0 {
            md = cmp::max(md, 10 - a % 10);
        }
    }

    println!("{}", ans - md);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int c[27];
int s[366][27];
int last[366][26];

ll evaluate(int day, int t) {
  ll score = 0;
  score += s[day][t];
  rep(j, 26) {
    if(t == j)continue;
    score -= c[j] * (day+1 - last[day][j]);
  }
  return score;
}

vi greedy(int d) {
  vi t(d);
  rep(i, d) {
    ll score = -100100100;
    int tt = -1;
    rep(j,26){
      ll tmp = evaluate(i,j);
      if(tmp>score){
        score = tmp;
        tt = j;
      }
      //show(score);
    }
    //cout<<"----"<<endl;
    t[i] = tt;
    last[i][t[i]] = i+1;
    rep(j,26)if(t[i]!=j && i>=1)last[i][j] = last[i-1][j];
  }
  return t;
}

ll evaluateAll(vi t) {
  int d = sz(t);
  ll score = 0;
  rep(i, d) {
    score+=evaluate(i,t[i]);
  }
  return score;
}

vi mutation(vi t){
  int d = sz(t);
  int loop = 10000;
  ll score = evaluateAll(t);
  while(loop--){
    int x = rand()%d;
    int y = rand()%26;
    vi ct = t;
    ct[x] = y;
    int oldLast = last[x][y];
    last[x][y] = x;
    ll score2 = evaluateAll(ct);
    if(score < score2){
      score = score2;
      t = ct;
    }
    else{
      last[x][y] = oldLast;
    }
  }
  return t;
}

void printLast(int d){
  rep(i,d){
    rep(j,26){cout<<last[i][j]<<" ";
    }
    cout<<endl;
  }
}
int main() {
  int d;
  cin >> d;
  rep(i, 26) cin >> c[i];
  rep(i, d) rep(j, 26) cin >> s[i][j];

  auto t = greedy(d);

  //print(evaluateAll(t));
  t = mutation(t);
  //print(evaluateAll(t));

  rep(i,d)cout<<t[i]+1<<endl;
  return 0;
}

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

int dp[4000][4000];
char ans[4000][4000];
pair <int ,int > par[4000][4000];
vector <char> vec;



void find (int a,int b){
	if (a==0 or b==0)
		return ;
	if (ans[a][b]!='.')
		vec.push_back(ans[a][b]);
	find (par[a][b].first, par[a][b].second);
}


int main(){
	string s,t;
	cin>>s>>t;
	int ss = s.size(), ts = t.size();
	for (int i =1;i<=ss;i++){
		for (int j = 1;j<=ts;j ++){
			if (dp[i-1][j] > dp[i][j-1]){
				dp[i][j] = dp[i-1][j];
				ans[i][j] = '.';
				par[i][j]={i-1,j};
			}
			else {
				dp[i][j] = dp[i][j-1];
				ans [i][j] = '.';
				par[i][j] = {i,j-1};
			}
			if ( s[i-1]==t[j-1] and dp[i][j]< dp[i-1][j-1]+1){
				dp[i][j] = dp[i-1][j-1] + 1;
				ans[i][j] = s[i-1];
				par[i][j] = {i-1,j-1};
			}
		}
	}	
	find (ss, ts);
	reverse (vec.begin(),vec.end());
	for (auto i : vec )
		cout<<i;
}

Measured memory_bytes: 155648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

//------------------------------------------------
int main(){
string s;
cin>>s;
if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&s.at(0)!=s.at(2)&&s.at(0)!=s.at(3)) cout<<"Yes"<<endl;
else{
  if(s.at(0)==s.at(2)&&s.at(1)==s.at(3)&&s.at(0)!=s.at(1)&&s.at(0)!=s.at(3)) cout<<"Yes"<<endl;
  else{
if(s.at(0)==s.at(3)&&s.at(1)==s.at(2)&&s.at(0)!=s.at(2)&&s.at(0)!=s.at(1)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}



}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int num = int.Parse(ReadLine());
        string[] liststr = ReadLine().Split(' ');
        int[] list = new int[100010];
        for(int i=0;i<num;i++){
            int temp = int.Parse(liststr[i]);
            list[temp]++;
        }
        int ans = 0;
        for(int i=1;i<100000;i++){
            int temp = list[i-1] + list[i] + list[i+1];
            ans = Max(ans,temp);
        }
        WriteLine(ans);
    }
}

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

int main() {
  int r = 0,a,b;
  cin >> a >> b;
  
  for ( int i= a ; i <= b ; i++ ) {
    int s = i /10000 , t = i/1000 - s*10;
    int u = i/100-s*100-t*10;
    int v = i/10-s*1000-t*100-u*10;
    int w = i%10;
    
    if (s == w && t == v) {
      r++;
    }
  }
  
  cout << r << endl;
}

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





int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
        ans += (s[i]=='g')?1:-1;
    ans -= s.length()%2;
    cout << ans / 2;


    return 0;
}




Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
#define MAX 200000

int main(){
  ll N,C,K,T[MAX];
  cin>>N>>C>>K;
  for(int i=0;i<N;i++){
    cin>>T[i];
  }
  sort(T,T+N);
  ll start=-1,ans=0,count=0;
  for(ll i=0;i<N;i++){
    if(start==-1){
      start=T[i];
      count=1;
      ans++;
    }else{
      if(T[i]<=start+K){
        if(++count==C) start=-1;
      }else{
        start=T[i];
        count=1;
        ans++;
      }
    }
  }
  if(C==1){
    ans=N;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = 1LL << 34;

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

    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> s(A+2), t(B+2);
    for (int i = 1; i <= A; i++) cin >> s[i];
    for (int i = 1; i <= B; i++) cin >> t[i];
    s[A+1] = t[B+1] = INF;

    for (int i = 0; i < Q; i++) {
        ll x; cin >> x;
        int si = lower_bound(s.begin(), s.end(), x)
               - s.begin();
        int ti = lower_bound(t.begin(), t.end(), x)
               - t.begin();
        ll sl = x - s[si-1], sr = s[si] - x;
        ll tl = x - t[ti-1], tr = t[ti] - x;

        ll ans = INF;
        if (si != 1 && ti != 1)
            ans = min(ans, max(sl, tl));
        if (si != A+1 && ti != B+1)
            ans = min(ans, max(sr, tr));
        if (si != 1 && ti != B+1)
            ans = min(ans, sl + tr + min(sl, tr));
        if (si != A+1 && ti != 1)
            ans = min(ans, sr + tl + min(sr, tl));
        cout << ans << "\n";
    }
}

Measured memory_bytes: 2944
def main():
  n=input()
  a=tuple(map(int,input().split()))
  cnt=[0]*(pow(10,5)+2)
  for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
  print(max(set(cnt)))   
if __name__=='__main__':
  main()

Measured memory_bytes: 14092
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Double> list = new ArrayList<Double>();
		for (int i = 0; i < N; i++) {
			list.add(Double.parseDouble(sc.next()));
		}

		double ans = list.stream().mapToDouble(s -> 1.0 / s).sum();

		ans = 1.0 / ans;
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 26964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
set<PI> F[N];
int n,a[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,1,n)a[i]=read();
	F[0].insert(mp(0,0));
	For(i,0,n+1){
		int mn=1e9;
		for(auto j:F[i])mn=min(mn,j.se);
		if(i==n+1){
			cout<<mn<<endl; return 0;
		}
		mn+=2;
		for(auto j=F[i].rbegin();j!=F[i].rend();j++)if((*j).se<mn){
			auto k=*j;
			//if(!k.se)cout<<i<<" "<<k.fi<<" "<<k.se<<" "<<(a[i+1]>k.fi)<<endl;
			if(k.fi<a[i+1])F[i+1].insert(mp(k.fi,k.se+(0>a[i+1]-a[i])));
			if(a[i+1]-a[i]+k.fi<a[i+1]&&a[i+1]-a[i]+k.fi>=0)
			F[i+1].insert(mp(a[i+1]-a[i]+k.fi,k.se+(a[i+1]-a[i]>0)));
			F[i+1].insert(mp(a[i+1],k.se+(a[i+1]>k.fi)+(a[i+1]-k.fi>a[i+1]-a[i])));
			mn=k.se;
		}
	}
}


Measured memory_bytes: 66688