akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.par = [-1]*n

    def Find(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.Find(self.par[x])
        return self.par[x]

    def Union(self, x, y):
        x = self.Find(x)
        y = self.Find(y)
        if (x==y): 
            return False
        if (self.par[x]>self.par[y]):
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True
    
    def isSameGroup(self, x, y):
        return self.Find(x)==self.Find(y)
    
    def Size(self, x):
        return self.par[self.Find(x)]*-1
    
    def PrintTree(self):
        return self.par

N, M, K = map(int, input().split())

uf = UnionFind(N)
deg = [0]*N
ans = [0]*N
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.Union(a, b)

for _ in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.isSameGroup(c, d):
        deg[c] += 1
        deg[d] += 1

for i in range(N):
    ans[i] = uf.Size(i)-1-deg[i]

print(' '.join(map(str,ans)))

Measured memory_bytes: 18776
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();
        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            var a = cin.ReadSplit();
            int cur = 1;
            int ans = N;
            for(var i = 0; i < N; i++)
            {
                if (a[i] == cur) { cur++;ans--; }
            }

            Console.WriteLine(cur == 1 ? -1 : ans);
            //Console.Out.Flush();
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    public class Scanner
    {
        public int[] ReadSplit()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitL()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplitD()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

    }
}


Measured memory_bytes: 33116
#include<stdio.h>
#include<algorithm>
using std::sort;

int n,k,a[51],sum;

bool cmp(int,int);

int main(void){
	register int i;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n,cmp);
	for(i=0;i<k;i++)
		sum+=a[i];
	printf("%d\n",sum);
	return 0;
}

bool cmp(int a,int b){
	return a>b;
}

Measured memory_bytes: 128
import sys

debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False
if debug_mode:
    import os
    inf = open(os.path.basename(__file__).replace(".py", ".in"))

    def input():
        return inf.readline()
else:
    inf = sys.stdin

# ==============================================================

def main():
    n, k = [int(x) for x in input().strip().split()]
    d = [x for x in input().strip().split()]

    while True:
        str_n = str(n)
        if any(i in str_n for i in d):
            n += 1
        else:
            break
    
    print(n)


main()

# ==============================================================

if debug_mode:
    inf.close()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int[] A = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			int[,] count = new int[3, 2];
			for (int i = 0; i < 3; i++) {
				count[i, 0] = -1;
			}

			foreach (var i in A) {
				if (count[0, 0] == -1 || count[0, 0] == i) {
					count[0, 0] = i;
					count[0, 1]++;
				} else if (count[1, 0] == -1 || count[1, 0] == i) {
					count[1, 0] = i;
					count[1, 1]++;
				} else if (count[2, 0] == -1 || count[2, 0] == i) {
					count[2, 0] = i;
					count[2, 1]++;
				} else {
					Console.WriteLine("No");
					return;
				}
			}
			if (count[1, 1] == 0) {
				if (count[0, 0] == 0) {
					Console.WriteLine("Yes");
					return;
				} else {
					Console.WriteLine("No");
					return;
				}
			} else if (count[2, 1] == 0) {
				if (count[0, 1] > count[1, 1]) {
					count[2, 0] = count[0, 0];
					count[0, 1] /= 2;
					count[2, 1] = count[0, 1];
				} else {
					count[2, 0] = count[1, 0];
					count[1, 1] /= 2;
					count[2, 1] = count[1, 1];
				}
			}

			if (count[0, 1] != count[1, 1] || count[0, 1] != count[2, 1]) {
				Console.WriteLine("No");
				return;
			}
			if ((count[0, 0] ^ count[1, 0]) != count[2, 0] || (count[1, 0] ^ count[2, 0]) != count[0, 0] || (count[2, 0] ^ count[0, 0]) != count[1, 0]) {
				Console.WriteLine("No");
				return;
			}
			Console.WriteLine("Yes");
			return;
		}
	}
}


Measured memory_bytes: 19296
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX = 2e3;
const int INF = 2e9;
typedef long long ll;

