akhauriyash/Code-Regression huggingface dataset:
N=int(input())
csf=[list(map(int,input().split())) for _ in range(N-1)]

for j in range(N):
	t=0
	for i in range(j,N-1):
		c,s,f=csf[i]
		if t>=s:
			t+=(s-t)%f+c
		else:
			t=s+c
	print(t)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,m;
  	cin>>n>>m;
  	vector<vector<char>> a(n, vector<char>(n));
  	vector<vector<char>> b(m, vector<char>(m));
  
  	for(int y=0;y<n;y++){
    	for(int x=0;x<n;x++){
      		cin>>a.at(y).at(x);	
    	} 
    }
  	
  	for(int y=0;y<m;y++){
    	for(int x=0;x<m;x++){
      		cin>>b.at(y).at(x);	
    	} 
    }
  for (int l=0;l<n-m+1;l++){
  	for (int k=0;k<n-m+1;k++){
      bool TorF=true;
  		for (int i=0;i<m;i++){
  			for (int j=0;j<m;j++){
  				if(a.at(j+l).at(i+k)!=b.at(j).at(i)){
                	TorF=false;
                }
    		}
  		}  
      if(TorF){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
      cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int n, l, q; cin >> n;
    int x[n]; for (int i = 0; i < n; i++) cin >> x[i];
    cin >> l >> q;
    int next[17][n];
    for (int i = 0, j = 0; i < n; i++) {
        while (j < n-1 && x[j+1] - x[i] <= l) j++;
        next[0][i] = j;
    }
    // for (int i = 0; i < n; i++) cerr << next[0][i] << endl;
    for (int k = 1; k < 17; k++)
        for (int i = 0; i < n; i++)
            next[k][i] = next[k-1][next[k-1][i]];

    while (q--) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        int lb = 0, ub = b-a;
        while (ub - lb > 1) {
            int mid = (ub + lb) / 2;
            int cur = a;
            for (int k = 0; 1<<k <= mid; k++) {
                if (mid & (1<<k)) {
                    cur = next[k][cur];
                }
            }
            if (cur >= b) ub = mid;
            else lb = mid;
        }
        cout << ub << endl;
    }
}


Measured memory_bytes: 7808
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] array = new int[num];
        for(int i = 0; i < num; i++){
            array[i] = sc.nextInt();
        }

        int max = -2000000000;
        int min = array[0];
        for(int i = 1; i < num; i++){
            if(max < array[i] - min){
                max = array[i] - min;
            }
            if(min > array[i]){
                min = array[i];
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 100048
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();
		int c = sc.nextInt();
		if ( a + b + c > 21 ) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int prime(int x);

int main (){
  int i,n,a[10001],count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    count+=prime(a[i]);
  }
  printf("%d\n",count);
  return 0;
}

int prime(int x){
  int i;
  if(x==2)return 1;
  else if(x%2==0||x==1)return 0;

  for(i=3;i*i<x+1;i++){
    if(x%i==0)return 0;
  }
  return 1;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = 1123456789012345678l;

typedef std::pair<long, long> P;
typedef std::pair<std::pair<long, long>, std::pair<long, long> > PP;

long x, y, z, k;
long a[1005], b[1005], c[1005];

int main(){
	scanf("%ld%ld%ld%ld", &x, &y, &z, &k);
	for(int i = 0; i < x; i++){
		scanf("%ld", &a[i]);
	}
	for(int i = 0; i < y; i++){
		scanf("%ld", &b[i]);
	}
	for(int i = 0; i < z; i++){
		scanf("%ld", &c[i]);
	}
	std::sort(a, a+x, std::greater<long>());
	std::sort(b, b+y, std::greater<long>());
	std::sort(c, c+z, std::greater<long>());
	std::set<PP> st;
	std::priority_queue<PP> que;
	que.push(PP(P(a[0]+b[0]+c[0], 0), P(0, 0)));
	for(int i = 0; i < k; ){
		PP vis = que.top();
		que.pop();
		if(st.find(vis) != st.end()){
			continue;
		}
		i++;
		st.insert(vis);
		printf("%ld\n", vis.first.first);
		//printf("%ld %ld %ld\n", vis.first.second, vis.second.first, vis.second.second);
		if(vis.first.second < x-1){
			que.push(PP(P(a[vis.first.second+1] + b[vis.second.first] + c[vis.second.second], vis.first.second+1), P(vis.second.first, vis.second.second)));
		}
		if(vis.second.first < y-1){
			que.push(PP(P(a[vis.first.second] + b[vis.second.first+1] + c[vis.second.second], vis.first.second), P(vis.second.first+1, vis.second.second)));
		}
		if(vis.second.second < z-1){
			que.push(PP(P(a[vis.first.second] + b[vis.second.first] + c[vis.second.second+1], vis.first.second), P(vis.second.first, vis.second.second+1)));
		}
	}
	return 0;
}
	


Measured memory_bytes: 768
s = input()
anslist = ['KIHBR','KIHBRA','KIHBAR','KIHBARA',
       'KIHABR','KIHABRA','KIHABAR','KIHABARA',
       'AKIHBR','AKIHBRA','AKIHBAR','AKIHBARA',
       'AKIHABR','AKIHABRA','AKIHABAR','AKIHABARA']
for ans in anslist:
    if ans == s:
        print('YES')
        exit()

print('NO')

Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

int main() {
	int N,a,b,c,d,sum=0;
	cin >> N;

	vector<pair<int, int>>red(N);
	vector<pair<int, int>>blue(N);

	rep(i, 0, N) {
		cin >> a;
		cin >> b;
		red[i].first = a;
		red[i].second = b;
	}
	rep(i, 0, N) {
		cin >> c;
		cin >> d;
		blue[i].first = c;
		blue[i].second = d;
	}

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

	rep(i, 0, N) {
		vector<pair<int, int>>dis;
		rep(j, 0, N) {
			if (red[j].first == -1 || red[j].second == -1)continue;
			if (red[j].first < blue[i].first) {
				if(red[j].second < blue[i].second)
				dis.push_back(pair<int, int>(red[j].second ,j));
			}		
		}

		if (1 <= dis.size()) {
			sort(dis.begin(), dis.end());
			sum++;			
			red[dis[dis.size()-1].second].first = -1;
			red[dis[dis.size() - 1].second].second = -1;
		}
	}
	
	
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, _q, op, t, x;
    scanf("%d %d", &n, &_q);
    priority_queue<int> pq[n];
    while (_q--) {
        scanf("%d %d", &op, &t);
        if (op == 0) {
            scanf("%d", &x);
            pq[t].push(x);
        } else if (op == 1) {
            if (!pq[t].empty()) printf("%d\n", pq[t].top());
        } else {
            if (!pq[t].empty()) pq[t].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstdlib>
#include <memory>
#include <cstdio>
#include <memory.h>
#include <numeric>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

typedef pair<int, pair<int, int> > pip;

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

int w, h;
int area[31][31];
int min_cost[31][31][4];
int c[4];

void bfs(){
	queue<pip> qp;
	qp.push(make_pair(0, make_pair(1, 1)));
	while(!qp.empty()){
		pip p = qp.front(); qp.pop();
		int y = p.second.first;
		int x = p.second.second;
		int d = p.first;
		for(int i = 0; i < 4; i++){
			int y2 = y+dy[(d+i)%4];
			int x2 = x+dx[(d+i)%4];
			if(y2 < 1 || y2 > h || x2 < 1 || x2 > w) continue;
			int cost = 0;
			int d2 = (d+i)%4;
			if(area[y][x] != i) cost = c[i];
			if(min_cost[y2][x2][d2] < 0 || min_cost[y][x][d] + cost < min_cost[y2][x2][d2]){
				min_cost[y2][x2][d2] = min_cost[y][x][d] + cost;
				qp.push(make_pair(d2, make_pair(y2, x2)));
			}
		}
	}
}

int main(){
	while(cin >> w >> h && (w || h)){
		memset(min_cost, -1, sizeof(min_cost));
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cin >> area[i][j];
			}
		}
		for(int i = 0; i < 4; i++){
			cin >> c[i];
		}
		min_cost[1][1][0] = 0;
		bfs();
		int cost = 1 << 15;
		for(int i = 0; i < 4; i++){
			if(min_cost[h][w][i] >= 0) cost = min(cost, min_cost[h][w][i]);
		}
		if(cost == 1 << 15) cout << -1 << endl;
		else cout << cost << endl;
	}
}

Measured memory_bytes: 940
/*
 * https://atcoder.jp/contests/abc154/tasks/abc154_b
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long

/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現系
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

const int MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    string result = REPLACE(t, "^" + s, "");
    cout << (result.length() == 1 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3768
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var x = new int[2 * N];
		var c = new int[2 * N];
		var rev = new int[2, N];
		for (var i = 0; i < 2 * N; i++)
		{
			var s = Strs;
			c[i] = s[0] == "W" ? 0 : 1;
			x[i] = int.Parse(s[1]) - 1;
			rev[c[i], x[i]] = i;
		}
		var cost = new int[2, 2 * N, N + 1];
		for (var i = 0; i < 2; i++)
			for (var v = 0; v <= N; v++)
			{
				for (var k = 0; k < 2 * N; k++) if (c[k] == i && x[k] < v) cost[i, k, v] = 1;
				for (var k = 2 * N - 2; k >= 0; k--) cost[i, k, v] += cost[i, k + 1, v];
			}
		var dp = new int[N + 1, N + 1];
		for (var i = 0; i < N; i++) dp[i + 1, 0] = dp[i, 0] + cost[0, rev[0, i], i];
		for (var j = 0; j < N; j++) dp[0, j + 1] = dp[0, j] + cost[1, rev[1, j], j];
		for (var i = 0; i < N; i++)
			for (var j = 0; j < N; j++)
			{
				dp[i + 1, j + 1] = Min(dp[i + 1, j] + cost[1, rev[1, j], j] + cost[0, rev[1, j], i + 1],
				dp[i, j + 1] + cost[0, rev[0, i], i] + cost[1, rev[0, i], j + 1]);
			}
		WriteLine(dp[N, N]);
	}
}


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

int main(){
int n; cin >> n;
vector<int> d(n);
int sum=0;
rep(i,n) {
    int t; cin >> t;
    d[i] = t; sum+=t;
}

int ans=0;
rep(i,n){
    ans += (sum-d[i])*d[i];
}

cout << ans/2 << endl;

return 0;
}

Measured memory_bytes: 256
def isPalin(s):
    return s[::-1]==s
s=input()
n=len(s)
n1,n2=(n-1)//2,(n+3)//2
a,b=s[:n1],s[n2-1:]
#print(a,b)
if isPalin(a) and isPalin(b) and len(s)%2!=0 and isPalin(s):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
typedef pair<ll, ll> Pair;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define FIND(x,key) x.find(key) != x.end()
#define IN_RANGE_V2(v,k,x,y) (0<=x+dx[k]&&x+dx[k]<v[y].size()&&0<=y+dy[k]&&y+dy[k]<v.size())
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(a) REPALL(__i,a) {cout<<a[__i]<<(__i != a.size()-1 ? " " : "");} newline;
#define PRINT_ARRAY_V(a) REPALL(__i,a) {cout<<a[__i]<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};
//const VI dx = {1, 1, 0, -1, -1, -1, 0, 1};
//const VI dy = {0, 1, 1, 1, 0, -1, -1, -1};

void solve()
{
    ll a, b, c, d, n, m, l, r, k, x, y, z, ans = 0ll;
    string s, t;
    cin>>n>>d;
    REP(i,n) {
        cin>>x>>y;
        if (x*x+y*y <= d*d) ans++;
    }
    cout<<ans<<endl;
}

int main()
{
    cout<<fixed<<setprecision(20);
    int __t = 1;
    //cin>>__t;
    REP(i,__t) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define dom 998244353
#define all(c) begin(c),end(c)
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
#define long long long
#define List vector
#define var auto
#define Count size()
#define Length size()
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

int A[1024][1024];
int B[1024];
bool U[1024];
void solve()
{
	int N; cin >> N;
	var A = vector<vector<int>>(N, vector<int>(N - 1));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N - 1; j++)
		{
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	int okcnt = 0;

	int cnt = 0;
	while (okcnt < N)
	{
		if (cnt > N * (N - 1) / 2)
		{
			cout << ("-1") << endl;
			return;
		}
		rep(i, N) U[i] = false;
		bool flag = false;
		for (int i = 0; i < N; i++)
		{
			if (U[i]) continue;
			if (B[i] == N - 1) continue;

			int rival = A[i][B[i]];
			if (U[rival]) continue;

			if (A[rival][B[rival]] == i)
			{
				U[i] = true;
				U[rival] = true;
				flag = true;
				B[i]++;
				B[rival]++;

				if (B[rival] == N - 1) okcnt++;
				if (B[i] == N - 1) okcnt++;
			}
		}

		if (!flag)
		{
			cout << ("-1") << endl;
			return;
		}
		cnt++;
	}

	cout << (cnt) << endl;
}

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


Measured memory_bytes: 6272
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define REP(i,n)  for(int i=0;i<(n);i++)

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

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <limits.h>


using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

struct DP
{
    int prev_workday;
    int daycount;
};
using vdp = vector<DP>;

vdp left_schedule(int N, int K, int C, const string &S)
{
    int k, count = 0, skip = 0;
    vdp work(N);
    for (int i = 0; i < N; i++)
    {
        if (skip <= 0 && S[i] == 'o')
        {
            count++;
            k = i;
            skip = C;
        }
        else if (skip > 0)
        {
            --skip;
        }
        work[i].daycount = count;
        work[i].prev_workday = k;
        
    }
    return work;
}

vdp right_schedule(int N, int K, int C, const string &S)
{
    int k, count = 0, skip = 0;
    vdp work(N);
    for (int i = N - 1; i >= 0; i--)
    {
        if (skip <= 0 && S[i] == 'o')
        {
            count++;
            k = i;
            skip = C;
        }
        else if (skip > 0)
        {
            --skip;
        }        
        work[i].daycount = count;
        work[i].prev_workday = k;
    }
    return work;
}

bool is_valid(const vdp &min_sche, const vdp &max_sche, int N, int K, int C, int i)
{
    int skip = C + 1;
    if (i > 0 && i < N - 1)
    {
        skip = max_sche[i+1].prev_workday - min_sche[i-1].prev_workday;
    }

    int left_daycount = 0, right_daycount = 0;
    if (i > 0) left_daycount = min_sche[i-1].daycount;
    if (i < N-1) right_daycount = max_sche[i+1].daycount;
    bool valid;
    if (skip <= C)
    {
        valid = (left_daycount + right_daycount >= K + 1);
    }
    else
    {
        valid = (left_daycount + right_daycount >= K);
    }
    return valid;
}

int main()
{
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vdp min_sche = left_schedule(N, K, C, S);
    vdp max_sche = right_schedule(N, K, C, S);
    
    for (int i = 0; i < N; i++)
    {
        if (!is_valid(min_sche, max_sche, N, K, C, i))
        {
            cout << (i+1) << endl;
        }
    }
}

Measured memory_bytes: 4996
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll a[200005];
    ll c[200005]{0};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        c[a[i]]++;
    }
    ll s = 0;
    for(int i = 0; i <= 200000; i++){
        s += c[i] * (c[i] - 1) / 2;
    }
    for(int i = 0; i < n; i++){
        cout << s - c[a[i]] * (c[a[i]] - 1) / 2 + (c[a[i]] - 1) * (c[a[i]] - 2) / 2 << endl;
    }
}

Measured memory_bytes: 5760
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

map<long long, long long> decomposit_prime(long long n)
{
    map<long long, long long> primes;
    long long a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            primes[a]++;
            n /= a;
        }
        else
        {
            a++;
        }
    }

    primes[n]++;
    return primes;
}

int main()
{
    cout.precision(18);

    long long N;
    cin >> N;

    vector<long long> c(101, 0);
    for(long long i = 2; i <= N; i++){
      map<long long, long long> m = decomposit_prime(i);
      for(auto x: m){
        c[x.first] += x.second;
      }
    }

    vector<map<long long, long long>> d(2, map<long long, long long>{});
    for(long long i = 1; i <= c[2] + 1; i++)
      d[0][i] = 1;
    
    for(long long i = 3; i <= N; i++) {
      d[i%2].clear();
      for(long long j = 1; j <= c[i] + 1; j++){
        for(auto x : d[(i-1)%2]) {
          if(x.first * j <= 75)
            d[i%2][x.first * j] += x.second;
        }
      }
    }

    cout << d[N%2][75] << endl;

}


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

void fnInput(int &rnElmCnt, vector<int> &rvnElm, int &rnTrgCnt , vector<int> &rvnTrg )
{
  cin >> rnElmCnt;

  rvnElm.resize(rnElmCnt);
  for (int i = 0; i < rnElmCnt; i++)
    cin >> rvnElm[i];

  cin >> rnTrgCnt;

  rvnTrg.resize(rnTrgCnt);
  for (int i = 0; i < rnTrgCnt; i++)
    cin >> rvnTrg[i];
}

void fnDPtblMake(vector<vector<int>> &rvvnDP, const vector<int> &cnrvnElm, int nMaxTrg)
{
  rvvnDP[cnrvnElm.size()][0] = 1;
  for (int j = 1; j <= nMaxTrg; j++)
    rvvnDP[cnrvnElm.size()][j] = 0;

  for (int i = cnrvnElm.size() - 1; i >= 0; i--)
    for (int j = 0; j <= nMaxTrg; j++)
      if (cnrvnElm[i] <= j)
        rvvnDP[i][j] = rvvnDP[i + 1][j] || rvvnDP[i + 1][j - cnrvnElm[i]];
      else
        rvvnDP[i][j] = rvvnDP[i + 1][j];

}

void fnExhSch(const vector<int> &cnrvnElm, const vector<int> &cnrvnTrg)
{
  vector<vector<int>> vvnDP(21, vector<int>(2001, -1));

  int nMaxTrg = cnrvnTrg[0]; 
  for (int i = 1; i < cnrvnTrg.size(); i++)
    nMaxTrg = max(nMaxTrg, cnrvnTrg[i]);

  fnDPtblMake(vvnDP, cnrvnElm, nMaxTrg);

  for (int i = 0; i < cnrvnTrg.size(); i++)
    if (vvnDP[0][cnrvnTrg[i]])
      cout << "yes" << endl;
    else
      cout << "no" << endl;
}

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

  int nElmCnt, nTrgCnt;
  vector<int> vnElm, vnTrg;

  fnInput(nElmCnt, vnElm, nTrgCnt, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

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

int P[10010];
void init(int N);
int root(int a);
bool is_same_set(int a,int b);
void unite(int a,int b);

struct Node {
  int cost,start,goal;
  bool operator<( const Node& right ) const {
    return cost == right.cost ? start < right.start : cost < right.cost;
  }
};

vector<Node> Nodes;

int main() {
  int N;
  cin >> N;
  for (int i=0;i<N;++i) {
    for (int j=0;j<N;++j) {
      int buf;
      cin >> buf;
      if (buf!=-1) {
	Node bufNode = {buf,i,j};
	Nodes.push_back(bufNode);
      }
    }
  }
  sort(Nodes.begin(),Nodes.end());
  init(N); int totalCost = 0;
  for (int i=0;i<Nodes.size();++i) {
    if (is_same_set(Nodes[i].start,Nodes[i].goal)==false) {
      unite(Nodes[i].start,Nodes[i].goal);
      totalCost += Nodes[i].cost;
    }
  }
  cout << totalCost << endl;
}

void init(int N) {
  for (int i=0;i<=N;++i) P[i] = i;
}

int root(int a) {
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int a,int b) {
  return root(a)==root(b);
}

void unite(int a,int b) {
  P[root(a)] = root(b);
}

Measured memory_bytes: 1352
#!/usr/bin/env python3
import sys

def main():
    N, K = map(int, input().split())
    p = 10**9+7
    ans = 0
    for i in range(K,N+2):
        minimum = i*(i-1)//2
        maximum = i*(2*N+1-i)//2
        ans += (maximum - minimum + 1)
        ans %= p
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args){

		solve_abc160_b();
	}
  
  	public static void solve_abc160_b(){

		FastScanner sc = new FastScanner(System.in);
		
		int x = sc.nextInt();
		
		int a = x / 500;
		int b = (x % 500) / 5;
		
		System.out.println(a * 1000 + b * 5);


	}

}

Measured memory_bytes: 21844
from sys import stdin
input = stdin.buffer.readline

def main():
    n, w = map(int, input().split())
    wv = [tuple(map(int, input().split())) for _ in range(n)]

    sum_v = sum([value for weight, value in wv])
    dp = [w + 1] * (sum_v + 1)
    dp[0] = 0
    for weight, value in wv:
        for i in range(sum_v - value + 1)[::-1]:
            if dp[i + value] > dp[i] + weight:
                dp[i + value] = dp[i] + weight

    for i in range(sum_v + 1)[::-1]:
        if dp[i] <= w:
            print(i)
            break

main()

Measured memory_bytes: 65872
A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = gets.to_i

listA = [A, B, C, D, E].select { |x| x % 10 == 0 }
listB = [A, B, C, D, E].select { |x| x % 10 != 0 }.sort_by { |x| x % 10 }

listB = listB.map.with_index do |x, i|
  if i == 0
    x
  else
    10 * (1 + x / 10)
  end
end

ans = 0
ans += listA.inject(:+) || 0
ans += listB.inject(:+) || 0

puts ans


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

int main() {
  int n,x;
  cin >> x >> n;
  if(n == 0){
    cout << x << endl;
    return 0;
  }
  int arr[300];
  int diff[n];
  int smallest = 200;
  int smallestVal = 0;
  for(int i = 0; i < n; i++){
    int t;
    cin >> t;
    arr[t+100] = 1;
  }
  for(int i = 199; i >= -100; i--){
    if(arr[i+100] == 1){
      continue;
    }
    if(abs(x-i) <= smallest){
      smallestVal = i;
      smallest = abs(x-i);
      // cout << smallestVal << " " << abs(x-i) << endl;
    }
  }
  cout << smallestVal << endl;
  return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int a=1; a<10; a++) {
		for (int b=0; b<10; b++) {
			for (int c=0; c<10; c++) {
				int s = a * 10001 + b * 1010 + c * 100;
				if (A <= s && s <= B) ans++;
			}
		}
	}
	cout << ans << endl;
}


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


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a ,b;
    cin>>a>>b;
    for(int i = 1 ; i <= 2000 ; i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

static const int MOD = 1000000007;

int n, m;
int ns, f, d;
int ans;

signed main() {
	
	cin >> n >> m;

	if (n == 1) {
		ns = 0;
	}
	else ns = ((m + 1) / (n - 1)) % MOD;
	f = (m + 1 - (n - 1)) % MOD;
	d = -(n - 1) % MOD;

	ans = (ns*((2 * f + ((ns - 1)*d) % MOD) % MOD) % MOD + m + 1) % MOD;

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

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

int main(){
    int n, a[100];
    cin >> n;

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

    int itr = 0;

    for (int i = 0; i < n - 1; ++i){
        int minj = i;
        for (int j = i; j < n; ++j){
            if (a[j] < a[minj]) minj = j;
        }
        int tmp = a[i];
        a[i] = a[minj];
        a[minj] = tmp;
        if (i != minj) itr++;
        
    }

    for (int i = 0; i < n - 1; ++i) cout << a[i] << " ";
    cout << a[n-1] << endl;
    cout << itr << endl;
}



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

int main(void){
  int N,D;
  scanf("%d %d",&N,&D);
  int A[N][D];
  
  for (int i=0;i<N;i++){
    /*fgets(line,256,stdin);
    sscanf(line,%d,)*/
    for(int j=0;j<D;j++){
      scanf("%d",&A[i][j]);
      /*printf("%d\n",A[i][j]);*/
    }
  }
  double s=0;
  int count=0;
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      for(int k=0;k<D;k++){
        s+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
      }
      for(int l=0;l<10000000;l++){
        if(sqrt(s)==l*1.0){
          count+=1;
        }
      }
      s=0;
          /*
      if(sizeof(sqrt(s))== sizeof(1)){
        printf("%d %d\n",i,j);
        count+=1;
      }*/
    }
  }
  printf("%d",count);
}


