akhauriyash/Code-Regression huggingface dataset:
/*input
8
5 4 8 1 2 6 7 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn],b[maxn];

set<int> st;

int main()
{
	IOS;
	ll n;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) a[i]--;
	REP(i,n) b[a[i]]=i;

	st.insert(-1);
	st.insert(n);

	ll ans=0;

	for(int i=0;i<n;i++){
		auto it=st.lower_bound(b[i]);
		ll r=*it,l=*prev(it);
		ans+=(b[i]-l)*(r-b[i])*i;
		st.insert(b[i]);
	}
	cout<<ans+n*(n+1)/2;

	return 0;
}


Measured memory_bytes: 13312
import math
import numpy as np

N, D = map(int, input().split())
X = [np.array(list(map(int, input().split()))) for _ in range(N)]
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        distance = np.linalg.norm(X[i] - X[j], ord=2)
        if distance.is_integer():
            ans += 1
print(ans)


Measured memory_bytes: 12444
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;


int main(){

    int N;
    cin >> N;



    vector<int> data(N,0);
    map<int, int> kosuu{};
    
    for(int i=0;i<N;i++){
        cin >> data[i];
        if(kosuu[data[i]]==0){
            kosuu[data[i]]=1;
        }else{
            kosuu[data[i]]++;
        }
    }

    map<int, long> pairs{};
    map<int, long> pairs2{};
    int key;
    long value;
    long tmp,tmp2;
    long sumpair=0;
    for(auto itr = kosuu.begin(); itr != kosuu.end(); ++itr){
        key = itr->first;
        value = itr->second;
        tmp = value>1 ? value*(value-1)/2 : 0;
        tmp2 = value>2 ? (value-1)*(value-2)/2 : 0;
        //cout << tmp << ',' << tmp2 << endl;
        pairs[key] = tmp;
        pairs2[key] = tmp2;
        sumpair += tmp;
    }

    for(int i=0;i<N;i++){
        cout << sumpair-pairs[data[i]]+pairs2[data[i]] << endl;
        //cout << sumpair <<',' << pairs[data[i]] << ',' << pairs2[data[i]] << ',' << kosuu[data[i]] << endl;
    }

    return 0;
}


Measured memory_bytes: 24064
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main()
{
	long A,B,i,j;
	cin >> A >>B; 
	j=1;
	for(i=1;i<=min(A,B);i++){
		if(A%i==0&&B%i==0){
			j=i;
			j=max(j,i);
		}
	}		
	cout<<A*B/j<<endl;

}


Measured memory_bytes: 256
//R<3S
#include <bits/stdc++.h>
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);}
#define inset(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);}
#define ll long long
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {

	int n,k,temp;
	cin>>n>>k;
	mii m;
	rep(i,k)
	{
		int d;cin>>d;
		rep(j,d)
		{
			cin>>temp;m[temp]++;
		}
	}
	int cnt=0;
	repA(i,1,n)if(m[i]==0)cnt++;cout<<cnt;
	

  }



signed main()
{
   FAST
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


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

int main() {
    int shift;
    cin>>shift;
	string s;
	cin>>s;
	string s1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int c=0;
	if(shift==0) {
        cout<<s;
    } else {
        for(int i=0; i<s.length(); i++) {
            int index = s1.find(s[i]); 
            s[i]=s1[(index+shift)%26];
        }
        cout<<s;
    }
	return 0;
}

Measured memory_bytes: 256
int main() {
  int n;
  scanf("%d", &n);
  
  char s[n], t[n];
  scanf("%s %s", &s, &t);
  
  for (int i = 0; i < n; i++) {
    printf("%c%c", s[i], t[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long int
#define M 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
const double pi = acos(-1.0);
#define F  first
#define S  second
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
const int INF = 1e18L+5;
const int LG = 20;
const int N = 1e5+9;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int power(int x,int y){if(x==0)return 0;int res=1;while(y>0){if(y%2==1)res=(res*x)%M;x=(x*x)%M;y=y/2;}return res;}
bool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}
int32_t main()
{
	//cout.precision(15);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int k;
		cin>>k;
		string s;
		cin>>s;
		if(s.size()<=k)
		cout<<s<<endl;
		else
		{
			for(int i=0;i<k;i++)
			cout<<s[i];
			cout<<"..."<<endl;
		}
	}
}



Measured memory_bytes: 3644
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
total = []
for v in itertools.permutations(l):
    nl = list(v)
    t = 0
    for num in range(len(nl)):
        if(num != 4 and nl[num] % 10 != 0):
            t += int(nl[num] / 10) * 10 + 10
        else:
            t += nl[num]
    t = int(t)
    total.append(t)
print(min(total))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M,R;
    cin >>N>>M>>R;
    vector<vector<ll>>dp(N,vector<ll>(N,INF));
    vector<ll>r(R);
    rep(i,R)cin>>r[i];
    rep(i,M){
        ll a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        dp[a][b]=c;
        dp[b][a]=c;
    }
    rep(i,N){
        dp[i][i]=0;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                chmin(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    /*rep(i,N){
        rep(j,N){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    vector<ll> a(R);
    rep(i,R){
        a[i] = i;
    }
    ll ans=INF;
    do {
    ll now=0; 
    rep(i,R-1) {
        now+=dp[r[a[i]]-1][r[a[i+1]]-1];
        
    }
    //cout<<now<<endl;
    chmin(ans,now);
    }while(next_permutation(a.begin(),a.end()));

    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3956
ball = input().split(" ")
S = str(ball[0])
T = str(ball[1])
ball_number = input().split(" ")
A = int(ball_number[0])
B = int(ball_number[1])
U = str(input())
if U == S:
	A -= 1
else:
	B -= 1
print(str(A) + " " + str(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k <= a){
        ans += k;
    }
    else if(k <= a+b){
        ans += a;
    }
    else{
        ans += a;
        k -= a+b;
        ans -= k;
    }
    cout << ans << endl;
    system("pause");
}


Measured memory_bytes: 3700
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
//const int mod=read();
const int mod=1e9+7;
ll l,r,k;

bool judge(ll x){
if (!x) return 1;
ll ans=r/x-l/x;
if (l%x==0) ans++;
write(ans),pl;
return ans>=k;
}

struct juzhen{
ll m[3][3];
void clearit(){
  memset(m,0,sizeof m);
  m[1][1]=m[2][2]=1;
  }
void clear(){memset(m,0,sizeof m);}
juzhen operator *(const juzhen &b) const{
  int i,j,k;
  juzhen ans;ans.clear();
  for (i=1;i<3;++i){
    for (j=1;j<3;++j){
      for (k=1;k<3;++k){
        ans.m[i][j]=(ans.m[i][j]+m[i][k]*b.m[k][j])%mod;
	    } 
	  }
    }return ans;
  }
};

juzhen operator ^(juzhen a,ll b){
juzhen c;c.clearit();
for (;b;b>>=1,a=a*a) if (b&1) c=c*a;
return c;
}

int main(){
//read(l),read(r),read(k);
//ll le=0,ri=1e15;
//for (;le<=ri;){
//  ll mid=le+ri>>1;
//  judge(mid)?le=mid+1:ri=mid-1;
//  }
//cout<<ri<<endl;
//juzhen tmp,ans;
//tmp.clear();
//tmp.m[1][1]=tmp.m[1][2]=tmp.m[2][1]=1;
//ans.clearit();
//tmp=tmp^(ri-1);
//write(((ans*tmp).m[1][1]+mod)%mod);
ll x;
read(l),read(r),read(x);
judge(x);
}
/*
gcd(F(a),F(b))=F(gcd(a,b));
*/

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    int l=0, m=0, u=0;
    rep(i, N){
        if(P[i] <= A) l++;
        if(A+1 <= P[i] && P[i] <= B) m++;
        if(B+1 <= P[i]) u++;
    }

    cout << min({l,m,u}) << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize, a: usize, b: usize,
    }
    let mut ans = 0;
    for i in 0..=n {
        let s = i.to_string();
        let mut sum = 0;
        for c in s.chars() {
            sum += c as usize - 48;
        }
        if a <= sum && sum <= b {
            ans += i;
        }
    }

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



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

