akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()

int main()
{   SPEED;
	ll n,flag1=1,flag2=1;
	cin>>n;
	ll t;
	
	vector<ll> v1,v2;
	for(ll i=0;i<n;i++)
	{
		cin>> t;
		v1.pb(t);
	}
    for(ll i=0;i<n;i++)
	{ cin>>t;
		v2.pb(t);
	}
	ll a,b,r=1;
	vector<ll> v3=v1;
	sort(v3.begin(), v3.end());
	while(flag1 || flag2)
	{
		if(v3==v1)
		{
			flag1=0;
			a=r;
		
		}
		 if(v3==v2)
		{
			flag2=0;
			b=r;
		
		}
		next_permutation(v3.begin(), v3.end());
		r++;

	}
	
    if(b>a)
    {
    	swap(a,b);
    }
    cout<<a-b<<endl;
	
    
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;

ll N;

map<ll, int> insu;
vector<ll> crt, nxt;

ll mpow(ll a, int b) {
	ll base = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)base *= kakeru;
		kakeru *= kakeru;
		b >>= 1;
	}
	return base;
}

void soinsu(ll x) {
	for (ll i = 2; i * i <= x; i++) {
		int cnt = 0;
		while (x % i == 0)x /= i, cnt++;
		if (cnt != 0)insu[i] = cnt;
	}
	if (x != 1) {
		insu[x]++;
	}

	crt.push_back(1);
	for (auto it = insu.begin(); it != insu.end(); it++) {
		for (int i = 0; i < crt.size(); i++) {
			ll times = 1;
			for (int j = 0; j <= (*it).second; j++) {
				nxt.push_back(crt[i] * times);
				times *= (*it).first;
			}
		}
		swap(crt, nxt);
		nxt.clear();
	}
}