Measured memory_bytes: 128
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if (k - (b - a)) >= 0 and (k - (c - a)) >= 0 and  (k - (d - a)) >= 0 and (k - (e - a)) >= 0 and (k - (c - b)) >= 0 and (k - (d - b)) >= 0 and (k - (e - b)) >= 0 and (k - (d - c)) >= 0 and (k - (e - c)) >= 0 and (k - (e -d) ) >= 0:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3064
nums = input().split(' ')
vals = input().split(' ')
num2 = []
val2 = []

for i in range(len(nums)):
  num2.append(int(nums[i]))

for i in range(len(vals)):
  val2.append(int(vals[i]))

sum = 0

for val in val2:
  sum += val

if (sum > num2[0]):
  print("-1")

else:
  print(num2[0] - sum)

Measured memory_bytes: 10004
#include <stdio.h>

int
main(int argc, char *argv[])
{
  long long a, b;
  scanf("%lld%lld", &a, &b);

  int k = 1;
  long long q = 1;
  long long d = b - a + 1;
  long long dtmp = d;
  int c[2];
  int t = 0;
  int s[100];
  long long ans = (d / 2 + (d & 1) * (b & 1))& 1;
  while(b >= (q << k)){
    c[0] = 0; c[1] = 0;
    c[(int)((a/(q << k)) & 1)] += ((q << k) - a % (q << k)) % 2;
    c[(int)((b/(q << k)) & 1)] += (int)(((b + 1) % (q << k))%2);
    ans += ((long long)(c[1] % 2)) * (q << k);
    k++;
  }
  printf("%lld\n", ans);

  return 0;
}


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

