akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int popRow(vvint &g, int y, int w = 5)
{
    vint row = g[y];
    int score = 0;

    int li = 0, l = row[0];
    rep(i, w)
    {
        if (row[i] != l)
        {
            l = row[i];
            li = i;
            continue;
        }

        if (i - li >= 2)
        {
            for (int j = i; j >= li && g[y][j]; j--)
            {
                score += g[y][j];
                g[y][j] = 0;
            }
        }
    }

    return score;
}

int pop(vvint &g, int h, int w = 5)
{
    int score = 0;
    rep(y, h)
    {
        score += popRow(g, y);
    }
    return score;
}

void shift(vvint &g, int h, int w = 5)
{
    for (int y = h - 2; y >= 0; y--)
        rep(x, 5)
        {
            int d = 1;
            while (y + d < h && g[y + d][x] == 0)
            {
                g[y + d][x] = g[y + d - 1][x];
                g[y + d - 1][x] = 0;
                d++;
            }
        }
}

int main()
{
    int h, w = 5;
    while (cin >> h, h)
    {
        vvint g(h, vint(w));
        rep(i, h) rep(j, w) cin >> g[i][j];

        int ans = 0;
        while (true)
        {
            int newScore = pop(g, h, w);
            ans += newScore;
            shift(g, h);

            if (newScore == 0)
                break;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> l(n);
    cin >> l;
    cout << (2 * *max_element(l.begin(), l.end()) < accumulate(l.begin(), l.end(), 0) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
A,B = map(int,input().split())
Af = factorization(A)
Bf = factorization(B)
As = set()
Bs = set()
for i in range(len(Af)):
    As.add(Af[i][0])
for j in range(len(Bf)):
    Bs.add(Bf[j][0])
if A == 1 and B ==1:
    print(1)
else:
    print(len(As & Bs)+1)

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

int main(){
    string s;
    cin >> s;
    string ans = "Good";
    if(s[0] ==s[1] || s[1] == s[2] || s[2] == s[3]){
        ans = "Bad";
    }
    cout << ans <<endl;
    return 0;
}

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

int main() {
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	
	int x,y,z;	//それぞれ買う個数
	int ans = 0;
	
	for(x = 0; x <= n / r; x++) {
		for(y = 0; y <= (n - r*x) / g; y++) {
			//cout << "x: " << x << " y: " << y << endl;
			if((n - r*x - g*y) % b ==0) {
				ans++;
				//cout << "match!" << endl;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    cin >> n;
    vi h(n);
    bool ans = true;
    
    rep(i, n){
            cin >> h[i];
            if(i == 0) h[i] = max(h[i]-1ll, 1ll);
            else{
                if(h[i]<h[i-1]) ans = false;
                else h[i] = max(h[i]-1ll, h[i-1]);
            }
        }
    (ans) ? Yes() : No();
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(s) printf("%c",s)
int main(void){
  char s[256],c[256];
  scanf("%s %s",s,c);
  FOR(strlen(s)+strlen(c)){
    if(i%2){
      PRC(c[(i-1)/2]);
    }else{
      PRC(s[i/2]);
    }
  }
  return 0;
}
/*
scanf("%d",&n);
scanf("%d %d",&a,&b);
*/

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n;
   cin >> n;
   int cnt = 0;
   for(int i = 1; i <= n; i++){
	   string ret = to_string(i);
	   if (ret[0] != 0){
	   if ((int)ret.size() % 2 != 0) cnt++;
	 }
    } 
  cout << cnt << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>>hp(n,vector<int>(3));
  for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>hp[i][j];
  vector<vector<int>>ans(n,vector<int>(3));
  ans[0][0]=hp[0][0];
  ans[0][1]=hp[0][1];
  ans[0][2]=hp[0][2];
  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
      ans[i][j]=hp[i][j]+max(ans[i-1][(j+1)%3],ans[i-1][(j+2)%3]);
    }
  }
  int val=INT_MIN;
  val=max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
  cout<<val<<endl;
}

Measured memory_bytes: 14036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf 1145141919810
typedef pair<int, int> P;
int a[200];
signed main() {
	a[0] = 2;
	a[1] = 1;
	for (int i = 0; i < 85; i++) {
		a[i + 2] = a[i] + a[i + 1];
	}
	int n; cin >> n; cout << a[n] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
vv64 g;
v64 vis;
ll c1=0;
v64 p;

ll dfs(ll v){
    if(v == p[1]) return 1;
    ll ans=0;
    vis[v]=1;
    forn(i,g[v].size()){
        if(vis[g[v][i]]==0) {ans+=dfs(g[v][i]);}
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin >> n >> m;
    v64 deg(n,0);
    ll s=0,c=0;
    ll a,b;
    g.resize(n);
    vis.resize(n,0);
    bool bo=false;
    forn(i,m){
        cin >> a >> b;
        a--,b--;
        deg[a]++;
        deg[b]++;
        g[a].pb(b);
        g[b].pb(a);
    }
        forn(i,n){
                if(deg[i]%2 == 1){
                    cout << "No" << ln;
                    return 0;
                }
                else{
                    s+=deg[i]/2;
                    c++;
                    if(deg[i]==4) p.pb(i);
                    if(deg[i]==6) bo=true;
                }
        }
    if(s<c+2){
        cout << "No" << ln;
        return 0;
    }
    else if(s>c+2 || bo) cout << "Yes" << ln;
    else{
            ll ck = 0;
            ck = dfs(p[0]);
            if(ck==2) cout << "Yes" << ln;
            else cout << "No" << ln;
    }
    return 0;
}

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

using namespace std;
void bad() {
    cout << "No\n";
    exit(0);
}
int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int cx = 0, cy = 0, ct = 0;
    for (int i = 1; i <= n; i++) {
        int x, y, t;
        cin >> t >> x >> y;
        if (abs(x - cx) + abs(y - cy) > t - ct) bad();
        if ((abs(x - cx) + abs(y - cy)) % 2 != (t - ct) % 2) bad();
        cx = x, cy = y, ct = t;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int x = sc.NextInt();
        int y = sc.NextInt();

        int min = 1 << 30;
        for (int i = 0; i < 100001; i++)
        {
            int res = 2 * c * i;
            if (x - i > 0) res += a * (x - i);
            if (y - i > 0) res += b * (y - i);
            if (res < min) min = res;
        }
        Console.WriteLine(min);
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140
/**
 * author: moririn_cocoa       
**/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

int main(void) {
  
  int A;
  string op;
  int B;
  
  cin >> A;
  cin >> op;
  cin >> B;
  
  if ( op == "+" ) {
   
    cout << A + B << endl;
  }

  else if ( op == "-" ) {
    
    cout << A - B << endl;
  }
	
  return 0;
}

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

char s[111];

int main() {
	scanf("%s", s);
	bool chk=true;
	int len = strlen(s);
	for(int i=0;i<len && chk;i++) {
		if(i%2 && s[i]=='R') chk = false;
		if(i%2==0 && s[i]=='L') chk = false;
	}
	puts(chk ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


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

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

using namespace std;

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

  int maxv = 0;
  for (int i = n - 1; i >= 0; --i) {
    int num = 0;
    // increment num if both include the same alphabet
    rep(j, 27) {
      rep(k, i) {
        if ('a' + j == s[k]) {
          for (int l = i; l < n; ++l) {
            {
              if ('a' + j == s[l]) {
                num++;
                break;
              }
            }
          }
          break;
        }
      }
    }
    maxv = max(maxv, num);
  }

  std::cout << maxv << std::endl;
  return 0;
}


Measured memory_bytes: 3572
def gcd(a, b)
  return a if b == 0
  gcd(b, a % b)
end

n = gets.to_i
a = gets.split.map(&:to_i)

l = [0, a[0]]
g = a[0]
1.upto(n - 2).each do |i|
  g = gcd(g, a[i])
  l << g
end

r = [a[-1], 0]
g = a[-1]
(n - 2).downto(1) do |i|
  g = gcd(g, a[i])
  r.unshift(g)
end

p (0...n).map { |i|
  next r[0] if i == 0
  next l[n - 1] if i == n - 1
  gcd(l[i], r[i])
}.max

Measured memory_bytes: 11220
program ec12;
var 
	ans,sum1,sum2,ans1:int64;
	a:array[0..100000] of int64;
	n,m,i,j:longint;
begin 	
	readln(n);
	ans:=0;
	ans1:=0;
	for i:=1 to n do
	read(a[i]);
	if a[1]>0 then 
	begin 
		sum1:=a[1];
		ans1:=a[1]+1;
		sum2:=-1;
	end
	else
	begin
		if a[1]=0 then 
		begin 
			sum1:=1;
			sum2:=-1;
			ans:=1;
			ans1:=1;
		end
		else
		begin
			ans:=abs(a[1])+1;
			sum1:=1;
			sum2:=a[1];
		end;
	end;
	for i:=2 to n do 
	begin 
		if sum1>0 then 
		begin 
			if sum1+a[i]>=0 then 
			begin 	
				inc(ans,sum1+a[i]+1);
				sum1:=-1;
			end
			else
			sum1:=sum1+a[i];
		end
		else
		begin 	
			if sum1+a[i]<=0 then 
			begin 
				inc(ans,abs(sum1+a[i])+1);
				sum1:=1;
			end
			else
			sum1:=sum1+a[i];
		end;
		if sum2>0 then 
		begin 
			if sum2+a[i]>=0 then 
			begin 	
				inc(ans1,sum2+a[i]+1);
				sum2:=-1;
			end
			else
			sum2:=sum2+a[i];
		end
		else
		begin 	
			if sum2+a[i]<=0 then 
			begin 
				inc(ans1,abs(sum2+a[i])+1);
				sum2:=1;
			end
			else
			sum2:=sum2+a[i];
		end;
	end;
	if sum1=0 then 
	inc(ans);
	if sum2=0 then 
	inc(ans1);
	if ans<ans1 then 
	writeln(ans)
	else
	writeln(ans1);
end. 

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;
typedef long long ll;

int mp(int x, int y){
    if(x <= y){
        return 1000 * x + y;
    }else{
        return 1000 * y + x;
    }
}

struct phash{
    inline size_t operator()(const pair<int, int> & p) const{
        const auto h1 = hash<int>()(p.first);
        const auto h2 = hash<int>()(p.second);
        return h1 ^ (h2 << 1);
    }
};

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n - 1; ++j){
            int x;
            cin >> x;
            x--;
            a.at(i).at(j) = x;
        }
    }

    unordered_map<int, unordered_set<int>> to;
    // unordered_map<int, unordered_set<int>> fr;
    unordered_map<int, int> fr;

    for(int i = 0; i < n; ++i){
        for(int j = 1; j < n - 1; ++j){
            int a1 = a.at(i).at(j - 1);
            int a2 = a.at(i).at(j);
            to[mp(i, a1)].insert(mp(i, a2));
            // fr[mp(i, a2)].insert(mp(i, a1));
            fr[mp(i, a2)]++;
        }
    }

    int count = 0;
    int d;
    vector<vector<bool>> done(n, vector<bool>(n, false));
    unordered_set<int> nxt[2];
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(!done.at(i).at(j) &&
                // fr[mp(i, j)].size() == 0){
                fr[mp(i, j)] == 0){
                nxt[0].insert(mp(i, j));
            }
        }
    }
    for(d = 0; count < n * (n - 1) / 2 && nxt[d % 2].size(); ++d){
        nxt[(d + 1) % 2].clear();
        for(auto p : nxt[d % 2]){
            count++;
            done.at(p / 1000).at(p % 1000) = true;
            for(auto p2 : to[p]){
                // fr[p2].erase(p);
                fr[p2]--;
                if(!done.at(p2 / 1000).at(p2 % 1000) &&
                    fr[p2] == 0){
                    // fr[p2].size() == 0){
                    nxt[(d + 1) % 2].insert(p2);
                }
            }
        }
    }

    if(count < n * (n - 1) / 2){
        cout << -1 << endl;
    }else{
        cout << d << endl;
    }
    return 0;
}


Measured memory_bytes: 118728
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
 int N;
    int W;
 
    cin >> N >> W;
 
    vector<int> w(N);
    vector<int> v(N);
 
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }
 
    int pv = 0;
    for (auto x : v) {
        pv += x;
    }
 
    vector<long long> dp(N * 1000 + 1, 10e9 + 5);
 
    dp[0] = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = pv - v[i]; j >= 0; --j) {
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
        }
    }
 
    long long ans = 0;
 
    for (int i = 0; i < pv + 1; ++i) {
        if (dp[i] <= W) {
            ans = max(ans, (long long)i);
        }
    }
 
    cout << ans;
      
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ; 
  vector<int> v(3*n) ;
  rep(i,3*n) cin >> v.at(i) ;
  
  sort(all(v)) ;
  reverse(all(v)) ;
  intll ans = 0 ; 
  
  for(int i=1;i<2*n;i+=2){
    ans += v.at(i) ;
  }
  
  cout << ans ;
  
  
 


}


