akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

var dp [20000]int

func dynamicPlanning(damage int, a []int, b []int) int {
	if damage <= 0 {
		return 0
	}
	//fmt.Println("Remains damage : ",damage)
	if dp[damage] > 0 {
		//fmt.Println("Already searched : ",dp[damage])
		return dp[damage]
	}
	var min = -1
	//var min_num int
	for i := 0 ; i < len(a) ; i++ {
		/*if damage <= a[i] {
			fmt.Println("Attacked one : ",b[i])
			dp[damage] = b[i]
			return b[i]
		}*/
		temp := dynamicPlanning(damage-a[i],a,b) + b[i]
		if min < 0 || min > temp {
			min = temp
			//min_num = i
		}
	}
	//fmt.Println("Attacked many times : ",min)
	dp[damage] = min
	return min
}

func main(){
	var h,n int
	fmt.Scan(&h, &n)
	a := make([]int,n)
	b := make([]int,n)
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&a[i],&b[i])
	}
	answer := dynamicPlanning(h,a,b)
	fmt.Println(answer)
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n;
string s[2];
const ll MOD=(ll)1e9+7;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
    cin>>s[0];
    cin>>s[1];
  //cout<<1<<endl;
  ll ans=0;
  bool pre=0;
  for(int i=0;i<n;){
    //cout<<i<<endl;
    if(i==0){
      if(s[0][i]==s[1][i]){
        ans=3;
        pre=0;
        i++;
      }else{
        ans=6;
        pre=1;
        i+=2;
      }
    }else{
      if(s[0][i]==s[1][i]){
        if(!pre)ans=((ans%MOD)*(2))%MOD;
        pre=0;
        i++;
      }else{
        if(pre)ans=((ans%MOD)*(3))%MOD;
        else ans=((ans%MOD)*(2))%MOD;
        pre=1;
        i+=2;
      }
    }
  }
  cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N, D = map(int, input().split())
    
    res = 0

    for i in range(N):
        x, y = map(int, input().split())
        dist = (x**2 + y**2)**0.5

        if dist <= D:
            res += 1
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10848
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
vvl v;
vl vis,d;
vl a(500,0);
ll dp[1000][1000];

ll sg(ll l,ll r){
    if(dp[l][r]!=-1)return dp[l][r];
    ll h=inf*inf;
    for(int i=l;i<r;i++)h=min(h,sg(l,i)+sg(i+1,r));
    return dp[l][r]=h+a[r+1]-a[l];
}

int main() {
    IOS;
    cin>>n;
    vl v(n);
    fo(i,n)cin>>v[i],a[i+1]=a[i]+v[i];
    fo(i,500)fo(j,500)dp[i][j]=-1;
    fo(i,500)dp[i][i]=0;
    cout<<sg(0,n-1);
    //fo(i,3)fo(j,3)cout<<dp[i][j]<<el;
    return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define forr(x,n) for(int x = 0; x < n; ++x)
#define pr pair<int,int>
#define ll long long int
const ll mod=998244353;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double l;
    cin>>l;
    l/=3;
    long double ans=l*l*l;
    cout<<fixed<<setprecision(12);
    cout<<ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public void syllables(int A,int B,int C) {
		
			switch(A) {
			case 5:
				if((B==5&&C==7)||(B==7&&C==5)) {
					System.out.println("YES");

				}else {
					System.out.println("NO");
				}
				break;
			case 7:
				if(B==5&&C==5) {
					System.out.println("YES");

				}else {
					System.out.println("NO");
				}
				break;
			default:
				System.out.println("NO");
				break;
			}
		}
	
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner sc=new Scanner(System.in);
	        int A=sc.nextInt();
	        int B=sc.nextInt();
		int C=sc.nextInt();
		new Main().syllables(A,B,C);
		
	}
	

}


