akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <bitset>

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;

using namespace std;

const llint inf = pow(10, 12);

int main(void) {
	int a, b, n;
	cin >> n >> a >> b;

	llint pre, ans = 0;
	cin >> pre;

	rep(i,n-1) {
	  int x;
	  cin >> x;

		if ((x - pre)*a > b) {
		  ans += b;
			pre = x;
		}
		else {
		  ans += (x-pre)*a;
			pre = x;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){ 
  string s;
  cin >> s;
  int ans = 0;
  int n = len(s);
  rep(i, 1, (n+1)/2){
    int cnt = 0;
    forn(j, i){
      if (s[j] == s[i+j]) cnt++;
      else break;
    }
    setmax(ans, cnt);
  }
  cout << ans * 2;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

0 < 2 > 1 > 0

 */

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl "\n"
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
const int N = 300001;
bool isPrime(int n)
{
    for (int i = 2; i * i <= n; ++i) 
    {
        if (n % i == 0) 
        {
            return false;
        }
    }
    return true;
}
int factorial(int n){return (n==1 || n==0) ? 1: n * factorial(n - 1); } 
int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n,int r){int res=1;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}
int max(int a,int b){int ans=a>b?a:b;return ans;}
int min(int a,int b){int ans=a<b?a:b;return ans;}

int main()
{
    ll n,i;
    bolt;
    cin>>n;
    ll b[n+1],a[n+1];
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        if (!i)
        b[i]=0;
        else if (i==1)
        {
            b[i]=abs(a[i]-a[i-1]);
        }
        else
        {
            b[i]=min(abs(a[i]-a[i-1])+b[i-1],abs(a[i]-a[i-2])+b[i-2]);
        }
    }
    cout<<b[n-1];
}

Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let hw = read_vec::<i64>();
    let mut f:Vec<Vec<char>> = Vec::new();
    for _ in 0..hw[0] {
        f.push( read::<String>().chars().collect() );
    }
    // let mut ans = Vec::new();
    for j in 0..hw[0] {
        if f[j as usize].iter().all(|&x| x == '.') {
            continue;
        }
        for k in 0..hw[1] {
            if f[j as usize][k as usize ] == '.' {
                for l in 0..hw[0] {
                    if  f[l as usize][k as usize] == '#'{
                        print!(".");
                        break;
                    } 
                }
            } else {
                print!("#");
            }
            
        }
        println!("");
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  int count = 0;
  for(int i=1;i<N-1;i++){
    if(P.at(i-1)<P.at(i)&&P.at(i)<P.at(i+1))
      count++;
    else if(P.at(i-1)>P.at(i)&&P.at(i)>P.at(i+1))
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
ll max(ll a, ll b){ return (a>b)?a:b;}
ll min(ll b, ll a){ return (a>b)?b:a;}

ll nums[2*100000];
ll N;
int main(void){
    scanf("%lld",&N);
    for(int i = 0; i < N; i++) scanf("%lld",nums+i);
    
    ll left=0, right=0;
    ll ans = 0;
    
    ll sums = nums[0];
    ll xors = nums[0];
    while(left < N && right < N){
        /*
        ll sums=nums[left], xors=nums[left];
        for(ll i = left+1; i <= right; i++){
            sums += nums[i];
            xors ^= nums[i];
        }*/
        if(sums == xors){
            //printf("l=%d,r=%d, add=%d\n",left,right,right-left+1);
            ans += right-left+1;
            right++;
            sums += nums[right];
            xors ^= nums[right];
        }else{
            if(right-left+1 == 1){
                right++;
                left++;
            
                sums = nums[left];
                xors = nums[right];
            }else{
                sums -= nums[left];
                xors ^= nums[left];            
                left++;
            }
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
//10:50
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define MAXt 16*100000

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vp;

typedef long long ll;

int dp[(1<<16)];
int dp2[(1<<16)][16];

vvi D;
int N;

int ftime(int c,int d){
    if(dp2[c][d]!=0) return dp2[c][d];
    int mi = D[d][0];
    c = c<<1;
    REP(j,1,N+1){
        if(j-1==d) continue;
        if(((1<<j)&c)==1<<j){
            mi = min(mi,D[d][j]);
        }
    }
    return dp2[(c>>1)][d] = mi;
}

int rec(int c){
    //c|=(1<<d);//????????????
    if(dp[c]!=0) return dp[c];
    if(c==(1<<N)-1) return dp[c] = 0;
    // cout<<"@c :"<<c;
    // cout<<" d :"<<d<<endl;
    int mi=MAXt;
    rep(i,N){
        int nc;
        nc = c|(1<<i);
        if(nc==c)continue;
        mi=min(mi,ftime(nc,i)+rec(nc));
    }
    return dp[c]=mi;
    /*
    if(c==(1<<N)-1) return dp[c][d] = ftime(c, d);
    else{
        int mi=MAXt;
        rep(i,N){
            if(i==d)continue;
            if(((1<<i)&c)==1<<i)continue;
            mi = min(mi,ftime(c, d) + rec(c, i));
        }
        return dp[c][d]=mi;
    }
    return dp[c][d]=MAXt;
    */
}

int main() {
    vvi eD;
    while(1){
        rep(i,(1<<16)){
            dp[i]=0;
        }
        rep(i,(1<<16)){
            rep(j,16){
                dp2[i][j]=0;
            }
        }
        cin>>N;
        if(N==0)break;
        D = eD;
        rep(i,N){
            D.pb(vi());
            rep(j,N+1){
                int t;
                cin>>t;
                D[i].pb(t);
            }
        }
        int ans = MAXt;
        ans = rec(0);
        cout<<ans<<endl;
        // rep(i,N){
        //     cout<<"@: ";
        //     rep(j,N+1){
        //         cout<<D[i][j]<<" ";
        //     }
        //     cout<<endl;
        // }
    }


    return 0;
}

Measured memory_bytes: 7476
h,w,z = map(int,input().split())
a_mat = []
for i in range(h):
  a_list = list(map(int,input().split()))
  a_mat.append(a_list)
pos_dic  = {}
for i in range(h):
  for j in range(w):
    pos_dic[a_mat[i][j] - 1] = [i,j]
    
d = [0 for i in range(h*w)]
for a in range(z,h*w):
  d[a] = d[a-z] + abs(pos_dic[a][0] - pos_dic[a-z][0]) +abs(pos_dic[a][1] - pos_dic[a-z][1])
  
q = int(input())
for _ in range(q):
  l,r = map(int,input().split())
  print(d[r-1] - d[l-1])
 
    


Measured memory_bytes: 70620
#include<bits/stdc++.h>
using namespace std;
string s;
string s1;
char s2;
int main()
{
	cin>>s;
	s1=s;
	s2=s[s.length()-1];
//	cout<<s2;
	if(s2=='s')  cout<<s1<<"es";
	if(s2!='s')  cout<<s1<<"s";
}

Measured memory_bytes: 3624
use std::collections::*;

#[allow(unused_macros, dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros, dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros, dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn top(x: usize) -> usize {
    let mut t = x;
    let mut v = x;
    while v > 0 {
        t = v;
        v /= 10;
    }
    return t;
}

fn main() {
    input! {
        n: usize,
    }
    let mut map = BTreeMap::<(usize, usize), usize>::new();
    for i in 1..(n + 1) {
        *map.entry((i % 10, top(i))).or_insert(0) += 1;
    }
    let mut ans = 0;
    for i in 1..(n + 1) {
        ans += *map.entry((top(i), i % 10)).or_insert(0);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#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>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    char s;cin >> s;
    if('a'  <= s && s <= 'z') cout << "a" << endl;
    if('A'  <= s && s <= 'Z') cout << "A" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int maxn = 2E5 + 20;
typedef long long LL;
const LL mo = 1000000007;

int n,X,Y,tp,Clock,tot,Ans = 1,cnt[maxn],last[maxn]
	,c[maxn],w[maxn],stk[maxn],Fac[maxn],Inv[maxn];
bool vis[maxn];

queue <int> Q; stack <int> s;
vector <int> v[maxn],g[maxn];

inline int Mul(const LL &x,const LL &y) {return x * y % mo;}
inline bool cmpw(const int &x,const int &y) {return w[x] < w[y];}
inline int C(const int &N,const int &M) {return Mul(Fac[N],Mul(Inv[M],Inv[N - M]));}

int ksm(int x,int y)
{
	int ret = 1;
	for (; y; y >>= 1)
	{
		if (y & 1) ret = Mul(ret,x);
		x = Mul(x,x);
	}
	return ret;
}

void BFS(int st)
{
	last[c[st]] = Clock; s.push(c[st]);
	vis[st] = cnt[c[st]] = 1; Q.push(st);
	while (!Q.empty())
	{
		int k = Q.front(); Q.pop(); ++tot;
		for (int i = 0; i < v[k].size(); i++)
		{
			int to = v[k][i]; if (vis[to]) continue;
			if (last[c[to]] == Clock) ++cnt[c[to]];
			else cnt[c[to]] = 1,last[c[to]] = Clock,s.push(c[to]);
			vis[to] = 1; Q.push(to);
		}
	}
}

void Add_Edgs(int st)
{
	for (int i = 1; i <= n; i++)
	{
		if (c[i] == c[st]) continue;
		if (w[i] + w[st] > Y) continue;
		v[st].push_back(i); v[i].push_back(st);
	}
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n >> X >> Y; Fac[0] = 1;
	for (int i = 1; i <= n; i++)
		scanf("%d%d",&c[i],&w[i]),g[c[i]].push_back(i);
	for (int i = 1; i <= n; i++) Fac[i] = Mul(Fac[i - 1],i);
	Inv[n] = ksm(Fac[n],mo - 2); for (int i = n - 1; i >= 0; i--) Inv[i] = Mul(Inv[i + 1],i + 1);
	for (int i = 1; i <= n; i++)
	{
		if (!g[i].size()) continue;
		sort(g[i].begin(),g[i].end(),cmpw);
		stk[++tp] = g[i][0];
		for (int j = 1; j < g[i].size(); j++)
		{
			if (w[g[i][0]] + w[g[i][j]] > X) break;
			v[g[i][0]].push_back(g[i][j]);
			v[g[i][j]].push_back(g[i][0]);
		}
	}
	sort(stk + 1,stk + tp + 1,cmpw);
	Add_Edgs(stk[1]); if (stk[2]) Add_Edgs(stk[2]);
	for (int i = 1; i <= n; i++)
	{
		if (vis[i]) continue; ++Clock; BFS(i);
		while (!s.empty())
		{
			int k = s.top(); s.pop();
			Ans = Mul(Ans,C(tot,cnt[k])); tot -= cnt[k];
		}
	}
	cout << Ans << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

//const ll INF=(ll)1e18;
const int INF=(1<<21);

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

  vector<pair<int, int>> e[n];
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int,int>>> pq;

  int d[n];
  bool visited[n];

  REP(i,n)d[i]=INF;
  REP(i,n)visited[i]=false;

  REP(i,n){
    int u,k;
    cin >> u >> k;

    REP(j,k){
      int v,c;
      cin >> v >> c;;
      e[i].push_back(make_pair(v,c));
    }
  }

  d[0]=0;
  visited[0]=true;

  pq.push(make_pair(0,0));
  while(!pq.empty()){
    int c=pq.top().first;
    int u=pq.top().second;
    pq.pop();

    visited[u] = true;
    if(d[u] < c)continue;

    REP(i,e[u].size()){
      int v = e[u][i].first;
      if(visited[v])continue;

      if(d[u] + e[u][i].second < d[v]){
        d[v] = d[u] + e[u][i].second;
        pq.push(make_pair(d[v], v));
      }
    }

  }

  REP(i,n){
    cout << i << " " << d[i] << endl;
  }


}




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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC134D()
{
	int N;
	cin >> N;
	vector<int> a(N+1);
	for (int i = 1; i <= N; ++i)
	{
		cin >> a[i];
	}

	vector<int> b(N + 1);
	int end = N + 1;
	for (int i = 2; i <= N+1; ++i)
	{
		int start = N / i + 1;
		for (int j = start; j < end; ++j)
		{
			int x = 0;
			for (int k = 1; k < i; ++k)
			{
				x += b[j*k];
			}
			b[j] = (x + a[j]) % 2;
		}
		end = start;
	}
	vector<int> ret;
	for (int i = 1; i <= N; ++i)
	{
		if (b[i] == 1)
			ret.push_back(i);
	}
	cout << ret.size() << endl;
	for (int i = 0; i < ret.size(); ++i)
	{
		cout << ret[i];
		if (i < ret.size() - 1)
			cout << ' ';
	}
	cout << endl;
}
int main()
{
	ABC134D();
	return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{



	public static void main(String[] args){




		Scanner sc =  new Scanner(System.in);
		int N= sc.nextInt();
		int K = sc.nextInt();
		int ans = 1;
		for(int i = 1;i <= N;i++){
			if(ans*2 <= (ans +K)){
				ans *= 2;
			}else{
				ans += K;
			}
			
		}
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    int it[3];
    it[0]=it[1]=it[2]=0;
    int now=0;
    while(true){
        if(it[now]==s[now].size()){
            cout<<(char)('A'+now)<<endl;
            return 0;
        }
        it[now]++;
        now=(int)(s[now][it[now]-1]-'a');
    }
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);

#define F first
#define S second
#define pb push_back
#define int long long
#define maxn 200000
#define mod 1000000007
#define inf 1000000000000000000

#define fr(i,a,b) for(int i=a;i<b;i++)
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
#define all(x) begin(x), end(x)
#define PII pair<int, int>
#define VI vector<int>
#define VII vector<PII>

using namespace std;

int n, dp[maxn][2];
vector <int> v[maxn];	

void dfs(int node, int par){
	dp[node][0] = 1, dp[node][1] = 1;
	for(auto x: v[node]){
		if(x == par) continue;
		dfs(x, node);
		dp[node][0] *= dp[x][0] + dp[x][1];
		dp[node][0] %= mod;
		dp[node][1] *= dp[x][0];
		dp[node][1] %= mod;
	}
}

signed main()
{
    FLASH

    cin>>n;
    fr(i, 1, n){
    	int x, y;
    	cin>>x>>y;
    	v[x].pb(y);
    	v[y].pb(x);
    }

    dfs(1, 1);
    cout<<(dp[1][0] + dp[1][1])%mod<<'\n';
}

Measured memory_bytes: 16640
import java.util.Scanner;

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

		int[] a = new int[N + 1];
		boolean chk = false;
		int[][] cand = new int[][] { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } };
		for (int[] x : cand) {
			a[0] = x[0];
			a[1] = x[1];
			for (int i = 1; i < N; i++) {
				if (s.charAt(i) == 'o') {
					if (a[i] == 0) {
						a[i + 1] = a[i - 1];
					} else {
						a[i + 1] = 1 - a[i - 1];
					}
				} else {
					if (a[i] == 0) {
						a[i + 1] = 1 - a[i - 1];
					} else {
						a[i + 1] = a[i - 1];
					}
				}
			}
			if (a[N] != a[0]) {
				continue;
			} else {
				if (s.charAt(0) == 'o') {
					if ((a[0] == 0 && a[N - 1] == a[1])
							|| (a[0] == 1 && a[N - 1] == 1 - a[1])) {
						chk = true;
						break;
					} else {
						continue;
					}
				} else {
					if ((a[0] == 1 && a[N - 1] == a[1])
							|| (a[0] == 0 && a[N - 1] == 1 - a[1])) {
						chk = true;
						break;
					} else {
						continue;
					}
				}
			}
		}
		String ans = null;
		if (chk) {
			StringBuffer buf = new StringBuffer();
			char[] t = new char[] { 'S', 'W' };
			for (int i = 0; i < N; i++) {
				buf.append(t[a[i]]);
			}
			ans = buf.toString();
		} else {
			ans = "-1";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26336
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int k,a,b;

int main() {
	read(k),read(a),read(b);
	if(a%k==0||b%k==0) puts("OK");
	else if(a/k<b/k) puts("OK");
	else puts("NG");
	return 0;
}

Measured memory_bytes: 3504
import sys
import bisect
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
X = [int(x) for x in input().strip().split()]
b = 1
if X.count(0) == 0:
    X.insert(bisect.bisect(X, 0), 0)
    b = 0

s = X.index(0)
ans = float('INF')
for i in range(1, K + 1):
    if s + i < len(X):
        t_ans = X[s + i]
        if i + b == K:
            ans = min(ans, t_ans)
            break
        else:
            if s - (K - i) < 0:
                continue
            t_ans += X[s + i]
            ans = min(ans, t_ans - X[s - (K - i)])
    else:
        break

for i in range(1, K + 1):
    if s - i >= 0:
        t_ans = - X[s - i]
        if i + b == K:
            ans = min(ans, t_ans)
            break
        else:
            if s + (K - i) >= len(X):
                continue
            t_ans += - X[s - i]
            ans = min(ans, t_ans + X[s + (K - i)])

if ans == float('INF'):
    ans = 0
print(ans)

Measured memory_bytes: 14316
#include <bits/stdc++.h>
using namespace std;
int x[8], y[8];
double dist(int i, int j){
	return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
	vector<int> od(n, 0);
	iota(od.begin(), od.end(), 0);
	int cnt = 0;
	double sum = 0;
	do{
		for(int i = 0; i < n - 1; i++){
			sum += dist(od[i], od[i + 1]);
		}
		cnt++;
	}while(next_permutation(od.begin(), od.end()));
	cout << fixed << setprecision(12) << sum / cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif */

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n;
    cin>>n;
    vi a(n);
    rep(i,0,n)
      cin>>a[i];
    ll ans = 0;
    sort(all(a));
    for(int i = 0;i<n;i++)
    {
      for(int j = i+1;j<n;j++)
      {
        for(int k = j+1;k<n;k++)
        {
          if(a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k])
            ans++;
        }
      }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
	long long n;
	cin >> n;
	if (n % 2 == 0) {
		n /= 10;
		long long ans = n;
		while (n >= 5) {
			n/=5;
			ans += n;
		}
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    string s,p;
    vector<int>v;
    map<int,int>mp;
    cin>>s;
    n=s.size();
    r=0;
    for(i=0;i<n;i++)
    {
        r=((r*10)+(s[i]-48))%9;
    }
    (r==0)? cout<<"Yes\n": cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3740
#include <stdio.h>

int main(void)
{
	int num[10];
	int x,a,b,i;
	
	for(i = 0;i < 10;i++){
		scanf("%d",&num[i]);
	}
	
	for(a = 0;a < 9;a++){
		for(b = a + 1;b < 10;b++){
			if(num[a] < num[b]){
				x = num[a];
				num[a] = num[b];
				num[b] = x;
			}
		}
	}
	
	printf("%d\n%d\n%d\n",num[0],num[1],num[2]);
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int sum=0;
  for(int i=1;i<=n;i++){
    int x=0;
    int k=i;
    x+=k%10;
    while(k>=10){
      k/=10;
      x+=k%10;
    }
    if(x>=a&&x<=b){
      sum+=i;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
G = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
ans = 0
for i in range(n):
    g = G[i]
    c = 1
    for j in g:
        if h[j] >= h[i]:
            c = 0
    if c == 1:
        ans += 1
print(ans)

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

vector<string> k = {"dreamer", "dream", "eraser", "erase"};

int main() {
	int p=0;
	string S;
	cin >> S;

	reverse(S.begin(), S.end());
	rep(i,4)
		reverse(k.at(i).begin(), k.at(i).end());

	while(p < S.size()) {
		bool ok = 0;

		rep(i,4)
			if(S.substr(p, min(S.size()-p, k.at(i).size())) == k.at(i)) {
				p += k.at(i).size();
				ok = 1;
			}

		if(!ok) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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;
}


auto solve() {
    string K;
    cin >> K;
    int D;
    cin >> D;

    int N = K.size();

    vector<vvll> dp(N + 1, vvll(D, vll(2, 0)));
    dp[0][0][1] = 1;

    const int MOD = 1e9 + 7;

    REP(i, N) {
        int d = K[i] - '0';

        REP(t, D) {
            // from max
            REP(td, d) {
                dp[i + 1][(t + td) % D][0] += dp[i][t][1];
                dp[i + 1][(t + td) % D][0] %= MOD;
            }
            dp[i + 1][(t + d) % D][1] += dp[i][t][1];
            dp[i + 1][(t + d) % D][1] %= MOD;

            // from not max
            REP(td, 10) {
                dp[i + 1][(t + td) % D][0] += dp[i][t][0];
                dp[i + 1][(t + td) % D][0] %= MOD;
            }
        }
    }

    ll res = (dp[N][0][0] + dp[N][0][1] - 1 + MOD) % MOD;
    return res;
}


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

//    cout << (solve() ? "Heisei" : "TBD") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}

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

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

    if (((a+b) == c) || ((a+c) == b) || (b+c) == a){
        cout << "Yes";
        return 0;
    }

    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll dp[105][100005];
int main()
{
    fastio();
    int n,W;cin>>n>>W;
    int v[n],w[n];
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for(int i=1;i<n+1;i++)
    {
        for(int j=0;j<W+1;j++)
        { 
            dp[i][j]=dp[i-1][j];
            if(j-w[i-1]>=0)
            {
                dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1],dp[i][j]);
            }
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    ll ans=0;
    for(int i=1;i<=W;i++)
    {
        ans= max(ans,dp[n][i]);
    }
    cout<<ans;
 }    

Measured memory_bytes: 79488
#include"bits/stdc++.h"
#define ll long long

using namespace std;

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

		ll X = 0;
		ll ans = 0;
		
		for (ll i = 40; i >=0; i--) {
			ll cnt = 0;
			for (ll k = 0; k < N; k++) {
				if ((1ll << i&a[k]) > 0) {
					cnt++;
				}
			}
			if (cnt < N - cnt&&X + (1ll << i) <= K) {
				X += 1ll << i;
				ans += (1ll << i)*(N - cnt);
			}
			else {
				ans += (1ll << i)*cnt;
			}
	}


	cout << ans << endl;

	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;

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

  std::cin >> S;

  if(S == "ARC"){
      std::cout << "ABC" << std::endl;
  }else{
      std::cout << "ARC" << std::endl;
  }
}


Measured memory_bytes: 3552
MOD = 10**9 + 7
n = int(input())
dp = [[0 for _ in range(3)] for _ in range(61)]
dp[60][0] = 1
for i in range(59, -1, -1):
	if (n>>i)&1 == 1:
		dp[i][0] += dp[i+1][0]
		dp[i][1] += dp[i+1][0] + dp[i+1][1]
		dp[i][2] += 2*dp[i+1][1] + 3*dp[i+1][2]
	else:
		dp[i][0] += dp[i+1][0] + dp[i+1][1]
		dp[i][1] += dp[i+1][1]
		dp[i][2] += dp[i+1][1] + 3*dp[i+1][2]
	for j in range(3):
		dp[i][j] %= MOD
print(sum(dp[0])%MOD)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
using namespace std;
inline int read(){
	#define gc getchar
	bool f=1;
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))f^=ch==gc(),ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return f?ans:-ans;
	#undef gc
}
const int mod=998244353;
typedef long long ll;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int&a,int b){(a+=b)<mod?a:a-=mod;}
inline void Dec(int&a,int b){(a-=b)<0?a+=mod:a;}
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))if(p&1)Mul(ret,a);return ret;}
const int N=2505;
int n,m,P,cnt[N];
vector<int>e[N],val[N];
ll dis[N];
bool ban[N],in[N];
const double eps=1e-7;
inline bool check(double x){
	queue<int>q;
	for(ri i=1;i<=n;++i)in[i]=0,cnt[i]=0,dis[i]=-1e9;
	dis[1]=0,q.push(1);
	while(q.size()){
		int x=q.front();
		q.pop();
		in[x]=0;
		for(ri i=0,v;i<e[x].size();++i){
			if((dis[v=e[x][i]])<dis[x]+val[x][i]){
				if(ban[v])continue;
				dis[v]=dis[x]+val[x][i];
				if(!in[v]){
					in[v]=1;
					++cnt[v];
					if(cnt[v]>=n){
						puts("-1");
						exit(0);
					}
					q.push(v);
				}
			}
		}
	}
	cout<<max(0ll,dis[n]);
}
inline bool dfs(int p){
	if(in[p])return 0;
	if(p==n)return 1;
	in[p]=1;
	for(ri i=0;i<e[p].size();++i)if(dfs(e[p][i]))return 1;
	return 0;
}
int main(){
	n=read(),m=read(),P=read();
	for(ri i=1,u,v,w;i<=m;++i){
		u=read(),v=read(),w=read()-P;
		e[u].push_back(v),val[u].push_back(w);
	}
	for(ri i=1;i<=n;++i){
		memset(in,0,sizeof(in));
		if(!dfs(i))ban[i]=1;
	}
	check(0);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 2000000000
#define Q 500000
void merge(int*,int,int,int);
void mergeSort(int*,int,int);

int count,n;

int main(){
  int i;
  int s[Q];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  count=0;
  mergeSort(s,0,n);
  printf("%d",s[0]);
  for(i=1;i<n;i++) printf(" %d",s[i]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}

void merge(int *A,int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1],R[n2+1];
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(j=0;j<n2;j++) R[j] = A[mid + j];
  L[n1] = N;
  R[n2] = N;
  i = 0;
  j = 0;
  for(k=left;k<right;k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      count++;
    }else{
      A[k] = R[j];
      j++;
      count++;
    }
  }
}

void mergeSort(int *A,int left, int right){
  int mid,i;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4508
#include <stdio.h>
#include<stdlib.h>

#define NIL NULL

struct node{

  struct node *right;
  struct node *left;
  struct node *parent;
  int key;

};

typedef struct node * Node; 
 
Node root;

void insert(int);

void inorder(Node );

void preorder(Node );

int main(){

  int n, i, x;

  char com[20];

  Node t;

  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){

    scanf("%s", com);

    if (com[0] == 'i'){
      
      scanf("%d", &x);
      
      insert(x);

    } 
    else if (com[0] == 'p'){
      
      inorder(root);

      printf("\n");

      preorder(root);

      printf("\n");

    }

  }
 
  return 0;
}


 
void insert(int k){

  Node y = NIL;

  Node x = root;

  Node z;
 
  z = malloc(sizeof(struct node));

  z->key = k;

  z->left = NIL;

  z->right = NIL;
 
  while(x != NIL){

    y = x;

    if((z->key) < (x->key))
      x = x->left;
    else 
      x = x->right;
  }

  z->parent = y;
 
  if(y == NIL)
    root = z;

  else if((z->key) < (y->key)) 
    y->left = z;
  else 
    y->right = z;
 
}

void inorder(Node u){

  if (u == NIL)
    return;
 
  inorder(u->left);

  printf(" %d", u->key);

  inorder(u->right);
 
}

void preorder(Node u){

  if (u == NIL)
    return;
 
 printf(" %d",u->key);

 preorder(u->left);

 preorder(u->right);
 
}

Measured memory_bytes: 24040
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
  
a, b = map(int, input().split())
la = prime_decomposition(a)
lb = prime_decomposition(b)
la_lb_and = list(set(la) & set(lb))
    
print(len(la_lb_and) + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fore_(i, s, e) for(long long i = s; i > e; i--)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
long long b,w,r;
string s;
int main() {
  FIN;cin>>s;fore_(i,s.size()-1,-1){
    if(s[i]-'W'){b++;r+=w;}else {w++;}
  } cout<<r<<endl; return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(10);
    int n,m;
    cin>>n>>m;
    vp a(m);
    cin>>a;
    sort(all(a), [](const P&a, const P&b){return a.S<b.S;});
    int last_cut=-1;
    int cnt=0;
    dprint(a);
    REP(i,m){
        if(a[i].F>last_cut){
            last_cut=a[i].S-1;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ab = a + b;
    ll r;
    if (n % ab < a) {
        r = n % ab;
    } else {
        r = a;
    }
    cout << (n / ab) * a + r << endl;
    return 0;
}

Measured memory_bytes: 3624
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        count +=1
if p[-1] == n:
    count += 1
print(count)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
using LL = long long;
typedef long long LL;

int n, k;
int a[100010];
int main() {
  scanf("%d%d", &n, &k);
  REP(i, n) scanf("%d", &a[i]);
  long long ans = 0;
  REP(i, n - 1) {
    int s = a[i] + a[i + 1];
    if (s <= k) continue;
    int d1 = min(a[i + 1], s - k);
    a[i + 1] -= d1;
    ans += d1;

    s = a[i] + a[i + 1];
    if (s <= k) continue;
    int d2 = min(a[i], s - k);
    a[i] -= d2;
    ans += d2;
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>
#include <deque>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;


struct edge {
    LL to;
    LL cost;
};

/*
 LL V;

 cin >> V;

 vector<edge> G[V];

 rep(i,0,V){
 	 LL e;

 	 cin >> e;

 	 rep(j,0,e){
 	 	 LL to,cost;
 	 	 cin >> to >> cost;

 	 	 G[j].insert(new edge(to,cost));
 	 }
 }

 */

void dijkstra(LL s,LL V,vector<edge> G[],LL d[]) {
    priority_queue<pLL, vector<pLL>, less<pLL> > que;
    fill(d, d+V, INT_MAX);
    d[s] = 0;
    que.push(pLL(0, s));

    while (!que.empty()) {
        pLL p = que.top();
        que.pop();
        LL v = p.second;
        if (d[v] < p.first) continue;

        for (LL i=0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pLL(d[e.to], e.to));
            }
        }
    }
}


int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


LL gcd(LL i,LL j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

LL A(){
	string s;

	cin >> s;

	if(s == "ABC")
		cout << "ARC";
	else
		cout << "ABC";


	return 0;
}

LL B(){

	return 0;
}

LL C(){

	return 0;
}

LL D(){

	return 0;
}

LL E(){

	return 0;
}

signed main() {
	A();
	//B();
	//C();
	//D();
	//E();
	return 0;
}


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

int main() {
    int H, W; cin >> H >> W;
    vector<vector<bool>> s(H, vector<bool>(W, false));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++){
            char c; cin >> c;
            if(c=='#') s[i][j] = true;
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(s[i][j]==true){
                if((i<H-1 && s[i+1][j]) || (i>0 && s[i-1][j]) || (j<W-1 && s[i][j+1]) || (j>0 && s[i][j-1])){
                    continue;
                }
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
suma=sum(a)
cnt=0
for i in a:
    #print(i)
    if i*4*m>=suma:
        cnt+=1
if cnt>=m:print('Yes')
else:print('No')


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)998244353;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, s = 0, ans = 1;
  cin >> N;
  vec a(N + 5, 0);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    s += a[i];
    ans = (ans * 3) % MOD;
  }

  static int dp[310][90010];
  for (int i = 1; i <= s; i++) dp[0][i] = 0;
  dp[0][0] = 1;

  for (int i = 1; i <= N; i++) {
    for (int r = 0; r <= s; r++) {
      dp[i][r] = dp[i - 1][r] * 2 % MOD;
      if (r - a[i] >= 0) dp[i][r] = (dp[i][r] + dp[i - 1][r - a[i]]) % MOD;
    }
  }

  int res = 0;
  for (int r = (s + 1) / 2; r <= s; r++) {
    res += dp[N][r] % MOD;
    res %= MOD;
  }

  if (s % 2 == 0) {
    for (int i = 1; i <= N; i++) {
      for (int r = 0; r <= s; r++) {
        dp[i][r] = dp[i - 1][r] % MOD;
        if (r - a[i] >= 0) dp[i][r] = (dp[i][r] + dp[i - 1][r - a[i]]) % MOD;
      }
    }
    res = (res - dp[N][s / 2] + MOD) % MOD;
  }

  cout << (ans - res * 3 % MOD + MOD) % MOD << endl;
  return 0;
}


Measured memory_bytes: 213248