Measured memory_bytes: 4216
n=int(input())
n1=n
l=[]
def isprime(n):
  if n==2:
    return True
  elif n==1:
    return False
  else:
    for i in range(2,int(n**0.5)+1):
      if n%i==0:
        return False
    return True
for i in range(2,int(n**0.5)+1):
  while n1%i==0:
    l.append(i)
    n1=n1//i
  if isprime(n1):
    l.append(n1)
    break
w=str(n)+":"
for i in l:
  w+=" "+str(i)
print(w)


Measured memory_bytes: 5644
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y;
    char hoge;
    cin>>a>>hoge>>b;
    if(hoge=='+') cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s, t, u;
	int a, b;
	//cin >> s >> t;
//	cin >> a >> b;
//	cin >> u;
//	if(u == s){
//		cout << a-1 << " " << b << endl;
//	} else{
//		cout << a << " " << b-1 << endl;
//	}
	cin >> s;
	for(int i = 0; i < (int)s.size(); i++)
		cout << "x";
	cout << endl;
	return 0;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int count = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(i*500+j*100+k*50 == x)count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
//29
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
  string ct=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  const char *en[]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
  for(string s;getline(cin,s);){
    string code;
    for(int i=0;i<s.size();i++){
      code+=en[ct.find(s[i])];
    }
    code+=string((code.size()+4)/5*5-code.size(),'0');
    for(int i=0;i<code.size()/5;i++){
      static const char *de="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
      cout<<de[strtol(code.substr(i*5,5).c_str(),0,2)];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
m = {0:"NA", 1:"YYMM", 2:"MMYY", 3:"AMBIGUOUS"}
s = input()
ans = 0
a = int(s[:2])
b = int(s[2:])
if 0 <= a <= 99 and 1 <= b <= 12:
    ans |= 1
if 0 <= b <= 99 and 1 <= a <= 12:
    ans |= 2
print(m[ans])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

char s[100][100];
int dp[100][100];

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> s[i][j];
        }
    }
    dp[0][0] = (s[0][0] == '#');
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i == 0 && j == 0)
                continue;
            else if (i == 0)
                dp[i][j] = dp[i][j - 1] + (s[i][j] != s[i][j - 1] && s[i][j] == '#');
            else if (j == 0)
                dp[i][j] = dp[i - 1][j] + (s[i][j] != s[i - 1][j] && s[i][j] == '#');
            else
                dp[i][j] = min(dp[i][j - 1] + (s[i][j] != s[i][j - 1] && s[i][j] == '#'),
                               dp[i - 1][j] + (s[i][j] != s[i - 1][j] && s[i][j] == '#'));
        }
    }
    cout << dp[H - 1][W - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    int f=1;
    int c=0;
    while(f==1){
        f=0;
        for (int j = n-1; j >0; j--) {
            if(a[j]<a[j-1]){
                c++;
                swap(a[j],a[j-1]);
                f=1;
            }
        }
    }
    rep(i,n-1)std::cout << a[i] << ' ';
    std::cout  <<a[n-1]<< std::endl;
    std::cout << c << std::endl;
}


