akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a+b);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a-b);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;

int row[]={0,0,1,-1};
int col[]={1,-1,0,0};

bool check(int a,int b,int x,int y)
{
	if(a<0 || b<0 || a>=x || b>=y)
		return false;
	return true;
}

void solve()
{
	int h,w;
	cin>>h>>w;
	int i,j;
	char mat[h][w];
	int dist[h][w];
	int sx,sy,ex,ey;
	cin>>sx>>sy>>ex>>ey;
	sx--,sy--,ex--,ey--;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cin>>mat[i][j];
		}
	}
	
	deque<pr> dq;
	
	for(i=0;i<h;i++)
		for(j=0;j<w;j++)
			dist[i][j]=1e9;
	dist[sx][sy]=0;
	dq.push_front({sx,sy});
	
	while(!dq.empty())
	{
		pr p=dq.front();
		dq.pop_front();
		//cout<<p.fi<<" "<<p.se<<endl;
		if(p.fi==ex && p.se==ey)
		{
			cout<<dist[ex][ey]<<endl;
			return;
		}
		for(i=0;i<4;i++)
		{
			int x=p.fi+row[i];
			int y=p.se+col[i];
			
			if(check(x,y,h,w) && mat[x][y]=='.' && dist[x][y]>dist[p.fi][p.se])
			{
				dq.push_front({x,y});
				dist[x][y]=dist[p.fi][p.se];
			}
		}
		
		for(i=-2;i<=2;i++)
		{
			for(j=-2;j<=2;j++)
			{
				int x=p.fi+i;
				int y=p.se+j;
				if(check(x,y,h,w) && mat[x][y]=='.' && dist[x][y]>(dist[p.fi][p.se]+1))
				{
					dq.push_back({x,y});
					dist[x][y]=dist[p.fi][p.se]+1;
				}
			}
		}
		
	}
	cout<<"-1"<<endl;
	
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 12404
#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[i];
    }
    auto b=a;
    sort(a.begin(),a.end());
    for(auto i:b){
        if(i==a.back())cout<<a[n-2]<<endl;
        else cout<<a.back()<<endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	vector<vector<ld>> dp(n,vector<ld>(n,0));
	REP(i,n) {
		REP(j,n) {
			if(j==0) {
				ll sum=0;
				REP(k,i+1) {
					sum+=a[k];
				}
				dp[i][j]=sum;
				continue;
			}
			if(j>i) {
				dp[i][j]=-INF*INF;
				continue;
			}
			ll sum=0;
			for(ll k=i; k>0; k--) {
				sum+=a[k];
				if(j-(i-k)>=0) dp[i][j]=max(dp[i][j],dp[k-1][j-(i-k)]+sum/(ld)(i-k+1));
			}
			sum+=a[0];
			if(j==i) dp[i][j]=max(dp[i][j],sum/(ld)(i+1));
		}
	}
	ld ans=0;
	FOR(i,n-m,n) ans=max(ans,dp[n-1][i]);
	cout<<fixed<<setprecision(39)<<ans<<endl;
}



Measured memory_bytes: 6856
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i += 2)
  {
    cout << s[i];
  }
  cout << endl;
}

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

typedef struct {
  double x;
  double y;
}P;

int kock(int,P,P);

int main(){
  int n;
  P p1,p2;
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  scanf("%d",&n);
  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}

int kock(int n,P p1,P p2){
  P s,t,u;
    if (n == 0){
        return 0;
      }
else{
    // p1, p2 から s, t, u を計算
      s.x=(2*p1.x+1*p2.x)/3;
      s.y=(2*p1.y+1*p2.y)/3;
      t.x=(1*p1.x+2*p2.x)/3;
      t.y=(1*p1.y+2*p2.y)/3;
      u.x=(t.x-s.x)/2-(t.y-s.y)*sqrt(3)/2+s.x;
      u.y=(t.x-s.x)*sqrt(3)/2+(t.y-s.y)/2+s.y;
    kock(n-1, p1, s);
    printf("%.8f %.8f\n",s.x,s.y);
    kock(n-1, s, u);
    printf("%.8f %.8f\n",u.x,u.y);
    kock(n-1, u, t);
    printf("%.8f %.8f\n",t.x,t.y);
    kock(n-1, t, p2);
  }}



