akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int a, b, c, d;
  a = n/1000; b = n/100%10; c = n/10%10; d = n%10;
  vector<int> vec(4);
  vec = {a, b, c, d};
  for(int tmp = 0; tmp < (1<<3); tmp++) {
    bitset<3> s(tmp);
    int ans = vec.at(0);
    string t = to_string(vec.at(0));
    rep(i,3) {
      if(s.test(i)) {
        ans += vec.at(i+1);
        t += ("+" + to_string(vec.at(i+1)));
      }
      else {
        ans -= vec.at(i+1);
        t += ("-" + to_string(vec.at(i+1)));
      }
    }
    if(ans == 7) {
      cout << t + "=7" << endl;
      return 0;
    }  
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  ll A[N];
  REP(i,N) cin>>A[i];
  
  REP(x,1010101){
    REP(i,N){
      if(A[i]>=N){
        ll time=A[i]/N;
        ans+=time;
        A[i]-=time*N;
        REP(j,N) if(i!=j) A[j]+=time;
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
class F
attr_reader:n,:d
def initialize(n,d)@n,@d=n/(g=n.gcd d),d/g
end
def eql?(f)@n==f.n&&@d==f.d
end
def hash
[@n,@d].hash
end
end
gets.to_i.times{h=Hash.new{0}
gets.to_i.times.map{gets}.map{|p|p.scan(/../).each_with_index{|s,i|h[F.new(i,p.size/2)]+=s.hex if"00"!=s}}
d=h.keys.map(&:d).inject(1){|r,l|r.lcm(l)}
puts d>1024?"Too complex.":d.times.map{|i|(f=h[F.new(i,d)])?format("%02X",f):"00"}*""}

Measured memory_bytes: 6972
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll ans = min(n%k,k-n%k);
   cout<<ans;
   
   return 0;        
}  
   

Measured memory_bytes: 256
#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 1000000009

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  ll k;
  cin >> k;
  if(k % 2 == 0) cout << a-b << endl;
  else cout << b-a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
ll a[100005];
ll t[100005];
ll ans[100005];
ll g[100005];
int n,q;
int tot;
void dfs(ll cnt,ll x,ll tim)
{
//	cout<<cnt<<" "<<x<<" "<<tim<<endl;
	if(x<=a[1])
	{
		g[x]+=tim;
		return;
	}
	if(a[cnt-1])
	{
	t[cnt-1]+=tim*(x/a[cnt-1]);
	x%=a[cnt-1];
	}
	cnt=upper_bound(a+1,a+tot+cnt,x)-a;
	cnt++;
//	cout<<cnt<<endl;
	if(x&&cnt>1)dfs(cnt-1,x,tim);
}
int main(int argc, char** argv) {
	
	cin>>n>>q;
	tot=1;
	a[1]=n;
	rep(i,1,q)
	{
		ll x;
		scanf("%lld",&x);
		while(tot&&x<=a[tot])
		{
			tot--;
		}
		a[++tot]=x;
	}
	t[tot]=1;
	rep2(i,tot,1)
	{
		dfs(i,a[i],t[i]);
	}
	rep2(i,n-1,1)
	{
		g[i]+=g[i+1];
	}
	rep(i,1,n)
	printf("%lld\n",g[i]);
	return 0;
}

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

int main() {
  int D, T, S;

  cin >> D;
  cin >> T;
  cin >> S;
 
  if ((double)D / T <= S) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define M 502
#define mo 1000000007
#define oo 1000000000
#define LL long long
using namespace std;

void read(int &x){
    char c; x=0;
    for (c=getchar(); c<48;)c=getchar();
    for (; c>=48; c=getchar())x=(x<<1)+(x<<3)+(c^48);    
}

int ans,a,b,c;
int main(){
	read(a); read(b); read(c);
	ans=min(a+b,min(a+c,b+c));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
#print(n,m,l)
def bin_search(a,li):
    max_len=len(li)-1
    min_len=0
    while max_len>=min_len:
        mid=(max_len+min_len)//2
        if li[mid]==a:
            return True
        elif li[mid]<a:
            min_len=mid+1
        else:
            max_len=mid-1
s=[]
g=[]
for i in l:
    if i[0]==1:
        s.append(i[1])
    if i[1]==n:
        g.append(i[0])
g.sort()
for i in s:
    if bin_search(i,g):
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 51740
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXN	100000
struct edge
{
  int v,n;
  ll w;
  edge():v(0),w(0),n(0){}
  edge(int vv, ll ww, int nn):v(vv),w(ww),n(nn){}
};
edge E[MAXN<<1];
int nE;
int front[MAXN+1];
void add_edge(int u, int v, ll w)
{
  int ne = ++nE;
  E[ne] = edge(v,w,u[front]);
  u[front] = ne;
}
int solid[MAXN+1];
ll d[MAXN+1];
void dijstra(int s)
{
  set< pair<ll,int> > q;
  memset(solid,0,sizeof(solid));
  memset(d, -1, sizeof(d));
  d[s] = 0; solid[s] = 1;
  q.insert(make_pair(0ll,s));
  while(!q.empty())
  {
    auto p = q.begin();
    int u = p->second;
    solid[u] = 1;
    q.erase(p);
    for(int e=u[front];e;e = E[e].n)
    {
      int v = E[e].v; ll w = E[e].w;
      if((!solid[v]) && ((-1 == d[v]) || (d[u]+w < d[v])))
      {
        q.erase(make_pair(d[v],v));
        d[v] = d[u]+w;
        q.insert(make_pair(d[v],v));
      }
    }
  }
}
int main(void)
{
  int N = 0;
  int a = 0, b = 0;
  ll c = 0;
  scanf("%d", &N);
  while(--N)
  {
    scanf("%d %d %lld", &a, &b, &c);
    add_edge(a,b,c);
    add_edge(b,a,c);
  }
  int Q = 0, K = 0;
  int x = 0, y = 0;
  scanf("%d %d", &Q, &K);
  dijstra(K);
  while(Q--)
  {
    scanf("%d %d", &x, &y);
    printf("%lld\n", d[x]+d[y]);
  }
  return 0;
}

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

int main(){
 
  int A,B;
  string S,T,U;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(U==S){
cout << A-1 << " " << B << endl;
  }
  
  else if(U==T){
    cout << A << " " << B-1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll A,B,C; cin >> A >> B >> C;
    ll K; cin >> K;
    if(abs(A-B)<1e18){
        if(K%2==0) cout << A-B << endl;
        else cout << B-A << endl;
    }else{
        cout << "Unfair" << endl;
    }
    return 0;
}


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

int main(){
    int d,n;
    cin >> n >> d ;
    vector< vector<int> > x(n,vector<int>(d));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x.at(i).at(j) ;
        }
        
    }
    int count = 0 ;
    for (int i = 0; i < n-1; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            double dis = 0 ;
            int disa = 0 ;
            for ( int k = 0; k < d; k++)
            {
                dis += (x.at(i).at(k) - x.at(j).at(k)) * (x.at(i).at(k) - x.at(j).at(k)) ;
            }
            dis = sqrt(dis) ;
            //cout << dis << endl ;
            disa = dis ;
            if (disa - dis == 0)
            {
                count ++ ;
            }
            
        }
        
    }
    cout << count << endl ;
    
}

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

int main() {
    int N;

    cin >> N;

    vector <int> vec(N);
    for (int i = 0; i < N; i++){
        cin >> vec[i];
    }

    int max = *max_element(vec.begin(), vec.end());
    int min = *min_element(vec.begin(), vec.end());

    cout << max - min << endl;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
  using namespace std;
using namespace __gnu_pbds;
  #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define double long double
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const double PI = acos(-1);
  const int N = 200005;
  int mod = 1e9 + 7;
     

    vector<int> adj[N];
    bool vis1[N];
    bool vis2[N];
    int dist1[N];
    int dist2[N];

    void bfs1(int s)
    {
        queue<int> q;
        q.push(s);
        dist1[s] = 0;
        while(!q.empty())
        {
          int k = q.front();
          q.pop();

          for(auto i:adj[k])
          {
            if(!vis1[i])
            {
              vis1[i] = true;
              dist1[i] = dist1[k] + 1;
              q.push(i);
            }
          }
        }
    }
    void bfs2(int s)
    {
        queue<int> q;
        q.push(s);
        dist2[s] = 0;
        while(!q.empty())
        {
          int k = q.front();
          q.pop();

          for(auto i:adj[k])
          {
            if(!vis2[i])
            {
              vis2[i] = true;
              dist2[i] = dist2[k] + 1;
              q.push(i);
            }
          }
        }
    }

int32_t main()
{
       
    int n,u,v;
    cin >> n >> u >> v;

    rep(i,1,n-1)
    {
      int x,y;
      cin >> x >> y;
      adj[x].PB(y);
      adj[y].PB(x);

    }

    

    bfs1(u);
    bfs2(v);
    dist1[u] = 0;
    dist2[v] = 0;


    int ans = 0;

    rep(i,1,n)
    {

      if(dist1[i]<dist2[i])
      {
        ans = max(dist2[i]-1,ans);
      }
    }



    cout << ans ;

   return 0;
}       

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    string N;
    cin >> N;
    char s = N.at(N.size() - 1);
    if(s == '3') cout << "bon" << endl;
    else if(s == '0'|| s == '1' || s == '6' || s == '8') cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, m, i, j, k;
	cin >> n >> m;
	vector<string> s(n), a(n), b(n);
	string ss;
	for (i = 0; i < n; i++) cin >> s[i];;
	ss = "";
	for (i = 0; i < m; i++) ss = ss + ".";
	a.assign(n, ss);
	b.assign(n, ss);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (j == 0) a[i][j] = '#';
			else if (j == m - 1) b[i][j] = '#';
			else if (i % 2 == 0) a[i][j] = '#';
			else b[i][j] = '#';
		}
	}
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				a[i][j] = '#';
				b[i][j] = '#';
			}
		}
	}

	for (i = 0; i < n; i++) cout << a[i] << "\n";
	cout << "\n";
	for (i = 0; i < n; i++) cout << b[i] << "\n";



	return 0;
}