int main(void){
    string S;
    cin >> S;
    int sum{700};
    for(int i{0}; i<3; ++i){
        if(S[i]=='o')
            sum += 100;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOG(...) printf(__VA_ARGS__)
using namespace std;

int main() {
    char s[10];
    cin >> s;

    if (strncmp(s, "YAKI", 4) == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		String[] s = new String[n];
		int[][] cnt = new int[n][26];
		for (int i=0; i<n; i++) {
			s[i] = in.next();
			for (int j=0; j<s[i].length(); j++) {
				cnt[i][s[i].charAt(j) - 'a']++;
			}
		}
		
		int[] min = new int[26];
		Arrays.fill(min, Integer.MAX_VALUE/2);
		
		for (int i=0; i<n; i++) {
			for (int j=0; j<26; j++) {
				min[j] = Math.min(min[j], cnt[i][j]);
			}
		}
		
		StringBuilder ans = new StringBuilder();
		for (int i=0; i<26; i++) {
			for (int j=0; j<min[i]; j++) {
				ans.append((char)(i + 'a'));
			}
		}
		
		out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 22612
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  vector<int> vec(5);
  int k;
  REP(i, 5) {
    cin >> vec[i];
  }
  cin >> k;
  REP(i, 5) {
    REP(j, 5) {
      if (i == j) {
        continue;
      }
      if (k < abs(vec[i] - vec[j])) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

template<typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    SegmentTree(F func, T id)
            : merge(func), identity(id) {}

    void init(ll n) {
        offset = 1;
        while (offset < n)
            offset <<= 1;
        node.assign(offset << 1, identity);
    }

    void build(const vector<T> &v) {
        int n = static_cast<int>(v.size());
        init(n);
        for (int i = 0; i < n; ++i) {
            node[offset + i] = v[i];
        }
        for (int i = offset - 1; i >= 0; --i) {
            node[i] = merge(node[(i << 1) | 0], node[(i << 1) | 1]);
        }
    }

    void set(int index, T value) {
        index += offset;
        node[index] = value;
        while (index >>= 1) {
            node[index] = merge(node[(index << 1) | 0], node[(index << 1) | 1]);
        }
    }

    //! [left, right]
    T get(int left, int right) {
        left += offset;
        right += offset + 1;

        T val = identity;
        while (left < right) {
            if (left & 1)
                val = merge(val, node[left++]);
            if (right & 1)
                val = merge(val, node[--right]);

            left >>= 1;
            right >>= 1;
        }
        return val;
    }

    T identity;
    F merge;
    vector<T> node;
    int offset;
};

ll H[200005];
ll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> H[i];
    }
    REP(i, N) {
        cin >> A[i];
    }
    SegmentTree<ll> seg([](ll a, ll b) { return std::max(a, b); }, 0);
    seg.init(N + 5);
    REP(i, N) {
        ll m = seg.get(0, H[i]);
        seg.set(H[i], m + A[i]);
    }

    cout << seg.get(0, N) << endl;
    return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a;
    for (int i = 0; i < h; i++)
    {
        string stg;
        cin >> stg;
        if (count(stg.begin(), stg.end(), '.') < w)
        {
            a.push_back(stg);
        }
    }
    h = a.size();
    for (int i = 0; i < w; i++)
    {
        int siro = 0;
        for (int j = 0; j < h; j++)
        {
            if (a.at(j)[i] == '.')
            {
                siro++;
            }
        }
        if (siro == h)
        {
            for (int j = 0; j < h; j++)
            {
                a.at(j).erase(a.at(j).begin() + i);
            }
            i--;
            w--;
        }
    }
    for (int i = 0; i < h; i++)
    {
        cout << a.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int,int);

int main(){
  int x,y,n;

  scanf("%d%d",&x,&y);
  
  if(x < y){
    n=x;
    x=y;
    y=n;
  }
  y=x%y;

  if(y==0) y=x;
  else while( (n=x%y) >0){
      x=y;
      y=n;
    }


  printf("%d\n",y);

  return 0;
}

  

    
  
  

  



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

int N;
std::vector<char> ans;
int a_int = (char)'a';

void print_string(int idx, int n)
{
  if (idx == N)
  {
    for (auto &e : ans)
      std::cout << e;
    std::cout << std::endl;
    ans.pop_back();
    return;
  }
  for (int i = 0; i < n; i++)
  {
    ans.push_back((char)(a_int + i));
    print_string(idx + 1, n);
  }
  ans.push_back((char)(a_int + n));
  print_string(idx + 1, n + 1);
  ans.pop_back();
  return;
}

int main(int argc, char const *argv[])
{
  std::cin >> N;
  print_string(0, 0);
}

Measured memory_bytes: 1536
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

//???
class Point {
public:
    double x, y;
    
    Point (double x = 0, double y = 0):x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(a * x, a * y);}
    Point operator / (double a){return Point(x / a, y / a);}
    
    double norm(){return x*x + y*y;};
    double absolute(){return sqrt(norm());};
    
    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
    
};
typedef Point Vector;                               //????????????
typedef struct Segment{Point p1, p2;}Segment;       //??????

//????????????a,b?????????
double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}


//??????s1??¨??????s2?????????????±???????
Point getCrossPoint(Segment s1, Segment s2){
    Vector base = s2.p2 - s2.p1;
    double d1 = abs(cross(base, s1.p1 - s2.p1));
    double d2 = abs(cross(base, s1.p2 - s2.p1));
    double t = d1 / (d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1) * t;
}

int main(){
    
    int x0, y0, x1, y1, x2, y2, x3, y3;
    int q;
    
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        Point p0 = Point(x0, y0);
        Point p1 = Point(x1, y1);
        Point p2 = Point(x2, y2);
        Point p3 = Point(x3, y3);
        
        Segment s1 = {p0, p1};
        Segment s2 = {p2, p3};
        
        Point ans = getCrossPoint(s1, s2);
        
        printf("%.8lf %.8lf\n", ans.x, ans.y);
    }

    return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        Map<Character, Integer> map =new HashMap<>();
        for (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }

        Set<Character> set = new HashSet<>();
        int max = 0;
        for (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, --count);
            set.add(c);
            
            int tmp = 0;
            for (Map.Entry<Character, Integer> e : map.entrySet()) {
                if (e.getValue() == 0) continue;
                if (set.contains(e.getKey())) tmp++;
            }

            max = Math.max(max, tmp);
        }

        System.out.println(max);
    }
}

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

