akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],wei[200010];
struct segs{int l,r,odd,even;}seg[800010];
struct node
{
	int x,y,l,r;
	friend bool operator < (node a,node b){return a.x>b.x;}
};
priority_queue<node> que;
void build(int root,int l,int r)
{
	seg[root].l=l;seg[root].r=r;
	if (l==r)
	{
		seg[root].odd=2100000000;seg[root].even=a[l];
		if (l&1) swap(seg[root].odd,seg[root].even);
		return;
	}
	int mid=(l+r)>>1;
	build(root<<1,l,mid);build((root<<1)+1,mid+1,r);
	seg[root].odd=min(seg[root<<1].odd,seg[(root<<1)+1].odd);
	seg[root].even=min(seg[root<<1].even,seg[(root<<1)+1].even);
}
int query(int root,int l,int r,int p)
{
	if ((seg[root].l>r)||(l>seg[root].r)) return 2100000000;
	if ((l<=seg[root].l)&&(seg[root].r<=r)) return p?seg[root].odd:seg[root].even;
	return min(query(root<<1,l,r,p),query((root<<1)+1,l,r,p));
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&a[i]);wei[a[i]]=i;}
	build(1,1,n);
	int x=query(1,1,n,1),y=query(1,wei[x]+1,n,0);que.push((node){x,y,1,n});
	for (int i=1;i<=n/2;i++)
	{
		node nd=que.top();que.pop();int wx=wei[nd.x],wy=wei[nd.y];
		if (nd.l<wx)
		{
			int x=query(1,nd.l,wx-1,nd.l&1),y=query(1,wei[x],wx-1,(nd.l&1)^1);
			que.push((node){x,y,nd.l,wx-1});
		}
		if (wx+1<wy)
		{
			int x=query(1,wx+1,wy-1,(wx+1)&1),y=query(1,wei[x]+1,wy-1,((wx+1)&1)^1);
			que.push((node){x,y,wx+1,wy-1});
		}
		if (wy<nd.r)
		{
			int x=query(1,wy+1,nd.r,(wy+1)&1),y=query(1,wei[x]+1,nd.r,((wy+1)&1)^1);
			que.push((node){x,y,wy+1,nd.r});
		}
		printf("%d %d ",nd.x,nd.y);
	}
}

Measured memory_bytes: 14068
#include <cstdio>
#include <utility>
#include <map>

#define MAX_N 200000

using namespace std;

typedef pair<int, int> P;