Measured memory_bytes: 21204
// æœªè§£æ±º

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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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 in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int n;
  cin >> n;

  string chars = "abcdefghij";

  vector<vector<string>> a(10);
  vector<vector<int>> uniq(10);

  a[0].pb("a");
  uniq[0].pb(1);

  REPS(i, 9) {  // i,9
    // debug(i);
    REP(j, a[i - 1].size()) {
      // debug(j);
      REP(k, uniq[i - 1][j] + 1) {
        // debug(k);
        a[i].pb(a[i - 1][j] + chars[k]);
        // cout << (a[i - 1][j] + chars[k]) << endl;
        if (k < uniq[i - 1][j]) {
          uniq[i].pb(uniq[i - 1][j]);
          // cout << "uniq1: " << uniq[i - 1][j] << endl;
        } else {
          uniq[i].pb(uniq[i - 1][j] + 1);
          // cout << "uniq2: " << uniq[i - 1][j] + 1 << endl;
        }
      }
    }
  }

  REP(i, a[n - 1].size()) { cout << a[n - 1][i] << endl; }

  return 0;
};


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var n = inputs[0] * inputs[1];
        Console.WriteLine(n % 2 == 0 ? "Even" : "Odd");
    }
}

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

public class Main {

    public Main(FastScanner in, PrintWriter out, int test) {
        long N = in.nextInt();

        // for each range
        // # of connected components = number of vertices - number of edges

        long res = 0;

        // total contributions from vertices
        for (int i = 0; i < N; i++) {
            res += (N - i) * (i + 1);
        }

        // total contribution from edges
        for (int i = 0; i < N - 1; i++) {
            int u = in.nextInt() - 1, v = in.nextInt() - 1;
            int l = Math.min(u, v), r = Math.max(u, v);
            res -= (N - r) * (l + 1);
        }

        out.println(res);
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

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

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

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

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}

Measured memory_bytes: 52364
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 100005;



int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	cout.precision(10);
	cout << fixed;
    double t,x;
    cin >> t >> x;
    cout << t/x << '\n';
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    cout << N * N * N << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
	int chi, kougeki, kaunta;
	scanf("%d %d", &chi, &kougeki);
	kaunta = 1;
	chi % kougeki == 0 ? printf("%d", chi/kougeki) : printf("%d", (chi/kougeki)+1);
	
	return 0;
}

Measured memory_bytes: 1680
program ec12;
var 
	n,m,i,j:longint;
	ans:int64;
	a,b,c,s,sum:array[0..100001] of int64;
procedure qsrt(l,r:longint);
var 
	v,s:int64;
	i,j:longint;
begin
	i:=l; j:=r; v:=b[(l+r) div 2];
	repeat
	while b[i]<v do inc(i);
	while b[j]>v do dec(j);
	if i<=j then 
	begin 
		s:=b[i];
		b[i]:=b[j];
		b[j]:=s;
		inc(i);
		dec(j);
	end;
	until i>=j;
	if l<j then qsrt(l,j);
	if i<r then qsrt(i,r);
end;
procedure qsrt1(l,r:longint);
var 
	v,s:int64;
	i,j:longint;
begin
	i:=l; j:=r; v:=c[(l+r) div 2];
	repeat
	while c[i]<v do inc(i);
	while c[j]>v do dec(j);
	if i<=j then 
	begin 
		s:=c[i];
		c[i]:=c[j];
		c[j]:=s;
		inc(i);
		dec(j);
	end;
	until i>=j;
	if l<j then qsrt1(l,j);
	if i<r then qsrt1(i,r);
end;
procedure qsrt2(l,r:longint);
var 
	v,s:int64;
	i,j:longint;
begin
	i:=l; j:=r; v:=a[(l+r) div 2];
	repeat
	while a[i]<v do inc(i);
	while a[j]>v do dec(j);
	if i<=j then 
	begin 
		s:=a[i];
		a[i]:=a[j];
		a[j]:=s;
		inc(i);
		dec(j);
	end;
	until i>=j;
	if l<j then qsrt2(l,j);
	if i<r then qsrt2(i,r);
end;
begin 
	readln(n);
	for i:=1 to n do
	read(a[i]);
	qsrt2(1,n);
	for i:=1 to n do
	read(b[i]);
	qsrt(1,n);
	for i:=1 to n do
	read(c[i]);
	qsrt1(1,n);
	i:=1;
	j:=1;
	while (i<=n) and (j<=n) do
	begin 
		if b[i]>=c[j] then 
		inc(j)
		else
		begin 
			s[i]:=n-j+1;
			inc(i);
		end;
	end;
	i:=1;
	j:=1;
	sum[0]:=0;
	for i:=1 to n do 
	sum[i]:=sum[i-1]+s[i];
	ans:=0;
	i:=1;
	j:=1;
	while (i<=n) and (j<=n) do 
	begin 
		if a[i]>=b[j] then 
		inc(j)
		else
		begin 
			ans:=ans+sum[n]-sum[j-1];
			inc(i);
		end;
	end;
	writeln(ans);