Measured memory_bytes: 1664
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        HashSet<String> set = new LinkedHashSet<>();

        for (int i = 0; i < n; i++) {
            String str = sc.next();
            if (set.contains(str)) {
                System.out.println("No");
                return;
            } else {
                set.add(str);
            }
        }

        sc.close();

        String[] w = set.toArray(new String[0]);

        for (int i = 1; i < n; i++) {
            String a = w[i - 1].substring(w[i - 1].length() - 1);
            String b = w[i].substring(0, 1);
            if (!a.equals(b)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  char s[11],t[12];
  cin >> s >> t;
  int n=strlen(s);
  string ans="Yes";
  REP(i,n) {
    if(s[i]!=t[i]) ans="No";
  }
  cout << ans << endl;
  return 0;
}


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


int main()
{
	char W[100], M[10000];
	gets(W);
	int n, count=0;
	for (n = 0; n <= 100; n++)
		W[n] = tolower(W[n]);
	while (1)
	{
		scanf("%s", M);
		if (strcmp(M, "END_OF_TEXT") == 0)break;
		for (n = 0; n <= 10000; n++)M[n] = tolower(M[n]);
		if (strcmp(M, W) == 0)count++;
	}
	printf("%d\n", count);
	return 0;

}

Measured memory_bytes: 1000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    
    ll a=-1,b=-1;
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    Sort(v);
    for(int i=n-2;i>=0;i--){
        if(v[i]==v[i+1]){
            if(a==-1){
                a=v[i];
                i--;
            } else {
                b=v[i];
                break;
            }
        }
    }
    if(a==-1||b==-1)fin(0);
    else fin(a*b);

    
    
}


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