using namespace std;


int main()
{
    long long int N,M;
    
        vector<int> v;
    long long int sum = 0;

	cin>>N>>M;
    
     for (int i = 0; i < M; ++i)
    {
        int val;
        cin >> val;

        v.push_back(val);
    }
    
    for (int j = 0; j < M; ++j)
    {
        sum = sum + v[j];
        
    }
    
    long long int result;
    
    if(sum > N)
    {
                cout<<-1<<endl;

    }
    else {
        result = N - sum;
        cout<<result<<endl;
    }


    
    
    
    
   
    
    return 0;
}

Measured memory_bytes: 3732
use proconio::*;
use std::collections::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        s: [String; n],
    }
    let mut map = BTreeMap::new();
    for s in s.iter() {
        *map.entry(s.as_str()).or_insert(0) += 1;
    }
    for s in ["AC", "WA", "TLE", "RE"].iter() {
        let v = map.get(s).map_or(0, |p| *p);
        println!("{} x {}", s, v);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 7844
n,m = map(int,input().split())
a = [int(x) for x in input().split()]
cc = sorted([list(map(int,input().split())) for _ in range(m)], key=lambda x:x[1], reverse=True)
t = 0
for b, c in cc:
    a.extend([c] * b)
    t += b
    if t > n:
        break
a.sort(reverse=True)
print(sum(a[:n]))

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

int main(){
    int a[100][100], b[100][100];
    
    int n, m, l;
    cin >> n >> m >> l;
    
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            cin >> a[i][j];
    
    for(int i=0; i<m; i++)
        for(int j=0; j<l; j++)
            cin >> b[i][j];
    
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            long long int c = 0;
            for(int k=0; k<m; k++)
                c += a[i][k]*b[k][j];
            cout << c << (j==l-1? "\n": " ");
        }
    }
    
    return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int readLn(){
    int n;
    scanf("%d", &n);
    return n;
}

