akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll N;
vector<ll> A, B, C;

int main(void){
    
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){ ll a; scanf("%lld", &a); A.push_back(a); }
    for(int i = 0; i < N; ++i){ ll a; scanf("%lld", &a); B.push_back(a); }
    for(int i = 0; i < N; ++i){ ll a; scanf("%lld", &a); C.push_back(a); }
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        ll num = B[i];
        ll a = lower_bound(A.begin(), A.end(), num) - A.begin();
        ll b = C.size() - (upper_bound(C.begin(), C.end(), num) - C.begin());
        ans += a * b;
    }    
    printf("%lld\n", ans);
    
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Data {
  int start,end,onAir,recorded;
  bool operator < ( const Data &data ) const {
    if( end != data.end ) return end < data.end;
    if( start != data.start ) return start < data.start;
    return ( onAir != data.onAir ) ? onAir < data.onAir : recorded < data.recorded;
  }
};

const int MAX_N = 1100;
int N,dp[2000][2000],h,m;
vector<int> buf;

int toTime(string s){
  rep(i,(int)s.size()) if( s[i] == ':' ) s[i] = ' ';
  stringstream ss(s);
  ss >> h >> m;
  return h * 60 + m;
}

int main(){
  while( cin >> N, N ){
    vector<Data> vec(N);
    rep(i,N) {
      string a,b,c;
      cin >> a >> b >> c >> vec[i].onAir >> vec[i].recorded;
      vec[i].start = toTime(b), vec[i].end = toTime(c);
    }
    vec.push_back((Data){0,0,0,0});
    rep(i,N+2) rep(j,N+2) dp[i][j] = 0; 
    sort(vec.begin(),vec.end());
    buf.clear();
    rep(i,vec.size()) buf.push_back(vec[i].end);
    rep(i,vec.size()){
      rep(j,vec.size()){
        if( i == j ) dp[i][j] = max((i?dp[i-1][j]:0),(j?dp[i][j-1]:0));
        else if( i < j ) {
          dp[i][j] = dp[i][j-1];
          int prev = upper_bound(buf.begin(),buf.begin()+j,vec[j].start) - buf.begin() - 1;
          dp[i][j] = max(dp[i][j],((prev!=-1)?dp[i][prev]:0)+vec[j].recorded);
        } else {
          dp[i][j] = dp[i-1][j];
          int prev = upper_bound(buf.begin(),buf.begin()+i,vec[i].start) - buf.begin() - 1;
          dp[i][j] = max(dp[i][j],((prev!=-1)?dp[prev][j]:0)+vec[i].onAir);
        }
      }
    }
    printf("%d\n",dp[(int)vec.size()-1][(int)vec.size()-1]);
  }
  return 0;
}

Measured memory_bytes: 9448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B ;
  cin >> A >> B;
  int a, b, c, d;
  a=A+B;
  b=A-B;
  c=A*B;
  if(a>=b){
    d=a;
  }else{
    d=b;
  }
  if(d<c){
     d=c;
  }else{
     d=d;
  }
  
 cout << d << endl; 
  
  return(0);
  
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n

#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define FOR(i,m,n) for(int (i)=(m);(i)<(n); i++)
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
	int N;cin>>N;
	ll A[N];REP(i,N)cin>>A[i];
	sort(ALL(A,N));
	bool ret=false;
	REP(i,N-1)if(A[i]==A[i+1])ret=true;
	cout<<(!ret?"YES":"NO");
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    vector<vector<int> > book(10);
    for(int i=0; i<n; ++i){
        int c, g;
        cin >> c >> g;
        book[g-1].push_back(c);
    }
    for(int i=0; i<10; ++i)
        sort(book[i].rbegin(), book[i].rend());

    vector<int> dp(m+1, 0);
    for(int i=0; i<10; ++i){
        vector<int> next = dp;
        int sum = 0;
        for(unsigned j=0; j<book[i].size(); ++j){
            sum += book[i][j] + 2*j;
            for(int k=j+1; k<=m; ++k)
                next[k] = max(next[k], dp[k-j-1] + sum);
        }
        dp.swap(next);
    }

    cout << dp[m] << endl;
    return 0;
}

Measured memory_bytes: 0
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
n, m = map(int, input().split())
num = [-1 for i in range(n)]
if n == 1:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s - 1] != -1 and num[s - 1] != c:
            print(-1)
            sys.exit()
        num[s - 1] = c
    if num[0] == -1:
        print(0)
    else:
        print(str(num[0]))
else:
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            print(-1)
            sys.exit()
        if num[s - 1] != -1 and num[s - 1] != c:
            print(-1)
            sys.exit()
        num[s - 1] = c
    # print(num)
    ans = ""
    for i in range(n):
        if num[i] != -1:
            ans += str(num[i])
        else:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
    print(ans)


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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
/**************************************/

