akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
#include <complex>
#define int long long
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
const int N=1e5+10;
struct ppap{int x,v;}a[N];
int n,ans[N];
inline bool cmp(ppap a,ppap b){return a.v>b.v;}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++){
		a[i].v=read();a[i].x=i;
	}
	sort(a+1,a+n+1,cmp);
	int minn=a[1].x;
	for(int i=2;i<=n;i++){
		int rp=a[i-1].v-a[i].v;
		ans[minn]+=(i-1)*rp;
		minn=min(minn,a[i].x);
	}
	ans[minn]+=n*a[n].v;
	for(int i=1;i<=n;i++)writeln(ans[i]);
	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int* A = new int[n];
	for (int i = 0; i < n; i++)
		cin >> A[i];


	void print(int* a, int n);
	print(A, n);

	for (int i = 1; i < n; i++)
	{
		int temp = A[i];
		int j = i - 1;
		while (j >= 0 && temp < A[j])
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = temp;
		print(A, n);
	

	}







	delete[] A;
	return 0;
}


void print(int* a,int n)
{
	for (int i = 0; i < n; i++)
	{
		if (i == n - 1)
			cout << a[i] << endl;
		else
			cout << a[i] << " ";
	}
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5+1;
ll H[N],Dp[N];
signed main(){
   ll n;
   cin>>n;
   for(ll i=0;i<n;i++){
     cin>>H[i+1];
   }
   Dp[1] = 0,Dp[2] = abs(H[2]-H[1]);
   for(ll i=3;i<=n;i++){
     Dp[i] = min(abs(H[i]-H[i-1])+Dp[i-1],abs(H[i]-H[i-2])+Dp[i-2]);
   }
   cout << Dp[n] << '\n';
return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int n;

void dfs(int d, string s, int num) {
  if (d == n) {
    std::cout << s << "\n";
    return;
  }
  rep(i, num) 
    dfs(d+1, s+char('a'+i), num);
  dfs(d+1, s+char('a'+num), num+1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  std::cin >> n;
  string s = "a";
  dfs(1, s, 1);
}


Measured memory_bytes: 1536
def counting_sort(array_b, max_b, array_r, max_r):
    bucket = {}
    for i in array_b:
        if i in bucket:
            bucket[i] += 1
            continue
        bucket[i] = 1

    for j in array_r:
        if j in bucket:
            bucket[j] -= 1
            continue
        else:
            bucket[j] = -1

    return bucket


def main():
    N = int(input())
    blue_list = [input() for _ in range(N)]
    M = int(input())
    red_list = [input() for _ in range(M)]
    ans_bucket = counting_sort(blue_list, N, red_list, M)
    ans_list = []
    for k in blue_list:
        ans_list.append(ans_bucket[k])
    for h in red_list:
        ans_list.append(ans_bucket[h])
    ans_list.sort(reverse = True)
    if ans_list[0] < 0:
        print(0)
    else:
        print(ans_list[0])
    #ans_bucket_sort = sorted(ans_bucket.items(), key = lambda x:x[1], reverse = True)
    #print(ans_bucket_sort[])

main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long int lli;

using namespace std;

int main(void){
    long double n, m, ans;
    lli a, b, c, d, e;
    cin>>n>>a>>b>>c>>d>>e;
    m = (std::min)({a, b, c, d, e});
    ans = 4 + ceil(n/m);

    cout<<(lli)ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#define MN 100000
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll ans,addl,addr;
int n,l[MN+5],r[MN+5];
priority_queue<ll> ql;
priority_queue<ll,vector<ll>,greater<ll> >qr;
int main()
{
    n=read();
    for(int i=1;i<=n;++i) l[i]=read(),r[i]=read();
    ql.push(l[1]);qr.push(l[1]);
    for(int i=2;i<=n;++i)
    {
        addr+=r[i-1]-l[i-1];addl+=r[i]-l[i];
        ll pl=ql.top()-addl,pr=qr.top()+addr;
        if(pl<=l[i]&&l[i]<=pr) ql.push(l[i]+addl),qr.push(l[i]-addr);
        else if(l[i]<pl)
        {
            ans+=pl-l[i];
            qr.push(pl-addr);
            ql.push(l[i]+addl);ql.push(l[i]+addl);ql.pop();
        }
        else
        {
            ans+=l[i]-pr;
            ql.push(pr+addl);
            qr.push(l[i]-addr);qr.push(l[i]-addr);qr.pop();
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2804
n = int(input())
R = [int(x) for x in input().split()]
time = 0
flag = True
while flag:
     flag = False
     for i in reversed(range(n-1)):
        if R[i+1] < R[i]:
            R[i], R[i+1] = R[i+1], R[i]
            flag = True
            time += 1 
print(*R)
print(time)

Measured memory_bytes: 7688
using namespace std;

#include <iostream>
#include <vector>
#include <cmath>

int N, M;
bool edge[8][8];

int dfs(int node, bool alr[]) {
  alr[node] = true;
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (!alr[i]) break;
    if (i == N-1) {
      alr[node] = false;
      return 1;
    }
  }
  for (int i = 0; i < N; i++) {
    if (edge[node][i] && !alr[i]) {
      res += dfs(i, alr);
    }
  }
  alr[node] = false;
  return res;
}

int main() {
  cin >> N >> M;
  memset(edge, 0, sizeof(edge));
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    edge[x-1][y-1] = true;
    edge[y-1][x-1] = true;
  }
  
  bool alr[N];
  for (int i = 0; i < N; i++) alr[i] = false;
  
  
  cout << dfs(0, alr) << endl;
  
  
  return 0;
  
  
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  char c; cin >> c;
  string s = "aiueo";
  for(auto e : s) if(c == e) return (cout << "vowel" << endl, 0);
  cout << "consonant" << endl;
}


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

int main(void){
    int N;
    scanf("%d", &N);

    char u[10][4];
    double *x;

    x = (double*)malloc(N * sizeof(double));
    double sum = 0;
    int i;
    for(i=0; i<N; i++) {
        scanf("%lf%s", &x[i], u[i]);
        if(strcmp(u[i], "BTC") == 0) {
            x[i] *= 380000.0;
        }
        sum += x[i];
    }
    printf("%f\n", sum);
    free(x);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	vector<ll> b_c(n, 0);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];
	sort(ALL(a));
	sort(ALL(c));
	ll ans = 0;
	rep(i, n)
	{
		ll tmp = 1;
		tmp *= (int)(lower_bound(ALL(a), b[i]) - a.begin());
		tmp *= (int)(c.end() - upper_bound(ALL(c), b[i]));
		ans += tmp;
	}
	co(ans);
	return 0;
}


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

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = 0;
  for ( int i=62; i>=1; --i ) {
    bool evenA = true;
    bool evenB = true;
    if ( (A & (1LL<<i)) != 0 ) {
      if ( (A & ((1LL << (i+1))-1)) % 2 == 1 ) {
        evenA = false;
      }
    }
    if ( (B & (1LL<<i)) != 0 ) {
      if ( (B & ((1LL << (i+1))-1)) % 2 == 0 ) {
        evenB = false;
      }
    }
    if ( (!evenA && evenB) || (evenA && !evenB) ) {
      ans |= (1LL << i);
    }
//    cout << i << " : " << evenA << " " << evenB << " : " << ans << endl;
  }
  ll a0 = A & 1LL;
  ll b0 = B & 1LL;
  ll ba = (B - A + 1LL) / 2LL;
  if ( (a0 == 1) && (b0 == 1) ) ba++;
  if ( ba % 2 == 1 ) ans |= 1LL;
  cout << ans << endl;
}


Measured memory_bytes: 256
//Heaplax
#include<bits/stdc++.h>
#define N 100005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,a[N],mx=-N,mn=N;
int main()
{
	re(n);
	for(int i=1;i<=n;++i)
		re(a[i]),mx=max(mx,a[i]),mn=min(mn,a[i]);
	if(mx==mn)
	{
		puts((mx==n-1||mx*2<=n)?"Yes":"No");
	}
	else if(mn+1==mx)
	{
		int x=0,y=0;
		for(int i=1;i<=n;++i)
			++(a[i]==mn?x:y);
		if(x>mn)return puts("No"),0;
		int last=mn-x+1;
		puts(last*2<=y?"Yes":"No");
	}
	else puts("No");
}


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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  char c;
  scanf("%c",&c);
  printf("%c\n",c+1);

  return 0;
}

Measured memory_bytes: 1644
#pragma GCC optimize("Ofast") 

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

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define bew ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mod (long)(1e9+7)
#define ip(ar,n) for(int i=0;i<n;++i)cin>>ar[i];
#define op(ar,n) for(int i=0;i<n;++i)cout<<ar[i]<<" ";
#define print(...) for(auto xas:{__VA_ARGS__})cerr<<xas<<" ";
#define test int t;cin>>t;while(t--)
#define tar(x) int x;cin>>x;
#define fil(ar,val) memset(ar,val,sizeof ar)
#define loop(n) for(int i=0;i<n;++i)
#define coutd(x,y) printf("%0.y lf",x);

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

typedef vector<int> vec; 
typedef pair<int, int> pa; 
typedef vector<pa> vecp; 
typedef set<int> se;
typedef map<int,int> ma;

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

bool isprime(int n)
{
    if(n<=1)
        return false;
    for(int i=2;i*i<=n;++i)
    if(n%i==0)
        return false;
    return true;
}

int expo(int a,int n)
{
    if(n==0)
        return 1;
    if(n==1)
        return a;
    int tmp=expo(a,n/2);
    tmp=(tmp*tmp)%mod;
    if(n&1)
        tmp=(tmp*a)%mod;
    return tmp;
}


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



signed main() {
bew;
    tar(n);
    cout<<2*3.1415*n;





return 0;
}

Measured memory_bytes: 3800
//    Unmesh Kumar
//    CSE'22 IIT Roorkee

#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <map>
#include <iterator>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>

using namespace std;
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) rep(i,n) cin>>arr[i]
#define carr2(arr,n,m) rep(i,n) rep(j,m) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
typedef pair<int,int> ii;
typedef vector<ii> vii;

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

ll arr[1000005];


int main()
{
  fast;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cout<<setprecision(10)<<fixed;
  string s;
  cin>>s;
  int n=s.length();
  bool b=true;
  for(int i=0;i<n;i+=2)
  {
    if((s[i]=='h')&&(s[i+1]=='i'))
    {

    }
    else
    {
      b=false;
      break;
    }
  }
  if(b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで、intは2*10^9まで

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int res=ceil(1.0*n/x)*t;
  cout <<res;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
/*cout<<setprecision(5)<<ret<<endl;で、数字部分を計5桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(5)<<ret<<endlで、小数部のみ5桁表示かつゼロ埋め有*/
using namespace std;

typedef long long ll;
#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; }
/* [Shift+Command+b]（コンパイル）ー＞[Ctrl+Shift+`]（ターミナル起動）ー＞[./a.out] */

//////////////////
//  A
/*int main(void){
    int a;cin>>a;
    cout<<3*a*a<<endl;
    return 0;
}*/
//////////////////
//  B
/*int main(void){
    int n,d;cin>>n>>d;
    if(n%(2*d+1)==0){
        cout<<(n/(2*d+1))<<endl;
    }else{
        cout<<(n/(2*d+1))+1<<endl;
    }
    return 0;
}*/
//////////////////
//  C 
int main(void){
    int n;cin>>n;
    vector<int> v(n);
    vector<int> w(n);
    rep(i,n){
        cin>>v[i];
        w[i]=v[i];
    }

    sort(v.begin(),v.end(),greater<int>());

    int high,secondhigh;
    if(v[0]==v[1]) high=secondhigh=v[0];
    else{ 
        high=v[0];
        secondhigh=v[1];
    }

    rep(i,n){
        if(w[i]==high) cout<<secondhigh<<endl;
        else cout<<high<<endl;
    }
    return 0;
}
//////////////////
//  D
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 4736
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

double pi = 3.14159265358979323846264338327;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
    cpp();
    ll n, x, t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t<<endl;
    return 0;
}




Measured memory_bytes: 3644
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        d: usize,
        x: usize,
        a: [usize;n],
    }

    let mut sum = n;
    for i in 0..n {
        sum += (d-1)/a[i];
        debug!(sum);
    }
    println!("{}", sum+x);
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef pair<double, double> pd;

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

int main() {
    ll i, j, k;
    ll X, N;
    cin >> X >> N;
    vll P(N);
    for(auto &e : P)
        cin >> e;
    ll ans = INF;
    ll d = INF;
    for(i = 0; i <= 101; i++) {
        bool ng = false;
        for(j = 0; j < N; j++) {
            if(i == P[j]) {
                ng = true;
            }
        }
        if(ng)
            continue;
        ll di = abs(X - i);
        if(di < d) {
            d = di;
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
s = input()
if len(s) == 1:
  print(1)
else:
  ans = 1
  ref = s[0]
  tmp = ""
  for i in range(1, len(s)):
    tmp += s[i]
    if ref != tmp:
      ans += 1
      ref = tmp
      tmp = ""
  print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }


void _main() {
  int A, B, C;
  cin >> A >> B >> C;
  Yes((A<B && A<C && B>C) || (A>B && A>C && B<C));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N; cin >> N;
  // evenMonth: 19days, oddMonth: 20days
  // 3,6,9...Year: all months is 20days
  for (int i = 0; i < N; i++) {
    int ans = 1; // because 1000/01/01
    int y,m,d; cin>>y>>m>>d;
    ans += (y%3==0 || m%2==1) ? 20-d : 19-d;
    
    m = 10-m;
    ans += (y%3==0) ? m*20 : ( (m%2==0) ? (m/2)*19+(m/2)*20 : (m/2+1)*19+(m/2)*20 );

    y = 1000-y-1;
    ans += y*(5*19+5*20);
    ans += 5*ceil(y/3.0);
    // 998 -> 2
    // 1 -> 1 ... ceil(N/3)
    // 2 -> 1
    // 3 -> 1
    // 4 -> 2
    cout << ans << endl;
  }  
}



Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define Mod 1000000007
//#define Mod 998244353
#define nl "\n" 
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define f(i, a, b) for (ll i = a; i < b; ++i)
#define rf(i, a, b) for (ll i = a; i >= b; --i)
#define vll vector<ll>
#define pll pair<ll, ll>
#define mem(a, b) memset(a, b, sizeof(a))
#define printv(v) for(int i=0;i<v.size();i++) { cout<<v[i]<<" "; } cout<<nl;
using namespace std;
inline bool kthbit(ll n, int k) { return (n >> k) & 1; }
ll pw(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1) c = (c * m);m = (m * m);b /= 2;}return c;}
//------------------------------------------------------------------------------------------------

int main()
{
    fast;
    ll T=1;
    //cin>>T; //comment for single test

    while(T--)
    {
        //code...
        ll X;
        cin>>X;
        if(X>=30)
            cout<<"Yes"<<nl;
        else
            cout<<"No"<<nl;
    }
    return 0;  
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {

	long long k;

	cin >> k;

	long long ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = i; j <= k; j++) {
			for (int s = j; s <= k; s++) {
				if (i == j && j == s && i == s) {
					ans += (gcd(gcd(i, j), s));
				}
				else if (i == j && j != s) {

					ans += (gcd(gcd(i, j), s)) * 3;
				}
				else if (i != j && j == s) {
					ans += (gcd(gcd(i, j), s)) * 3;
				}
				else {
					ans += (gcd(gcd(i, j), s)) * 6;
				}


			}
		}
	}
		cout << ans << endl;

		return 0;
	}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);

	int m1 = 0, m2 = 0, ind = -1;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (m2 < x) m2 = x;
		if (m1 < m2) {
			x = m1;
			m1 = m2;
			m2 = x;
			ind = i;
		}
	}

	for (int i = 0; i < n; i++) {
		if (i != ind) printf("%d\n", m1);
		else printf("%d\n", m2);
	}
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