end. 

Measured memory_bytes: 3968
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int M; cin >> M;
    cout << 24+(24-M) << endl;
    
    return 0;
}

Measured memory_bytes: 256
from itertools import product
n, m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]

ans = 0
for x, y, z in product([1, -1], repeat=3):
    tmp = [x * a + y * b + z * c for a, b, c in s]
    tmp.sort(reverse=True)
    ans = max(ans, sum(tmp[:m]))

print(ans)


Measured memory_bytes: 3432
n=int(input())
count=0
for i in range(1,n+1):
    if i%2==1:
        yakusuu=0
        for j in range(1,int((i**0.5)//1)+1):
            if i%j==0:
                if j**2==i:
                    yakusuu+=1
                else:
                    yakusuu+=2
        if yakusuu==8:
            count+=1
print(count)

Measured memory_bytes: 3188
from fractions import gcd  #  from python3.5, use math,gcd
from collections import defaultdict


def prime_factorization(x):
    res = defaultdict(int)
    n = 2
    while n**2 <= x:
        while x % n == 0:
            res[n] += 1
            x //= n
        n += 1
    if x != 1:
        res[x] += 1
    return res


def main():
    A, B = list(map(int, input().split(' ')))
    gcd_ab = gcd(A, B)
    pf = prime_factorization(gcd_ab)
    print(1 + len(pf.keys()))  # +1 for factor `1`


if __name__ == '__main__':
    main()


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

int main(){
    int numberOfTopping;
    
    numberOfTopping=0;
    string S;cin>>S;
    if(S[0]=='o')numberOfTopping++;
    if(S[1]=='o')numberOfTopping++;
    if(S[2]=='o')numberOfTopping++;
    int price;
    price=700+100*numberOfTopping;
    cout<<price<<endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  using llp = pair<ll, ll>;
  vector<llp> XY(N);
  for (ll i = 0; i < N; i++) {
    cin >> XY[i].first >> XY[i].second;
  }

  // 差分を覚える。総当たりで
  vector<llp> Sa;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      if (i == j) continue;
      Sa.push_back({XY[i].first - XY[j].first, XY[i].second - XY[j].second});
    }
  }
  // 差分の最頻値を求める
  map<llp, ll> XYmap;
  for (const auto& sa : Sa) {
    XYmap[sa]++;
  }

  // 最頻値を取り出す
  auto most_pair =
      *max_element(cbegin(XYmap), cend(XYmap), [](auto x, auto y) { return x.second < y.second; });

  const ll most_freq = most_pair.second;

  const ll ans = N - most_freq;

  cout << ans << endl;

  return 0;
}


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

int main(){
    char tem;
    while(cin>>tem){
        vector<pair<int,int> >vec, v1;
        vector<int>ans;
        for(int i=0;i<9;i++)
            vec.push_back(make_pair(i,0));
        vec[tem-'0'-1].second++;
        for(int i=1;i<13;i++){
            cin>>tem;
            vec[tem-'0'-1].second++;
        }
        for(int i=1;i<10;i++){
            if(vec[i-1].second==4)continue;
            vec[i-1].second++;
            v1=vec;
            for(int j=0;j<9;j++){
                if(vec[j].second>1){
                    vec[j].second-=2;
                    for(int k=0;k<7;k++){
                        while(vec[k].second>2)
                            vec[k].second-=3;
                        while(vec[k].second>0&&vec[k+1].second>0&&vec[k+2].second>0){
                            vec[k].second--;
                            vec[k+1].second--;
                            vec[k+2].second--;
                        }
                    }
                    for(int k=0;k<10;k++)
                        while(vec[k].second>2)
                            vec[k].second-=3;
                    int suc=1;
                    for(int k=0;k<vec.size();k++){
                        if(vec[k].second!=0){
                            suc=0;
                            break;
                        }
                    }
                    if(suc){
                        ans.push_back(i);
                        goto next;
                    }
                }
                vec=v1;
            }
        next:
            vec=v1;
            vec[i-1].second--;
        }
        if(!ans.size()){
            cout<<0<<endl;
            continue;
        }
        for(int i=0;i<ans.size()-1;i++)
            cout<<ans[i]<<" ";
        cout<<ans[ans.size()-1]<<endl;
    }
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner o = new Scanner(System.in);
		int n = o.nextInt();
		int a = o.nextInt();
		int max = a;
		int min = a;
		long sum = 0;
		
		for(int i = 0;i < n;i++){
			//System.out.println(a);
			if(max < a){
				max = a;
			}	
			if(min > a){
				min = a;
			}
			sum = sum + a;
			if((n-1) != i)
				a = o.nextInt();
			else
				break;
		}
		System.out.println(min+" "+max+" "+sum);
	}

}