template<typename T, typename R>
vector<R> map(vector<T> xs, R(*fp)(T)){
    vector<R> ys;
    for(T x : xs) ys.push_back(fp(x));
    return ys;   
}

string join(const vector<string>& v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}

vector<int> calcTime(int n){
    vector<int> v = {0, 0, 0};
    while(n >= 3600){
        n -= 3600;
        ++v[0];
    }
    while(n >= 60){
        n -= 60;
        ++v[1];
    }
    v[2] = n;
    return v;
}

int main(void){
    cout << join(map(calcTime(readLn()), +[](int n){ return to_string(n); }), ":") << endl;
    return 0;
}

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

int ans[510][510];

void solve(int s, int g, int c){
	int num=(g-s)/2;
	if(num>0){
		for(int i=s; i<s+num; ++i){
			for(int j=s+num; j<g; ++j){
				ans[i][j]=c;
			}
		}
		solve(s, s+num, c+1);
		solve(s+num, g, c+1);
	}
}

int main() {
	int N;
	cin >> N;
	solve(1, N+1, 1);
	for(int i=1; i<N; ++i){
		cout << ans[i][i+1];
		for(int j=i+2; j<=N; ++j) cout << ' ' << ans[i][j];
		cout << endl;
	}
	return 0;
}

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