//nまでの素数を求める(prime[i] == i => 素数)
vector<int> Sieve(int n){
    vector<int> ret(n + 1, 0);
    vector<int> pr;
    for (int i = 2; i <= n; i++) {
        if (ret[i] == 0) {
            ret[i] = i;
            pr.emplace_back(i);
        }
        for (int j = 0; j < pr.size() && pr[j] <= ret[i] && i*pr[j] <= n; j++) ret[i * pr[j]] = pr[j];
    }
    return ret;
}

LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 

int main(){
    LL n;cin >> n;
    auto p = Sieve(n);
    LL ans = 0;
    for (int i = 1; i < n; i++) {
        LL t = n - i;
        map<int,int> ma;
        while(t != 1){
            ma[p[t]]++;
            t /= p[t];
        }
        LL cnt = 1;
        for(auto m:ma){
            cnt *= (m.sc + 1);
        }
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

  vector<ll> d(N);
  REP(i, N) cin >> d[i];

  ll ans = 0;
  for(int i = 0; i < N ; i++){
      for(int j = i + 1; j < N ; j++){
          ans += d[i] * d[j];
      }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long int x, y, ans, t=0;
	cin>>x>>y;
	for(t=0;t<=100;t++){
		if(pow(y, t)>x){
			ans=t; break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	double s[1000];
	double ave;
	double var;//bunsan
	int n;
	int i;
	while(1){
		scanf("%d", &n);
		if(n == 0)break;
		ave = 0;
		for(i = 0;i < n;i++){
			scanf("%lf", &s[i]);
			ave += s[i]/n;
		}
		var = 0;
		for(i = 0;i < n;i++){
			var += (s[i]-ave)*(s[i]-ave)/n;
		}
		printf("%lf\n",sqrt(var));
	}
	return 0;
}

Measured memory_bytes: 660
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    ll sum = 0;
    for (int mask = 0; mask < (1 << n - 1); mask++)
    {
        ll c = s[0] - '0';
        for (int i = 0; i < n - 1; ++i)
        {
            if (mask & (1 << i))
            {
                sum += c;
                c = s[i + 1] - '0';
            }
            else
            {
                c *= 10;
                c += s[i + 1] - '0';
            }
        }
        sum += c;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3604
#include <stdio.h>
int main(void){
    int h, w;
    char s[50+5][50+5];
    scanf("%d %d", &h, &w);
    
    for(int i=1; i<=h; i++){
        scanf("%s", &s[i][1]);
    }
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(s[i][j]=='#'){
                // 独立した黒なら不可能
                if(s[i+1][j]=='.' && s[i-1][j]=='.' && s[i][j+1]=='.' && s[i][j-1]=='.'){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1644
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3;
    lli i,j,k,a,b,c,n,m,sum=0,ans=0,temp;
    cin >> n;
    lli arr[n];
    rep(i,0,n)	cin >> arr[i];
    lli dp[n];
    dp[0]=0;dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++){
    	a=abs(arr[i]-arr[i-1])+dp[i-1];
    	b=abs(arr[i]-arr[i-2])+dp[i-2];
    	dp[i]=min(a,b);
	}
	cout << dp[n-1] << endl;
	
    
    
    
    return 0;
}

















/* UJJWAL KESHRI */

Measured memory_bytes: 1792
# include <bits/stdc++.h>
# define rr register
const int N=100010;
int size;
int a[N];
int k;
int main(void){
	scanf("%d",&k);
	size=1,a[1]=1;
	for(rr int i=2;i<=k;++i){
		for(rr int j=size;j>=1;--j){
			if((j>1&&a[j]<a[j-1]+1&&a[j]<9)||(j==1&&a[j]<9)){
				++a[j];
				for(rr int k=j+1;k<=size;++k){
					a[k]=std::max(0,a[k-1]-1);
				}
				goto ENd;
			}
		}
		++size;
		a[1]=1;
		for(rr int j=2;j<=size;++j){
			a[j]=0;
		}
		ENd:;
	}
	for(rr int i=1;i<=size;++i){
		printf("%d",a[i]);
	}
	return 0;
}

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

@SuppressWarnings("unchecked")
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long[] a = new long[N];
        for(int i=0;i<N;++i)a[i]=scan.nextLong();
        List<Integer> posIndex[] = new ArrayList[2];
        for(int i=0;i<2;++i)posIndex[i]=new ArrayList<>();
        for(int i=0;i<N;++i)if(a[i]>=0)posIndex[i%2].add(i);
        if(posIndex[0].isEmpty()&&posIndex[1].isEmpty()){
            int minIndex = 0;
            for(int i=0;i<N;++i)if(a[i]>a[minIndex])minIndex=i;
            System.out.println(a[minIndex]);
            System.out.println(N-1);
            for(int i=N;i>minIndex+1;--i)System.out.println(i);
            for(int i=0;i<minIndex;++i)System.out.println(1);
        }else{
            long ans = Long.MIN_VALUE;
            List<Integer> index = new ArrayList<>();
            for(int i=0;i<2;++i){
                long sum=0;
                for(int j : posIndex[i])sum+=a[j];
                if(sum>ans){
                    ans = sum;
                    index = posIndex[i];
                }
            }
            System.out.println(ans);
            List<Integer> list = new ArrayList<>();
            for(int i=N;i>index.get(index.size()-1) +1;--i)list.add(i);
            for(int i=0;i<index.get(0);++i)list.add(1);
            for(int i=0;i<index.size()-1;++i){
                int num = (index.get(i+1) - index.get(i) -1)/2;
                while(num-->0)list.add(3);
                list.add(2);
            }
            System.out.println(list.size());
            for(int i : list)System.out.println(i);
        }
    }
}

Measured memory_bytes: 28268
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,N,M,P,Q,R,W,X,Y,Z;
string S,T;
vector<ll> V;

int main(){
  cin >> A >> B ;
  if(A+B==3){
    cout << 3 << endl;
  }
  if(A+B==4){
    cout << 2 << endl;
  }
  if(A+B==5){
    cout << 1 << endl;
  }
}

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

using namespace std;

const int mod = 1e9 + 7;
const int N = 1e5 + 3;

int n, k;
long long ar[N];

int bin_pow(int a, int n) {
    int ret = 1;
    while (n) {
        if (n & 1)
            ret = (ret * 1ll * a) % mod;
        a = (a * 1ll * a) % mod;
        n >>= 1;
    }
    return ret;
}

int main() {
    cin >> n >> k;

    long long ans = 0;
    for (int i = k; i >= 1; i--) {
        ar[i] = bin_pow(k / i, n);
        for (int j = i + i; j <= k; j += i)
            ar[i] = (ar[i] - ar[j] + mod) % mod;
        ans = (ans + (ar[i] * i)) % mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4328
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const ll LINF = (ll)1 << 60;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int w;
  cin>>w;
  cout<<32*w<<'\n';
  return(0);
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,d,sum=0;
	cin>>m>>d;
	for(int j=4;j<=m;j++)
	{
		for(int i=22;i<=d;i++)
		{
			if((i%10>=2)&&(i/10>=2))
			{
				if(j==((i%10)*(i/10)))
			{
				sum++;
			}
			}
			
			
		}
	}
	cout<<sum;
}

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

#define MAX_PACKET 100000

int num_packet;
int num_track;
int weight[MAX_PACKET];

bool canAlloc(long capacity);

int main(void)
{
    int i;

    scanf("%d %d", &num_packet, &num_track);

    int max_weight = 0;
    long sum_weight = 0;
    for (i = 0; i < num_packet; i++) {
        scanf("%d", &weight[i]);
        if (weight[i] > max_weight) {
            max_weight = weight[i];
        }
        sum_weight += weight[i];
    }

    long low = max_weight;
    long upp = sum_weight;
    while (low < upp) {
        long mid = (low + upp) / 2;
        if (canAlloc(mid)) {
            upp = mid;
        } else {
            low = mid + 1;
        }
    }

    printf("%ld\n", low);

    return 0;
}

bool canAlloc(long capacity)
{
    int i = 0;

    long alloced_in_one = 0;
    int track_id = 0;
    while (i < num_packet) {
        if (alloced_in_one + weight[i] <= capacity) {
            alloced_in_one += weight[i++];
        } else {
            alloced_in_one = 0;
            if (++track_id == num_track) {
                return false;
            }
        }
    }
    return true;
}

Measured memory_bytes: 984
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Optional;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();

		int n = sc.nextInt();

		sc.nextLine();

		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}

		int count = 0;

		for (int j = 0; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				for (int l = k + 1; l < n; l++) {

					int a = list.get(j);
					int b = list.get(k);
					int c = list.get(l);

					if (a == b || b == c || c == a) {
						continue;
					}
					if (calc(a,b,c)) {
						count++;
					}

				}
			}
		}

		System.out.println(count);
	}


	private static boolean calc(int a,int b,int c){

		Optional<Integer> max = Arrays.asList(a,b,c).stream().max((x,y) -> x-y);
		Integer sum = Arrays.asList(a,b,c).stream().reduce(0,(x,y) -> x+y);


		return (sum - max.get()) > max.get();
	}


}

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

using namespace std;

int main () {
    int x, y, m, n, mx=-10000,mn=1e8;
    cin >> n >> m >> x >> y;
    for(int i = 0 ; i < n ; i++ ) {int xx;cin >> xx;mx=max(mx, xx);}
    for(int i = 0 ; i < m ; i++ ) {int xx;cin >> xx;mn=min(mn, xx);}
    if(mx>=mn) {
        cout << "War";
        return 0;
    }
    if(mn <= x || mx >= y) {
        cout << "War";
        return 0;
    }
    cout << "No War";
}


Measured memory_bytes: 256
using System;

class AtCoder
{
    static void Main()
    {
        bool f = false;
        string[] s;       
        s = NextS();
        string t = s[0];
        string u;
        for(int i=0; i<t.Length; i++)
        {
            for(int j=i; j<t.Length; j++)
            {
                u = t.Substring(0, i) + t.Substring(j);
                if (u == "keyence") f = true;
            }
        }
        if (f) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }

    static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String line;
            try {
                line = sc.nextLine();
            }catch(Exception e) {
                break;
            }
            
            String[] linesp = line.split(" ");
            int a = Integer.parseInt(linesp[0]);
            int b = Integer.parseInt(linesp[1]);
            
            String sum = String.valueOf(a + b);
            
            System.out.println(sum.length());
        }
    }
 } 