Measured memory_bytes: 31772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<ll> T(N, 0LL);
	rep (i, N) cin >> T[i];

	ll sum = accumulate(ALL(T), 0LL);

	int M; cin >> M;
	rep (i, M){
		int p; cin >> p;
		--p;
		ll x; cin >> x;
		cout << sum - T[p] + x << endl;
	} // end rep 		

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h, w;
    
    while (1) {
        
        cin >>h >>w;
        if (h==0 && w==0) {
            break;
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << '#';
            }
            cout << endl;
        }
        
        cout << endl;
    }
}


Measured memory_bytes: 3132
def make_divisors(n):
    cnt = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            cnt += 1
            if i != n // i:
                cnt += 1
        i += 1
    return cnt
numbers = [1,10, 100, 1000, 10000, 100000, 150000,200000, 250000,300000,350000, 400000,450000, 500000,550000,600000,630000,675000,700000,720000,750000,800000,825000,850000,875000,900000,912500,925000,950000,975000,987500,1000000]
datas = [0,23,473,7053,93643,1166714, 1810893, 2472071, 3145923, 3829761, 4522005,5221424,5927120,6638407,7354651,8075420,8509899,9164377,9529244,9821778,10261678,10997400,11366472,11736253,12106789,12478098,12664043,12850013,13222660,13595947,13782871,13969985]

N = int(input())
ttl = 0
numPin = 0

for i in range(len(numbers)):
    if N == 1000000:
        numPin = len(numbers) - 1
        break
    if numbers[i] <= N < numbers[i+1]:
        numPin = i
        break

if numPin != len(numbers)-1:
    if N - numbers[numPin] < numbers[numPin + 1] - N:
        for i in range(numbers[numPin], N):
            ttl += make_divisors(i)
        print(ttl + datas[numPin])
    else:
        for i in range(N,numbers[numPin+1]):
            ttl -= make_divisors(i)
        print(ttl + datas[numPin + 1])
else:
    print(datas[numPin])


Measured memory_bytes: 9292
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,i;cin>>n;vi v(n);for(i=0;i<n;i++) cin>>v[i];
	for(i=0;i<n;i++) if(v[i]%2==0&&v[i]%3&&v[i]%5) return cout<<"DENIED\n",0;
	cout<<"APPROVED\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