int main() {
	cin >> N;
	if (N == 2) {
		cout << 1 << endl;
		return 0;
	}
	soinsu(N - 1);
	sort(crt.begin(), crt.end());

	ll cnt = 0;
	for (ll i = 2; i * i <= N; i++) {
		ll cN = N;
		while (cN % i == 0)cN /= i;
		if (cN % i == 1)cnt++;
	}
	
	cout << cnt + crt.size() - (lower_bound(crt.begin(), crt.end(), sqrt(N)) - crt.begin())+ 1 << endl;

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <ll> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



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

    int T=1;
    //cin >> T;
    while(T--){
        string s,t;
        cin>>s>>t;
        int f=1;
        int n=s.length();
        if(t.length()!=n+1) f=0;
        if(f && t.substr(0,n)!=s) f=0;
        if(f) cout<<"Yes"<<el;
        else cout<<"No"<<el;
    }

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
const int MAX = 700000;
const int MOD = 1000000007;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll ma=max(a,b);
  ll mi=min(a,b);
  ll ans=0;
  if((ma-mi)%2==0){
    COUT((ma-mi)/2);
  }
  else{
    ll maa=mi;
    ll mii=n-ma+1;
    if(ma-mi==1) COUT(min(maa,mii));
    else{
      if(n-ma<mi-1){
        ans+=n-ma+1;
        mi+=ans;
        ans+=(n-mi)/2;
        COUT(ans);
      }
      else{
        ans+=mi;
        ma-=ans;
        ans+=(ma-1)/2;
        COUT(ans);
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') {
		cout << b << endl;
	}
	else {
		if (b == 'H') {
			cout << "D" << endl;
		}
		else cout << "H" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for(int i = 0;i<5;i++){
            int tmp = sc.nextInt();
            min = Math.min(min, tmp);
            max = Math.max(max,tmp);
            sc.nextLine();
        }
        if(max - min > sc.nextInt()){
            System.out.println(":(");
        }else{
            System.out.println("Yay!");
        }
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    int m2 = 0, m4 = 0,other = 0;
    REP(i,n) {
        int x; cin >> x;
        if (x % 4 == 0) m4++;
        else if (x % 2 == 0) m2++;
        else other++;
    }
    bool ans = false;
    if (m2 == 0) {
        if (m4+1 >= other) ans = true;
    } else {
        if (m4 >= other) ans = true;
    }
    ATYN(ans)

    return 0;
}

Measured memory_bytes: 256
s = list(map(str, input()))
n = len(s)
ans = 0
for i in range(2**(n-1)):
  bag = []
  t = s[:]
  for j in range(n):
    if (i>>j) & 1:
      bag += [j]

  for num in bag[::-1]:
    t.insert(num+1, '+')
  ans += eval(''.join(t))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    cout <<(n-1)/2<<"\n";
}

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

#define ALL(a)  a.begin(),a.end()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cerr << #x << ": " << x << endl

using LL = long long; template<class T> using V = vector<T>;

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

	int a, b, c;
	while (cin >> a >> b >> c, a | b | c) {
		int N;
		cin >> N;
		V<int>A(N), B(N), C(N), D(N);
		V<int>res(a + b + c + 1,2);
		FOR(i, 0, N) {
			cin >> A[i] >> B[i] >> C[i] >> D[i];
			if (D[i]) {
				res[A[i]] = 1;
				res[B[i]] = 1;
				res[C[i]] = 1;
			}
		}
		// 1index
		FOR(i, 0, N) {
			if (D[i])continue;
			if (res[A[i]] == 1 && res[B[i]] == 1) {
				res[C[i]] = 0;
			}
			else if (res[A[i]] == 1 && res[C[i]] == 1) {
				res[B[i]] = 0;
			}
			else if (res[C[i]] == 1 && res[B[i]] == 1) {
				res[A[i]] = 0;
			}

		}

		FOR(i, 1, a + b + c + 1) {
			cout << res[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3140
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x - r >= 0 && x + r <= W && y - r >=  0 &&y + r <= H){
    printf("Yes\n");
  }else printf("No\n");
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
long long mx[maxn<<2],mn[maxn<<2];
bool rev[maxn<<2];
int r[maxn],a[maxn],t[maxn],b[maxn];
long long add[maxn<<2],all[maxn<<2];
map<int,int> ma;
int ql,qr,x;
void maintain(int o){
  mn[o]=min(mn[o<<1],mn[o<<1|1]);
  mx[o]=max(mx[o<<1],mx[o<<1|1]);
}

void flip(int o){
  rev[o]^=1;
  if (all[o]!=-1) {
	all[o]=x-all[o];
	rev[o]=0;
  } else add[o]*=-1;
  int t1=mx[o],t2=mn[o];
  mx[o]=x-t2;mn[o]=x-t1;
}
void pushdown(int o){
   if (!rev[o]){
	  if (all[o]!=-1){
		all[o<<1]=all[o];add[o<<1]=0;mx[o<<1]=mn[o<<1]=all[o];rev[o<<1]=0;
		all[o<<1|1]=all[o];add[o<<1|1]=0;mx[o<<1|1]=mn[o<<1|1]=all[o];rev[o<<1|1]=0;
		all[o]=-1;
	  }
	  else{
		if (all[o<<1]!=-1) {
			all[o<<1]+=add[o];
			mx[o<<1]+=add[o];
			mn[o<<1]+=add[o];
		} else {
			add[o<<1]+=add[o];
			mx[o<<1]+=add[o];
			mn[o<<1]+=add[o];
		}
		if (all[o<<1|1]!=-1) {
			all[o<<1|1]+=add[o];
			mx[o<<1|1]+=add[o];
			mn[o<<1|1]+=add[o];
		} else {
		    add[o<<1|1]+=add[o];
			mx[o<<1|1]+=add[o];
			mn[o<<1|1]+=add[o];
		}
		add[o]=0;
	  }
   } else {
     flip(o<<1);flip(o<<1|1);
     if (add[o]){
		 if (all[o<<1]!=-1){
			all[o<<1]+=add[o];
		 } else add[o<<1]+=add[o];
		 if (all[o<<1|1]!=-1){
			all[o<<1|1]+=add[o];
		 }else {
		    add[o<<1|1]+=add[o];
		 }
		 mn[o<<1]+=add[o];mx[o<<1]+=add[o];
		 mn[o<<1|1]+=add[o];mx[o<<1|1]+=add[o];
		 add[o]=0;
     }
     rev[o]=0;
   }
}
void build(int o,int l,int r){
  rev[o]=0;add[o]=0;all[o]=-1;
  if (l==r){
	 mx[o]=mn[o]=b[l];
  }else {
    int mid=(l+r)>>1;
    build(o<<1,l,mid);
    build(o<<1|1,mid+1,r);
    maintain(o);
  }
}

void update(int o,int l,int r){
  if (l!=r) pushdown(o);
  if (mx[o]<=qr) {all[o]=mn[o]=mx[o]=add[o]=rev[o]=0;return;}
  if (mn[o]>=qr) {
		if (all[o]!=-1) {all[o]-=qr;mn[o]-=qr;mx[o]-=qr;}
		else {add[o]-=qr;mn[o]-=qr;mx[o]-=qr;}
		return;
  }
  int mid=(l+r)>>1;
  update(o<<1,l,mid);
  update(o<<1|1,mid+1,r);
  if (l!=r) maintain(o);
}

int query(int o,int l,int r){
  if (l==r && qr==l) return mx[o];
  else {
	pushdown(o);
	int mid=(l+r)>>1;
	int ans;
	if (qr>mid) ans= query(o<<1|1,mid+1,r);
	else ans= query(o<<1,l,mid);
	maintain(o);
	return ans;
  }
}

int main()
{
    int k,q;
    int i,j;
    scanf("%d %d",&x,&k);
    for (i=1;i<=k;i++){
		scanf("%d",&r[i]);
    }
    scanf("%d",&q);
    for (i=1;i<=q;i++){
		scanf("%d %d",&t[i],&a[i]);
		b[i]=a[i];
    }
    sort(b+1,b+1+q);
    int m=unique(b+1,b+1+q)-b-1;
    ma.clear();
    for (i=1;i<=m;i++) ma[b[i]]=i;
    build(1,1,m);
    j=0;
    r[0]=0;
    for (i=1;i<=k;i++){
      while (j<q && t[j+1]<=r[i]) {
		j++;
        ql=qr=ma[a[j]];
        int ans=query(1,1,m);
        if (t[j]-r[i-1]>=ans) ans=0;
        else ans-=t[j]-r[i-1];
        if ((i&1)==0) ans=x-ans;
        printf("%d\n",ans);
      }
      ql=0;qr=r[i]-r[i-1];
      update(1,1,m);
      pushdown(1);maintain(1);
      flip(1);
    }
    while (j<q){
	    j++;
        ql=qr=ma[a[j]];
        int ans=query(1,1,m);
        if (t[j]-r[k]>=ans) ans=0;
        else ans-=t[j]-r[i-1];
        if (((k+1)&1)==0) ans=x-ans;
        printf("%d\n",ans);
    }
    return 0;
}


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

using ll = long long;

int main(){
    ll n, m;
    cin >> n >> m;
    if(n > m) swap(n,m);
    if(n == 1){
        if(m == 1){
            cout << 1 << '\n';
            return 0;
        }
        else{
            cout << m - 2 << '\n';
            return 0;
        }
    }else{
        cout << (n-2) * (m-2) << '\n';
        return 0;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(B/A>=C){
        printf("%d",C);
    }else{
        printf("%d",B/A);
    }
    return 0;
}

Measured memory_bytes: 128
from collections import Counter
N = int(input())
S = [input() for i in range(N)]

S_c = Counter(S)
max_count = max(S_c.values())

ans = []

for key, value in S_c.items():
  if value == max_count:
    ans.append(key)
    
ans.sort()

for i in range(len(ans)):
  print(ans[i])

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

#define range 100005
#define mod 1000000007
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int a[200];

int dp[200][100010];

int summu[200][100010];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=k;i>=(k-a[0]);i--)
		dp[0][i] = 1;
	for(int i=0;i<n;i++)
		dp[i][k] = 1;
	for(int i=0;i<n;i++)
	   summu[i][k] = 1;	
	for(int i=k-1;i>=0;i--)
		summu[0][i] = summu[0][i+1] + dp[0][i];
	for(int i=1;i<n;i++)
	{
		for(int j=k-1;j>=0;j--)
		{
			int mini = min(j + a[i],k) + 1;
			dp[i][j] = (summu[i-1][j] - summu[i-1][mini] + mod)%mod;
		}
		for(int j=k-1;j>=0;j--)
			summu[i][j] = (summu[i][j+1] + dp[i][j])%mod;
	}
	cout<<dp[n-1][0]<<endl;
	return 0;
}

Measured memory_bytes: 160000
/*  -*- coding: utf-8 -*-
 *
 * 2817.cc: Dance Now!
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_C = 100;
const int K = 9;
const int INF = 1 << 30;

/* typedef */

template <typename T, const int MAX_N>
struct BIT {
  int n;
  T bits[MAX_N + 1];
  BIT() {}

  void init(int _n) {
    n = _n;
    //memset(bits, 0, sizeof(bits));
  }

  T sum(int x) {
    T s = 0;
    while (x > 0) {
      s += bits[x];
      x -= (x & -x);
    }
    return s;
  }

  void add(int x, T v) {
    while (x <= n) {
      bits[x] += v;
      x += (x & -x);
    }
  }
};

/* global variables */

int rs[MAX_N], ps[MAX_N][3], wps[K][3];
BIT<int,MAX_C> bits[3];

/* subroutines */

int score(int n, int mps[], int *rks = NULL) {
  int sc = 0;
  for (int j = 0; j < 3; j++) {
    int k = n - bits[j].sum(mps[j]);
    sc += rs[k];
    if (rks != NULL) rks[j] = k;
  }
  return sc;
}

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d", rs + i);

  for (int j = 0; j < 3; j++) bits[j].init(MAX_C);

  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++) {
      scanf("%d", ps[i] + j);
      bits[j].add(ps[i][j], 1);
    }
  //for (int i = 0; i < n; i++) printf("%d ", score(n, ps[i])); putchar('\n');

  int sc0 = score(n, ps[0]);
  int m = 0;
  for (int i = 1; i < n; i++) {
    int sci = score(n, ps[i]);
    if (sci > sc0) memcpy(wps[m++], ps[i], sizeof(ps[i]));
  }
  //printf("m=%d\n", m);

  int mind = INF;
  for (int j = 0; j < 3; j++) {
    int pj = ps[0][j];
    bits[j].add(ps[0][j], -1);

    for (int d = 1; ps[0][j] < MAX_C; d++) {
      ps[0][j]++;
      bits[j].add(ps[0][j], 1);

      int rks[3];
      int sc0 = score(n, ps[0], rks);
      bool ok = false;

      for (int i = 0; i < m; i++)
	if (score(n, wps[i]) <= sc0) {
	  ok = true;
	  break;
	}

      bits[j].add(ps[0][j], -1);

      if (ok) {
	//printf("d[%d]=%d\n", j, d);
	if (mind > d) mind = d;
	break;
      }
      if (rks[j] == 0) break;
    }

    bits[j].add(pj, 1);
    ps[0][j] = pj;
  }

  if (mind >= INF) puts("Saiko");
  else printf("%d\n", mind);
  return 0;
}



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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int c1, c5, c10, c50, c100, c500;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    cout << (c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 >= 1000) << endl;
}




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

