akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <string>
using namespace std;
#include<chrono>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
// ll ans=0;

void iluzn() {
string s;
cin>>s;
ll count=0;
int i;
fo(i,s.length()){
  count+=(int)s[i]-48;
}
if(count%9==0)  cout<<"Yes";
else
  cout<<"No";
}
 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
     {
      iluzn();
    
      }
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10812
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var dx = ps.Select((p, i) => new { p, i }).ToLookup(_ => _.p[0]);
		var dy = ps.Select((p, i) => new { p, i }).ToLookup(_ => _.p[1]);

		var uf = new UF(n);
		foreach (var g in dx)
		{
			if (g.Count() == 1) continue;
			var p0 = g.First();
			foreach (var p in g) uf.Unite(p0.i, p.i);
		}
		foreach (var g in dy)
		{
			if (g.Count() == 1) continue;
			var p0 = g.First();
			foreach (var p in g) uf.Unite(p0.i, p.i);
		}

		var r = 0L;
		foreach (var g in uf.ToGroups())
		{
			if (g.Count() == dx[ps[g.First()][0]].Count()) continue;
			r += (long)g.Select(i => ps[i][0]).Distinct().Count() * g.Select(i => ps[i][1]).Distinct().Count() - g.Count();
		}
		Console.WriteLine(r);
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
	public int[][] ToGroups() => Enumerable.Range(0, p.Length).GroupBy(GetRoot).Select(g => g.ToArray()).ToArray();
}


Measured memory_bytes: 51840
num = int(input())
order = list(map(int, input().split()))
content = list(map(int, input().split()))
add_content = list(map(int, input().split()))
base = sum(content)
add = 0
for i in range(len(order) - 1):
    if order[i] + 1 == order[i+1]:
        add += add_content[order[i] - 1]
print(add + base)


Measured memory_bytes: 3060
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, M, a[505];

struct S {
    int water, width;
    S () {}
    S(int water, int width) : water(water), width(width) {}
};

double dp[505][505];

int main() {
    cin >> N >> M;
    for (int j = 1; j <= N; ++j) { cin >> a[j]; }

    double b[505]; b[0] = 0;
    for (int j = 1; j <= N; ++j) b[j] = b[j-1] + a[j];

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) dp[i][j] = -1;
    }
    dp[0][0] = 0;

    for (int r = 1; r <= N; ++r) {
        for (int m = M; m >= 1; --m) {
            for (int i = 0; i < r; ++i) {
                if (dp[i][m-1] >= 0) {
                    dp[r][m] = max(dp[r][m], dp[i][m-1] + (double) (b[r] - b[i]) / (r - i));
                }
            }
        }
    }

    cout << fixed << setprecision(10) << dp[N][M] << endl;

    return 0;
}



Measured memory_bytes: 5264
import java.io.*;
import java.io.ObjectInputStream.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	//final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		slove(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void slove(String[] args) throws Exception{
		int n=nextInt();
		int a=nextInt();
		int b=nextInt();

		long ans = modPow(2,n,MOD) -1;

		long nca = nCr_withMod(n,a,MOD);
		long ncb = nCr_withMod(n,b,MOD);

		ans=(ans-nca-ncb)+2*MOD;
		ans%=MOD;

		pw.println(ans);

	}

	/* pow(a,n) % modの繰り返し2乗法による計算 */
	public static long modPow(long a ,long n,long mod) {
		if(n==0) {
			return 1;
		}
		if(n==1) {
			return a%mod;
		}
		if(n%2==1) {
			return (a * modPow(a,n-1,mod))%mod;
		}
		long t=modPow(a,n/2,mod);
		return (t*t)%mod;

	}

    static long nPr_withMod(long n, long r, long MOD) {
        long res = 1;
        for (long i = (n - r + 1); i <= n; i++) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static long nCr_withMod(long n, long r, long MOD) {
        long r_factorial = nPr_withMod(r, r, MOD);
        long first = nPr_withMod(n, r, MOD);
        long second = modPow(r_factorial, MOD-2, MOD);
        return  (first * second) % MOD;
    }

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}



Measured memory_bytes: 21460
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Twirling Robot
public class Main{