/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;

    map<ll,int> mp;
    mp = prime_factor(n);

    ll ans = 0;
    for(auto x: mp){
        ll tmp = x.second;
        for(int i=1;;i++){
            if(tmp-i>=0){
                ans++;
                tmp -= i;
            }else{
                break;
            }
        }
    }

    // for(auto x: mp){
    //     cout << x.first << " " << x.second << endl;
    // }

    cout << ans << endl;

    return 0;
}
/********  Main() Ends Here *************/


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

const int ms = 100;

char buffer[ms][ms + 1];

int main() {
	for(int i = 0; i < ms; i++) {
		for(int j = 0; j < ms / 2; j++) {
			buffer[i][j] = '.';
			buffer[i][j + ms / 2] = '#';
		}
		buffer[i][ms] = 0;
	}
	int a, b;
	std::cin >> b >> a;
	a--;
	b--;
	for(int i = 1; i < ms && a; i += 2) {
		for(int j = 1; j < ms / 2 - 1&& a; j += 2) {
			buffer[i][j] = '#';
			a--;
		}
	}
	for(int i = 1; i < ms && b; i += 2) {
		for(int j = 1; j < ms / 2 - 1 && b; j += 2) {
			buffer[i][j + ms / 2] = '.';
			b--;
		}
	}
	std::cout << ms << ' ' << ms << '\n';
	for(int i = 0; i < ms; i++) {
		printf("%s\n", buffer[i]);
	}
}

Measured memory_bytes: 256
from math import log,floor
n=int(input())
"""
num=log(n/100)
den=log(1.01)
ans=num/den
print(int(ans))
"""
i=0
p=100
while 1:
	inter=p/100
	p+=inter
	p=int(p)
	i+=1
	if p>=n:
		print(i)
		break

Measured memory_bytes: 9172
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int cnt = 0;
    for(int i=3;i<=s.length();i++){
      if(s.substring(i-3,i).equals("ABC"))cnt++;
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 22996
#include <cstdio>
using namespace std;
int vv[505][505];
int v[250005][5];
int count=0;
int main() {
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            scanf("%d",&vv[i][j]);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
            if(vv[i][j]%2==1){
                if(j+1<=w&&(vv[i][j]+vv[i][j+1])%2==0){
                    vv[i][j]--;
                    vv[i][j+1]++;
                    count++;
                    v[count][1]=v[count][3]=i;
                    v[count][2]=j;
                    v[count][4]=j+1;
                }
                else if(i+1<=h&&(vv[i][j]+vv[i+1][j])%2==0){
                    vv[i][j]--;
                    vv[i+1][j]++;
                    count++;
                    v[count][1]=i;
                    v[count][3]=i+1;
                    v[count][2]=v[count][4]=j;
                }
                else if(j+1<=w){
                    vv[i][j]--;
                    vv[i][j+1]++;
                    count++;
                    v[count][1]=v[count][3]=i;
                    v[count][2]=j;
                    v[count][4]=j+1;
                }
                else if(i+1<=h){
                    vv[i][j]--;
                    vv[i+1][j]++;
                    count++;
                    v[count][1]=i;
                    v[count][3]=i+1;
                    v[count][2]=v[count][4]=j;
                }
            }
        }
    printf("%d\n",count);
    for(int i=1;i<=count;i++)
        printf("%d %d %d %d\n",v[i][1],v[i][2],v[i][3],v[i][4]);
    return 0;
}


Measured memory_bytes: 7040
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Main().main();
    }

    public void main() {
        Scanner scanner = new Scanner(System.in);

        int sNum = Integer.parseInt(scanner.nextLine());
        String[] sLine = scanner.nextLine().split(" ", sNum);
        int[] s = new int[sNum];
        for (int i = 0; i < sNum; i++) {
            s[i] = Integer.parseInt(sLine[i]);
        }

        int tNum = Integer.parseInt(scanner.nextLine());
        String[] tLine = scanner.nextLine().split(" ", tNum);

        int result = 0;
        for (int i = 0; i < tNum; i++) {
            int t = Integer.parseInt(tLine[i]);
            if (this.binarySearch(t, s)) {
                result++;
            }
        }
        System.out.println(result);
    }

    private boolean binarySearch(int key, int[] arr) {
        int left = 0;
        int right = arr.length - 1;

        while (true) {
            int middle = (left + right) / 2;
            if (middle == left || middle == right) {
                return key == arr[left] || key == arr[right];
            }

            if (key == arr[middle]) {
                return true;
            } else if (key < arr[middle]) {
                right = middle;
            } else {
                left = middle;
            }
        }
    }
}



