akhauriyash/Code-Regression huggingface dataset:
#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;
#define X real()
#define Y imag()
#define EPS (1e-10)
typedef complex<double> P;
typedef pair<P, P> L;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

P projection(P a, P b){
  return dot(a, b)/abs(b)/abs(b)*b;
}

P intersection(L a, L b){
  //直線aと直線bの交点
  return a.first + cross(b.second-b.first,a.first-b.first)/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
}

int main(){
  int q;
  cin >> q;
  P points[4];
  for(int i = 0; i < q; ++i){
    for(int j = 0; j < 4; ++j){
      double x, y;
      cin >> x >> y;
      points[j] = P(x, y);
    }
    L l1 = L(points[0],points[1]), l2 = L(points[2], points[3]);
    printf("%.10lf %.10lf\n", intersection(l1, l2).X, intersection(l1, l2).Y);
  }
  return 0;
}



Measured memory_bytes: 3200
#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;
  string s;
  int count = 0;
  cin >> n >> s;
  rep(i,1000){
    int c[3] = {i/100,(i/10)%10,i%10};
    int f = 0;
    for(int j = 0;j<n;++j){
      if(s[j] == 48 + c[f]) f++;
      if(f == 3) break;
    }
    if(f == 3) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
	//*/
	int N = 0;
	boolean ans = false;
	public void input() throws IOException {
		/*
		S = br.readLine();
		/*/
		N = in.nextInt();
	}
 
	public void solve() throws IOException {
		int val = 0;
		int Nbak = N;
		while(N>0){
			val += (N%10);
			N = N/10;
		}
		ans = (Nbak % val == 0);
	}
	
	
	public void output() {
		out.println(ans?"Yes":"No");
		out.flush();
	}
}
 
 
//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/


Measured memory_bytes: 21204
def main():
    MOD = 10**9 + 7
    N = int(input())
    C = [int(input()) - 1 for _ in range(N)]
    if N == 1:
        print(1)
        return
    # |---|
    # 1-2-1-2-2
    #   |---|
    latest_indices = [-1] * (2 * (10**5))
    next_indices = [-1] * N
    for cur_index, c in enumerate(C):
        latest_index = latest_indices[c]
        if latest_index >= 0:
            next_indices[latest_index] = cur_index
        latest_indices[c] = cur_index
    dp = [0] * N
    dp[0] = 1
    for cur_index in range(N - 1):
        next_index = next_indices[cur_index]
        if next_index > cur_index + 1:
            dp[next_index] += dp[cur_index]
            dp[next_index] %= MOD
        dp[cur_index + 1] += dp[cur_index]
        dp[cur_index + 1] %= MOD
    print(dp[N - 1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 92268
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int a,b,c;

	cin >> a >> b >> c;
	int count =0;
	for(int x = a; x <=b; x++) {
		if ( (c % x) == 0) count++;
	}
	cout << count << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int N = 190;
const int ANS = 17;

int dp[ANS][N][N][N];
int wr[N][N];

int n, m;

void relax(int i1, int i2, int j, int to) {
    dp[to][j][i1][i2] = -1;
    {
        int l = i1;
        int r = i2 - 1;
        if (i1 < i2 && wr[i1][i2 - 1] != -1 && wr[i1 + 1][i2] != -1) {
            l = max(l, wr[i1][i2 - 1]);
            r = min(r, wr[i1 + 1][i2]);
        }
        for (int mid = l; mid <= r; mid++) {
            int f = dp[to - 1][j][i1][mid];
            int s = dp[to - 1][j][mid  + 1][i2];
            if (dp[to][j][i1][i2] < min(f, s)) {
                dp[to][j][i1][i2] = min(f, s);
                wr[i1][i2] = mid;
            }
        }
    }
    {
        int len = dp[to - 1][j][i1][i2];
        if (j + len == m) {
            dp[to][j][i1][i2] = max(dp[to][j][i1][i2], len);
        } else {
            dp[to][j][i1][i2] = max(dp[to][j][i1][i2], len + dp[to - 1][j + len][i1][i2]);
        }
    }
}

int ps[N][N];
int a[N][N];

void init() {
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            ps[i][j] = ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1] + a[i - 1][j - 1];
        }
    }
    auto ok = [&](int i1, int i2, int j, int len) {
        i2++;
        int s = ps[i2][j + len] - ps[i1][j + len] - ps[i2][j] + ps[i1][j];
        int rs = (i2 - i1) * len;
        return s == rs || s == 0;
    };
    for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = i1; i2 < n; i2++) {
            for (int j = 0; j < m; j++) {
                for (int len = 0; j + len <= m; len++) {
                    if (ok(i1, i2, j, len)) dp[0][j][i1][i2] = len;
                }
            }
        }
    }
}

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

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            a[i][j] = (c == '#');
            // a[i][j] = rand() & 1;
        }
    }
    init();
    for (int to = 1; to < ANS; to++) {
        for (int j = 0; j < m; j++) {
            for (int i1 = 0; i1 < n; i1++) {
                for (int i2 = i1; i2 < n; i2++) {
                    wr[i1][i2] = -1;
                }
            }
            for (int i1 = n - 1; i1 >= 0; i1--) {
                for (int i2 = i1; i2 < n; i2++) {
                    relax(i1, i2, j, to);
                }
            }
        }   
    }
    for (int to = 0; to < ANS; to++) {
        if (dp[to][0][0][n - 1] == m) {
            cout << to << endl;
            return 0;
        }
    }
}   