	static int[][][] dist;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] move = {{-1,0},{0,1},{1,0},{0,-1}};
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h)==0)break;
			int[][] m = new int[h][w];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)m[i][j]=sc.nextInt();
			int[] cost = new int[4];
			for(int i=0;i<4;i++)cost[i]=sc.nextInt();
			dist = new int[h][w][4];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<4;k++)dist[i][j][k]=Integer.MAX_VALUE;
			dist[0][0][1] = 0;
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(h*w, new Comparator<int[]>(){
				public int compare(int[] o1, int[] o2) {
					return dist[o1[0]][o1[1]][o1[2]] - dist[o2[0]][o2[1]][o2[2]];
				}
			});
			q.add(new int[]{0, 0, 1});
			int min = Integer.MAX_VALUE;
			while(!q.isEmpty()){
				int[] a = q.poll();
				int i = a[0];
				int j = a[1];
				int d = a[2];
				if(i==h-1&&j==w-1){
					min = Math.min(min, dist[i][j][d]);
				}
				for(int k=0;k<4;k++){
					int nd = (d+k)%4;
					int ni = i + move[nd][0];
					int nj = j + move[nd][1];
					if(0<=ni&&ni<h&&0<=nj&&nj<w){
						int c = dist[i][j][d] + (m[i][j]==k?0:cost[k]);
						if(c < dist[ni][nj][nd]){
							dist[ni][nj][nd] = c;
							q.add(new int[]{ni, nj, nd});
						}
					}
				}
			}
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (!(1 <= a && a <= 9)) {
            System.out.println(-1);
            return;
        }
        if (!(1 <= b && b <= 9)) {
            System.out.println(-1);
            return;
        }
        int ans = a * b;
        System.out.println(ans);
    }
}

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 22996
program main;
var
  N, M, i, total, count : integer;
  A : array[1..100] of integer;
begin
  readln(N, M);
  for i := 1 to N do
    read(A[i]);

  // calculate total
  total := 0;
  for i := 1 to N do
    total := total + A[i];

  // count number of enough votes
  count := 0;
  for i := 1 to N do
    if A[i] >= total / (4 * M) then
      count := count + 1;

  if count >= M then
    writeln('Yes')
  else
    writeln('No');
end.

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

int main(){
  long long int N;
  cin >> N;
  long long int m = 0;
  long long int a = 0;
  long long int r = 0;
  long long int c = 0;
  long long int h = 0;
  long long int x;
  string s;
  for(long long int i = 0; i < N; i++){
    cin >> s;
    if(s[0] == 'M'){
      m++;
    }
    else if(s[0] == 'A'){
      a++;
    }
    else if(s[0] == 'R'){
      r++;
    }
    else if(s[0] == 'C'){
      c++;
    }
    else if(s[0] == 'H'){
      h++;
    }
  }
  x = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
  cout << x << endl;
}
  


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

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int main() {
#ifdef LOCAL
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    set <int> s;
    int n;
    scanf("%d", &n);
    forn(i, n) {
        int x;
        scanf("%d", &x);
        s.insert(x);
    }
    printf("%d", (int)s.size());
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int c[][] = new int[a][2];
		
		for (int i=0; i<a; i++){
			c[i][0] = sc.nextInt();
			c[i][1] = sc.nextInt();
		}
		
		boolean flg = false;
		int cost = 0;
		for (int i=0; i<a; i++){
			
			if (c[i][1] <= b){
				if ((cost == 0) || (c[i][0] <= cost)){
					cost = c[i][0];
					flg = true;
				}
			}
		}
		
		if (flg){
			System.out.println(cost);
		}
		else {
			System.out.println("TLE");
		}
		return;
		
		
	}
	
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
vector<long long> a,b,c,qa,qb,qc;
long long ans=0,qn=0;
void solve(int x,int y,int z)
{
	vector<long long> qdh,p,q,r;
	long long pos,i,pn=1;
	qdh.push_back(0);
	for(i=0;i<qn-x-y-z;i++)
		pn=(pn*3)%MOD;
	if(x)
		p=qa;
	else
		p=a;
	if(y)
		q=qb;
	else
		q=b;
	if(z)
		r=qc;
	else
		r=c;
	for(i=0;i<q.size();i++)
	{
		pos=upper_bound(r.begin(),r.end(),q[i])-r.begin();
		qdh.push_back(qdh[qdh.size()-1]+r.size()-pos);
	}
	for(i=0;i<p.size();i++)
	{
		pos=upper_bound(q.begin(),q.end(),p[i])-q.begin();
		ans=(ans+(qdh[qdh.size()-1]-qdh[pos])*pn)%MOD;
	}
}
int main(){
	string s;
	long long i,j,k,pos;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='A')
		{
			a.push_back(i);
		}
		else if(s[i]=='B')
		{
			b.push_back(i);
		}
		else if(s[i]=='C')
		{
			c.push_back(i);
		}
		else
		{
			qa.push_back(i);
			qb.push_back(i);
			qc.push_back(i);
			qn++;
		}
	}
	for(i=0;i<=1;i++)
	{
		for(j=0;j<=1;j++)
		{
			for(k=0;k<=1;k++)
			{
				solve(i,j,k);
			}
		}
	}
	cout<<ans<<endl;
	solve(0,1,1);
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double r; cin >> r;
    double pi = acos(-1);
    cout << setprecision(12) << 2 * pi * r << "\n";

    return 0;
}

