akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define de(x) cout << #x << '=' << x << ", "
#define dd cout << '\n';
#define XinAi ios::sync_with_stdio(0), cin.tie(0);
#define rep(i,j,k) for (int i=j; i<=k; i++)
#define S second
#define F first
#define int long long
using namespace std;
typedef pair<int,int> pii;
const int N = 2e5+10;
/*
dp[i][j] = dp[i-1][j] + |x[i]-x[i-1]|
dp[i][x[i-1]] = min(dp[i][x[i-1]], min(dp[i-1][k] + |k-x[i]|, k=1~n))

owo = dp[i-1][k] + |k-x[i]|, k=1~n
k=1~x[i]: owo = dp[i-1][k] + x[i] - k;
k=x[i]~n: owo = dp[i-1][k] + k - x[i];

sta[j], dp[i][j]-j
stb[j], dp[i][j]+j

dp[b]=0
*/
int n, q, x[N], b;
struct ST
{
	int st[N<<2], lz[N<<2]; //lz: not cover to subnodes, st: merge subnode + lazy
	inline void init()
	{
		memset(st,0x3f,sizeof(st));
	}
	inline void setto (int u, int l, int r, int p, int v)
	{
		if (r<p || p<l) return;
		else if (l==p && p==r) st[u]=v;
		else
		{
			int m = (l+r)/2;
			setto(u<<1,l,m,p,v-lz[u]);
			setto(u<<1|1,m+1,r,p,v-lz[u]);
			st[u] = min(st[u<<1], st[u<<1|1])+lz[u];
		}
	}
	inline void add (int u, int l, int r, int ql, int qr, int v)
	{
		if (r<ql || qr<l) return;
		else if (ql<=l && r<=qr) st[u]+=v,lz[u]+=v;
		else
		{
			int m = (l+r)/2;
			add(u<<1,l,m,ql,qr,v);
			add(u<<1|1,m+1,r,ql,qr,v);
			st[u] = min(st[u<<1], st[u<<1|1])+lz[u];
		}
	}
	inline int query (int u, int l, int r, int ql, int qr)
	{
		if (r<ql || qr<l) return 1e18;
		else if (ql<=l && r<=qr) return st[u];
		else
		{
			int m = (l+r)/2;
			return min(query(u<<1,l,m,ql,qr), query(u<<1|1,m+1,r,ql,qr)) + lz[u];
		}
	}
} sta, stb;

void test ()
{
	int n, t, l, r, a;
	cin >> n;
	while (cin >> t >> l >> r)
	{
		if (t==0) sta.setto(1,1,n,l,r);
		if (t==1) cin >> a, sta.add(1,1,n,l,r,a);
		if (t==2) cout << sta.query(1,1,n,l,r) << '\n';
	}
}
void print ()
{
	int dp, dp_min_i, dp_add_i;
	rep(i,1,n)
	{
		dp = sta.query(1,1,n,i,i)+i;
		dp_min_i = sta.query(1,1,n,i,i);
		dp_add_i = stb.query(1,1,n,i,i);
		de(i), de(dp), de(dp_min_i), de(dp_add_i), dd;
	}
	dd
}

signed main()
{
	XinAi
	cin >> n >> q >> x[0] >> b;
	rep(i,1,q) cin >> x[i];
	sta.init(), stb.init();
	sta.setto(1,1,n,b,-b), stb.setto(1,1,n,b,b);
	
	//print();
	
	rep(i,1,q)
	{
		int owo = min(sta.query(1,1,n,1,x[i])+x[i], stb.query(1,1,n,x[i],n)-x[i]);
		sta.add(1,1,n,1,n,abs(x[i]-x[i-1]));
		stb.add(1,1,n,1,n,abs(x[i]-x[i-1]));
		int qwq = sta.query(1,1,n,x[i-1],x[i-1])+x[i-1];
		if (owo < qwq)
		{
			sta.setto(1,1,n,x[i-1],owo-x[i-1]);
			stb.setto(1,1,n,x[i-1],owo+x[i-1]);	
		}
		//de(i), de(owo), de(qwq), de(owo-x[i-1]), de(owo+x[i-1]), dd print();
	}
	int res=9e18;
	rep(i,1,n) res = min(res, sta.query(1,1,n,i,i)+i);
	cout << res << '\n';
}