Measured memory_bytes: 26412
import numpy as np

N, W = map(int, input().split())
v_max = 10**3

dp = np.ones(v_max*N+1, dtype=int) * (10**9+1)
dp[0] = 0

for i in range(N):
  w, v = map(int, input().split())
  dp[v:] = np.minimum(dp[v:], dp[:-v]+w)


print(np.where(dp <= W)[0][-1])

Measured memory_bytes: 21400
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	long long n,y;
	cin>>n>>y;
	long long i1,i2,i3;
	for(i1=0;i1<=n;i1++)
	{
		for(i2=0;i2<=n-i1;i2++)
		{
			i3=n-i1-i2;
			long long s=i1*10000+i2*5000+i3*1000;
			if(s==y)
			{
				cout<<i1<<" "<<i2<<" "<<i3<<endl;
				return 0;
			}			
		}

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

Measured memory_bytes: 384
#input
N, M = map(int,input().split())
A = list(map(int,input().split()))

#count num
count = 0
for i in range(N):
    if A[i] * 4 * M >= sum(A): #A[i] = sum(A)/(4*M)
        count +=1

#Check availavle N
if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
#define FayeValentine 
void dz(){cerr<<NL;}template<typename H,typename... T> void dz(H h,T... t){cerr<<' '<<h;dz(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dz(__VA_ARGS__)
#else
#define debug(...) 
#endif


void absinthe() {
	int n, x; cin >> n;
	ll s = 0; 
	while(n--) {cin >> x; s += ((ll)x-1); }
	cout << s << NL;
}

 
int main(){
  async();
  int __t = 1, __c; //cin >> __t;
  for(__c = 1; __c <=__t; __c++) {
    //cout << "Case " << __c << ": "; 
    absinthe();
  }
}  

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
 
for i in a:
  x -= i
  if x < 0:
    break
  ans += 1
if x > 0:
  if ans > 0:
    ans -= 1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <set>
#include <algorithm>

int main()
{
  long long A, B, C, D, E, F;
  scanf("%lld%lld%lld%lld%lld%lld", &A, &B, &C, &D, &E, &F);
  std::set<long long> water;
  std::set<long long> sugar;
  for (long long i = 0; i * 100 * B < F; ++i)
  {
    for (long long j = 0; 100 * (i * B + j * A) < F; ++j)
    {
      if (i == 0 && j == 0) continue;
      water.insert(100 * (i * B + j * A));
    }
  }
  for (long long i = 0; i * D <= F / 100 * E; ++i)
  {
    for (long long j = 0; i * D + j * C <= F / 100 * E; ++j)
    {
      if (i == 0 && j == 0) continue;
      sugar.insert(i * D + j * C);
    }
  }

  long long answ = *water.begin(), anss = 0;
  for (auto w : water)
  {
    auto end = std::upper_bound(sugar.begin(), sugar.end(), w / 100 * E);
    for (auto it = sugar.begin(); it != end; ++it)
    {
      if (*it + w <= F && *it * (answ + anss) - anss * (w + *it) > 0)
      {
        anss = *it;
        answ = w;
      }
    }
  }
  printf("%lld %lld\n", answ + anss, anss);
  return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int cnt[100010];

bool isPrime(int n){
    double q = sqrt(n);
    for(int i = 2; i <= q; i++){
        if(n%i == 0) return false;
    }
    return true;
}

int main(){
    int q;
    cin >> q;
    vector<int> l(q), r(q);
    for(int i = 0; i < q; i++){
        cin >> l[i] >> r[i];
    }

    cnt[0] = 0;
    cnt[1] = 0;
    cnt[2] = 0;
    for(int i = 3; i <= 100000; i+=2){
        if(isPrime(i) && isPrime((i+1)/2)){
            cnt[i] = cnt[i-2]+1;
        } else {
            cnt[i] = cnt[i-2];
        }
        cnt[i+1] = cnt[i];
    }

    for(int i = 0; i < q; i++){
        cout << cnt[r[i]]-cnt[l[i]-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
def main():
  import sys

  f = "" # 前回のステップの文字 "<" or ">" 
  ans = 0 # Answer
  count = 0 # Ai
  continuous = 0 # ">" が何回連続するか
  
  for m in sys.stdin.readline().strip("\n"):
    if m=="<":
      if f==">" and count>0:
        # 清算
        ans-=count*continuous
        count=0
      count+=1
        
    else:
      if f=="<":
        # セット
        continuous=0
      count-=1
      continuous+=1
      if count==-1:
        ans+=continuous
        count=0
        continue

    ans+=count
    f=m

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

Measured memory_bytes: 43424
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
    char sen1[1000],sen2[1000][32];
    int i,j,k,l,MAX1=0,MAX2=0,output1[1000]={0},output2[1000]={0},a=0,b=0;
    gets(sen1);
    for(i=0,j=0,k=0;sen1[i]!='\0';i++){
        //printf("%c\n",sen1[i]);
        if(isspace(sen1[i])!=0){
            for(l=0;l<k;l++){
                if(strcmp(sen2[k],sen2[l])==0){
                    output1[l]++;
                    //printf("test\n");
                    break;
                }

            }
            if(output2[k]<strlen(sen2[k])){
                output2[k]=strlen(sen2[k]);
            }
            sen2[k][j]='\0';
            //printf("%d %d\n",k,j);
            k++;
            j=0;
        }
        else{
            sen2[k][j]=sen1[i];
            j++;
        }
    }
    for(l=0;l<k;l++){
        if(strcmp(sen2[k],sen2[l])==0){
            output1[l]++;
            //printf("test\n");
            break;
        }

    }
    if(output2[k]<strlen(sen2[k])){
        output2[k]=strlen(sen2[k]);
    }

    /*for(i=0;i<=k;i++){
        printf("%d %d\n",output1[i],output2[i]);
    }*/
    /*for(i=0;i<=k;i++){
        for(j=0;j<32;j++)printf("%c",sen2[i][j]);
    puts("");
    }*/

    for(j=0;j<=i;j++){
        if(output1[j]>MAX1){
            MAX1=output1[j];
            a=j;
        }
    }
    for(k=0;k<=i;k++){
        if(output2[k]>MAX2){
            MAX2=output2[k];
            b=k;
        }
    }
    printf("%s %s\n",sen2[a],sen2[b]);
    return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1000000007;


int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  vector<int> d(n,0);
  for(int i=0; i<n; i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  ll sum=0;
  for(int i=0; i<k; i++){
    sum=sum+d[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3652
n,m=map(int,input().split())
h=list(map(int,input().split()))
cnt=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    cnt[b-1]=-1
  elif h[b-1]>h[a-1]:
    cnt[a-1]=-1
  else:
    cnt[a-1]=-1
    cnt[b-1]=-1
print(cnt.count(0))

Measured memory_bytes: 20108