int main(){
  int X,Y;
  cin >>X>>Y;
  int v = (X*4-Y);
  if(v%2==0&&v>=0&&v/2<=X){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
w,h = map(int,input().split())
arr=[]
for i in range(w):
    arr.append( (int(input()),'p') )
for i in range(h):
    arr.append( (int(input()),'q') )
arr.sort()
#print(arr)
ans=0
for a in arr:
    if a[1]=='p':
        ans+=a[0]*(h+1)
        w-=1
    else:
        ans+=a[0]*(w+1)
        h-=1
print(ans)


Measured memory_bytes: 24660
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    ans = ""
    while n > 0:
        n -= 1
        ans = chr(n%26 + ord('a')) + ans
        n //= 26
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i] >> p[i];
    }
    vector<int> ord(n);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int x,int y){
        if(s[x] == s[y]) return p[x] > p[y];
        else return s[x] < s[y];
    });
    for (int i = 0; i < n; ++i) {
        cout << ord[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int maxN = 205,maxM=2e6+5;
const int inf = 1e9;

struct edge
{
	int fr, to, nxt;
	int c, f;
} graph[maxM];
int head[maxN];
int totlen;
int level[maxN];
int n, m;
int s, t;

bool dinic_bfs()
{
	memset(level, 0, sizeof(level));
	queue<int> que;
	que.push(s);
	level[s] = 1;
	while (!que.empty())
	{
		int u = que.front(); que.pop();
		for (int i = head[u]; i != -1; i = graph[i].nxt)
		{
			int v = graph[i].to;
			if (!level[v] && graph[i].c > graph[i].f)
			{
				level[v] = level[u] + 1;
				que.push(v);
			}
		}
	}
	return level[t] != 0;
}

int dinic_dfs(int u, int cpflow)
{
	if (u == t) return cpflow;
	int addflow = 0;
	for (int i = head[u]; i != -1 && addflow < cpflow; i = graph[i].nxt)
	{
		int v = graph[i].to;
		if (level[u] + 1 == level[v] && graph[i].c > graph[i].f)
		{
			int tmpadd = dinic_dfs(v, min(cpflow - addflow, graph[i].c - graph[i].f));
			graph[i].f += tmpadd;
			graph[i ^ 1].f -= tmpadd;
			addflow += tmpadd;
		}
	}
	return addflow;
}

int dinic()
{
	int maxflow = 0;
	while (dinic_bfs())
		maxflow += dinic_dfs(s, inf);
	return maxflow;
}

void addEdge(int u, int v, int c, int i)
{
	graph[totlen].to = v;
	graph[totlen].fr = u;
	graph[totlen].nxt = head[u];
	graph[totlen].c = c;
	graph[totlen].f = 0;
	head[u] = totlen++;
	graph[totlen].to = u;
	graph[totlen].fr = v;
	graph[totlen].nxt = head[v];
	graph[totlen].c = 0;
	graph[totlen].f = 0;
	head[v] = totlen++;
}

void init()
{
	for (int i = 0; i <= n + 5; i++)
		head[i] = -1;
	totlen = 0;
}

int main()
{
	int k,l,h,w,sk,sl,tk,tl;
	char ch[105];
	scanf("%d%d",&h,&w);
	n=h+w+2;s=0;t=h+w+1;
	init();
	for(k=1;k<=h;k++)
    {
        scanf("%s",ch+1);
        for(l=1;l<=w;l++)
        {
            if(ch[l]=='o')
            {
                addEdge(k,h+l,1,0);
                addEdge(h+l,k,1,0);
            }
            if(ch[l]=='S')
            {
                sk=k;sl=l;
                addEdge(s,k,inf,0);
                addEdge(s,h+l,inf,0);
            }
            if(ch[l]=='T')
            {
                tk=k;tl=l;
                addEdge(k,t,inf,0);
                addEdge(h+l,t,inf,0);
            }
        }
    }
    if(sk==tk || sl==tl)printf("-1");
	else printf("%d", dinic());
	return 0;
}


Measured memory_bytes: 1024