int ans[MAX + 1];

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

    int n, x, y;
    cin >> n >> x >> y;

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j < i; ++j)
        {
            if (i == j) continue;
            if ((j <= x && i <= x) || (j >= y && i >= y)) {
                ans[i - j]++;
            } else {
                if (j <= x && i <= y) {
                    ans[min(i - j, x - j + 1 + y - i)]++;
                } else if (x <= j && i <= y) {
                    ans[min(i - j, j - x + 1 + y - i)]++;
                } else if (x <= j && y <= i) {
                    ans[min(i - j, 1 + j - x + i - y)]++;
                } else if (j <= x && y <= i) {
                    ans[min(i - j, x - j + 1 + i - y)]++;
                }
            }
        }
    }

    for (int i = 1; i < n; ++i)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) { cout << "No"; }
	else {
		if (a == b && b != c) {
			cout << "Yes";
		}
		if (a == c && b != c) {
			cout << "Yes";
		}
		if (b == c && b != a) {
			cout << "Yes";
		}
		if (a != b && b != c && c != a) cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

inline int read() {
  int f = 1;
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    f = (ch == '-') ? -1 : 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}

const int N = 300 + 5;
const int P = 1e9 + 7;
const int bas = 131;

vector <int> g[N]; //col

inline int mul(int a, int b) {
  return (long long) a * b % P;
}
inline int sub(int a, int b) {
  return a - b < 0 ? a - b + P : a - b;
}
inline int add(int a, int b) {
  return a + b >= P ? a + b - P : a + b;
}

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

int fac[N];
int hsl[N];
int hsh[N];

inline void rebuild(int A) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      g[j][i] = s[(i + A) % n][j] - 'a';
    }
  }
  for (int i = 0; i < n; ++i) {
    hsl[i] = 0;
    for (int j = 0; j < n; ++j) {
      hsl[i] = add(hsl[i], mul(g[i][j], fac[n - j - 1]));
    }
  }
  for (int i = 0; i < n; ++i) {
    hsh[i] = 0;
    for (int j = 0; j < n; ++j) {
      hsh[i] = add(hsh[i], mul(g[j][i], fac[n - j - 1]));
    }
  }
}

inline bool check() {
  for (int i = 0; i < n; ++i) {
    if (hsh[i] != hsl[i]) {
      return false;
    }
  }
  return true;
}

inline void move() {
  for (int i = 0; i < n; ++i) {
    hsh[i] = sub(hsh[i], mul(g[0][i], fac[n - 1]));
    hsh[i] = mul(hsh[i], bas);
    hsh[i] = add(hsh[i], g[0][i]);
  }
  for (int i = 0; i < n - 1; ++i) {
    swap(g[i], g[i + 1]);
    swap(hsl[i], hsl[i + 1]);
  }
}