using namespace std;

int main()
{
    int N ,A, B;
    cin>>N>>A>>B;
    
    int ans = 0;
    for(int n = 1; n <= N; n++){
        int t = 0;
        for(int i = 10000; 1 <= i; i /= 10){
            t += (n % (i*10)) / i;
        }
        if(A <= t && t <= B){
            ans += n;   
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}


int main(){
  //cout << fixed << setprecision(10);
  string s;cin >> s;
  if(s[1]=='R')cout << "ABC";
  else cout << "ARC";
  cout << endl;
  
  return 0;
}

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

int main() {
    long H;
    cin >> H;
    long hhh = H;
    long count = 0;

    while(hhh != 1){
        hhh /= 2;
        count ++;
    }

    long ans = 1;
    for(long i = 0; i < count; i++){
        ans = ans * 2 + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll ans = c - (a - b);
  if (ans < 0) {
    cout << 0 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long a[n];
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }
    long long ans=0;
    sort(a,a+n);
    for(long long i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            ans=1;
            break;
        }
    }
    if(ans==1){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
ll n,k;
cin>>n>>k;
vector<double>p(n+1),q(n+1),r(n+1),s(n+1);
rep(i,n)cin>>p[i];
rep(i,n) q[i]=0.50+0.50*p[i];
for(ll i=0; i < n; i++) s[i+1] = s[i] + q[i+1];
for(ll j=0; j<=n-k;j++) r[j]=s[j+k]-s[j];
 sort(r.begin(), r.end()); 
 reverse(r.begin(),r.end());
 printf("%lf",r[0]);

return 0;
}

Measured memory_bytes: 6528
from operator import mul
from functools import reduce

def combinations_count(n, r):
    if n<r: return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    N,M = map(int, input().split())
    ans = combinations_count(M,2) + combinations_count(N,2)
    print(ans)

main()


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

int main()
{
  int num_employee;
  cin >> num_employee;
  vector<int> employees(num_employee);
  for (int i = 0; i < num_employee - 1; i++)
  {
    int num_boss;
    cin >> num_boss;
    employees.at(num_boss - 1)++;
  }
  for (auto employee : employees)
  {
    cout << employee << endl;
  }
}


Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int grid[3][3];
	int a[3];
	int b[3];

	for (int i = 0; i < 3;i++) {
		for (int j = 0; j < 3;j++) {
			cin >> grid[i][j];
		}
	}

	//for (int i = 0; i < 3; i++) {
	//	for (int j = 0; j < 3; j++) {
	//		cout << grid[i][j];
	//	}
	//	cout << endl;
	//}

	//cout << grid[1][0] - grid[0][0] << ",";
	//cout << grid[1][1] - grid[0][1] << ",";
	//cout << grid[1][2] - grid[0][2] << endl;

	//cout << grid[2][0] - grid[0][0] << ",";
	//cout << grid[2][1] - grid[0][1] << ",";
	//cout << grid[2][2] - grid[0][2] << endl;
	//
	//cout << grid[2][0] - grid[0][0] << endl;
	//cout << grid[2][1] - grid[0][1] << endl;
	//cout << grid[2][2] - grid[0][2] << endl;

	//解答のやつそのまま
	if (grid[1][0] - grid[0][0] == grid[1][1] - grid[0][1] && grid[1][0] - grid[0][0] == grid[1][2] - grid[0][2] && grid[2][0] - grid[0][0] == grid[2][1] - grid[0][1] && grid[2][0] - grid[0][0] == grid[2][2] - grid[0][2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = arr[0];
    int t = arr[1];
    var s = Enumerable.Repeat(0, n).Select(x => Console.ReadLine().Split().Select(int.Parse).ToArray());
    var lst = new List<int>();
    foreach (var i in s) {
      if (i[1] > t) continue;
      lst.Add(i[0]);
    }
    Console.WriteLine(lst.Count > 0 ? lst.OrderBy(x => x).First().ToString() : "TLE");
  }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
bool e[10][10]; //bool型の10x10の多次元配列e
int m, n; //int型のmとn
int count_for, count2_if, count_do = 0;
int ar[8] = {1, 2, 3, 4, 5, 6, 7, 8}; //int型の配列ar。要素は8つで1~8
bool has() //bool型のhas()関数
{
  for (int i = 0; i < n - 1; i++) {
    // cout << "ar[";
    // rep(j, 8) cout << ar[j];
    // cout <<  "]" << endl;
    // cout << "配列e: " << ar[i] << "," << ar[i + 1] << endl;
    if (!e[ar[i]][ar[i + 1]]) {
      return 0;
    }
  }
  return 1;
}
int main()
{
  cin >> n >> m;
  rep(i, m) //m回繰り返す。
  {
    int a, b;
    cin >> a >> b;
    e[a][b] = e[b][a] = 1; //多次元配列eのab番目、ba番目に1を入れてく
  }
  int ans = 0;
  do //条件式の前に一度実行
  {
    if (has()) //has()から1がreturnされたら
      ans++; //ans加算
  } while (next_permutation(ar + 1, ar + n)); //ソート済みコンテナクラスの範囲 （first, last) を引数で受け取り、その範囲の要素の次の順列を生成し、arに代入。順列が生成されるうちはtrue。2~8の組み合わせ分has()を繰り返す。最大で5040回
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main(a, b, c, k):
    total = 0

    a_k_min = min(a, k)
    total += a_k_min
    k -= a_k_min

    if k == 0:
        return total

    b_k_min = min(b, k)
    k -= b_k_min

    if k == 0:
        return total

    c_k_min = min(c, k)
    return total - c_k_min


if __name__ == '__main__':
    a, b, c, k = tuple(map(int, input().split(' ')))
    print(main(a, b, c, k))


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

int main(){
    string str;
    int m, h;
    while (1){
        cin >> str;
        if (str == "-") break;
        cin >> m;
        for (int i=0; i<m; i++){
            cin >> h;
            str += str.substr(0, h);
            str.erase(0, h);
        }
        cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
class Main{
    public static void main(String[] a){
         for(int i=1;i<=9;i++){
              for(int j=1;j<=9;j++){
System.out.print(i);
System.out.print('x');
System.out.print(j);
System.out.print('=');
System.out.println(i*j);
}
}
    }
}


Measured memory_bytes: 24180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int compress(vector<int> &x,int w){
    vector<int> sx;
    for(int i=0;i<(int)x.size();++i){
        for(int d=-2;d<=2;++d){
            int t=x[i]+d;
            if(t>=0&&t<w) sx.push_back(t);
        }
    }
    sort(sx.begin(),sx.end());
    sx.erase(unique(sx.begin(),sx.end()),sx.end());
    for(int i=0;i<(int)x.size();++i){
        x[i]=lower_bound(x.begin(),x.end(),x[i])-x.begin();
    }
    return (int)sx.size();
}
int main(){
    ll x,y;cin>>x>>y;
    if(abs(x-y)<=1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
    return 0;
}

Measured memory_bytes: 26524
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int main(){
  int n,m;

  cin >> n >> m;

  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> x = vector<int>(m);

  REP(i,m){
    cin >> x[i];
  }

  sort(x.begin(),x.end());

  vector<int> l = vector<int>(m-1);

  REP(i,m-1){
    l[i] = x[i+1] - x[i];
  }

  sort(l.begin(),l.end());

  int ans = x[m-1] - x[0];

  REP(i,n-1){
    ans -= l[m - 2 - i];
  }


  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits//stdc++.h>
using namespace std;
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(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(25);
    
    int H,W;
    cin >> H >> W;
    char temp;
    int c[H][W];
    int flag[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> temp;
            if(temp == '.'){
                c[i][j] = 0;
            }
            if(temp == '#'){
                c[i][j] = -1;
            }
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            flag[i][j] = 1e9 + 10;
        }
    }


    int ans = 0;
    queue<int> x,y;
    //多点スタート
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(c[i][j] == -1){
                flag[i][j] = 0;
                x.push(j);
                y.push(i);
            }
        }
    }

    while(!y.empty()){
        int nx = x.front();
        int ny = y.front();
        x.pop();
        y.pop(); 
        for(int i = 0; i < 4; i++){
            int ry = ny + dy[i], rx = nx + dx[i];
            if(ry < 0 || ry >= H || rx < 0 || rx >= W) continue;
            if (flag[ry][rx] > flag[ny][nx] + 1){
                flag[ry][rx] = flag[ny][nx] + 1;
                x.push(rx);
                y.push(ry);
            }
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(flag[i][j] >= ans){
                ans = flag[i][j];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int h,n; cin >> h >> n;
  vi a(n),b(n); rep(i,n) cin >> a[i] >> b[i];
  const int INF = 1001001001;
  vector<vi> dp(n+1,vi(h+1,INF));
  dp[0][0] = 0;
  rep(i,n) rep(j,h+1){
    chmin(dp[i+1][j],dp[i][j]);
    int next_j = min(h,j+a[i]);
    chmin(dp[i+1][next_j],dp[i+1][j]+b[i]);
  }
  cout << dp[n][h];
  cout << "\n";
  return 0;
}


Measured memory_bytes: 42520
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int p[100000],a[100000],b[100000],c[100000],tetu[100001];
int main(void)
{
	int i,j,n,m;
	long long int sum[100001],kip,ic,kin;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++) scanf("%d",&p[i]);
	for(i=1;i<n;i++) scanf("%d %d %d",&a[i],&b[i],&c[i]);
	for(i=0;i<m;i++) tetu[i]=0;
	for(i=0;i<m-1;i++) {
		if(p[i]>p[i+1]) {
			tetu[p[i+1]]++;
			tetu[p[i]]--;
		}
		else {
			tetu[p[i]]++;
			tetu[p[i+1]]--;
		}
	}
	for(i=0;i<n;i++) sum[i]=0;
	for(i=1;i<n;i++) sum[i]+=sum[i-1]+tetu[i];
    kin=0;
	for(i=1;i<n;i++) {
		kip=(long long)a[i]*sum[i];
		ic=(long long)c[i]+(long long)b[i]*sum[i];
		kin+=min(kip,ic);
	}
	printf("%lld\n",kin);
	return 0;
}

Measured memory_bytes: 3756
t = int(input())
point_l = [0 for i in range(t)]
for i in range(int(t*(t-1)/2)):
    tmp = [int(x) for x in input().split()]
    if tmp[2] > tmp[3]:
        point_l[tmp[0]-1] += 3
    elif tmp[3] > tmp[2]:
        point_l[tmp[1]-1] += 3
    elif tmp[2] == tmp[3]:
        point_l[tmp[0]-1] += 1
        point_l[tmp[1]-1] += 1

rank_l = [0 for i in range(t)]
rank = 1
for l in sorted(point_l, reverse=True):
    dup = point_l.count(l)
    for j in range(dup):
        rank_l[point_l.index(l)] += rank
        point_l[point_l.index(l)] = -1
    rank += dup

for l in rank_l:
    print(l)

Measured memory_bytes: 5632
S = input()
i = 0
start = 0
while True:
    if S[i] == "A":
        start = i
        break
    i += 1

i = -1
end = 0
while True:
    if S[i] == "Z":
        end = i + 1
        break
    i -= 1

if end < 0:
    print(len(S[start:end]))
else:
    print(len(S[start:]))

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,x=0;
   cin>>n;
   ll a[n];
   for(int i=0;i<n;i++){
    cin>>a[i];
     if(a[i]==0)
        x++;
}
if(x>0)
    return cout << 0 << endl,0;
   ll pro=1;
   for(int i=0;i<n;i++){
    if(a[i]<=1000000000000000000/pro)
        pro*=a[i];
    else
        return cout <<-1 << endl,0;
    }
   cout << pro << endl;

    return 0;

}


Measured memory_bytes: 4364
import java.io.BufferedReader;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = (a+b+1)/2;
		System.out.println(Math.round(x));
	}
}

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

using namespace std;

int main(void) {
	int a, b, num, i, ans = 0;
	cin >> num >> b;
	vector<int> d(num - 1, 0);
	for (i = 0; i < num - 1; i++) {
		scanf("%d", &a);
		d[i] = a - b;
		b = a;
	}
	for (i = 0; i < num - 1; i++) {
		if (d[i] == 0)
			continue;
		if (d[i] > 0) {
			while (i < num - 1 && d[i] >= 0)
				i++;
			if (i < num - 1)
				ans++;
		}
		else {
			while (i < num - 1 && d[i] <= 0)
				i++;
			if (i < num - 1)
				ans++;
		}
	}
	printf("%d\n", ans + 1);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);


int main(){
  double a,b;
  cin >> a >> b;
  for(double i=1;i<=10000;i++){
    if(floor(i*1.08)-i==a && floor(i*1.1)-i==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=10010;
string dp[N];
int x,b[9]={2,5,5,4,5,6,3,7,6};
vector<int> A;
void cmp(string &a,string b)
{
  if(a=="-") a=b;
  else if(a.size()<b.size()) a=b;
  else if(a.size()==b.size()) if(a<b) a=b;
}
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++) cin>>x,A.push_back(x);
  for(int i=0;i<n;i++) dp[i]="-";
  dp[0]="";
  for(int i=0;i<=n;i++)
  {
    if(dp[i]=="-") continue;
    for(auto a:A) cmp(dp[i+b[a-1]],dp[i]+(char)('0'+a));
  }
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 45056
# coding: utf-8
from collections import defaultdict

def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    H, W = ILI()
    count = defaultdict(int)
    for __ in range(H):
        sen = str(input())
        for i in range(W):
            count[sen[i]] += 1
    return H, W, count


def solve(H, W, count):
    odd = 0
    num_2 = 0
    num_4 = 0
    for val in count.values():
        div_2, mod_2 = divmod(val, 2)
        odd += mod_2
        div_2 *= 2
        div_4, mod_4 = divmod(div_2, 4)
        num_4 += div_4 * 4
        num_2 += mod_4
    ans = 0
    if H % 2 == 0:
        if W % 2 == 0:
            if odd == 0:
                if num_4 == H * W:
                    ans = "Yes"
                else:
                    ans = "No"
            else:
                ans = "No"
        else:
            if odd != 0:
                ans = "No"
            else:
                if num_2 > H:
                    ans = "No"
                else:
                    ans = "Yes"
    else:
        if W % 2 == 0:
            if odd != 0:
                ans = "No"
            else:
                if num_2 > W:
                    ans = "No"
                else:
                    ans = "Yes"
        else:
            if odd != 1:
                ans = "No"
            else:
                if num_2 > (W - 1) + (H - 1):
                    ans = "No"
                else:
                    ans = "Yes"
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


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

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    for(int i = 0; i < N; i++){
        cin >> P.at(i);
    }
    vector<int> Q(N);
    for(int i = 0; i < N; i++){
        cin >> Q.at(i);
    }
    vector<int> A(N), B(N);
    for(int i = 1; i < N + 1; i++){
        A.at(i - 1) = i;
        B.at(i - 1) = i;
    }
    int count1 = 0, count2 = 0;
    do{
        if(A != P){
            count1++;
        }
        else{
            break;
        }
    } while(next_permutation(A.begin(), A.end()));

    do{
        if(B != Q){
            count2++;
        }
        else{
            break;
        }
    } while(next_permutation(B.begin(), B.end()));

    
    cout << abs(count1 - count2) << endl;

    
}

Measured memory_bytes: 256
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    T, X = map(int, sys.stdin.readline().split())
    print(T/X)


Measured memory_bytes: 5328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a[4];
	a[0]=s[0]-'0';a[1]=s[1]-'0';
	a[2]=s[2]-'0';a[3]=s[3]-'0';
	int m1=a[0]*10+a[1];
	int m2=a[2]*10+a[3];
	if(!m2||!m1){
		if(!m1&&m2!=0){
			if(m2<=12){
				cout<<"YYMM";
			}
			else{
				cout<<"NA";
			}
		}
		//cout<<"NA";
		if(!m2&&m1!=0){
			if(m1<=12){
				cout<<"MMYY";
			}
			else{
				cout<<"NA";
			}
		}
		if(m1==0&&m2==0){
			cout<<"NA";
		}
	}
	else{
		if(m2<=12){
			if(m1<=12){
				cout<<"AMBIGUOUS";
			}
			else{
				cout<<"YYMM";
			}
		}
		else{
			if(m1<=12){
				cout<<"MMYY";
			}
			else{
				cout<<"NA";
			}
		}
	}
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e3+5;

int main(){
    int A,B;
    cin >> A >> B;
    cout << 6 - A - B << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	int n,k=0,b[205]={0},sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(i%j==0)
			{
				b[i]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
		if(b[i]==8&&i%2!=0)
			sum++;
	printf("%d\n",sum);
}

Measured memory_bytes: 256
import sys

input = sys.stdin.buffer.readline


class SegmentTree:
    ele = 0
    func = max
    # SEG木は1-index
    # Aに関しては0-index

    def __init__(self, n):  # Aは0-idx
        self.n = n
        self.num = 2 ** ((self.n - 1).bit_length())
        self.SEG = [self.ele] * (2 * self.num)

    def search(self, idx):
        return self.SEG[idx + self.num]

    def initialize(self, A):
        for i in range(self.n):
            self.SEG[i + self.num] = A[i]
        for i in range(self.num - 1, 0, -1):
            self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1])

    # 1点更新
    def set(self, idx, val):
        idx += self.num
        self.SEG[idx] = val
        idx //= 2
        while idx:
            self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1])
            idx //= 2

    # 区間取得
    def query(self, left, right):
        # 開区間
        resleft = self.ele
        resright = self.ele
        left += self.num
        right += self.num
        while right - left > 0:
            if left % 2 == 1:
                resleft = self.func(resleft, self.SEG[left])
                left += 1
            if right % 2 == 1:
                right -= 1
                resright = self.func(resright, self.SEG[right])
            left //= 2
            right //= 2
        return self.func(resleft, resright)


n, k = map(int, input().split())
ans = 0
ST = SegmentTree(3000001)
for _ in range(n):
    val = int(input())
    lower = val - k
    lower = max(lower, 0)
    upper = val + k
    upper = min(upper, 3000000)
    temp = ST.query(lower, upper + 1) + 1
    ST.set(val, temp)
    ans = max(ans, temp)
print(ans)


Measured memory_bytes: 136084
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define pr(a) printf("%d", a)
#define scll(x) scanf("%I64d", &x)
#define prll(x) printf("%I64d", x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define print(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef vector<int> vi;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const double PI = acos(-1.0);
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const double EPS = -1e-2;
const ll mod = ll(1e9 + 7);
const int N = 2000 + 5;

//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent

int n, m;
char arr[1001][1001];
int mem[1001][1001];
bool valid(int i, int j)
{
	return i >= 0 && j >= 0 && i < n && j < m;
}
int solve(int i = 0, int j = 0)
{
	if (!valid(i, j) || arr[i][j] == '#')
		return 0;

	if (i + 1 == n && j + 1 == m)
		return 1;

	int &ret = mem[i][j];
	if (~ret)
		return ret;
	ret = 0;
	ret += solve(i + 1, j)%mod;
	ret += solve(i, j + 1)%mod;
	return ret%mod;
}
int main()
{
	Ma7moud_7amdy;
	//Open_Sesame;
	cin >> n >> m;
	clr(mem, -1);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	cout << solve();
}


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

using namespace std;

int main(){
    lli h,w,count=0;
    char a;
    string ans;
    lli i,j;
    cin>>h>>w;
    rep(i,0,h){
        rep(j,0,w){
            cin>>a;
            if(a=='#'){
                count++;
            }
        }
    }
    if(count==w+h-1){
        ans="Possible";
    }
    else{
        ans="Impossible";
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[][] values = new int[n][3];
        for(int i = 0 ; i < n ; i++){
            values[i][0] = scan.nextInt();
            values[i][1] = scan.nextInt();
            values[i][2] = scan.nextInt();
        }

        int[][] cache = new int[n+1][3];

        for(int i = 0 ; i < n ; i++){
            cache[i+1][0] = Math.max(values[i][0]+cache[i][1], values[i][0]+cache[i][2]);
            cache[i+1][1] = Math.max(values[i][1]+cache[i][0], values[i][1]+cache[i][2]);
            cache[i+1][2] = Math.max(values[i][2]+cache[i][0], values[i][2]+cache[i][1]);
        }
        System.out.println(Math.max(Math.max(cache[n][0], cache[n][1]), cache[n][2]));
    }
}

Measured memory_bytes: 98376
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<string> mp(n);
	for (int i=0; i<n; i++) cin >> mp[i];
	int nn = 1<<n;
	int mm = 1<<m;
	int ans = 0;
	for (int i=0; i<nn; i++) {
		for (int j=0; j<mm; j++) {
			int cur = 0;
			for (int r=0; r<n; r++) {
				if (i & (1<<r)) continue;
				for (int c=0; c<m; c++) {
					if (j & (1<<c)) continue;
					cur += (mp[r][c] == '#');
				}
			}
			if (cur == k) ans++;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	printf("%d\n",N*N*N);

	return 0;
}


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

string s;
ll n,rez=1000000000;

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

    cin>>s;
    n=s.size();
    rez=n;
    for(ll i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
            rez=min(rez,max(i,n-i));
    }

    cout<<rez<<endl;

    return 0;
}


Measured memory_bytes: 3748
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, S[20], D[20], V[20];
double dp[1 << 15][15];
vector<int> vec[1 << 15][15];
 
signed main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> S[i] >> D[i] >> V[i];
    }

    fill(dp[0], dp[1<<N], INF);
    dp[0][0] = 0;

    for(int bit=0; bit<(1<<N); bit++) {
        for(int k=0; k<N; k++) {
            if(dp[bit][k] == INF) continue;

            int weight = 0;
            for(int i=0; i<N; i++) {
                if(bit >> i & 1) weight += V[i] * 20;
            }
            for(int i=0; i<N; i++) {
                if(bit >> i & 1) continue;
                else {
                    int nbit = bit | (1 << i);
                    int pre = (bit ? D[k] : 0);
                    int dist = abs(D[i] - pre);

                    double cost = dist / (2000.0 / (70 + weight));
                    if(dp[nbit][i] > dp[bit][k] + cost) {
                        dp[nbit][i] = dp[bit][k] + cost;
                        vec[nbit][i] = vec[bit][k];
                        vec[nbit][i].push_back(S[i]);
                    }
                }
            }
        }
    }
    
    vector<int> ans;
    double rec = INF;
    for(int i=0; i<N; i++) {
        if(rec > dp[(1<<N)-1][i]) {
            rec = dp[(1<<N)-1][i];
            ans = vec[(1<<N)-1][i];
        }
    }

    for(size_t i=0; i<ans.size(); i++) {
        cout << ans[i] << " \n"[i+1==ans.size()];
    }
    return 0;
}


Measured memory_bytes: 49072