akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

struct edge{ int to, cap, d;};
struct node{
    int p, v, prev; double d;
    node(int p, int v, int prev, double d):p(p),v(v),prev(prev),d(d){}
    bool operator<(const node &n)const{ return d > n.d;}
};
const int dv[] = {-1,0,1};
int done[32][32][32], N, M, s, t;
double dist[32][32][32];
vector<edge> G[32];

void solve(){
    priority_queue<node> q;
    q.push(node(s,0,s,0));
    while(!q.empty()){
        node u = q.top(); q.pop();
        if(done[u.p][u.v][u.prev]) continue;
        if(u.p == t and u.v == 1){
            printf("%.8f\n", u.d);
            return;
        }
        done[u.p][u.v][u.prev] = 1;
        dist[u.p][u.v][u.prev] = u.d;
        rep(i,G[u.p].size()){
            edge &e = G[u.p][i];
            if(e.to == u.prev) continue;
            rep(j,3){
                int nv = u.v + dv[j];
                if(nv > 0 and nv <= e.cap)
                    q.push(node(e.to, nv, u.p, 1.*e.d/nv+u.d));
            }
        }
    }
    puts("unreachable");
}

void input(){
    cin >> s >> t;
    s--; t--;
    rep(i,M){
        int x, y, d, c; cin >> x >> y >> d >> c;
        x--; y--;
        G[x].pb((edge){y,c,d});
        G[y].pb((edge){x,c,d});
    }
}

void init(){
    rep(i,32) G[i].clear();
    memset(done, 0, sizeof(done));
}

int main()
{
    while(cin  >> N >> M, N or M){
        init();
        input();
        solve();
    }
    return 0;
}

Measured memory_bytes: 21656
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_NM = 100000;
ll n, m;
ll p[MAX_NM], x[MAX_NM], y[MAX_NM];

const int MAX_N = 200000;

int par[MAX_N];
int rk[MAX_N];