Measured memory_bytes: 17748
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    ll n, l, t;
    cin >> n >> l >> t;
    vector<ll> x(n), y(n), w(n);
    ll k = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> w[i];

        if (w[0] != w[i]) {
            if (w[0] == 1 && 2 * t >= x[i] - x[0]) {
                k += (2 * t - x[i] + x[0]) / (l) + 1;
            } else if (w[0] == 2 && 2 * t >= x[0] - x[i] + l) {
                k -= (2 * t - x[0] + x[i] - l) / (l) + 1;
            }
        }

        if (w[i] == 1)
            y[i] = (x[i] + t) % l;
        else
            y[i] = (x[i] - t + t * l) % l;
    }

    k += n * 1000000000000LL;
    k %= n;

    ll y0 = y[0];
    sort(y.begin(), y.end());
    int m = lower_bound(y.begin(), y.end(), y0) - y.begin();
    int o = upper_bound(y.begin(), y.end(), y0) - y.begin();

    if (o - m == 2 && w[0] == 1) {
        m = o - 1;
    }

    for (int i = 0; i < n; ++i) {
        x[(k + i) % n] = y[(m + i) % n];
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i] << endl;
    }

    return 0;
}

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

int main() {
  int K;
  std::cin >> K;
  std::string S;
  std::cin >> S;

  if (S.size() <= K) {
    std::cout << S << std::endl;
  } else {
    std::cout << S.substr(0, K) << "..." << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  char ch;cin >> ch;
  if(ch <= 'Z') cout << 'A' << endl;
  else cout << 'a' << endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=200000;
 
int main(){
  int R[MAX],n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>R[i];
 
  int maxv=-2000000000;
  int minv=R[0];
 
  for(int i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
  }
 
  cout<<maxv<<endl;
 
  return 0;
}

Measured memory_bytes: 3860
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] p = new int[n];
        int[] clonep = new int[n];
        for(int i = 0;i<p.length;i++) {
            p[i] = stdIn.nextInt();
            clonep[i] = p[i];
        }
        Arrays.sort(clonep);
        for(int i = 0;i<p.length;i++) {
            for(int j = i;j<p.length;j++) {
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
                int count = 0;
                for(int k = 0;k<p.length;k++) {
                    if(p[k]==clonep[k]) count++;
                }
                if(count==p.length) {
                    System.out.println("YES");
                    System.exit(0);
                }
                tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
        System.out.println("NO");
    }
}

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

using namespace std;

int main(){
  int n,k,d,t,ans;
  cin >> n >> k;
  vector<int> a;
  for(int i=0; i<k; i++){
    cin >> d;
    for(int j=0; j<d; j++){
      cin >> t;
      a.push_back(t);
    }
  }
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  ans=n-a.size();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int S(int N) {
    int res = 0;
    while(N) {
        res += N % 10;
        N /= 10;
    }
    return res;
}

int main(void) {
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for(int i=1; i<=N; i++) {
        if(A <= S(i) && S(i) <= B) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    long const mod = 1e9+7;

    int h = 0;
    int m = 0;
    int l = 0;

    long ans = 1;

    for(int i=0;i<n;i++){
        // printf("%ld %ld %ld %ld %ld\n",h,m,l,a[i],ans);
        if(a[i] == h){
            if(a[i] == m){
                if(a[i] == l){
                    ans *= 3;
                }else{
                    ans *= 2;
                }
            }
            h++;
        }else{
            if(a[i] == m){
                if(a[i] == l){
                    ans *= 2;
                }
                m++;
            }else{
                if(a[i] == l){
                    l++;
                }else{
                    ans = 0;
                    break;
                }
            }
        }

        ans %= mod;
    }
    cout << ans << endl;
}

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

using namespace std;

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

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

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

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main() {
    string N;
    ll K;
    cin >> N >> K;
    ll length = N.length();
    Combination cmb(1000);
    ll ans = 0;
    REP(i, length - 1) {
        //! i+1桁でちょうどK個になるもの
        //! i+1桁目は固定
        ll t = 9;
        if (K - 1 > 0)
            t *= cmb.get(i, K - 1) * pow(9LL, K - 1);
        ans += t;
    }
    //! 最上位桁を考える
    {
        {
            ll t = N[0] - '0' - 1;
            if (K - 1 > 0) {
                t *= cmb.get(length - 1, K - 1) * pow(9LL, K - 1);
            }
            ans += t;
        }
        //! 最上位をN[0]に固定
        if (K - 1 > 0) {
            bool nz = false;
            for (ll b = 1; b < length; ++b) {
                if (nz) {
                    ll t = 9LL;
                    if (K - 2 > 0)
                        t *= cmb.get(length - b - 1, K - 2) * pow(9LL, K - 2);
                    ans += t;
                    continue;
                }

                if (N[b] - '0' == 0)
                    continue;

                {
                    ll t = N[b] - '0' - 1;
                    if (K - 2 > 0) {
                        t *= cmb.get(length - b - 1, K - 2) * pow(9LL, K - 2);
                    }
                    ans += t;

                    //! 固定
                    if (K - 2 > 0) {
                        bool pz = false;
                        for (ll bb = b + 1; bb < length; ++bb) {
                            if (pz) {
                                ans += 9;
                                continue;
                            }
                            if (N[bb] - '0' == 0)
                                continue;
                            ll tt = N[bb] - '0';
                            ans += tt;
                            pz = true;
                        }
                    }
                    else {
                        ans++;
                    }
                }
                nz = true;
            }
        }
        else {
            ans++;
        }
    }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int k,x;
  cin >> k >> x;
  for(int i=x-k+1;i<x+k;i++) cout<< i <<" ";
  cout<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    static final long MOD = 1000000007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(3 * n * n);
    }
}


Measured memory_bytes: 22996
//abc176_a.cpp
//Sat Aug 22 20:51:37 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	int n,x,t;
	cin >> n >> x >> t;


	int ans = (n+x-1)/x;


	cout << ans*t<< endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	string s[101],t;
	int i;
	cin>>n>>m;
	for(i=0;i<n;i++)	cin>>s[i];
	sort(s,s+n);
	for(i=0;i<n;i++)	t+=s[i];
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <set>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int dp[5000][5000];
int memo[5000];

int main(){
  int n = getInt();
  int m = getInt();
  REP(i,n) memo[i] = i * (i + 1) / 2;

  REP(i,m){
    int a = getInt() - 1;
    int b = getInt() - 1;
    int x = getInt();

    REP(i,x + 1){
      dp[b][a + i] = max(dp[b][a + i], i + 1);
    }
  }

  int ans = 0;
  REP(i,n){
    int mx = 0;
    REP(j,i + 1){
      mx = max(mx - 1, dp[j][i]);
      if(mx > 0) ans++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 0
n = int(input())
arr = [input() for _ in range(n)]
dict = {}
alpha = "abcdefghijklmnopqrstuvwxyz"

for s in arr:
    count = [0]*26
    for i in range(10):
        for j in range(26):
            if s[i] == alpha[j]:
                count[j] += 1
                break
    count = tuple(count)
    if count not in dict:
        dict[count] = 1
    else:
        dict[count] += 1
ans = 0
for val in dict.values():
    ans += val * ( val - 1 ) / 2
print(int(ans)) 

Measured memory_bytes: 120452
N = int(input())
S = input()
X = [0] * (N+1)
Y = [0] * (N+1)
for i in range(N):
    X[i+1] = X[i] + (1 if S[i]=="#" else 0)
for i in range(N+1):
    Y[i] = X[i] + (N-i-X[N]+X[i])
print(min(Y))

Measured memory_bytes: 19108
#include <iostream>

using namespace std;

int main() {
    int n;
    while (true) {
        int count = 0;
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int b=1; 2*b<n; b++) {
            int total = 0;
            for (int k=b; total<n; k++) {
                total += k;
            }
            if (total == n) {
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<vector<bool>> grid(n, vector<bool>(m));
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < m; j++) {
			grid[i][j] = s[j] == '.';
		}
	}
	
	auto ok = [&](int i, int j) {
		return 0 <= i && i < n && 0 <= j && j < m;
	};
	
	int dr[] = {-1, 0, 0, 1};
	int dc[] = {0, -1, 1, 0};
	
	int ans = 0;
	
	for(int sr = 0; sr < n; sr++) {
		for(int sc = 0; sc < m; sc++) {
			if(!grid[sr][sc]) continue;
			for(int tr = 0; tr < n; tr++) {
				for(int tc = 0; tc < m; tc++) {
					if(!grid[tr][tc]) continue;
					int d = 0;
					vector<pair<int, int>> q = {{sr, sc}};
					vector<vector<bool>> now = grid;
					now[sr][sc] = false;
					for(int i = 0; i < (int) q.size(); ) {
						int sz = q.size();
						for(; i < sz; i++) {
							auto u = q[i];
							if(u == make_pair(tr, tc)) {
								ans = max(ans, d);
							}
							
							for(int k = 0; k < 4; k++) {
								int r = u.first + dr[k], c = u.second + dc[k];
								if(ok(r, c) && now[r][c]) {
									now[r][c] = false;
									q.emplace_back(r, c);
								}
							}
						}
						d++;
					}
				}
			}
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
s = input()
q = int(input())
ans = deque(s)
rev = 0
for i in range(q):
    qi = input()
    if qi[0] == '1':
        rev += 1
    else:
        if qi[2] == '1' and rev % 2 == 0:
            ans.appendleft(qi[4])
        elif qi[2] == '2' and rev % 2 == 0:
            ans.append(qi[4])
        if qi[2] == '1' and rev % 2 == 1:
            ans.append(qi[4])
        elif qi[2] == '2' and rev % 2 == 1:
            ans.appendleft(qi[4])

parity = rev % 2
if parity:
    ans.reverse()
    for i in ans:
        print(i, end='')
else:
    for i in ans:
        print(i, end='')

Measured memory_bytes: 7664
def is_odd(n):
    if n % 2:
        return True
    return False

X,K,D = map(int, input().split())
X = abs(X)

ans = 0
if K >= X // D:
    if is_odd(X // D) is is_odd(K):
        ans = X % D
    else:
        ans = X % D - D
else:
    ans = X - D * K

print(abs(ans))


Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int H=gi();
	    int W=gi();
	    char[][] S=new char[H][W];

	    for (int i=0; i<H; i++) {
	    	String s=gs();
	    	for (int j=0; j<W; j++) {
                S[i][j]=s.charAt(j);
	    	}
	    }
	    
	    for (int i=0; i<H; i++) {
	    	for (int j=0; j<W; j++) {
	    		if (S[i][j]=='#') {
                    boolean f=false;
                    if (i!=0 && S[i-1][j]=='#') {
                        f=true;
	    		    }else if (i!=H-1 && S[i+1][j]=='#') {
                        f=true;
	    		    } else if (j!=0 && S[i][j-1]=='#') {
                        f=true;
	    		    } else if (j!=W-1 && S[i][j+1]=='#') {
                        f=true;
	    		    }
                    if(!f) {
                    	System.out.println("No");
                      return;
                    }
	    	    }
	    	}
	    }

	    System.out.println("Yes");
//        if (f) {
//    	    String a=Sq.substring(0, S.lastIndexOf(T)) + T + Sq.substring(S.lastIndexOf(T)+T.length());
//    	    System.out.print(a.replaceAll("\\?", "a"));
//        }else {
//        	System.out.print("UNRESTORABLE");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
#define INF 10000000000

int main(){
	long long W;
	long long N;
	scanf("%lld",&N);
	long long w[N-1+1];
	long long v[N-1+1];
	scanf("%lld",&W);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&w[i]);
		scanf("%lld",&v[i]);
	}
  long long dp[N+1][100001];
	for(int i = 0 ; i <= N ; i++){
		for(int j = 0 ; j <= 100000 ; j++){
			if (i == 0) {
				if (j == 0) {
					dp[i][j] = 0;
				} else {
					dp[i][j] = INF;
				}
			} else {
				if (j-v[i-1] < 0) {
					dp[i][j] = dp[i-1][j];
				} else {
					dp[i][j] = min(dp[i-1][j-v[i-1]]+w[i-1],dp[i-1][j]);
				}
			}
		}
	}
	long long res;
	for(int i = 0 ; i <= 100000 ; i++){
		if(dp[N][i] <= W) res = i;
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 79104
import java.util.Scanner;
 
class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] numbers = new int[n];
        
        for(int i=0 ; i< n ;i++){
            numbers[i] = sc.nextInt();
        }
        
        boolean flag = true;
        int count = 0;
        
      while(flag){
        for(int j=0; j<n; j++){
            if(numbers[j] %2 == 0){
            	numbers[j] /= 2;
            }else{
                flag = false;
                count --;
                break;
            }
        }
        
        count ++;
      }
        System.out.println(count);
    }
}

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

/* define const */

/* finish defineing const */

int n,x = 0;
string s;

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

  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'I') {
      x++;
      mx = max(mx,x);
    }
    else
      x--;
  }
  cout << mx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
int main() {
  ll n;
  cin >> n;
  map<ll, ll> data = prime_factor(n);
  ll ans = 0;
  for (auto iter = data.begin(); iter != data.end(); iter++) {
    ll len = iter->second;
    FOR(i, 1, (iter->second) + 1) {
      len -= i;
      if (len >= 0) {
        ans++;
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int min_a = 0;
  int min_b = 0;
  int aux = 0;
  int aux2 = 0;
  cin >> min_a;
  cin >> min_b;
  cin >> aux;
  if (min_a > min_b){
      aux2 = min_a;
      min_a = min_b;
      min_b = aux2;
  }
  if (aux < min_b){
      min_b = aux;
  }
  cout << min_a + min_b << "\n";
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	static int v = 0;
	static List<List<Integer>> ansList = null;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		br.close();

		if (n == 1) {
			System.out.println("Yes");
			System.out.println(2);
			System.out.println("1 1");
			System.out.println("1 1");
			return;
		}
		if (n == 2) {
			System.out.println("No");
			return;
		}

		int k = 0;
		for (int i = 3; i <= n; i++) {
			int ic2 = i * (i - 1) / 2;
			if (ic2 == n) {
				k = i;
				break;
			} else if (ic2 > n) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");

		ansList = new ArrayList<List<Integer>>(k);
		int[] target = new int[k];
		for (int i = 0; i < k; i++) {
			ansList.add(new ArrayList<Integer>(k - 1));
			target[i] = i;
		}
		combination(target, 2, new ArrayList<Integer>());

		System.out.println(k);
		for (int i = 0; i < k; i++) {
			StringBuilder sb = new StringBuilder();
			sb.append(k - 1).append(' ');
			List<Integer> list = ansList.get(i);
			for (int j : list) {
				sb.append(j).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}

	static void combination(int[] target, int k, List<Integer> list) {
		if (list.size() == k) {
			v++;
			for (int i : list) {
				ansList.get(i).add(v);
			}
			return;
		}

		int i = 0;
		if (!list.isEmpty()) {
			i = list.get(list.size() - 1) + 1;
			if (list.size() + target.length - i < k) {
				return;
			}
		}
		for ( ; i < target.length; i++) {
			list.add(i);
			combination(target, k, list);
			list.remove(list.size() - 1);
		}
	}
}


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

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	if (A + B + C == 17 && (max({ A, B, C }) == 7) && (min({ A, B, C }) == 5)


		){cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  int result = 0;
  rep(i, N)
  {
    int x, y;
    cin >> x >> y;
    result += y - x + 1;
  }
  cout << result << endl;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 52;
const i64 MAXM = 20004;

i64 n;
map<string, i64> a;
map<i64, set<string>> b;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;
    for (i64 i = 0; i < n; i++) {
        string s;
        cin >> s;
        a[s] += 1;
    }

    for (auto t : a) {
        b[t.second].insert(t.first);
    }

    stringstream ss;
    for (auto t : b.rbegin()->second) {
        ss << t << endl;
    }

    cout << ss.str();

    return 0;
}

Measured memory_bytes: 36868
n,m = gets.chomp.split(" ").map { |e| e.to_i }

a = Array.new(n){Array.new(m,0)}
b = Array.new(m)
c = Array.new(n,0)

k = 0
while k <= n-1
a[k] = gets.chomp.split.map { |e| e.to_i }
k += 1
end
t = 0
while t <= m-1
b[t] = gets.to_i
t += 1
end

for i in 0..(n-1)
  for e in 0..(m-1)
    c[i] += a[i][e] * b[e]
  end
end
for i in 0..(n-1)
  puts c[i]
end

Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a,jie=1;
	cin>>a; 
	for(int i=1;i<=a;i++)
	{
		jie*=i;
		jie%=1000000007;
	 } 
	 cout<<jie; 
	return 0;
}

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

int main() {
  int n;
  long long ans = 1;
  cin >> n;
  vector<long long>cnt(1001,0);
  for(int i = 2;i <= n;i++){
    int v = i;
    for (int p = 2;p <= sqrt(v);p++) {
      if (v%p != 0) continue;
      int num = 0;
      while (v%p == 0){
        num++;
        v /= p;
      }
      cnt[p] += num;
    }
    if(v != 0) cnt[v]++;
  }
  for(int i = 2;i < 1001;i++){
    if(cnt[i] == 0) continue;
    ans *= cnt[i]+1;
    ans %= 1000000000+7;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;
ll pow(ll p, ll q) {
    ll ret = 1;
    for (ll i = 0; i < q; i++) ret *= p;
    return ret;
}
int main() {
    ll N, K;
    cin >> N >> K;
    ll p = N / K - ceil(1.0 / K) + 1;
    ll q = (2 * N - K) / (2 * K) - ceil((2.0 - K) / (2.0 * K)) + 1;
    if (N == 1) cout << (K <= 2 ? 1 : 0) << endl;
    else cout << pow(p, 3LL) + (K % 2 ? 0 : pow(q, 3LL)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
  t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
  for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

int calc(int x, int y){
  string sx = to_string(x), sy = to_string(y);
  reverse(sx.begin(), sx.end());
  reverse(sy.begin(), sy.end());
  int res = 0, nx = sx.size(), ny = sy.size(), c = 0, kuri = 0;
  for(int i = 0; i < max(nx, ny); i++){
    int tx = (nx-1 < i ? 0 : (int)(sx[i] - '0'));
    int ty = (ny-1 < i ? 0 : (int)(sy[i] - '0'));
    c += tx + ty;
    res += tx * ty + kuri;
    if(c >= 10) kuri = 1;
    else kuri = 0;

    c = kuri;
  }
  return res + kuri;
}

int f(int x, int y, int c){
  if(not x and not y) return c;
  int a = x % 10, b = y % 10;
  return a * b + c + f(x/10, y/10, (a+b+c)/10);
}

signed main(){

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

  vector<int> imos(n+1, 0);
  for(int i = 0; i < n; i++){
    imos[i+1] = imos[i] + a[i];
  }

  auto dp = make_vec<int>(n, n);
  fill(dp, INF);
  for(int i = 0; i < n; i++) dp[i][i] = 0;
  for(int l = 1; l <= n; l++){
    for(int i = 0; i <= n-l; i++){
      int j = i + l - 1;
      for(int k = i; k < j; k++){
        int x = imos[k+1] - imos[i];
        int y = imos[j+1] - imos[k+1];
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + calc(x, y));
        //dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + f(x, y, 0));
      }
    }
  }
  cout << dp[0][n-1] << endl;

  return 0;
}


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

using namespace std;

int main()
{
    int x[5],y[5];
    cin >> x[0] >> y[0];
    cin >> x[1] >> y[1];
    x[2]=x[1]-y[1]+y[0];
    y[2]=y[1]+x[1]-x[0];
    x[3]=x[2]-x[1]+x[0];
    y[3]=y[2]-y[1]+y[0];
    cout << x[2] << ' ';
    cout << y[2] << ' ';
    cout << x[3] << ' ';
    cout << y[3] << ' ';
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  val pow10 = Array.ofDim[Long](19)
  pow10(0) = 1
  REP(18)(i => pow10(i + 1) = pow10(i) * 10)

  def solve(): Unit = {
    val N = ni()

    var all = ArrayBuffer[Long](3, 5, 7)
    var prev = ArrayBuffer[Long](3, 5, 7)
    REP(9) { k =>
      val cur = ArrayBuffer[Long]()
      prev.foreach { a =>
        Seq(3, 5, 7) foreach { d =>
          val x = pow10(k + 1) * d + a
          cur += x
        }
      }
      prev = cur
      all ++= cur
    }

    val ans = all.count { a =>
      val s = a.toString
      Seq('3', '5', '7').forall(c => s.indexOf(c) != -1) &&  a <= N
    }
    out.println(ans)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;


#define N 100000
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

// 連結成分の番号を振る関数
void dfs(int n, int comp[], vector<int> G[]) {
  int i, j, vertex, neighbor, color[N];
  stack<int> S;
  // 初期状態
  for (i = 0; i < n; i++) color[i] = WHITE;

  for (i = 0; i < n; i++) {
    if (color[i] == WHITE) {
      // dfs
      S.push(i);
      while (!S.empty()) {
        vertex = S.top();
        S.pop();
        color[vertex] = BLACK;  // 訪問済みにする
        comp[vertex] = i;  // 連結成分の番号を振る
        for (j = 0; j < (int) G[vertex].size(); j++) {
          neighbor = G[vertex][j]; // 隣接している頂点：友人
          if (color[neighbor] == WHITE) S.push(neighbor);
        }
      }
    }
  }
}

int main() {
  int i, n, m, q, s, t;
  int comp[N];  // 連結成分の番号
  vector<int> G[N];  // グラフを表現する隣接リスト
  int k;
  cin >> n >> m >> k;
  // 隣接リストを作成
  for (i = 0; i < m; i++) {
    cin >> s >> t;
    s--; t--;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  // cout << "Test"<< endl;
  vector<int>  UF[N];
  rep(i,k) {
    cin >> s >> t;
    s--; t--;
    UF[s].push_back(t);
    UF[t].push_back(s);
  }
  // グラフを連結成分に分ける
  dfs(n, comp, G);
  vector<int> comp_size(n);
    // cout << comp[i+1] << endl;
  rep(i,n) {
    comp_size[comp[i]] += 1;
  }
  // check_v(comp_size);
  rep(i, n){
    int ans = comp_size[comp[i]] - G[i].size() -1;
      for(auto p : UF[i]) {
        if(comp[i] == comp[p])
          ans -= 1;
      }
      cout << ans << " ";
  }
  cout << endl;
  // cin >> q;
  // for (i = 0; i < q; i++) {
  //   cin >> s >> t;
  //   if (comp[s] == comp[t]) cout << "yes" << endl;
  //   else cout << "no" << endl;
  // }
  return 0;
}


Measured memory_bytes: 13048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	vector<int> syllabes(3);
	cin >> syllabes[0] >> syllabes[1] >> syllabes[2];

	sort(syllabes.begin(), syllabes.end());
	if (syllabes[0] == 5 && syllabes[1] == 5 && syllabes[2] == 7) 
		cout << "YES\n";
	else 
		cout << "NO\n";

	return 0;

}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

int main() {
  fast;
  cin.tie(0);
/*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w" , stdout);
#endif*/
  string s, t;
  lld i;
  cin >> s >> t;
  bool f = true;
  for (i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) {
      f = false;
      break;
    }
  }
  if (!f) cout << "No" << endl;
  else {
    if (t.length() == s.length() + 1) {
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }

}


Measured memory_bytes: 3652
# https://atcoder.jp/contests/arc061/tasks/arc061_a
S = input()
op_cnt = len(S) - 1
ops = []
for i in range(2 ** op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = "+"
    ops.append(op)

# print(ops)


def eval_fomula(S, op):
    s = list(S)
    count = 1
    for i in range(len(s) - 1):
        s.insert(i+count, op[i])
        count += 1
    fomula = ""
    for k in range(len(s)):
        fomula += s[k]

    return eval(fomula)


total = 0
for i in range(2 ** op_cnt):
    total += eval_fomula(S, ops[i])

print(total)


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

using namespace std;

#define USE_IOSTREAM \
{\
	ios::sync_with_stdio(false);\
	cin.tie(0);\
	cout.tie(0);\
}

#define pii pair<int, int>
#define mp make_pair

typedef long long ll;



int main()
{
	USE_IOSTREAM;
	string s;
	cin >> s;
	
	int n = s.length();
	
	bool firstWin = true;
	if (s[0] == s[n - 1])
	{
		firstWin = (n % 2 == 0);
	}
	else
	{
		firstWin = (n % 2 == 1);
	}
	
	if (firstWin)
	{
		cout << "First" << endl;
	}
	else
	{
		cout << "Second" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
 
class Main {
	int n;
	int w;
	int[] weight;
	int[] value;
	long[][] dp;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		w = sc.nextInt();
		weight = new int[n];
		value = new int[n];
		dp = new long[n+1][w+1];
		for(int i=0;i<n;i++){
			weight[i] = sc.nextInt();
			value[i] = sc.nextInt();
		}
	}
	void solve(){
		for(int i=1;i<=n;i++){
			for(int j=0;j<=w;j++){
				if(j-weight[i-1]>=0) dp[i][j] = Math.max(dp[i][j], dp[i-1][j-weight[i-1]]+value[i-1]);
				dp[i][j] = Math.max(dp[i][j], dp[i-1][j]);
			}
		}
		System.out.println(dp[n][w]);
	}
}

Measured memory_bytes: 126672
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
string s;
bool hs[256];
int main()
{
	cin>>s;
	for (int i=0; i<s.size(); i++) hs[s[i]]=1;
	if (s.size()<26)
	{
		int it = 'a';
		while (hs[it]) it++;
		s.PB(char(it));
		cout<<s<<endl;
	}
	else
	{
		for (int i=int(s.size())-1; i>=0; i--)
		{
			hs[s[i]] = 0;
			s[i]++;
			while (s[i]<='z'&&hs[s[i]]) s[i]++;
			if (s[i]<='z')
			{
				s.resize(i+1);
				break;
			}
			else
			{
				if (i==0)
				{
					puts("-1");
					return 0;
				}
			}
		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
string s;
vi alpha(3);
int t;
int formula(int a){
	int out=-1;
	int co=0;
	if(s[t]=='(')++t,out=formula(0);
	else if(s[t]=='-')++t,out=2-formula(1);
	else if(isdigit(s[t]))out=s[t]-'0';
	else if(isalpha(s[t]))out=alpha[s[t]-'P'];
	
	if(a)return out;
	t++;
	if(s[t]=='*'){
		t++;
		out=min(out,formula(0));
	}else if(s[t]=='+'){
		t++;
		out=max(out,formula(0));
	}
	
	if(co%2)out=2-out;
	
	return out;
}
void f(){
	int co=0;
	rep(P,3)rep(Q,3)rep(R,3){
		t=0;
		alpha[0]=P;
		alpha[1]=Q;
		alpha[2]=R;
		if(formula(0)==2)co++;
	}
	cout<<co<<endl;
}
int main(){
	while(cin>>s,s!=".")f();
}





Measured memory_bytes: 3068
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long ans = lcm(a, b);
		System.out.println(ans);
	}

	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	public static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}

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

int main () {
  int n,m;
  cin>>n;
  if(n%2==0) m=n/2;
  else m=(n/2)+1;
  float x=float(m)/float(n);
  cout<<fixed<<setprecision(10)<<x;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b + c, min(c + a, a + b));
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=100004;
int N, M, k;

int main()
{
    ll a[5], an=1;
    for(int i=1;i<=3;i++) {
        scanf("%lld", &a[i]);
        if(a[i] % 2 == 0) an=a[i]%2;
    }
    if(an) an=min(a[1]*a[2], min(a[1]*a[3], a[2]*a[3]));
    printf("%lld ", an);
    return 0 ;
}


Measured memory_bytes: 256
N = int(input())
T = ("3","5","7")

from collections import deque
que = deque(list(T))

ans = 0
while que:
  num = que.pop()
  if int(num) > N:
    continue
  if len(set(num)) == 3:
    ans += 1
  for t in T:
    que.append(num + t)

print(ans)

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

int main(){
	int n; cin >> n;
	double res = (double)(n / 2);
	cout << 1 - res / n;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007
int main(){
  int N;
  string S;
  cin >> N >> S;
  string A="000";
  std::map<std::string,int> yey;
  vector<int> count1(10,0);
  rep(i1, N-2){
  vector<int> count2(10,0);
    if(count1[S[i1]-'0']==1)
      continue;
    count1[S[i1]-'0']=1;    
    A[0]=S[i1];
    rep2(i2, i1+1, N-1){
  vector<int> count3(10,0);
    if(count2[S[i2]-'0']==1)
      continue;
    count2[S[i2]-'0']=1;    
      A[1]=S[i2];
      rep2(i3, i2+1, N){
    if(count3[S[i3]-'0']==1)
      continue;
    count3[S[i3]-'0']=1;    
        A[2]=S[i3];
        yey[A]=0;
      }
    }
  }
  cout << yey.size()<< endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)

#define mp make_pair
#define fi first
#define se second

#define bit(n) (1LL<<(n))

i64 bfs(const vector<string> &v, i64 h, i64 w){
  i64 H = v.size(), W = v[0].size();
  vector<vector<i64>> dist(H, vector<i64>(W, -1));
  queue<pair<i64,i64>> que;

  que.push({h,w});
  dist[h][w] = 0;
  while(!que.empty()){
    h = que.front().fi;
    w = que.front().se;
    que.pop();
    rep(dir,4){
      i64 nh = h+dy[dir], nw = w+dx[dir];
      if(nh<0 || H<=nh || nw<0 || W<=nw) continue;
      if(v[nh][nw] == '#') continue;
      if(dist[nh][nw] == -1){
        dist[nh][nw] = dist[h][w] + 1;
        que.push({nh,nw});
      }
    }
  }
  return dist[h][w];
}

void Main()
{
  i64 H,W;
  cin >> H >> W;
  vector<string> v(H);
  rep(i,H) cin >> v[i];

  i64 ans = 0;
  rep(h,H) rep(w,W){
    if(v[h][w]=='#') continue;
    ans = max(ans,bfs(v,h,w));
  }
  cout << ans << '\n';
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 256