Measured memory_bytes: 3212
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]


def bellman_ford(s, g):
	# loop 0 - (n-1) : bellman ford
	# loop n - (2n-1): check g can be updated
	dist = [float("inf")] * n
	dist[s] = 0
	for i in range(2 * n):
		for a, b, c in abc:
			a -= 1
			b -= 1
			c = -c

			if dist[b] > dist[a] + c:
				dist[b] = dist[a] + c
				if i >= n:
					dist[b] = -float("inf")

	if dist[g] == -float("inf"):
		ret = "inf"

	else:
		ret = -dist[g]

	return ret


ans = bellman_ford(0, n - 1)
print(ans)


Measured memory_bytes: 3572
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();

    if (a.equals(b)) {
      System.out.println("H");
    } else {
      System.out.println("D");
    }

  }

}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>

int p[2][100001],q[2][100001],n,k;
int tem[100001],A[100001],ans[100001],con[100001],top,f[7][100001];
bool vis[100001];
void mul(int *a,int *b,int *c){
	for(int i=1;i<=n;i++)tem[i]=a[b[i]];
	for(int i=1;i<=n;i++)c[i]=tem[i];
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&p[0][i]),p[1][p[0][i]]=i;
	for(int i=1;i<=n;i++)scanf("%d",&q[0][i]),q[1][q[0][i]]=i;
	for(int i=1;i<=n;i++)A[i]=ans[i]=i;
	mul(A,q[0],A);
	mul(A,p[1],A);
	mul(A,q[1],A);
	mul(A,p[0],A);
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			con[(top=0)++]=i;
			int Tem=A[i];
			vis[i]=1;
			while(Tem!=i){
				vis[Tem]=1;
				con[top++]=Tem;
				Tem=A[Tem];
			}
			for(int i=0;i<top;i++)
				tem[con[i]]=con[(i+((k-1)/6))%top];
		}
	for(int i=1;i<=n;i++)A[i]=tem[i];
	mul(ans,A,ans);
	memcpy(f[1],p[0],sizeof p[0]);
	memcpy(f[2],q[0],sizeof q[0]);
	for(int i=3;i<=(k-1)%6+1;i++){
		for(int j=1;j<=n;j++)tem[f[i-2][j]]=j;
		for(int j=1;j<=n;j++)f[i-2][j]=tem[j];
		mul(f[i-1],f[i-2],f[i]);
	}
	mul(ans,f[(k-1)%6+1],ans);
	for(int i=1;i<=n;i++)tem[A[i]]=i;
	for(int i=1;i<=n;i++)A[i]=tem[i];
	mul(ans,A,ans);
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
}