const int MAX_N = 100;
int n;
int a[MAX_N], b[MAX_N - 1];

void solve() {
    a[0] = b[0];
    for (int i = 1; i <= n - 2; i++) {
        if (b[i] >= b[i - 1]) {
            a[i] = b[i - 1];
        } else {
            a[i] = b[i];
        }
    }
    a[n - 1] = b[n - 2];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[i];
    }
    cout << ans << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        cin >> b[i];
    }
    solve();
}

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

using namespace std;
const int N = 3e3 + 3, MOD = 998244353;
int a[N], dp[N];

void mod(int &a) {if (a >= MOD) a -= MOD;}
int mul(int a, int b) {return 1ll * a * b % MOD;}
int Pow(int a, int b) {
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b&1) res = mul(res, a);
    return res;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, S; scanf("%d%d", &n, &S);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    dp[0] = Pow(2, n);
    int inv = Pow(2, MOD - 2);
    for (int i = 0; i < n; i++)
        for (int j = S; j >= a[i]; j--) dp[j] += mul(dp[j - a[i]], inv), mod(dp[j]);
    printf("%d\n", dp[S]);

    return 0;
}


Measured memory_bytes: 3852
n = gets.chomp.to_i
nums = gets.chomp.split(' ').map(&:to_i)
 