Measured memory_bytes: 65616
#include<iostream>
using namespace std;
int a[10000];
int b[10000];
int main(){
	int h=0;
	int w=0;
	int i=0;
	int x=0;
	int y=0;
	int z=0;
	while(1){
		cin>>h>>w;
		if(h==0&&w==0){
			break;
		}
		a[i]=h; //y
		b[i]=w; //x
		i++;
	}
	for(z=0;z<i;z++){
		for(y=0;y<a[z];y++){
			for(x=0;x<b[z];x++){
				if(x==0||y==0||x==b[z]-1||y==a[z]-1){
					cout<<"#";
				}else{
					cout<<".";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
}
		

Measured memory_bytes: 1156
N = gets.to_i
len = gets.strip.split.map(&:to_i)
newlen = len.sort
if N <= 2
  puts "0"
else
  cnt = 0
  for i in 0..N-3
    for j in i+1..N-2
      for k in j+1..N-1
        if newlen[i]<newlen[j] && newlen[j]<newlen[k] && newlen[i]+newlen[j]>newlen[k]
          cnt += 1
        end
      end
    end
  end
  puts cnt
end

Measured memory_bytes: 14328
#include <stdio.h>

#define INF 3000

void prim();

int n;
int A[101][101],color[101] = {};

int main(){
  int i,j,a;
  
   scanf("%d",&n);
   
  for(i = 1; i < n+1;i++){
    for(j = 1; j < n+1;j++){
      scanf("%d",&a);
      if(a == -1)A[i][j] = INF;
      else A[i][j] = a;
     }
  }
  prim();
  return 0;
}
  
void prim(){
  
  int i,j,sum=0,mincost,u;
  int d[101] = {},pi[101];
  
  for(i = 1;i < n+1; i++){
    d[i] = INF;
    pi[i] = -1;
  }

  d[1] = 0;
  
  while(1){
    mincost = INF;
    
    for(i = 1; i< n+1; i++){
      if(color[i] != -2 && d[i] < mincost){
        mincost = d[i];
	u = i;
      }
    }
    if(mincost == INF)break;
    color[u] = -2;

    for(i = 1; i < n+1; i++){
      if(color[i] != -2 && A[u][i] != INF){
	if(A[u][i] < d[i]){
	pi[i] = u;
	d[i] = A[u][i];
       }
      }
    }
  }
  for(i = 1; i < n+1; i++){
    if(pi[i] != -1)sum += A[i][pi[i]];
  }
   printf("%d\n",sum);
}
  



Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define vi vector<int>
using namespace std;
int main(void)
{
   int n,k;
   cin>>n>>k;
   vi h(n);
   vi dp(n);
   for(int  i = 0;i<n;i++)
   {
      dp[i] =INT_MAX;
      cin>>h[i];
   }
   dp[0]=0;
   for(int  i = 0;i<n;i++)
   {
      for(int j = 1;j<=k;j++)
        if((i+j)<n)
          dp[i+j] = min(dp[i+j],(dp[i]+abs(h[i+j]-h[i])));
    }
   cout<<dp[n-1]<<endl;
}





























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

using namespace std;

typedef long long ll;

const ll N = 1010;

ll a[N];
ll n, k;

int main() {
	cin >> n >> k;
	for (ll i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	ll res = 0;
	for (ll i = 0; i < k; i++)res += a[i];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>
#include<set>

using namespace std;


int main()
{
	int n;
	bool flag = true;
	cin >> n;
	int t, x, y, st = 0, sx = 0, sy = 0, dt, dx, dy;
	for (int i = 0; i < n; i++) {
		cin >> t >> x >> y;
		dt = t - st;
		dx = abs(x - sx);
		dy = abs(y - sy);
		if (dt >= (dx + dy) && (dx + dy + dt) % 2 == 0) {
			st = t;
			sx = x;
			sy = y;
		}
		else {
			flag = false;
		}
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main(void){
	int n,k;
	cin>>n>>k;
	vector<pair<int,int>>anst;
	if(((n-1)*(n-2)/2)-k>=0){
		for(int i=2;i<=n;i++)anst.push_back(make_pair(1,i));
		int num = ((n-1)*(n-2))/2;
		int i=2;
		int j=i+1;
		for(;;){
			if(num==k)break;
			if(j>n){
				i++;
				j=i+1;
			}
			anst.push_back(make_pair(i,j));
			j++;
			num--;
		}
		cout<<anst.size()<<endl;
		for(auto p:anst){
			cout<<p.first<<" "<<p.second<<endl;
		}
	}else{
		cout<<-1<<endl;
	}
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second

typedef long long LL;

int n ;
int a[123456];
char b[123456];
long long ans;

int main() {
   // freopen("test.txt","r",stdin);
    cin >> n ;
    for (int i =1 ; i <=n ; i++) {
        cin >> a[i];
        if ( a[i] != i ) b[i] = 'o';
        else b[i] = 'x';
    }
    for (int i =1 ; i < n ; i++) {
        if (b[i] == 'x') {
            if ( b[i+1] == 'x') {
                ans++;
                b[i] = 'o';
                b[i+1] = 'o';
            } else {
                if ( b[i+1] == 'o') {
                    ans++;
                    b[i] = 'o';
                }
            }
        }
    }
    if ( b[n] == 'x') ans++ ;
    cout << ans;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main (){
	map <int, int> num;
	int n,x,r=0; 
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> x;
		if (num.count(x)==0) num[x] = 1;
		else num[x]++;
	}
	
	for (auto &it:num){
		if (it.first<it.second){
			r += (it.second-it.first);
		}
		else if(it.first>it.second){
			r+= it.second;
		}
	}
	
	cout << r;
	
	return 0;
}

Measured memory_bytes: 8096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n[5];
  for(int i=0;i<4;i++) cin>>n[i];
  sort(n,n +4);
  if(n[0]==1&&n[1]==4&&n[2]==7&&n[3]==9) cout<<"YES"<<'\n';
  else cout<<"NO"<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int N, A[200005];
ll psum[200005];

pair<ll, ll> divide(int i, int j) {
	int a = i;
	int b = j;
	ll minDiff = 1LL << 60;
	pair<ll, ll> res;
	while (a <= b) {
		int m = (a + b) / 2;
		ll s1 = psum[m] - psum[i - 1];
		ll s2 = psum[j] - psum[m];
		ll diff = abs(s1 - s2);
		if (minDiff > diff) {
			minDiff = diff;
			res = make_pair(min(s1, s2), max(s1, s2));
		}
		if (s1 < s2) {
			a = m + 1;
		} else {
			b = m - 1;
		}
	}
	return res;
}

int main() {
  scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &A[i]);
		psum[i] = psum[i - 1] + A[i];
	}
	ll res = 1LL << 60;
	for (int i = 2; i < N - 1; i++) {
		auto p1 = divide(1, i);
		auto p2 = divide(i + 1, N);
		ll diff = max(p1.second, p2.second) - min(p1.first, p2.first);
		res = min(res, diff);
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef unsigned long long ll;

ll p = pow(10, 9) + 7;





int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> vals(N);
    for(int i = 0; i < N; i++)
    {
        cin >> vals[i];
    }
    vector<int> dp(N);
    dp[1] = abs(vals[0] - vals[1]);
    for(int i = 2; i < N; i++)
    {
        dp[i] = min(abs(vals[i] - vals[i - 1]) + dp[i - 1], abs(vals[i] - vals[i - 2]) + dp[i - 2]);
    }
    cout << dp[N - 1] << endl;

}


Measured memory_bytes: 1024
def main():
    H , N  = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N)]

    dp = [float("inf")]*(H + 10010)
    mx = 10**8
    for a,b in AB:
        dp[min(a,H)] = min(dp[min(a,H)],b)
    for i in range(1,H + 1):
        if dp[i] > mx:
            continue
        for a,b in AB:
            if i + a > H:
                dp[H] = min(dp[H],dp[i] + b)
            else:
                dp[i + a] = min(dp[i + a],dp[i] + b)
    print(dp[H])


if __name__ == "__main__":
    main()

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

int n;
int a;
bool flag = 1;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		if (a % 2 == 0)
			if (a % 3 != 0 && a % 5 != 0) flag = 0;
		else continue;
	}
	if (flag == 0) cout << "DENIED" << endl;
	else cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

constexpr long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr long long MOD = 1e9+7;

// typedef long long lint;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

using Point = complex<double>;
const double eps = 1e-9, pi = acos(-1);

istream &operator>> (istream &is, Point &p){
	double a, b;
	is >> a >> b;
	p = Point(a, b);
	return is;
}

struct Circle {
	Point p; double r;
	Circle() = default;
	Circle(Point p, double r) : p(p), r(r){}
};

double distance(const Point &a, const Point &b){
	return abs(a-b);
}

pair< Point, Point > crosspoint(const Circle &c1, const Circle &c2){
	double d = abs(c1.p - c2.p);
	double a = acos((c1.r*c1.r + d*d - c2.r*c2.r) / (2 * c1.r * d)); // 余弦定理
	double t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());
	Point p1 = c1.p + Point(cos(t+a) * c1.r, sin(t+a) * c1.r);
	Point p2 = c1.p + Point(cos(t-a) * c1.r, sin(t-a) * c1.r);
	return {p1, p2};
}
using Points = vector<Point>;
using Circles = vector<Circle>;

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

	int N; cin >> N;
	Points P(N);
	REP(i, N) cin >> P[i];
	double left = 0.0, right = 10000.0;
	REP(_, 60){
		double R = (left+right) / 2.0;
		bool ok = 0;
		REP(i, N) RANGE(j, i+1, N){
			if(abs(P[i]-P[j]) - R*2 + eps > 0.0) continue;
			pair<Point, Point> cross = crosspoint(Circle(P[i], R), Circle(P[j], R));
			bool cover1 = 1, cover2 = 1;
			REP(k, N){
				if(k == i or k == j) continue;
				cover1 &= (R - abs(cross.first  - P[k]) + eps >= 0.0);
				cover2 &= (R - abs(cross.second - P[k]) + eps >= 0.0);
			}
			ok |= (cover1 or cover2);
		}
		if(ok) right = R;
		else left = R;
	}
	dcout << right << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
ll cor[105000];
int main() {
    ll n, k, q;
    cin >> n >> k >> q;
    ll a[q];
    for(int i = 0; i < q; i++){
        int x;
        cin >> x;
        cor[x - 1] += 1;
    }

    for(int i = 0; i < n; i++){
        if(k - q + cor[i] <= 0){
            cout << "No";
        }
        else cout << "Yes";
        cout << '\n';
    }
}

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

long long luca(long long a,long long b) {
  return a + b;
}


    
    
    

int main() {
  int N;
  cin >> N;
  long long a = 2;
  long long b = 1;
  long long pa;
  long long pb;
  for (int i = 0;i < N-1;i++) {
    pa = a;
    pb = b;
    a = pb;
    b = luca(pa,pb);
  }
  cout << b  << endl;
    
  
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Chars;
use std::collections::HashSet;
//use std::cmp::*;

fn main() {
    input! {
        N:usize,
        S:[String;N]
    }
    let mut h: HashSet<&str> = HashSet::new();

    for s in S.iter() {
        h.insert(s);
    }
    println!("{}", h.len());
}


Measured memory_bytes: 21756
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a,b;
    cin>>a>>b;
    if(a<b) cout<<"<"<<endl;
    else if(a>b) cout<<">"<<endl;
    else cout<<"="<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        List<Double> list = new ArrayList<Double>();
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            if ("q".equals(s)) {
                break;
            }
            list.add(Double.parseDouble(s));
        }

        double max = 0;
        double min = 999999999;
        for (int i = 0; i < list.size(); i++) {
            if (max < list.get(i)) {
                max = list.get(i);
            } else if (min > list.get(i)) {
                min = list.get(i);
            }
        }
        System.out.println(max - min);
    }
}

Measured memory_bytes: 26016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];
    vector<ll> gc(n), gcb(n);
    gc[0] = a[0];
    FOR(i, 1, n){
        gc[i] = gcd(gc[i-1], a[i]); 
    }
    gcb.back() = a.back();
    repd(i, n-1){
        gcb[i] = gcd(gcb[i+1], a[i]);
    }
    
    ll res=0;
    rep(i, n){
        ll fr=0, bc=0;
        if(0<i) fr = gc[i-1];
        if(i<n-1) bc = gcb[i+1];
        if(!fr || !bc) res = max(res, max(fr, bc));
        else res = max(res, gcd(fr, bc));
    }
    cout << res << endl;
}