Measured memory_bytes: 3792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdlib.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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 INF (ll) 1000000007

long long modinv(long long a, long long p) {
    long long b = p, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= p;
    if (u < 0) u += p;
    return u;
}

long long mul_modp(long long a, long long b, long long p){
    return (a * b) % p;
}

ll nCr_modp(ll n, ll r, ll p){
    ll bunbo = 1;
    ll bunsi = 1;
    REP(i,r){
        bunsi = mul_modp(bunsi, n-i, INF);
        bunbo = mul_modp(bunbo, r-i, INF); 
    }

    return bunsi * modinv(bunbo, INF) % INF;
}

int main() {
    ll X, Y;
    cin >> X >> Y;

    if((2*X-Y)%3 != 0 || (2*Y-X)%3 != 0 || (2*X-Y)<0 || (2*Y-X)<0){
        cout << 0 << endl;
        return 0;
    }

    ll x = (2*X-Y) / 3;
    ll y = (2*Y-X) / 3;

    cout << nCr_modp(x+y, y, INF) << endl;

    return 0;
}

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

int n;
int main(void){
    // Your code here!
    cin >> n;
    int H[n];
    for(int i = 0; i < n; i++){
        cin >> H[i];
    }
    
    bool flag = true;
    
    int cnt = 1;
    for(int i = 1; i < n; i++){
        flag = true;
        for(int j = 0; j < i; j++){
            if(H[j] > H[i]) {
                flag = false;
                break;
            }
        }
        
        if(flag) {
            cnt += 1;
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
ll dp[maxn];
ll n, W;
ll v[maxn];
ll w[maxn];
inline ll max(ll x, ll y) {
	return x > y ? x : y;
}
inline ll min(ll x, ll y) {
	return x < y ? x : y;
}
int main() {
	memset(dp, 0x3f, sizeof(dp));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> W;
	for (int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];
	ll ans = 0ll;
	dp[0] = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1e5; j >= v[i]; --j){
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
			if (dp[j] <= W) ans = max(ans, (ll)(j));
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 10624
import numpy as np

N = int(input())
S = input()
d = {}
for i in range(N):
  c = S[i]
  if c not in d.keys():
    d[c] = [i]
  else:
    #if len(d[c])>=3:
    #  continue
    #else:
    d[c].append(i)
#print(d)

ans=0
for i in range(1000):
  code = str(i)
  while len(code)<3:
    code = "0" + code
  if code[0] not in d.keys() or code[1] not in d.keys() or code[2] not in d.keys():
    continue
  first = np.array(d[code[0]])
  current = first[0]
  
  second = np.array(d[code[1]])
  if len(second[second>current])==0:
    continue
  current = second[second>current][0]
  
  third = np.array(d[code[2]])
  if len(third[third>current])==0:
    continue
  ans+=1
  
print(ans)
  
  
    
    
  
  
  
    
  

Measured memory_bytes: 15728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
const int MAX_N = 100;
const int MAX_TIME = 25;
struct edge
{
    int to, cost, time, line;
};
typedef pair<pair<int, int>, int> P;
typedef pair<int, int> PAIR;
int N, M, H, K;
int pass_cost[1000];
int d[MAX_N][MAX_TIME];
void dijkstra(int s, int iter, vector<vector<edge>> &G)
{
    priority_queue<P, vector<P>, greater<P>> que;
    rep(i, N)
    {
        rep(j, H + 1) d[i][j] = INF;
    }
    d[s][0] = 0;
    que.push(P(PAIR(0, 0), s));
    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        int v = p.second;
        int t = p.first.second;
        if (d[v][t] < p.first.first)
            continue;
        for (int i = 0; i < G[v].size(); i++)
        {
            edge e = G[v][i];
            if (t + e.time > H)
                continue;
            int tmp_cost = (iter & (1 << e.line) ? 0 : e.cost);
            if (d[e.to][t + e.time] > d[v][t] + tmp_cost)
            {
                d[e.to][t + e.time] = d[v][t] + tmp_cost;
                que.push(P(PAIR(d[e.to][t + e.time], t + e.time), e.to));
            }
        }
    }
}
int main()
{
    vector<int> ans_list;
    while (1)
    {
        cin >> N >> M >> H >> K;
        if (N == 0)
            break;

        vector<vector<edge>> G(N);
        rep(i, M)
        {
            int a, b, c, h, r;
            cin >> a >> b >> c >> h >> r;
            a--;
            b--;
            r--;
            G[a].push_back({b, c, h, r});
            G[b].push_back({a, c, h, r});
        }
        int S, T;
        cin >> S >> T;
        S--;
        T--;
        int p;
        cin >> p;
        fill(pass_cost, pass_cost + (1 << K), INF);
        pass_cost[0] = 0;
        rep(i, p)
        {
            int l, d;
            cin >> l >> d;
            int pass = 0;
            rep(j, l)
            {
                int k;
                cin >> k;
                k--;
                pass |= (1 << k);
            }
            rep(j, (1 << K))
                pass_cost[j | pass] = min(pass_cost[j | pass], pass_cost[j] + d);
        }
        int ans = INF;
        rep(i, (1 << K))
        {
            dijkstra(S, i, G);
            rep(j, H + 1)
            {
                ans = min(ans, d[T][j] + pass_cost[i]);
            }
        }
        if (ans == INF)
            ans = -1;
        ans_list.push_back(ans);
    }
    rep(i, ans_list.size()) cout << ans_list[i] << endl;
    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R, G, B, N, r, g, b, rg, ans = 0;
  cin >> R >> G >> B >> N;
  
  for (int i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      r = i, g = j, rg = r*R+g*G, b = (N - rg)/B;
      if (b >= 0 && b <= 3000 && (N - rg)%B == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
dp = [[0 for j in range(2)] for i in range(n+1)]
inf = 10**9+7
dp[1][0], dp[1][1] = a[0], -a[0]
for i in range(1, n-1):
    dp[i+1][0] = max(dp[i][0]+a[i], dp[i][1]-a[i])
    dp[i+1][1] = max(dp[i][0]-a[i], dp[i][1]+a[i])
ans = max(dp[n-1][0]+a[-1], dp[n-1][1]-a[-1])
print(ans)

Measured memory_bytes: 72864
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
typedef long long int ll;

int main(){
    long long int n, x, i;
    cin >> n;
    for(i = 1;i <= sqrt(n);i++){
        if(n % i == 0){
            x = i + n / i - 2;
        }
    }
    cout << x << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,a[123],b;
int s;
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    int S=s%4*m;
    s/=4*m;
    if(S!=0)s++;
    for(int i=0;i<n;i++){
        if(a[i]>=s)b++;
    }
    if(b>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def digit_count(n):
  str_n = str(n)
  
  return len(str_n)

N = int(input())
divisor = make_divisors(N)

if len(divisor) % 2 == 1:
  num = divisor[int(len(divisor)/2)]
  ans = digit_count(num)
  print(ans)
else:
  num1 = divisor[int(len(divisor)/2) -1]
  num2 = divisor[int(len(divisor)/2)]  
  ans1 = digit_count(num1)
  ans2 = digit_count(num2)
  
  if ans1 > ans2:
    print(ans1)
  elif ans2 > ans1:
    print(ans2)
  else:
    print(ans1)
  





Measured memory_bytes: 3064
import Control.Monad
import Data.Function (on)
import Data.List

main = do
  [d, g] <- map read . words <$> getLine
  pcs <- replicateM d $ map (read :: String -> Int) . words <$> getLine
  print $ solve g d $ reverse pcs

solve :: Int -> Int -> [[Int]] -> Int
solve _ _ [] = 1001
solve g i ([p,c]:pcs)
  | g <= 0         = 0
  | g <= p*i*100   = min ((g + (i*100) - 1) `div` (i*100)) (solve g (i-1) pcs)
  | g <= p*i*100+c = min p (solve g (i-1) pcs)
  | otherwise      = min (p + (solve (g-p*i*100-c) (i-1) pcs)) (solve g (i-1) pcs)


Measured memory_bytes: 636
from heapq import*
i=input
for _ in'_'*int(i()):
 n,s,x,*y=int(i()),0,[]
 for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
 for x in x,y:
  x.sort();n,*h=len(x),
  while n:
   while[[n,0,0]]<x[-1:]:k,l,r=x.pop();heappush(h,(r-l,l,r))
   if h:s+=heappop(h)[1]
   n-=1
  for*_,r in x+h:s+=r
 print(s)

Measured memory_bytes: 47556
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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 dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n; cin >> n;
    int ans = 0;
    vector<int> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    sort(ALL(lis));
    for(int i = n-1; i >= 2; i--){
        for(int l = i-1; l >= 1; l--){
            int a = lis[i], b = lis[l];
            int k = a - b + 1;
            auto it = lower_bound(ALL(lis), k);
            int x = it - lis.begin();
            ans += max(l - x, 0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long LL;
using namespace std;
#define max_n 100005
int a[max_n];
int main()
{
	int n,k=1,ans,i;
	bool sign,res=false;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	if(n==1)
	{
		printf("1\n");
		return 0;
	}
	ans=a[0];
	for(i=1;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(!res)
		{
			if(a[i]>ans)
			{
				sign=true;
				res=true;
				ans=a[i];
			}
			else if(a[i]<ans)
			{
				sign=false;
				res=true;
				ans=a[i];
			}
		}
		else
		{
			if(sign)
			{
				if(a[i]>=ans)
					ans=a[i];
				else
				{
					k++;
					ans=a[i];
					res=false;
				}
			}
			else
			{
				if(a[i]<=ans)
					ans=a[i];
				else
				{
					k++;
					ans=a[i];
					res=false;
				}
			}
		}
	}
	printf("%d\n",k);
	return 0;
}


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

using namespace std;

int main() {
	cin.sync_with_stdio(false);
	int n;
	cin >> n;
	vector<string> words(n);
	vector<string> uniwords(n);
	int minwords = 50;
	int minnumber;
	for (int i = 0;i < n;i++) {
		cin >> words[i];
		uniwords[i] = words[i];
		sort(uniwords[i].begin(), uniwords[i].end());
		uniwords[i].erase(unique(uniwords[i].begin(), uniwords[i].end()), uniwords[i].end());
		if (minwords > uniwords[i].size()) {
			minwords = uniwords[i].size();
			minnumber = i;
		}
	}
	vector<char>s;
	int counter1 = 0;
	int counter2 = 50;
	for (int k = 0;k < minwords;k++) {
		counter2 = 50;
		for (int i = 0;i < n;i++) {
			counter1 = 0;
			for (int j = 0;j < words[i].size();j++) {
				if (uniwords[minnumber][k] == words[i][j]) {
					counter1++;
				}
			}
			counter2 = min(counter1, counter2);
		}
		for (int i = 0;i < counter2;i++) {
			s.push_back(uniwords[minnumber][k]);
		}
	}
	for (int i = 0;i < s.size();i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
if t in s:
    print(0)
else:
    ans = len(t)
    for i in range(len(s) - len(t) + 1):
        cnt = 0
        k = i
        l = 0
        while l < len(t) and k < len(s):
            if s[k] != t[l]:
                cnt += 1 
            k += 1
            l += 1    
        ans = min(ans, cnt)
    print(ans)  


Measured memory_bytes: 8928
#include <stdio.h>
int main(void){
  int k, a, b;
  scanf("%d", &k);
  scanf("%d %d", &a, &b);
  int n;
  for(n = a; n <= b; n++){
    if(n % k == 0){
        printf("OK\n");
        return 0;
    }
  }
  printf("NG\n");
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<int> v2(n);
    rep(i,n) v2[i] = v[i];
    sort(ALL(v2));

    int cnt = 0;
    rep(i,n) {
        if(v[i]==v2[i]) ++cnt;
    }

    int ans = -1;

    if(cnt==n) ans = 0;

    int q; cin >> q;

    rep(i,q) {
        int a, b; cin >> a >> b;
        --a;--b;
        if(ans==-1) {
            if(v[a]==v2[a]) --cnt;
            if(v[b]==v2[b]) --cnt;
            swap(v[a],v[b]);
            if(v[a]==v2[a]) ++cnt;
            if(v[b]==v2[b]) ++cnt;
            if(cnt==n) ans = i+1;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5212
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	sieve := make([]int, n+1)
	sieve[1] = 1
	for i := 2; i <= n; i++ {
		if sieve[i] != 0 {
			continue
		}
		for j := i; j <= n; j += i {
			sieve[j] = i
		}
	}
	sum := 0
	for i := 1; i <= n; i++ {
		x := i
		y := 1
		f := 0
		g := 0
		for x > 1 {
			if f != sieve[x] {
				y *= g + 1
				f = sieve[x]
				g = 0
			}
			x /= sieve[x]
			g++
		}
		y *= g + 1
		sum += y * i
	}
	con.Println(sum)
	return nil
}


Measured memory_bytes: 82572
#include<stdio.h>
#define N 10000
#define MAX 5000000

typedef struct node{
  int v;
  int c;
}node;
int isEmpty(void);
void enqueue(int);
int dequeue(void);
void dijkstra(int);

node A[N][1000];
int n;
int c[N],d[N];
int Q[N];
int head=0,tail=0;

int main(){
  int i,j;
  int u,v,k,c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j].c=MAX;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][j].v=v;
      A[u][j].c=c;
    }
  }
  dijkstra(0); 
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}

int isEmpty(){
  if(head==tail) return 1;
  return 0;
}

void enqueue(int n){
  
  Q[tail]=n;
  if(tail+1==N){
    tail=0;
  }
  else{
    tail++;
  }
}

int dequeue(){

  int n;

  n=Q[head];
  if(head+1==N){
    head=0;
  }
  else{
    head++;
  }
  return n;
}

void dijkstra(int s){
  int i;
  int min;
  int u,v;
  //初期化
  for(i=0;i<n;i++){
    d[i]=MAX;
    c[i]=0;
  }
  d[s]=0;
  //計算
  while(1){
    min=MAX;
    for(i=0;i<n;i++){
      if(c[i]!=2 && d[i]<min){
        min=d[i];
        u=i;
      }
    }
    if(min==MAX) break;
    c[u]=2;
    for(v=0;v<1000;v++){
      if(A[u][v].c>=0){
        if(c[A[u][v].v]!=2 && d[u]+A[u][v].c<d[A[u][v].v]){
          d[A[u][v].v]=d[u]+A[u][v].c;
        }
      }
    }
  }
}



Measured memory_bytes: 80104
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

int[] getTable() {
    bool[] era = new bool[100010];
    era[2 .. $] = true;
    for (int i = 0; i * i < era.length; i++)
    {
        if (!era[i]) continue;
        for (int j = i + i; j < era.length; j += i)
        {
            era[j] = false;
        }
    }
    int[] res = new int[100010];
    foreach (i; 0 .. era.length)
    {
        if (era[i] && era[(i + 1) / 2])
        {
            res[i] = 1;
        }
    }
    foreach (i; 1 .. res.length) {
        res[i] += res[i - 1];
    }
    return res;
}

void main()
{
    static auto imos = getTable;
    auto cin = new Scanner;
    int q;
    cin.scan(q);
    foreach (i; 0 .. q) {
        int l, r;
        cin.scan(l, r);
        writeln(imos[r] - imos[l - 1]);
    }
}


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

int main()
{
    int N;
    map<string,int> dic;

    cin>>N;
    for(int i=0;i<N;i++)
    {
        string str;
        cin>>str;
        dic[str] += 1;
    }

    int biggest = 0;
    for(auto itr = dic.begin();itr != dic.end();++itr)
    {
        int check = itr->second;
        if(biggest<check)
        {
            biggest = check;
        }
    }


    for(auto itr = dic.begin();itr != dic.end();++itr)
    {
        if(itr->second==biggest)
        {
            cout<<itr->first<<endl;
        }
    }


    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int l, r, d;
    cin >> l >> r >> d;
    
    int ans = 0;
    for (int i=l; i<=r; i++) {
        if (i%d==0) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n;
double coins[3005];

double memo[3005][3005];
bool check[3005][3005];

double dp(int pos, int heads){
    //cout << coins[pos] <<' ' << pos << endl;
    if(pos>=n){
        if(n-heads >= heads)
            return 0;
        else
            return 1;
    }

    if(check[pos][heads]) return memo[pos][heads];

    double op1 = (coins[pos]) * dp(pos+1,heads+1);
    double op2 = (1-coins[pos]) * dp(pos+1,heads);

    memo[pos][heads] = op1+op2;
    check[pos][heads] = true;

    return memo[pos][heads];
}

int main() {

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> coins[i];
    }

    cout << setprecision(10) << dp(0,0);

    return 0;
}

Measured memory_bytes: 79744
#include <stdio.h>

int main() {
    int a, b, ans;
    char op;
    
    while(scanf("%d %c %d", &a, &op, &b)) {
        if(op == '?') {
            break;
        }
        
        switch(op) {
            case '+':
                ans = a + b;
                break;
                
            case '-':
                ans = a - b;
                break;
            
            case '*':
                ans = a * b;
                break;
                
            case '/':
                ans = a / b;
                break;
        }
        
        printf("%d\n", ans);
    }
    
    return 0;
}


Measured memory_bytes: 2100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A, INF = 10**8):
    counts = [0 for i in range(N)]
    a = 1
    loop_init = -1
    loop_count = -1
    while True:
        counts[a-1] += 1
        if counts[a-1] == 2 and loop_count < 0:
            loop_count = 0
        elif counts[a-1] == 3:
            loop_count += 1
            break
        elif loop_count >= 0:
            loop_count += 1
        a = A[a-1]
    loop_init = sum([c == 1 for c in counts])

    a = 1
    if loop_init > K:
        for i in range(K):
            a = A[a-1]
    else:
        loop_k = (K - loop_init) % loop_count
        for i in range(loop_init + loop_k):
            a = A[a-1]
    return a


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 31172
#include <stdio.h>
#include <string.h>
int main () {
    char s[205];
    char c[205];
    int m,h;
    while(1){
        scanf("%s",s);
        if(!strcmp(s,"-")) return 0;
        scanf("%d",&m);
        for(int i=0;i<m;i++) {
            scanf("%d",&h);
            for(int j=0;j<h;j++) c[j]=s[j];
            for(int k=h,j=0;k<strlen(s);j++,k++) s[j]=s[k];
            for(int j=strlen(s)-h,k=0;j<strlen(s);k++,j++) s[j]=c[k];
        }
        printf("%s\n",s);
    }
}



Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}
ll n; 

int main()
{
    cin >> n;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<pair<ll, int>> fs;
    for(ll i = 2; i*i <= n; i++) {
        int x = 0;
        while (n % i == 0) {
            n /= i;
            x++;
        }
        fs.emplace_back(i,x);
    }
    if (n != 1) fs.emplace_back(n,1);

    int ans = 0;
    for (auto p : fs) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            b++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19304
import queue
INF=10**8
R=10**9+7
h,w=map(int,input().split())
maze=[input() for _ in range(h)]
d=[[0 for i in range(h)] for _ in range(w)]
sx=0
sy=0
gx=w-1
gy=h-1
q=queue.Queue()
dx=[1,0]
dy=[0,1]
q.put((sx,sy))
d[sy][sx]=1
while not q.empty():
  x,y=q.get()
  if (x,y)==(gx,gy):break
  for i in range(2):
    nx=x+dx[i]
    ny=y+dy[i]
    if nx<w and ny<h:
      if maze[ny][nx]=='.':
        if d[nx][ny]==0:
          q.put((nx,ny))
          d[nx][ny]=d[x][y]
        else:d[nx][ny]+=d[x][y]
print(d[gx][gy]%R)

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

int main() {
  int N;
  cin >> N;
  vector <int> T(N);
  for ( int i = 0; i < N ; i++ ){
    cin >> T.at(i);
  }
  
  int M;
  cin >> M;
  vector <vector <int>> P(M, vector<int>(2));
  for ( int i = 0 ; i < M ; i++ ){
    for ( int  j = 0 ; j < 2 ; j++ ){
      cin >> P.at(i).at(j);
    }
  }
  
  int count;
  for (int i = 0 ; i < M ; i++ ){
    int w = T.at(P.at(i).at(0) - 1);
    T.at(P.at(i).at(0) - 1) = P.at(i).at(1);
    for ( int j = 0; j < N ; j++ ){
      count = count + T.at(j);
    }
    cout << count << endl;
    count = 0;
    T.at(P.at(i).at(0) - 1) = w;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1234567;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<vector<P>>ki(N);
    for(int i = 0; i < N-1; i++) {
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        ki[u].push_back({v,w});
        ki[v].push_back({u,w});
    }
    vector<int>cnt(N,INF);
    cnt[0] = 0;
    queue<P>que;
    que.push({0,0});
    while(!que.empty()) {
        P x = que.front();
        que.pop();
        for(int i = 0; i < ki[x.first].size(); i++) {
            if(cnt[ki[x.first][i].first] == INF) {
                cnt[ki[x.first][i].first] = x.second+ki[x.first][i].second;
                que.push({ki[x.first][i].first,cnt[ki[x.first][i].first]});
            }
        }
    }
    for(int i = 0; i < N; i++) {
        if(cnt[i]%2 == 0) {
            cout << 0 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }
}


Measured memory_bytes: 11364
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

long comb2(long n) {
    if (n < 2) return 0;
    return (long)n * (n-1) / 2;
}

int main() {
    string s;
    long cnt[26] = {0};
    cin >> s;
    for (auto c:s) cnt[c-'a']++;
    long len = s.size(), sum = comb2(len) + 1;
    for (auto n:cnt) sum -= comb2(n);
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
using namespace std;
typedef long long ll;
const int MAX = 100001;

int main(){
    ll x,xb,a,b;
    cin >> x;

    REP(ll,b,-100,130){
        xb=x+b*b*b*b*b;
        if(xb>=0){
            a=pow(xb,0.2);
            if(xb==a*a*a*a*a){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4064
using System;

namespace _20190629_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力値:r, D, x2000
            // すべてint
            var input = Console.ReadLine().Split(' ');
            var r = int.Parse(input[0]);
            var D = int.Parse(input[1]);
            var x2000 = int.Parse(input[2]);

            for (int i = 0; i < 10; i++)
            {
                int xWeight = r * x2000 - D;
                x2000 = xWeight;
                Console.WriteLine(xWeight);
            }
        }
    }
}

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

int main() {
  ll X, A = 1, B;
  bool tr = 0;
  cin >> X;
  while(1) {
    for(ll i = 0; i <= A; i++) {
      if(pow(A, 5) - pow(i, 5) == X) {
        B = i;
        tr = 1;
        break;
      }
      if(pow(A, 5) - pow(-i, 5) == X) {
        B = -i;
        tr = 1;
        break;
      }
    }
  if(tr) break;
  A += 1;
  }
  cout << A << " " << B << endl;
}

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

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int constexpr N = 100009;
int n, a[N], pref[N], suff[N];


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];

    pref[1] = a[1];
    for(int i = 2; i <= n; ++i) pref[i] = gcd(a[i], pref[i - 1]);
    suff[n] = a[n];
    for(int i = n - 1; i >= 1; --i) suff[i] = gcd(a[i], suff[i + 1]);

    int ans = max(suff[2], pref[n - 1]);
    for(int i = 2; i < n; ++i) ans = max(ans, gcd(pref[i - 1], suff[i + 1]));
    cout << ans << endl;
}


Measured memory_bytes: 2560
n = int(input())
s = input()

dp1 = [[0 for i in range(10)] for _ in range(n + 1)]
dp2 = [[0 for i in range(100)] for _ in range(n + 1)]
dp3 = [[0 for i in range(1000)] for _ in range(n + 1)]

for i in range(n):
    dp1[i + 1][int(s[i])] = 1
    for j in range(10):
        if dp1[i][j]:
            dp2[i + 1][j * 10 + int(s[i])] = 1
            dp1[i + 1][j] = 1
    for j in range(100):
        if dp2[i][j]:
            dp3[i + 1][j * 10 + int(s[i])] = 1
            dp2[i + 1][j] = 1
    for j in range(1000):
        if dp3[i][j]:
            dp3[i + 1][j] = 1

print(sum(dp3[n]))

Measured memory_bytes: 334472
/* AtCoder Beginner Contest abc137
 * Problem C
 * Au: SJoshua
 */
#include <map>
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	map <string, long long int> cnt;
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		sort(str.begin(), str.end());
		cnt[str]++;
	}
	for (auto e: cnt) {
		ans += (e.second - 1) * e.second / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136