long n;
map<long,vector<long>> a;
map<long,vector<long>> b;
vector<long> dis(100010);
vector<bool> is_searched(100010);

void dfs(long x,long y) {
  is_searched[x-1]=true;
  dis[x-1]=y;
  if(a.count(x)) {
    for(long i=0;i<a[x].size();i++) {
      if(!(is_searched[a[x][i]-1])) dfs(a[x][i],y+b[x][i]);
    }
  }
  return;
}

int main() {
  cin >> n;
  for(int i=0;i<n-1;i++) {
    long u,v,w;
    cin >> u >> v >> w;
    a[u].push_back(v);
    a[v].push_back(u);
    b[u].push_back(w);
    b[v].push_back(w);
  }
  dfs(1,0);
  for(long i=0;i<n;i++) cout << dis[i]%2 << endl;
}

Measured memory_bytes: 27008
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n, K;
    scanf("%d%d", &n, &K);
    ll ans = 1;
    int i;
    for (i = 0; i < n; i++) {
        if (i == 0) ans = K;
        else ans = ans * (K - 1);
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  string s;
  int k;
  cin>>k>>s;
  if(s.size()<=k) cout<<s<<endl;
  else cout<<s.substr(0,k)+"..."<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>                                                                               
using namespace std;
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)
#define FORE(v1, v2) for (v1 = 0; v1 <= v2; ++v1)
#define FORO(v1, v2) for (v1 = 1; v1 < v2; ++v1)
#define FOROE(v1, v2) for (v1 = 1; v1 <= v2; ++v1)
using ll = long long;
constexpr ll kMod = 1'000'000'007;

