akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		HashMap<Integer, Long> map = new HashMap<Integer, Long>();

		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
			if (map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1l);
			}
		}
		long sum = 0;
		for (long i : map.values()) {
			sum += i * (i - 1) / 2;
		}

		long[] ans = new long[n];

		long b = 0;
		for (int i = 0; i < n; i++) {
			b = map.get(a[i]) - 1;
			if (b > 0)
				ans[i] = sum - b;
			else
				ans[i] = sum;
		}

		for (long i : ans) {
			System.out.println(i);
		}
	}

}


Measured memory_bytes: 99576
#include<bits/stdc++.h>
using namespace std;
#define MN 200005
char c[MN];
int n,num[26];
long long ans;
int main(){
	scanf("%s",c+1);
	n=strlen(c+1);
	for(int i=n;i>=1;i--) ans+=(n-i)-num[c[i]-'a']++;
	ans++;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 384
N=int(input())
h=list(map(int,input().split()))

dp=[-1]*(N+1)
dp[1]=0
dp[2]=abs(h[2-1]-h[1-1])

for i in range(3,N+1):
  dp[i]=min(abs(h[i-1]-h[i-2])+dp[i-1],abs(h[i-1]-h[i-3])+dp[i-2])
  
print(dp[N])

Measured memory_bytes: 20628
#include <iostream>
#include <fstream>
#include <cstdlib>

#define MAX_C 30
#define MAX_N 500

using namespace std;

int matrix[MAX_N+1][MAX_N+1];
int color[MAX_C+1][MAX_C+1];

int cnt[3][MAX_C+1];

int n;
int c; 
int min_cost = 1000*500*500;
int cost;
int min_x;
int min_y;
int min_z;
bool changed_x;
bool changed_y;
bool changed_z;
int main()
{
    cin>>n>>c;
    for(int i = 1;i<=c;i++)
        for(int j = 1;j<=c;j++)
            cin>>color[i][j];
    for(int i = 1;i<=n;i++)
        for(int j = 1;j<=n;j++){
            cin>>matrix[i][j];
            cnt[(i+j)%3][matrix[i][j]]++;
        }
    //permutation of target color
    for(int x=1;x<=c;x++)
        for(int y=1;y<=c;y++)
            for(int z=1;z<=c;z++){
                if (x!=y && y!=z && z!=x){
                    cost = 0;
                    //changed_x=false;
                    for (int k = 1;k<=c;k++){
                        cost += color[k][x]*cnt[0][k];
                        //if(color[cnt[0][k]][x])changed_x = true;
                    }
                    //changed_y=false;
                    for (int k = 1;k<=c;k++){
                        cost += color[k][y]*cnt[1][k];
                        //if(color[cnt[1][k]][y])changed_y = true;
                    }
                    //changed_z=false;
                    for (int k = 1;k<=c;k++){
                        cost += color[k][z]*cnt[2][k];
                        //if(color[cnt[2][k]][z])changed_z = true;
                    }
                    //if(changed_x && changed_y && changed_z && cost<min_cost){
                    if(cost<min_cost){
                        min_x = x;
                        min_y = y;
                        min_z = z;
                        min_cost = cost;
                    }
                }
            }
    cout<<min_cost<<endl;
    //cout<<min_x<<" "<<min_y<<" "<<min_z<<endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  for(char i='a';i<='z';i++){
    bool flag=true;
    for(int j=0;j<S.size();j++){
      if(S.at(j)==i){
        flag=false;
        break;
      }
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll N,M;
  cin >> N >> M;
  cout << min(N,M/2) + max(ll(0),M-2*N)/4 << endl;
  return 0;
}


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

int main() {
  std::string S;

  std::cin >> S;

  int const N = S.size();

  int even_black = 0;
  int even_white = 0;
  int odd_black = 0;
  int odd_white = 0;

  for (int i=0; i<N; i++) {
    if (i%2 == 0) {
      if (S[i] == '0') {
        even_black++;
      } else {
        even_white++;
      }
    } else {
      if (S[i] == '0') {
        odd_black++;
      } else {
        odd_white++;
      }
    }
  }

  auto ans = std::min(even_white+odd_black, even_black+odd_white);

  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > vp(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		vp[i] = make_pair(b, a);
	}
	sort(vp.begin(), vp.end());
	
	int ans = 0, pre = 0;
	rep(i, m) {
		if (vp[i].second > pre) {
			pre = vp[i].first - 1;
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

int main()
{
	INT n;
	cin >> n;
	
	INT max1 = 0, maxi = -1, max2 = 0;

	for (size_t i = 0; i < n; i++)
	{
		INT t;
		cin >> t;

		if (t >= max1)
		{
			max2 = max1;
			max1 = t;
			maxi = i;
		}
		else if (t >= max2)
		{
			max2 = t;
		}
	}

	for (size_t i = 0; i < n; i++)
	{
		if (i == maxi)
		{
			cout << max2 << endl;
		}
		else
		{
			cout << max1 << endl;
		}
	}
}


Measured memory_bytes: 1664
N = int(input())
ans_ac = 0
ans_wa = 0
ans_tle =0
ans_re =0

for i in range(N):
    S = input()
    if S == 'AC':
        ans_ac += 1
    elif S == 'WA':
        ans_wa += 1
    elif S == 'TLE':
        ans_tle += 1
    else:
        ans_re += 1

print('AC','x',ans_ac)
print('WA','x',ans_wa)
print('TLE','x',ans_tle)
print('RE','x',ans_re)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int p,q,a,n;

pii add(pii i1,int c){
    int a=i1.first,b=i1.second;
    int d = a*c;
    int e = b*c+a;
//    int t = gcd(d,e);
//    return make_pair(d/t,e/t);
    return pii(d,e);
}

// sum = (bunbo,bunsi)
int dfs(pii sum,ll product,int start,int num){
    if(sum.second*q==sum.first*p){ return 1; }
    if(num==n || sum.second*q>sum.first*p) return 0;

    int ret=0;
    for(int i=start;i<a/product+1;i++){
        if(i*product>a) break;
        pii ns = add(sum,i);
        ret += dfs(add(sum,i),product*i,i,num+1);
    }
    return ret;
}

int main(){
    while(cin>>p>>q>>a>>n){
        if(p==0 && q==0 && a==0 && n==0) break;
        int g = gcd(p,q);
        p /= g;
        q /= g;
        cout << dfs(make_pair(1,0),1,1,0) << endl;
    }
}

Measured memory_bytes: 2944
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define mod(x) ((x % MOD) + MOD) % MOD
#define int long long int
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define rrep(i, a, n) for(int i = n-1; i >= a; --i)

using namespace std;

typedef pair<int,int> P;

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}

struct edge {
  int to, cost;
  bool used;
};

void fill_potential(vector<int>& V, vector< vector<edge> >& G, int i, int x)
{
  if (V[i] != INF) {
    return;
  }

  V[i] = x;

  rep(j, 0, G[i].size()) {
    edge e = G[i][j];
    fill_potential(V, G, e.to, x + e.cost);
  }
}

bool dfs(vector<int>& V, vector< vector<edge> >& G, int i) {
  rep(j, 0, G[i].size()) {
    edge e = G[i][j];
    if (e.used) {
      continue;
    }
    e.used = true;
    if (V[i] + e.cost != V[e.to]) {
      return false;
    }
  }
  return true;
}



signed main()
{
  int N, M;
  cin >> N >> M;
  vector< vector<edge> > G(N, vector<edge>());
  int l, r, d;
  rep(i, 0, M) {
    cin >> l >> r >> d;
    l--; r--;
    G[l].push_back(edge{ r, -d, false });
    G[r].push_back(edge{ l,  d, false });
  }

  vector<int> V(N, INF);
  rep(i, 0, N) {
    fill_potential(V, G, i, 0);
  }
  rep(i, 0, N) {
    if (!dfs(V, G, i)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 21632
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    double r;
    cin>>r;
    double pi=3.141592653589;
    double arc = 2*pi*r;
    double circ = pi*r*r;
    printf("%.6f  %.6f\n",  circ, arc);
    return 0;
}


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

l = [list(map(int, input().split())) for i in range(n-1)]




for i in range(n):
    p = i
    t = 0
    while p!=n-1:
        # 出発時刻
        if t > l[p][1]:
            if t%l[p][2] != 0:
                t += l[p][2]-t%l[p][2]
        else:
            t = l[p][1]
        # 到着時刻
        t += l[p][0]
        p += 1
    print(t)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <array>

class Baseball{
	int score;
	int out_count;
	std::array<bool, 3> runner;
	
public:
	Baseball(){
		score = 0;
		out_count = 0;
		for(int i = 0 ; i < 3 ; ++i){
			runner[i] = false;
		}
	}
	int get_score(){ return score; } //getter
	void start_inning();
	void event_hit();
	void event_homerun();
	void event_out();
};

void Baseball::start_inning(){
	std::string event;
	
	while(out_count < 3){
		std::cin >> event;
		if(event == "HIT"){
			event_hit();
		}else if(event == "HOMERUN"){
			event_homerun();
		}else if(event == "OUT"){
			event_out();
		}
	}
}

void Baseball::event_hit(){
	if(runner[2]){
		++score;
		runner[2] = false;
	}
	if(runner[1]){
		runner[2] = true;
		runner[1] = false;
	}
	if(runner[0]){
		runner[1] = true;
		runner[0] = false;
	}
	runner[0] = true;
}

void Baseball::event_homerun(){
	for(int i = 0 ; i < 3 ; ++i){
		if(runner[i]){
			runner[i] = false;
			++score;
		}
	}
	++score;
}

void Baseball::event_out(){
	++out_count;
}

int main(){
	int n; //number of inning
	std::cin >> n;
	
	while(n--){
		Baseball baseball;
		
		baseball.start_inning();
		std::cout << baseball.get_score() << std::endl;
	}
	
    return 0;
}

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

using namespace std;
long long mas[5001];
long long val[5001];
bool vis[5001];
int main()
{
    long long n,k,ans=-1e14;
    cin>>n>>k;
    for(long long i=1; i<=n; i++){
        cin>>mas[i];
    }
    for(long long i=1; i<=n; i++){
        cin>>val[i];
    }
    for(long long i=1; i<=n; i++){
        if(!vis[i]){
            vector<long long> cycle_members;
            cycle_members.push_back(i);
            long long cycle_length=1,cycle_sum=val[i];
            vis[i]=1;
            long long pos=mas[i];
            while(pos!=i){
                vis[pos]=1;
                cycle_length++;
                cycle_sum+=val[pos];
                cycle_members.push_back(pos);
                pos=mas[pos];
            }
            //cout<<i<<" "<<cycle_length<<"\n";
            for(auto u:cycle_members){
                long long ans1=cycle_sum*((k-1)/cycle_length);
                long long pos=u;
                for(long long j=0; j<(k-1)%cycle_length+1; j++){
                    pos=mas[pos];
                    ans1+=val[pos];
                    ans=max(ans,ans1);
                }
            }
            for(auto u:cycle_members){
                long long ans1=0;
                long long pos=u;
                for(long long j=0; j<min(cycle_length,k); j++){
                    pos=mas[pos];
                    ans1+=val[pos];
                    ans=max(ans,ans1);
                }
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    h[0]--;
    rep(i,n-1){
        if(h[i] + 1 <= h[i+1]) h[i+1]--;
        if(h[i] - 1 >= h[i+1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define WHITE 0
#define BLACK 1

void prim(int);

int G[100][100] = {};  //??°??????
int color[100]={};    //?????\??¨??????
int n;               //????????°
int mincost=0;        //????°???¨?????¨?????????
int min;          

int main(){
  int i, j;

  scanf("%d",&n);
  if( n<1 || 100<n ) exit(1);

  for( i=0 ; i<n ; i++ ){
    for( j=0 ; j<n ; j++ ){
    scanf("%d",&G[i][j]);
    }
  }
  
  prim(0);

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

  return 0;
}

void prim(int r){
  int i, j, k=0, tmp=INT_MAX;
  
  color[r] = BLACK;
  
  while(1){
    
    for( k=0 ; k<n ; k++ ){
      if(color[k] == WHITE) break;
    }
   
    if( k==n ) break;
    
    min = INT_MAX;
    
    for( i=0 ; i<n ; i++){
      if( color[i] == WHITE ) continue;
      
      for( j=0 ; j<n ; j++ ){
	if(G[i][j] == -1 || color[j] == BLACK){
	  continue;
	}
	else{
	  if(min > G[i][j]){
	    min = G[i][j];
	    tmp = j;
	  }
	}
      }
    }
	   
    color[tmp] = BLACK;
    mincost += min;
  }

}

Measured memory_bytes: 640
N, A, B, C = map(int, input().split())


def f(a, b, c, bl, ans):
    if len(bl) == 0:
        if len(a) == 0 or len(b) == 0 or len(c) == 0:
            return ans
        return abs(A - sum(a)) + (len(a) - 1) * 10 + \
            abs(B - sum(b)) + (len(b) - 1) * 10 + \
            abs(C - sum(c)) + (len(c) - 1) * 10
    for i in range(len(bl)):
        l = bl[i]
        a.append(l)
        ans = min(ans, f(a, b, c, bl[i + 1:], ans))
        a.pop(-1)
        b.append(l)
        ans = min(ans, f(a, b, c, bl[i + 1:], ans))
        b.pop(-1)
        c.append(l)
        ans = min(ans, f(a, b, c, bl[i + 1:], ans))
        c.pop(-1)
        ans = min(ans, f(a, b, c, bl[i + 1:], ans))
    return ans


def main():
    bl = []
    for _ in range(N):
        bl.append(int(input()))
    print(f([], [], [], bl, 10000))


main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  ll a,b,c; cin >> a >> b >> c;
  ll x = c-(a+b);
  if(x<0) {
    cout << "No" << "\n";
    return 0;
  }
  x = sqr(x);
  ll y = 4 * a * b;
  if(x>y) cout << "Yes" << endl;
  else cout << "No" << endl;
    

}


Measured memory_bytes: 256
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d %d\n", a*b, 2*(a+b));
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
ll mod = 1000000007;
int main()
{
    int n;
    ll ans=1;
    cin >>n;
    vector<ll>last(1000010,0LL);
    last[0]=3LL;
    int bef;
    rep(i,n){
        cin>>bef;
        last[bef+1]++;
        
        ans*=(last[bef]);
        last[bef]--;
        ans%=mod;
        
       // clog<<ans<<" ( "<<last[bef]<<" "<<last[bef+1]<<endl;
        if(ans<0){
            cout<<"0"<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int x, y, z, k;

int main() {
    cin >> x >> y >> z >> k;
    vector<ll> A(x, 0);
    vector<ll> B(y, 0);
    vector<ll> C(z, 0);
    for(int i = 0; i < x; ++i) cin >> A.at(i);
    for(int i = 0; i < y; ++i) cin >> B.at(i);
    for(int i = 0; i < z; ++i) cin >> C.at(i);
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> AB;
    for(int i = 0; i < x; ++i) {
        for(int j = 0; j < y; ++j) {
            ll sum = A.at(i)+B.at(j);
            AB.emplace_back(sum);
        }
    }

    sort(AB.begin(), AB.end(), greater<ll>());
    vector<ll> ABC;
    for(int i = 0; i < min(x*y, 3000); ++i) {
        for(int j = 0; j < z; ++j) {
            ll sum = AB.at(i) + C.at(j);
            ABC.emplace_back(sum);
        }
    }

    sort(ABC.begin(), ABC.end(), greater<ll>());
    for(int i = 0; i < k; ++i) {
        cout << ABC.at(i) << endl;
    }
}

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

using namespace std;

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

  int count_ac = 0;
  int count_wa = 0;
  int count_tle = 0;
  int count_re = 0;

  for (int i = 0; i < n; i++){
    string str;
    cin >> str;

    if (str == "AC"){
      count_ac++;
    } else if (str == "WA"){
      count_wa++;
    } else if (str == "TLE"){
      count_tle++;
    } else if (str == "RE"){
      count_re++;
    }
  }

  cout << "AC x " << count_ac << endl;
  cout << "WA x " << count_wa << endl;
  cout << "TLE x " << count_tle << endl;
  cout << "RE x " << count_re << endl;
 
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Map<Integer, Integer> h = new TreeMap<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            if (h.containsKey(a[i])) {
                h.put(a[i], h.get(a[i]) + 1);
            } else {
                h.put(a[i], 1);
            }
        }
        List<Integer> max4 = h.entrySet().stream().filter(x -> x.getValue() >= 4).map(x -> x.getKey())
                .collect(Collectors.toList());
        List<Integer> max2 = h.entrySet().stream().filter(x -> x.getValue() >= 2).map(x -> x.getKey())
                .collect(Collectors.toList());
        long ans = 0;
        if (max4.size() > 0) {
            ans = (long) max4.get(0) * max4.get(0);
        }
        if (max2.size() > 1) {
            if (ans < (long) max2.get(0) * max2.get(1))
                ans = (long) max2.get(0) * max2.get(1);
        }
        System.out.println(ans);
    }
}

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

using namespace std;

int main() {
	vector<int> v;
	for(int i=0;i<3;i++) {
		int temp;
		cin >> temp;
		v.push_back(temp);
	}
	sort(v.begin(), v.end());

	for(auto it = v.begin(); it != v.end(); it++) {
		cout << *it;
		if(it - v.begin() < 2) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
vector<vector<ll>>vec(ll x, ll y, ll w){
  vector<vector<ll>>v(x,vector<ll>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  cout<<max({a+b,a-b,a*b})<<endl;


  return 0;
}

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

int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;
  if(S.at(K-1)=='A'){
    S.at(K-1)='a';
  }
  else if(S.at(K-1)=='B'){
    S.at(K-1)='b';
  }
  else{
    S.at(K-1)='c';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
 
int main(){
  int n,d,f[1000]={};
  string s;
  cin>>n;
  cin>>s;
  cin>>d;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'&&d>0)s[i]='1',f[i]=1,d--;
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='1'&&d>0&&!f[i])s[i]='0',d--;
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {


	/**与えられた二つの行列の積を出力
	 *
	 * @param args
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String args[]){


		int gyo = scan.nextInt();
		int retu = scan.nextInt();		//vec_1:retu / vec_2:gyo
		int re_retu = scan.nextInt();

		//		int gyo = Integer.parseInt(args[0]);
		//		int retu = Integer.parseInt(args[1]);		//vec_1:retu / vec_2:gyo
		//		int re_retu = Integer.parseInt(args[2]);

		//		int output;
		long[][] vec_1 = new long[gyo][retu];			//一つ目の行列
		long[][] vec_2 = new long[retu][re_retu];		//２つ目の行列


		//入力→配列に収める

		for(int i = 0 ;i < gyo ;i++){
			for(int j = 0 ;j < retu ;j++){
				vec_1[i][j] = scan.nextLong();
				//vec_1[i][j] = Integer.parseInt(args[3 + (retu * i) + j]);
			}
		}
		for(int j=0;j<retu;j++){
			for(int k = 0 ;k < re_retu ;k++){
				vec_2[j][k] = scan.nextLong();
				//	vec_2[j][k] = Integer.parseInt(args[2 + (gyo * retu +1)+(re_retu * j) + k]);//2+6+1+3*j+k
			}
		}

		//配列→出力
		long[][] sum = new long[gyo][re_retu];

		for(int p = 0 ;p < gyo ;p++){
			for(int q = 0 ;q < re_retu ; q++){
				sum[p][q]=0;
				for(int k = 0 ; k < retu ;k++){
					sum[p][q] = sum[p][q] + vec_1[p][k]*vec_2[k][q];
				}
				if(q != re_retu-1){							//最後の列だけは空白をいれない
					System.out.print(sum[p][q]+" ");
				}else{
					System.out.print(sum[p][q]);
				}
			}
			System.out.println("");
		}
	}
}


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

int main(){
    int n, x, y;
    cin >> n;
    if ( n == 1 ) {
        cout << "Hello World\n";
    } else {
        cin >> x >> y;
        cout << x + y << endl;
    }
    
    return (0);
}


Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0


int main(){
	int n,hasi[2][128];
	int dp[2][128];
	while(scanf("%d",&n),n){
		rep(i,128)dp[0][i]=dp[1][i]=INT_MAX;
		rep(i,n)scanf("%d",&hasi[0][i]);
		rep(i,n)scanf("%d",&hasi[1][i]);

		rep(k,2){
			bool f = true;
			if( hasi[k][0]==1 ){
				rep(j,n+1){
					if( hasi[k][j]!=1 ){
						dp[k][j-1] = 0;
						f = false;
						break;
					}
				}
			}
			if( f ){
				dp[k][0] = 0;
			}
		}

		for(int t=1;;t++){
			bool change = false;
			rep(i,n){
				rep(k,2)if( dp[k][i]!=INT_MAX ){
					int next = (k+1)%2;
					rep(j,3){
						if( hasi[next][i+j]==0 ){
							if( dp[next][i+j] > dp[k][i]+1 ){
								dp[next][i+j] = dp[k][i]+1;
								change = true;
							}
						}else if( hasi[next][i+j]==1 ){
							rep(l,n)if( hasi[next][i+j+l]!=1 || i+j+l==n ){
								if( dp[next][i+j+l-1] > dp[k][i]+1 ){
									dp[next][i+j+l-1] = dp[k][i]+1;
									change = true;
									break;
								}else{
									break;
								}
							}
						}else{
							rep(l,n)if( hasi[next][i+j-l]!=2 || i+j-l==-1 ){
								if( dp[next][i+j-l] > dp[k][i]+1 ){
									dp[next][i+j-l] = dp[k][i]+1;
									change = true;
									break;
								}else{
									break;
								}
							}
						}
					}
				}
#if DEB
				
				rep(k,2){
					rep(j,n)printf("%2d ",dp[k][j]==INT_MAX?-1:dp[k][j]);
					puts("");
				}
				puts("");
				
#endif			
			}
			if( !change )break;
		}
		int ans = min(dp[0][n-1], dp[1][n-1]);
		if( ans==INT_MAX ){
			puts("NA");
		}else{
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
#define INF (1e18)+1
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i; 
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}

int arr[200001];

int32_t main() {
 
  	int N,K;
  	
  	cin >> N >> K;
  	
  	for(int i=0; i<N; i++){
  	 
  		cin >> arr[i];  	
  		
	}
	
	sort(arr,arr+N);
	
	int l = -INF , r = INF;
	
	while(l+1 < r){
		
		int x = (l+r)/2;
		int cnt = 0;
		for(int i=0; i<N; i++){
			
			if(arr[i] < 0){
				
				int left = i;
				int right =  N;
				
				while(left+1 < right){
					
					int m = (left+right)/2;
					
					if(arr[m] * arr[i]  <= x ){
						right = m;
					}
					else{
						left = m;
					}
				}
				cnt += N - right;
			}
			else{
				
				int left = i;
				int right = N;
				
				while(left+1 < right){
					
					int m = (left+right)/2;
					
					if(arr[m] * arr[i] <= x)
						left = m;
					else
						right =m;
					
				}
				
				cnt+= left-i;
				
				
			}
			
		//	if(arr[i] * arr[i] < x){
		//		cnt--;
		//	}
			
			
		}
		
		//cnt /= 2;
		
		if(cnt < K){
			l = x;
		}
		else{
			r = x;
		}
		
	}
	
	
	cout << r << endl;
	
	
 
}

Measured memory_bytes: 4720
N = int(input())
x = [0]*(N+1)
def fibo(n):
    if n ==0 or n==1:
        return 1
    else:
        if x[n] != 0:
            return x[n]
        else:
            x[n] = fibo(n-1)+fibo(n-2)
            return x[n]
print(fibo(N))


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

using namespace std;

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

int main()
{
	int n, count = 0, flag = 0;
    cin>> n;
    int h[n];
    fo(i, n)
      cin>>h[i];
    int a = h[0];
  	fo(i, n)
    {
        fo(j, i+1)
        {
	     	if(h[j] <= h[i] && h[i] >= a)
          		flag = 1;
          	else
          	{
          	    flag = 0;
          	    break;
          	}
        }
        if(flag)
            count++;
    }
  	cout<< count;
 	return 0;
}

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

using namespace std;
typedef long long ll;

string solve(int a, int b, int c, int d) {
  return abs(a-c) <=d || (abs(a - b) <= d && abs(b -c) <= d) ? "Yes" : "No";
}

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << solve(a, b, c, d);
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, s.size()){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3916
#include<iostream>
//#include<string>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

int main(void) {
	using namespace std;
	long long int K, A, B;
	long long int a;
	long long int res = 1;
	cin >> K >> A >> B;
	if (B - A <= 2) {
		res += K;
	}
	else {
		K -= A - 1;
		res += A - 1;
		a = K / 2;
		res += (B - A)*a;
		if (K%2 == 1) {
			res += 1;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int k = sc.nextInt();

		for (int i = 0; i < n; i++) {
			if (s[i] != s[k - 1]) {
				s[i] = '*';
			}
		}
		
		pr.println(s);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21716
use std::cmp;

fn main(){
  let inf: u32 = 1000000000;
  let mn: Vec<usize> = read_vec();
  let m = mn[0];
  let n = mn[1];

  let mut pv: Vec<u32> = Vec::new();

  for _ in 0 .. m {
    pv.push(read());
  }

  pv.push(inf);
  pv.sort_by(|a, b| b.cmp(a));
  pv[0] = 0;

  for i in 1 .. pv.len() {
    pv[i] += pv[i-1];
  }

  let mut dp: Vec<u32> = vec![inf; m + 1];
  dp[0] = 0;

  for _ in 0 .. n {
    let ce: Vec<usize> = read_vec();
    let c = ce[0];
    let e = ce[1] as u32;

    let mut ndp: Vec<u32> = vec![0; m + 1];

    for i in 1 .. m + 1 {
      let mn = if i >= c { dp[i - c] } else { dp[0] };
      ndp[i] = cmp::min(dp[i], mn + e);
    }
    
    dp = ndp;
  }

  let ans: u32 = (0 .. m + 1).map(|i| if pv[i] >= dp[i] { pv[i] - dp[i]} else { 0 }).max().unwrap();
  
  println!("{}", ans);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



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

using namespace std;

main() {
    //freopen("input.txt", "r", stdin):
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

s = ins()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")

Measured memory_bytes: 8984
#include<stdio.h>
#define W 0
#define G 1
#define B 2
  
int main(){
  int i,j,n;
  int A[101][101],wei[101],col[101];
  int ver,min_wei,sum_wei=0;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    col[i] = W;
    wei[i] = 2001;
    for(j=1;j<=n;j++) scanf("%d",&A[i][j]);
  }

  wei[1] = 0;
  col[1] = G;
  
  while(1){
    ver = -1;
    min_wei = 2001;
    
    for(i=1;i<=n;i++){
      if(col[i] == G && wei[i] < min_wei){
	min_wei = wei[i];
	ver = i;
      }
    }

    if(ver == -1) break;

    col[ver] = B;
    sum_wei += wei[ver];

    for(i=1;i<=n;i++){
      if(col[i] != B && A[ver][i] != -1){
	col[i] = G;
	if(wei[i] > A[ver][i]) wei[i] = A[ver][i];
      }
    }
  }

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

  return 0;
}



Measured memory_bytes: 2004
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split())
    P = list(map(int, input().split()))
    uf = UF_tree(N + 10)
    for _ in range(M):
        x, y = map(int, input().split())
        uf.unite(x, y)

    ans = sum(uf.isSame(i, p) for i, p in enumerate(P, start=1))
    print(ans)

Measured memory_bytes: 12384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Yamanote Line
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int a = parseInt(st.nextToken());
			int b = parseInt(st.nextToken());
			int c = parseInt(st.nextToken());

			int arriveAt = 0;
			int overSleep;
			List<Integer> overSleeps = new ArrayList<Integer>();

			for (int i = 0; ; i++) {
				arriveAt = 60 * i + c;
				overSleep = arriveAt % (a + b);
				if (overSleep <= a) {
					break;
				} else {
					if (overSleeps.contains(overSleep)) {
						arriveAt = -1;
						break;
					} else {
						overSleeps.add(overSleep);
					}
				}
			}
			System.out.println(arriveAt);
		}
	} //end while
} //end main

Measured memory_bytes: 24432
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

const double PI = 3.141592653589793238462643383279;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(13);
	long long N; cin >> N;
	int L; cin >> L;
	vector<int> T(N); rep(i, 0, N) {
		cin >> T[i];
	}
	double ansx = 0, ansy = 0;
	long long c = 0;
	rep(i, 0, N)rep(j, i + 1, N) {
		double x = PI * (T[i] + T[j]) / L;
		ansx += std::cos(x) * (N - (j - i - 1) - 2);
		ansy += std::sin(x) * (N - (j - i - 1) - 2);
		x += PI;
		ansx += std::cos(x) * (j - i - 1);
		ansy += std::sin(x) * (j - i - 1);
	}
	ansx /= N * (N - 1) * (N - 2) / 3 / 2;
	ansy /= N * (N - 1) * (N - 2) / 3 / 2;
	cout << ansx << " " << ansy << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    long long N;
    
    // 入力
    cin >> N;
    
    if (N==1) {
        cout << 0 << endl;
        return 0;
    }
    
    long long result = 0;
    
    for (int i=2;i<=1000000;i++) {
        if (N==1) {
            break;
        }
        
        int count = 0;
        while (1) {
            if (N%i==0) {
                N = N/i;
                count += 1;
            }
            else {
                break;
            }
        }
//        cout << count << endl;
        
        if (count != 0) {
//            cout << i << " " << count << endl;
        }
        
        int num = 1;
        while (count>=num) {
            count -= num;
            num += 1;
            result += 1;
        }
    }
    
    if (N > 1000000) {
        result += 1;
    }
    
    cout << result << endl;

    
    return 0;
}

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

def find(n):
  result = []
  for i in range(1, n+1):
    count = 0
    while i // 2 >= 1:
      if i % 2 == 0:
        count += 1
      
      i = i // 2
    
    result.append(count)
  return result.index(max(result)) + 1

print(find(n))


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

int main() {
  int H,W;
  cin >> H >> W;
  
  for(int i = 0; i < H + 2; i++){
    vector<char> vec(W + 2);
    
    for(int j = 0; j < W + 2; j++){
      
      if(i == 0 || i == H + 1 || j == 0 ||  j== W + 1){
        vec.at(j) = '#';
      } else {
        cin >> vec.at(j);
      }
      
      cout << vec.at(j);
    }
    
    cout << endl;
  } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  rep(i,0,365){
    Out((i+998244353+mod)%26+1);
  }
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
//static const ll mod = 1e9;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll>x(n);
	ll dis1,dis2;
	ll minv = INF;
	bool start=false;//0が含まれるか含まれないか
	repp(i, 0, n) {
		cin >> x[i];
		if (x[i] == 0)start = true;
	}
	k -= start;//0が含まれていれば１つ付けなければいけないロウソクが減る
	if(!start)x.push_back(0);//0が含まれていなければ0のロウソクを作る(付けなければいけないロウソクの数は変わらない)
	sort(x.begin(), x.end());
	int z;
	repp(i, 0, x.size())if (x[i] == 0)z = i;//0の座標
	repp(i, 0, k+1) {
		if (i + z >= x.size() || z - k + i < 0)continue;//オーバーフローしていればそのルートは存在しない
		dis1 = x[i + z] + 2*abs(x[z - k + i]);
		dis2 = 2 * x[i + z] + abs(x[z - k + i]);//それぞれの座標について進むか引き返すかで全探索(片方決まればもう片方は自動で決まる)
		minv = min({ dis1,dis2,minv });
	}
	cout << minv << endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  string T = S;
  reverse(S.begin(), S.end());
  if (S != T) return cout << "No" << "\n", 0;
  string s = T.substr(0, N / 2);
  string t = s;
  reverse(s.begin(), s.end());
  if (s != t) return cout << "No" << "\n", 0;
  string u = T.substr(N / 2 + 1);
  string v = u;
  reverse(s.begin(), s.end());
  if (u != v) return cout << "No" << "\n", 0;
  cout << "Yes" << "\n";
}

Measured memory_bytes: 256
lis = list(map(int, input().split()))
n = lis[0]
k = lis[1]
count = 0

for b in range(k+1, n+1):
	quo = int(n / b)
	rem = n % b
	if rem == 0:
		count += quo * (b - k)
	else:
		count += quo * (b - k)
		if (rem >= k) and (k != 0):
			count += rem - k + 1
		elif (rem >= k) and (k == 0):
			count += rem - k
print(count)

Measured memory_bytes: 3064
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    d=ceil(n/1000);

    cout<<(d*1000)-n<<endl;
}


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

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

fn main() {
    let n:u64 = read();
    let mut ans = 1;
    for i in 0..n {
        ans = ans * (i+1) %(10u64.pow(9)+7);
    }
    println!("{}", ans);
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

int main(){
  int n,d,a; cin >> n >> d >> a;
  vector<P<int,int>> v(n);
  for(int i = 0; i < n; ++i)cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  vector<int> x(n),h(n);
  for(int i = 0; i < n; ++i)tie(x[i],h[i]) = v[i];
  ll total = 0;
  ll ans = 0;
  vector<ll> pos(n,n);
  {
    int l=0,r=0;
    while(l < n){
      while(r < n && x[r] - x[l] <= 2*d) r++;
      pos[l] = min<ll>(pos[l],r);
      l++;
    }
  }
  vector<ll> hp(n+1);
  for(int i = 0; i < n; ++i){
    total -= hp[i];
    h[i] -= total;
    ChangeMax(h[i],0);
    ll c = (h[i]+a-1)/a;
    ans += c;
    total += c*a;
    hp[pos[i]] += c*a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528