Measured memory_bytes: 6272
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back

#define INT 1.01

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

    int64_t X;
    cin >> X;

    int64_t v = 100;
    int ret = 0;
    while(true){
    //rep(ret, INF){
        if(X<=v){
            cout << ret << endl;
            break;
        }
        ret ++;
        //v *= INT;
        v += 0.01*v;
    }

    //cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>V;
void func(int node,int par,int rang);
bool flg[100000]={0};
int n,u,k,c;
V v[100000];
struct Node{
	int parent,depth;
};
Node T[100000];
int main(void){
	
	int i,j;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>u>>k;
		T[i].parent=0;
		T[i].depth=0;
		for(j=0;j<k;j++){
			cin>>c;
			flg[c]=1;
			v[u].push_back(c);
		}
	}
	for(i=0;i<n;i++){
		if(!flg[i]){
			func(i,-1,0);
		}
	}
	//cout<<"check2"<<endl;
	for(i=0;i<n;i++){
		cout<<"node "<<i<<": parent = "<<T[i].parent<<", depth = "<<T[i].depth<<", ";
		if(v[i].empty()){
			if(T[i].parent==-1){
				cout<<"root, []"<<endl;
			}
			else{
				cout<<"leaf, []"<<endl;
			}
		}
		else{
			if(T[i].parent==-1){
				cout<<"root, ["<<v[i][0];
				for(j=1;j<v[i].size();j++){
					cout<<", "<<v[i][j];
				}
				cout<<"]"<<endl;
			}
			else{
				cout<<"internal node, ["<<v[i][0];
				for(j=1;j<v[i].size();j++){
					cout<<", "<<v[i][j];
				}
				cout<<"]"<<endl;
			}
		}
	}
	return 0;
}
void func(int node,int par,int rang){
	int i;
	//cout<<"check"<<endl;
	T[node].parent=par;
	T[node].depth=rang;
	//cout<<"cheack1"<<endl;
	for(i=0;i<v[node].size();i++){
		func(v[node][i],node,rang+1);
	}
}
	
	
	
	
	