Measured memory_bytes: 5580
var
    n,l,i,j,k: Integer;
    S:array[1..100] of String;
    t:String;
    flag:Boolean;
begin
    readln(n,l);
    readln(S[1]);
    for i := 2 to n do
    begin
        readln(t);
        flag:=false;
        for j := 1 to i-1 do
        begin
            if t<S[j] then
            begin
                for k := i-1 downto j do
                begin
                    S[k+1]:=S[k];
                end;
                S[j]:=t;
                flag:=true;
                break;
            end;
        end;
        if not flag then
        begin
            S[i]:=t;
        end;
    end;
    for i := 1 to n do
    begin
        write(S[i]);
    end;
    writeln;
    readln;
end.


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func floatSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	if n%2 == 1 {
		fmt.Println(0)
	} else {
		ans := 0
		for n != 0 {
			n /= 5
			ans += n / 2
		}
		fmt.Println(ans)
	}
}


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

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    ull A;
    string B;
    cin >> A >> B;
    cout << ull(((B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0')) * A / 100) << endl;
}


Measured memory_bytes: 3536
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto si = readln.split.to!(int[]);
  auto q = readln.chomp.to!size_t;
  auto ti = readln.split.to!(int[]);
  writeln(ti.count!(t => si.canFind(t)));
}

Measured memory_bytes: 2656
from itertools import combinations

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

count = 0
for C in combinations(L, 3):
    l_list = list(C)
    l_list.sort()

    if l_list[2] > l_list[1] and l_list[1] > l_list[0]:
        if l_list[2] < l_list[1] + l_list[0]:
            count += 1

print(count)

Measured memory_bytes: 9096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		String n = sc.next();
		String n1 = n.substring(n.length() - 1);
		int n2 = Integer.parseInt(n1);
		// 判定
		switch (n2) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			;
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			;
			break;
		case 3:
			System.out.println("bon");
			;
			break;
		}
		sc.close();
	}
}