void init(int n){
  REP(i,n){
    par[i] = i;
    rk[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y) return;
  if(rk[x] < rk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rk[x] == rk[y]) rk[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}


int main(){
  cin >> n >> m;
  REP(i, n) {
    cin >> p[i];
    p[i]--;
  }
  REP(j, m) {
    cin >> x[j] >> y[j];
    x[j]--;
    y[j]--;
  }

  init(2 * n);
  REP(i, n) unite(i, p[i] + n);
  REP(j, m) unite(x[j], y[j]);
  ll ans = 0;
  REP(i, n) if(same(p[i] + n, p[i])) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4096
n=int(input())
dp=[float("inf")]*(n+1)
dp[0]=0
for i in range(n):
    dp[i+1]=min(dp[i+1],dp[i]+1)
    j,k=1,1
    while i+6**j<=n:
        dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
        j+=1
    while i+9**k<=n:
        dp[i+9**k]=min(dp[i+9**k],dp[i]+1)
        k+=1
print(dp[-1])

Measured memory_bytes: 3828
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int maxp = (n - 1) * (n - 2) / 2;
    if (k > maxp) {
        printf("-1\n");
    } else {
        int diff = maxp - k;
        int e = (n - 1) + diff;
        printf("%d\n", e);
        for (int i = 2; i <= n; i++) {
            printf("%d %d\n", 1, i);
        }
        for (int i = 2; i <= n && diff > 0; i++) {
            for (int j = i + 1; j <= n && diff > 0; j++) {
                printf("%d %d\n", i, j);
                diff--;
            }
        }
    }
}


Measured memory_bytes: 3736
N = int(input())
d = {}

for i in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
y = sorted(d.items(), key=lambda x: x[0])
z = sorted(y, key=lambda b: b[1], reverse=True)
m = 0
for s in z:
    if s[1] >= m:
        print(s[0])
        m = s[1]
    else:
        break

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

int main() {

  int N;
  cin>>N;
  long long int ans;
  vector<long long int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int n=1;
  int k=1;
  int count=0;
  ans=A[0];
  while(n<N-1){
    ans=ans+A[k];
    count=count+1;
    if(count==2){
      count=0;
      k=k+1;
    }    
  n++;
  }
  cout <<ans<<endl;
  
 return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

set<int> eratos(int n)
{
	bool isPrime[1001];
	for (int i = 0; i <= n; i++)
	{
		isPrime[i] = true;
	}

	isPrime[0] = false;
	isPrime[1] = false;

	for (int i = 2; i*i <= n; i++)
	{
		isPrime[i] == true;

		int j = i * 2;
		while (j <= n)
		{
			isPrime[j] = false;
			j += i;
		}
	}

	set<int> primes;
	for (int i = 0; i <= n; i++)
	{
		if (isPrime[i])
		{
			primes.insert(i);
		}
	}
	return primes;
}

int main()
{
	int n;
	cin >> n;
	set<int> primes = eratos(n);

	map<int, int> primeCount;

	for (set<int>::iterator it = primes.begin(); it != primes.end(); it++)
	{
		primeCount[*it];
	}

	for (int i = 1; i <= n; i++)
	{
		int p = i;
		for (map<int, int>::iterator it = primeCount.begin(); it != primeCount.end(); it++)
		{
			if (p < it->first)
			{
				break;
			}

			int count = 0;
			while (true)
			{
				if (p % it->first == 0)
				{
					it->second++;
					p /= it->first;
					if (p == 1)
					{
						break;
					}
				}
				else {
					break;
				}
			}
		}
	}
	ll res = 1;
	for (map<int, int>::iterator it = primeCount.begin(); it != primeCount.end(); it++)
	{
		res = (res * (it->second + 1)) % mod;
	}
	cout << res << endl;

	return 0;
}

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

#define rep(i, s, t) for (int i = s; i < int(t); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define const_range(c)	c.cbegin(), c.cend()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builin_popcount
#define pop_count64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count64	__builtin_clzll

#define temp_name template<typename

temp_name T1, typename T2> ostream& operator<< (ostream& os, const pair<T1, T2>& p) { return os << "<" << p.ff << "," << p.ss << ">"; }
#define container_ostream(container)						\
temp_name... T> ostream& operator<< (ostream& os, const container<T...>& c) {	\
	if (c.empty()) return os << "{ }";					\
	auto iter = c.cbegin();							\
	os << "{ " << *iter;							\
	while (++iter != c.cend()) os << ", " << *iter;				\
	return os << " }";							\
}
container_ostream(vector);
container_ostream(set);
container_ostream(map);

void dbg() { cerr << endl;}
temp_name Head, typename... Tail> void dbg(Head h, Tail... t) { cerr << " " << h; dbg(t...); }

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__)
#else
#define debug(...) 0
#endif

typedef long long i64;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;

temp_name T> T& minn(T& x, const T& y) { return x = min(x, y); }
temp_name T> T& maxx(T& x, const T& y) { return x = max(x, y); }

constexpr const int mod = 1000000007;
constexpr int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
constexpr int sub(int a, int b) { return a < b ? mod + a - b : a - b; }
constexpr int mul(int a, int b) { return 1LL * a * b % mod; }
#define more_para(type, func) temp_name... T> constexpr type func(type a, type b, T... c) { return func(func(a, b), c...); }
more_para(int, add);
more_para(int, sub);
more_para(int, mul);
constexpr int square(int a) { return mul(a, a); }
constexpr int fpow(int a, int b) { return b ? mul(b & 1 ? a : 1, square(fpow(a, b >> 1))) : 1; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vi x(n), inv(n);
	inv[1] = 1;
	rep(i, 2, n) inv[i] = mul(inv[mod % i], mod - mod / i);
	partial_sum(range(inv), inv.begin(), [] (int x, int y) -> int { return add(x, y); });
	rep(i, 0, n) cin >> x[i];
	int ans = 0;
	rep(i, 1, n) ans = add(ans, mul(x[i] - x[i - 1], inv[i]));
	rep(i, 1, n) ans = mul(ans, i);
	cout << ans << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<pair<int,int>> vec;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int h, m;
        cin >> h >> m;
        vec.emplace_back(h, m);
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int h, m;
        cin >> h >> m;
        vec.emplace_back(h, m);
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    for (int i = 0; i < vec.size() - 1; ++i) {
        cout << vec[i].first << ':';
        if (vec[i].second < 10) cout << 0 << vec[i].second << " ";
        else cout << vec[i].second << " ";
    }
    cout << vec[vec.size() - 1].first << ':';
    if (vec[vec.size() - 1].second < 10) cout << 0 << vec[vec.size() - 1].second << '\n';
    else cout << vec[vec.size() - 1].second << '\n';
    return 0;
}


Measured memory_bytes: 3228
n = int(input())
a = list(map(int, input().split()))


res = []
mx = max(a)
mx_idx = a.index(mx)
mn = min(a)
mn_idx = a.index(mn)

if abs(mx) >= abs(mn):
    for i in range(n):
        res.append((mx_idx, i))
    for i in range(0, n - 1):
        res.append((i, i + 1))
else:
    for i in range(n):
        res.append((mn_idx, i))
    for i in range(n - 1, 0, -1):
        res.append((i, i - 1))

print(len(res))

for i, j in res:
    print("%d %d" % (i + 1, j + 1))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll f1=0,f2=0;
    string s;
    cin>>s;
    if((s[0]=='0'&&s[1]!='0')||(s[0]=='1'&&s[1]<='2'))
    f1=1;
    if((s[2]=='0'&&s[3]!='0')||(s[2]=='1'&&s[3]<='2'))
    f2=1;
    if(f1&&f2)
    cout<<"AMBIGUOUS";
    else if(f1)
    cout<<"MMYY";
    else if(f2)
    cout<<"YYMM";
    else
    cout<<"NA";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (d <= s * t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
 
 
signed main(){
 
	lli n,m;
	cin>>n>>m;
	map<lli,vector<lli>> d;

	lli in[100100]={0};
 
	REP(i,0,n-1+m){
		lli a,b;
		cin>>a>>b;
		a--;b--;
		d[a].push_back(b);
		in[b]++;
	}

	/*適当な点から逆側に幅優先探索で最後にたどり着く箇所が根になる*/
	/*さらに根から幅優先探索を行っていき、親を更新していくことで答えとなる*/
 
	queue<lli> q;
 
	lli last=-1;
	REP(i,0,n){
		if(in[i]==0){
			last = i;
			break;
		}
	}

	lli ans[100100]={-1};
	ans[last]=0;
	q.push(last);
 
	while(q.size()){
		lli top=q.front();
		q.pop();

		for(auto e:d[top]){
			in[e]--;
			if(in[e]==0){
				q.push(e);
				ans[e]=top+1;
			}
		}
	}
 
	REP(i,0,n) cout<<ans[i]<<endl;
 
	return 0;
}

Measured memory_bytes: 13312
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, d;
	cin >> n >> d;
	int cap = d * 2 + 1;
	int ans = 0;
	if (n % cap == 0) {
		ans = n / cap;
	}
	else {
		ans = n / cap + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair


vector<ll> v;
void solve()
{
  ll k=1;
  for(ll i=0;i<=100;i++)
  {
    v.pb(k);
    k+=(i+2);
  }
}
int main()
{
  //solve();
  long double a,b;
  cin >> a;;

  cin >> b;

  long double ans=a*b*1.0;
  ans = truncl(ans);
  ll a1=ans;

  cout << a1;



}


Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

		int N = sc.nextInt();
		Integer a[] = new Integer[N];
		for(int i=0; i < N; i++){
			a[i] = sc.nextInt();
		}

		Arrays.sort(a, Comparator.reverseOrder());

		int A = 0;
		int B = 0;

		for(int i=0; i < N; i++){
			if(i%2 == 0){
				A = A + a[i];
			}
			else{
				B = B + a[i];
			}
		}

		System.out.println(A-B);
		//System.out.println(Arrays.toString(a));
	}
}

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

int main(){
  int N; cin>>N;
  ll A[N]; rep(i,N) cin>>A[i];
  if(A[0]!=0){
    cout<<-1<<endl;
    return 0;
  }
  ll ans=0;
  for(int i=1;i<N;i++) if(A[i]!=0){
    if(A[i]-A[i-1]>1){
      cout<<-1<<endl;
      return 0;
    }
    if(A[i]==A[i-1]+1) ans++;
    else ans+=A[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static long[] list = new long[10001];
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			String tmp = stdIn.next();
			solv(tmp);
		}
	}
	public static void solv(String a) {
		int tmp = 0;
		tmp += check(a.charAt(0));
		for(int i = 1; i < a.length(); i++) {
			if(check(a.charAt(i)) <= check(a.charAt(i-1))) {
				tmp += check(a.charAt(i));
			}
			else {
				tmp -= check(a.charAt(i-1));
				tmp += check(a.charAt(i)) - check(a.charAt(i-1));
			}
		}
		System.out.println(tmp);
	}
	public static int check(char a) {
		if(a == 'M') return 1000;
		if(a == 'D') return 500;
		if(a == 'C') return 100;
		if(a == 'L') return 50;
		if(a == 'X') return 10;
		if(a == 'V') return 5;
		if(a == 'I') return 1;
		return 0;
	}
}

Measured memory_bytes: 17228
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y)) 
#define NUMRNK 7

