akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (auto&& e : s) {
    cin >> e;
  }
  vector< vector<int> > a(h, vector<int>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '#') {
        a[i][j] = k--;
      }
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 1; j < w; ++j) {
      if (a[i][j] == 0) {
        a[i][j] = a[i][j - 1];
      }
    }
    for (int j = w - 2; j >= 0; --j) {
      if (a[i][j] == 0) {
        a[i][j] = a[i][j + 1];
      }
    }
  }
  for (int j = 0; j < w; ++j) {
    for (int i = 1; i < h; ++i) {
      if (a[i][j] == 0) {
        a[i][j] = a[i - 1][j];
      }
    }
    for (int i = h - 2; i >= 0; --i) {
      if (a[i][j] == 0) {
        a[i][j] = a[i + 1][j];
      }
    }
  }
  for (const auto& v : a) {
    for (int j = 0; j < w; ++j) {
      cout << v[j] << " \n"[j == w - 1];
    }
  }
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int pos, n;

vector <int> post, in, pre;
void rec(int left,int right)
{
	if(left >= right)
	{
		return ;
	}
	int root = pre[pos++];
	int m = distance(in.begin(),find(in.begin(),in.end(),root));
	rec(left,m);
	rec(m + 1,right);
	post.push_back(root);
}

void solve()
{
	pos = 0;
	rec(0,pre.size());
	int i;
	for(i = 0; i < n; i++)
	{
		if(i)
		{
			cout << " "; 
		}
		cout << post[i];
	}
	cout << endl;
}

int main()
{
	cin >> n;
	int k;
	for(int i = 0; i < n; i++)
	{
		cin >> k;
		pre.push_back(k);
	}
	for(int i = 0; i < n; i++)
	{
		cin >> k;
		in.push_back(k);
	}
	
	solve();
	
	return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,i,t;
  cin>>n>>m;
  t=m-1;
  int mn,mx,l,r;
  cin>>l>>r;
  mn=r;
  mx=l;
  while(t--)
  {
    cin>>l>>r;
    mx=max(mx,l);
    mn=min(mn,r);
  }
  if(mn>=mx) cout<<(mn-mx)+1;
  else cout<<0;
  return 0; 
}

Measured memory_bytes: 256
def main():
    N, Y = map(int, input().split())

    for i in range(N + 1):
        for j in range(N - i + 1):
            k = N - i - j
            total = 10000 * i + 5000 * j + 1000 * k
            if total == Y:
                print(i,j,k)
                exit()
    print(-1,-1,-1)
main()

Measured memory_bytes: 38896
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;

}


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

int main() {
  int A, B;
  int sum = 0;
  int diff = 0;
  cin >> A >> B;
  diff = B - A;
  
  for (int i = 0; i < diff + 1; i++){
	if ((A / 10000) % 10 == A % 10 && (A / 1000) % 10 == (A / 10) % 10){
      sum++;
    }
    A++;
  }
  cout << sum << endl;
}

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

int n,k,x;
bool arr[10];

bool check(int n)
{
    while(n)
    {
        if(arr[n%10])
            return 0;
        n /= 10;
    }
    return 1;
}

int main()
{
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        for(int i=0;i<k;i++)
        {
            scanf("%d",&x);
            arr[x] = 1;
        }
        for(int i=n;;i++)
        {
            if(check(i))
            {
                printf("%d\n",i);
                break;
            }
        }
    }
return 0;
}

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

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

    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}

Measured memory_bytes: 3652
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
 
if b-a <= k && c-a <= k && d-a <= k && e-a <= k &&
   c-b <= k && d-b <= k && e-b <= k &&
   d-c <= k && e-c <= k &&
   e-d <= k
   puts "Yay!"
else
   puts ":("
end