Measured memory_bytes: 7112
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

int rwa[100006];

signed main() {
	int n,q; cin >> n>>q; string s; cin >> s;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'A'&&s[i] == 'C') {
			rwa[i]++;
		}
	}
	rep(i, n)rwa[i + 1] += rwa[i];
	rep(i, q) {
		int l, r;
		cin >> l >> r;
		cout << rwa[r-1] - rwa[l-1] << endl;
	}
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) { return a * b * gcd(a, b); }

bool compareP(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll f, l = 0, c = 0;
    ll ans = 0;
    bool flag = true;
    while (c < s.size()) {
        int cnt = 1;
        char tmp = s[c];
        while (c < s.size() && s[c + 1] == tmp) {
            cnt++;
            c++;
        }
        if (flag) {
            f = cnt;
            flag = false;
        } else if (c == s.size() - 1)
            l = cnt;
        else
            ans += cnt / 2;
        c++;
    }
    ans *= k;
    if (f == s.size())
        ans += (f * k) / 2;
    else if(s[0] == s[c - 1])
        ans += ((f + l) / 2) * (k - 1) + (f / 2) + (l / 2);
    else
        ans += ((f / 2) + (l / 2)) * k;
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
#if N >= M:
#  print(0)
#  exit()
  
X = list(map(int,input().split()))

X.sort()
diff = []

for i in range(1,M):
  diff.append(X[i]-X[i - 1])

diff.sort()

for i in range(N - 1):
  if len(diff) != 0:
    diff.pop()

print(sum(diff))

Measured memory_bytes: 13968
H,W = (int(i)for i in input().split())
S = []

zero = []
for i in range(W+2):
    zero += '-'
S.append(zero)
for i in range(H):
    tmp = ['-']
    tmp += (list(str(input())))
    tmp += '-'
    S.append(tmp)
S.append(zero)
ans = []
for h in (range(H)):
    tmp = []
    for w in (range(W)):
        if S[h+1][w+1] == '#':
            tmp.append('#')
        else:
            count = 0
            for i in range(3):
                for j in range(3):
                    if S[h+i][w+j] == '#':
                        count += 1
            tmp.append(str(count))
    ans.append(tmp)

for i in range(H):
    print(''.join(ans[i]))



Measured memory_bytes: 3188
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	//static long mod = 1000000007;
	static long mod =998244353; 
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";


		long res = 0;


		int n = int.Parse(Console.ReadLine());
		//int[] vals = new int[n];
		int[] vals = parseAry(Console.ReadLine().Split(cs));

		
		/*
		for ( int i = 1; i < (n+2)/2; i++ ) {
			vals[i] = i;
			vals[i+(n/2)-1] = i;
		}*/

			if ( vals[0] != 0 ) { Console.WriteLine(0); return; }
		long[] num = new long[n];
		for ( int i = 1; i < n; i++ ) {
			if ( vals[i] == 0 ) { res = 0; Console.WriteLine(res); return; }
			num[vals[i]]++;
		}
		res=1;
		for ( int i = 2; i < n; i++ ) {
			if ( num[i] == 0 ) {
				for ( int k = i; i < n; i++ ) {
					if ( num[i] != 0 ) { res = 0; break; }
				}
				break;
			}
			long p=(long)mod_pow(num[i-1],num[i])%mod;
			res = ( res * p) % mod;
		}


			Console.WriteLine(res);

		return;

	}
	static public long mod_pow(long x, long n) {
		long res = 1;
		while ( n > 0 ) {
			if ( ( n & 1 ) == 1 ) { res = res * x % mod; }
			x = (x * x) % mod;
			n >>= 1;
		}
		return res;
	}

	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			sb.Append(a[i] + " "); 
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 18912
#include <iostream>
#include <vector>
#include <string>
#define ll long long
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){
    while(b!=0){
        a %= b;
        if(a==0) return b;
        b %= a;
    }
    return a;
}
int main(){
  int n; cin >> n;
  int a[n]; for(int i=0;i<n;i++) cin >> a[i];
  if(n>2){
  int gcdl[n],gcdr[n];
  gcdl[0] = a[0]; gcdr[n-1] = a[n-1];
  for(int i=n-2;i>=0;i--) gcdr[i] = gcd(gcdr[i+1],a[i]);
  for(int i=1;i<n;i++) gcdl[i] = gcd(gcdl[i-1],a[i]);
  int ans = gcdr[1];
  for(int i=1;i<n-1;i++){
    int res = gcd(gcdl[i-1],gcdr[i+1]);
    ans = max(ans,res);
  }
  cout << max(ans,gcdl[n-2]) << endl;
  }
  else cout << max(a[0],a[1]);
  
  return 0;
}