int main() {
    cin >> N;
    cin >> S;
    vector<int> a(N);
    vector<int> cnt(3);
    for (int i = 0; i < N; i++) {
        a[i] = (int)(S[i] - '1');
        cnt[a[i]]++;
    }

    if (cnt[1] > 0) {
        bool is_odd = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] == 1) {
                is_odd ^= (((N - 1) & i) == i);
            }
        }
        if (is_odd) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    } else {
        bool is_odd = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] == 2) {
                is_odd ^= (((N - 1) & i) == i);
            }
        }
        if (is_odd) {
            cout << 2 << endl;
        } else {
            cout << 0 << endl;
        }
    }

    return 0;
}


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n;
    cin >> n;

    vector< long long int > v;

    bool f = false;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        v.push_back( in );
        if ( in == 1 ) f = true;
    }

    if ( f == false ) {
        cout << -1 << endl;
        return 0;
    }

    long long int ans = 0;
    long long int cnt = 1;
    for ( long long int i = 0; i < n; i++ ) {
        if ( v[i] == cnt ) {
            cnt++;
            continue;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 2420
# include <iostream>
# include <cstring>
# include <cstdio>
using namespace std;

char s[100][110];
int score[1000];
long long sum = 0;
int main(void){
    // freopen("aaa.in","r",stdin);
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
    scanf("%s",s[i]);
    scanf("%d",&score[i]);
    sum+=score[i];
    }
    // cout<<sum<<endl;
    char X[110];
    scanf("%s",X);
    for (int i=1;i<=n;i++){
        sum-=score[i];
        int p = 0;
        while(X[p]==s[i][p]&&s[i][p]!='\0'&&X[p]!='\0') p++;
        if (X[p]=='\0'&&s[i][p]=='\0') break;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
s1 = input()
n1 = len(s1)
s2 = s1[:(n1-1)//2]
n2 = len(s2)
s3 = s1[-(n1-1)//2:]
n3 = len(s3)
f1, f2, f3 = True, True, True
for i in range((n1-1)//2):
    if s1[i] != s1[-i-1]:
        f1 = False
        break
for i in range(n2//2):
    if s2[i] != s2[-i-1]:
        f2 = False
        break
for i in range(n3//2):
    if s3[i] != s3[-i-1]:
        f3 = False
        break
if f1 and f2 and f3:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main(){
    int n,m,l;
    cin >> l;
    int x = 0;
    int nn = l;
    while(nn>0){
        x++;
        nn >>= 1;
    }
    n = x;
    m = 0;
    
    vector<vector<pair<int, int>>> G(n);
    for(int i = 1; i < n;i++){
        G[i].push_back({i + 1, 1 << (i-1)});
        G[i].push_back({i + 1, 0});
        m += 2;
    }
    for(int i = n-1; i >= 1;i--){
        if(l - (1<<(i-1))>=1<<(x-1)){
            m++;
            G[i].push_back({n, l - (1 << (i-1))});
            l -= 1 << (i-1);
        }
    }
    printf("%d %d\n", n, m);
    for(int i = 1; i < n; i++) {
        for(pair<int,int> p:G[i]){
            printf("%d %d %d\n", i, p.first, p.second);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll N,K;
    cin >> N >> K;

    ll ans = 0;

    vector<int> p(N);
    REP (i, N) {
        cin >> p[i];
    }
    sort(ALL(p));
    REP (j, K) {
        ans += p[j];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"
#define Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything 42

signed main(){
	cout<<fixed<<setprecision(7);
	bool f = false, flag = true;
	int n, m;
	int a, b, c, d;
	string str, S, T;
	int x, y, z;
	// cin>>n>>m;
	
	cin>>x>>y>>z;
	
	cout<<(x-z)/(y+z)<<endl;
	
	// cout<<yn(f)<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in),1);
		String input = r.readLine();
		while (input != null){
			String[] s = input.split(" ");
			int a = Integer.valueOf(s[0]);
			int b = Integer.valueOf(s[1]);
			System.out.println(String.valueOf(a+b).length());
			input = r.readLine();
		}
	}
}

Measured memory_bytes: 24808
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int p[999999];

int main(void){
	int i,j,n,count=0;
	
	memset(p,0,sizeof(p));
	p[0] = 1;
	
	for(i=2;i<=999999;++i){
		for(j=2;i*j<=999999;++j){
			if(p[i*j-1]==0){
				p[i*j-1] = 1;
			}
		}
	}
	
	while(~scanf("%d",&n)){
		for(i=0;i<n;++i){
			if(p[i]==0){
				count++;
			}
		}
		printf("%d\n",count);
		count = 0;
	}
	
	return 0;
	
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll ans=a[n-1];
  ans-=a[0];
  vll h(0);
  vll m(0);
  for(int i=1;i<n-1;i++){
    if(a[i]<0) {
      ans-=a[i];
      m.pb(a[i]);
    }
    else{
      ans+=a[i];
      h.pb(a[i]);
    }
  }
  COUT(ans);
  ll cu=a[0];
  rep(i,sz(h)){
    cout<<cu<<" "<<h[i]<<endl;
    cu-=h[i];
  }
  ll kk=a[n-1];
  rep(i,sz(m)){
    cout<<kk<<" "<<m[i]<<endl;
    kk-=m[i];
  }
  cout<<kk<<" "<<cu<<endl;
}


Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int a, b, c;
  cin >> a >> b >> c;

  for (int i = 1; i <= b; i++) {
    if (a*i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static void main(String args[]) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		long count = 0;
		int dp[] = new int[N];
		for (int i = 0; i < N; i++) {
			if (arr[i] > x) {
				count += arr[i] - x;
				arr[i] = x;
			}
		}
		for (int i = 1; i < N; i++) {
			if (arr[i] + arr[i - 1] > x) {
				count += arr[i] + arr[i - 1] - x;
				arr[i] = x - arr[i - 1];
			}
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 50888
#include<iostream>
#define INF 100000000
#include<queue>
#include<map>
using namespace std;
typedef pair<int,int> P;
int main(){
	int h,w,n,sx,sy,dx[]={1,-1,0,0},dy[]={0,0,1,-1};
	char s[1000][1000];
	
	cin>>h>>w>>n;
	for(int i=0;i<h;i++)
		cin>>s[i];
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	if(s[i][j]=='S'){
		sx=j;
		sy=i;
	}
	int nx,ny,ans=0;
	char nex;
	for(int i=1;i<=n;i++){
		nex='0'+i;
		queue<P> que;
		que.push(P(sy,sx));
		map<P,int> mp;
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		mp[P(i,j)]=INF;
		mp[P(sy,sx)]=0;
		while(!que.empty()){
			P p=que.front();
			que.pop();
			if(s[p.first][p.second]==nex){
				ans+=mp[P(p.first,p.second)];
				sy=p.first;
				sx=p.second;
				break;
			}
			for(int i=0;i<4;i++){
				nx=p.second+dx[i];
				ny=p.first+dy[i];
				if(nx>=0&&nx<w&&ny>=0&&ny<h&&s[ny][nx]!='X'&&mp[P(ny,nx)]>mp[P(p.first,p.second)]+1){
					que.push(P(ny,nx));
					mp[P(ny,nx)]=mp[P(p.first,p.second)]+1;
				}
			}
		}
		
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 32000
import math
a,b,x = map(int, input().split())

if x > a*a*b/2:
    theta = math.atan( (2*a*a*b - 2*x) / a**3 )
    print(math.degrees(theta))
else:
    theta = math.atan( a*b*b / (2*x) )
    print(math.degrees(theta))


Measured memory_bytes: 38512
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vll p(a), q(b), r(c);
    rep(i, 0, a) cin >> p[i];
    rep(i, 0, b) cin >> q[i];
    rep(i, 0, c) cin >> r[i];
    sort_v(p);
    sort_v(q);

    vll array;
    repm(i, a - 1, a - x) array.push_back(p[i]);
    repm(i, b - 1, b - y) array.push_back(q[i]);
    rep(i, 0, c) array.push_back(r[i]);
    sort_v(array);
    reverse_v(array);
    ll sum = 0;
    rep(i, 0, x + y) sum += array[i];
    cout << sum << endl;
}

Measured memory_bytes: 8688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;

int main(){
    string s;
    cin>>s;
    int a=0;
    int b=0;
    REP(i,SZ(s)){
        if(s[i]=='0')a++;
        else b++;
    }
    int ans=2*min(a,b);
    OUT(ans);
    return 0;
}

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

ll dp[51][51][2501];

int main() {
  int N, A;
  cin >> N >> A;
  vector<ll> x(N);
  for (int i = 0; i < N; i++) cin >> x[i];

  ll ans = 0;
  for (int i = 0; i <= N; i++) dp[i][0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i; j++) {
      for (int k = 0; k <= 2500; k++) {
        if (dp[i - 1][j][k] >= 0 && k + x[i - 1] <= 2500) {
          dp[i][j][k + x[i - 1]] += dp[i - 1][j - 1][k];
          if ((k + x[i - 1]) == A * j) ans += dp[i - 1][j - 1][k];
        }
        dp[i][j][k] += dp[i - 1][j][k];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 49152
import sys
sys.setrecursionlimit(10**9)
n,m,q = map(int,input().split())
query = [[int(i) for i in input().split()] for _ in range(q)]

def f(A):
    if len(A) == n+1:
        # print(A)
        cnt = 0
        for i in range(q):
            a,b,c,d = query[i]
            if A[b]-A[a] == c: cnt += d
        return cnt
    res = 0
    for i in range(A[-1],m+1):
        res = max(res,f(A+[i]))
    return res

print(f([1]))

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

int main() {
  int A, B;
  cin >> A >> B;
  if(A<=0 && B>=0) cout << "Zero" << endl;
  else if(A>0 && B>0) cout << "Positive" << endl;
  else{
    if((B-A)%2==0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
  } 
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define MAX_N 100000000
#define INF 100000000000000

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = 1;
  for(int i=0;i<n-1;i++){
    if(s[i] != s[i+1]) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define INF 1000000000

int max(int a, int b)
{
    if (a > b)
    {
        return a;
    }
    return b;
}

int min(int a, int b)
{
    if (a > b)
    {
        return b;
    }
    return a;
}

int main(void)
{
    int W, H;
    while (1)
    {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }
        int status = 0;
        int def = H * H + W * W;
        int distance;
        int ans = INF; // defaultより大きい最小の横長整長方形
        int w, h;
        int ans_h = INF, ans_w = INF;
        for (h = 1; h <= 149; h++)
        {
            if (status != 0)
            {
                break;
            }
            for (w = h + 1; w <= 150; w++)
            {
                if (status != 0)
                {
                    break;
                }
                if (w == W && h == H)
                {
                    continue;
                }
                distance = w * w + h * h;
                if (def == distance)
                {
                    if (h >= H)
                    {
                        ans = def;
                        ans_h = h;
                        ans_w = w;
                        status = 1;
                    }
                }
                else if (def < distance)
                {
                    if (ans > distance) // 直前より対角線の長さが短いとき
                    {
                        ans = distance;
                        ans_h = h;
                        ans_w = w;
                    }
                    else if (ans == distance) // 対角線の長さが同じならば，高さの低いほうが小さい
                    {
                        if (ans_h > h)
                        {
                            ans_h = h;
                            ans_w = w;
                        }
                    }
                }
            }
        }
        printf("%d %d\n", ans_h, ans_w);
    }
    return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int i, count = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for(i = a; i <= b; i++)
	{
		if(c % i == 0)
		{
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

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

string op[] = {"+", "-"};

int main(int argc, const char * argv[]) {
    // insert code here...
    int n;
    scanf("%d", &n);
    int a = n / 1000;
    int b = (n - a*1000) / 100;
    int c = (n - a*1000 - b*100) / 10;
    int d = n - a*1000 - b*100 - c*10;

    string ans = "";
    for (int i = 0; i <= 1; i++) {
        for (int j = 0; j <= 1; j++) {
            for (int k = 0; k <= 1; k++) {
                int v = a;
                if (i == 0) {
                    v += b;
                } else {
                    v -= b;
                }
                if (j == 0) {
                    v += c;
                } else {
                    v -= c;
                }
                if (k == 0) {
                    v += d;
                } else {
                    v -= d;
                }
                if (v == 7) {
                    ans = to_string(a) + op[i] + to_string(b) + op[j] + to_string(c) + op[k] + to_string(d) + "=7";
                }
            }
        }
    }
    if (ans != "") {
        printf("%s\n", ans.c_str());
    }
    return 0;
}

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

int main() {
    int64_t x, y;
    cin >> x >> y;
    
    int64_t count = 0;
    while (y / x > 0) {
        count++;
        x *= 2;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  vector<char> s(9);
  rep(i,9){
    cin >> s[i];
  }
  cout << s[0] << s[4] << s[8] << endl;
}

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

int main() {
	int n,m;
  	cin>>n>>m;
  
  	cout<<(n*(n-1)/2+m*(m-1)/2)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 4096;
const int mod = 998244353;

int ans[MAXN];
int main(){
	int n; cin >> n;
	int l = 1;
	while(l * (l + 1) / 2 < n) l++;
	for(int i=1; i<=l; i++) ans[i] = i;
	n = accumulate(ans, ans + l + 1, 0) - n;
	for(int i=1; i<=n; i++) ans[i]--;
	for(int i=1; i<=l; i++) if(ans[i]) printf("%d\n", ans[i]);
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK: 2000000")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define double long double
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 1000000007;
int n, q;
string s;
set<int> pos['z'+2];

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>s;
	s=" "+s;
	for(int i=1; i<=n; i++){
		pos[s[i]].insert(i);
	}
	cin>>q;
	while(q--){
		int id;
		cin>>id;
		if(id==1){
			int iq;
			char cq;
			cin>>iq>>cq;
			for(char c='a'; c<='z'; c++) if(pos[c].find(iq)!=pos[c].end()) pos[c].erase(pos[c].find(iq));
			pos[cq].insert(iq);
		}
		else{
			int l, r, ans=0;
			cin>>l>>r;
			for(char c='a'; c<='z'; c++){
				if(pos[c].empty() || pos[c].lower_bound(l)==pos[c].end()) continue;
				int xd=(*pos[c].lower_bound(l));
				if(xd<=r) ans++;
			}
			cout<<ans<<"\n";
		}
	}
}


Measured memory_bytes: 26288