akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const int MAXN = 100005;
const int INF = (LL)1e9 + 5;
const LL MOD = 1000000007;

LL mod_inv(LL a) {
	LL pw = MOD - 2, res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		pw >>= 1;
		a = a * a % MOD;
	}
	return res;
}

int N;
LL sum[MAXN], pref[MAXN], fac = 1;

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

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> pref[i];
		pref[i] = (pref[i - 1] + pref[i]) % MOD;
		fac = (fac * i) % MOD;
	}
	
	sum[1] = pref[N];
	for (int i = 2; i <= N; i++) {
		sum[i] = (sum[i - 1] + pref[N - i + 1] - pref[i - 1]) % MOD;
//		cout << i << " -> " << sum[i] << '\n';
	}
	
	LL ans = 0;
	for (int i = 1; i < N; i++) {
//		cout << i << " add " << (sum[i] - pref[i] - (pref[N] - pref[N - i])) << " mul " << mod_inv((LL) (i + 2) * (i + 1) % MOD) * fac % MOD << '\n';
		ans = (ans + (sum[i] - pref[i] - (pref[N] - pref[N - i])) % MOD * 2 * mod_inv((LL) (i + 2) * (i + 1) % MOD)) % MOD;
	}
	
	ans = (ans + pref[N]) % MOD;
	for (int i = 1; i < N; i++) {
		LL s = pref[i];
//		cout << "Pref " << i << " add " << s << ' ' << fac * mod_inv(i + 1) % MOD << '\n';
		ans += s * mod_inv(i + 1);
		ans %= MOD;
	}
	for (int i = 2; i <= N; i++) {
		LL s = (pref[N] - pref[i - 1]) % MOD;
//		cout << "suff " << i << " add " << s << ' ' << fac * mod_inv(N - i + 2) % MOD << '\n';
		ans += s * mod_inv(N - i + 2);
		ans %= MOD;
	}
	
	cout << (ans * fac % MOD + MOD) % MOD << '\n';

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
char a[100001];
int c,d;
int main()
{
	scanf("%s",a);
	int str=strlen(a);
	for(int i=0;i<str;i++)
	{
		d=10*d+a[i]-'0';
		c+=a[i]-'0';
	}
	if(d%c==0)cout<<"Yes";
	else cout<<"No"; 
	return 0;
}

Measured memory_bytes: 256
import numpy as np

nk = input().split(' ')
n, k = (int(nk[0]), int(nk[1]))
l = [int(num) for num in input().split(' ')]
max = 0
for _ in range(k):
    m = np.array(l).max()
    max += m
    l.remove(m)
print(max)


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

int N;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    bool sec = true;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 1) {
            sec = false;
            break;
        }
    }

    cout << (sec ? "second" : "first") << endl;

    return 0;
}


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

int main() {
  int a = 0;
  int b  =0;
  cin >> a;

  b = a%3;

  switch (b)
  {
    case 0:
      if (a == 0)
        a = 0;
      else
      {
          a =3;
      }
      
      break;
    case 1:
      a = 1;
      break;
    case 2:
      a = 2;
      break;
  }

  cout << a;

  return 0;
}

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

using namespace std;