Measured memory_bytes: 35652
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<ll, ll> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}

int main()
{

	int n, k;
	cin >> n >> k;
	//bool even = (k % 2 == 0);
	bool ans = false;
	vector<int> a(n);
	
	rep(i, n)
	{
		cin >> a[i];
		
	}
	int gcd=a[0];
	rep(i,n)gcd=GCD(gcd,a[i]);
	sort(all(a));
	int m = a[0];
	int ma = a[n - 1];
	if (k > ma)
	{
		ans=false;
	}
	else if(k%gcd==0)
	{
		ans=true;
	}

	if (ans)
	{
		cout << "POSSIBLE" << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}
}

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

int main() {
	int a,b;
	cin>>a>>b;
	b= 2*b+1;
	if(a>b){
    	if(a%b!=0){
    	    cout<<(a/b)+1;
    	}
    	else if(a%b==0){
    	    cout<<(a/b);
    	}
	}
	else{
	    cout<<1;
	}
	return 0;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll n;
ll num[10][10];
ll ans;
int main(){
	cin >> n;
	REP(i,1,n+1){
		ll j = i;
		while(j >= 10){
			j /= 10;
		}
		num[j][i%10]++;
	}
	REP(i,1,10){
		REP(j,1,10){
			ans += num[i][j] * num[j][i];
		}
	}
	p(ans);
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LIM 1+2+4+8+16+32+64+128
using namespace std;
typedef long long int ll;
typedef struct{
  int per;
  int ko;
  int kyoda;
  int konoko;
}TRE;
int ace(int a,int b){
  int ss=0;
  for(int i=b;i<=a;i++){
    ss+=i;
  }
  return(ss);
}
typedef pair<int,int>P;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    if(n%1111==0){
      cout<<"NA"<<endl;
    }else{
      int cnt=0;
      while(n!=6174){
	cnt++;
	int l=0;
	int s=0;
	int sl[4];
	int ss=0;
	for(int i=10;i<=1000;i*=10){
	  sl[ss]=(n-((n/i)*i))/(i/10);
	  ss++;
	}
	sl[ss]=n/1000;
	sort(sl,sl+4);
	ss=0;
	for(int i=1;i<=1000;i*=10){
	  l+=sl[4-ss-1]*i;
	  s+=sl[ss]*i;
	  ss++;
	}
	n=abs(l-s);
      }
      cout<<cnt<<endl;
    }
  }
  return(0);
}