Measured memory_bytes: 455552
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> d(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    int counter = 1;
    for (size_t i = 0; i < n-1; i++)
    {
        if(d[i] == d[i+1])continue;
        else counter ++;
    }

    cout << counter << endl;
    
    return 0;
}

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

int main() {
  int n; cin >> n;
  int a[200];
  rep(i,n){
    cin >> a[i];
  }
  int count = 0;
  bool flag = true;

  while(flag){
    flag = false;
    for(int j = n-1; j>0; j--){
      if(a[j] < a[j-1]){
        flag = true;
        swap(a[j],a[j-1]);
        count++;
      }
    }
  }

  rep(i,n){
    if(i>0) cout << " ";
    cout << a[i];
  }
  cout << endl << count << endl;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    cout << (int) pow(N, 3) << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

int main() {
  string s;
  cin >> s;
  
  int x, y;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'A') {
      x = i;
      break;
    }
  }
  
  for(int j = s.size() - 1; j >= 0; j--) {
    if(s[j] == 'Z') {
      y = j;
      break;
    }
  }
  cout << y - x + 1 << endl;
}  


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

int main(void){
  char N[3];

scanf("%s", &N);

if(N[0] == '7'){
    printf("Yes");
}else if(N[1] == '7'){
    printf("Yes");
}else if(N[2] == '7'){
    printf("Yes");
}else{
    printf("No");
}
  
  //printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 1728
use std::io;


fn main() {
    let n = read_one::<String>();
    println!("ABC{}", n);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;

    int n;
    cin >> n;
    vector<string> judge{"AC", "WA", "TLE", "RE"};
    int count[4]{0};

    rep(_, n) {
        string order;
        cin >> order;

        if ("AC" == order) {
            count[0] += 1;
        } else if ("WA" == order) {
            count[1] += 1;
        } else if ("TLE" == order) {
            count[2] += 1;
        } else {
            count[3] += 1;
        }
    }

    for (size_t i = 0; i < 4; i++) {
        cout << judge.at(i) << " x " << count[i] << endl;
    }
}

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

using namespace std;

int main(){
    
    int N,K,X,Y;
    int ans = 0;
    
    cin >> N >> K >> X >> Y;
    
    for(int i = 0; i <N; i++){
     
        if(i>=K)
            ans+=Y;
        else
            ans+=X;
        
    }
    
    cout << ans <<endl;
    
    
    return 0;
}

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


Measured memory_bytes: 2104
#include <stdio.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define ll long long
int main(void){
    int n,a;
    int num=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if(a%2==1) num++;
    }
    if(num%2==1) puts("NO");
    else puts("YES");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int n, t[100], m, p[100], x[100], ta = 0;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		ta += t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cout << ta - (t[p[i] - 1] - x[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		
		Set<Integer> set = new HashSet<>();
		for(int i = 1;;++i) {
			int num = (A * i) % B;
			if(!set.contains(num))
				set.add(num);
			else
				break;
		}
		if(set.contains(C))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


Measured memory_bytes: 22612
#include <vector>
#include <iostream>
#include <cstdlib>
#include <string>

static const int INF = 1001001001;

using namespace std;

int main()
{
	string s;
	cin >> s;
	int start, end;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'A') {
			start = i;
			break;
		}
	}
	for (int i = s.size() - 1; i >= 0; --i) {
		if (s[i] == 'Z') {
			end = i;
			break;
		}
	}

	cout << end - start + 1 << endl;
	return 0;
}


Measured memory_bytes: 832
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


long long solve() {
    long long N, X, M;
    cin >> N >> X >> M;

    const int MAXD = 55;
    vector<vector<long long>> nex(MAXD+1, vector<long long>(M, -1)),
                              sum(MAXD+1, vector<long long>(M, 0));
    for (long long r = 0; r < M; ++r) {
        nex[0][r] = r * r % M;
        sum[0][r] = r;
    }
    for (int p = 0; p < MAXD; ++p) {
        for (int r = 0; r < M; ++r) {
            nex[p+1][r] = nex[p][nex[p][r]];
            sum[p+1][r] = sum[p][r] + sum[p][nex[p][r]];
        }
    }
    long long res = 0;
    int cur = X;
    for (int p = MAXD; p >= 0; --p) {
        if (N & (1LL<<p)) {
            res += sum[p][cur];
            cur = nex[p][cur];
        }
    }
    return res;
}

int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 91596
#include <bits/stdc++.h>
using namespace std;
#define ll 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 ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());  // 昇順に並べる
  return ret;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  vector<long long> ret = divisor(n);
  for (auto x : ret) {
    ll _n = (n / x) - 1;
    if (_n != 0 && (n / _n == n % _n)) {
      ans += _n;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cstdio>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    long int n;
    cin >> n;
    long int num[n+1];
    fill(num, num + n + 1, 0);
    long int a[n];
    rep(i, n) {
        cin >> a[i];
        num[a[i]]++;
    }
    long int sm = 0;
    rep(i, n + 1){
        sm += (num[i] * (num[i] - 1)) / 2;
    }
    rep(i, n){
        long int ans = sm;
        ans -= (num[a[i]] * (num[a[i]] - 1)) / 2;
        ans += ((num[a[i]] - 1) * (num[a[i]] - 2)) / 2;
        cout << ans << endl;
    }

}


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

int main(){
  int n, k;
  cin >> n >> k;
  ll ans = 1;
  for (int i = 0; i < n; ++i) {
    if(ans * 2 > ans + k) ans += k;
    else ans *= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
B = LI()
ans = INF
for odd_ind in combinations(range(n), n // 2):
    even_ind = set(range(n)) - set(odd_ind)
    odd_list = []
    even_list = []
    whole_num_list = []
    whole_idx_list = []
    for i in odd_ind:
        if i % 2:
            odd_list += [(A[i], i)]
        else:
            odd_list += [(B[i], i)]
    for j in even_ind:
        if j % 2:
            even_list += [(B[j], j)]
        else:
            even_list += [(A[j], j)]
    even_list.sort(reverse=1)
    odd_list.sort(reverse=1)
    while even_list or odd_list:
        x, idx = even_list.pop()
        whole_num_list += [x]
        whole_idx_list += [idx]
        if odd_list:
            x, idx = odd_list.pop()
            whole_num_list += [x]
            whole_idx_list += [idx]
    if whole_num_list == sorted(whole_num_list):
        cnt = 0
        for i in range(n):
            for j in range(i + 1, n):
                if whole_idx_list[i] > whole_idx_list[j]:
                    cnt += 1
        ans = min(ans, cnt)


if ans == INF:
    print(-1)
else:
    print(ans)




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



int main() {
  cin.tie(0);
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if (C-(A-B)>=0) printf("%d",(C-(A-B)));
  else printf("%d",0);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int total, tmp;
	
	while(1){
		cin >> total;
		if(total == 0){
			break;
		}
		
		for(int i = 2; i <= 10; i++){
			cin >> tmp;
			total -= tmp;
		}
		
		cout << total << endl;
	}
	
	return 0;
}

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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif


void solve(){
	int n;
	cin>>n;
	vector<vector<int>> d(n,vector<int> (2));
	for(int i=0;i<n;i++){
		cin>>d[i][0]>>d[i][1];
	}
	bool f = 0;
	for(int i=0;i<n-2;i++){
		bool ok= true;
		for(int j=0;j<3;j++){
			ok &= (d[i+j][0]==d[i+j][1]);
		}
		f |= ok;
	}
	cout<<((f)?"Yes":"No")<<endl;
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


Measured memory_bytes: 3628
//問題URL
    //

    //解き方メモ
    //
    
    #include<iostream>
    using namespace std;

    int main(){
        int r,g;
        int result;

        //R,G入力
        cin >> r >> g;

        //出力
        cout << 2*g-r << endl;

        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	double a; cin>>a;
	int b=a-(a/2);
	double c=b;
	cout<<1-(c/a)<<endl;
	
	return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

ll M = 1e9+7;

int main() {
	int N;
	cin >> N;
	vector<int> T(N), A(N);
	rep(i,N) cin >> T[i];
	rep(i,N) cin >> A[i];
	ll res = 1;

	if(T.back() != A[0]) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i < N-1; i++) {
		if(T[i] != T[i-1] && A[i] != A[i+1]) {
			if(T[i] != A[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		else if(T[i] != T[i-1]) {
			if(T[i] > A[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		else if(A[i] != A[i+1]) {
			if(A[i] > T[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		else {
			res = res * min(T[i],A[i]) % M;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    var (K,N) = readLine()!!.split(" ").map { it.toInt() }
    var a = readLine()!!.split(" ").map { it.toInt() }

    val d = Array(N){i: Int -> a[(i+1)%N] - a[i]}
    d[N-1] += K
    println(K-d.max()!!)
}

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

int main() {
  long long int x,m=100,ans=0;
  cin>>x;

  while(m<x){
    m=m*1.01;
    ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define getMat(x, n, m, val) vector<vector<ll>> x(n, vector<ll> (m, val))
#define setp fixed<<setprecision
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll M=1000000000+7;
 
ll power(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

int main(){
    fastio;
    string s,t;
    cin>>s>>t;
    ll ans=INT_MAX;
    for(ll i=0;i<=s.length()-t.length();i++){
        ll d=0;
        for(ll j=i;j<t.length()+i;j++){
            if(s[j]!=t[j-i])d++;
        }
        ans=min(ans,d);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

char num[3] ={'7', '5', '3'};



bool check(string s, ll N){
  if(s.size() && stoll(s) > N)return false;
  for(int i = 0; i < 3; i++) if(s.find(num[i]) == string::npos) return false;
  return true;
}

int dfs(ll N, string s){
  // cout << s << endl;
  if(s.size() == 9) return check(s, N);
  int ret = 0;
  for(int i = 0; i < 3; i++){
    ret += dfs(N, s + num[i]);
  }
  ret += check(s, N);
  return ret;
}

int main(){
  ll N;
  cin >> N;
  cout << dfs(N, "") << endl;
}


Measured memory_bytes: 256
while True:
  H, W = map(int, input(). split())
  if H == 0 and W == 0:
    break
  print('#' * W)
  for i in range(1, H-1):
    print('#', end='')
    for j in range(1, W-1):
      print('.', end='')
    print('#')
  print('#' * W)
  print()


Measured memory_bytes: 6992
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  string s; readV(s);

  auto t = new int[](n);
  foreach (i; 0..n) t[i] = cast(int)(s[i]-'a');

  auto calc(int[] a, int[] b)
  {
    return setIntersection(a.dup.sort().uniq, b.dup.sort().uniq).walkLength.to!int;
  }

  auto m = 0;
  foreach (i; 1..n-1)
    m = max(m, calc(t[0..i], t[i..$]));

  writeln(m);
}


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

N = int(input())
H = list(map(int, input().split()))

ans = 0
n = 0
before = H.pop(0)

for x in H:
    if x <= before:
        n += 1
        before = x
    else:
        n = 0
        before = x

    if n >= ans:
        ans = n

print(ans)


Measured memory_bytes: 15020
#include <stdio.h>

int main() {
  int n;
  int x;
  int i;
  int min = 1001;

  scanf("%d %d", &n, &x);

  for (i = 0; i < n; i++) {
    int m;
    scanf("%d", &m);
    x -= m;
    if (m < min) {
      min = m;
    }
  }

  printf("%d\n", n + x/min);
  
  return 0;
}


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

int mod = 1e9+7;

signed main(){
  
    int n,b;
    cin >> n >> b;

     int dig = (int)(floor( log(n) /  
                         log(b)) + 1);

     cout << dig << endl;

  //cout << fixed << setprecision(8) << ans << endl;
  return 0;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	int n, m;
	cin >> n >> m;

	int ans = (n - m) * 100 + m * 1900;

	int rate = 1 << m;
	ans *= rate;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args){
    string[] input = Console.ReadLine().Split(' ');
    int L = int.Parse(input[0]);
    int R = int.Parse(input[1]);
    int d = int.Parse(input[2]);
    Console.WriteLine(R/d - (L-1)/d);
  }
}

Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int gcd(int a, int b){
  return b ? gcd(b, a%b) : a;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    if(n==2){
        cout<<max(a[0], a[1])<<endl;
        return 0;
    }
    vector<int> gcdl(n+1, 0), gcdr(n+1, 0);
    for(int i=0;i<n;i++) gcdl[i+1]=gcd(gcdl[i], a[i]);
    for(int i=n-1;i>=0;i--) gcdr[i]=gcd(gcdr[i+1], a[i]);
    int ans=0;
    for(int i=0;i<n;i++){
        int l = gcdl[i];
        int r = gcdr[i+1];
        chmax(ans, gcd(l, r));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
int l,r,largest;
l=2*i;
r=2*i+1;

 if(l<=H && A[l] > A[i] ) largest = l;
 else largest = i;
 if(r<=H && A[r] > A[largest]) largest = r;

 if(largest != i){
   swap(A[i],A[largest]);
   maxHeapify(largest);
 }
}

int main(){
  cin >> H;

  for(int i=1; i<=H;i++) cin >> A[i];
  for(int i=H/2;i>=1;i--) maxHeapify(i);

  for(int i=1;i<=H;i++){
    cout << " " << A[i];
  }
    cout << endl;

    return 0;
  }

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

using namespace std;


#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int 
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))


int solve(){

   string typeC;

   cin >> typeC;

   if(typeC == "ABC") cout << "ARC" << endl;
   else cout << "ABC" << endl;
    
    return 0;
}

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


    time__("programm time"){
        solve();
	}
    return 0;

}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
int main() {
	int a, v, b, w, t;
	scanf("%d%d%d%d%d", &a, &v, &b, &w, &t);
	if(v<=w) {
		puts("NO");
		return 0;
	}
	if(v>w && abs(a-b)<=1ll*t*(v-w))
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 3688
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] t = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++)
			sum += (t[i] = sc.nextInt());
		int m = sc.nextInt();
		int p, x;
		for(int i = 0; i < m; i++)
			System.out.println(sum - t[sc.nextInt() - 1] + sc.nextInt());
	}
}

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

int main(){
    int H, W;

    while(cin>>H>>W){
        if(H==0 && W==0){
            break;
        }else{
            for(int i=0; i<H; i++){
                if(i%2){ // 奇数行
                    for(int j=0; j<W; j++){
                        if(j%2){ // 奇数列
                            cout << "#";
                        }else{   // 偶数列
                            cout << ".";
                        }
                    }
                }else{   // 偶数行
                    for(int j=0; j<W; j++){
                        if(j%2){ // 奇数列
                            cout << ".";
                        }else{   // 偶数列
                            cout << "#";
                        }
                    }
                }
                cout << endl;
            }
        }
        cout << endl;
    }
    return 0;
}
                

Measured memory_bytes: 1152
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<long long> a(n);
   int guusuu=0;
   for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]%2==0) guusuu++; 
   }
   if((n-guusuu)%2!=0) cout << "NO" << endl;
   else cout << "YES" << endl;


}
 

Measured memory_bytes: 1024
import collections

n = int(input())

ss = []
for _ in range(n):
  ss.append(input())

c = collections.Counter(ss)

l = c.most_common()
ans = []
ans.append(l[0][0])
for i in range(len(l)-1):
  if l[i][1] == l[i+1][1]:
    ans.append(l[i+1][0])
  else:
    break

ans.sort()

print('\n'.join(ans))


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

#define rep(i,f,n) for (long long (i) =(f);(i)<(n);(i)++)
#define MOD 1000000007 
typedef  long long ll;

using namespace std;

int main(){
    int n;
    string s,t;
    cin>>n;
    cin>>s;
    cin>>t;
    vector<ll>csum(27,0),dp(n,0);
    csum[s[0]-'a']=1;
    dp[0]=1;
    rep(i,1,n){

        dp[i]=(dp[i]+csum[t[i]-'a'])%MOD;
        csum[s[i]-'a']+=dp[i];
       // cout<<dp[i]<<" "<<csum[t[i]-'a']<<s[i]<<t[i]<<endl;
        
    }
cout<<dp[n-1]<<endl;
return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;
typedef map<ll, ll> Map;


int main(void) {
    ll N, i, j;
    map<pair<string, string>, ll> mp;
    string S;
    cin >> N;
    cin >> S;
    for(i=0; i<1<<N; i++) {
        string s, t;
        for(j=0; j<N; j++) {
            if(1&i>>j) {
                s+=S[j];
            }else {
                t+=S[j];
            }
        }
        mp[{s, t}]++;
    }
    ll ans=0;
    for(i=0; i<1<<N; i++) {
        string s, t;
        for(j=0; j<N; j++) {
            for(j=0; j<N; j++) {
                if(1&i>>j) {
                    s=S[j+N]+s;
                }else {
                    t=S[j+N]+t;
                }
            }
        }
        ans+=mp[{s, t}];
    }
    
    prin(ans)
}


Measured memory_bytes: 87040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  ll k,n;
  cin >> k >> n;
  ll a;
  cin >> a;
  ll aa = a;
  ll ans = 0;
  for(int i = 1;i<=n;i++){
    ll b;
    cin >> b;
    if(i != n)
      ans = max(ans,b-a);
    else
      ans = max(ans,k-b+aa);
    a = b;
  }
  cout << k - ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <stdio.h>

constexpr int MAX_INPUT_SIZE = 2000'000; //'
char Input[MAX_INPUT_SIZE];
char* input = Input;

inline int getint(void){
    int res = 0, c; while((c = *input++ - '0') >= 0) res = 10 * res + c;
    return res;
}

constexpr int MAX_N = 500;
constexpr int shift = 10;
constexpr int mask = (1 << shift) - 1;
int Q[MAX_N * MAX_N];
int dist[MAX_N][MAX_N];
bool vacant[MAX_N][MAX_N];

int main(void){
    fread_unlocked(Input, 1, MAX_INPUT_SIZE, stdin);
    const int n = getint();
    {
        // initial distance
        const int p = n - 1;
        for(int i = 0; i < n; ++i){
            const int d1 = (i > p - i) ? p - i : i;
            for(int j = 0; j < n; ++j){
                const int d2 = (j > p - j) ? p - j : j;
                dist[i][j] = (d1 > d2) ? d2 : d1;
            }
        }
    }
    int res = 0;
    for(int _ = n * n; _--;){
        {
            const int p = getint() - 1;
            const int px = p / n, py = p % n;
            res += dist[px][py];
            vacant[px][py] = true;
            Q[0] = (px << shift) | py;
        }
        int head = 0, tail = 1;
        while(head != tail){
            const int x = Q[head] >> shift, y = Q[head] & mask; ++head;
            const int nd = dist[x][y] + !vacant[x][y];
            if(x - 1 >= 0 and dist[x - 1][y] > nd){ dist[x - 1][y] = nd; Q[tail++] = ((x - 1) << shift)| y; }
            if(y - 1 >= 0 and dist[x][y - 1] > nd){ dist[x][y - 1] = nd; Q[tail++] = (x << shift) | (y - 1); }
            if(y + 1 <  n and dist[x][y + 1] > nd){ dist[x][y + 1] = nd; Q[tail++] = (x << shift) | (y + 1); }
            if(x + 1 <  n and dist[x + 1][y] > nd){ dist[x + 1][y] = nd; Q[tail++] = ((x + 1) << shift) | y; }
        }
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 5320
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let mut ans = 1;
    for i in 1..n {
        if s[i] != s[i - 1] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

const int maxn = 200000 + 5;
int N;
int A[maxn];
int tmp[maxn];

void solve()
{
	sort(tmp, tmp+N, greater<int>());
	for(int i = 0; i < N; i++)
	{
		if(A[i] != tmp[0]) printf("%d\n", tmp[0]);
		else printf("%d\n", tmp[1]);
	}
}

int main()
{
	cin >> N;
	for(int i = 0; i < N; i++) 
	{ 
		cin >> A[i];
		tmp[i] = A[i];
	}
	solve();
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=b)ou(a);
  else ou(a-1);
}

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

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

ll fac(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

int main() {
	ll x; cin >> x;
	while(!IsPrime(x)) x++;
	cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K,A,B;cin>>K>>A>>B;
    for(int i=1;i<=1000;i++){
        if(A<=K*i&&K*i<=B){
            cout<<"OK\n";
            return 0;
        }
    }
    cout<<"NG\n";
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int longest(vector<vector<int>> &g,vector<int>&dp,int i){
    if(dp[i]!=-1) return dp[i];
    int ans=0;
    for(int j=0;j<g[i].size();j++){
        ans=max(ans,longest(g,dp,g[i][j]));
    }
    dp[i]=ans+1;
    return dp[i];
}
int main() {
    int n,m,x,y;
    cin>>n>>m;
    vector<vector<int>> g(n);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        g[x-1].push_back(y-1);
    }
    vector<int> dp(n,-1);
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,longest(g,dp,i));
    }
    cout<<ans-1;
}


Measured memory_bytes: 8832
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

ll n,m,a,b,c,x,y,aa[100010],ba[100010];
bool r,br,ar;
string s;
char ca,cb;


int main(){
    cin>>a>>b;
    r=(a%3==0 or b%3==0 or (a+b)%3==0);
    cout<<(r ? "Possible":"Impossible")<<s<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e6+5;
int a[MAX];
int main()
{
    int T;
    int n;
    scanf("%d%d",&n,&T);
    for(int i = 0; i < n; ++i)
        scanf("%d",&a[i]);
    long long ans = T;
    for(int i = 1; i < n; ++i)
    {
        if(a[i] - a[i-1] > T)
        {
            ans += T;
            continue;
        }
        ans += (a[i] - a[i-1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
l,r = map(int,input().split())
ans = float("inf")
if (l <= 2019 and r >= 2019) or r-l >= 2019:
  print(0)
else:
  x = [_ for _ in range(l,r+1)]
  cnt = r-l+1
  for i in range(cnt):
    for j in range(i+1,cnt):
      ij_mod = (x[i]% 2019)*(x[j] % 2019) % 2019
      ans = min(ans,ij_mod)
  print(ans)

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

bool comp(const pair<int, int> a, const pair<int, int> b) {
    return a.second < b.second;
}

int main() {

    int N, M;
    cin >> N >> M;

    vector <pair<int, int>> edges(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edges[i] = make_pair(a, b);
    }

    sort(edges.begin(), edges.end(), comp);

    int ans = 0;
    pair<int, int> p(-1, -1);

    for (int i = 0; i < M; i++) {
        if (p == make_pair(-1, -1)) {
            p = edges[i];
            ans++;
            continue;
        }
        if (p.second <= edges[i].first) {
            p = edges[i];
            ans++;
        }
    }

    cout << ans << endl;

}















































Measured memory_bytes: 1024
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
a.sort()
for i in range(m):
    s, t = map(int, input().split())
    if t > a[0]:
        b.append([s, t])
b.sort(reverse=True, key=lambda x: x[1])
j = 0
for i in range(len(b)):
    if j >= n:
        break
    while a[j] < b[i][1] and b[i][0] >= 1:
        a[j] = b[i][1]
        b[i][0] -= 1
        j += 1
        if j >= n:
            break
print(sum(a))

Measured memory_bytes: 80152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>

int ans = INT_MAX;
char o[20];

int main(int argc, char *argv[]) {
    scanf("%s", o);
    int n = strlen(o);
    for (int i = 0; i + 3 - 1 < n; i++) {
        int tmp = 0;
        for (int j = i; j <= i + 2; j++) {
            tmp = tmp * 10 + o[j] - '0';
        }
        ans = std::min(ans, (int)std::abs(tmp - 753));
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256