int main() {
  n = read();
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < n; ++i) {
    g[i].resize(n);
  }
  fac[0] = 1;
  for (int i = 1; i < n; ++i) {
    fac[i] = mul(fac[i - 1], bas);
  }
  rebuild(0);
  // for (int i = 0; i < n; ++i) {
  //   for (int j = 0; j < n; ++j) {
  //     cerr << g[j][i] << " ";
  //   }
  //   cerr << endl;
  // }
  int ans = 0;
  for (int A = 0; A < n; ++A) {
    for (int B = 0; B < n; ++B) {
      if (check()) {
        ++ans;
      }
      move();
    }
    rebuild(A + 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265358979323846264338327950
vector <int> adj[100001];
int lvl[100001]={0},parent[100001];
void bfs(int x)
{
    queue <int> q;
    q.push(x);
    while(q.size())
    {
        x=q.front();
        q.pop();
        for(int i=0;i<adj[x].size();i++)
        {
            if(lvl[adj[x][i]]>lvl[x]+1)
            {
                lvl[adj[x][i]]=lvl[x]+1;
                parent[adj[x][i]]=x;
                q.push(adj[x][i]);
            }
        }
    }
}
signed main()
{
    SPEED;
    int n,m;
    cin>>n>>m;
    for(int i=2;i<100001;i++)
    {
        lvl[i]=1e18;
    }
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    bfs(1);
    for(int i=2;i<=n;i++)
    {
        if(lvl[i]==1e18)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    {
        cout<<parent[i]<<endl;
    }
}

Measured memory_bytes: 13840
N, K = map(int, input().split())

ans, saidai, saisyo = 0, 0, 0
for i in range(1, N+2):
    saisyo += i-1
    saidai += N-i+1
    if i >= K:
        ans += (saidai - saisyo + 1)
    
print(ans%(10**9+7))

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int cnt[4] = {};
	int x,y;
	cin >> x >> y;
	cnt[x] = 1;
	cnt[y] = 1;
	int ans = 0;
	for(int i = 1;i <= 3; ++i){
		if(cnt[i] == 0)ans = i;
	}
	cout << ans << '\n';
}


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

using namespace std;

int main ()
{
   int a,b;
   cin>>a;
   int c,f;
   if(a%2==0)
   {
      c=a/2;
      f=a-c;
   }
  
 else{
      c=(a/2);
      f=a-c;
 }
  cout<<c*f;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
 
inline double heron(double a, double b, double c){
    double s = (a + b + c) / 2;
    return sqrt(s * (s-a) * (s-b) * (s-c));
}
 
int N;
ll K;
double px[200001], py[200001], d[200001];
 
inline double g(int i, int j, int k) {
    double a = d[j - i], b = d[k - j], c = d[k - i];
    return heron(a, b, c);
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> N >> K) {
        rep(i, N) {
            double w = 2 * M_PI * i / N;
            px[i] = cos(w);
            py[i] = sin(w);
            d[i] = hypot(px[i] - 1, py[i]);
        }
 
        double l = 0, r = 2, m;
        rep(i_, 60) {
            m = (l + r) / 2;
            ll z = 0;
            for(int i = 1; i < N - 1; ++i) {
                int j = (N + i) / 2;
                int L = i + 1, R = j + 1, M;
                if(g(0, i, i+1) > m) continue;
                while(R - L > 1) {
                    M = (L + R) / 2;
                    (g(0, i, M) <= m ? L : R) = M;
                }
                if(L == j)z += (ll)(N - i - 1)*i;
                else z += 2 * (L - i)*i;
            }
            (z >= K ? r : l) = m;
        }
        cout << setprecision(20) << l << endl;
    }
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void){
    int num,person[4],okasi[1000][4]={0},sum,i,o;
    while(1){
        sum=0;
        scanf("%d",&num);
        if(num == 0)
            break;
        for(i=0;i<num;i++){
            for(o=0;o<4;o++){
                scanf("%d",&okasi[i][o]);
            }
        }
        for(i=0;i<4;i++){
            scanf("%d",&person[i]);
        }
        for(i=0;i<num;i++){
                           if(okasi[i][1] <= person[0] && okasi[i][2] <= person[1] && okasi[i][3] <= person[2] && okasi[i][1]*4+okasi[i][2]*9+okasi[i][3]*4 <= person[3]){
                    printf("%d\n",okasi[i][0]);
                    sum++;
            }
        }
        if(sum == 0)
            printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int dp[5005][5005] = {};



int main() {
	int N;
	string S;
	cin >> N >>S;
	for (int i = N-1; 0<=i;--i) {
		for (int j = N - 1;0 <= j;--j) {
			if (S[i]==S[j]) {
				dp[i][j] = dp[i + 1][j + 1] + 1;
			}
		}
	}
	int ans = 0;
	rep(i, N) {
		rep(j, N) {
			if (i <= j)continue;//j<i
			int now = min(dp[i][j],i-j);
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
		return 0;
}

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


int main(){
	int a[20];
	int i,n,max=0,z=0;

	cin >> n;

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

	
	}


	for (i = 0; i < n; i++) {
		if (a[i] >= max) {
			z++;
			max = a[i];
		
		}
	
	
	
	}


	cout << z;



	return 0;
	}

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

int main(){
    string w;
    cin >> w;
    map<char,int>Map;
    for(int i = 0; i < w.size(); i++) {
        Map[w[i]]++;
    }
    for(int i = 0; i < w.size(); i++) {
        if(Map[w[i]]%2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		int ans = a/111;
		if(a%111 != 0) {
			ans+= 1;
		}
		
		System.out.println(ans*111);
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 2000009;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
ll mod = 1e9+7;
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
// ll fact[N];


// ll ncr(ll n,ll r){
//      return (((fact[n]*powm(fact[r],mod-2))%mod)*powm(fact[n-r],mod-2))%mod;
// }
 int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
     // #endif
     ll t = 1;
     // cin>>t;
     while(t--){
          ll n,m;cin>>n>>m;
          vector<ll> a(n);
          for(int i = 0;i<n;i++){
               cin>>a[i];

          }
          make_heap(a.begin(),a.end());
          for(int i = 0;i<m;i++){
               ll k = a.front();
               pop_heap(a.begin(),a.end());
               a.pop_back();
               k = k/2;
               a.push_back(k);
               push_heap(a.begin(),a.end());
          }
          ll ans = 0;
          for(auto i:a){
               ans+=i;
          }
          cout<<ans;
     }
}            


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

int n=100,x;

signed main()
{
	cin>>x;
	for (int i=1;i<=40000;i++)
	{
		n=n*1.01;
		if (n>=x)  return cout<<i<<endl,0;
	}
}

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

using namespace std;

int cals[6];
int rows[6];

char mat[6][6];


int main()
{

    int n;
    cin >> n;
    vector<long long> v(n);

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

    sort(v.rbegin() , v.rend());


    long long sum = v[0];
    n-=2;
    int i = 1;

    while(n > 0){
        if (n >= 2){
            sum+= v[i]*2;
            n-=2;
        }
        else {
            sum+= v[i];
            n--;
        }
        i++;

    }

    cout << sum <<endl;

    return 0;
}


Measured memory_bytes: 4824
#!/usr/bin/ruby
D=[[-1,0],[0,-1],[1,0],[0,1]]
def fill(_x,_y,_c)
	r=[0,0]
	q=[[_x,_y,_c]]
	while !q.empty?
		x,y,c=q.shift
		r[c]+=1
		D.each{|dx,dy|
			nx=x+dx
			ny=y+dy
			if 0<=nx&&nx<$n&&0<=ny&&ny<$m&&$T[ny][nx]&&$T[ny][nx]==c^1
				$T[ny][nx]=nil
				q.push([nx,ny,c^1])
			end
		}
	end
	r[0]*r[1]
end
$m,$n=gets.split.map(&:to_i)
$T=$m.times.map{gets.chomp.chars.map{|c|c=='#' ? 1 : 0}}
r=0
$m.times{|i|
	$n.times{|j|
		if $T[i][j]
			c=$T[i][j]
			$T[i][j]=nil
			r+=fill(j,i,c)
		end
	}
}
p r

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast_I_O ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = 1e9+7 , INF = 1e9 ,  mx = 200009 ;
bool val(int mid,int a[],int n,int k)
{
    int t=0,i,j;
    if(mid==0) return false;
    for(i=0;i<n;i++)
    {
        t+=(a[i]-1)/mid;
    }
    return t<=k;
}
main()
{
    fast_I_O;
    int i,j,m,x,y,sum=0,p=0;
    int  n , k;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int l=0 , r=a[n-1],mid;
    while(l+1<r)
    {
        mid=(l+r)/2;
        if(val(mid,a,n,k)) r=mid;
        else l=mid;
    }
    cout<<r;
    return 0;
}

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

namespace question1
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run(){
            var s = Console.ReadLine();
            var chars = s.ToCharArray().OrderBy(c=>c).ToList();

            if( chars[0] == chars[1] && chars[2] == chars[3] && chars[0] != chars[2]){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 3005,  MOD = 1e9+7;
int n, m, l[MX], r[MX], ac[MX], rmax, c;
char s[MX];
ll dp[MX] = {1};
int main(){
	scanf("%d%d\n%s", &n, &m, s);
	rep(i,n) ac[i+1] = ac[i] + s[i] -'0';
	rep(i,m) scanf("%d%d", l+i, r+i);
	rep(i,n){
		for(; c < n && l[c] == i+1; c++) rmax = max(rmax, r[c]);
		if(rmax == i) rmax++;
		for(int j=ac[rmax]-1; j >= max(0,ac[rmax]-rmax+i); j--) (dp[j+1] += dp[j]) %= MOD;
		rep(j,ac[rmax]-rmax+i+1) dp[j] = 0;
	}
	printf("%lld\n", dp[ac[n]]);
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>

using namespace std;

char s[100005],pre;
int cnt;

int main()
{
    scanf("%s",s); 
	pre=s[0];
    for(int i=1;i<strlen(s);i++)
      	if(pre!=s[i]) cnt++,pre=s[i];
    printf("%d",cnt);
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int AC=0;
  int WA=0;
  int TLE=0;
  int RE=0;
  for(int i=0;i<N;i++){
    if(vec.at(i)=="AC"){
      AC++;
    }
    else if(vec.at(i)=="WA"){
      WA++;
    }
    else if(vec.at(i)=="TLE"){
      TLE++;
    }
    else{
      RE++;
    }
  }
  cout<<"AC x "<<AC<<endl;
  cout<<"WA x "<<WA<<endl;
  cout<<"TLE x "<<TLE<<endl;
  cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
ll n,k,s;
cin>>n>>k>>s;
ll a[n+1]={0};
for(int i=0;i<k;i++){
    a[i]=s;
    
}
for(int i=k;i<n;i++){
    if(s==1e9){
   a[i]=s-1;}
   else{
   a[i]=s+1;}
}

for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
}
cout<<endl;
	// your code goes here
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


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


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

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        bool mod3 = (i % 3) == 0;
        bool mod5 = (i % 5) == 0;
        if (!mod3&&!mod5) {
            res += i;
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3608
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int dp[1405][1405],h,w,M;
int main()
{
	cin>>h>>w;
	FOR(i,1,h+1)
	{
		FOR(j,1,w+1)
		{
			cin>>dp[i][j];
			dp[i][j]^=1;
			if(dp[i][j]!=0)
			{
				dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
			}
			M=max(M,dp[i][j]);
		}
	}
	cout<<M*M<<endl;
	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i];

    int l = 40;
    ll x = 0;
    rrep(i,l+1){
        if((x|1ll<<i) > k) continue;
        int cnt = 0;
        rep(j,n) if(a[j]>>i & 1) cnt++;
        if(cnt*2 < n) x |= 1ll<<i;
    }

    ll ans = 0;
    rep(i,n) ans += x ^ a[i];
    cout << ans << endl;
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" <<endl;
    }else{
        cout <<"No" << endl; 
    }
}

Measured memory_bytes: 256
fn main() {
    let a: i64 = read();
    let b: i64 = read();
    for x in 1..1001 {
        if ((x as f64) * 0.08) as i64 == a && ((x as f64) * 0.10) as i64 == b {
            println!("{}", x);
            return;
        }
    }
    println!("-1");
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

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


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    vector<Int> div(0);
    Int count = 0;
    for (Int i = 1; i <= sqrtl(n); i++) {
        if (n % i == 0) {
            count++;
            div.push_back(i);
        }
    }
    Int a, b;
    a = div[count - 1];
    b = n / div[count - 1];

    cout << a - 1 + b - 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    unordered_map<char, vector<int>> pos;
    for(int i = 0; i < s.size(); i++) {
        pos[s[i]].push_back(i);
    }
    cout << (pos['Z'].back() - pos['A'][0] + 1) << endl;
    return 0;
}


Measured memory_bytes: 4784
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    getline(cin,s);
    int i=0;
    while(i<(int)(s.size())-4){
        if(s.substr(i,5)=="apple"){
            s.replace(i,5,"peach");
            i+=5;
        }else if(s.substr(i,5)=="peach"){
            s.replace(i,5,"apple");
            i+=5;
        }else i++;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 0
def main():
    n, k = map(int, input().split())
    tmp = list(map(int, input().split()))
    h = [0]
    for v in tmp:
        h.append(v)
    dp = [[float("inf")]*(n-k+1) for i in range(n+1)]
    dp[0][0] = 0
    for i in range(1, n+1):
        for j in range(1, n-k+1):
            tmp = float("inf")
            for l in range(i):
                p = max(0, h[i] - h[l])
                if tmp > dp[l][j-1] + p:
                    tmp = dp[l][j-1] + p
            dp[i][j] = tmp
    ans = float("inf")
    for i in range(n+1):
        if ans > dp[i][n-k]:
            ans = dp[i][n-k]
    print(ans)

if __name__ == "__main__":
    main()

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

int main()
{
  string a, b;
  cin >> a >> b;
  
  int n1 = a.size(), n2 = b.size();
  
  if(n1 > n2)
  {
    cout << "GREATER" << endl;
    return 0;
  }
  if(n1 < n2)
  {
    cout << "LESS" << endl;
    return 0;
  }
  if(n1 == n2)
  {
    for(int i = 0; i < n1; i++)
    {
      if(a[i] < b[i])
      {
        cout << "LESS" << endl;
        return 0;
      }
      if(a[i] > b[i])
      {
        cout << "GREATER" << endl;
        return 0;
      }
    }
  }
  
  cout << "EQUAL" << endl;
  return 0;
}
      

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char s[100001];
int l,i,j;
int main()
{
    scanf("%s",s);
    l=strlen(s);
    for(i=0;i<l;i++)
    if(s[i]=='C')
    for(j=i+1;j<l;j++)
    if(s[j]=='F')
    return puts("Yes")&0;
    puts("No");
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int INF=100000;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
vvi G;
void f(int x,int y){
	rep(i,4){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(G[nx][ny]==inf)continue;
		if(G[nx][ny]>G[x][y]+1){
			G[nx][ny]=G[x][y]+1;
			f(nx,ny);
		}
	}
}
int main(){
	int n,m;
	while(cin>>m>>n,n+m){
		G=vvi(2*n+1,vi(2*m+1,inf));
		rep(i,n)rep(j,m)G[i*2+1][j*2+1]=INF;
		G[1][1]=0;
		rep(i,n){
			rep(j,m-1){
				int a;
				cin>>a;
				if(!a)G[2*i+1][2*j+2]=INF;
			}
			if(i!=n-1){
				rep(j,m){
					int a;cin>>a;
					if(!a)G[2*i+2][2*j+1]=INF;
				}
			}
		}
		f(1,1);
//		rep(i,2*n+1){rep(j,2*m+1)cout<<" "<<G[i][j];cout<<endl;}
		if(G[2*n-1][2*m-1]==INF)cout<<0<<endl;
		else cout<<G[2*n-1][2*m-1]/2+1<<endl;
	}
}

Measured memory_bytes: 1316
package main

import (
	"fmt"
	"io"
	"os"
	"strconv"
)

var pri = fmt.Println
var scan = fmt.Fscanln
var scanone = fmt.Fscan

func main() {
	solve(os.Stdin)
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] {
			res = a[i]
		}
	}
	return res
}

func mustint(a string) int {
	i, _ := strconv.Atoi(a)
	return int(i)
}

type P struct {
	x, y int
}

func (p *P) add(q *P) *P {
	return &P{p.x + q.x, p.y + q.y}
}

const huge = 1e10

func solve(rd io.Reader) {
	var n, h int
	scan(rd, &h, &n)
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		scan(rd, &a[i], &b[i])
	}
	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, h+1)
		for j := 0; j < h+1; j++ {
			dp[i][j] = 1000000000
		}
	}
	dp[0][0] = 0
	for i := 0; i < n; i++ {
		for j := 0; j < h+1; j++ {
			dp[i+1][j] = min(dp[i][j], dp[i+1][max(0, j-a[i])]+b[i])
		}
	}
	pri(dp[n][h])
}


Measured memory_bytes: 85508
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int H,W; cin >> H >> W;
    char A[H+1][W+1];

    REP(i,H) REP(j,W) cin >> A[i][j];

    ll cnt=0;

    REP(i,H) REP(j,W) if(A[i][j]=='#') cnt++;

    if(cnt!=(H+W-1)) cout << "Impossible" << endl;
    else cout << "Possible" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
    cout << a << endl;
    exit(0);
}

void Main()
{
    ll x; cin >> x;
    if(x == 0) fin(1);
    else fin(0);

}

//前処理
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10); //高精度少数表示
    Main();
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D)
    cout << "Balanced" << endl;
  else if (A + B > C + D)
    cout << "Left" << endl;
  else if (A + B < C + D)
    cout << "Right" << endl;
}

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

int main() {
  int h = 0;
  int w = 0;
  int k = 0;

  cin >> h;
  cin >> w;
  cin >> k;
  vector<vector<char>> table(h, vector<char>(w));

  int hh = 0;
  int ww = 0;
  while (true) {
    char c = 0;
    cin >> c;
    if (c == '\n') {
      continue;
    }
    table[hh][ww] = c;
    if (hh == h - 1 && ww == w - 1) {
      break;
    } else if (ww == w - 1) {
      hh++;
      ww = 0;
    } else {
      ww++;
    }
  }

  int result = 0;
  uint64_t max_h = (2 << (h - 1)) - 1;
  uint64_t max_w = (2 << (w - 1)) - 1;
  for (uint64_t deletedh = 0; deletedh <= max_h; deletedh++) {
    for (uint64_t deletedw = 0; deletedw <= max_w; deletedw++) {
      vector<uint8_t> deleted_h(h);
      vector<uint8_t> deleted_w(w);
      for (int i = 0; i < h; i++) {
        if ((deletedh >> i) % 2 == 1) {
          deleted_h[i] = 1;
        } else {
          deleted_h[i] = 0;
        }
      }
      for (int j = 0; j < w; j++) {
        if ((deletedw >> j) % 2 == 1) {
          deleted_w[j] = 1;
        } else {
          deleted_w[j] = 0;
        }
      }

      int count = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (!deleted_h[i] && !deleted_w[j] && table[i][j] == '#') {
            count++;
          }
        }
      }
      if (count == k) {
        result++;
      }
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 3628
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t a,b;
  cin >> a >> b;
  cout << a / __gcd(a, b) * b << endl;
  return 0;
}
//templete by private_yusuke

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

int main() {
	int n;
	cin>>n;
	int ans=0;
	int count = 0;
	for(int i=1;i<=n;i+=2) {
		for (int j=1;j<i;j++) {
			if (i%j==0) count++;
		}
		if (count == 7) ans++;
		count = 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

set<int> st;
int N; 
void dfs(string S = "", int a = 0, int b = 0, int c = 0) {
    if(S.size() && stoll(S) > N) return;
    if(a > 0 && b > 0 && c > 0) {
        st.insert(stoll(S));
    }
    dfs(S + '3', a + 1, b, c);
    dfs(S + '5', a, b + 1, c);
    dfs(S + '7', a, b, c + 1);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    dfs();
    cout << st.size() << endl;


    return 0;
}


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

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

    int A, B, K;
    cin >> A >> B >> K;
    int range = B - A;
    vector<int> ans;

    if(range >= 2 * K){
        for(int i = A; i < A + K; i++){
            ans.push_back(i);
        }
        for(int i = B - K + 1; i <= B; i++){
            ans.push_back(i);
        }
    }
    else if(range <= K){
        for(int i = A; i <= B; i++){
            ans.push_back(i);
        }
    }
    else{
        for(int i = A; i < A + K; i++){
            ans.push_back(i);
        }
        for(int i = A + K; i <= B; i++){
            ans.push_back(i);
        }
    }

    for(int i : ans){
        cout << i << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void) {
	// Your code here!
	int a, b;
	cin >> a >> b;

	int sums = 0;
	int &sum = sums;

	sum = a + b;

	if (sum < 24) cout << sum << endl;
	else if (sum >= 24) cout << sum%24 << endl;


	return 0;

}



Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readString = map BS.unpack . BS.words

getInt = readInt <$> BS.getLine
getNString n = map readString <$> replicateM n BS.getLine

check :: [String] -> [String] -> Int -> Int
check [] _ m = m
check ss ts m = check (snd ss') (snd ts') m''
  where
    s = head ss
    ss' = partition (== s) ss
    ts' = partition (== s) ts
    m' = length (fst ss') - length (fst ts')
    m'' = if m' > m then m' else m

main = do
  n <- getInt
  ss <- getNString n
  m <- getInt
  ts <- getNString m
  let ss' = map head ss
  let ts' = map head ts
  print $ check ss' ts' 0


Measured memory_bytes: 3948
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	
	if(N%2){
		cout<<0<<endl;
	} else {
		int ans = 0;
		
		N /= 10;
		
		while(N){
			ans += N;
			N /= 5;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
	
	vector<int> test(N+1, 1);
	
	
	for(int i = 2; i <= N; i++){
		test[i] = test[i-2] * i;
	}
	
	for(int i = 0; i <= N; i++){
		cout<<"i = "<<i<<" "<<test[i]<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string w;
	cin>>w;
	if(w=="Sunny"){
		cout<<"Cloudy\n";
	}
	else if(w=="Cloudy"){
		cout<<"Rainy\n";
	}
	else if(w=="Rainy"){
		cout<<"Sunny\n";
	}

}



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

int same(vector<int> &c){
	for(int i = 1 ; i < c.size() ; i++)
		if(c[i] != c[i-1]) return false;
	return true;
}

int royal(vector<int> &v,vector<int> &c){
	return same(c) && v[0] == 1 && v[1] == 10 && v[2] == 11 && v[3] == 12 && v[4] == 13;
}
int straightflash(vector<int> &v,vector<int> &c){
	if(!same(c))return false;
	if(v[0] == 1 && v[1] == 10 && v[2] == 11 && v[3] == 12 && v[4] == 13) return true;
	for(int i = 1; i < v.size() ; i++)
		if(v[i] != v[i-1]+1) return false;
	return true;
}
int straight(vector<int> &v,vector<int> &c){
	if(v[0] == 1 && v[1] == 10 && v[2] == 11 && v[3] == 12 && v[4] == 13) return true;
	for(int i = 1; i < v.size() ; i++){
		if(v[i] != v[i-1]+1) return false;
	}
	return true;
}
int four(vector<int> &v,vector<int> &c){
	for(int i = 0 ; i < v.size() ; i++){
		if(count(v.begin(),v.end(),v[i]) == 4) return true;
	}
	return false;
}
int fullhouse(vector<int> &v,vector<int> &c){
	bool f1 = 0 , f2 = 0;
	for(int i = 0 ; i < v.size() ; i++){
		if(count(v.begin(),v.end(),v[i]) == 3) f1 = true;
		if(count(v.begin(),v.end(),v[i]) == 2) f2 = true;
	}
	return f1 & f2;
}

int three(vector<int> &v,vector<int> &c){
	for(int i = 0 ; i < v.size() ; i++){
		if(count(v.begin(),v.end(),v[i]) == 3) return true;
	}
	return false;
}

int two(vector<int> &v,vector<int> &c){
	int k[10] = {0};
	for(int i = 0 ; i < v.size() ; i++){
		k[count(v.begin(),v.end(),v[i])]++;
	}
	return k[2] == 4;
}

int one(vector<int> &v,vector<int> &c){
	int k[10] = {0};
	for(int i = 0 ; i < v.size() ; i++){
		k[count(v.begin(),v.end(),v[i])]++;
	}
	return k[2] == 2;
}

int flash(vector<int> &v,vector<int> &c){
	return same(c);
}
int num(char c){
	if(c == 'A') return 1;
	else if(c == 'T') return 10;
	else if(c == 'J') return 11;
	else if(c == 'Q') return 12;
	else if(c == 'K') return 13;
	else return c - '0';
}
int suit(char c){
	switch(c){
	case 'S':return 1;
	case 'C':return 2;
	case 'H':return 3;
	case 'D':return 4;
	};
}
int main(){
	int n;
	int (*p[9]) (vector<int> &v,vector<int> &c);
	p[0] = one;
	p[1] = two;
	p[2] = three;
	p[3] = straight;
	p[4] = flash;
	p[5] = fullhouse;
	p[6] = four;
	p[7] = straightflash;
	p[8] = royal;
	int T = 0;
	while(cin >> n){
		if(T++)cout << endl;
		int w[5][14];
		for(int y = 1 ; y <= 4 ; y++){
			for(int i = 1 ; i <= 13 ; i++){
				cin >> w[y][i];
			}		
		}
		
		int rate[9];
		for(int i = 0 ; i < 9 ; i++){
			cin >> rate[i];
		}
		for(int _ = 0 ; _ < n ; _++){
			int o = 0;
			vector<int> v; vector<int> c;
			for(int i = 0 ; i < 5 ; i++){
				string s;
				cin >> s;
				v.push_back(num(s[0]));
				c.push_back(suit(s[1]));
				o += w[suit(s[1])][num(s[0])];
			}
			for(int __ = 0 ; __ < 5 ; __++){
				for(int i = 0 ; i < 4 ; i++){
					if(v[i] > v[i+1]){
						swap(v[i],v[i+1]);
						swap(c[i],c[i+1]);
					}
				}
			}
			int ans = 0;
			for(int i = 0 ; i < 9 ; i++){
				ans = max( p[i](v,c) * o * rate[i] , ans);
			}
			cout << ans << endl;
		}
		
	}

}

Measured memory_bytes: 928
#include <bits/stdc++.h>
using namespace std;
# define ll long long
int n,arr[100005],ans[100005];
int calc(int i)
{
    if(ans[i]!=-1)
        return ans[i];
    if(i==n-1)
        return 0;
    int x=abs(arr[i]-arr[i+1]);
    int y=abs(arr[i]-arr[i+2]);
    int z1=calc(i+1);
    ans[i]=z1;
    int z2=10000000;
    if(i+2<n)
        z2=calc(i+2);
    int aa=min(x+z1,y+z2);
    ans[i]=aa;
    return aa;

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n;
    //int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    memset(ans,-1,sizeof(ans));
    int sum=calc(0);
    cout<<sum;
    //code goes here
	return 0;
}



Measured memory_bytes: 5760
#include<cstdio>
#include<cmath>
const int maxn = 55;
int a[maxn];
using namespace std;
int main(){
    int n,mx=0,id=0;scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        if(abs(a[i]) > mx){
            mx = abs(a[i]);
            id = i;
        }
    }
    printf("%d\n",2*n-1);
    for(int i = 0; i < n; i++){
        printf("%d %d\n",id+1,i+1);
    }
    if(a[id]>=0)for(int i = 1; i < n; i++)printf("%d %d\n",i,i+1);
    else for(int i = n; i > 1; i--)printf("%d %d\n",i,i-1);
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

n = int(raw_input())
l = map(int, raw_input().split())
A = [0]
for i in range(n):
    A.append(l[i])
print "node %d: key = %d, left key = %d, right key = %d, " %(1, A[1], A[2*1], A[2*1+1])
for i in range(2, int((n+1)/2)):
    print "node %d: key = %d, parent key = %d, left key = %d, right key = %d, " %(i, A[i], A[int(i/2)], A[2*i], A[2*i+1])
if not n%2:
    i = n/2
    print "node %d: key = %d, parent key = %d, left key = %d, " %(i, A[i], A[int(i/2)], A[2*i])
for i in range(int(n/2)+1, n+1):
    print "node %d: key = %d, parent key = %d, " %(i, A[i], A[int(i/2)])

Measured memory_bytes: 6424