akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>
#define ti3 tuple<ll,ll,ll>

struct UnionFind {
    vector<int> data;
    
    UnionFind(int size) : data(size, -1) { }
    
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y)
        {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main()
{
    int n;
    cin >> n;
    map<int, int> m;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        m[x]++;
    }
    vector<pii> v;
    ll count = 0;
    for(auto e : m)
    {
        //cout << e.first << "," << e.second << endl;
    }
    for(auto e : m)
    {
        if(e.second > 2)
        {
             if(e.second % 2 == 0)
             {
                 v.push_back(make_pair(2, e.first));
             }
             else
             {
                 v.push_back(make_pair(1, e.first));
             }
        }
        else
        {
            v.push_back(make_pair(e.second, e.first));
        }
    }
    sort(v.begin(), v.end(), std::greater<pii>());
    int i = 0;
    int t = 0;
    vector<int> memo;
    while(i < v.size())
    {
        if(v[i].first == 2)
        {
            v[i].first--;
            t++;
        }
        else if(v[i].first == 1)
        {
            break;
        }
        if(t == 3)
        {
            count++;
            t = 1;
        }
        i++;
    }
    ll r = v.size();
    if(t == 1)
    {
        r--;
    }
    for(int i = 0;i < v.size();i++ )
    {
        
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 6136
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

		
public class Main {
	public static void main(String[] args) throws Exception{
		MScanner sc = new MScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n=sc.nextInt();int d=sc.nextInt();
        int i=1;
        int ans=0;
        while(i<=n) {
        	ans++;
        	i+=2*d+1;
        }
        pw.println(ans);
        pw.flush();
    }
	
	static class MScanner {
        StringTokenizer st;
        BufferedReader br;

        public MScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}		

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

int main()
{
  int n;
  cin >> n;
  int ans_cx = 0, ans_cy = 0;
  int64_t ans_h = 0;
  vector<int> vx(n), vy(n);
  vector<int64_t> vh(n);
  int si = -1;
  for (int i = 0; i < n; ++i)
  {
    cin >> vx[i] >> vy[i] >> vh[i];
    if (vh[i] > 0)
      si = i;
  }
  for (int px = 0; px <= 100; ++px)
  {
    for (int py = 0; py <= 100; ++py)
    {
      int64_t h = vh[si] + abs(px - vx[si]) + abs(py - vy[si]);
      bool flag = 1;
      for (int i = 0; i < n; ++i)
      {
        if (vh[i] != max(h - abs(px - vx[i]) - abs(py - vy[i]), (int64_t)0))
          flag = 0;
      }
      if (flag)
        ans_cx = px, ans_cy = py, ans_h = h;
    }
  }
  printf("%d %d %lld\n", ans_cx, ans_cy, ans_h);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const lint MOD = (lint)1e9 + 7;

void mod_add(lint &a, lint b){
    a = (a+b) % MOD;
}

lint mod_pow(lint n, lint x){
    lint res = 1;
    while(x){
        if(x & 1) res = res * n % MOD;
        x >>= 1, n = n * n % MOD;
    }
    return res;
}

class ECellDistance {
public:
    lint N, M, K, L;
    vector<lint> fact, fact_inv;
    vector<vector<lint>> dp;

    void input(std::istream& in){
        ios_base::sync_with_stdio(false);
        in>>N>>M>>K;
        L = N * M;
        fact = vector<lint>(L+1, 1);
        fact_inv = vector<lint>(L+1, 1);
        dp = vector<vector<lint>>(N, vector<lint>(M, 0));
    }

    void comb_pre(int n){
        RREP(i, n) fact[i] = fact[i-1] * i % MOD;
        fact_inv[n] = mod_pow(fact[n], MOD-2);
        for(int i=L;0<i;i--) fact_inv[i-1] = fact_inv[i] * i % MOD;
    }

    lint comb(int n, int r){
        if(n<r or n<0 or r<0) return 0;
        return fact[n] * fact_inv[r] % MOD * fact_inv[n-r] % MOD;
    }

	void solve(std::istream& in, std::ostream& out) {
        input(in);
        comb_pre(L);
        lint ans = 0;
        RREP(i, N-1){
            mod_add(ans, i*M*M%MOD*(N-i)%MOD*comb(L-2, K-2)%MOD);
        }
        RREP(i, M-1){
            mod_add(ans, i*N*N%MOD*(M-i)%MOD*comb(L-2, K-2)%MOD);
        }
        out<<ans<<'\n';
	}
};


int main() {
	ECellDistance solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    ans = b * 2 - a;
    if(ans >= 0) cout << 0 << endl;
    else cout << abs(ans) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;
const int MAXN = 8000;
const int MAXS = 16100;
// vector<vector<bool>> dpx(MAXN, vector<bool>(MAXS));
// vector<vector<bool>> dpy(MAXN, vector<bool>(MAXS));

bool dpx[MAXN][MAXS];
bool dpy[MAXN][MAXS];

void calculate(bool (&dp)[MAXN][MAXS], vector<int> &res) {
  int n = res.size();
  int m = MAXS;
  rep(i, n) rep(j, m) {
    int dist = res[i];
    if (dp[i][j] == true) {
      if (j + dist < m) dp[i + 1][j + dist] = true;
      if (j - dist >= 0) dp[i + 1][j - dist] = true;
    }
  }
  return;
}

int main() {
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;

  const int n = s.size();
  const int center = MAXS / 2;
  int curx = center;
  int i;
  for (i = 0; i < n; ++i) {
    if (s[i] == 'T') break;
    curx++;
  }
  dpx[0][curx] = true;
  dpy[0][center] = true;

  vector<int> resx, resy;
  bool direction = false;
  resx.push_back(0);

  for(; i < n; ++i) {
    if (s[i] == 'T') {
      direction = !direction;
      if(direction) resy.push_back(0);
      else resx.push_back(0);
    } else {
      if (direction) resy.back()++;
      else resx.back()++;
    }
  }
  // rep(i, MAXS) {
  //   if(dpx[0][i]) cout << i - center << endl;
  // }

  calculate(dpx, resx);
  calculate(dpy, resy);

  bool ans = false;
  x = center + x;
  y = center + y;
  if (dpx[resx.size()][x] == true && dpy[resy.size()][y] == true) ans = true;
  else ans = false;

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 125696
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll sum[101010];
ll ans;
int main(){
    cin>>n;
    REP(i, 0, n){
       ll a, b;
       cin>>a>>b;
       sum[i]=a+b;
       ans-=b;
    }

    sort(sum, sum+n);
    reverse(sum, sum+n);

    REP(i, 0, n){
        if(i%2==0) ans+=sum[i];
    }

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

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


int main(){
    int n;cin>>n;
    vector<ll>a(n);
    vector<ll>b(n);
    rep(i,n)cin>>a[n-i-1]>>b[n-i-1];
    ll res = 0;
    rep(i,n){
        if((a[i]+res)%b[i]==0)continue;
        res += b[i]-((a[i]+res)%b[i]);
    }
    cout<<res<<endl;
}



Measured memory_bytes: 1792
//By Bibi
///                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
///             __.'              ~.   .~              `.__
///           .'//                  \./                  \`.
///        .'//                     |                     \`.
///       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \`.
///     .'//.-"                 `-.  |  .-'                 "-.\`.
///   .'//______.============-..   \ | /   ..-============.______\`.
/// .'______________________________\|/______________________________`.
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
int read(){
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int n,a,b;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	if(n==1) printf("Hello World\n");
	else{
		a=read();b=read();
		printf("%d\n",a+b );
	}
	return 0;
}

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

int n;
typedef struct Card
{
	char ca[2];
	int id;
};

Card card[10000];
Card test[10000];

void enter()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> card[i].ca;
		card[i].id = i;
	}
}

void optimize(Card c[], int n)
{
	for (int i = 0; i < n - 1; i++)
	{
		if (c[i].ca[1] == c[i + 1].ca[1] && c[i].id>c[i + 1].id)
		{
			cout << "Not stable" << endl;
			return;
		}
	}
	cout << "Stable" << endl;
}

void sort(Card c[], int n)
{
	for (int i = 0; i < n - 1; i++)
		for (int j = i + 1; j < n; j++)
			if (c[i].id>c[j].id)
			{
				Card temp = c[i];
				c[i] = c[j];
				c[j] = temp;
			}
}

void BubbleSort(Card c[], int n)
{
	for (int i = 0; i < n - 1; i++)
		for (int j = n - 1; j >= i + 1; j--)
		{
			if (c[j].ca[1] < c[j - 1].ca[1])
			{
				Card temp = c[j];
				c[j] = c[j - 1];
				c[j - 1] = temp;
			}
		}
	for (int i = 0; i < n-1; i++)
	{
		cout << c[i].ca << " ";
	}
	cout <<c[n-1].ca<< endl;
	optimize(c, n);
}

void SelectionSort(Card c[], int n)
{
	for (int i = 0; i <= n - 1; i++)
	{
		int minj = i;
		for (int j = i; j <= n - 1; j++)
		{
			if (c[j].ca[1] < c[minj].ca[1])
			{
				minj = j;					
			}			
		}
		Card temp = c[i];
		c[i] = c[minj];
		c[minj] = temp;
	}
	for (int i = 0; i < n-1; i++)
	{
		cout << c[i].ca << " ";
	}
	cout << c[n - 1].ca << endl;
	optimize(c, n);
}



int main()
{
	enter();
	BubbleSort(card, n);
	sort(card, n);
	SelectionSort(card, n);
	//getchar(); getchar();
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)

struct UnionFind
{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};

int main(){
    int n,m;cin>>n>>m;
    vector<int>p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    UnionFind u(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        u.unite(x,y);
    }
    int ans=0;
    rep(i,n){
        if(p[i]==i)ans++;
        else if(u.same(p[i],p[p[i]]))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    vector<pair<int, pair<int,int> > > xst(n);
    REP(i,n){
        int s,t,x;
        cin >> s >> t >> x;
        xst[i] = make_pair(x, make_pair(s-x, t-x));
    }
    sort(ALL(xst));
    vint d(q);
    set<int> ds;
    REP(i,q){
        cin >> d[i];
        ds.insert(d[i]);
    }
    map<int, int> ans;
    REP(i,n){
        auto st = xst[i].se;
        int s,t;
        s = st.fi;
        t = st.se;
        while(true){
            auto itr = ds.lower_bound(s);
            if(itr==ds.end()){
                break;
            }
            if((*itr)<t){
                ans[(*itr)] = xst[i].fi;
                ds.erase(itr);
            }else{
                break;
            }
        }
    }
    REP(i,q){
        if(ds.find(d[i])==ds.end()){
            cout << ans[d[i]] << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 14464
#include<iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    ans += a * 100 + b * 10 + c;
    if (ans % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[][] a = new int[n][2];
        for(int i=0; i<2; i++){
            for(int j=0; j<n; j++){
                a[j][i] = sc.nextInt();
            }
        }
        int ans = 0;
        for(int i=0; i<n; i++){
            int mans = 0;
            int j = i;
            for(int k=0; k<=j; k++){
                mans += a[k][0];
            }
            for(int k=j; k<n; k++){                
                mans += a[k][1];
            }
            ans = Math.max(ans, mans);
        }

        System.out.println(ans);
    }
}

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


using namespace std;

const int INF = 1000000001;
const int MAX = 500000;
int cnt,N;
int S[MAX] = {0}, L[1 + MAX/2] = {0}, R[1 + MAX/2] = {0};


void merge(int* A,int left,int mid,int right)
{
	int n1,n2,i,j;
	n1 = mid - left;
	n2 = right - mid;

	for(int i = 0; i < n1; i++)
	{
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; i++)
	{
		R[i] = A[mid + i];
	}

	L[n1] = INF;
	R[n2] = INF;

	i = 0;
	j = 0;

	for(int k = 0; k < right - left; k++)
	{
		if (L[i] <= R[j] )
		{
			A[left + k] = L[i];
			i++;
		}else
		{
			A[left + k] = R[j];
			j++;
		}

		cnt++;
	}
}


void mergesort(int* A,int left,int right)
{
	int mid;

	if(left + 1 < right)
	{
		mid = (left + right) / 2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main()
{
	cnt = 0;

	scanf("%d", &N);

	for(int i = 0; i < N; i++)
	{
		scanf("%d", &S[i]);
	}

	mergesort(S,0,N);

	for(int i = 0; i < N; i++)
	{
		if (i == N-1)
		{
			printf("%d\n", S[i]);
		}else
		{
			printf("%d ", S[i]);
		}
	}

	printf("%d\n", cnt);
	return 0;
}
	

Measured memory_bytes: 7024
($H,$W,$N)=glob<>;
@c=($H-2)*($W-2);
map{$a=$`+$_%3;$b=$'+$_/3|0;$c[$d{$a}{$b}]--,$c[++$d{$a}{$b}]++if$H>=$a&&$a>2&&$W>=$b&&$b>2}!/ /..8for<>;
print$_+0,$/for@c[0..9]

Measured memory_bytes: 156032
s = input()
n = len(s)
flag = 0

if s == s[::-1]:
    flag += 1

ss = s[:int((n-1)/2)]
if ss == ss[::-1]:
    flag += 1

sss = s[int((n+3)/2)-1:]
if sss == sss[::-1]:
    flag += 1

if flag == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8936
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
l, r = 0, 0
l = max(a)
a.remove(l)
j = bisect.bisect_left(a, l/2)
try:
    if abs((l/2) - a[j-1]) < abs((l/2) - a[j]):
        j -= 1
except:
    pass
print(l, a[min(j, len(a)-1)])

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> hw(h, vector<char>(w));
    int sharp_cnt = 0;
    rep(i, h) rep(j, w) {
        cin >> hw[i][j];
        if ( hw[i][j] == '#' ) ++sharp_cnt;
    }
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
//    vector<vector<bool>> flg(h, vector<bool>(w));
    vector<vector<int>> cnt(h, vector<int>(w, 1e8));
    cnt[0][0] = 0;
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    while(1) {
        if ( que.empty() ) break;
        pair<int, int> now_p = que.front();
        que.pop();
//        flg[now_p.first][now_p.second] = true;
        rep(i, 4) {
            int next_py = now_p.first + dy[i];
            int next_px = now_p.second + dx[i];
            if ( next_py < 0 || next_py >= h || next_px < 0 || next_px >= w ) continue;
            if ( hw[next_py][next_px] == '#' ) continue;
            else if ( cnt[next_py][next_px] != 1e8 ) continue;
            que.push(make_pair(next_py, next_px));
            cnt[next_py][next_px] = min(cnt[next_py][next_px], cnt[now_p.first][now_p.second] + 1);
        }
    }
    if ( cnt[h-1][w-1] == 1e8 ) cout << -1 << endl;
    else                        cout << h * w - cnt[h-1][w-1] - 1 - sharp_cnt << endl;;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i = a; i < b; i++)
#define fst first
#define snd second
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define piii pair<int, pii>
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mp make_pair

using namespace std;


int main(){
    int X;
    cin>>X;
    int d =__gcd(X,360);
    cout<<360/d<<endl;
    return 0;
}

Measured memory_bytes: 3628
n,m = map(int,input().split())
h = list(map(int, input().split()))
k = [100] * n
ans = 0
for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        k[b-1] = 0
    elif h[a-1] < h[b-1]:
        k[a-1] = 0
    elif h[a-1] == h[b-1]:
        k[a-1] = 0
        k[b-1] = 0

for x in range(n):
    if k[x] == 100:
        ans += 1

print(str(ans))

Measured memory_bytes: 86344
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        int 机の数 = scan.nextInt();
        
        int 椅子の数 = scan.nextInt();
        System.out.println(机の数*椅子の数);
        
    }
}



Measured memory_bytes: 26112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
const int MAX = 1e9;
struct Key {
    int price;
    int open;
};

int solve(int s, int b, int N, int M, vector<Key> &keys, vector<vector<int>> &cache) {
    if(s >= M) return (b == (1 << N) - 1) ? 0 : MAX;
    int &ret = cache[s][b];
    if(ret != -1) return ret;
    return ret = min(solve(s + 1, b | keys[s].open, N, M, keys, cache) + keys[s].price,
                    solve(s + 1, b, N, M, keys, cache));
}
 
int main() {
    FAST_IO();
    int N, M; cin >> N >> M;
    vector<Key> keys(M);
    rep(i, M) {
        int a, b; cin >> a >> b;
        keys[i].price = a;
        rep(j, b) {
            int c; cin >> c;
            keys[i].open += (1 << (c - 1));
        }
    }
    // rep(i, M) cout << keys[i].price << " : " << keys[i].open << "\n";
    vector<vector<int>> cache(M, vector<int>(1 << N, -1));
    // cache[i][j] : minimum prices for open all boxes using i-th~ keys when j(bit) boxes are already opened
    int ans = solve(0, 0, N, M, keys, cache);
    if(ans >= 1e9) cout << "-1\n";
    else cout << ans << "\n";
}

Measured memory_bytes: 16384
#include <stdio.h>

int gcd(int x,int  y){
	return y > 0 ? gcd(y, x % y) : x;
}

int main(){
	int n, m, g;
	while(scanf("%d %d", &n, &m) != EOF){
		g = gcd(n, m);
		printf("%d %d\n", g, n / g * m);
	}
	return 0;
}

Measured memory_bytes: 596
fun main(args: Array<String>) {
    val A = readLine()!!.toInt()
    val B = readLine()!!.toInt()
    val C = readLine()!!.toInt()
    val D = readLine()!!.toInt()
    val E = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    if(E - A < k || E == k) {
        println("Yay!")
    } else {
        println(":(")
    }
}

Measured memory_bytes: 30120
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int A[10];
int main(){
	int n,x,ans=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&A[i]);
	for(int i=0;i<n-1;i++){
		int a=A[i],b=A[i+1];
		ans=(a*b)/gcd(a,b);
		A[i+1]=ans;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 3212
import java.util.Scanner
import java.util.TreeSet

//
fun _Do() {

    val N_ = scan.nextInt()
    
    //--------
    println(when {
        N_%10==9 -> "Yes"
        N_/10==9 -> "Yes"
        else -> "No"
    })
}

var scan = Scanner(System.`in`)

fun strings(N:Int):Array<String>{
    var _s = Array(N,{""})
    for (i in _s.indices) {
        _s[i] = scan.next()
    }
    return _s
}

fun ints(N:Int):Array<Int>{
    var _s = Array(N,{0})
    for (i in _s.indices) {
        _s[i] = scan.nextInt()
    }
    return _s
}

fun longs(N:Int):Array<Long>{
    var _s = Array<Long>(N,{0})
    for (i in _s.indices) {
        _s[i] = scan.nextLong()
    }
    return _s
}
//
fun main( argv : Array<String> ) {
    _Do()
}


Measured memory_bytes: 31008
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n), tmp_v(n);
  rep(i, 0, n) {
      cin >> p[i];
  }
  tmp_v = p;
  vsort(p);
  int cnt = 0;
  rep(i, 0, n) {
      if(p[i] != tmp_v[i]) cnt++;
  }
  if (cnt == 0 || cnt == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    reverse(h.begin(),h.end());
    int ans = 0;
    int val = 0;
    for(int i=1; i<n; i++) {
        if(h[i-1] <= h[i]) val++;
        else val=0;
        ans=max(ans,val);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  const int MAX = 2 * 100010;
  vector<ll> a(n), cnt(MAX, 0);
  set<ll> set;
  rep(i, n) {
    cin >> a[i];
    cnt[a[i]]++;
    set.insert(a[i]);
  }
  ll sum = 0;
  for (auto s : set) sum += cnt[s] * (cnt[s] - 1) / 2;
  // debug(sum);
  rep(i, n) {
    outl(sum - (cnt[a[i]] - 1));
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 10624
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 300000
int A,B;
LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
  return x*F;
}
int main()
{
  A=read(),B=read();
  int tmp=A*B;
  if(A<=9&&B<=9)printf("%d",tmp);
  else printf("-1\n");
}


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

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

const i64 M = 1e9 + 7;
const int INF = 1e9 + 1;

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

    i64 a, b, x;
    while (read(a, b, x)) {
        i64 bc = b / x;
        i64 ac = a / x;
        i64 ans = bc - ac + (a % x == 0);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

    ll n; cin>>n;
    vec<ll> a(n+1);
    for(ll i=0; i<n+1; i++) cin>>a[i];
    vec<ll> b(n);
    forn(i) cin>>b[i];

    ll res = 0;
    forn(i){
        if( b[i] <= a[i] ){
            //le saco todo lo q puedo a a[i] y paso
            res += b[i];
        }else{
            //b[i] > a[i]
            res += a[i];
            b[i] -= a[i];
            //veo como sigo con a[i+1]
            ll saco = min(b[i], a[i+1]);
            res += saco;
            a[i+1] -= saco;
        }
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const ll mod = 1000000007;

ll modfact(ll n) {
  ll res = 1LL;
  for(int i = 1; i <= n; i++) res = res * i % mod;
  return res;
}

ll modpow(ll b, ll e) {
  if(e == 0) return 1LL;
  if(e % 2 == 1) return modpow(b, e - 1) * b % mod;
  ll m = modpow(b, e >> 1);
  return m * m % mod;
}

ll inv(ll a) {
  return modpow(a, mod - 2);
}

int main() {
  ll n;
  ll x[2];
  cin >> n >> x[0] >> x[1];
  ll ans = modpow(2, n);
  rep(i, 2) {
    ll comb = 1LL;
    for(int r = 1; r <= x[i]; r++)
      comb = comb * (n - r + 1) % mod;
    comb = comb * inv(modfact(x[i])) % mod;
    ans = (ans + (mod - comb) % mod) % mod;
  }
  cout << --ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

string C;

int n, A[CMax], ats;

int main() {
    cin >> C;

    if ((C[0] == C[1] && C[1] == C[2]) || (C[1] == C[2] && C[2] == C[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <iterator>
#include <stdio.h>

int main() {
  std::map<int, int> num_seq;
  int num;
  scanf("%d", &num);
  int tmp;
  while (num--) {
  	scanf("%d", &tmp);
	num_seq[tmp]++;
  }
  
  if (num == 0) std::cout << 0 << '\n';
  else {
    int cnt = 0;
    for (auto elem : num_seq) {
    	cnt += (elem.first > elem.second ? elem.second : elem.second - elem.first);
  	}
  	std::cout << cnt << '\n';
  }
  
  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
    std::string S, T;

    std::cin >> S >> T;

    //std::cout << S << std::endl << T << std::endl;
    // case:
    // aabbcd -> c1=a, c2=c, -> ccbbad -> Yes
    // ccbbad -> abbccd 
    // should find pair (a, c) to swap.
    bool ok = true;
    std::map<char, char> R1, R2;
    for (int i = 0; i < S.size(); i++) {
        char s = S[i], t = T[i];
        if (R1.count(s) && R1[s] != t) ok = false;
        if (R2.count(t) && R2[t] != s) ok = false;
        R1[s] = t; R2[t] = s;
    }

    if (ok) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(long long i = 0; i < (ll)(n); i++)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
int main(){
    ll N, P;
    cin >> N >> P;
    ll a = P;
    ll ans = 1;
    for(ll i = 2; i * i <= P; i++){
        int n = 0;
        for(; P % i == 0; P /= i){
            n++;
        }
        if(n >= N){
            ans *= pow(i, n / N);
        }
    }
    if(P != 1){
        if(N == 1){
            ans *= P;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3868
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
         
         if(height == 0){
            break;
         }
         
         for(int i = 0; i < height; i ++){
            if(i%2 == 0){
               even(width);
            }else{
               odd(width);
            }
         }
         System.out.println();
         
      }
         
   }//main method 
   
   public static void even(int width){
      for(int i = 0; i < width; i++){
         if(i%2 == 0){
            System.out.print("#");
         }else{
            System.out.print(".");
         }   
      }
      System.out.println();
   }
   
   public static void odd(int width){
      for(int i = 0; i < width; i++){
         if(i%2 == 0){
            System.out.print(".");
         }else{
            System.out.print("#");
         }
         
      }
      System.out.println();
   }
   
   
   
}//class

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

using ll = long long;
using P = pair<int, int>;

int main() {
    ll a,b,c,k;

    cin >> a >> b >> c >> k;

    ll max = (a > k)? k : a;
    if (a + b < k) {
        max -= (k-a-b);
    }
    cout << max << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
          double a,b,c,d,e,f,x,y;
          while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF)
          {
                    y=((c*d - a*f)/(b*d - a*e));
                    x=((c - b*y)/a);
                    cout<<fixed<<setprecision(3)<<x<<" ";
                    cout<<fixed<<setprecision(3)<<y<<endl;
          }

return 0;
}


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

#define rep(x, n) for(int i = x; i < (n); ++i)

using namespace std;
using ll = long long;

int main(void)
{
  ll k;
  cin >> k;
  ll f = 0;
  rep(1, 2000001) {
    f = (f * 10 +7) % k;
    if (!f) return cout << i << endl, 0;
  }
  return cout << -1 << endl, 0;
}


Measured memory_bytes: 3604
import sys
import itertools
import math
from math import factorial
from heapq import heapify, heappop, heappush
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) %mod

    return result

X, Y = IL()

num = 0
n = 0
f = 0
for i in range(X+1): #(1, 2)を取る回数
  x = X - i
  y = Y - 2*i
  if x == 2*y:
    n = i
    num = i + y
    f = 1
    break
if f == 0:
  print(0)
else:
  print(cmb(num, n) %mod)

Measured memory_bytes: 102376
def selection_sort(a):
    res = 0
    for i in range(len(a)):
        m = i
        for j in range(i, len(a)):
            if a[m] > a[j]:
                m = j
        if m != i:
            res += 1
            a[i], a[m] = a[m], a[i]
    return res


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = selection_sort(a)
    print(' '.join(map(str, a)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
  Comb(){
    fac = new ll[1000001];
    finv = new ll[1000001];
    inv = new ll[1000001];
    fac[0] = 1;
    for(int i=1;i<1000001;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000001;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000001;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string N;
  cin >> N;
  int n,k;
  cin >> k;
  n = N.length();
  ll dp0[n+1][k+1],dp1[n+1][k+1];
  for(int i=0;i<n+1;i++){
    for(int j=0;j<k+1;j++){
      dp0[i][j]=0;
      dp1[i][j]=0;
    }
  }

  dp1[0][0] = 1;
  for(int i=0;i<n;i++){
    dp0[i+1][0] = 1;
    dp1[i+1][0] = 0;
    for(int j=1;j<k+1;j++){
      if(N[i]=='0'){
        dp0[i+1][j] = dp0[i][j-1]*9+dp0[i][j];
        dp1[i+1][j] = dp1[i][j];
      }
      else{
        int d = N[i]-'0';
        dp0[i+1][j] = dp0[i][j-1]*9+dp0[i][j]+dp1[i][j]+dp1[i][j-1]*(d-1);
        dp1[i+1][j] = dp1[i][j-1];
      }
    }
  }
  cout << dp0[n][k]+dp1[n][k] << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np


def solve_greedy(dd, c_arr, s_arr):
    missing_d = np.zeros(26, dtype=np.int64)
    score = 0
    res_list = []
    for d in range(dd):

        missing_d += 1

        score_add = s_arr[d, :]
        score_miss = c_arr * missing_d

        t = np.argmax(score_add + score_miss)

        score += score_add[t] + score_miss[t] - score_miss.sum()

        res_list.append(t)
        missing_d[t] = 0

    # print(score)

    return score, np.array(res_list)


def solve(dd, c_arr, s_arr):

    score, t_arr = solve_greedy(dd, c_arr, s_arr)

    score_d = np.zeros(dd, dtype=np.int64)
    missing_d = np.zeros((dd, 26), dtype=np.int64)
    for d in range(dd):
        score_d[d] = s_arr[d, t_arr[d]]
        if d == 0:
            missing_d[d, :] = 1
        else:
            missing_d[d, :] = missing_d[d - 1, :] + 1
        missing_d[d, t_arr[d]] = 0

    for i in range(1000):
        d0 = np.random.choice(dd)
        q0 = np.random.choice(26)
        p0 = t_arr[d0]
        t_arr[d0] = q0

        score_new = score

        score_new += s_arr[d0, q0]
        score_new -= s_arr[d0, p0]
        score_new += (c_arr[q0] * missing_d[:, q0]).sum()
        score_new += (c_arr[p0] * missing_d[:, p0]).sum()
        for d in range(dd):
            if d == 0:
                missing_d[d, p0] = 1
                missing_d[d, q0] = 1
            else:
                missing_d[d, p0] = missing_d[d - 1, p0] + 1
                missing_d[d, q0] = missing_d[d - 1, q0] + 1
            if t_arr[d] == p0:
                missing_d[d, p0] = 0
            elif t_arr[d] == q0:
                missing_d[d, q0] = 0

        score_new -= (c_arr[q0] * missing_d[:, q0]).sum()
        score_new -= (c_arr[p0] * missing_d[:, p0]).sum()

        if score_new >= score:
            score = score_new
        else:
            t_arr[d0] = p0
            for d in range(dd):
                if d == 0:
                    missing_d[d, p0] = 1
                    missing_d[d, q0] = 1
                else:
                    missing_d[d, p0] = missing_d[d - 1, p0] + 1
                    missing_d[d, q0] = missing_d[d - 1, q0] + 1
                if t_arr[d] == p0:
                    missing_d[d, p0] = 0
                elif t_arr[d] == q0:
                    missing_d[d, q0] = 0

    return [t + 1 for t in t_arr]


def main():
    d = np.int64(input())
    c_arr = np.array(list(map(int, input().split()))).astype(np.int64)
    s_arr = np.array([list(map(int, input().split())) for _ in range(d)]).astype(np.int64)
    res = solve(d, c_arr, s_arr)
    for r in res:
        print(r)


if __name__ == "__main__":
    main()


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

typedef struct{
    int *data;
    int cnt;
}QUE;

void insert(QUE Q){
    int l,r,max,parent=Q.cnt/2,tmp;
    while(parent>=1){
        l=parent*2;
        r=parent*2+1;
        max=parent;
        if(l<=Q.cnt&&Q.data[l-1]>Q.data[max-1])max=l;
        if(r<=Q.cnt&&Q.data[r-1]>Q.data[max-1])max=r;
        if(max==parent)break;
        tmp=Q.data[parent-1];
        Q.data[parent-1]=Q.data[max-1];
        Q.data[max-1]=tmp;
        parent=parent/2;
    }
    return;
}
void delete(QUE Q){
    int l,r,max,tmp,parent=1;
    while(parent<=Q.cnt){
        l=parent*2;
        r=parent*2+1;
        max=parent;
        if(l<=Q.cnt&&Q.data[l-1]>Q.data[max-1])max=l;
        if(r<=Q.cnt&&Q.data[r-1]>Q.data[max-1])max=r;
        if(max==parent)break;
        tmp=Q.data[max-1];
        Q.data[max-1]=Q.data[parent-1];
        Q.data[parent-1]=tmp;
        parent=max;
    }
    return;
}
int main(){
    int i;
    
    int n,q;
    scanf("%d %d\n",&n,&q);
    
    QUE Q[n];
    for(i=0;i<n;i++){
        Q[i].data=(int*)malloc(sizeof(int)*q);
        Q[i].cnt=0;
    }
    
    int com,t,x;
    while(q--){
        scanf("%d ",&com);
        switch(com){
            case 0:
                //insert
                scanf("%d %d\n",&t,&x);
                Q[t].data[Q[t].cnt++]=x;
                insert(Q[t]);
                break;
            case 1:
                //getMax
                scanf("%d\n",&t);
                if(Q[t].cnt!=0)printf("%d\n",Q[t].data[0]);
                break;
            case 2:
                //delete
                scanf("%d\n",&t);
                if(Q[t].cnt==0)break;
                Q[t].data[0]=Q[t].data[--Q[t].cnt];
                delete(Q[t]);
                break;
        }
    }
/*    
    int j;
    for(i=0;i<n;i++){
        for(j=0;j<Q[i].cnt;j++)printf("%d ",Q[i].data[j]);
        printf("\n");
    }
*/    
    return 0;
}


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

typedef long long int llint;

int main(){
	int N,M;
	map<string,int> money;
	vector<string> index;
	cin >> N;
	for(int i=0;i<N;i++){
		string s;
		cin >> s;
		if(money.count(s)==0){
			index.push_back(s);
		}
		money[s]++;
	}
	cin >> M;
	for(int i=0;i<M;i++){
		string t;
		cin >> t;
		if(money.count(t)==0){
			index.push_back(t);
		}
		money[t]--;
	}

	int maxMoney=0;
	for(const string& i : index){
		if(maxMoney<money[i]){
			maxMoney=money[i];
		}
	}

	cout << maxMoney << endl;
	
	return 0;
}


Measured memory_bytes: 256