Measured memory_bytes: 3168
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


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

//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

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

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	ll n;
	cin >> n;


	if (n % 2) {
		cout << 0 << endl;
	}
	else {

		ll ans = 0;
		n /= 2;
	
		ll base = 5LL;

		while (n / base) {
			ans += n / base;
			base *= 5LL;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0

int main(){

	lli h,w;
	cin>>h>>w;

	/*最短経路以外は全部塗ることで達成できそう*/
	/*幅優先を行う。ここで通ってきた経路も確保しておく*/

	lli flag[60][60];
	lli last[60][60];

	lli white=0;

	REP(i,60)REP(j,60){
		flag[i][j]=0;
		last[i][j]=0;
		if(i==0 || i>h || j==0 || j>w){
			flag[i][j]=-1;
			last[i][j]=-1;
		}
	}

	for(lli i=1;i<=h;i++){
		for(lli j=1;j<=w;j++){
			char s;
			cin>>s;
			if(s=='#'){
				flag[i][j]=-1;
				last[i][j]=-1;
			}
			else white++;
		}
	}

	queue<pair<lli,lli>> q;
	queue<string> qs;

	q.push(make_pair(1,1));
	qs.push("");
	flag[1][1]=-1;

	string ansS="";

	while(q.size()){
		lli topI = q.front().first;
		lli topJ = q.front().second;
		string topS = qs.front();
		if(topI == h && topJ == w){
			ansS = topS;
			break;
		}
		q.pop();
		qs.pop();

		lli di[4] = {-1,0,1,0};
		lli dj[4] = {0,1,0,-1};
		string ds[4] = {"U","R","D","R"};

		REP(k,4){
			lli nextI=topI+di[k];
			lli nextJ=topJ+dj[k];
			string nextS = topS + ds[k];

			if(flag[nextI][nextJ]==0){
				q.push(make_pair(nextI,nextJ));
				qs.push(nextS);
				flag[nextI][nextJ]=-1;
			}
		}
	}

	if(ansS==""){
		cout<<-1<<endl;
		return 0;
	}

	cout<<white-ansS.size()-1<<endl;


	return 0;
}

Measured memory_bytes: 256
require 'pp'
require 'prime'
require 'set'

N=gets.chomp.split(' ').map{|n| n.to_i}.first
#
# if Prime.prime?(N)
#   puts N-1
#   exit
# end
#
# a=0
# b=0
#
# mini = 1_000_000_000_000_0
# source = Math.sqrt(N).to_i+1
# 1.upto(source) do |n|
#   next if N%n!=0
#   a=n
#   b=N/n
#   if ((a-1 + b-1) < mini)
#     mini = a-1 + b-1
#   end
# end
#
# puts mini
#
#
#

# a,b,x=gets.chomp.split(' ').map{|n| n.to_f}

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

def arc057func(a,b)
  [a.to_s.size, b.to_s.size].max
end

ans = 10**10
divisors(N).each do |n|
  candidate = arc057func(n, N/n)
  if candidate < ans
    ans = candidate
  end
end

puts ans

Measured memory_bytes: 2684
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] S = str.toCharArray();
        boolean flag = true;
        for(int i=0; i<3; i++){
            if(S[i] == S[i+1]){
                flag = false;
                break;
            }
        }
        if(flag == true){
            System.out.println("Good");
        }else{
            System.out.println("Bad");
        }
    }
}

Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EDividingChocolate solver = new EDividingChocolate();
        solver.solve(1, in, out);
        out.close();
    }

    static class EDividingChocolate {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int h = in.nextInt();
            int w = in.nextInt();
            int k = in.nextInt();
            int res = Integer.MAX_VALUE;
            char[][] c = new char[h][w];
            int[][] acc = new int[h + 1][w + 1];

            for (int i = 0; i < h; i++) {
                c[i] = in.next().toCharArray();
            }

            for (int j = 0; j <= w; j++) {
                for (int i = 0; i <= h; i++) {
                    if (i > 0 && j > 0) {
                        if (c[i - 1][j - 1] == '1') {
                            acc[i][j] = acc[i - 1][j] + acc[i][j - 1] - acc[i - 1][j - 1] + 1;
                        } else {
                            acc[i][j] = acc[i - 1][j] + acc[i][j - 1] - acc[i - 1][j - 1];
                        }
                    } else {
                        acc[i][j] = 0;
                    }
                }
            }

            for (int i = 0; i < Math.pow(2, h - 1); i++) {
                // 必要な情報はc, k, i
                int cmp = func(acc, k, i);
                res = Math.min(res, cmp);
                // System.out.println(cmp);
            }

            out.println(res);

        }

        int func(int[][] acc, int k, int x) {
            ArrayList<Integer> al = new ArrayList<>();
            al.add(0);
            int cnt = 1;
            while (x > 0) {
                if (x % 2 == 1) {
                    al.add(cnt);
                }
                cnt++;
                x /= 2;
            }
            al.add(acc.length - 1);

            // System.out.println(al.toString());

            int res = al.size() - 2;
            int last = 0;

            for (int i = 0; i < acc[0].length; i++) {
                for (int j = 1; j < al.size(); j++) {

                    // System.out.println(al.get(j));
                    // System.out.println(acc[al.get(j)][i]);

                    if ((acc[al.get(j)][i] - acc[al.get(j)][last])
                            - (acc[al.get(j - 1)][i] - acc[al.get(j - 1)][last]) > k) {
                        if (last == i - 1) {
                            return 114514;
                        }
                        res++;
                        last = i - 1;
                        // System.out.println("cut: " + last);
                    }
                }
            }
            return res;
        }

    }
}