int main(void){  
  double t500, t1k;
  double lim500[] = {70, 55, 50, 43, 40, 37.5, 35.5};
  double lim1k[] = {148, 116, 105, 89, 83, 77, 71};
  string rnkName[] = {"E", "D", "C", "B", "A", "AA", "AAA"};
  int rnk, rnk500, rnk1k;
  
  while (cin >> t500 >> t1k){
    rnk = rnk500 = rnk1k = -1;
    for (int i=0; i<NUMRNK; i++){
      if (t500<lim500[i]) rnk500 = i;
      if (t1k<lim1k[i]) rnk1k = i;
    }
    rnk = MIN(rnk500, rnk1k);
    if (rnk < 0) cout << "NA" << endl;
    else cout << rnkName[rnk] << endl;
  }
  return 0;
}


Measured memory_bytes: 3228
// #define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 2e5+10;
#define int ll
vector<ll> N_LIS(vector<int> a){
    vector<ll> dp(n_max, INF);
    // fill(all(dp), INF);
    int n = a.size();
    rep(i,n){
        *lower_bound(all(dp), a[i]) = a[i];
    }
    cout << lower_bound(all(dp), INF) - dp.begin() << endl;
    return dp;
}


vector<ll> dp(n_max, INF);
vector<ll> a(n_max);
void dfs(vvl &graph, vl &v, ll pos, ll par){
    ll id = lower_bound(all(v), a[pos]) - v.begin();
    ll temp = v[id];
    v[id] = a[pos];
    for(auto &to : graph[pos]){
        if(to != par){
            dfs(graph, v, to, pos);
        }
    }
    dp[pos] = lower_bound(all(v), INF) - v.begin();
    v[id] = temp;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;

    rep(i,n) cin >> a[i];
    vector<vector<ll>> graph(n);
    rep(i,n-1) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    vector<ll> v(n, INF);
    dfs(graph, v, 0, -1);
    rep(i,n){
        cout << dp[i] << "\n";
    }
}