int main(){
  int i,N,K,j;
  int dp[100001],h[100001];
  long long minv;
  cin >> N;
  cin >> K;
  for (i=0;i<N;++i) {
    cin >> h[i];
  }
  dp[0]=0;
  for (i=1;i<N;++i) {
    minv=9999999999;
    for (j=1;j<=K;++j) {
      if (i-j < 0) {
        break;
      }
      if (dp[i-j]+abs(h[i-j]-h[i]) < minv) {
        minv=dp[i-j]+abs(h[i-j]-h[i]);
      }
    }
    dp[i]=minv;
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  vector<int> rui(N+1);
  for( int i = 0; i < N; i++ ){
    rui[i+1] = rui[i];
    if( S.at(i) == 'R' ) rui[i+1]++;
  }

  int ans = 2000000;
  for( int i = 0; i <= N; i++ ){
    int kae1 = i-rui[i];
    int kae2 = rui[N]-rui[i];

    ans = min(ans, kae1+kae2-min(kae1, kae2));
    //cout << kae1+kae2 << endl;
  }
  cout << ans << endl;

}


Measured memory_bytes: 5240
#include<iostream>
using namespace std;
int N,x,y,D;
string s[30];
bool f()
{
	int now=x-1;
	for(int i=0;i<D;i++)
	{
		if(now>0&&s[i][now-1]=='1')now--;
		else if(now<N-1&&s[i][now]=='1')now++;
	}
	return now==y-1;
}
main()
{
	while(cin>>N,N)
	{
		cin>>x>>y>>D;
		for(int i=0;i<D;i++)cin>>s[i];
		if(f())
		{
			cout<<0<<endl;
		}
		else
		{
			bool g=true;
			for(int i=0;i<D;i++)
			{
				for(int j=0;j<N-1;j++)
				{
					if(s[i][j]=='0'&&(j==0||s[i][j-1]=='0')&&(j==N-2||s[i][j+1]=='0'))
					{
						s[i][j]='1';
						if(f())
						{
							g=false;
							cout<<i+1<<" "<<j+1<<endl;
							break;
						}
						s[i][j]='0';
					}
				}
				if(!g)break;
			}
			if(g)cout<<1<<endl;
		}
	}
}



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

using namespace std;
const int N = 1<<20;
struct node
{
    int l,r,id;
}Q[N];

int ans[N];
long long answer[N];
long long flag[N];
int a[N];
bool cmp(node x,node y)
{
    if(ans[x.l]==ans[y.l])
        return x.r<y.r;
    return ans[x.l]<ans[y.l];
}
int n,m,k;
int L = 1,R = 0;
long long Ans= 0;
int num[N];
void add(int x)
{
    num[a[x]]++;
    if(num[a[x]]==1)
        Ans++;
}
void del(int x)
{
    num[a[x]]--;
    if(num[a[x]]==0)
        Ans--;
}
int main()
{
    scanf("%d%d",&n,&m);
    int sz = sqrt(n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        ans[i] = i/sz;
    }
    for(int i = 1; i <= m; i++)
    {
        scanf("%d%d",&Q[i].l,&Q[i].r);
        Q[i].id = i;
    }
    sort(Q+1,Q+m+1,cmp);
    for(int i = 1; i <= m; i++)
    {
        while(L<Q[i].l)
        {
            del(L);
            L++;
        }
        while(L>Q[i].l)
        {
            add(L-1);
            L--;
        }
        while(R<Q[i].r)
        {
            R++;
            add(R);
        }
        while(R>Q[i].r)
        {
            del(R);
            R--;
        }
        answer[Q[i].id] = Ans;
    }
    for(int i = 1; i <= m; i++)
    {
        printf("%lld\n",answer[i]);
    }
    return 0;
}


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

using namespace std;

long long h;
long long sum;
long long twoo = 1;
long long ssum;

int main(void)
{
	scanf("%lld", &h);
	
	if(h == 1)
	{
		printf("1");
		return 0;
	}
	
	while(h > 0)
	{
		ssum++;
		h /= 2;
	}
	
	for(int i = 0 ; i < ssum ; i++)
	{
		twoo *= 2;
	}
	
	printf("%lld", twoo - 1);
	return 0;
}

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

#define x first
#define y second
#define PII pair<int,int>
#define LL long long
#define pb push_back
#define pqp priority_queue<PII,vector<PII>,greater<PII>>
#define pqi priority_queue<int,vector<int>,greater<int>>
#define PSS pair<string,string>

using namespace std;

const int N = 2e5+10;

int a[N];
vector<int> e[N];
int dist[N];
int book[N],book2[N];
int dx[]=  {0,-1,0,1,0,0},dy[]= {-1,0,1,0,0,0},dz[] = {0,0,0,0,-1,1};
int t;
int n,m, res;

void bfs()
{
    memset(dist,0x3f,sizeof dist);
    queue<int> q;
    q.push(1);
    dist[1] = 0;
    int cnt = 1;

    while(!q.empty() && cnt != n)
    {
        int t = q.front(); q.pop();

        for(auto x : e[t])
        {
            if(dist[x] == 0x3f3f3f3f)
            {
                cnt ++;
                dist[x] = t;
                q.push(x);
            }
            if(cnt == n) break;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 1 ; i <= m; i ++)
    {
        int a,b; cin >> a >> b;
        e[a].pb(b);
        e[b].pb(a);
    }

    bfs();

    for(int i = 2 ; i <= n;i ++)
    {
        if(dist[i] == 0x3f3f3f3f)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << "\n";
    for(int i = 2 ;i <= n; i ++) cout << dist[i] <<endl;

    return 0;

}


Measured memory_bytes: 13268
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>


int main() {
  ll n, m;
  cin >> n >> m;
  ll a = 0, b = 0;
  map<ll, ll> mp;
  ll p[m];
  string s[m];
  map<ll, ll> mpp;
  for (ll i = 0; i < m; i++) {
    cin >> p[i] >> s[i];
    if (s[i] == "AC") mpp[p[i]] = 1;
  }

  for (ll i = 0; i < m; i++) {
    if (mp[p[i]] == 0) {
      if (s[i] == "AC") {
        b++;
        mp[p[i]] = 1;
      } else if (mpp[p[i]] == 1){
        a++;
      }
    }
  }
  cout << b << ' ' << a << endl;
  return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    map<string, ll> m;
    rep(i, n) m[s[i]]++;
    ll mv = 0;
    for(auto x : m) {
        if (x.second > mv) {
            mv = x.second;
        }
    }
    for(auto x : m) {
        if (x.second == mv) {
            cout << x.first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25472
import random

D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]

plus=0
minus=0
data=[[1 for i in range(D)] for j in range(26)]
ans=[0]*D
for i in range(D):
    t=random.randint(1,26)
    ans[i]=t
    plus+=s[i][t-1]
    if i!=0:
        for j in range(26):
            data[j][i]=data[j][i-1]+1
    data[t-1][i]=0
    minus+=sum(c[j]*data[j][i] for j in range(26))

eval=plus-minus
count=150000
while count:
    d=random.randint(1,D)
    q=random.randint(1,26)
    if ans[d-1]==q:
        continue
    testplus=plus+s[d-1][q-1]-s[d-1][ans[d-1]-1]
    testminus=minus
    pre=ans[d-1]
    #print("pre",pre)
    "ans[d-1]=q"

    day=0
    for j in range(d-1,D):
        if data[q-1][j]!=0:
            if j==d-1:
                testminus+=day*c[q-1]-data[q-1][d-1]*c[q-1]
            else:
                testminus+=(day+1-data[q-1][j])*c[q-1]
                day+=1
        else:
            break

    day=0
    for j in range(d-1,D):
        if j==d-1:
            if j==0:
                day=1
                testminus+=c[pre-1]*day
            else:
                day=1+data[pre-1][j-1]
                testminus+=c[pre-1]*day
        elif data[pre-1][j]!=0:
            testminus+=(day+1-data[pre-1][j])*c[pre-1]
            day+=1
        else:
            break

    if testplus-testminus>eval:
        eval=testplus-testminus
        plus=testplus
        minus=testminus
        ans[d-1]=q
        for j in range(d-1,D):
            if data[q-1][j]!=0:
                if j==d-1:
                    data[q-1][d-1]=0
                else:
                    data[q-1][j]=data[q-1][j-1]+1
            else:
                break

        for j in range(d-1,D):
            if j==d-1:
                if j==0:
                    data[q-1][j]=1
                else:
                    data[q-1][j]=1+data[pre-1][j-1]
            elif data[pre-1][j]!=0:
                data[q-1][j]=data[q-1][j-1]+1
            else:
                break
    count-=1

#print(eval)
for i in range(D):
    print(ans[i])

Measured memory_bytes: 89684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
const int MOD = 1e9 + 7;
#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
int main() {
    int n, w, V = 0;
    cin >> n >> w;
    vi wt(n), v(n);
    for (int i = 0; i < n; ++i) {
        cin >> wt[i] >> v[i];
        V += v[i];
    }
    vi dp(V+1, MOD);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = V - v[i]; j >= 0; --j) {
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + wt[i]);
        }
    }
    ll ans = 0;
    for (int i = V; i >= 0; --i)
        if (dp[i] <= w) {
            ans = i;
            break;
        } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int N,d,num[110]={},ans=0;

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> d;
    num[d]++;
  }
  for(int i=0;i<110;i++){
    if(num[i]!=0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    A = LI()

    pre = 0
    ans = 0
    for a in A:
        if a < pre:
            sa = pre - a
            ans += sa
        else:
            pre = a
    print(ans)


if __name__ == '__main__':
    solve()



Measured memory_bytes: 32424
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

int n,mx;
int a[N],s[N],S[N];

int c[N<<1];
inline int lowbit(int x) { return x&-x; }
inline void add(int x,int y) {
    for (;x<=mx;x+=lowbit(x)) c[x]+=y;
}
inline int query(int x) {
    int res=0;
    for (;x;x-=lowbit(x)) res+=c[x];
    return res;
}

inline int check(int mid) {
    memset(c,0,sizeof(c)),mx=0;
    for (re int i=1;i<=n;++i) {
        if (a[i]<mid) s[i]=-1;
        else s[i]=1;
    }
    ll res=0;
    for (re int i=1;i<=n;++i) s[i]+=s[i-1],res+=(s[i]>=0);
    for (re int i=1;i<=n;++i) s[i]+=n+1,mx=max(mx,s[i]);
    for (re int i=1;i<=n;++i) res+=query(s[i]),add(s[i],1);
    ll cnt=1ll*n*(n-1)/2+n;
    return cnt-res<cnt/2+1;
}

int main() {
    n=read();
    for (re int i=1;i<=n;++i) S[i]=a[i]=read();
    sort(S+1,S+n+1); int m=unique(S+1,S+n+1)-S-1;
    for (re int i=1;i<=n;++i) a[i]=lower_bound(S+1,S+m+1,a[i])-S;
    int L=1,R=m,ans=0;
    while (L<R) {
        int mid=(L+R+1)>>1;
        if (check(mid)) L=mid;
        else R=mid-1;
    }
    printf("%d\n",S[L]);
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef struct{
  int right;
  int left;
  int daturaku;
}Player;
main(){
  int m,n;
  Player p[10005];
  char sengen[10];
  while(1){
    cin>>m>>n;
    if(m==0&&n==0)break;
    for(int i=1;i<=m;i++){
      p[i].left=i-1;
      p[i].right=i+1;
      p[i].daturaku=0;
    }
    p[1].left=m;
    p[m].right=1;
    int menber=m;
    int now=1;
    for(int i=1;i<=n;i++){
      cin>>sengen;
      if(menber==1){
	continue;
      }
      bool deff=false;
      int beki=log10(i)+1;
      int num=atoi(sengen);
      if(strcmp("Fizz",sengen)==0){
	if(i%3!=0||i%15==0){
	  deff=true;
	}
      }
      else if(strcmp("Buzz",sengen)==0){
	if(i%5!=0||i%15==0){
	  deff=true;
	}
      }
      else if(strcmp("FizzBuzz",sengen)==0){
	if(i%15!=0){
	  deff=true;
	}
      }
      else if(strlen(sengen)!=beki||num!=i||num%3==0||num%5==0){
	deff=true;
      }
      if(deff==true){
	p[p[now].left].right=p[now].right;
	p[p[now].right].left=p[now].left;
	p[now].daturaku=1;
	menber--;
      }
      now=p[now].right;
    }
    bool nidome=false;
    for(int i=1;i<=m;i++){
      if(p[i].daturaku==0){
	if(nidome==true){
	  cout<<' ';
	}
	else{
	  nidome=true;
	}
	cout<<i;
      }
    }
    cout<<endl;
  }
}

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


int main(){
    int a, b;
    cin >> a >> b;
    int point = 0;
    for (int i = 0; i < 2; i++){
        if (a > b){
            point += a;
            a--;
        }else{
            point += b;
            b--;
        }
    }

    cout << point << endl;

    return 0;
}

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


using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define DOUBLE fixed << setprecision(10)
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Ps(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void Pvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}

ll  n, m, r, l, k, h, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

void INIT() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << DOUBLE;
}

int main() {
	INIT();
	/*ll a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 1) cout << "IMPOSSIBLE\n";
	else cout << (a + b) / 2 << endl;
	*/
	cin >> n;
	vll v(n);
	rep(i, n) cin >> v[i];
	rep(i, n) {
		rep(j, n) {
			flag = true;
			vll w = v;
			swap(w[i], w[j]);
			//Pvll(w);
			rep(k, n - 1) if (w[k] > w[k + 1]) {
				//cout << w[k] << " " << w[k+1] << endl;
				flag = false;
				break;
			}
			if (flag) {
				YES(1);
				return 0;
			}
		}
	}
	YES(0);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5 + 5;
string s;

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int h = 0, w = 0;
	cin >> h >> w;
	string s;
	vector<string> a;
	for(int i = 0; i < h; ++i){
		cin >> s;
		a.push_back(s);
	}
	for(int i = 0; i < w+2; ++i){
		cout << "#";
	}
	cout << endl;
	for(int i = 0; i < h; ++i){
		cout << "#" << a[i] << "#" << endl;
	}
	for(int i = 0; i < w+2; ++i){
		cout << "#";
	}
	cout << endl;




    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int p;
    scanf("%d", &p);
    int h, m, s;
    h = p / 3600;
    m = (p - h * 3600) / 60;
    s = p - (h * 3600 + m * 60);
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2096
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(void) {
	int n;

	cin >> n;

	vector<int>a(n);

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

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

	cout << a[n - 1] - a[0] << endl;

	return 0;
}

Measured memory_bytes: 256
$primes = [2,3]

def is_prime?(n)
	i = 0
	while $primes[i] <= Math.sqrt(n).to_i
		return false if n % $primes[i] == 0
		i += 1
	end
	return true
end

def next_prime(n)
	n += 1 if n % 2 == 0
	loop do
		return n if is_prime?(n)
		n += 2
	end
end

def make_prime(n)
	while $primes[-1] <= n
		$primes << next_prime($primes[-1]+1)
	end
end

while gets
	n = $_.to_i
	if n < 0 || 1000000 < n
		puts "n must be in the range (1..999999)"
		next
	end
	make_prime(n)
	puts $primes[0,$primes.index{|x| x>n}].size
end

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

using namespace std;
using ll = long long;

bool solve() {
  unordered_map<int, bool> map;

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (map[A]) {
      return false;
    }
    map[A] = true;
  }

  return true;
}

int main() {
  if (solve()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 8520
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,cev,b,a[li],k;
string s;
vector<int> v;

inline int solve(){
	n=5;
	FOR{
		scanf("%d",&a[i]);
	}
	scanf("%d",&m);
	if(a[n]-a[1]>m){printf(":(\n");return 0;}
	printf("Yay!\n");
	return 0;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int cnt=0;;
	int i,j,n,m,amari,syo;
	while(1) {
		scanf("%d %d",&n,&m);
		if(n==0 && m==0) break;
		if(n<m) swap(n,m);
		while(1) {
			n=n%m;
			swap(n,m);
			cnt++;
			if(m==0) break;
		}
		
		printf("%d %d\n",n,cnt);
		cnt=0;
	}
	return 0;
}
		
		

Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  bool judge = true;
  for(int i = 0; i< s.size(); i++){
    
  if(s.at(i) != t.at(i)) {
    judge = false;
    cout << "No" << endl;
    break;
  }
  }
  if (judge == true) {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str,ptr;


   cin>>str>>ptr;

     for(i=0; i<3; i++)
     {
         ans+=(str[i]==ptr[i]);
     }

     cout<<ans<<endl;










}



Measured memory_bytes: 3620
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

	uint16_t n;
	cin >> n;
	// 1~n のうち奇数の個数がわかればよい
	short odd, even;
	if (n%2 == 0) { // n 偶数
		even = n / 2;
		odd = even;
	} else { // n 奇数
		even = (n-1)/2;
		odd = even + 1;
	}


	cout << ((double)odd)/n << endl;
	return 0;
}

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

using namespace std;

const int Nmax = 205, lim = 1e7 + 5;

int n, a[Nmax];
bitset<lim+3> prim;


int modul(int x) { return (x>0?x:-x); }

class Graph
{
    vector<int> edge[Nmax];
    bool marked[Nmax];
    int L[Nmax], R[Nmax];

    bool cupleaza(int node)
    {
        if(marked[node]) return 0;
        marked[node] = 1;

        for(auto it : edge[node])
            if(R[it] == -1)
            {
                L[node] = it;
                R[it] = node;
                return 1;
            }

        for(auto it : edge[node])
            if(cupleaza(R[it]))
            {
                L[node] = it;
                R[it] = node;
                return 1;
            }
        return 0;
    }

public:
    void add_edge(int x, int y)
    {
        edge[x].push_back(y);
    }

    int cuplaj(int n, int m)
    {
        int done = 1, i;
        for(i=0; i<n; ++i) L[i] = -1;
        for(i=0; i<m; ++i) R[i] = -1;

        while(done)
        {
            done = 0;
            memset(marked, 0, sizeof(marked));

            for(i=0; i<n; ++i)
                if(L[i] == -1) done |= cupleaza(i);
        }

        int cnt = 0;
        for(i=0; i<n; ++i) cnt += (L[i] != -1);
        return cnt;
    }

} graph;

void prec()
{
    int i, j;

    prim.set();
    prim[1] = 0;
    for(i=2; i*i <= lim; ++i)
        if(prim[i])
            for(j=i*i; j<=lim; j+=i)
                prim[j] = 0;
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    prec();

    int i, j;
    vector<int> p, impar, par;

    cin >> n;
    for(i=1; i<=n; ++i) cin >> a[i];

    for(i=1; i<=n; ++i)
    {
        j = i;
        while(a[j] - a[i] == j - i) ++j;

        p.push_back(a[i]);
        p.push_back(a[j-1] + 1);

        i = j - 1;
    }

    for(auto it : p)
        if(it & 1) impar.push_back(it);
            else par.push_back(it);

    for(i=0; i<impar.size(); ++i)
        for(j=0; j<par.size(); ++j)
            if(prim[modul(impar[i] - par[j])]) graph.add_edge(i, j);

    int best = graph.cuplaj(impar.size(), par.size()), A, B;

    A = impar.size() - best;
    B = par.size() - best;

    cout << best + 2 * (A/2 + B/2) + 3 * (A&1) << '\n';
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;

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

	int a, b;

	cin >> a >> b;

	if(a <= b) {
		for(int i = 0; i < b; i++) {
			cout << a;
		}
	} else {
		for(int i = 0; i < a; i++) {
			cout << b;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<long long int, long long int> P;

int main(void) {
	long long int n;
	long long int point;
	long long int total = 0;
	bool flag = false;
	long long int result;
	long long int pos = 0;
	

	cin >> n;
	vector<long long int>a(n);
	vector<long long int>dp(n, 0);
	FOR(i, 0, n - 1) {
		cin >> a[i];
	}

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

	dp[0] = a[0];
	FOR(i, 1, n - 1) {
		dp[i] = dp[i - 1] + a[i];
	}

	FOR(i, 0, n - 2) {
		if (a[i+1] <= 2*dp[i]) {
			continue;
		}
		else {
			pos = i + 1;
		}
	}

	cout << n - pos << endl;

	return 0;
}

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

signed main() {
    ll k, n;
    cin >> k >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    ll b[n];
    rep(i, n) {
        b[i] = a[i + 1] - a[i];
        if (i == n - 1) b[i] = k - a[i] + a[0];
    }
    ll mx = 0;
    rep(i, n) {
        mx = max(mx, b[i]);
    }
    cout << k-mx << endl;
    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define ld long double
using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    double csum[n + 5], ans;

    csum[0] = 0;

    for(int i = 1; i <= n; i++){
        int x;

        cin >> x;

        double tmp = ((x + 1) / 2.0);
        csum[i] = tmp + csum[i - 1];
    }

    for(int i = k; i <= n; i++){
        double temp = (csum[i] - csum[i - k]);
        ans = max(ans, temp);
    }

    cout << fixed << setprecision(12);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner sc  = new Scanner(System.in);
		int a[][] = new int[3][3];
		for(int i=0;i<a.length;i++){
			for(int j=0;j<a[i].length;j++){
				a[i][j]=sc.nextInt();
			}
		}
		int h[] = {0,0,0};
		int w[] = {0,0,0};
		int nn[] = {0,0};
		int n = sc.nextInt();
		for(int k=0;k<n;k++){
			int b = sc.nextInt();
			for(int i=0;i<a.length;i++){
				for(int j=0;j<a[i].length;j++){
					if(a[i][j]==b){
						a[i][j]=0;
						h[i]++;
						w[j]++;
						if(i==1&&j==1){
							nn[0]++;
							nn[1]++;
						}else if(i==j){
							nn[0]++;
						}else if(i==a.length-1-j||j==a.length-1-i){
							nn[1]++;
						}
					}
				}
			}
		}
		for(int i=0;i<3;i++){
			if(h[i]==3||w[i]==3){
				System.out.println("Yes");
				System.exit(0);
			}
		}	
		for(int i=0;i<2;i++){
			if(nn[i]==3){
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <cmath>

using namespace std;

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

  int comb[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      comb[i][j] = 0;
    }
  }

  for (int i = 1; i <= n; i++) {
    int first = i;
    while (first >= 10) {
      first /= 10;
    }
    int last = i % 10;
    comb[first][last] += 1;
  }


  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += comb[i][j] * comb[j][i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
  const inputList = input.split('\n');
  const n = Number(inputList[0].split(' ')[0])
  const m = Number(inputList[0].split(' ')[1])
  const heightList = inputList[1].split(' ').map(height => Number(height))
  const routeList = inputList.slice(2)

  let goodTowers = new Array(n)
  goodTowers.fill(1)
  for (let i=0; i<routeList.length; i++) {
    const tmpTower = routeList[i].split(' ')
    const a = Number(tmpTower[0]) - 1 
    const b = Number(tmpTower[1]) - 1

    if (heightList[a] < heightList[b]) {
      goodTowers[a] = 0
    } else if (heightList[a] > heightList[b]) {
      goodTowers[b] = 0
    } else {
      goodTowers[a] = 0
      goodTowers[b] = 0
    }
  }

  let count = 0;
  for (let i=0; i<goodTowers.length; i++) {
    count += goodTowers[i]
  }
  console.log(count)

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 56160
/// IN THE NAME OF GUITAR
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;
 
#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
 
ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
 
const ll MAXN = 3e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll A[MAXN], n, m, inv = Pow(2, MOD - 2, MOD), ans = 0, dp[MAXN][MAXN];

int main() {
    scanf("%lld%lld", &n, &m);
    for (ll i = 1; i <= n; i++) scanf("%lld", &A[i]);
    for (ll i = 1; i <= n; i++) for (ll j = 1; j <= n; j++) if (A[i] > A[j]) dp[i][j] = 1;
    for (ll i = 1; i <= m; i++) {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) % MOD * inv % MOD;
        for (ll j = 1; j <= n; j++) if (j != x && j != y) {
            dp[x][j] = dp[y][j] = (dp[x][j] + dp[y][j]) % MOD * inv % MOD;
            dp[j][x] = dp[j][y] = (dp[j][x] + dp[j][y]) % MOD * inv % MOD;
        }
    }
    for (ll i = 1; i <= n; i++) for (ll j = 1; j < i; j++) ans = (ans + dp[j][i]) % MOD;
    printf("%lld\n", ans * Pow(2, m, MOD) % MOD);
    return 0;
}
 

Measured memory_bytes: 74300
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k: usize = read();
    let mut ans: Vec<usize> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
    for i in 1..10 {
        let kazu = i;
        solve(k, i, kazu, &mut ans, 0);
    }
    ans.sort();
    //println!("{:?}", ans);
    println!("{}", ans[k-1]);
}

fn solve(k: usize, i: usize, kazu: usize, ans: &mut Vec<usize>, depth: usize) {
    if depth > 9 {
        return;
    }
    if i == 0 {
        ans.push(kazu*10+i);
        ans.push(kazu*10+(i+1));
        solve(k, i, kazu*10+i, ans, depth+1);
        solve(k, i+1, kazu*10+(i+1), ans, depth+1);
    } else if i == 9 {
        ans.push(kazu*10+i);
        ans.push(kazu*10+(i-1));
        solve(k, i, kazu*10+i, ans, depth+1);
        solve(k, i-1, kazu*10+(i-1), ans, depth+1);
    } else {
        ans.push(kazu*10+i);
        ans.push(kazu*10+(i-1));
        ans.push(kazu*10+(i+1));
        solve(k, i, kazu*10+i, ans, depth+1);
        solve(k, i-1, kazu*10+(i-1), ans, depth+1);
        solve(k, i+1, kazu*10+(i+1), ans, depth+1);
    }
}

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

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

	int N;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> B;

	cin >> N;

	for(i=0;i<N-1;i++){
		cin >> tmp;
		B.push_back(tmp);
	}
	
	for(i=0;i<N;i++){
		if(i==0){
			counter+=B[0];
		}else if(i==N-1){
			counter+=B[N-2];
		}else{
			if(B[i]<B[i-1]){
				counter+=B[i];
			}else{
				counter+=B[i-1];
			}
		}
	}
	
	answer=counter;
	cout << answer << endl;

	return 0;
}



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

#define dStackSize 500

int stack[dStackSize];
int top;


void initialize();
bool isFull();
bool isEmpty();
void Dump();
void Push(int x);
int Pop();

int main() {
    initialize();
    string buf;
    int a, b;

    while( cin >> buf ) {
        if ( buf[0] == '+' ) {
            a = Pop();
            b = Pop();
            Push(b + a);
            // cout << b << "+" << a << "=" << b + a << endl;
        }
        else if( buf[0] == '-' ) {
            a = Pop();
            b = Pop();
            Push(b - a);
        }
        else if( buf[0] == '*' ) {
            a = Pop();
            b = Pop();
            Push(b * a);
        }
        else{
            Push(stoi(buf));
        }
        // Dump();
    }
    cout << Pop() << endl;

    return 0;
}

void initialize() {
    top = -1;
}
bool isFull() {
    if( top + 1 == dStackSize) {
        return true;
    }

    return false;
}

bool isEmpty() {
    if (top == -1 ) {
        return true;
    }

    return false;
}

void Dump() {
    for (int i = top; i >= 0; i--) {
        cout << i << ":" << stack[i] <<endl;
    }
}

void Push(int x) {
    if ( isFull() == true){
        cout << "stack is full" << endl;
        exit(1);
    }
    top++;
    stack[top] = x;

}

int Pop() {
    if ( isEmpty() == true ) {
        return -1;
    }
    int pop = stack[top];
    top--;

    return pop;
}

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

using namespace std;

int main()
{
   int n;
   string s;
   cin>>n>>s;

   int ans=0;

   for(int i=0;i<=n-3;i++){
    if(s[i]=='A'&& s[i+1]=='B' && s[i+2]=='C')ans++;
   }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3604
N=int(input())
a=list(map(int,input().split()))
a_=sorted(a,key=lambda x:-x)
ans=0
from collections import Counter
c=Counter(a_)
for i in a_:
    if c[i]==0:
        continue
    c[i]-=1
    for n in range(i):
        if i<2**n:
            t=n
            break
        elif i==2**n:
            t=n+1
            break
    j=2**t-i
    if j in c and c[j]>0:
        ans+=1
        c[j]-=1
print(ans)


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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
//    ll ma=-1e9-1,mi=1e9+1,res,r;
//    res=ma;
//    for(int i=0;i<n;i++){
//        cin >> r;
//        res=max(res,r-mi);
//        if(r<mi)mi=r;
//    }
////    cout << "max:mi " << ma << ":" << mi << endl;
//    cout << res << endl;

    ll r;
    cin >> r;
    ll mi=r,res=-1e9;
    for(int i=1;i<n;i++){
        cin >> r;
        res=max(res,r-mi);
        if(mi>r)mi=r;
    }
    cout << res << endl;
}



Measured memory_bytes: 3208
#include<iostream>
using namespace std;
long long h,n,dp[21468],a[21468],b[21468];
int main()
{
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=20001;i++) dp[i]=0x7f7f7f7f;
	for(int i=1;i<=n;i++)
	{
		for(int j=a[i];j<=20001;j++)
		{
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	}
	for(int i=h;i<=20001;i++) dp[h]=min(dp[h],dp[i]);
	cout<<dp[h]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    cout << n * n * n;

    return 0;
}



Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main () {
    long long a, b, k; cin >> a >> b >> k;

    if (a > k) {a -= k; k = 0;}
    else {k -= a; a = 0;  }
    
    b -= k;
    b = max(0ll, b);

    cout << a << " " <<  b << endl;
}

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

using namespace std;

#define int long long
#define forr(i,n) for(int i = 0;i < (int)n; i++)
#define forn(i,n) for(int i = (int)(n-1); ~i ;i--)
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define pb push_back
#define mpa make_pair
#define endl "\n"
#define ar array



void solve(){
	int n;
	cin >> n;
	int ans = 1e18;
	for(int i = 1; i*i <= n; i++){
		if(n%i == 0){
			ans = min(ans,(n/i)+i-2);
		}
	}
	cout << ans;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		solve();	
	}
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int n,k;
vector<int> a,b;
ll solve(int mask){
    ll ans = 0;
    for(int i = 0; i < n; ++i)
        if((a[i]&mask) == a[i])
            ans += b[i];
    return ans;
}
int main(){
    cin >> n >> k;
    a.resize(n);
    b.resize(n);
    for(int i = 0; i < n; ++i)
        scanf("%d %d",&a[i], &b[i]);
    ll ans = solve(k);
    for(int i = 0; i < 30; ++i)
        if(k & (1<<i)){
            int test = (k ^ (1<<i)) | ((1<<i)-1);
            ans = max(ans,solve(test));
        }
    cout << ans << '\n';
}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a>b){
    cout<<a-1<<endl;
  }else{
    cout<<a<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,m,ans=0,k[30]={0},x,y;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        for(int j=0;j<x;j++){
            scanf("%d",&y);
            k[y-1]++;
        }
    }
    for(int i=0;i<m;i++){
        if(k[i]==n) ans++;
    }
    printf("%d",ans);

}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  long long N, _X; 
  double X;  
  cin >> N;
  
  X = ((double)N / 108) * 100; 
  _X = (N*100/108); 
  if ( X - _X > 0) {
  X = X - (X - _X) + 1; 
  } else {
    X = X - (X - _X); 
  }
  if ( floor(X * 1.08) == N) {
    cout << X; 
  } else {
    cout << ":("; 
  }
  
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,x,cnt;
int main()
{
	//cout<<log2(1000000000);
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
	scanf("%d",&x);
	while(x%2==0)
{
	cnt++; x/=2;
}
}
printf("%d",cnt);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    ll n,m,pos=0,ans=0;
    cin>>n>>m;
    vector<ll> v(n);
    vector<P> pa(m);
    for(ll i=0;i<n;i++) cin>>v[i];
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        pa[i]={b,a};
    }
    sort(v.begin(),v.end());
    sort(pa.rbegin(),pa.rend());
    for(ll i=0;i<n;i++) {
        if(pos>=pa.size()) break;
        else if(v[i]>=pa[pos].first) break;
        else if(v[i]<pa[pos].first){
            v[i]=pa[pos].first;
            pa[pos].second--;
            if(pa[pos].second==0) pos++;
        }
    }
    for(ll i=0;i<n;i++) ans+=v[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> Extv(vector<int> A)
{
  int i,j,r,l,n=A.size();
  vector<int> right(0),left(0),ans(0);
  if(n==1){ return A; }
  else if(n==2){ A.push_back(A[0]+A[1]); return A; }
  
  for(i=0;i<n;i++){
    if(i<n/2) left.push_back(A[i]);
    else right.push_back(A[i]);
  }
  right=Extv(right); left=Extv(left);
  r=right.size(); l=left.size();
  for(int i=0; i<right.size(); i++){
    for(int j=0; j<left.size(); j++){
      ans.push_back(right[i]+left[j]);
    }
  }
  for(int i=0;i<right.size();i++) ans.push_back(right[i]);
  for(int i=0;i<left.size();i++) ans.push_back(left[i]);
  
  return ans;
}
int main()
{
  int i,j,n,q,judge;
  vector<int> A,m;
  cin>>n; A.resize(n);
  for(i=0; i<n; i++) cin>>A[i];
  cin>>q; m.resize(q);
  for(j=0; j<q; j++) cin>>m[j];

  A=Extv(A);
  
  for(j=0; j<q; j++){
    judge=0;
    for(i=0; i<A.size(); i++) if(m[j]==A[i]){ judge=1; break; }
    if(judge==0) cout<<"no"<<endl;
    else cout<<"yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 11168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long k = in.nextLong();
		
		long num = n/k;
		if(k%2==1) {
			System.out.println(num*num*num);
		}else {
			long num2 = n/(k/2);
			long num3 = num2 - num;
			System.out.println(num3*num3*num3+num*num*num);
		}

	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[1050][10000];
int maxx=1;
void solve(){
	int n,m,a,b,sta=0,tmp;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		maxx*=2;
	}
	maxx-=1;
	for(int i=0;i<=m;i++){
		for(int j=1;j<=maxx;j++){
			dp[i][j]=1e9;
		}
	}
	for(int t=1;t<=m;t++){
		sta=0;
		scanf("%d%d",&a,&b);
		for(int i=1;i<=b;i++){
			scanf("%d",&tmp);
			sta=sta|(1<<(tmp-1));
		}
		for(int i=0;i<=maxx;i++){
			dp[t][i|sta]=min(min(dp[t-1][i|sta],dp[t][i|sta]),dp[t-1][i]+a);
		}
		for(int i=0;i<=maxx;i++){
			dp[t][i]=min(dp[t][i],dp[t-1][i]);
		}
	}
	if(dp[m][maxx]==1e9){
		printf("-1");
	}
	else{
		printf("%d",dp[m][maxx]);
	} 
}
signed main(){
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 23640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = new String();
		s = sc.nextLine();
		char c[] = new char[s.length()];
		c = s.toCharArray();
		for(int i=0; i<s.length(); i++){
			if(Character.isLowerCase(c[i])){
				System.out.print(Character.toUpperCase(c[i]));
			} else if(Character.isUpperCase(c[i])){
				System.out.print(Character.toLowerCase(c[i]));
			} else {
				System.out.print(c[i]);
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 17268
import java.util.Scanner;

public class Main {
	
	public static int GCD(int A,int B) {
		
		int ancer = 0;
		
		while(A%B != 0) {
			
			ancer = A % B;
			
			A = B;
			B = ancer;
			
		}
		
		return ancer;
	}
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	
    	int X = sc.nextInt();
    	
    	int Y = sc.nextInt();
    	
    	int a = 0;
    	
    	if(X > Y) {
    		a = GCD(X,Y);
    	}else if(Y > X){
    		a = GCD(Y,X);
    	}else {
    		a = X;
    	}
    	
    	System.out.println(a);
    }
}


Measured memory_bytes: 26344