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

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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 (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const int kInf = 1e9;
const ll kLInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
   int N;
   cin >> N;
   int val;
   int h[100010];
   REP(i, N) {
      cin >> h[i];
   }
   vector<int> *dp = new vector<int>(N+10, kInf);
   dp->at(0) = 0;
   dp->at(1) = abs(h[1]-h[0]);
   REP(i, N+2) {
      dp->at(i+2) = min(dp->at(i)+abs(h[i+2]-h[i]), dp->at(i+1)+abs(h[i+2]-h[i+1]));
   }
   cout << dp->at(N-1) << endl;
   return 0;
}


Measured memory_bytes: 1024
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    ll gu = 0;
    ll ch = 1;
    ll pa = 2;
    ll blank = 3;
    ll point[4];
    point[blank]=0;
    string S;

    cin >> N;
    cin >> K;
    cin >> point[gu];
    cin >> point[ch];
    cin >> point[pa];
    cin >> S;
    /*
    N = base10_5;
    K = N-1;
    point[gu]=1;
    point[ch]=2;
    point[pa]=3;
    S = "";
    rep(ni,N){
        if(ni%3==0) S+="r";
        else if(ni%3==1) S+="s";
        else S+="p";
    }*/

    vll ans;
    ll ans_index = 0;
    rep(ki,K){
        ans.push_back(blank);
        ans_index++;
    }
    

    rep(si,S.size()){
        stmp = S.substr(si,1);
        if(stmp=="r"){
            ltmp = pa;
        }else if(stmp=="s"){
            ltmp = gu;
        }else{
            ltmp = ch;
        }

        ll bef_index = ans_index - K;
        if(ans[bef_index]==ltmp){
            ans.push_back(blank);
        }else{
            ans.push_back(ltmp);
        }
        ans_index++;
    }

    ll sum = 0;
    rep(ai,ans.size()){
        ll index = ans[ai];
        sum+=point[index];
    }
    cout << sum << endl;

    

}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  int n;
  cin >> n;

  bool judge = false;
  rep (i, 1, 10) {
    if (n % i == 0) {
      if (n / i > 0 && n / i < 10) {
        judge = true;
        break;
      }
    }
  }

  if (judge)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

	return 0;
}


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