Measured memory_bytes: 33144
#include <bits/stdc++.h>
#define ll long long
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int n,m,k;
char tu[20][2000];
int gs[20]={0};
int temp[20]={0};
int p;
void col(int id,int x) {
	memset(temp,0,sizeof(temp));
	p=1;
	for(int i=1;i<=n;i++) {
		if(tu[i][id]=='1') {
			temp[p]++;
		}
		if((x>>(i-1))&1) {
			p++;
		}
	}
	p++;
	return ;
}
int Max() {
	int mx=0;
	for(int i=1;i<p;i++) {
		mx=max(temp[i]+gs[i],mx);
	}
	return mx;
}
void Sum() {
	for(int i=1;i<p;i++) {
		gs[i]+=temp[i];
	}
}
void copy() {
	for(int i=1;i<p;i++) {
		gs[i]=temp[i];
	}
}
int cl(int x) {
	//cout<<endl;
	//cout<<x<<endl;
	memset(gs,0,sizeof(gs));
	int res=0;
	col(1,x);
	int mx=Max();
	if(mx>k)return -1;
	Sum();
	for(int i=1;i<m;i++) {
		int j=i+1;
		while(j<=m) {
			col(j,x);
			mx=Max();
			if(mx<=k) {
				Sum();
				j++;
			}else {
				//cout<<j<<" ";
				res++;
				mx=0;
				for(int t=1;t<p;t++) {
					mx=max(temp[t],mx);
				}
				if(mx>k)return -1;
				copy();
				break;
			}
		}
		i=j-1;
	}
	//puts("");
	return res;
}
int main()
{
	//cwk;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) {
		scanf("%s",tu[i]+1);
	}
	int N=(1<<(n-1));
	int ans=1e9;
	for(int i=0;i<N;i++) {
		int sum1=cl(i);
		int sum2=0;
		int x=i;
		while(x) {
			if(x&1) sum2++;
			x>>=1;
		}
		if(sum1!=-1) {
			ans=min(ans,sum1+sum2);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    ll n;cin>>n;
    vector<string> v(n),ans;
    rep(i,n)cin>>v[i];
    sort(all(v));
    ll from=-1,to=-1;
    ll m=0;
    while(to<n-1){
        from=to+1;
        while(v[from]==v[to+1]){
            to++;
            if(to>=n-1)break;
        }
        chmax(m,to-from);
    }
    from=-1;
    to=-1;
    while(to<n-1){
        from=to+1;
        while(v[from]==v[to+1]){
            to++;
            if(to>=n-1)break;
        }
        if(to-from==m)ans.pb(v[to]);
    }
    sort(all(ans));
    for(auto x:ans)out(x);
}

Measured memory_bytes: 15988
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

int main() {
    Int a, b;
    cin >> a >> b;
    map<Int, Int> mp;
    mp[1] = 2;
    if (a != 1) mp[a]++;
    if (b != 1) mp[b]++;
    for (Int i = 2; i * i <= a; i++) {
        if (a % i == 0) {
            if (i * i == a) {
                mp[i]++;
            }
            else {
                mp[i]++;
                mp[a / i]++;
            }
        }
    }
    for (Int i = 2; i * i <= b; i++) {
        if (b % i == 0) {
            if (i * i == b) {
                mp[i]++;
            }
            else {
                mp[i]++;
                mp[b / i]++;
            }
        }
    }
    vector<Int> c;
    for (auto i : mp) {
        if (i.se == 2) {
            c.push_back(i.fi);
        }
    }
    Int res = 1;
    for (Int i = 1; i < (Int)c.size(); i++) {
        bool prime = true;
        for (Int j = 2; j * j <= c[i]; j++) {
            if (c[i] % j == 0) {
                prime = false;
                break;
            }
        }
        if (prime) {
            res++;
        }
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 768
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 2e5 + 3;
lli n, m, vis[N] = {0}, a, b, ct = 0;
vi gp[N];

void dfs(lli nd, lli par = 0){
	vis[nd] = 1; ++ct;
	for(lli i:gp[nd]) if(i!=par && !vis[i]) {
		dfs(i, nd);
	}
	return;
}

void solve(){
	set<pr> st;
	cin >> n >> m;
	NA(i,0,m) {
		cin >> a >> b;
		if(a < b) swap(a, b);
		pr p = {a,b};
		if(st.find(p)==st.end()) st.insert(p);
	}
	for(auto &i:st) {
		gp[i.fi].pb(i.se);
		gp[i.se].pb(i.fi);
	}
	lli ans = 0;
	NA(i,1,n+1) {
		if(!vis[i]) ct = 0, dfs(i);
		ans = max(ans, ct);
	}
	cout << ans;
	return;
}

int main(){
    fastIO;
    lli t = 1;
	// cin >> t;
	NA(i,0,t) {
		// cout << "Case #" << i+1 << ": "; 
		solve();
	}
	return 0;
}



Measured memory_bytes: 37864
// AOJ 0348: Sevens
// 2017.10.28 bal4u@uu

#include <stdio.h>
#include <string.h>

char a[15], b[15];

int check()
{
	int min, max, an, bn;

	if (a[1] && a[13]) return 0;
	if (b[1] && b[13]) return 1;
	min = 6, max = 8, an = bn = 6;
	if (a[1]) {
		while (1) {
			if      (a[min]) min--, an--;
			else if (a[max]) max++, an--;
			if (an == 0) return 1;
			if      (b[max]) max++, bn--;
			else if (b[min]) min--, bn--;
			if (bn == 0) return 0;
		}
	} else {
		while (1) {
			if      (a[max]) max++, an--;
			else if (a[min]) min--, an--;
			if (an == 0) return 1;
			if      (b[min]) min--, bn--;
			else if (b[max]) max++, bn--;
			if (bn == 0) return 0;
		}
	}
	return 0;
}

int main()
{
	int n, i, v;

	scanf("%d", &n);
	while (n-- > 0) {
		memset(a, 0, sizeof(a)), memset(b, 0, sizeof(b));
		for (i = 0; i < 6; i++)	scanf("%d", &v), a[v] = 1;
		for (i = 1; i <= 13; i++) if (!a[i]) b[i] = 1;
		puts(check() ? "yes" : "no"); 
	}
	return 0;
}

Measured memory_bytes: 1788
#include <cstdio>

using namespace std;

int main(){
	int joi;
	int ioi;
	char str[16384];
	char self[16384];
	while(scanf("%s",str) != EOF){
		joi = 0;
		ioi = 0;
		int l = sprintf(self,"%s",str) + 1;
		
		for(int i=0;i < l;i++){
			if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I'){
				ioi += 1;
				i += 1;
				continue;
			}
			if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I'){
				joi += 1;
				i += 1;
				continue;
			}
		}
		printf("%d\n%d\n",joi,ioi);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		char c;
		cin>>c;
		c++;
		cout<<c;
	}
	return 0;
	}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, K;
const int max_N = 2000;
const int max_K = 2000;
long long C[max_N+1][max_N+1];
long long res[max_K+1];

long long mod = 1000000007;


int main(){
    cin >> N >> K;

    // C[i][j] := i_C_j
    for(int i = 0; i <= N; i++){
        C[i][0] = 1;
        C[i][i] = 1;
        for(int j = 1; j < i; j++){
            C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
        }
    }

    for(int i = 1; i <= K; i++){
        if(N-K+1 >= i){
            res[i] = (C[N-K+1][i] * C[K-1][i-1]) % mod;
        }else{
            res[i] = 0;
        }
    }

    for(int i = 1; i <= K; i++){
        cout << res[i] << endl;
    }


    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n;
vector<int> rest;
vector<pair<int, int>> ok;
vector<int> query;
int cnt = 0;

int quest(vector<int> &c) {
  cnt++;
  if (cnt > 210) {
    exit(1);
  }
  if (c.size() != n) {
    exit(1);
  }
  cout << "?";
  for (int i = 0; i < n; i++) cout << " " << c[i];
  cout << endl;
  string q;
  cin >> q;
  if (q == "-1") {
    exit(1);
  }
  return q == "Red";
}

vector<bool> use;

void solve() {
  vector<int> query;
  for (int i = 0; i < n; i++) query.push_back(rest[i]);
  int c = quest(query);
  int l = n, r = rest.size();
  while (r - l > 1) {
    query.clear();
    int m = (r + l) / 2;
    for (int i = m - n; i < m; i++) query.push_back(rest[i]);
    int c2 = quest(query);
    if (c == c2) {
      l = m;
    } else {
      r = m;
    }
  }
  query.clear();
  for (int i = l - n + 1; i < l; i++) query.push_back(rest[i]);
  for (int i = 0; i < l - n; i++) {
    vector<int> q2 = query;
    q2.push_back(rest[i]);
    int c = quest(q2);
    ok.emplace_back(rest[i], c);
    use[rest[i] - 1] = true;
  }
  for (int i = l + 1; i < rest.size(); i++) {
    vector<int> q2 = query;
    q2.push_back(rest[i]);
    int c = quest(q2);
    ok.emplace_back(rest[i], c);
    use[rest[i] - 1] = true;
  }
  ok.emplace_back(rest[l], 1 - c);
  ok.emplace_back(rest[l - n], c);
  use[rest[l] - 1] = true;
  use[rest[l - n] - 1] = true;
  rest.erase(rest.begin() + l);
  rest.erase(rest.begin() + l - n);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n;
  use.resize(2 * n);
  for (int i = 0; i < 2 * n; i++) rest.push_back(i + 1);
  while (ok.size() < n / 2 * 2) {
    solve();
  }
  vector<int> query;
  int c[2] = {0};
  for (int i = 0; i < ok.size(); i++) {
    if (c[ok[i].second] < n / 2) {
      query.push_back(ok[i].first);
      c[ok[i].second]++;
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (use[i]) continue;
    vector<int> q2 = query;
    q2.push_back(i + 1);
    int c = quest(q2);
    ok.emplace_back(i + 1, c);
  }
  vector<char> ans(2 * n, '0');
  for (int i = 0; i < ok.size(); i++) {
    ans[ok[i].first - 1] = ok[i].second ? 'R' : 'B';
  }
  int rcnt = 0;
  for (int i = 0; i < 2 * n; i++) if (ans[i] == 'R') rcnt++;
  if (rcnt != n) {
    exit(1);
  }
  cout << "! ";
  for (int i = 0; i < 2 * n; i++) cout << ans[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 724
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
vector<ll> sum_ab;
vector<ll> a;
vector<ll> b;
vector<ll> c;
ll x,y,z,k;
bool check(ll mid){
	ll cnt = 0;
	for(int i = 0;i < z;i++){
		cnt += sum_ab.end() - lower_bound(sum_ab.begin(),sum_ab.end(),mid-c[i]);
	}
	if(cnt >= k)return true;
	else return false;
}
int main(){
	cin >> x >> y >> z >> k;
	a.resize(x);
	b.resize(y);
	c.resize(z);
	for(ll i = 0;i < x;i++)cin >> a[i];
	for(ll i = 0;i < y;i++)cin >> b[i];
	for(ll i = 0;i < z;i++)cin >> c[i];

	for(ll i = 0;i < x;i++){
		for(ll j = 0;j < y;j++){
			sum_ab.push_back(a[i]+b[j]);
		}
	}

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

	ll ok = 0, ng = 1e18;
	while(ng - ok > 1){
		ll mid = (ok + ng) / 2;
		if(check(mid)){
			ok = mid;
		}
		else ng = mid;
	}

	vector<ll> ans;
	for(ll i = 0;i < z;i++){
		for(ll j = x * y - 1;j >= 0;j--){
			if(c[i] + sum_ab[j] <= ok)break;
			else ans.push_back(c[i]+sum_ab[j]);
		}
	}

	sort(ans.begin(),ans.end(),greater<ll>());
	ll sz = (ll)ans.size();
	for(ll i = 0;i < sz;i++){
		cout << ans[i] << endl;
	}
	for(ll i = 0;i < k - sz;i++)cout << ok << endl;

}


Measured memory_bytes: 10224
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=2000005;
char s[N],t[N];
int n,a,b,ans;

int main(){
	read(n);
	scanf("%s",s+1);
	a=strlen(s+1);
	scanf("%s",t+1);
	b=strlen(t+1);
	n=max(n,max(a,b));
	ans=max(n,a+b);
	rep(i,max(0,n-b),a-1){
		int flag=1;
		for(int x=i+1,y=1;x<=a&&y<=b;x++,y++)	
			if(s[x]!=t[y]){
				flag=0;
				break;
			}
		if(flag)ans=min(ans,i+b);
	}
	cout<<ans<<endl;
	return 0;
}

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

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

    if(n % 2 == 1){
        cout << 0 << endl;
    }else{
        ll ans = 0;
        for(ll i=1; pow(5, i) <= n; i++){
            ll k = pow(5, i) * 2;
            ans += n / k;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        while(true) {
            string inpt = Reader.ReadLine();
            if(inpt == null || inpt.Equals("0")) {
                break;
            }
            ans.AppendLine(inpt.Select(a=>int.Parse(a.ToString())).Sum().ToString());
        }
        Console.Write(ans.ToString());
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


123
55
1000
0


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9500
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])cout << "Yes";
	else cout << "No";
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    ll a;
    cin >> a;

    ll diff = numeric_limits<ll>::max();
    for(ll i = 1; i * i <= a; i++){
        if(a % i == 0){
            ll s = a / i;
            diff = min(diff, (i - 1 + s - 1));
        }
    }
    cout << diff;

}










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

using namespace std;

const int N=505;

int n,m;
char s[N][N];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char c=s[i][j];
			if(j<m&&(i%2==1||j==1))c='#';
			putchar(c);
		}
		puts(" ");
	}
	puts("");
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char c=s[i][j];
			if(j>1&&(i%2==0||j==m))c='#';
			putchar(c);
		}
		puts(" ");
	}
	return 0;
}