res = 0
(1..n-2).each do |i|
  res += 1 if (nums[i-1] < nums[i] && nums[i] < nums[i+1]) || (nums[i+1] < nums[i] && nums[i] < nums[i-1])
end
 
puts res

Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;
 

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

    int a[20][20];
    int b[20];

    for(int i=0;i<m;i++) cin >> b[i];
    
    for(int row=0;row<n;row++){
        for(int col=0;col<m;col++){
            cin >> a[row][col];
        }
    }

    int counter = 0;

    for(int row=0;row<n;row++){
        int sum = 0;
        for(int col=0;col<m;col++){
            sum += a[row][col]*b[col];
        }
        if(sum > -c) ++counter;
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N, P;
    cin >> N >> P;
    int flag = 1;
    ll ans = 1;
    rep(i, N) {
        int a;
        cin >> a;
        if(a%2 == 1) {
            flag = 0;
        }
    }

    if(flag) {
        if(P) {
            ans = 0;
        }
        else {
            rep(i, N) {
                ans *= 2;
            }
        }
    }
    else {
        rep(i, N-1) {
            ans *= 2;
        }
    }

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

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

const int MAXN = 3002;

double dp[MAXN][MAXN],P[MAXN];
int vis[MAXN][MAXN],N;

double solve(int pos,int heads){
	
	if(heads < 0) return 0.0;

	if(pos == 0){
		return (heads == 0);
	}

	if(vis[pos][heads]) return dp[pos][heads];
	vis[pos][heads] = 1;

	return dp[pos][heads] =  (P[pos])*solve(pos-1,heads-1) + (1.0 - P[pos])*solve(pos-1,heads);

}

int main(){

	cin >> N;
	for(int i = 1;i<=N;i++){
		cin >> P[i];
	}

	double tot = 0;
	for(int heads = 0;heads<=N;heads++){
		int tails = N - heads;
		if(heads > tails) tot += solve(N,heads);
	}

	cout<<fixed<<setprecision(9)<<tot<<endl;

	return 0;

}


Measured memory_bytes: 105192
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cstdio>
using namespace std;

int main() {
	int w,h,n;
	cin >> w >> h >> n;
	int ans = 0;
	int xleft = 0;
	int xright = w;
	int ydown = 0;
	int yup = h;
	int xtmp,ytmp,type;
	for(int i = 0; i < n; i++){
		cin >> xtmp >> ytmp >> type;
		switch(type){
			case 1:
			if(xtmp > xleft)
				xleft = xtmp;
			break;
			case 2:
			if(xtmp < xright)
				xright = xtmp;
			break;
			case 3:
			if(ytmp > ydown)
				ydown = ytmp;
			break;
			case 4:
			if(ytmp < yup)
				yup = ytmp;
			break;
		}
	}

	ans = (xright-xleft)*(yup-ydown);

	if(xright < xleft || yup < ydown) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((b - a) % 2 == 0) {
            System.out.println(a + (b - a) / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int K, N;
	cin >> K >> N;

	vector<int> Ai(N, 0);
	rep(i, N) cin >> Ai.at(i);

	int d_max = 0;
	vector<int> Di(N, K);
	Di.at(0) = Ai.at(0) + (K - Ai.at(N - 1));
	d_max = Di.at(0);
	for (int j = 1; j < N; ++j)
	{
		Di.at(j) = Ai.at(j) - Ai.at(j - 1);
		d_max = max(d_max, Di.at(j));
	}

	cout << K - d_max << endl;
	return 0;
}

Measured memory_bytes: 4832
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

typedef std::pair<int64_t,int64_t> ii;

using namespace std;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,k;
  cin>>n>>k;
  std::vector<ii> vec;
  for(int i=0;i<n;i++){
    int t,d;
    cin>>t>>d;
    vec.push_back(std::make_pair(d,t));
  }
  sort(vec.begin(), vec.end(), std::greater<>());
  unordered_map<int,int> count;
  int64_t result=0,point=0;
  for(int i=0;i<k;i++){
    point+=vec[i].first;
    if(count.find(vec[i].second)==count.end()){
      count[vec[i].second]=1;
    }else{
      count[vec[i].second]++;
    }
  }
  int64_t species=count.size();
  point+=species*species;
  result=point;
  int removeitr=k-1;
  for(int i=k;i<n;i++){
    if(count.find(vec[i].second)==count.end()){
      bool canremove=false;
      for(;removeitr>=0;removeitr--){
        if(count[vec[removeitr].second]>=2){
          canremove=true;
          break;
        }
      }
      if(canremove){
        count[vec[removeitr].second]--;
        point-=vec[removeitr].first;
        count[vec[i].second]++;
        point+=vec[i].first;
        point-=species*species;
        species++;
        point+=species*species;
        result=std::max(result,point);
        removeitr--;
      }
    }
  }
  cout<<result<<endl;


  return 0;
}


Measured memory_bytes: 5232
/*Infor {{{
 ******************************************************
 * > File Name: c.cpp
 * > Author: zrz_orz
 * > Mail: 1281941815@qq.com
 * > Created Time: 2018/9/8/周六 20:11:42
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
const int N = 100005;
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
int cz[N];
int n, X;
int x[N];
/*}}}*/

/*Declare {{{*/
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
/*}}}*/

/*Main {{{*/
int main() {
  scanf ("%d%d", &n, &X);
  for (int i = 1; i <= n; i++) {
    scanf ("%d", &x[i]);
  }
  x[n + 1] = X;
  if (n == 1) {
    cout<< abs(X - x[1])<< endl;
    return 0;
  }
  sort(x + 1, x + n + 2);
  int maxx = 0;
  for (int i = 2; i <= n + 1; i++) {
   cz[i - 1] = abs(x[i] - x[i - 1]);
  }
  maxx = gcd(cz[1], cz[2]);
  for (int i = 3; i < n + 1; i++) {
    maxx = gcd(maxx, cz[i]);
  }
  cout<<maxx<<endl;
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
	freopen("d.in","r",stdin);
	freopen("d.out","w",stdout);
}

const int MAXN=3000+7;

static int n,m,a[MAXN];

inline void init()
{
	read(n),read(m);
	Rep(i,1,n)read(a[i]);
}

const int mod=1e9+7,inv2=(mod+1)/2;

inline int power(int u,int v)
{
	static int sm;
	for(sm=1;v;v>>=1,u=1ll*u*u%mod)if(v&1)
		sm=1ll*sm*u%mod;
	return sm;
}

static int f[MAXN][MAXN],lef[MAXN][MAXN];

inline void solve()
{
	static int u,v;
	Rep(i,1,n-1)Rep(j,i+1,n)
	{
		if(a[i]<a[j])f[i][j]=1;
		if(a[i]>a[j])f[j][i]=1;
	}
	Rep(_,1,m)
	{
		read(u),read(v);
		Rep(i,1,n)lef[i][u]=lef[i][v]=lef[u][i]=lef[v][i]=0;
		Rep(i,1,n)if(i^u&&i^v)
		{
			lef[i][u]=(1ll*lef[i][u]+f[i][u]+f[i][v])%mod;
			lef[i][v]=(1ll*lef[i][v]+f[i][u]+f[i][v])%mod;
			lef[u][i]=(1ll*lef[u][i]+f[u][i]+f[v][i])%mod;
			lef[v][i]=(1ll*lef[v][i]+f[u][i]+f[v][i])%mod;
		}
		lef[u][v]=lef[v][u]=(f[u][v]+f[v][u])%mod;
		Rep(i,1,n)
		{
			f[i][u]=1ll*lef[i][u]*inv2%mod;
			f[i][v]=1ll*lef[i][v]*inv2%mod;
			f[u][i]=1ll*lef[u][i]*inv2%mod;
			f[v][i]=1ll*lef[v][i]*inv2%mod;
		}
	}
	static int ans=0;
	Rep(i,2,n)Rep(j,1,i-1)ans=(ans+f[i][j])%mod;
	ans=1ll*ans*power(2,m)%mod;
	cout<<ans<<endl;
}

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


Measured memory_bytes: 70912
import Control.Applicative
import Data.List

main = do
    _ <- getLine
    (a:b:_) <- map read . words <$> getLine
    c <- readLn
    toppings <- map read . lines <$> getContents
    print $ solve a b c toppings

solve :: Int -> Int -> Int -> [Int] -> Int
solve basePrice toppingPrice baseCalories toppings' =
    totalCalories `div` totalPrice
    where
        toppings = sortBy (flip compare) toppings'
        (totalPrice, totalCalories) =
            chooseToppings (basePrice,baseCalories) toppings
        chooseToppings p [] = p
        chooseToppings p@(currentPrice, currentCalories) (t:ts) =
            if currentCalories * toppingPrice < t * currentPrice
               then chooseToppings (
                   currentPrice + toppingPrice, currentCalories + t
                   ) ts
                else p

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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 = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

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

int main() {
    int n;
    cin>>n;
    int v[30],c[30],ans=0;
    for (int i = 0; i < n; i++) {
        cin>>v[i];
    }
    for (int i = 0; i < n; i++) {
        cin>>c[i];
    }
    for (int i = 0; i < n; i++) {
        if(v[i]>c[i]) ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

long long INF = 1e18;

int main(){
    int n;
    cin>>n;
    if(n%2==1){
        cout << (n / 2)  +1            << endl;
    }else{
        cout << n / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
mod = 10**9 + 7
n = int(input())
prev = None
s = []
d = defaultdict(list)
cnt = 0
for i in range(n):
    c = int(input())
    if prev == c:
        continue
    prev = c
    s.append(c)
    d[c].append(cnt)
    cnt += 1
#print(s)
DP = [0]*cnt
DP[0] = 1
e = {}
for i, c in enumerate(s):
    if i == cnt-1:
        break
    e[c] = e.get(c, 0) + 1
    j = e[c]
    DP[i+1] = (DP[i+1] + DP[i]) % mod
    if j < len(d[c]):
        DP[d[c][j]] = (DP[d[c][j]] + DP[i]) % mod
    #print(DP)
print(DP[-1])

Measured memory_bytes: 78108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x, d = 10, sum = 0;
  cin >> N;
  x = N;
  
  for (int i = 0; i < 8; i++) {
  sum += x % d;
  x /= d;
  }
  
  if (N % sum == 0) cout << "Yes";
  else cout << "No";
}

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

int main(){
	string S;
	long long K;
	cin>>S>>K;
	int pos = S.find_first_not_of('1');
	if(pos == string::npos) pos = 0;
	else if(K < pos+1) pos = 0;
	cout<<S[pos] <<endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=5000_0000_0000_0000
s=get_nsp.map(&:to_i)
k=gets.to_i
i=0
while true
  if s[i]==1
    break unless k>1
    i+=1
    k-=1
  else
    break
  end
end
puts s[i]

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

int main() {
  char a,b,c,d; cin >> a >> b >> c >> d;
  vector<char>v{a,b,c,d};
  sort(v.begin(),v.end());
  if(v[0]==v[1]&&v[1]!=v[2]&&v[2]==v[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long int;

int main(void) {
	int n;
	cin >> n;
	vector<int> c(n), v(n), tmp(n);
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
		tmp[i] = v[i] - c[i];
	}
	
	int ret = 0;
	rep(i, n) {
		if (tmp[i] > 0) {
			ret += tmp[i];
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

def divlist(x):
  numbers = []
  divX = []
  try:
    for i in range(1,x+1):
      numbers.append(i)
      if x % i == 0:
        divX.append(i)
    divX = set(divX)
    return divX
  except ZeroDivisionError:
      print("ZeroDivisionError!!")

divA = divlist(A)
divB = divlist(B)
common = list(divA & divB)
common = sorted(common)

#print("divA:", divA)
#print("divB:", divB)
#print("common:", common)
print(common[-K])

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
double sum;
int main()
{
	int n;
	cin>>n;
	string t;
	while(n--)
	{
		double x;
		cin>>x>>t;
		if(t=="JPY")
			sum+=x;
		else
			sum+=x*380000.0;
	}
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
int n,a[100005];
bool work(){
	int num1=0,num2=0;
	for(int i=1;i<=n;i++)
		if(a[i]>1){
			if(a[i]&1)
				num1++;
			else
				num2++;
		}
	if(!num1&&!num2)
		return false;
	if(num2&1)
		return true;
	if(num1>1||!num1)
		return false;
	for(int i=1;i<=n;i++)
		if(a[i]>1&&a[i]&1){
			a[i]--;
			break;
		}
	int d=a[1];
	for(int i=2;i<=n;i++)
		d=__gcd(d,a[i]);
	for(int i=1;i<=n;i++)
		a[i]/=d;
	return !work();
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	puts(work()?"First":"Second");
	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  rep(i,n){
  	 cin >> a[i];
  	 sum += a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  if(4*m*a[m - 1] < sum) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def insertionSort(A,n,g,count):
    for i in range(g,N):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            count += 1
        A[j+g] = v
    return count

def shellSort(A,n):
    count = 0
    m = 0
    G = []
    while (3**(m+1)-1)//2 <= n:
        m += 1
        G.append((3**m-1)//2)
    for i in range(m):
        count = insertionSort(A,n,G[-1-i],count)
    return m,G,count

import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

m,G,count = shellSort(A,N)

print(m)
print(*G[::-1])
print(count)
print('\n'.join(map(str,A)))


Measured memory_bytes: 125984
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    print(N*800-200*(N//15))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const string YES = "YES";
const string NO = "NO";

void solve(long long X){
    if(X ==3||X==5||X==7){
        cout << YES << endl;
    }else{
        cout << NO <<endl;
    }

}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;

ll gcd(ll a, ll b) {
    if (a == 0) return b;
    else return gcd(b%a, a);
}
int main() {
    ll a,b;
    scanf("%lld %lld", &a,&b);
    int ans = gcd(a,b);
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 2084
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
int a[102],s1[102]={0},s2[102]={0};
int main()
{
   int n;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    int sum=0;
   for(int i=1;i<=n;i++)
    {
        sum+=a[i];
        s1[i]=sum;
    }
    sum=0;
    for(int i=n;i>=1;i--)
    {
        sum+=a[i];
        s2[i]=sum;
    }
    int mn=100000000;
    for(int i=1;i<n;i++)
    {
        int m;
        m=max(s1[i]-s2[i+1],s2[i+1]-s1[i]);
        if(m<mn)
            mn=m;
    }
    printf("%d\n",mn);

}



Measured memory_bytes: 256
n,a,b=map(int,input().split())
arr=[int(input()) for _ in range(n)]
l=0
r=10**9+1
while r-l!=1:
  tmp=0
  m=(l+r)//2
  for i in range(n):
    if m*b>=arr[i]:
      continue
    else:
      tmp+=(arr[i]-m*b+(a-b-1))//(a-b)
  if tmp<=m:
    r=m
  else:
    l=m
print(r)

Measured memory_bytes: 7096
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	int K, A, B;
	cin >> K >> A >> B;

	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	
	return 0;

}

Measured memory_bytes: 3632
a=[]
for i in range(5):
  a.append(int(input()))
k=int(input())
cnt=0
for l in range(5):
  for j in range(1,5-l):
    if a[l+j]-a[l]>k:
        cnt+=1
    else:
        cnt=cnt
if cnt==0:
  print('Yay!')
else:
  print(':(')
  

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

int main(){
  int n,m;
  cin >> n >> m;
  int city[n+1] = {0};
  int a[m] = {0}, b[m] = {0};
  for(int i=0;i<m;i++) cin >> a[i] >> b[i];
  for(int i=0;i<m;i++){
    city[a[i]]++;
    city[b[i]]++;
  }
  for(int i=1;i<=n;i++) cout << city[i] << endl;

}
    
 


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

int c[301000];
int a[301000], st[301000], top, n;

void add(int x) {for(int i = x; i <= n; i += i & -i) c[i]++;}
int query(int x) {int ans = 0;for(int i = x; i; i -= i & -i) ans += c[i]; return ans;}

bool check1()
{
	for(int i = 1; i <= n; i++)
	{
		if((a[i] - i) & 1) return false;
	}
	return true;
}

bool check2()
{
	for(int i = 1; i <= n - 2; i++)
	{
		if(a[i] != i && a[i + 1] != i + 1 && a[i + 2] != i + 2) return false;
	}
	return true;
}

bool check3()
{
	long long sum = 0;
	for(int i = n; i >= 1; i--)
	{
		sum += query(a[i]);
		add(a[i]);
	}
	if(sum % 3 != 0) return false;
	return true;
}

bool check4()
{
	top = 0;
	st[++top] = a[1];
	for(int i = 3; i <= n; i += 2)
	{
		if(st[top] > a[i]) st[++top] = a[i];
		else
		{
			int l = 1, r = top + 1;
			while(l < r)
			{
				int mid = l + r >> 1;
				if(st[mid] < a[i]) r = mid;
				else l = mid + 1;
			}
			st[r] = a[i];
		}
	}
	if(top > 2) return false;
	top = 0;
	st[++top] = a[2];
	for(int i = 2; i <= n; i += 2)
	{
		if(st[top] > a[i]) st[++top] = a[i];
		else
		{
			int l = 1, r = top + 1;
			while(l < r)
			{
				int mid = l + r >> 1;
				if(st[mid] < a[i]) r = mid;
				else l = mid + 1;
			}
			st[r] = a[i];
		}
	}
	if(top > 2) return false;
	return true;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	if(check1() && check2() && check3() && check4()) puts("Yes");
	else puts("No");
	return 0;
}

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






int main() {
  int n;
  cin >> n;
  long long values[n];
  for(int i = 0; i< n; i++) cin >> values[i];
  int eksiler = 0;
  long long res = 0;
  int ind;
  long long larges = 1000000001;
  for(int i = 0; i < n;i++) {
    if(values[i] < 0) eksiler++;
    if(abs(values[i]) < larges) {larges = abs(values[i]);ind = i;}
  }

  if(eksiler%2 == 0) {
    for(int i = 0; i < n;i++) res += abs(values[i]);
  }
  else{
    if(values[ind] < 0) {
      for(int i = 0; i < n;i++) res += abs(values[i]);
      res += 2*values[ind];
    }
    else {
      for(int i = 0; i < n;i++) res += abs(values[i]);
      res -= 2*values[ind];
    }
  }
  cout << res;


}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
ans=0
tmp=0
for i in range(n):
  tmp+=a[i]
  if i%2==0:
    if tmp<=0:
      ans+=abs(tmp)+1
      tmp=1
  else:
    if tmp>=0:
      ans+=abs(tmp)+1
      tmp=-1

tmp=0
tmp2=0
for i in range(n):
  tmp+=a[i]
  if i %2==0:
    if tmp>=0:
      tmp2+=abs(tmp)+1
      tmp=-1
  else:
    if tmp<=0:
      tmp2+=abs(tmp)+1
      tmp=1
print(min(ans,tmp2))
    

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  int res = 0;
  for (int i = 0; i < N;) {
    int j = i + 1;
    while (j < N && a[j] <= a[j-1]) ++j;
    res = max(res, j - i - 1);
    i = j;
  }
  cout << res << endl;
}

Measured memory_bytes: 3716
#include <iostream>

using namespace std;

int main() {
    long long N;
    long long sum = 0;
    cin >> N;
    while(N!= 0)
    {
        if ((N % 3 == 0) && (N % 5 == 0))
        {
            N--;
        }
        else if (N % 3 == 0)
        {
            N--;
        }
        else if (N % 5 == 0)
        {
            N--;
        }
        else
        {
            sum = sum + N;
            N--;
        }
    }
    cout << sum;


    return 0;
}


Measured memory_bytes: 3632
from collections import Counter


def ok(n, D):
    # Dに含まれる数字をnで使っていたらFalse
    counter = Counter(str(n))
    for d in D:
        if counter[str(d)] > 0:
            return False
    return True


def main():
    N, K = list(map(int, input().split(' ')))
    D = list(map(int, input().split(' ')))
    while not ok(N, D):
        N += 1
    print(N)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

struct Card {char suit, value;};

void bubble_sort(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j].value < A[j - 1].value) swap(A[j], A[j - 1]);
        }
    }
}

void selection_sort(struct Card A[], int N) {
    int minj;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;
        }
        swap(A[i], A[minj]);
    }
}

void print(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i) cout << ' ';
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

int main() {
    int N, flag;
    struct Card C1[36], C2[36];

    cin >> N;

    for (int i = 0; i < N; i++) cin >> C1[i].suit >> C1[i].value;
    for (int i = 0; i < N; i++) C2[i] = C1[i];

    bubble_sort(C1, N);
    selection_sort(C2, N);

    print(C1, N);
    cout << "Stable" << endl;

    print(C2, N);

    flag = 0;
    for (int i = 0; i < N; i++) {
        if (C2[i].suit != C1[i].suit) flag = 1;
    }

    if (flag) {
        cout << "Not stable" << endl;
    } else {
        cout << "Stable" << endl;
    }


}


Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main() {
    int N;
    char S[51];
    cin >> N >> S;
    int cnt = 0;
    for (int i = 0; i < N - 2; ++i) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin>>n>>x;

    set<ll> s;
    s.insert(x);

    vector<ll> a(n),dp(x+1,0LL);
    for(int i=0;i<n;i++)cin>>a[i];
    dp[x]=1;
    sort(a.rbegin(),a.rend());
    for(int i=0;i<n;i++){
    	ll m=a[i];
    	for(auto& v:s){
    		if(v<m){
    			(dp[v]*=(n-i))%=mod;
    		}else{
    			s.insert(v%m);
    			(dp[v%m]+=dp[v])%=mod;
    			(dp[v]*=(n-i-1))%=mod;
    		}
    	}
    }
    ll ans=0;
    for(int i=0;i<=x;i++){
    	(ans+=dp[i]*i)%=mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408