int main() {
  long long N,K,Q;
  cin >> N >> K >> Q;
  long long A;
  vector<long long> seikai(N,0);
  for(long long i=0;i<Q;i++){
    cin >> A;
    seikai.at(A-1)++;
  }
  for(long long i=0;i<N;i++){
    long long point = K - (Q - seikai.at(i));
    if(point > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  
  
}


Measured memory_bytes: 1408
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define P pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main()
{
	ll n;
	cin >> n;
	ll dp[100];
	dp[0] = 2;
	dp[1] = 1;
	for (int i = 2;i <= n;i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
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;
    string a, b;
    set<string> se;
    bool ans = true;
    cin >> a;
    se.insert(a);
    for (int i = 1; i < n; i++) {
        cin >> b;
        if (!se.insert(b).second) {
            ans = false;
        }
        if (a[a.size() - 1] != b[0]) {
            ans = false;
        }

        a = b;
    }

    if (ans) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<iostream>
#include<vector>
#include<set>
#include<cmath>
using ll = long long;
using namespace std;

struct prime{
    int n;
    vector<int> f, primes;
    prime(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    vector<pair<ll, int> > factor(ll x){
        vector<pair<ll, int> > res;
        for(auto &p: primes){
            int cnt=0;
            while(x%p == 0){
                cnt++;
                x=x/p;
            }
            if(cnt!=0){
                res.emplace_back(p, cnt);
            }
        }
        if(x!=1){
            res.emplace_back(x, 1);
        }
        return res;
    }
};

int main(){
    ll n;
    cin>>n;
    int ans=0;
    prime s = prime(1000005);
    auto fs = s.factor(n);

    for(auto p: fs){
        ll e = p.second;
        ll current = 1;
        ll tmp = 0;
        while(e >= current){
            e = e-current;
            current++;
            tmp++;
        }
        ans+=tmp;
    }
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 7828
N = int(input())

c = 0
flag = False
for i in range(N):
    c1, c2 = list(map(int, input().split()))
    if c1 == c2:
        c += 1
    elif c>0 and c1 != c2 and c<3:
        c = 0
    if c == 3:
        flag = True
    

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define pb push_back
#define F first
#define S second
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)

# define M_PIl          3.141592653589793238462643383279502884L /* pi */

const ll M=1e9+7;
const int MaxM=100005;


void SieveOfEratosthenes(int n)                                   //all prime <= n
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}


bool isPowerOfTwo (int x)
{
    return x && (!(x&(x-1)));
}



bool comp(pair<int,int> a,pair<int,int> b){
  if(a.F==b.F){
    return a.S>b.S;
  }
  return a.F<b.F;
}




void solve(){

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

for(int i=1;i<n;i++){ 

   a[i]+=max(b[i-1],c[i-1]);
   b[i]+=max(a[i-1],c[i-1]);
   c[i]+=max(a[i-1],b[i-1]);

}

int ans=max(a[n-1],max(b[n-1],c[n-1]));

cout<<ans;

}

int main(){


   int t=1;
//  cin>>t;
   while(t--){
      solve();
       }

 }



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

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

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

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

  def solve(): Unit = {
    val X = ni()
    val ans = if (X == 7 || X == 5 || X == 3) "YES" else "NO"
    out.println(ans)
  }

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

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

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

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


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

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

Measured memory_bytes: 27176
#include <iostream>
#include <string>
#include <vector>

int main(){
  int N, M, s, c;
  std::cin >> N >> M;
  std::string out;
  std::vector<int> called(N, 0);

  
  for (int i = 0; i < N; i++) out.push_back('0');
  
  for (int i = 0; i < M; i++){
    std::cin >> s >> c;
    s -= 1;
    if (called[s] == 0){
      called[s] = 1;
      out[s] = c + '0';
    }
    else if (out[s] != c + '0'){
      std::cout << -1;
      return 0;
    }
  }
  
  if (out[0] == '0'){
    if (called[0] == 1){
      if (N == 1){
        std::cout << 0;
        return 0;
      }
      else{
        std::cout << -1;
        return 0;
      }
    }
    else if (N > 1) out[0] = '1';
  }
  
  std::cout << out;

  return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	int a[50], b[50];
	for (int i = 0;i < m;i++) {
		cin >> a[i] >> b[i];
	}
	int num[50] = {};
	for (int i = 0;i < m;i++) {
		num[a[i]-1]++;
		num[b[i]-1]++;
	}
	for (int i = 0;i < n;i++)cout << num[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<"square1001"<<endl;
  return 0;
}



Measured memory_bytes: 3012
import sys
n = int(sys.stdin.readline().rstrip("\n"))
a = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
a_max = max(a)
c = {num: 0 for num in a}
for num in a:
    c[num] += 1
d = {num: 0 for num in a}
for num in a:
    t = 2
    while num * t <= a_max:
        d[num*t] = 1
        t += 1
ans = 0
for num in a:
    if c[num] == 1 and d[num] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 104256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s; cin >> s;
	int a = 0, b = 0;
	for (char c : s) {
		if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
			a++;
			b = max(a, b);
		}
		else {
			a = 0;
		}
	}
	cout << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(2e5) + 17;

int n;
int a[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    cout << accumulate(a, a + n, 0ll) - n << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]

d = sorted(d)
t = sorted(t)

left = 0
ans = 'YES'
for i in range(m):
    if t[i] < d[left]:
        ans='NO'
        break
    elif t[i] == d[left]:
        left+=1
        if i!= m-1 and left >=n:
            ans = 'NO'
            break
    else:
        while t[i] != d[left]:
            left+=1
            if left >= n:
                ans='NO'
                break
        left+=1
        if left>=n:
            ans = 'NO'
            break
print(ans)

Measured memory_bytes: 35012
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int A ,B ,C ,D;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cout << min(min(A+C,A+D),min(B+C,B+D)) << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n= sc.nextInt();
        int c=0;
        for (int i=1;i<n;i++){
            for (int j=1;j<n;j++){
                if ((i*j)<n)
                    c++;
                else
                    break;
            }
        }
        System.out.println(c);
    }
}


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

using namespace std;


int main()
{
  int N, x;

  cin >> N >> x;


  int bottom = 2 * N - 1;
  deque< int > val;
  bool used[500001] = {};

  if(2 <= x && x + 2 <= bottom) {
    val.push_back(x + 1);
    used[x + 1] = true;
    val.push_back(x);
    used[x] = true;
    val.push_back(x - 1);
    used[x - 1] = true;
    val.push_back(x + 2);
    used[x + 2] = true;


  } else if(1 <= x - 2 && x + 1 <= bottom) {
    val.push_back(x - 1);
    used[x - 1] = true;
    val.push_back(x);
    used[x] = true;
    val.push_back(x + 1);
    used[x + 1] = true;
    val.push_back(x - 2);
    used[x - 2] = true;
  }


  if(val.empty()) {
    if(N == 2 && x == 2) {
      cout << "Yes" << endl;
      cout << "1" << endl;
      cout << "2" << endl;
      cout << "3" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    bool first = false;
    int left = bottom / 2 - 1;
    for(int i = 1; i <= bottom; i++) {
      if(!used[i]) {
        --left;
        if(left >= 0) val.push_front(i);
        else val.push_back(i);
      }
    }
    
    cout << "Yes" << endl;
    for(int v : val) {
      cout << v << endl;
    }
  }
}

Measured memory_bytes: 2816
#include <stdio.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int A[N][N], color[N];
int d[N], f[N];
int time, n;

void dfs(void);
void visit(int);

int main() {
  int u, v, k, i, j;

  scanf("%d", &n);
  for(i = 1; i <= n; i++) {
    for(j = 1; j <= n; j++) {
      A[i][j] = 0;
    }
  }

  for(i = 1; i <= n; i++) {
    scanf("%d", &u);
    scanf("%d", &k);
    for(j = 1; j <= k; j++) {
      scanf("%d", &v);
      A[u][v] = 1;
    }
  }

  dfs();

  for(i = 1; i <= n; i++) {
    printf("%d %d %d\n", i, d[i], f[i]);
  }

  return 0;
}


void dfs() {
  int i;
  for(i = 1; i <= n; i++) {
    color[i] = WHITE;
  }
  time = 0;
  for(i = 1; i<= n; i++) {
    if(color[i] == WHITE) visit(i);
  }
}


void visit(u) {
  int i;
  color[u] = GRAY;
  d[u] = ++time;
  for(i = 1; i<= n; i++) {
    if(A[u][i] == 1) {
      if(color[i] == WHITE) visit(i);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}

Measured memory_bytes: 636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);
			int[] dp = new int[n];
			Arrays.fill(dp, INF);

			for (int i : a) {
				int idx = lowerBound(dp, i);
				dp[idx] = i;
			}

			out.println(lowerBound(dp, INF));

		}

		public static int lowerBound(int[] a, int obj) {
			int l = 0, r = a.length - 1;
			while (r - l >= 0) {
				int c = (l + r) / 2;
				if (obj <= a[c]) {
					r = c - 1;
				} else {
					l = c + 1;
				}
			}
			return l;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}



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

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

    bool b[10000] = {false};
    for(int i=0; i<N; i++) b[i] = true;
    
    int tmp = a[0];
    int count = 0;
    for(int i=1; i<N; i++)
    {
        if(a[i] == tmp)
        {
            bool flag = true;
            for(int j=0; j<10000 && flag; j++)
            {
                if(!b[j])
                {
                    a[i] = j;
                    b[j] = true;
                    count++;
                    flag = false;
                }
            }
        }
        tmp = a[i];
    }

    cout << count;
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
N = len(S)

kazu = [0]*N
right_i = 0
left_i = 0
count = 0

for i in range(1, N - 1):
	if S[i - 1] == "R" and S[i] == "L" and count == 0:
		count = 1
		index = i - 1
		left_i = i
	if count == 1:
		if S[i + 1] == "L":
			left_i += 1
		else:
			count = 0
			a = index - right_i
			if a%2 == 0:
				kazu[index] += a//2
				kazu[index + 1] += a//2 
			else:
				kazu[index] += a//2
				kazu[index + 1] += a//2 + 1 
			a = left_i - (index + 1)
			if a%2 == 0:
				kazu[index] += a//2
				kazu[index + 1] += a//2 
			else:
				kazu[index] += a//2 + 1
				kazu[index + 1] += a//2
			kazu[index] += 1
			kazu[index + 1] += 1 
			right_i = i + 1

if S[N - 2] == "R":
	index = N - 2
left_i = N - 1
a = index - right_i
if a%2 == 0:
	kazu[index] += a//2
	kazu[index + 1] += a//2 
else:
	kazu[index] += a//2
	kazu[index + 1] += a//2 + 1 
a = left_i - (index + 1)
if a%2 == 0:
	kazu[index] += a//2
	kazu[index + 1] += a//2 
else:
	kazu[index] += a//2 + 1
	kazu[index + 1] += a//2
kazu[index] += 1
kazu[index + 1] += 1

for i in kazu:
	print(i, end=" ")

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


int n, m;
int a[60], b[60];
bool graph[60][60];
bool visited[60];

void dfs(int x) {
  visited[x] = true;
  rep(w,60) {
    if(!graph[x][w]||visited[w]) continue;
    dfs(w);
  }
}

int main() {
  cin >> n >> m;
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans = 0;
  rep(i,m) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    rep(j,60) visited[j] = false;
    dfs(0);
    rep(j,n) {
      if(visited[j]==false) {
        ans++;
        break;
      }
    }
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main(){
    int H, W; cin >> H >> W;
    vector<string> S;
    for(int i = 0; i < H; i++) {
        string tmp; cin >> tmp; 
        if( find(tmp.begin(), tmp.end(), '#') == tmp.end()) continue;
        else S.push_back(tmp);
    }
    H = S.size();
    vector<int> B(W);
    for(int j = 0; j < W; j++){
        bool f = true;
        for(int i = 0; i < H; i++){
            if(S[i][j] == '#') f = false;
        }
        if(f) B[j] = 1;
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(B[j] == 1) continue;
            else cout << S[i][j];
        }
        cout << endl;
    }

}

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

static const int MAX = 100;
static const int INFTY = 1 << 21;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void search() {
	int d[MAX], p[MAX], color[MAX];
	for (int i = 0; i < n; i++) {
		p[i] = -1;
		d[i] = INFTY;
		color[i] = WHITE;
	}
	d[0] = 0;
	while (true) {
		int minv = INFTY;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				minv = d[i];
				u = i;
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int i = 0; i < n; i++) {
			if (color[i] != BLACK && M[u][i] != INFTY) {
				if (d[u] + M[u][i] < d[i]) {
					d[i] = d[u] + M[u][i];
					p[i] = u;
					color[i] = GRAY;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			cin >> M[u][v];
		}
	}

	search();
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(c - (a - b), 0LL) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    string s;cin>>s;
    int x=0;
    for(int i=0;i<n;i++)
    {
        x++;
        while(s[i]==s[i+1]&&i<n-1)
        i++;
    }
    cout<<x;
}

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

public class Main {
	private int num;
	private int[] a;
	final String[] rom = {"I", "V", "X", "L", "C", "D", "M"};
	final int[] nrom = {1 , 5, 10, 50, 100, 500, 1000};

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String str = scan.nextLine();
			int n = str.length();
			
			a = new int[n];
			
			for (int i = 0; i < n; i++) {
				a[i] = number(str.substring(i, i+1));
			}
			
			for (int i = 0; i < n - 1; i++) {
				if (a[i] < a[i + 1]) {
					a[i] = a[i + 1] - a[i];
					neat(i + 1, n--);
				}
			}
			//debug();
			num = 0;
			
			for (int i = 0; i < n; i++) {
				num += a[i];
			}
			
			System.out.println(num);
		}
	}
	
	private int number(String s) {
		int i = 0;
		while (true) {
			if (s.equals(rom[i])) break;
			i++;
		}
		return nrom[i];
	}
	
	private void neat(int b, int e) {
		for (int i = b + 1; i < e; i++) {
			a[i - 1] = a[i];
		}
	}
	
	private void debug() {
		System.out.println(Arrays.toString(a));
	}

}

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


using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 10000

int mo[5] = {0,1,0,-1,0};

void calc(int n,int m){
    int a,c,i0,ans=INF;
    
    stack<int> in[3];
    
    for(int i=0;i<3;i++){
        in[i].push(0);
    }
    
    for(int i=0;i<3;i++){
        scanf("%d",&a);
        
        for(int j=0;j<a;j++){
            scanf("%d",&c);
            in[i].push(c);
        }
    }
    
    for(int i=0;i<2;i++){
        stack<int> tray[3];
        int back=-1;
        if(i==1) back = i0;
        
        for(int j=0;j<3;j++){
            tray[j] = in[j];
        }
        
        for(int j=0;j<m;j++){
            
            for(int k=0;k<2;k++){
                
                if(tray[k].size() > 1){
                    if(tray[k].top() > tray[k+1].top() && k!=back){
                        tray[k+1].push(tray[k].top());
                        tray[k].pop();
                        back=k;
                        break;
                    }
                }
                
                if(tray[k+1].size() > 1){
                    if(tray[k].top() < tray[k+1].top() && k!=back){
                        tray[k].push(tray[k+1].top());
                        tray[k+1].pop();
                        back=k;
                        break;
                    }
                }
            }
            
            if(i==0 && j==0)
                i0=back;
            
            if(tray[0].size()==n+1 || tray[2].size()==n+1){
                ans = min(ans,j+1);
                break;
            }
        }
    }
    if(ans < INF)
        printf("%d\n",ans);
    else
        puts("-1");
    
}

int main(){
    int n,m;
    
    while(1){
        scanf("%d%d",&n,&m);
        if(n==0) break;
        calc(n,m);
    }
    
    
    return 0;
}

Measured memory_bytes: 1200
#16:00
n,m = map(int,input().split())
a = list(map(lambda x:int(x)-1,input().split()))
pre = [i for i in range(n)]
for _ in range(m):
  X,Y = map(int,input().split())
  X -= 1
  Y -= 1
  while pre[X] != X:
    X = pre[X]
  while pre[Y] != Y:
    Y = pre[Y]
  if X == Y:
    continue
  elif X < Y:
    pre[Y] = X
  else:
    pre[X] = Y
#print(a)
#print(pre)
region = [[] for _ in range(n)]
ser = [[] for _ in range(n)]
for i in range(n):
  b = a[i]
  I = i
  while pre[I] != I:
    I = pre[I]
  region[I].append(b)
  ser[I].append(i)
#print(region)
#print(ser)
home = [10**6 for _ in range(n)]
mother = [10**6 for _ in range(n)]
for i in range(n):
  for x in region[i]:
    home[x] = i
for i in range(n):
  for y in ser[i]:
    mother[y] = i
#print(home)
#print(mother)
ans = []
for i in range(n):
  if home[i] == mother[i]:
    ans.append(i)
#print(ans)
print(len(ans))

Measured memory_bytes: 88428
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
//const bool is_in = container.find(element) != container.end();

int main() 
{
	zapp;
	int n,k,i,j;
	vector<int> d;
	vector<vector<int>> a;
	cin>>n>>k;
	d.resize(k);
	a.resize(k,vector<int>());
	for(i=0;i<k;i++) 
	{
		cin>>d[i];
		a[i].resize(d[i]);
		for(j=0;j<d[i];j++) 
		{
			cin>>a[i][j];
		}
	}
	int ans = 0;
	for(i=1;i<=n;i++) 
	{
		bool have = false;
		for(auto v : a) 
		{
			for(auto p : v) 
			{
				if(p == i) 
					have = true;
			}
		}
	if(!have) 
		ans++;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 3640
import sys

for line in sys.stdin:
  l = list(map(float,line.split()))
  ax,ay,bx,by,cx,cy,dx,dy = [int(i*(10**5)) for i in l] 
  dx1 = bx - ax
  dy1 = by - ay
  dx2 = dx - cx
  dy2 = dy - cy
  x = dx1 * dx2
  y = dy1 * dy2
  if x + y == 0:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 7408
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<lli,lli>
struct triplet{int index,a,b;};bool comp (triplet &t1, triplet &t2){return (t1.a < t2.a);}
lli dp[101][100001];
int main()
{
    fio;
    lli N,W;
    cin>>N>>W;
    int w[N],v[N];
    for(lli i=0;i<N;i++)
    cin>>w[i]>>v[i];
     for(int i=0;i<100;i++)
        for(int j=0;j<=100000;j++)
        if(j==0)
            dp[i][j]=0;
        else
            dp[i][j]=INT_MAX;


    dp[0][v[0]]=w[0];
    for(int i=1;i<N;i++)
    {
        for(int j=0;j<=100000;j++)
        if(j>=v[i])
        {
            dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);


        }
        else
            dp[i][j]=dp[i-1][j];


    }
    lli ans=0;
    for(int i=1;i<100001;i++)
        if(dp[N-1][i]<=W)
        ans=i;


        cout<<ans;

}


Measured memory_bytes: 78336
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
c = list(input())

r_cnt = c.count('R')
w_cnt = c.count('W')

ans = min(r_cnt, w_cnt)

from heapq import heappush, heappop

r_heapq = []
w_heapq = []

for i in range(1, n + 1):
    if c[i - 1] == "R":
        heappush(r_heapq, -i)
    else:
        heappush(w_heapq, i)
cnt = 0
while w_heapq and r_heapq:
    if heappop(w_heapq) < -heappop(r_heapq):
        cnt += 1
ans = min(ans, cnt)
print(max(ans, 0))
    
    

Measured memory_bytes: 90748
N = int(input())
S = str(input())
R, G, B = 0, 0, 0
for i in range(N):
  if S[i] == "R":
    R += 1
  elif S[i] == "G":
    G += 1
  else:
    B += 1
    
ans = R * G * B 

for i in range(1, 2000):
  for j in range(1, N - 2 * i + 1):
    if S[j - 1] != S[j + i - 1]:
      if S[j + 2 * i - 1] != S[j + i - 1]:
        if S[j - 1] != S[j + 2 * i - 1]:
          ans -= 1
            
print(max(ans, 0))
  


Measured memory_bytes: 9208
from itertools import accumulate
N, W = map(int, input().split())
w0, w1, w2, w3 = [], [], [], []
base_w = -1
for i in range(N):
    w, v = map(int, input().split())
    if base_w < 0:
        base_w = w

    # 重みごとの箱にいれる
    w -= base_w
    if w == 0:
        w0.append(v)
    elif w == 1:
        w1.append(v)
    elif w == 2:
        w2.append(v)
    else:
        w3.append(v)

# 降順ソート
w0.sort(reverse=True)
w1.sort(reverse=True)
w2.sort(reverse=True)
w3.sort(reverse=True)

# 累積和
w0 = [0] + list(accumulate(w0))
w1 = [0] + list(accumulate(w1))
w2 = [0] + list(accumulate(w2))
w3 = [0] + list(accumulate(w3))

ans = 0
for i0 in range(len(w0)):
    for i1 in range(len(w1)):
        for i2 in range(len(w2)):
            for i3 in range(len(w3)):
                if base_w * i0 + (base_w + 1) * i1 + (base_w + 2) * i2 + (base_w + 3) * i3 > W:
                    continue
                ans = max(ans, w0[i0] + w1[i1] + w2[i2] + w3[i3])

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

char solver(string &x) {
    char nextturn = x[0];
    reverse(ALL(x));
    x.pop_back();
    reverse(ALL(x));
    return nextturn;
}

char solve(string &A, string &B, string &C) {
    char nowturn = 'a';
    while (true) {
        if (nowturn == 'a') {
            if (len(A) == 0) return 'A';
            nowturn = solver(A);
        } else if (nowturn == 'b') {
            if (len(B) == 0) return 'B';
            nowturn = solver(B);
        } else {
            if (len(C) == 0) return 'C';
            nowturn = solver(C);
        }
    }
}

int main() {
    string A, B, C; cin >> A >> B >> C;
    cout << solve(A, B, C) << endl;
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;


int main(){
    int A,B,Q;
    cin >> A >> B >> Q;
    
    vector<ll> s;
    vector<ll> t;
    
    for(int i=0; i<A; i++){
        ll a;
        cin >> a;
        s.push_back(a);
    }
    
    for(int i=0; i<B; i++){
        ll b;
        cin >> b;
        t.push_back(b);
    }
    
    
    ll x[100001];
    ll y[100001];
    for(int i=0; i<Q; i++){
        cin >> x[i];
        y[i]=x[i];
    }
    pair<ll,int> yidx[100001];
    for(int i=0; i<Q; i++){
        yidx[i].first=y[i];
        yidx[i].second=i;
    }
    sort(yidx,yidx+Q);
    
    sort(x,x+Q);
    
    
    ll ls[100001];
    ll lt[100001];
    ll rs[100001];
    ll rt[100001];
    
    for(int i=0; i<Q; i++){
        ls[i]=-1;
        lt[i]=-1;
        rs[i]=-1;
        rt[i]=-1;
    }
    
    ll temp=0;
    for(int i=0; i<Q; i++){
        while(t[temp]<=x[i] && temp<B){
            temp++;
        }
        lt[i]=temp-1;
    }
    
    temp=0;
    for(int i=0; i<Q; i++){
        while(s[temp]<=x[i] && temp<A){
            temp++;
        }
        ls[i]=temp-1;
    }
    
    temp=0;
    for(int i=0; i<Q; i++){
        while(t[temp]<x[i] && temp<B){
            temp++;
        }
        rt[i]=temp;
    }
    
    temp=0;
    for(int i=0; i<Q; i++){
        while(s[temp]<x[i] && temp<A){
            temp++;
        }
        rs[i]=temp;
    }
    
    ll answer[100001];
    
    for(int i=0; i<Q; i++){
        ll ans=INF;

        if(ls[i]>=0){
            if(lt[i]>=0){
                //ls and lt
                ans=min(ans, x[i]-min(s[ls[i]],t[lt[i]]) );

            }
            if(rt[i]>=0 && rt[i]<B){
                //ls and rt
                ll temp_ans=(t[rt[i]]-s[ls[i]]) + min(t[rt[i]]-x[i], x[i]-s[ls[i]]);
                ans = min(ans,temp_ans);

            }
        }
        
        if(rs[i]>=0 && rs[i]<A){
            if(rt[i]>=0 && rt[i]<B){
                //rs and rt
                ans = min(ans, max(s[rs[i]],t[rt[i]])-x[i] );

            }
            if(lt[i]>=0){
                //rs and lt
                ll temp_ans= (s[rs[i]]-t[lt[i]]) + min(s[rs[i]]-x[i], x[i]-t[lt[i]]  );
                ans = min(ans,temp_ans);

            }
        }
        
        answer[yidx[i].second]=ans;
    }
    
    
    for(int i=0; i<Q; i++){
        cout<<answer[i]<<endl;
    }



    
        
    return 0;
}


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

const int maxp = 2999+10;

int p, a[maxp];
int MOD(int x) { return (x%p+p)%p; }
void mod(int &x) { x = MOD(x); }

int f[maxp], g[maxp];
int ans[maxp];

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

	f[0] = 1;
	for (int i = 0; i < p; ++i) {
		memset(g, 0, sizeof(g));
		for (int j = 0; j <= p; ++j) {
			mod(g[j] += f[j]*i);
			mod(g[j+1] += f[j]);
		}
		swap(f, g);
	}
	for (int i = 0; i < p; ++i) if (a[i]) {
		memset(g, 0, sizeof(g));
		for (int j = p-1; ~j; --j) {
			g[j] = MOD(f[j+1]+i*g[j+1]);
			mod(ans[j]-=g[j]);
		}
	}
	for (int i = 0; i < p; ++i)
		cout << ans[i] << ' ';
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 1;
  rep(i,n-1){
    if(s[i]!=s[i+1]) cnt++;
  }
  cout << cnt << endl;
    
         
  
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    vector<int> b(m),c(m);
    for(int i=0;i<m;i++) cin>>b[i]>>c[i];
    vector<int> ids(m);
    iota(ids.begin(),ids.end(),0);
    sort(ids.begin(),ids.end(),[&](int lhs,int rhs){return c[lhs]>c[rhs];});
    int iter=0;
    for(int i=0;i<n && iter<m;i++){
        int id=ids[iter];
        if(b[id] && a[i]<c[id]){
            a[i]=c[id];
            b[id]--;
        }
        else{
            iter++;
            i--;
        }
    }
    cout<<accumulate(a.begin(),a.end(),0LL)<<endl;
    return 0;
}

Measured memory_bytes: 1792
N,T = map(int,(input().split()))
c = [[0]*2 for _ in range(N)]
ans = []
for i in range(N):
    c[i][0],c[i][1] = map(int,(input().split()))
    if c[i][1] <= T:
        ans.append(c[i][0])
if ans:
    ans.sort()
    print(ans[0])
else:
    print("TLE")

Measured memory_bytes: 38512
import math
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n=int(input())
s=[]
for _ in range(n):
    s.append(sorted(input()))
s=sorted(s)

now=1
sum=0
for i in range(n-1):
    if s[i]==s[i+1]:
        now+=1
    else:
        if now!=1:
            sum+=cmb(now, 2)
        now=1

if now!=1:
    sum+=cmb(now, 2)
print(sum)





Measured memory_bytes: 101080
#include <bits/stdc++.h>
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << x << endl;

using namespace std;

inline void read(int &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void read(long long &x){register int c = getchar();x = 0; int neg = 0;for (;((c<48 || c>57) && c != '-') ;c = getchar());if(c=='-') {neg=1;c=getchar();}for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
inline void writeln(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar('\n');}
inline void write(long long x){char buffor[21];register int i=0;int neg=0; if (x<0) {neg=1; x= -x;}do{buffor[i++]=(x%10)+'0';x/=10;} while(x);i--;if (neg) putchar('-');while(i>=0) putchar(buffor[i--]);putchar(' ');}

string s;
int n, res;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> s;
	n = s.size();
	s = ' ' + s;
	res = n;
	for (int i = 1; i < n; i++){
		if (s[i] != s[i + 1])
			res = min(res, max(i, n - i));
	}
	cout << res;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  string S;
  cin>>S;
  string su = "Sunny",cl = "Cloudy", ra = "Rainy";
  if(S==su){
    cout<<cl<<endl;
  }else if(S==cl){
    cout<<ra<<endl;
  }else{
    cout<<su<<endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#define N 101

int a[N];
int count=0;

void swap(int *x,int *y){
  int t=*x;
  *x=*y;
  *y=t;
}

void bubblesort(int n){
  int flag=1;
  /* flag: ????????£??\????´?(?????????????????????
     ????????§????°??????????????????£??????????????£???????´?)????????????????????? 1:true,0:false */
  while(flag){  // flag==1????????????  flag==0???break
    flag=0;
    int i,j;
    for(i=0;i<n;i++){ // ??????????????¨???????????????????´???????
      for(j=n-1;j>i;j--){
	if(a[j]<a[j-1]){
	  swap(&a[j],&a[j-1]);
	  flag=1;
	  count++;
	}
      }
    }
  }
}

int main()
{
  int n;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  bubblesort(n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

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

const int MOD=1e9+7;
using namespace std;
typedef long long ll;
 
void solve() {
  ll k, a, b;
  cin >> a >> b >> k;
  ll count=0;
  ll ret = a;
  for ( ret = a ; ret > 0 ; ret-- )
  {
    if( (0==a%ret) && (0==b%ret) )
    {
      count++;
      if ( count == k ) break;
    }
  }
    
  std::cout << ret << std::endl;
}

int main(int argc, char *argv[])
{
  solve();
  return 0;
}

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

int main(void){
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    int n,k;
    cin>>n>>k;
    int x[n];
    for(int j=0;j<n;j++){
      cin>>x[j];
    }
    int distance[n-1];
    for(int j=0;j<n-1;j++){
      distance[j]=x[j+1]-x[j];
    }
    sort(distance,distance+n-1);
    int length=0;
    for(int j=0;j<n-k;j++){
      length+=distance[j];
    }
    cout<<length<<endl;
  }
  return 0;
}



Measured memory_bytes: 3932
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int a[3][3];
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j ++){
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  int b[n];
  for (int k = 0; k < n; k++){
    cin >> b[k];
    for (int l = 0; l < 3; l++){
      for (int m = 0; m < 3; m++){
        if (b[k] == a[l][m]){
          a[l][m] = 0;
        }
      }
    }
  }
  if (a[0][0]+a[0][1]+a[0][2]==0 ||
     a[1][0]+a[1][1]+a[1][2]==0 ||
     a[2][0]+a[2][1]+a[2][2]==0 ||
     a[0][0]+a[1][0]+a[2][0]==0 ||
     a[0][1]+a[1][1]+a[2][1]==0 ||
     a[0][2]+a[1][2]+a[2][2]==0 ||
     a[0][0]+a[1][1]+a[2][2]==0 ||
     a[0][2]+a[1][1]+a[2][0]==0){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256