Measured memory_bytes: 2068
#include <stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2108
n,m=gets.split.map &:to_i
a=[]
n.times do
  g=gets.split.map &:to_i
  a<< g
end
h=Hash.new(0)
n.times do |i|
  g=a[i]
  hh=h.dup
  h.each do |e,v|
    if hh[e+g[0]]
      hh[e+g[0]]=[hh[e+g[0]],v+g[1]].max
    else
      hh[e+g[0]]=v+g[1]
    end
  end
  hh[g[0]]=[hh[g[0]],g[1]].max
  h=hh.dup
end
max=0
h.each do |e,v|
  max=[max,v].max if e<=m
end
p max

Measured memory_bytes: 21500
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.replaceAll("BC", "D");
        long cnt = 0;
        long aCnt = 0;
        for(int i = 0; i < s.length(); i++) {
        	if(s.charAt(i) == 'A')
        		aCnt++;
        	else if(s.charAt(i) == 'D')
        		cnt += aCnt;
        	else
        		aCnt = 0;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35084
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,x;
long long int a[100000];
cin >> n >> x;
long long int cnt = 0;
for(int i = 0; i < n; i++){
cin >> a[i];
if(a[i] > x){
cnt += (a[i] - x);
a[i] = x;
}
}
for(int i = 0; i < n-1; i++){
if(a[i] + a[i+1] > x){
cnt += (a[i]+a[i+1]-x);
a[i+1] -= (a[i]+a[i+1]-x);
}
}
cout << cnt << endl;
}


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

int main(){
    int M, K;
    cin >> M >> K;
    int x = 0;
    int maxX = pow(2, M) - 1;
    if(M < 2){
        if(K == 0){
            rep(i, pow(2, M+1)){
            cout << i/2 << " ";
            }
            cout << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(maxX < K){
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    for(int i = 0;i <= maxX; i++){
        if(i == K) continue;
        ans.push_back(i);
    }
    ans.push_back(K);
    for(int i = maxX;i >= 0;i--){
        if(i == K) continue;
        ans.push_back(i);
    }
    ans.push_back(K);

    for(auto i : ans){
        cout << i << " ";
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 4644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back

ll n, ans ;

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

cin >> n;
ans = 1;
rep(i, 1, n){
ans = (ans*i)%mod;
}

cout << ans << endl;




return 0;}


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

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

    int count = 0;
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            count++;
        }
    }
    cout << count <<endl;
    return 0;
}



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

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

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int N; cin >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];
	vector<int> B = A;
	sort(B.begin(), B.end());
	rep(i, N) {
		if (A[i] == B[B.size() - 1])cout << B[B.size() - 2] << endl;
		else cout << B[B.size() - 1] << endl;
	}

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;

int main() {
  int N, X, T;
  cin >> N >> X >> T;

  cout << (N + X - 1) / X * T << endl;

  return 0;
}


Measured memory_bytes: 3540
N = int(input())
count = {}
for _ in range(N):
    s = str(input())
    if s in count.keys():
        count[s] += 1
    else:
        count[s] = 1

max_value = max(count.values())
max_key_list = [kv[0] for kv in count.items() if kv[1] == max_value]
max_key_list.sort()
for key in max_key_list:
    print(key)


Measured memory_bytes: 32096
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

long long max3(long long x, long long y, long long z) {
	return max(max(x, y), z);
}
long long min3(long long x, long long y, long long z) {
	return min(min(x, y), z);
}