Measured memory_bytes: 1788
#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n;
	cin >> n;
	int m = 2;
	while(1){
		int t = m * (m - 1) / 2;
		if(t < n){
			m++;
		}else if(t == n){
			break;
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
	vector<vector<int>> a(m, vector<int>());
	int cnt = 1;
	for(int i = 0; i < m - 1; i++){
		for(int j = 0; j <= i; j++){
			a[i].emplace_back(cnt);
			if(i > j){
				a[j].emplace_back(cnt);
			}else if(i == j){
				a[m - 1].emplace_back(cnt);
			}
			cnt++;
		}
	}
	cout << "Yes" << endl;
	cout << m << endl;
	for(int i = 0; i < m; i++){
		cout << m - 1 << " ";
		for(int j = 0; j < m - 1; j++){
			cout << a[i][j];
			if(j < m - 1){
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,m;
  string s;

  
  cin>>n>>m>>s;
  s[m-1]+=32;
  cout<<s<<endl;
  return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if (a > b) cout << "a > b" << endl;
    else if (a < b) cout << "a < b" << endl;
    else cout << "a == b" << endl;
}


Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>

using std::cin;
using std::cout;
using std::endl;

using std::vector;
using std::set;

using std::min;

int main(void) {
    long A, B, C, D;
    long E, F;
    cin >> A >> B >> C >> D >> E >> F;

    set<long> water_set;
    for (long a = 0; a <= F; a += 100 * A) {
        for (long b = 0; a + b <= F; b += 100 * B) {
            water_set.insert(a + b);
        }
    }

    long opt_water = 0;
    long opt_sugar = 0;
    for (long water : water_set) {
        const long limit = min(F - water, E * (water / 100));
        for (long c = 0; c <= limit; c += C) {
            for (long d = 0; c + d <= limit; d += D) {
                long sugar = c + d;
                if(sugar * (opt_sugar + opt_water) >= opt_sugar * (sugar + water)){
                    opt_sugar = sugar;
                    opt_water = water;
                }
            }
        }
    }

    cout << (opt_sugar + opt_water) << " " << opt_sugar << endl;

    return 0;
}


Measured memory_bytes: 256
import queue
n,k = map(int,input().split())

ab = [[] for j in range(n+1)]
mod = 10**9 + 7

for i in range(n-1):
    a,b = map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
    
check = [False] * (n+1)
kazu = [0] * (n+1)

check[0] = True

q = queue.Queue()
q.put(1)

ans = k
#print(ab)

while not q.empty():
    tmp = q.get()
    check[tmp] = True
    kake = 0
    for i in range(len(ab[tmp])):
        if check[ab[tmp][i]] == True:
            continue
        kazu[ab[tmp][i]] += 1
        q.put(ab[tmp][i])
        ans *= k - kake - kazu[tmp] - 1
        ans %= mod
        #print(i,k,ans,tmp,kazu[tmp])
        kake += 1
    
print(ans)

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

#define INF 1145141919
using LL = long long int;
#define II pair<int, int>

using namespace std;

int main()
{
  string S;
  cin >> S;
  if(S.find("AC") != string::npos) {
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
string s;
int main()
{
	cin>>s;
	int n=s.length()-1;
	if(n%2==0)
		if(s[0]==s[n])cout<<"Second\n";
		else cout<<"First\n";
	else
	{
		if(s[0]==s[n])cout<<"First\n";
		else cout<<"Second\n";
	}
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string.h>

using namespace std;

int main(){
	char kata1[10];
	char kata2[10] = "ABC";
	cin >> kata1;
	if(strcmp(kata1,kata2) == 0){
		cout << "ARC "<< endl;
	}else{
		cout << "ABC"<< endl;
	}
	
	return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ll tn = N / i * i;
    ans += (i + tn) * (tn / i) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
main(){
  long long a,b,c,d;cin >> a >> b >> c >> d;
  long long e=b*d;
  long long f=b*c;
  long long g=a*d;
  long long h=a*c;
  cout << max(max(e,f),max(g,h)) << endl;
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b,c;
    cin >> a>>b>>c;
    if(c >= a && c <= b)
        cout << "Yes" <<endl;
    else
        cout << "No"<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int N, C[500][3], t = 0, ans[500] = {0};

void m(int i)
{
	int f = 0;
	for (; i < N; i++) {
		ans[i] -= t;

		if (i == N - 1)break;

		if (f == 0) {
			t += C[i][1];
			t += C[i][0];
			f = 1;
			continue;
		}

		if (t < C[i][1]) {
			t += C[i][1] - t;
		}

		if (t % C[i][2] == 0) {
			t += C[i][0];
		}
		else {
			t += C[i][2] - t % C[i][2];
			t += C[i][0];
		}
	}
}

int main()
{
	cin >> N;

	for (int i = 0; i < N-1; i++)
		scanf("%d %d %d", &C[i][0], &C[i][1], &C[i][2]);

	for (int i = 0; i < N; i++) {
		m(i);
		ans[i] = t;
		t = 0;
	}

	ans[N - 1] = 0;

	for (int i = 0; i < N; i++)
		cout << ans[i]+t << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int n, a[100][100], i, j;
   scanf("%d", &n);
   while ( n != 0 ) {
      for ( i = 1; i <= n; i++ ) {
         for ( j = 1; j <= n; j++ ) {
            scanf("%d", &a[i][j]);
            a[i][n + 1] += a[i][j];
            a[n + 1][j] += a[i][j];
         }
      }
      for ( i = 1; i <= n; i++ ) {
         a[n + 1][n + 1] += a[n + 1][i];
      }
      for ( i = 1; i <= n + 1; i++ ) {
         for ( j = 1; j <= n; j++ ) {
            printf("%5d", a[i][j]);
            a[i][j] = 0;
         }
         printf("%5d\n", a[i][j]);
         a[i][j] = 0;
      }
      scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1696
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[200010];
int S[200010];
int main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		//A[i] = 0;
	}
	for (int i = 0; i < K; i++) {
		for (int j = 0; j <= N; j++) S[j] = 0;
		bool out = true;
		for (int j = 0; j < N; j++) {
			S[max(0, j - A[j])]++;
			S[min(N + 2, j + A[j] + 1)]--;
		}
		int sum = S[0];
		A[0] = sum;
		for (int j = 1; j < N; j++) {
			sum += S[j];
			A[j] = sum;
			if (A[j] != N) out = false;
		}
		/*for (int j = 0; j < N; j++) {
			cout << A[j] << " ";
		}
		cout << endl;*/
		if (out) break;
	}
	for (int i = 0; i < N; i++) {
		cout << A[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 25;

char A[N][N];
int dis[N][N];

int dx[] = {1, 0 , -1 , 0};
int dy[] = {0 , -1 , 0 , 1};
int n , m;
void init(){
	for(int i = 1;i <= n; ++i){
		for(int j = 1;j <= m; ++j){
			dis[i][j] = 1000;
		}
	}
}
int bfs(int i , int j){
	init();
	queue<pii> Q;
	dis[i][j] = 0;
	Q.push(mp(i, j));
	int mx = 0;
	while(Q.size()){
		pii z = Q.front();
		mx = max(mx , dis[z.F][z.S]);
		Q.pop();
		for(int i = 0;i < 4 ; ++i){
			if(z.F+dx[i] > n || z.F+dx[i] <= 0 || z.S+dy[i] > m || z.S+dy[i] <= 0)
				continue;
			if(A[z.F+dx[i]][z.S+dy[i]] == '#')
				continue;
			if(dis[z.F+dx[i]][z.S+dy[i]] > dis[z.F][z.S] + 1){
				dis[z.F+dx[i]][z.S+dy[i]] = dis[z.F][z.S]+1;
				Q.push(mp(z.F+dx[i] , z.S+dy[i]));
			}
		}
	}
	return mx;
}

int main(){
	fio; cout<<fixed<<setprecision(25);	
	
	cin >> n >> m;
	for(int i = 1;i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			cin >> A[i][j];
			dis[i][j] = 1000;
		}
	}
	int mx = 0;

	for(int i = 1;i <= n ; ++i){
		for(int j =1 ;j <= m; ++j){
			if(A[i][j] == '#') continue;
			mx = max(mx , bfs(i , j));
		}


	}
	cout << mx << endl;
	












	return 0;
}


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

//Farey Sequence
public class Main{

	int[] eulerPhiTable(int n){
		int[] res = new int[n+1];
		boolean[] p = new boolean[n+1];
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		for(int i=0;i<=n;i++)res[i]=i;
		for(int i=2;i<=n;i++)if(p[i]){
			res[i]-=res[i]/i;
			for(int j=i+i;j<=n;j+=i){
				p[j] = false;
				res[j]-=res[j]/i;
			}
		}
		return res;
	}
	
	void run(){
		int N = 1000000;
		int[] f = eulerPhiTable(N);
		long[] res = new long[N+1];
		res[1] = 2;
		for(int i=2;i<=N;i++)res[i]=res[i-1]+f[i];
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0)System.out.println(res[sc.nextInt()]);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 24000
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] div = new int[n+1];
        for(int i = 2; i <= n; i++){
            int now = i;
            for(int j = 2; j <= i; j++){
                while(now % j == 0){
                    div[j]++;
                    now /= j;
                }
            }
        }
        int[] cnt = new int[101];
        for(int d : div){
            for(int i = 0; i <= d+1; i++){
                cnt[i]++;
            }
        }
        System.out.println(cnt[75] + cnt[25] * (cnt[3] - 1) + cnt[15] * (cnt[5] - 1) + cnt[5] * (cnt[5] - 1) * (cnt[3] - 2) / 2);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int f[26]={0};
    for(int i=0;i<s.length();i++)
    {
        f[s[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
        if(f[i]>0&&f[i]%2==1)
        {cout<<"No";return 0;}
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}


//modの値の確認をすること
int main(){
    ll n,ans = 0;
    cin >> n;
    vector<ll> a(0);
    for(ll i = 1; i * i <= n; ++i)if(n % 1 == 0){a.push_back(i - 1);a.push_back(n / i - 1);}
    rep0(i, a.size())if(a[i] != 0)if(n % a[i] == n / a[i])ans += a[i];
    pf(ans);
    return 0;
}


Measured memory_bytes: 18536
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string S;
typedef pair<bool, int> P;
set<string> St;
bool DP[30005][11][11];

void dfs(int idx, char a, char b, char c) {
  if (idx==N) return;
  int _a = a=='n'?10:a-'0';
  int _b = b=='n'?10:b-'0';
  if (DP[idx][_a][_b]) return;
  rep(i, 2) {
    if (i==0) {
      dfs(idx+1, a,b,c);
      DP[idx][_a][_b] = true;
    } else {
      if (a=='n') {
        a = S[idx];
        dfs(idx+1, a, 'n', 'n');
        DP[idx][_a][10] =true;
      } else if (b=='n') {
        b = S[idx];
        dfs(idx+1, a, b, 'n');
        DP[idx][_a][_b]=true;
      } else if (c=='n') {
        c = S[idx];
        string d = "";
        d+=a;d+=b;d+=c;
        St.insert(d);
      }
    }
  }
  return;
}

int main() {
  INCANT;
  cin >> N >> S;
  dfs(0, 'n', 'n', 'n');
  cout << St.size() << "\n";
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b;
	cin>>a>>b;
	if(a==1) a=14;
	if(b==1) b=14;
	if(a==b) cout<<"Draw\n";
	else cout<<(a<b?"Bob\n":"Alice\n");
}




Measured memory_bytes: 3652
def main():
    x = list(map(int, input().split()))
    counter = 0

    while x[0] % 2 == 0 and x[1] % 2 == 0 and x[2] % 2 == 0:
        if x[0] == x[1] and x[1] == x[2] and x[2] == x[0]:
            counter = -1
            break
        share_0 = x[0] / 2
        share_1 = x[1] / 2
        share_2 = x[2] / 2
        x[0] = share_1 + share_2
        x[1] = share_0 + share_2
        x[2] = share_0 + share_1
        counter += 1

    print(counter)


if __name__ == "__main__":
    main()

Measured memory_bytes: 62152
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	string S, T;
	cin >> S >> T;
	cout << T << S << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define LEN 100000

typedef struct{
  char name[15];
  int time;
}P;

int main(){
	int i=0,n,t,cnt=0,check=0,new_n,q=0;
	P N[LEN];
	
	scanf("%d %d",&n,&t);
	new_n=n;
	for(int i=0;i<n;i++){
		scanf("%s",N[i].name);
		scanf("%d",&N[i].time);
	}
	
	
	while(check<n){
		if(N[i].time==0){
			;
		}else if(0<N[i].time && N[i].time<=t){
			cnt=cnt+N[i].time;
			N[i].time=0;
			printf("%s %d\n",N[i].name,cnt);
			check++;
			q++;
		}else{
			cnt=cnt+t;
			N[i-q].time=N[i].time-t;
			strcpy(N[i-q].name,N[i].name);
		}
		
		if(i==new_n-1){
			i=0;
			new_n=new_n-q;
			q=0;
		}else{
			i++;
		}
	}
	

  return 0;
}


Measured memory_bytes: 2824
use std::io;
use std::collections::HashMap;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let s = iter.next().unwrap().to_string();
	let t = iter.next().unwrap().to_string();
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let a:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let b:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let u = buf.trim().to_string();
	
	let mut map = HashMap::new();
	map.insert(&s, a);
	map.insert(&t, b);
	if s == u {
		map.insert(&&u, a-1);
	}
	if t == u {
		map.insert(&&u, b-1);
	}
	
	println!("{} {}", map.get(&s).unwrap(), map.get(&t).unwrap());
}

Measured memory_bytes: 4352
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

string S;

int check(int K){
    if(SZ(S)<K)
        return false;
    char c=S[SZ(S)-K];
    FOR(i,SZ(S)-K,K)
        if(S[i]!=c)
            return false;
    return true;
}

int main(void){
    cin>>S;
    int ma=SZ(S)+1,mi=1;
    while(1<ma-mi){
        int md=(ma+mi)/2;
        if(check(md))
            mi=md;
        else
            ma=md;
    }
    if(check(ma))
        cout<<ma<<endl;
    else
        cout<<mi<<endl;
     return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define repl(i, l, r) for (int i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
const int MAX = 1000005;
int n, P[MAX], Q[MAX];
int main() {
	scanf("%d", &n);
	int a[n];
	rep(i, n) {
		scanf("%d", a + i);
		Q[a[i]]++;
	}
	sort(a, a + n);
	int ans = 0;
	rep(i, n) {
		if (P[a[i]]) continue;
		if (Q[a[i]] == 1) ans++;
		for (int j = a[i]; j < MAX; j += a[i]) P[j] = 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 12356
#include<stdio.h>

int depth(int node,int d[]){
	return d[node];
}
void search(int i, int depth,int d[], int mark[], int b[]){
	d[i] = depth;
	int index = mark[i];
	int count = b[index]; // nuber of children
	for(int j = 0; j < count; j++){
		search(b[index+1+j],depth+1,d,mark,b);
	}
}
void pre_process(int d[], int n,int a[],int mark[],int b[]){
	int parent;
	for(int i = 0; i<n; i++){
		if(a[i] == -1){
			parent = i; break;
		}
	}
	//printf("%d\n",parent);
	d[parent] = 0;
	search(parent,0,d,mark,b);
}
void check_type(int a[],int type[], int node,int n){
	int tag = 0;//0: leaf, 1: internal
	if(a[node]==-1) printf("root, ");
	else{
		if(type[node]==2)printf("internal node, ");
		else printf("leaf, ");
	}	
}

void check_children(int b[], int mark[], int node,int n){
	int index = mark[node]; //
	int count = b[index]; //how many children
	printf("[");
	for(int i = 0; i<count-1; i++){
		printf("%d, ",b[index+i+1]);
	}
	if(count!=0)
	printf("%d]",b[index+count]);
	else printf("]");
}
int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	int b[200001];
	int d[n];
	int type[n];
	for(int i = 0; i<n; i++){
		a[i] = -1;
		d[i] = -1;
		type[i] = 2; // 0: root, 1: leaf, 2: internal
	}
	int index = 0;
	int mark[n];
	for(int i = 0; i<n; i++){
		int parent;
		scanf("%d",&parent);
		int k;
		scanf("%d",&k); //unmber of children
		if(k==0) type[parent] = 1;//leaf
		mark[parent] = index;
		b[index++] = k;
		int child;
		for(int j = 0; j<k; j++){
			scanf("%d",&child);
			b[index++] = child;
			a[child] = parent;
		}
	}
	pre_process(d, n,a,mark,b);
	//print
	for(int i = 0; i<n; i++){
		printf("node %d: parent = %d, depth = %d, ",i,a[i],depth(i,d));
		check_type(a,type,i,n);
		check_children(b,mark,i,n);
		printf("\n");	
	}
	return 0;
}


Measured memory_bytes: 5060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if(a > 0) {
			System.out.println("Positive");
			return;
		}else if(a <= 0 && b >= 0) {
			System.out.println("Zero");
			return;
		}else {
			int cnt = -a - (-b)+1;
			if(cnt%2==0) {
				System.out.println("Positive");
			}else {
				System.out.println("Negative");
			}
		}
	}
}

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

#define jaldi ios_base::sync_with_stdio(false)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define all(x) x.begin(),x.end()
#define mod 1000000007

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}
ll root(ll a,vll &head)
{
    while(a!=head[a])
    {
        head[a]=head[head[a]];
        a=head[a];
    }
    return a;
}
void merge(ll a,ll b,vll &head, vll &size)
{
    ll p_a = root(a,head);
    ll p_b = root(b,head);
    if(p_a==p_b)
        return;
    
    if(size[p_a]>size[p_b])
    {
        size[p_a]+=size[p_b];
        head[p_b]=head[p_a];
    }
    else
    {
        size[p_b]+=size[p_a];
        head[p_a]=head[p_b];
    }
    
}

int main()
{
    jaldi;
    precision(20);
    ll i,j;
    ll t;
    t=1;
    // cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<a*b;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int cnt = 0;
  int n,x;
  cin >> n >> x;
  int k = 0;
  REP(i,n) {
    int d;
    cin >> d;
    cnt += (k <= x);
    k += d;
  }
  cnt += (k <= x);
  cout << cnt << endl;
}

int main(int argc, char *argv[]){

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

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

char result[100000];

void calculation(int multi){
    int carry=0,i,j=0;
    for(i=0;result[i]!=NULL;i++){
        carry+=(result[i]-48) * multi;
        result[j++]=(carry % 10) + 48;
        carry/=10;
    }
    while(carry){
        result[j++]=(carry % 10) + 48;
        carry/=10;
    }
    result[j]=NULL;
}

int main(){
    int i,input_number,multiplier,fact;

    scanf("%d",&input_number);
        result[0]=52;
        result[1]=50;
        result[2]=NULL;
        if(1<=input_number&&input_number<=4){
            fact=1;
            for(i=1;i<=input_number;i++){
                fact*=i;
            }
            printf("%d\n",fact);
        }

        else if(input_number==0)
            printf("1");

        else{
        for(i=5;i<=input_number;i++){
            multiplier=i;
            calculation(multiplier);
        }
        int con=strlen(result);
        for(i=con-1;i>=0;i--){
            printf("%c",result[i]);
        }
        printf("\n");


        }
    return 0;
}

Measured memory_bytes: 992
from collections import Counter

n = int(input())
d = list(map(int, input().split()))

count = Counter(d)

if d[0] != 0:
    print(0)
    


#print(count[0])
#print(len(count))
#print(count.keys())
#print(count.items())
elif count[0] != 1:
    print(0)
    
else:
    ans = 1
    tmp = 1
    max_d = max(d)
    for i in range(1, max_d+1):
        
        ans *= tmp**count[i]
        #print(ans)
        tmp = count[i]


    print(ans%998244353)



Measured memory_bytes: 19936
#include <stdio.h>

int main(void){

  int a, b;
  int n;

  scanf("%d", &n);

  if (n == 1){
    printf("Hello World\n");
  }else{
    scanf("%d\n%d", &a, &b);
    printf("%d", a + b);
  }

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N), Y(N), H(N);
    int x, y, h;
    REP(i, N) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] > 0) {
            x = X[i], y = Y[i], h = H[i];
        }
    }
    REP(cx, 101) {
        REP(cy, 101) {
            bool f = true;
            int A = h + abs(x - cx) + abs(y - cy);
            for (int i = 0; i < N && f; i++) {
                int d = abs(X[i] - cx) + abs(Y[i] - cy);
                if (H[i] > 0) {
                    f = H[i] + d == A;
                } else {
                    f = A <= d;
                }
            }
            if (f) {
                cout << cx << " " << cy << " " << A << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>

int main() {
	int n, k;

	std::cin >> n >> k;

	if (k != 1) {
		n -= k;
	}
	else {
		n = 0;
	}

	std::cout << n << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,count =1;
  string s;
  cin >> n >> s;
  for(int i=0;i<n-1;i++){
    if(s.at(i) != s.at(i+1)){
      count ++;
    }
  }
  printf("%d\n",count);
}
      
    

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

typedef long long ll;

struct str
{
    ll i,y,p;
};
bool operator<(str a,str b)
{
    if(a.p==b.p)return a.y<b.y;
    return a.p<b.p;
}

string make(ll n)
{

    string st,st1;
    while(n!=0)
    {
        int a=n%10;
        st.push_back(a+48);
        n/=10;
    }
    reverse(st.begin(),st.end());
    int i,diff=6-st.size();
    for(i=0; i<diff; i++)st1.push_back('0');
    for(i=0; i<st.size(); i++)st1.push_back(st[i]);
    return st1;
}

int main()
{

    ll n,a,b,m,i,c,y,p,pos;
    vector<str>v;
    string st[100007];
    cin >> n >> m;
    for(i=0; i<m; i++)
    {
        cin >> a >> b;
        v.push_back({i+1,b,a});
    }
    sort(v.begin(),v.end());
    map<int,int>mp;
    for(i=0; i<v.size(); i++)
    {
        pos=v[i].i;
        p=v[i].p;
        y=v[i].y;
        mp[p]++;
        a=mp[p];
        st[pos]=make(p)+make(a);
    }
    for(i=1; i<=m; i++)cout << st[i] << "\n";



    return 0;
}



Measured memory_bytes: 15600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();
        int K = sc.nextInt();

        /**
         * i桁目まで決めて
         * j個の非0をつかって
         * 0: 底までの桁はNと一致
         * 1: そこまでの桁ですでにN(与えられた値)以下であることが確定
         */

        /**
         * 最初のとき
         * i=0桁目は1桁も決めてない状態のこと
         * 数字がないのでj=0
         * この時k=0
         */

        /**
         * 配るDP: 遷移もとから次を考える
         * もらうDP: 遷移先に注目して考える。
         * 今回は次の状態を考えやすいので配るDP
         * 背反な場合の数を足し合わせるイメージ
         */


        int[][][] dp = new int[105][4][2];

        dp[0][0][0] = 1; //初期状態

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 2; k++) {
                    int nd = Integer.parseInt(String.valueOf(S.charAt(i)));
                    for (int d = 0; d < 10; d++) {
                        int ni = i + 1, nj = j, nk = k;
                        if (d != 0) nj++;
                        if(nj > K) continue;
                        if(k == 0) {
                            if (d > nd) continue;
                            if (d < nd) nk = 1;
                        }
                        dp[ni][nj][nk] += dp[i][j][k];
                    }
                }
            }
        }
//
//        for (int i = 0; i < N + 1; i++) {
//            for (int j = 0; j < 4; j++) {
//                System.out.print(dp[i][j][0]+ " ");
//            }
//            System.out.println();
//        }
//        System.out.println();
//        for (int i = 0; i < N + 1 ; i++) {
//            for (int j = 0; j < 4; j++) {
//                System.out.print(dp[i][j][1]+ " ");
//            }
//            System.out.println();
//        }

        int ans = dp[N][K][0] + dp[N][K][1];
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, K = 40, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

int n, ans, k;
ll t, dp[K], b[N];
pll a[N]; 
bool cmp(pll x, pll y){
	return x.s * (y.f - 1) < y.s * (x.f - 1);
}
int main()
{
	scanf("%d%lld", &n, &t);
	for(int i = 0; i < n; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		a[i].f = x + 1;
		a[i].s = x + y + 1;
	}
	dp[0] = 0;
	for(int i = 1; i < K; i++)
		dp[i] = t + 100;
	sort(a, a + n, cmp);
	for(int i = 0; i < n; i++){
		if(a[i].f == 1){
			b[k++] = a[i].s;
		}else{
			for(int j = K - 1; j > 0; j--)
				dp[j] = min(dp[j], dp[j - 1] * a[i].f + a[i].s);					
		}
	}
	sort(b, b + k);
	for(int j = 0; j < K; j++){
		ll cur = dp[j];
		for(int i = 0; i <= k; i++){
			if(cur <= t)
				ans = max(ans, j + i);
			if(i < k)
				cur += b[i];		
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 4992
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    static int N;
    static double[][][] dp;
    static boolean[][][] flag;

    public static void main(String[] args) {
        N = in.i();
        int[] c = new int[4];
        for (int i = 0; i < N; i++) {
            c[in.i()]++;
        }
        dp = new double[c[1] + c[2] + c[3] + 1][c[2] + c[3] + 1][c[3] + 1];
        out.println(f(c[1], c[2], c[3]));
    }

    static double f(int c1, int c2, int c3) {
        if (dp[c1][c2][c3] > 0 || c1 == 0 && c2 == 0 && c3 == 0) return dp[c1][c2][c3];
        double d = 1. / (c1 + c2 + c3);
        double ret = N * d;
        if (c1 > 0) ret += f(c1 - 1, c2, c3) * c1 * d;
        if (c2 > 0) ret += f(c1 + 1, c2 - 1, c3) * c2 * d;
        if (c3 > 0) ret += f(c1, c2 + 1, c3 - 1) * c3 * d;
        return dp[c1][c2][c3] = ret;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 280780
#include <bits/stdc++.h>
using namespace std;
long long int a,b,k;
int main(){
	cin>>a>>b>>k;
	if(a>k) cout<<a-k<<" "<<b;
	else if(k>(a+b))cout<<"0 0";
	else cout<<"0 "<<a+b-k;
	return 0;
}

Measured memory_bytes: 256