Measured memory_bytes: 25816
/*
* @author:  codancer
* @createTime:  2020-04-13, 10:42:14
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
const int N = 2e5+100;
ll dp[N][3];
ll a[N];
int main(){
	int n;
	cin>>n;
	rep(i,1,n){
		cin>>a[i];
	}
	rep(i,1,n){
		rep(j,0,2){
			dp[i][j]=-1e18;
		}
	}
	rep(i,1,3) dp[i][i-1]=a[i];
	rep(i,3,n){
		if(i>2){
			dp[i][0]=max(dp[i][0],dp[i-2][0])+a[i];
			dp[i][1]=max(dp[i][1],dp[i-2][1]+a[i]);
			dp[i][2]=max(dp[i][2],dp[i-2][2]+a[i]);
		}
		if(i>3){
			dp[i][1]=max(dp[i][1],dp[i-3][0]+a[i]);
			dp[i][2]=max(dp[i][2],dp[i-3][1]+a[i]);
		}
		if(i>4){
			dp[i][2]=max(dp[i][2],dp[i-4][0]+a[i]);
		}
	}
	ll ans=-1e18;
	if(n&1){
		ans=max(ans,dp[n][2]);
		if(n>1){
			ans=max(ans,dp[n-1][1]);
		}
		if(n>2){
			ans=max(ans,dp[n-2][0]);
		}
	}else{
		ans=max(ans,dp[n][1]);
		if(n>1) ans=max(ans,dp[n-1][0]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9888
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    n_min = 0
    for i in range(0, n):
        if i == 0:
            count += 1
            n_min = p[i]
            continue
        if p[i] <= n_min:
            count += 1
            n_min = p[i]
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24744
#include <iostream>
#include <vector>
#include <cmath>
#include <bitset>
 
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    
    int N, M, X;
    cin >> N >> M >> X;
    
    vector<int> c(N, 0);
    vector<int> money;
    int** A = new int*[N];
    
    for(int i=0; i<N; i++){
        cin >> c[i];
        A[i] = new int[M];
        for(int j=0; j<M; j++){
            cin >> A[i][j];
        }
    }
    
    
    for(int tmp=0; tmp < (1 << 12); tmp++){
        bitset<12> s(tmp);
    
        int m=0;
        vector<int> skill(M,0);
        for(int i=0; i<12; i++){
            if(i>=N) continue;
            if(s.test(i)==1){
                for(int j=0; j<M; j++){
                    skill[j]+=A[i][j];
                }
                m += c[i];
            }
        }
        
        int count=0;
        for(int i=0; i<M; i++){
            if(skill[i]>=X){
                count+=1;
            }
        }
        
        if(count>=M){
            money.push_back(m);
        }
    }
    
    if(money.size() > 0){
        int ans=10000000;
        for(int i=0; i<money.size(); i++){
            ans=min(ans, money[i]);
        }
        cout << ans << endl;
    }else{
        cout << "-1" << endl;
    }
    
    for(int i=0; i<N; i++){
        delete A[i];
    }
    delete[] A;
    
    return 0;
}


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

int main(){
	string s,t;
	cin >> s >> t;
	cout << t << s << endl;

	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;

	cin >>n>>k;
	vector<double> dis(n, 1.0/n);
	int at;
	rep(i, n) { at = (i + 1); 
	while(at< k){
		dis[i] /= 2.0;
		at *= 2;
	}
	}
	double ans = 0.0;
	rep(i, n) { ans += dis[i]; }
	printf("%.11lf\n", ans);
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

int n,m,a[100005];
vector<int> adj[100005];

map<int,int> mp[100005];

int main()
{
    cin >> n >> m;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=m; i++)
    {
        int x,y;
        cin >> x >> y;
        if (mp[x][y] || mp[y][x]) continue;
     //   mp[x][y]=1 , mp[y][x]=1;
     //   cout << x << ' ' << y << " ha\n";
        adj[x].push_back(y) , adj[y].push_back(x);
    }

    int ans=0;
    for(int i=1; i<=n; i++)
    {
        bool ni=0;
        for(auto ch : adj[i])
        {
            if (a[ch] >= a[i]) ni=1;
        }
        ans += (!ni);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 23196
#include <iostream>

int main(){
  
  int N =0;
  std::string S;
  
  std::cin >> N >> S;
  
  // 一つ目の条件が当てはまるものを数える
  int64_t R = 0;
  int64_t G = 0;
  int64_t B = 0;
  for(char c : S){
    if(c == 'R'){
      R++;
    }
    else if(c == 'G'){
      G++;
    }
    else{
      B++;
    }
  }
  int64_t first_sum = R*G*B;
  
  // 二つ目の対象に当てはまらないものを数える
  int64_t second_sum = 0;
  
  if( 3 <= N ){
    for(int i = 0; i < N-2; i++){
      for(int j = i+1; j < N-1; j++){
        int k = 2*j-i;
        if( N <= k ){
          continue;
        }
        else if(S.at(i) != S.at(j)){
          if(S.at(i) != S.at(k)){
            if(S.at(j) != S.at(k)){
              second_sum++;
            }
          }
        }
      }
    }
  }
  
  std::cout << first_sum-second_sum << std::endl;
  
  return 0;
}

Measured memory_bytes: 3192