int main() {

	int h, w;
	cin >> h>> w;
	
	long long s1, s2, s3;
	long long ans = min(h, w);
	if (w % 3 == 0 || h % 3 == 0) {
		ans = 0;
	}
	else {
		for (long long i = h / 4; i <= h/2;i++) {
			s1 = w*i;

			s2 = (w / 2)*(h - i);
			s3 = (w - w / 2)*(h - i);
			ans = min(ans, max3(s1, s2, s3) - min3(s1, s2, s3));
		}
		for (long long i =w / 4; i <= w/2; i++) {
			s1 = h*i;
			s2 = (h / 2)*(w - i);
			s3 = (h - h / 2)*(w - i);
			ans = min(ans, max3(s1, s2, s3) - min3(s1, s2, s3));
		}
	}
	

	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int l;cin>>l;
  double ans=l*l*l/27.0;
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
double dis1(int n, int x[], int y[]){
    double sum = 0;
    for (int i = 0; i < n; i++){
        sum = sum + abs(x[i] - y[i]);
    }
    return sum;
}
double dis2(int n, int x[], int y[]){
    double sum = 0;
    for (int i = 0; i < n; i++){
        sum = sum + pow(abs(x[i] - y[i]), 2);
    }
    double distance = sqrt(sum);
    return distance;
}
double dis3(int n, int x[], int y[]){
    double sum = 0;
    for (int i = 0; i < n; i++){
        sum = sum + pow(abs(x[i] - y[i]), 3);
    }
    double distance = pow(sum, 1.0 / 3.0);
    return distance;
}
double dis8(int n, int x[], int y[]){
    double max = 0, sum = 0;
    for (int i = 0; i < n; i++){
        sum = abs(x[i] - y[i]);
        if (sum > max){
            max = sum;
        }
    }
    return max;
}
int main(){
    int n, x[1000], y[1000];
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &y[i]);
    }
    printf("%.6lf\n", dis1(n, x, y));
    printf("%.6lf\n", dis2(n, x, y));
    printf("%.6lf\n", dis3(n, x, y));
    printf("%.6lf\n", dis8(n, x, y));
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	string s;
	ll k;
	cin >> s >> k;
	ll n = s.size();
	for (int i = 0; i < n; ++i) {
		if (i == n - 1) {
			s[i] = (s[i] - 'a' + k) % 26 + 'a';
		} else {
			if (s[i] == 'a') continue;
			int to_a = 26 - (s[i] - 'a');
			if (k >= to_a) {
				k -= to_a;
				s[i] = 'a';
			}
		}
	}
	cout << s << endl;
}

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

using namespace std;

#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second
#define ar array

double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=50010;


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1;
//cin>>t;
while(t--){
ll x;
cin>>x;
ll a=7;
a%=x;
ll ans=1;
while(a!=0){
    a*=10;
    a+=7;
    a%=x;
    ans++;
    if(ans==1000001)break;
}
if(ans<1000001)cout<<ans<<"\n";
else cout<<"-1";
}
	return 0;
}


Measured memory_bytes: 3660
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  long long int a,b,x;
  cin>>a>>b>>x; 
  long long int start;
  if(a%x!=0){
    start=a+(x-(a%x));
  }
  else{
    start=a;
  }
  long long int end; 
  if(b%x!=0){
    end=b-(b%x);
  }
  else{
    end=b;
  }
  if(start<=end){    
    cout<<((end-start)/x)+1<<"\n";
  }
  else{
    cout<<0<<"\n";  
  }     
   
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();
        long CD = C*D/gcd(C,D);
        long ans = B -B/C - B/D + B/CD -( A-1 -(A-1)/C- (A-1)/D+(A-1)/CD );
        System.out.println(ans);

//        System.out.println(gcd(15L,20L));
    }

    static long gcd(long a, long b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }


}


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

typedef long long ll;

const int mod = 998244353;

ll fac[200002], fin[200002];
int n, m, k;

ll powe(ll x, ll e) {
	ll r = 1;
	while (e) {
		if (e & 1) r = r * x % mod;
		x = x * x % mod;
		e >>= 1;
	}
	return r;
}

ll inv(ll x) {
	return powe(x, mod - 2);
}

ll choose(int a, int b) {
	if (b < 0 || b > a) return 0;
	return fac[a] * fin[b] % mod * fin[a - b] % mod;
}