Measured memory_bytes: 1024
/*
 * Matheus Oliveira
 * 23:56:23 10/04/2019
 * nada.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN 100010
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, ini, fim) printf("%s: ", #x); for(int i = ini; i <= fim; i++) printf("%d%c", x[i], (i == fim) ? '\n' : ' ');
typedef long long ll;
typedef pair<int, int> pii;

const ll mod = 1000000000 + 7;

int freq[30];
char inp[MAXN];

ll mul(ll a, ll b) {
	return ((a%mod) * (b%mod))%mod;
}

ll fastExpo(ll n, ll e) {
	if(e == 0) return 1LL;
	if(e == 1LL) return n%mod;
	if(e&1) return mul(n, fastExpo(n, e-1));
	ll aux = fastExpo(n, e/2);
	return mul(aux, aux);
}

int main() {
	int n;

	scanf("%d", &n);
	getchar();
	
	scanf("%s", inp);
	for(int i = 0; i < n; i++) freq[ inp[i] - 'a' ]++;

	ll ans = 1;
	for(int i = 0; i < 30; i++) {
		if(freq[i] == 0) continue;
		ans = mul(ans, freq[i] + 1);
	} 

	printf("%lld\n", ((ans - 1LL) + mod)%mod);
	return 0;
}


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

unsigned long long int ret;
bool check = false;

void solve(vector<unsigned long long int> T, int ize, unsigned long long int find, unsigned long long int how){
	unsigned long long int miru = find * how;
	if(check == true) return;
	for(int i = ize; i >= 0; i --){
		if(miru % T[i] == 0){
			if(i == 0){
				ret = miru;
				check = true;
				return ;
			}
		}else {
			if(check == true)return ;
			else solve(T, ize, find, how + 1);
			return ;
		}
	}
}

int main(){
	// int N;
	// vector<unsigned long long int> T;
	// cin >> N;
	// unsigned long long int in;
	// for(int i = 0; i < N; i++){
	// 	cin >> in;
	// 	T.push_back(in);
	// }
	// sort(T.begin(), T.end());
	// if(T.size() == 1)cout << T[0] << endl;
	// else{solve(T, T.size() - 1, T[T.size() - 1], 1);
	// 	cout << ret << endl;
	// }
	int red, green, blue;
	cin >> red >> green >> blue;
	int sum = red * 100 + green * 10 + blue;
	if(sum % 4 == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << min(x * y, z) << endl;


    return 0;
}


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

int main() {
  int n,k;
  string ans;

  cin >> n >> k;

  vector<int> a(n,0);

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

  for(int i=0;i<n-k;i++) {
    if(a[i]<a[i+k]) {ans="Yes";}
    else {ans="No";}
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4056
use std::io;

fn main() {
     print!("{}", execute(from_stdin()));
}

fn execute(s: String) -> String {
    s.replace("?", "D")
}

fn from_stdin() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim_end().to_owned()
}

#[test]
fn test_execute() {
    assert_eq!(execute("PD?D??P".to_owned()), "PDDDDDP");
    assert_eq!(execute("P?P?".to_owned()), "PDPD");
}


Measured memory_bytes: 2412
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace ABC134
{
    class Program4
    {
        static void Main()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var b = new byte[N];
            var m = 0;

            for (int i = N; i >= 1; i--)
            {
                for (int j = i * 2; j <= N; j += i)
                {
                    a[i - 1] += b[j - 1];
                    a[i - 1] %= 2;
                }

                b[i - 1] = (byte)a[i - 1];
                if (b[i - 1] == 1)
                    m++;
            }

            Console.WriteLine(m);
            var needSpace = false;
            for (int i = 0; i < N; i++)
            {
                if (needSpace)
                    Console.Write(' ');
                if (b[i] == 1)
                {
                    Console.Write(i + 1);
                    needSpace = true;
                }
            }
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 30552
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 1000000000000
#define mod 998244353
vec costdp;
vec height;
ll n;
ll func(ll ind) {
	if(ind > n - 1)
		return inf;
	if(costdp[ind] != -1)
		return costdp[ind];
	if(ind == n - 1)
		return 0;
	ll res = min(func(ind+1) + abs(height[ind+1]-height[ind]),func(ind+2) + abs(height[ind+2]-height[ind]));
	return costdp[ind] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	height.resize(n);
	ll i;
	costdp.resize(n,-1);
	for(i = 0; i < n ; i++) cin >> height[i];
	cout << func(0);
	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int a,b,n;
	while(~scanf("%d %d %d",&a,&b,&n))
	{
		if(a+b>=n) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 998244353;
ll n,a,b,k;
ll fac[300005];
ll add(ll x, ll y) {
    return ((x+y)%mod + mod)%mod;
}
ll mul(ll x, ll y) {
    return ((x*y)%mod + mod)%mod;
}
ll inv(ll x, ll y) {
    return 1<x ? y - inv(y%x,x)*y/x : 1;
}
ll get(ll x, ll y) {
    return mul(fac[x], mul(inv(fac[x-y], mod), inv(fac[y], mod)));
}
int main() {
    scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
    fac[0] = 1;
    for(ll i=1;i<=n;i++) fac[i] = mul(fac[i-1], i);
    ll res = 0;
    for(ll k1=0;k1<=n;k1++) {
        ll k2 = (k-k1*a)/b;
        if(k2<0 || k2>n || k1*a+k2*b!=k) continue;
//        printf("%lld %lld : %lld %lld\n",k1,k2,get(n,k1),get(n,k2));
        res = add(res, mul(get(n,k1), get(n,k2)));
    }
    printf("%lld",res);
}


Measured memory_bytes: 2688
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        io.r<int>();
        long[] n = io.r<long>(' ');
        io.w(n.Min() + " " + n.Max() + " " + n.Sum());
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 11352
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool ng[700];
lint dp[110][700];
string tmp="XAGCT";
bool ch2(string a){
	rep(i,a.size()-2){
		if(a.substr(i,3)=="AGC") return true;
	}
	return false;
}
bool ch(string a){
	if(ch2(a)) return true;
	rep(i,a.size()-1){
		swap(a[i],a[i+1]);
		if(ch2(a)) return true;
		swap(a[i],a[i+1]);
	}
	return false;
}
int main()
{
	int n;cin>>n;lint out=0,mo=1000000007;
	rep(i,625){
		string s="";int x=i;
		rep(j,4){
			s+=tmp[x%5];x/=5;
		}
		reverse(All(s));
		ng[i]=ch(s);
	}
	memset(dp,0,sizeof(dp));dp[0][0]=1;
	rep(i,n) rep(j,625) REP(k,1,5){
		if(ng[j]) continue;
		dp[i+1][(j*5+k)%625]+=dp[i][j];
		dp[i+1][(j*5+k)%625]%=mo;
	}
	rep(i,625){
		if(ng[i]) continue;
		out+=dp[n][i];
		out%=mo;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    ll N,K;
    cin>>N>>K;
    if(K==0){
        cout<<N*N<<endl;
        return 0;
    }
    ll ans=0;
    for(int b=1;b<=N;++b){
        if(b-1<K) continue;
        ll maxs=N/b;
        ans+=maxs*(b-K);
        ll maxt= N-maxs*b;
        ans+=max(maxt-K+1,0LL);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

sum_A = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
    sum_A[i] = sum_A[i - 1] + A[i - 1]

ans = float('inf')
for i in range(1, n):
    ans = min(abs(sum_A[i] - (sum_A[-1] - sum_A[i])), ans)
print(ans)

Measured memory_bytes: 30700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin>>n>>m;
  int ans=0;
  for(int i=0;i<n;++i){
    int s=0;
    for(int j=0;j<m;++j){
      int a; cin>>a;
      s+=a;
    }
    ans = max(ans, s);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3076