int a[100000];
int main () {
  int h, n;
  cin >> h >> n;
  int i;
  int sum = 0;
  FOR(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  if (sum < h) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {

    int n, k;
    cin >> n >> k;

    cout << n - k + 1 << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const{
    for(int i = 0; i < N2; i++){
      if(f[i] == p.f[i])continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
  for(int i = 0;i < N2;i++)if(p.f[i] != (i+1))return false;
    return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while( !Q.empty() ){
    u = Q.front();
    Q.pop();
    if( isTarget(u) )return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int r = 0;r < 4;r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if( tx < 0 || ty < 0 || tx >= N || ty >= N )continue;
      v = u;
      swap(v.f[u.space], v.f[tx*N+ty]);
      v.space = tx * N + ty;
      if( !V[v] ){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }

  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i=0;i<N2;i++){
    cin >> in.f[i];
    if( in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}



Measured memory_bytes: 30600
import static java.util.Arrays.deepToString;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int from = sc.nextInt();
			if (from == 0) break;
			int ft = sc.nextInt() * 100 + sc.nextInt();
			int to = sc.nextInt();
			int tt = sc.nextInt() * 100 + sc.nextInt();
			int d = getD(from, to);
			int fee = getF(from, to);
			boolean half = (isin(ft) || isin(tt)) && d <= 40;
			if (half) {
				fee = (fee / 2 + 49) / 50 * 50;
			}
			System.out.println(fee);
		}
	}
	
	int getD(int a, int b) {
		if (a > b) { int tmp = a; a = b; b = tmp; }
		return t[b][a];
	}
	int getF(int a, int b) {
		if (a > b) { int tmp = a; a = b; b = tmp; }
		return t[a][b];
	}
	
	int[][] t = new int[][] {
		{0, 0, 0, 0, 0, 0, 0, 0,},
		{0, 0, 300, 500, 600, 700, 1350, 1650,},
		{0, 6, 0, 350, 450, 600, 1150, 1500,},
		{0, 13, 7, 0, 250, 400, 1000, 1350,},
		{0, 18, 12, 5, 0, 250, 850, 1300,},
		{0, 23, 17, 10, 5, 0, 600, 1150,},
		{0, 43, 37, 30, 25, 20, 0, 500,},
		{0, 58, 52, 45, 40, 35, 15, 0,}
	};
	
	boolean isin(int t) {
		return 1730 <= t && t <= 1930;
	}
}

Measured memory_bytes: 20432
#include <stdio.h>

int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp, c1, c2, c3;
	
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF){
		c1 = (x2 - x1) * (yp - y2) - (y2 - y1) * (xp - x2);
		c2 = (x3 - x2) * (yp - y3) - (y3 - y2) * (xp - x3);
		c3 = (x1 - x3) * (yp - y1) - (y1 - y3) * (xp - x1);
		
		if((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

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

int main(){
  int H,N,i,A,B=0;
  cin >> H >> N;
  for(i=0;i<N;i++){
    cin >> A;
    B+=A;
  }
  if(H<=B)
  cout << "Yes";
  else
  cout << "No";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC132 E
#有向グラフ上の路長が3の倍数であるようなものの内、最短の長さを3で割ったものを出力

import sys
sys.setrecursionlimit(1000000)
from collections import deque

N,M = map(int,input().split())
UV = [list(map(int,input().split())) for _ in range(M)]
S,T = map(int,input().split())

G = [[] for _ in range(N)]

for i in UV:
    G[i[0]-1].append(i[1]-1)

reach = [[-1 for _ in range(N)] for _ in range(3)]#元のグラフのGの状態数3倍化
reach[0][S-1] = 0#スタート位置を0にする

que = deque()
que.append(S-1)#スタート位置を追加

time = 1
for _ in range(4*N):
    new_que = deque()
    for q in que:
        for v in G[q]:#qから移動できる辺を見る
            if reach[time%3][v] == -1:#まだたどり着いていない辺なら
                reach[time%3][v] = time#たどり着けた時刻をたどり着いた時刻を3で割った余りのリストに入れる
                new_que.append(v)#たどり着いた頂点をqueueにいれて次のターンでそこから移動できる辺を見る
    que = new_que
    time += 1
if reach[0][T-1] == -1:
    print(-1)
else:
    print(reach[0][T-1]//3)


Measured memory_bytes: 50024
N=int(input())
W=[]
W.append(N)
i=1
while True:
  if N%2==0:
    N=N/2
    i+=1
    if N in W:
      print(i)
      exit()
    else:
      W.append(N)
  else:
    N=3*N+1
    i+=1
    if N in W:
      print(i)
      exit()
    else:
      W.append(N)

Measured memory_bytes: 9196
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	int n, sum = 0, l, r;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << 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;
const int INF=1001001001;

int main(){
	int a,b;
	cin >> a >> b;
	int ans = a-1;
	if(a<=b) ans = a;
	cout << ans << endl;

	return 0;

}




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

int main() {
	int n, i, j;
	int flg = 1;
	char w[100][100];

	scanf("%d", &n);
	scanf("%s", w[0]);
	for (i = 1; i < n; i++) {
		scanf("%s", w[i]);
		if (w[i - 1][strlen(w[i - 1]) - 1] != w[i][0]) flg = 0;
	}

	for (i = 0; i < n; i++) {
		for (j = n - 1; j > i; j--) {
			if (strcmp(w[i], w[j]) == 0) flg = 0;
		}
	}

	if (flg == 1) puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  vector<ll> T(2), A(2), B(2);
  rep(i, 2) cin >> T[i];
  rep(i, 2) cin >> A[i];
  rep(i, 2) cin >> B[i];
  if(A[0]<B[0]) rep(i, 2) swap(A[i], B[i]);
  ll d1 = (A[0]-B[0])*T[0];
  ll d2 = (A[0]-B[0])*T[0]+(A[1]-B[1])*T[1];
  if(d2 > 0) {
    cout << 0 << endl;
  } else if(d2 == 0) {
    cout << "infinity" << endl;
  } else {
    ll cnt = 1 + 2 * (d1/(-d2));
    if(d1%(-d2) == 0) cnt--;
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);          
	
	while(true){
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a == 0 && b == 0){
	 break;
	 }
         System.out.println(Math.min(a,b) + " " + Math.max(a,b));
	}
	}
}


Measured memory_bytes: 34584
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<Int, P> T;
Int n, k, a, b, c;

int main(){
    cin >> n >> k;
    if(n < 2 * k - 1){
        cout << -1 << endl;
        return 0;
    }
    int middle =  n / 2;
    vector<T> nums;
    for(int i = 0;i < n;i++){
        a = i+k;
        b = n + ((i+middle) % n) + k;
        nums.push_back(T(a+b,P(a, b)));
    }
    sort(nums.begin(), nums.end());
    for(int i = 0;i < n;i++){
        Int a = nums[i].second.first;
        Int b = nums[i].second.second;
        Int c = n + n + i + k;
        cout << a << " " << b << " "<< c << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  string s;
  cin >> s;
  int cnt_C = 0;
  int cnt_s = 0;

  for(int i=0;i<s.size();i++){
    if(s[i]=='C' && 2<=i && i<s.size()-1) cnt_C++;
    if(islower(s[i])) cnt_s++;
  }

  if(s[0]!='A' || cnt_C != 1 || cnt_s!=(s.size()-2)){
    cout<< "WA" <<endl;
  }
  else cout<< "AC" <<endl;
}


Measured memory_bytes: 256
<?php
list($R, $C, $K) = ints();
for ($i = 0; $i < $K; ++$i) {
    list($r, $c, $v) = ints();
    $val[$r][$c] = $v;
}
// dp[j][k] := 見ている行のj列までで、この行上のk個以下のアイテムを選んだ時の価値の合計の最大値
$dp = array_fill(0, $C + 1, array_fill(0, 4, 0));
for ($i = 1; $i <= $R; ++$i) {
    for ($j = 1; $j <= $C; ++$j) {
        for ($k = 0; $k < 4; ++$k) {
            if ($dp[$j - 1][$k] > $dp[$j][3]) {
                $dp[$j][$k] = $dp[$j - 1][$k];
            } else {
                $dp[$j][$k] = $dp[$j][3];
            }
        }
        if (!isset($val[$i][$j])) continue;
        for ($k = 3; $k >= 1; --$k) {
            if ($dp[$j][$k - 1] + $val[$i][$j] > $dp[$j][$k]) {
                $dp[$j][$k] = $dp[$j][$k - 1] + $val[$i][$j];
            }
        }
    }
}
echo $dp[$C][3], PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 36904
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let a: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = if (n % 500) <= a { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <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>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::vector<long long> A){
    int minus=0;
    REP(i,N)if(A[i]<0)minus++;
    REP(i,N)if(A[i]<0)A[i]*=-1;
    LL sum=0;
    LL minim=1000000000000;
    REP(i,N){sum+=A[i];minim=min(minim,A[i]);}
    if(minus%2==0){
        cout<<sum<<endl;
    }
    else{
        cout<<sum-minim*2<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b) for(int i=a;i>=b;i--)
#define debug

using namespace std;

int read(){
    char c=getchar(); int flag=1, x=0;
    while(!isdigit(c)){ if(c=='-') flag=-1; c=getchar(); }
    while( isdigit(c)){ x=x*10+(c-'0'); c=getchar(); }
    return flag*x;
}


signed main(){

    int n=read();
    char pre='*';
    int Ans=0;
    FOR(i,1,n){
        char c; cin>>c;
        if(c!=pre) Ans++;
        pre=c;
    }

    cout<<Ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }


int main() {
  int n; li k; cin >>n >>k;
  vector<int> a(n); for(auto& x:a){ cin >>x; x--; }
  vector<int> seen(n);
  seen[0]=1;
  int tmp=a[0],cnt=1;
  while(seen[tmp]==0){
    cnt++;
    seen[tmp]=1;
    tmp=a[tmp];
  }
  int tail=0,tmp2=0;
  while(tmp2!=tmp){
    tail++;
    tmp2=a[tmp2];
  }
  
  if(k<=cnt){
    int ans=0;
    rep(i,k){
      ans=a[ans];
    }
    print(ans+1);
    return 0;
  }
  
  int T=cnt-tail;
  li q=(k-tail)/T,r=(k-tail)%T;
  k=min(k,(li)tail);
  int ans=0;
  rep(i,tail+r){
    ans=a[ans];
  }
  print(ans+1);
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string S,D,F;
  char x;
  cin>>S>>D>>F;
  x=D.at(0);
  
  cout<<"A"<<x<<"C"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
#define lcm(a,b) a*(b/__gcd(a,b))
#define sz(x) (int)x.size()
#define cmp complex<double> 
int power(int x,int y){
    int res=1;
    x=x%mod1;
    while(y>0){
        if(y&1)res=(res*x)%mod1;
        x=(x*x)%mod1;
        y/=2;
    }
    return res;
}
vector<int> spf(1e6+1);
void inline precompute(){
    for(int i=2;i<=1e6;i++){
        if(!spf[i]){
            for(int j=i;j<=1e6;j+=i){
                if(!spf[j])spf[j]=i;
            }
        }
    }
}
// void dfs(vector<int> adj[],int x,int par){
//     intime[x]=t++;
//     for(int i=1;i<=k;i++){
        
//     }
//     for(auto it: adj[x]){
//         if(it!=par){
//             dfs(adj,it,x);
//         }
//     }
//     outtime[x]=t++;
// }
void solve(int tc){
    int n;
    cin>>n;
    int cp=n;
    if(n==1){cout<<0;return;}
    int ans=0;
    for(int i=2;i*i<=cp;i++){
        if(cp%i==0){
            if(spf[i]==i){
                int ctr=0;
                while(cp%i==0)cp/=i,ctr++;
                int k=(sqrt(8*ctr+1)-1.0)/2.0;
                ans+=k;
            }
        }
    }
        if(cp>1e6){
            cout<<ans+1;
        }
        else{
            while(cp>1){
                int k=spf[cp];
                while(cp%k==0)cp/=k;
                ans++;
            }
            cout<<ans;
        }
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(12);
    int t=1,ctr=0;
    precompute();
    // cin>>t;
    while(t--){
        solve(ctr+1);
        ctr++;
    }
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, M;
    cin>>N>>M;
    vector<pint> A(M);
    REP(i, 0, M){
        int a, b, d = 0;
        cin>> a >> b;
        REP(j, 0, b){
            int c;
            cin >> c;
            d += pow(2, c-1);
        }
        A[i] = {a, d};
    }
    int state = pow(2, N);
    vvi DP(M + 1, vi(state, 0));
    REP(i, 1, M+1){
        int a = A[i-1].first, b = A[i-1].second;
        DP[i][b] = a;
    }
    REP(i, 2, M+1){
        int a = A[i-1].first, b = A[i-1].second;
        REP(j, 0, state){
            if(j != 0 && DP[i-1][j] == 0) continue;
            int o = j | b;
            if(DP[i][o] == 0 || DP[i][o] > DP[i-1][j] + a) DP[i][o] = DP[i-1][j] + a;
            if(DP[i][j] == 0 || DP[i][j] > DP[i-1][j]) DP[i][j] = DP[i-1][j];
        }
    }
    /*
    REP(i, 0, M + 1){
        REP(j, 0, state){
            cout << setw(5) << DP[i][j] << " ";
        }
        cout << endl;
    }*/
    int ans = __INT_MAX__;
    if(DP[M][state-1] == 0){
        cout << -1 << endl;
        return 0;
    }
    REP(i, 0, M+1){
        if(DP[i][state-1] != 0){
            ans = min(ans, DP[i][state-1]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19704
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int i,n,w,j;
	cin>>n>>w;
	long long int value[n+1]={0},weight[n+1]={0},table[n+1][w+1]={0};
	for(i=1;i<=n;i++)
	{
		cin>>weight[i]>>value[i];
	}
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			if(i==0||j==0)
				table[i][j]=0;
			else if(weight[i]<=j)
				table[i][j]=max(table[i-1][j],value[i]+table[i-1][j-weight[i]]);
			else
				table[i][j]=table[i-1][j];
		}
	}
	cout<<table[n][w];
}

Measured memory_bytes: 79104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;

int main() {
	char N[4];
	cin >> N;
	char A[4];
	A[0] = N[2];
	A[1] = N[1];
	A[2] = N[0];
	if ((N[0] == A[0]) && (N[1] == A[1]) && (N[2] == A[2])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using namespace std;
int N;
const int MAX_N = 100000;
int a[MAX_N];

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

	sort(a, a + N);

	int tmp = a[0], cnt = 1, sum = 0;
	for (int i = 1; i < N; i++) {
		if (tmp == a[i]) {
			cnt++;
		}
		else {
			if (cnt < tmp) sum += cnt;
			else sum += cnt - tmp;
			tmp = a[i];
			cnt = 1;
		}
	}
	if (cnt < tmp) sum += cnt;
	else sum += cnt - tmp;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 640
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    lli n,k,i=1; cin>>n>>k;
    vi a(n+1), vis(n+1, 0); NA(i,1,n+1) cin>>a[i];
    while(k){
        if(!vis[a[i]]) vis[a[i]] = 1;
        else break;
        i = a[i]; --k;
    }
    if(!k){
        cout<<i; return;
    }
    lli j = 0, p = i;
    unordered_map<lli,lli> mpp;
    while(k){
        mpp[j] = i; 
        i = a[i]; ++j;
        if(i==p) break;
    }
    cout<<mpp[k%j];
    return ;
}
int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

Measured memory_bytes: 13384
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    int num = 7 % k;
    const int N = 1e6 + 100;
    for(int i = 1 ; i < N ; i++){
        if(num == 0){
            cout << i << "\n";
            return 0;
        }
        num = ((num * 10) % k + 7) % k;
    }
    cout << "-1\n";
    return 0;
}

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

//int AtCoderABC096A( int argc, char *argv[] )
int main( int argc, char *argv[] )
{
int a;
int b;

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

	cin >> a;
	cin >> b;
// 2018 年 1 月 1 日から 2018 年 a 月 b 日まで

	if( a <= b )
		cout << a << endl;
	else
		cout << a - 1 << endl;

	return 0;
}




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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll x, y, d;

ll extgcd(ll a, ll b, ll &x, ll &y){
    d = a;
    if(b == 0){
        x = 1;
        y = 0;
    }else{
        d = extgcd(b, a%b, y, x);
        y -= a/b * x;
    }
    return d;
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll a,b;
    cin >> a >> b;
    extgcd(a,b, x,y);
    cout << x << " " << y << endl;
}



Measured memory_bytes: 3184