int main()
{
    scanf("%d%d%d", &n, &m, &k);
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % mod;
	fin[n - 1] = inv(fac[n - 1]);
	for (int i = n - 2; i >= 0; --i) fin[i] = fin[i + 1] * (i + 1) % mod;

	ll ans = 0;
	// p blocks
	for (int p = 0; p <= k; ++p) {
        // M*(M-1)*choose(n-1,p)
		(ans += choose(n - 1, p) * powe(m - 1, n - 1 - p) % mod * m) %= mod;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6888
#include <bits/stdc++.h>
#include <set>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<vector<int>> children;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
void hukasa(vector<vector<int>> s,vector<vector<int>> table,int &ans,pii frm,int n,int m){
  int x,y;
  tie(x,y) = frm;
  set<pii> se;
  if(x-1 >= 0)se.insert(pii(x-1,y));
  if(x+1 < n)se.insert(pii(x+1,y));
  if(y-1 >= 0)se.insert(pii(x,y-1));
  if(y+1 < m)se.insert(pii(x,y+1));
  for(auto t:se){
    int tx,ty;
    tie(tx,ty) = t;
    if(s.at(tx).at(ty) && table.at(tx).at(ty) == -1){
      table.at(tx).at(ty) = table.at(x).at(y) + 1;
      ans = max(ans,table.at(tx).at(ty));
      hukasa(s,table,ans,t,n,m);
      table.at(tx).at(ty) = -1;
    }
  }
}
void daiku(int frm,vector<vector<pii>> g,vector<int> &cost,int n){
  priority_queue<pii,vector<pii>,greater<pii>> q;
  q.push(pii(cost.at(frm),frm));
  vector<bool> kakutei(n,false);
  while(!q.empty()){
    pii now = q.top();
    q.pop();
    int n1,n2;
    tie(n1,n2) = now;
    if(kakutei.at(n2))continue;
    kakutei.at(n2) = true;
    for(auto t:g.at(n2)){
      int tx,ty;
      tie(tx,ty) = t;
      if(cost.at(tx) > n1 + ty){
        cost.at(tx) = n1 + ty;
        q.push(pii(cost.at(tx),tx));
      }
    }
  }
}
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  int ans = 0;
  for(int i=0;i<k;i++)ans += p.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 3556
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), m = in.nextInt(), X = in.nextInt(), Y = in.nextInt();
		int[] x = new int[n + 1], y = new int[m + 1];
		x[0] = X;
		y[0] = Y;
		for (int i = 1; i <= n; i++) {
			x[i] = in.nextInt();
		}
		for (int i = 1; i <= m; i++) {
			y[i] = in.nextInt();
		}
		Arrays.sort(x);
		Arrays.sort(y);
		if (x[x.length - 1] < y[0]) {
			System.out.print("No ");
		}
		System.out.println("War");
	}
}

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

vector<int> A = {7, 5, 3};