struct uftree {
    int par[MAX_N], rank[MAX_N];
    uftree(int N) {
        for (int i=0; i<N; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    int root(int x) {
        return par[x] == x ? x : par[x] = root(par[x]); 
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) par[y] = x;
        else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int N, K, L, a, b;
    scanf("%d %d %d", &N, &K, &L);
    uftree road(N), rail(N);
    for (int i=0; i<K+L; i++) {
        scanf("%d %d", &a, &b);
        if (i < K) road.unite(a-1, b-1);
        else rail.unite(a-1, b-1);
    }
    P roots[N];
    map<P, int> ans;
    for (int i=0; i<N; i++) {
        roots[i] = {road.root(i), rail.root(i)};
        ans[roots[i]]++;
    }
    for (int i=0; i<N; i++) printf("%d ", ans[roots[i]]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define ihave2talk2u ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define z 1000000007
#define sh 3000
#define mi2 500000004
#define pb push_back
#define pba pop_back
#define pf push_front
#define mpa make_pair
#define fi first
#define se second
#define pr(x) printf("%d ", x)
#define sc(x) scanf("%d",&x)
#define mxf INT_MAX
#define mnf INT_MIN
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpi;
typedef map<int,pi> mpii;
struct util
{
	int val,id;
};
int dp[sh+1][sh+1];

int  main()
{
    ihave2talk2u
   
	string s ,t;
	cin>>s>>t;
	int n1,n2,i,j;
	n1=s.length();n2=t.length();
	
	memset(dp,0,sizeof(dp));
	for(i=0;i<n1;i++)
	{
		for(j=0;j<n2;j++)
		{
			if(s[i]==t[j])
				dp[i+1][j+1]=dp[i][j]+1;
			else
			dp[i+1][j+1]=max({dp[i][j+1],dp[i+1][j],dp[i][j]});
		}
	}
	string ans;
	i=n1;j=n2;
	while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans.pb(s[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
	
	reverse(ans.begin(), ans.end());
	cout<<ans;
	

	
}

Measured memory_bytes: 38784
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int a,b,c,x,y;
  scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
  int sum=0;
  if(a+b<2*c){
    sum=a*x+b*y;
  }else{
    sum+=2*c*min(x,y);
    if(x>y){
      sum+=(x-y)*min(a,c*2);
    }else{
      sum+=(y-x)*min(b,c*2);
    }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

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

int d[N * N], a[N * N], q[N * N], n;
bool v[N * N]; int ans = 0;

inline bool pd(int x, int y) { return 1 <= x && x <= n && 1 <= y && y <= n; }

void upd(int id) {
	ans += d[id];
	int l = 1, r = 0; q[++r] = id; v[id] = 0;
	for (int nw = q[l]; l <= r; nw = q[++l]) {
		int x = (nw - 1) / n, y = nw - x * n; ++x;
		for (int i = 0; i < 4; ++i) {
			int nx = x + dx[i], ny = y + dy[i];
			if (!pd(nx, ny)) continue;
			int nxt = (nx - 1) * n + ny;
			int cs = 1; if (!v[nw]) cs = 0;
			if (d[nxt] > d[nw] + cs) {
				d[nxt] = d[nw] + cs; 
				q[++r] = nxt;
			}
		}
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n * n; ++i) scanf("%d", &a[i]), v[i] = 1;
	for (int i = 1; i <= n * n; ++i) {
		int x = (i - 1) / n, y = i - x * n; ++x;
 		d[i] = min(x - 1, min(y - 1, min(n - x, n - y)));
	}
	for (int i = 1; i <= n * n; ++i) upd(a[i]);
	
	for (int i = 1; i <= n * n; ++i) ans += d[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1000000001;
int H, N;
ll Ai[10010];
ll Bi[10010];
ll dp[1001][10010];

void solve() {
    cin >> H >> N;
    for (int i = 0; i < N; ++i) {
        cin >> Ai[i] >> Bi[i];
    }
    memset(dp, INF, sizeof(dp));
    for (int i = 0; i <= N; ++i) {
        dp[i][0] = 0;
    }
    for (int i = 0; i < N; ++i) {
        int a = Ai[i];
        int b = Bi[i];
        for (int j = 1; j <= H; ++j) {
            ll diff = ((j - 1) / a + 1) * b;
            if (0 <= j - a) {
                dp[i+1][j] = min(dp[i][j-a] + b, dp[i][j]);
                dp[i+1][j] = min(dp[i+1][j - a] + b, dp[i+1][j]);
            }
            dp[i+1][j] = min(diff, dp[i+1][j]);
            dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
        }
    }
    cout << dp[N][H] << endl;
}

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


Measured memory_bytes: 78592
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;

int main(){
	int64_t x,y;
	cin >> x >> y;
	if (abs(x - y) <= 1) {
		cout << "Brown" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
d=[0]*41
for i in range(n):
  for j in range(41):
    d[j]+=(a[i]>>j)&1
f=0
la=len(bin(max(a)))-2
lk=len(bin(k))-2
b=[0]*41
for i in range(lk-1,-1,-1):
  if (k>>i)&1==1:
    if d[i]<n-d[i]:
      b[i]=1
    else:
      b[i]=0
      f=1
  if (k>>i)&1==0:
    if d[i]<n-d[i] and f==1:
      b[i]=1
    else:
      b[i]=0
ans=0
for i in range(max(lk,la)):
  ans+=(1<<i)*[d[i],n-d[i]][b[i]]
print(ans)

Measured memory_bytes: 20076
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 100010

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

LL n, cnt = 0;
LL A[MAXN];

LL solve(int i, bool target, LL prev) {
  LL a = A[i] + prev;
  LL diff = 0;
  if ((a > 0) != target) {
    if (target == 1) { // A < 0
      diff = 1 - a;
    }
    else {  // A > 0
      diff = -1 - a;
    }
    cnt += abs(diff);
  }
  else if (a == 0) {
    if (target == 1) { // A < 0
      diff = 1 - a;
    }
    else {  // A > 0
      diff = -1 - a;
    }
    cnt += abs(diff);
  }
  return diff;
}

int main() {
  GLL(n);
  FORN(i, n) GLL(A[i]);
  FORN(i, n-1) A[i+1] += A[i];

  LL diff = 0; bool sign = 1;
  FORN(i, n) {
    diff += solve(i, sign, diff);
    sign ^= 1;
  }


  LL ans1 = cnt; cnt = 0;
  diff = 0; sign = 0;
  FORN(i, n) {
    diff += solve(i, sign, diff);
    sign ^= 1;
  }
  LL ans2 = cnt;

  printf("%lld\n", min(ans1, ans2));
  return 0;
}


Measured memory_bytes: 1024
from __future__ import division, print_function

''' Hey stalker :) '''
INF = 10 ** 10
TEST_CASES = False


def main():
    a, b = input().split()
    b1, b2 = b.split(".")
    print(int(a)*int(b1) + (int(b2)*int(a))//100)

''' FastIO Footer: PyRival Library, Thanks @c1729 and contributors '''
import os
import sys
from bisect import bisect_left, bisect_right
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
# else:
#     sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
if __name__ == "__main__":
    if TEST_CASES:
        [main() for _ in range(int(input()))]
    else:
        main()


Measured memory_bytes: 65812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = (n%2==0 ? n/2*(n-1) : (n-1)/2*n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> a) {
  ll ans = 0;
  while (true) {
    ll c = 0;
    REP(i, N) {
      ll b = a[i] / N;
      a[i] %= N;
      a[i] -= b;
      c += b;
    }
    REP(i, N) a[i] += c;
    ans += c;
    if (!c)
      break;
  }

  // 123456789486
  // 123456789492

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> a(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> a[i];
  }
  solve(N, a);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String ss = sc.nextLine();
		for(int i=0;i<ss.length();i++){
			if(i%2==1){
				continue;
			}
			System.out.print(ss.charAt(i));
		}
    }
}


Measured memory_bytes: 31648
from bisect import bisect_right as br
N = int(input())
A = [int(a) for a in input().split()]
s = sum(A)
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + A[i]

mi = 1<<100
for i in range(1, N-1):
    sl = S[i]
    sr = s - sl
    a = br(S, sl//2)
    b = br(S, sl + sr//2)
    L = [S[a], S[i]-S[a], S[b]-S[i], s-S[b]]
    mi = min(mi, max(L) - min(L))
    L = [S[a], S[i]-S[a], S[b-1]-S[i], s-S[b-1]]
    mi = min(mi, max(L) - min(L))
    if a-1 >= 0:
        L = [S[a-1], S[i]-S[a-1], S[b]-S[i], s-S[b]]
        mi = min(mi, max(L) - min(L))
        L = [S[a-1], S[i]-S[a-1], S[b-1]-S[i], s-S[b-1]]
        mi = min(mi, max(L) - min(L))

print(mi)

Measured memory_bytes: 91128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int main(){
	cin.tie(0);					//cinとcoutの結び付きを解除
	ios::sync_with_stdio(false);//stdioとの同期を解除
	
	int m;
	cin >> m;
	cout << 48 - m << endl;
	
	
	
	
	return 0;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int array[34]={-1,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<array[k];
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,ans=0;
    cin>>a>>b;
    if(a>b) {for(int i=0;i<a;i++){ans=ans*10+b;}}
    else if(a<b) {for(int i=0;i<b;i++){ans=ans*10+a;}}
    else if(a==b) {for(int i=0;i<a;i++){ans=ans*10+a;}}
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  int n;
  R n;
  if(30<=n) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>


#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

int main()
{

  int x,y;
  cin >>x>>y;
  int ret =0;
  if(x==1)
  {
    if(y==1)
    {
      cout <<1000000;
      	return 0;
    }
  }
  
  if(x<4)
  {
    ret += 400000-(x*100000);
  }
  
  if(y<4)
  {
    ret += 400000-(y*100000);
  }
        cout <<ret;
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, k, a[5001];
bool dp1[5001][5001], dp2[5001][5001];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	dp1[0][0] = true;
	rep(i, n - 1) {
		rep(j, k) {
			if (dp1[i][j])dp1[i + 1][j] = true;
			if (dp1[i][j] && j + a[i] <= k) {
				dp1[i + 1][j + a[i]] = true;
			}
		}
	}
	dp2[n - 1][0] = true;
	for (int i = n - 1; i > 0; i--) {
		rep(j, k) {
			if (dp2[i][j])dp2[i - 1][j] = true;
			if (dp2[i][j] && j + a[i] <= k) {
				dp2[i - 1][j + a[i]] = true;
			}
		}
	}
	int ans = 0;
	rep(i, n) {
		vector<int>ans1, ans2;
		rep(j, k + 1) {
			if (dp1[i][j])ans1.push_back(j);
			if (dp2[i][j])ans2.push_back(j);
		}
		bool b = false;
		for (int p : ans1) {
			if (upper_bound(all(ans2), k - p - 1) - lower_bound(all(ans2), k - p - a[i])) {
				b = true;
			}
		}
		if (!b)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 49280
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = []
if min(a)>=0:
    print(sum(a)-2*a[0])
    now = a[0]
    for i in range(n-2):
        print(now, a[i+1])
        now -= a[i+1]
    print(a[-1], now)
elif max(a)<=0:
    print(-sum(a)+2*a[-1])
    now = a[-1]
    for i in range(n-1):
        print(now, a[i])
        now -= a[i]
else:
    idx = bisect_left(a, 0)
    pa = a[idx:]
    na = a[:idx]
    print(sum(pa)-sum(na))
    now = pa[0]
    for i in range(len(na)-1):
        print(now, na[i])
        now -= na[i]
    pa.append(now)
    now = na[-1]
    for i in range(1, len(pa)-1):
        print(now, pa[i])
        now -= pa[i]
    print(pa[-1], now)


Measured memory_bytes: 20792
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll C,X[100009],cal[100009];
ll turnL[100009], turnR[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>C;
    rep(i,N) cin>>X[i]>>cal[i];
    
    ll sum=0;
    rep(i,N){
        sum+=cal[i];
        turnL[i]=max(0ll,sum-X[i]);
        if(i) chmax(turnL[i],turnL[i-1]);
    }
    
    sum=0;
    rrep(i,N-1){
        sum+=cal[i];
        turnR[i]=max(0ll,sum-(C-X[i]));
        if(i<N-1) chmax(turnR[i],turnR[i+1]);
    }
    
    ll mx=0;
    sum=0;
    rep(i,N){
        sum+=cal[i];
        ll tmp=sum-X[i];
        if(i<N-1) chmax(tmp,tmp-X[i]+turnR[i+1]);
        chmax(mx,tmp);
    }
    
    sum=0;
    rrep(i,N-1){
        sum+=cal[i];
        ll tmp=sum-(C-X[i]);
        if(i) chmax(tmp,tmp-(C-X[i])+turnL[i-1]);
        chmax(mx,tmp);
    }
    cout1(mx)
}

Measured memory_bytes: 3328
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");

        while (true) {
            String[] strArray = sc.next().split("");
            if (strArray[0].equals("0")) break;
            int sum = 0;
            for (String s : strArray)
                sum += Integer.parseInt(s);
            pw.println(sum);
        }
        
        pw.flush();
    }
}


Measured memory_bytes: 27184
#include <iostream>
using namespace std;
 
int main(void) {
 
	string S, T;
  
  	cin >> S;
  	cin >> T;
  
  	int ans = 0;
  	for (int i = 0; i < S.length(); i++) {
    	if (S[i] != T[i]) ans++;
    }
  
  	cout << ans << '\n';
  
  	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define int long long 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define re(x) cout<<(#x)<<" is "<<(x)<<"\n"; 
#define gif(a,b) ((a)/(b)+((a)%(b)?1:0))
using namespace std;

int32_t main()
{
	IOS
	int T = 1; 
	//cin >> T;  
	for (int t = 0; t < T; ++t)
	{
		int n;
		cin >> n;
		int a[n], ans = 0;
		for (int i = 0; i < n; ++i)
			cin >> a[i];
		sort(a, a + n);
		for (int i = 0; i < n - 2; ++i)
		{
			int x = a[i];
			for (int j = i + 1; j < n - 1; ++j)
			{
				int y = a[j];
				for (int k = j + 1; k < n; ++k)
				{
					int z = a[k];
					if(x + y > a[k])
					{
						if( (x != y) && (y != z) )
						{
							
							ans++;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}
//if not working? go ahead.


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

main(){
  int i,n,count=0;
  cin >> n;
  int p[20];
  for(i=0;i<n;i++) cin >> p[i];
  for(i=1;i<n-1;i++){
    if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])) count++;
  }
  
  cout << count << endl;
}
    

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

#define all(x) x.begin(),x.end()
#define pb push_back
#define ss second
#define ff first

int main(){
	int n;	cin>>n;
	long long int ans = 0;
	vector<int>A(n+1), B(n);
	for(int i=0;i<=n;i++)	cin>>A[i];
	for(int j=0;j<n;j++)	cin>>B[j];
	
	for(int i=0;i<n;i++){
		if(B[i]>=A[i]){
			B[i] -= A[i];
			ans += A[i];
			if(B[i]>=A[i+1]){
				ans+=A[i+1];
				A[i+1] = 0;
			}
			else{
				ans += B[i];
				A[i+1] -= B[i];
			}
		}
		else
			ans += B[i];	
	}		 
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
/*
勉強させて頂いたコード
https://twitter.com/kyopro_friends/status/1191212126221688834
dp的な更新が使えるのは盲点
記号の右と左で比較して、差の合計が結果的に答えになる
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    string S;
    cin>>S;
    int n=S.length(),cnt=0;
    vi a(n+1,0);
    rep(i,n){
        if(S[i]=='<')chmax(a[i+1],a[i]+1);
    }
    for(int i=n;i>0;i--){
        //iはa配列基準なのでS配列に添わない。
        if(S[i-1]=='>')chmax(a[i-1],a[i]+1);
    }
    ll sum=accumulate(a.begin(),a.end(),ll(0));
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	lint n, m;
	cin >> m >> n;
	if (n < 2 || m < 2) {
		cout << 1 << endl;
	} else {
		cout << (m / 2) * n + (m & 1) * (n + 1) / 2 << endl;
	}
	return 0;
}

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

#define ll long long
#define pb push_back
#define N 1000000007
#define nmax 200001
#define pll pair<ll,ll>
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}

ll extended_gcd(ll a, ll b, ll &x, ll &y) {
	if(a==0) {
		x = 0;
		y = 1;
		return b;
	}

	ll x1,y1;
	ll gcd = extended_gcd(b%a,a,x1,y1);

	x = y1 - (b/a)*x1;
	y = x1;

	return gcd;
}

ll solve(vector<vector<ll>> &dp, vector<vector<ll>> &adj, ll idx, ll mask) {

	ll n = adj.size();
	if(mask==(1<<n)-1)
		return 1;

	if(dp[idx][mask]!=-1)
		return dp[idx][mask];

	ll res = 0;

	for(ll i=0;i<n;i++) {
		if((mask & (1<<i)) == 0 && adj[idx][i]) {
			res = (res + solve(dp,adj,idx+1,mask|(1<<i)))%N;
		}
	}

	dp[idx][mask] = (res+N)%N;
	return dp[idx][mask];
}

int main() {
    
   	ll n; cin>>n;
   	vector<vector<ll>> adj(n,vector<ll>(n,0));

   	for(int i=0;i<n;i++) 
   		for(int j=0;j<n;j++)
   			cin>>adj[i][j];
   	
   	ll s = (1<<n);
   	vector<vector<ll>> dp(n, vector<ll>(s,-1));

   	cout<<solve(dp,adj,0,0)<<endl;

	return 0;
}


 

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

using namespace std;

int main()
{
    int n;
    int y;
    vector<int> totals;
    vector<int> is;
    vector<int> js;
    vector<int> ks;

    cin >> n >> y;

    for (unsigned i = 0; i < n + 1; ++i) {
        for (unsigned j = 0; j < n - i + 1; ++j) {
            int total = i * 10000 + j * 5000 + (n - i - j) * 1000;
            totals.push_back(total);
            is.push_back(i);
            js.push_back(j);
            ks.push_back(n - i - j);
        }
    }

    for (unsigned index = 0; index < totals.size(); ++index) {
        if (totals.at(index) == y) {
            cout << is.at(index) << " " << js.at(index) << " " << ks.at(index) << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 32552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int a, b, d, r;
		double f;
		
		Scanner scan = new Scanner(System.in);
		
		a = scan.nextInt();
		b = scan.nextInt();
		
		d = a / b;
		r = a % b;
		f = (double)a / (double)b;
		
		System.out.printf("%d ", d);
		System.out.printf("%d ", r);
		System.out.printf("%f", f);
		
	}

}


Measured memory_bytes: 26556
#include <iostream>
#include <string>

using namespace std; 

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


int main() {
    
  int S, Sa, Sb;
  bool SaM = false, SbM= false;
  cin >> S;

  Sa = S / 100;
  Sb = S - Sa * 100;


  if( 1 <= Sa && Sa <=12){
	  SaM = true;
  }

  if( 1 <= Sb && Sb <=12){
	  SbM = true;
  }

  if( SaM == true && SbM == true){
	  cout << "AMBIGUOUS" << endl;
  } else if (SaM == false && SbM == true){
	  cout << "YYMM" << endl;
  } else if (SbM == false && SaM == true){
	  cout << "MMYY" << endl;
  } else {
	  cout << "NA" << endl;
  }

  return 0;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int main() {
  int N, total = 0, maxn = 0, tmp;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> tmp;
    total += tmp;
    maxn = max(maxn, tmp);
  }

  cout << total - (maxn / 2) << 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 == 0) {
      System.out.println(A + B);
    } else {
      System.out.println(B - A);
    }
  }
}

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

using namespace std;

using ll = long long;

void solve(int i, int n, int maxv, string cur, vector<string>& res) {
    if (i == n) {
        res.push_back(cur);
        return;
    }

    for (int j = 0; j <= maxv; ++j) {
        cur.push_back((char)('a' + j));
        solve(i + 1, n, maxv, cur, res);
        cur.pop_back();
    }
    cur.push_back((char)('a' + maxv + 1));
    ++maxv;
    solve(i + 1, n, maxv, cur, res);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> ans;
    solve(0, n, -1, "", ans);
    for (string& s : ans) {
        cout << s << "\n";
    }
    return 0;
}

Measured memory_bytes: 9332
a = input()
b = []
c = []
bb = 0
cc = 0
for i in range(len(a)):
    if i % 2 == 0:
        b.append("0")
    else:
        b.append("1")
for i in range(len(a)):
    if i % 2 == 0:
        c.append("1")
    else:
        c.append("0")
for i in range(len(a)):
    if a[i] != b[i]:
        bb += 1
for i in range(len(a)):
    if a[i] != c[i]:
        cc += 1
print(min(bb, cc))


Measured memory_bytes: 4852
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int w = stdIn.nextInt();
		int[] a = new int[w+1];
		for (int i = 1; i <= w; i++)
			a[i] = i;
		int s = stdIn.nextInt();
		for (; s != 0; s--) {
			String[] S = stdIn.next().split(",");
			int l = Integer.parseInt(S[0]);
			int r = Integer.parseInt(S[1]);
			int t = a[l];
			a[l] = a[r];
			a[r] = t;
		}
		for (int i = 1; i <= w; i++)
			System.out.println(a[i]);

	}
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;
using namespace atcoder;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

using mint = modint998244353;
struct S{
	mint value;
    mint vsize;
	int size;
};

using F = mint;
const F ID = mint(0);

S op(S a, S b){ return {
	a.value * mint(10).pow(b.size) + b.value,
	a.vsize * mint(10).pow(b.size) + b.vsize,
	a.size + b.size
};}

S e(){ return {mint(0), mint(0), 0}; }
S mapping(F f, S x){
    if(f != ID) x.value = f * x.vsize;
    return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

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

	int n, q;
	cin >> n >> q;
	vector<int> l(q), r(q), d(q);
	rep(i, q) {
		cin >> l[i] >> r[i] >> d[i];
		l[i]--; r[i]--;
	}

	vector<S> v(n, {mint(1), mint(1), 1});
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

	rep(i, q){
		seg.apply(l[i], r[i]+1, mint(d[i]));
		cout << seg.all_prod().value.val() << endl;
	}	
}


Measured memory_bytes: 15112
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, K, S, MX = 1000000000;
	cin >> N >> K >> S;
	for(int i = 0; i < K; i++) cout << S << " ";
	for(int i = 0; i < N-K; i++) cout << ((S == MX) ? 1 : (S+1)) << " ";
	cout << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=100010,P=324;
ll n,ans,p[MAXN],q[MAXN];
map <ll,int> mp;
ll prime[330]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,
97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,
199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,
331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,
457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,
599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,
733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,
877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,
1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,
1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,
1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,
1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,
1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,
1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,
1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,
1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,
2089,2099,2111,2113,2129,2131,2137,2141,2143,2153};
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&p[i]);
		for (int j=0;j<=P;j++) {
			while (p[i]%(prime[j]*prime[j]*prime[j])==0) {p[i]/=prime[j]*prime[j]*prime[j];} 
		}
		mp[p[i]]++;
		ll sm=1,bg=p[i];
		for (int j=0;j<=P;j++) {
			if (bg%prime[j]==0) {
				if (bg%(prime[j]*prime[j])==0) {sm*=prime[j];}
				else {sm*=prime[j]*prime[j];}
				while (bg%prime[j]==0) {bg/=prime[j];}
			}
		}
		ll x=sqrt(bg);
		if (x*x==bg) {sm*=x;}
		else {sm*=bg*bg;}
		q[i]=sm;
	}
	if (mp[1]) {ans++,mp[1]=0;}
	for (int i=1;i<=n;i++) {ans+=max(mp[p[i]],mp[q[i]]);mp[p[i]]=mp[q[i]]=0;}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n;
  cin >> n;
  ll cnt=0;
  for(ll i=1;i<=n;++i){
    for(ll j=i;j<=n;++j){
      if(i*j<n){
        if(i!=j) cnt+=2;
        else cnt++;
      }
      else break;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main(){
    int k,a,b;cin >> k;
    cin >> a >> b;
    bool ok = false;

    for(int i=a; i<=b; i++){
        if(i % k == 0) ok = true;
    }

    if(ok)cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int c=0;
    while(c<n)c+=1000;
    cout<<c-n<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

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

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a<10 && b<10){
		printf("%d", a*b);
	}

	else{
		printf("-1");
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
int n, A[N];
ll ans;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> A[i];
  sort(A, A+n, greater<int>());
  FOR(i, 1, n) ans += A[i/2];
  cout << ans << endl;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }




signed main() {

	string A, B;
	cin >> A >> B;
	rep(i, A.length()) {
		cout << A[i];
		if (i < B.length()) cout << B[i];
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

def mass_search(x):
  divisor = 0
  limit = math.floor(math.sqrt(x))
  for i in range(1,limit+1):
    if N % i == 0:
      divisor = max(divisor, i)
  x = divisor
  y = N//divisor
  return x+y-2

print(mass_search(N))

Measured memory_bytes: 9140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll ans=1;
  int mode=0;
  for(int i=1;i<n;i++){
    if(mode==0){
      if(a[i]<a[i-1]) mode=-1;
      else if(a[i]>a[i-1]) mode=1;
    }else if(mode==1){
      if(a[i]<a[i-1]){
        ans++;
        mode=0;
      }
    }else{
      if(a[i]>a[i-1]){
        ans++;
        mode=0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
sp = n.times.map{|i| a = gets.split; [i+1, a[0], a[1].to_i]}
sp.sort do |a, b|
  (a[1] <=> b[1]).nonzero? || (b[2] <=> a[2])
end.each do |c|
  p c[0]
end

Measured memory_bytes: 14344
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  long S1 = A*B;
  long S2 = C*D;

  if(S1 > S2) {
    cout << S1 << endl;
  }
  else {
    cout << S2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	string s;
	int count=0;

	bool A=false;
	bool B=false;
	bool C=true;

	cin >> s;

	for(int i=0;i<s.size();i++){
		if(i==0&&s[i]=='A'){
			A=true;
		}
		else if(i>1&&i<s.size()-1&&s[i]=='C'){
			if(B==true){
				B=false;
				break;
			}
			B=true;
		}
		else{
			if(!islower(s[i])){
				C=false;
			}
		}
	}
	if(A==true&&B==true&&C==true){
		cout << "AC" << endl;
	}
	else{
		cout << "WA" << endl;
	}


}

Measured memory_bytes: 256
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

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


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int tot = 0;
    for (int i = 0; i < k; ++i) {
        tot += v[i];
    }
    cout << tot;
    return 0;
}

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


int main(){
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256