Measured memory_bytes: 1408
n=gets.chomp.to_i
s=n.times.map { gets.chomp.to_s }
m=gets.chomp.to_i
t=m.times.map { gets.chomp.to_s}

count = -10*9

for i in s do
  temp = 0
  for j in s do
    if i == j
      temp += 1
    end
  end

  for k in t do
    if i == k
      temp -= 1
    end
  end
  count = temp > count ? temp : count
end

if count < 0
  puts 0
else
  puts count 
end


Measured memory_bytes: 1788
import sys
input=sys.stdin.readline
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
dic={}
for i,x in enumerate(b):
	dic[x]=i
for i in range(n):
	a[i]=dic[a[i]]
cnt=0
for i in range(n):
	if i%2!=a[i]%2:
		cnt+=1
print(cnt//2)

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

const int N = 1111;
const string colors = "YGRB";
string mat[N];
int h, w, d;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cin >> h >> w >> d;
    for(int i = 0; i < N; i++) {
        mat[i] = "";
        for(int j = 0; j < N; j++) {
            int ii = i % (2 * d);
            int jj = j % (2 * d);
            bool iii = ii < d;
            bool jjj = jj < d;
            mat[i] += colors[iii * 2 + jjj];
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int ii = i + j;
            int jj = i - j + 500;
            cout << mat[ii][jj];
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int64_t price = 0;
	int64_t min_price;
	for(int i = 0; i <= max(x, y); i++) { // ABピザを2i枚買ったとき
		price += 2 * i * c; //2i枚の値段
		if(x > i) { //ABピザで足りなかった分
			price += (x - i) * a;
		}
		if(y > i) { //ABピザで足りなかった分
			price += (y - i) * b;
		}
		if(i == 0) {
			min_price = price;
		}
		else {
			min_price = (price < min_price) ? price : min_price;
		}
		price = 0;
	}
	cout << min_price << endl;
}

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

vector<int> countingSort(vector<int> &array,int n,int max){
    vector<int> count_array(max+1,0);
    for(int i=0;i<n;i++){
        int x = array.at(i);
        count_array.at(x) ++;
    }
    /*for(int i=0;i<=max;i++){
        cout << count_array.at(i) << " ";
    }
    cout << endl;*/
    for(int i=1;i<=max;i++){
        count_array.at(i) = count_array.at(i) + count_array.at(i-1);
    }
    /*for(int i=0;i<=max;i++){
        cout << count_array.at(i) << " ";
    }
    cout << endl;*/
    vector<int> arr(n);
    for(int i=n-1;i>=0;i--){
        int num = array.at(i);
        //cout << num << endl;
        int idx = count_array.at(num);
        arr.at(idx-1) = num;
        count_array.at(num)--;
        //cout << count_array.at(num) << endl;
    }
    return arr;
}

int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++) cin >> array.at(i);
    int max = -1;
    for(int i=0;i<n;i++){
        if(max<array.at(i)){
            max = array.at(i);
        }
    }
    vector<int> arr = countingSort(array,n,max);
    for(int i=0;i<n;i++){
        cout << arr.at(i);
        if(i != n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    } 
}


Measured memory_bytes: 18384
// 2020-06-27 22:56:42
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> sum_a(n+1, 0), sum_b(m+1, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    sum_a[i+1] = sum_a[i] + a;
  }
  rep(i, m) {
    ll b;
    cin >> b;
    sum_b[i+1] = sum_b[i] + b;
  }
  int cur_a = n+1, cur_b = 0, ans = 0;
  while(1) {
    cur_a--;
    while(sum_a[cur_a] + sum_b[cur_b] <= k) {
      chmax(ans, cur_a + cur_b);
      if(cur_b == m) break;
      else cur_b++;
    }
    if(cur_a == 0) break;
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 6364
from heapq import heappush, heappop
from random import randint
from time import time

class PriorityQueue(object):
    def __init__(self):
        self.queue = []
    def push(self, value):
        heappush(self.queue, value)
    def pop(self):
        return heappop(self.queue)
    def __len__(self):
        return len(self.queue)
    def __contains__(self, item):
        return item in self.queue

n,m = map(int,input().split())
v = list(map(int,input().split()))

ans = 0

#取得する操作を何回行うか？
for i in range(0,m+1):

	#操作残り回数
	lef = m-i

	hp = PriorityQueue()
	#左側からどれだけ取るか？
	for j in range(0,i+1):
		if j>n :
			break

		#左側からj個取る
		for k in range(0,j):
			hp.push(v[k])

		#右側から i-j個取る
		for k in range(0,i-j):
			if n-1-k < j:
				break
			hp.push(v[n-1-k])

		#minusは戻す
		for k in range(0,lef):
			if len(hp) == 0:
				break
			top = hp.pop()
			if top>=0 :
				hp.push(top)
				break

		ss = 0
		while len(hp)>0:
			ss += hp.pop()

		ans = max(ans,ss)

print(ans)

Measured memory_bytes: 9596
import numpy as np
 
a,b=map(int,input().split())
A=np.array(sorted(list(map(int,input().split()))))
F=np.array(sorted(list(map(int,input().split())),reverse=True))
 
s=A.sum()
 
x=-1
y=10**12
while x+1<y:
  mid=(x+y)//2
  if s-np.minimum(A,mid//F).sum()<=b:
    y=mid
  else:
    x=mid
print(y)

Measured memory_bytes: 37276
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    ll n, k; cin >> n >> k;
    ll h[n];
    rep(i,n) cin >> h[i];
    sort(h,h+n, greater<ll>());
    ll ans=0;
    for(int i = k; i < n; i++){
        ans += h[i];
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>

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

int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int h,w;
int main() {
	cin >> h >> w;
	string s = "snuke";

	int count = 0;
	char a1;
	int a2;
	rep(i,1,h+1){
		rep(j,1,w+1){
			string n;
			cin >> n;
			if(n == s){
				a1 = j-1+'A';
				a2 = i;
			}
		}
	}
	printf("%c%d\n",a1,a2);
	return 0;
}

Measured memory_bytes: 256
n=int(input())

a=[0]*n

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      k=x*x+y*y+z*z+x*y+y*z+z*x
      if k <=n:
        a[k-1]+=1
        
for q in range(n):
  print(a[q])

Measured memory_bytes: 74828
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << max({a,b,c}) - min({a,b,c}) << endl;
	return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=jp

int part(int a[], int p, int r) {
	int x = a[r];
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (a[j] <= x) {
			i += 1;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}

int main() {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) cin >> arr[i];
	int d = part(arr, 0, n - 1);
	
	if (d == 0) cout << "[" << arr[0] << "]";
	else cout << arr[0];
	
	for (int i = 1; i < n; i++) {
		cout << " " << (i == d ? "[" : "") << arr[i] << (i == d ? "]" : "");
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1556
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
// #MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(int argc, char const *argv[]) {
  int n,m;
  std::cin >> n >> m;
  int sum=0,a[m],ans;

  REP(i,m) std::cin >> a[i];
  REP(i,m) sum+=a[i];
  ans = n - sum;
  if (ans < 0) ans = -1;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3660