int N;
vector<int> num; //準七五三数を格納
void dfs(int n, int keta, vector<int> &num){
  if( keta == 10 ) return;
  for( int i = 0; i < 3; i++ ){
    n = n*10 + A[i];
    num.push_back(n);
    dfs(n, keta+1, num);
    n /= 10;
  }
}
signed main() {
  cin >> N;
  dfs(0, 0, num);
  int ans = 0;
  for( int i = 0; i < num.size(); i++ ){
    if( num.at(i) > N ) continue;
    bool s = 0;
    bool f = 0;
    bool t = 0;
    int a = num.at(i);
    while( a > 0 ){
      if( a%10 == 7 ) s = 1;
      if( a%10 == 5 ) f = 1;
      if( a%10 == 3 ) t = 1;
      a /= 10;
    }
    if( s && f && t ) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
N = int(input())


def main():
    ans = N

    for i in range(N + 1):
        num = 0
        cur = i

        while 0 < cur:
            num += cur % 6
            cur //= 6

        cur = N - i

        while 0 < cur:
            num += cur % 9
            cur //= 9

        if num < ans:
            ans = num

    print(ans)
    return


main()


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

int main() {
  int a, b; cin >> a >> b;
  //a口電源タップ一個→a-1個増える
  //b口以上にしたい
  rep(i,1000) {
    if (1 + i*(a-1) >= b) {
      cout << i << endl;
      break;
    }
  }
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<int> dp = {};
  dp.resize(n, 0);

  // 累積和
  for (auto i = 0; i < n + 1; i++)
  {
    if (i != 0)
    {
      dp[i] = (dp[i - 1] + i) % MOD;
    }
  }

  ll total = 0;
  for (ll i = k; i < n + 1; i++)
  {
    ll max = dp[n] - dp[n - i];
    ll min = dp[i - 1];
    ll val = max - min + 1;

    total += val;
    total %= MOD;
  }

  if (total < 0)
    total += MOD;

  total += 1;
  total %= MOD;
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3972
from itertools import product

H, W = map(int, input().split())
L = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
S = [[str(_) for _ in input().split()] for _ in range(H)]

for i, j in product(range(H), range(W)):
    if S[i][j] == "snuke":
        break

res = L[j] + str(i+1)
print(res)

Measured memory_bytes: 3064
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int A,B;
  cin >> A >> B;

  for(int x = 1; x <= 10000; x++){
    int ax = x * 0.08;
    int bx = x * 0.10;

    if((ax == A) && (bx == B)){
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include    <algorithm>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int n;
	int w[100];
	cin >> n;
	rep(i, n) cin >> w[i];
	int s1=0, s2=0;
	int ans=1000000;
	rep(i, n)
	{
		for (int j = 0; j <= i; j++) s1 += w[j];
		for (int k = i + 1; k < n; k++) s2 += w[k];
		ans = min(ans, abs(s1 - s2));
		//cout << "i=" << i << " " << s1 << " " << s2 <<"ans "<<ans<< endl;
		s1 = 0; 
		s2 = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
A,B,C=map(int,input().split())
D,E,F=map(int,input().split())
G,H,I=map(int,input().split())
N=int(input())
l=list()
for i in range(N):
  b=int(input())
  l.append(b)

if A in l and B in l and C in l:
  print('Yes')
  exit()

if A in l and D in l and G in l:
  print('Yes')
  exit()
  
if A in l and E in l and I in l:
  print('Yes')
  exit()

if D in l and E in l and F in l:
  print('Yes')
  exit()
  
if G in l and H in l and I in l:
  print('Yes')
  exit()

if B in l and E in l and H in l:
  print('Yes')
  exit()
  
if C in l and F in l and I in l:
  print('Yes')
  exit()
  
if C in l and E in l and G in l:
  print('Yes')
  exit()
  
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int a,b;
	while(true){
		cin>>a>>b;
		if(a == 0 && b == 0)
            break;
		if(a > b)
		cout<<b<<" " <<a<< endl;
		else{
			cout<<a<<" "<<b<< endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3124
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<s.length();i+=2)
            sb.append(s.charAt(i));
        System.out.println(sb);
    }

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


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,a,b,c;cin>>n>>a>>b>>c;

    string s[n];
    rep(i,n) cin>>s[i];

    vector<vector<int>> nxt(n+1,vector<int>(3,INF));
    for(int i=n-1;i>=0;i--){
        rep(j,3) nxt[i][j]=nxt[i+1][j];
        nxt[i][s[i][0]-'A']=i;
        nxt[i][s[i][1]-'A']=i;
    }

    string ans="";

    rep(i,n){
        if(s[i]=="AB"){
            if(a==0 and b==0){
                cout<<"No"<<endl;
                return 0;
            }
            if(a==1 and b==1){
                if(nxt[i+1][0]<nxt[i+1][1]) a++,b--,ans.push_back('A');
                else                        a--,b++,ans.push_back('B');
            }
            else{
                if(a>b){
                    a--,b++;ans.push_back('B');
                }else{
                    a++,b--;ans.push_back('A');
                }
            }
        }
        if(s[i]=="AC"){
            if(a==0 and c==0){
                cout<<"No"<<endl;
                return 0;
            }
            if(a==1 and c==1){
                if(nxt[i+1][0]<nxt[i+1][2]) a++,c--,ans.push_back('A');
                else                        a--,c++,ans.push_back('C');
            }
            else{
                if(a>c){
                    a--,c++;ans.push_back('C');
                }else{
                    a++,c--;ans.push_back('A');
                }
            }
        }
        if(s[i]=="BC"){
            if(b==0 and c==0){
                cout<<"No"<<endl;
                return 0;
            }
            if(b==1 and c==1){
                if(nxt[i+1][1]<nxt[i+1][2]) b++,c--,ans.push_back('B');
                else                        b--,c++,ans.push_back('C');
            }
            else{
                if(b>c){
                    b--,c++;ans.push_back('C');
                }else{
                    b++,c--;ans.push_back('B');
                }
            }
        }
    }


    cout<<"Yes"<<endl;
    for(auto c:ans)cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 12188
#include<stdio.h>

int main(){
  int n,t,min=99999999,cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&t);
    if(min>=t){
      min=t;
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}


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

int main() {
	ll n,w;
	cin >> n>>w;
	ll dp[w+1]={0};

	for(ll i=0; i<n; i++){
		ll val,wt;
		cin >>wt>>val;
		for(ll j=w-wt; j>=0; j--){
			dp[j+wt]= max(dp[j+wt],dp[j]+val);
		}
	}
	ll ans = 0;
	for(ll i=0; i<=w; i++)
		ans = max(ans,dp[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var C = ReadLine()[0];
            WriteLine((char)(C + 1));
        }
    }
}


Measured memory_bytes: 17132
n = int(input())
monster_list = list(map(int, input().split()))
kill_mon = list(map(int, input().split()))

# 配列数を合わせる
kill_mon.append(0)

# 持ち越しパワーの初期化
killed_monster = 0
carry_power = 0
for mons, kill in zip(monster_list, kill_mon):   
    # 全パワーを使い果たす
    if mons >= (kill + carry_power):
        killed_monster += (kill + carry_power)
        # 持ち越しパワーの初期化
        carry_power = 0
    # 余力を残して勝利する
    else:
        killed_monster += mons
        # 前回余力は今回のモンスターにしか使えない。次回のバトルに持ち越せない
        # だから、mons - carry_powerとなる
        # ただ、前回余力が今回モンスターよりも多い場合も考慮するためmax関数を使いマイナス値になることを避ける
        # 前回余力だけで今回バトルに勝利したら、今回パワーをそのまま持ち越せる
        carry_power = kill - max(0, mons - carry_power)
print(killed_monster)

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int n;
    cin >> n;
    
    cout << 800*n - (n/15)*200 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d",&a);
    b=(a/1000)+1;
    c=(b*1000)-a;
    if(c==1000)
    {
        printf("0");
    }
    else
    {
        printf("%d",c);
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }


int main() {
    int N;
    cin >> N;
  N %= 10;
    if(N == 3){
        cout << "bon" << endl;
    }
    else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>

using namespace std;

#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    
    cin >> s;
    
    int ans = 0;
    
    for(auto c : s)
    {
        if(c == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int datamax,datanum;
	int i;
	int num;
	scanf("%d",&datamax);
	for(datanum=1;datanum<=datamax;datanum++) {
		printf("Case %d:\n",datanum);
		scanf("%d",&num);
		for(i=0;i<10;i++) {
			num=(int)(num*num)%100000000;
			num=(num/100)%10000;
			printf("%d\n",num);
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		List<String> listr = new ArrayList<String>();
		for(int i=0; i<n; i++ ) {
			listr.add(sc.next());
		}

		Map<String, Integer> mapr = new LinkedHashMap<String, Integer>();
		for (String s1 : listr) {
			int countb = 0;

			for (String s2 : listr) {
				if(s1.equals(s2)) countb++;
			}
			
			mapr.put(s1, countb);
//			System.out.println(countb);
		}

		int m = sc.nextInt();

		List<String> listb = new ArrayList<String>();
		for(int i=0; i<m; i++ ) {
			listb.add(sc.next());
		}

		Map<String, Integer> mapb = new LinkedHashMap<String, Integer>();
		for (String s1 : listb) {
			int countb = 0;

			for (String s2 : listb) {
				if(s1.equals(s2)) countb++;
			}
			
			mapb.put(s1, countb);
		}

		ArrayList<Integer> arrayList = new ArrayList<Integer>();
		for (String s1 : listr) {
			int r = mapr.get(s1);
			int b;
			if (mapb.containsKey(s1)) {
				b = mapb.get(s1);
			} else {
				b = 0;
			}
			arrayList.add(r-b);
		}

		int result = (Collections.max(arrayList)<0)? 0 : Collections.max(arrayList);
		// 出力
		System.out.println(result);
	}
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(){
    long double N,K;
    cin>>N>>K;
    long double ans=0;
    for(int i=1;i<=N;i++){
        int cnt=0,j=i;
        while(j<K){
            cnt++;
            j*=2;
        }
        ans+=pow(2,-1*cnt);
    }
    ans/=N;
    cout<<fixed<<setprecision(20)<<ans<<endl;
    
}

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

int main() {

    int n;
    cin >> n;

    int h = 0;
    int tmp_num = 0;
    int start_place = 0;
    int max_place = 0;
    int cnt = 0;
    int max_cnt = 0;
    for ( int i = 0; i < n; i++ ) {
        cin >> h;
        if ( h > tmp_num ) {
            if ( cnt >= max_cnt ) {
                max_place = start_place;
                max_cnt = cnt;
            }
            cnt = 0;
            start_place = h;
        }
        else {
            cnt++;
        }
        tmp_num = h;
    }

    if ( cnt >= max_cnt ) {
        cout << cnt << endl;
    }
    else {
        cout << max_cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
mask = n2 - 1

dp = [[a, 0] for a in aaa]


def update(dp, i, k):
    dpi, dpk = dp[i], dp[k]
    if dpk[0] < dpi[0]:
        dpk[1] = max(dpk[0], dpi[1])
        dpk[0] = dpi[0]
    elif dpk[1] < dpi[0]:
        dpk[1] = dpi[0]


for j in range(n):
    b = 1 << j
    c = i = mask ^ b
    while i:
        update(dp, i, i | b)
        i = (i - 1) & c
    update(dp, 0, b)

ans = []
tmp = 0
for a in dp[1:]:
    tmp = max(tmp, a[0] + a[1])
    ans.append(tmp)
print(*ans)


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

int dp[3001][3001];
int n,t,s;
int a[3001],b[3001];
int res=0;
int main(void){
	memset(dp,0,sizeof(dp));
	scanf("%d%d%d",&n,&t,&s);
	for(int i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
	for(int i=0;i<n;i++){
		for(int j=0;j<=t;j++){
			if(j>=b[i]){
				if(j>=s){
					if(j-b[i]>=s)dp[i+1][j]=max(max(dp[i+1][j],dp[i][j]),dp[i][j-b[i]]+a[i]);
					else dp[i+1][j]=max(max(dp[i+1][j],dp[i][j]),dp[i][j-b[i]]);
				}
				if(j<=s)dp[i+1][j]=max(max(dp[i+1][j],dp[i][j]),dp[i][j-b[i]]+a[i]);
			}else dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			if(dp[i+1][j]>res)res=dp[i+1][j];
		}
	}
	printf("%d\n",res);
    return 0;
}

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

#define int long long
#define mod 1000000007
#define p pair<int,int>
#define MAX 1000010

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector <pair<pair<int,int>,int> > v;

    for(int i=0;i<n;i++)
    {
        int x,y,z;
        cin >> x >> y >> z;
        v.push_back({{x,y},z});
    }

    for(int i=0;i<=100;i++)
    {
        for(int j=0;j<=100;j++)
        {
            set <int> s;

            for(auto k:v)
                s.insert(k.second + abs(i-k.first.first) + abs(j-k.first.second));

            for(int k:s)
            {
                if(k != 0)
                {
                    bool flag = true;

                    for(auto l:v)
                    {
                        if(max(0ll,k-abs(i-l.first.first)-abs(j-l.first.second)) != l.second)
                        {
                            flag = false;
                            break;
                        }
                    }

                    if(flag)
                    {
                        cout << i << " " << j << " " << k << endl;
                        return 0;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/13/20 20:47:40
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int x; cin>>x;
  cout << (x^1) << endl;

  return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n + 2];
        for (int i = 1; i <= n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int sum = 0;
        for (int i = 1; i < a.length; i++) {
            int amount = Math.abs(a[i - 1] - a[i]);
            sum += amount;
        }

        int[] minus = new int[n + 2];
        for (int i = 1; i <= n; i++) {
            int left = a[i - 1];
            int right = a[i + 1];
            int center = a[i];
            if ((left < center && right < center)) {
                int max = Math.max(left, right);
                minus[i] = Math.abs(max - center) * 2;
            } else if (center < left && center < right) {
                int min = Math.min(left, right);
                minus[i] = Math.abs(min - center) * 2;
            }
        }

        List<String> list = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            int num = sum - minus[i];
            list.add(Integer.toString(num));
        }

        String result = String.join("\n", list);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 53608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[1010], b[1010], c[1010];
int main() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++) {
		cin >> a[i];
	}
	sort(a, a + x);
	for (int i = 0; i < y; i++) {
		cin >> b[i];
	}
	sort(b, b + y);
	for (int i = 0; i < z; i++) {
		cin >> c[i];
	}
	sort(c, c + z);
	int co = 0;
	set<tuple<long long, int, int, int>> st;
	priority_queue<tuple<long long, int, int, int>> que;
	que.push(make_tuple(a[x - 1] + b[y - 1] + c[z - 1], x - 1, y - 1, z - 1));
	while (co < k) {
		int bo = st.size();
		tuple<long long, int, int, int> t = que.top();
		st.insert(t);
		if (bo != st.size()) {
			long long d = get<0>(t);
			int e = get<1>(t);
			int f = get<2>(t);
			int g = get<3>(t);
			cout << d << endl;
			co++;
			if (e != 0) {
				que.push(make_tuple(d - a[e] + a[e - 1], e - 1, f, g));
			}
			if (f != 0) {
				que.push(make_tuple(d - b[f] + b[f - 1], e, f - 1, g));
			}
			if (g != 0) {
				que.push(make_tuple(d - c[g] + c[g - 1], e, f, g - 1));
			}
		}
			que.pop();
	}
	return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin >> a >> b >> c;
    cout << (abs(c - a) > abs(b - a) ? "A" : "B");
}


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


using namespace std;


vector<vector<long long>> dp;
long long attack[1001];
long long mp[1001];


int main() {
    int H, N;
    cin >> H >> N;
    dp.resize(N + 1, vector<long long>(H + 1, LONG_LONG_MAX / 2));
    for (int i = 1; i <= N; i++) {
        cin >> attack[i] >> mp[i];
    }

    dp[1][1] = mp[1];
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= H; j++) {
            long long a, m;
            a = attack[i];
            m = mp[i];
            dp[i][j] = min({
                    dp[i - 1][j],
                    j - a > 0 ? dp[i - 1][j - a] + m : m,
                    j - a > 0 ? dp[i][j - a] + m : m}
                    );
        }
    }
    cout << dp[N][H] << endl;
}


Measured memory_bytes: 78592
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

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

  int n, x, y;
  cin >> n >> x >> y;

  vector<int> k(n, 0);
  vector<vector<int>> adj(n + 1, vector<int>(n + 1, 0));
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      adj[i][j] = min({adj[i][j - 1] + 1, abs(x - i) + abs(j - y) + 1});
      k[adj[i][j]]++;
    }
  }

  for (int i = 1; i <= n - 1; ++i) {
    cout << k[i] << '\n';
  }
}


Measured memory_bytes: 16000
#include<stdio.h>
int main(void)
{
	int n,m,i,j,k,x,y,co;
	int a[5000],b[5000],cost[5000];
	int size[100],root[100];
	int wk,sum;
	
	while(1)	{
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)	break;
		for(i=0;i<m;i++)	{
			scanf("%d %d %d",&a[i],&b[i],&cost[i]);
		}
		for(i=0;i<m-1;i++)	{
			for(j=i+1;j<m;j++)	{
				if(cost[i]>cost[j])	{
					wk=cost[i];	cost[i]=cost[j];	cost[j]=wk;
					wk=a[i];	a[i]=a[j];	a[j]=wk;	
					wk=b[i];	b[i]=b[j];	b[j]=wk;		
				}
			}
		}
		for(i=0;i<n;i++)	{
			root[i]=i;
			size[i]=1;
		}
		sum=0;
		for(i=0;i<m;i++)	{
			x=a[i];	y=b[i];	co=cost[i];
			while(root[x]!=x)	x=root[x];
			while(root[y]!=y)	y=root[y];
			if(x!=y)	{
				sum+=co;
				if(size[x]>size[y])	{
					root[y]=x;
				}
				else if(size[x]<size[y])	{
					root[x]=y;
				}
				else {
					root[x]=y;
					size[y]++;
				}
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 612