akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val x = sc.nextInt

  val d = x % 10
  val c = x % 100 / 10
  val b = x % 1000 / 100
  val a = x / 1000

  val bins = (0 until 8).map(k => zeroEmbeddingtoString(k.toBinaryString, 3))

  val res = bins.find { bin =>
    a + (if (bin(0) == '0') 1 else -1) * b +(if (bin(1) == '0') 1 else -1) * c +(if (bin(2) == '0') 1 else -1) * d == 7
  }.fold("impossible") { bin =>
    val flg0 = if (bin(0) == '0') "+" else "-"
    val flg1 = if (bin(1) == '0') "+" else "-"
    val flg2 = if (bin(2) == '0') "+" else "-"
    s"$a$flg0$b$flg1$c$flg2$d=7"
  }

  println(res)

  def zeroEmbeddingtoString(str: String, index: Int): String ={
    val l = str.length
    List.fill(index - l)("0").mkString + str
  }

}

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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  vector<int>s(n);
  vector<int>ans(n);
  rep(i,n){
    s[i]=a[i];
  }
  sort(s.rbegin(),s.rend());
  rep(i,n){
    if(a[i]!=s[0])ans[i]=s[0];
    if(a[i]==s[0])ans[i]=s[1];
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3968
S = input()

words = ['dream', 'dreamer', 'erase', 'eraser']

i = len(S)

while True:
    if S[i-5:i]==words[0] or S[i-5:i]==words[2]:
        i -= 5
    elif S[i-6:i]==words[3]:
        i -= 6
    elif S[i-7:i]==words[1]:
        i -= 7
    else:
        print('NO')
        exit()
    if i == 0:
        print('YES')
        exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int a=0,x=0;
	cin >> s;
	sort(s.begin(),s.end());
	if(s[0]!=s[1]) a=1;
	if(s[2]!=s[3]) a=1;
  	if(s[0]!=s[3] && s[1]==s[2]) a=1;
  	if(s[0]==s[3]) a=1;
	if(a==1) cout << "No" << '\n';
	if(a==0) cout << "Yes" << '\n';
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x;
int main()
{
    cin >> x;
    for(ll i = -150; i <= 160; i++){
        for(ll j = -150; j <= 160; j++){
            if(i*i*i*i*i-j*j*j*j*j == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3636
package main

import "fmt"
import "bufio"
import "os"
import "strconv"

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
  var a,b,c,x int
  
  sc.Split(bufio.ScanWords)
  a = nextInt() // 500
  b = nextInt() // 100
  c = nextInt() // 50
  x = nextInt()
  
  cnt:=0
  
  var i_max, j_max, k_max int

  if a > x/500 {
    i_max = x/500
  } else {
    i_max = a
  }
  if b > x/100 {
    j_max = x/100
  } else {
    j_max = b
  }
  if c > x/50 {
    k_max = x/50
  } else {
    k_max = c
  }
  
  // fmt.Print("%d %d %d", i_max, j_max, k_max)
  
  for i:=0; i<=i_max; i++ {
    for j:=0; j<=j_max; j++ {
      for k:=0; k<=k_max; k++ {
        if i*500+j*100+k*50 == x {
          cnt++
        }
      }
    }
  }

  fmt.Print(cnt)
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int x,y,z,tmp;
	cin>>x>>y>>z;
	tmp=x;
	x=y;
	y=tmp;
	
	tmp=x;
	x=z;
	z=tmp;
	cout<<x<<" "<<y<<" "<<z<<endl;
	// your code goes here
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const int _ = 2007;

int finding(int a,int b)
{
	cout<<"? "<<a<<' '<<b<<endl;
	char temp;cin>>temp;
	return temp=='Y';
}

int n,na,nb;
int stk[_]={0},top=0;

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

	cin>>na>>nb;
	if(na<=nb){cout<<"Impossible"<<endl;return 0;}
	n=na+nb;

	for(int i=0;i<n;i++)
	{
		if(top<=0){stk[++top]=i;continue;}
		if(!finding(stk[top],i))top--;
		else stk[++top]=i;
	}

	string ans="";
	int who=stk[top];
	for(int i=0;i<n;i++)
	{
		if(i==who){ans.push_back('1');continue;}
		ans.push_back("01"[finding(who,i)]);
	}

	cout<<"! "<<ans<<endl;

	return 0;
}


Measured memory_bytes: 724
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  set<string> se;
  for(int i=1;i<=n;i++){
    string x; cin >> x;
    se.insert(x);
  }

  cout << se.size() << '\n';

  

  return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

int h, w;

int main() {
  int i, j;
  int rh, rw;
  while (1) {
    scanf("%d%d ", &h, &w); 
    if (!h && !w) break;

    rh = h; rw = w;
    int min_diag = 200*200;
    for (i=1; i<=150; i++)
      for (j=i+1; j<=150; j++) {
        int diag = i*i + j*j; 
        if ((diag <= h*h + w*w) && (diag != (h*h + w*w) || i<=h)) continue;
        if ((diag < min_diag) || (diag = min_diag && i < rh)) {
          rh = i;
          rw = j; 
          min_diag = diag;
        }
      }
    printf("%d %d\n", rh, rw);
  }
	return 0;
}

Measured memory_bytes: 1192
n,k = map(int,input().split())
x = list(map(int,input().split()))

# print(n,k)
minx = 300000000
if k==1:
    x = list(map(abs,x))
    print(min(x))
else:
    for idx in range(n-k+1):
        if x[idx]*x[idx+k-1] < 0 :
            sumx = min(abs(x[idx]),abs(x[idx+k-1])) + abs(x[idx])+abs(x[idx+k-1])
        else :
            sumx = max(abs(x[idx]),abs(x[idx+k-1]))
        if sumx < minx:
            minx = sumx
        # print(x[idx:idx+k], minx)

    print(minx)


Measured memory_bytes: 14252
class Node():
	def __init__(self, key):
		self.parent = None
		self.left = None
		self.right = None
		self.key = key
 
class Tree():
	def __init__(self):
		self.root = None
	def insert(self, key):
		z = Node(key)
		y = None
		x = self.root
		while x:
			y = x
			if z.key < x.key:
				x = x.left
			else:
				x = x.right
		z.parent = y
		if y == None:
			self.root = z;
		elif z.key < y.key:
			y.left = z
		else:
			y.right = z
	def pre_order(self, node):
		print(" {}".format(node.key), end = "")
		if node.left:
			self.pre_order(node.left)
		if node.right:
			self.pre_order(node.right)
	def in_order(self, node):
		if node.left:
			self.in_order(node.left)
		print(" {}".format(node.key), end = "")
		if node.right:
			self.in_order(node.right)
	def out(self):
		self.in_order(self.root)
		print("")
		self.pre_order(self.root)
		print("")
	def find(self, key):
		node = self.root;
		while node:
			if node.key == key:
				return "yes"
			elif node.key > key:
				node = node.left
			else:
				node = node.right
		return "no"

tree = Tree()
n = int(input())
for i in range(n):
	c = input().split()
	if c[0] == "insert":
		tree.insert(int(c[1]))
	elif c[0] == "find":
		print(tree.find(int(c[1])))
	else:
		tree.out()

Measured memory_bytes: 124564
#include <iostream>
using namespace std;
int a[100];
int main(){
    int n;
    while(cin>>n && n){
        int ans=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            for(int j=0;j<i;j++){
                if(a[j]>a[i])ans++;
            }
        }
        cout << ans << endl;
    }
}

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

struct node_t {
	int x;
	struct node_t* next;
};

int main(void) {
	int n, q;
	struct node_t *ent[1024], *exi[1024];
	int i;
	if (scanf("%d%d", &n, &q) != 2) return 1;
	for (i = 0; i < n; i++) {
		ent[i] = exi[i] = NULL;
	}
	for (i = 0; i < q; i++) {
		int query, t, x;
		if (scanf("%d%d", &query, &t) != 2) return 1;
		if (query == 0 && scanf("%d", &x) != 1) return 1;
		switch (query) {
			case 0:
				{
					struct node_t* nn = malloc(sizeof(struct node_t));
					if (nn == NULL) return 1;
					nn->x = x;
					nn->next = NULL;
					if (ent[t] == NULL) {
						ent[t] = exi[t] = nn;
					} else {
						ent[t]->next = nn;
						ent[t] = nn;
					}
				}
				break;
			case 1:
				if (exi[t] != NULL) {
					printf("%d\n", exi[t]->x);
				}
				break;
			case 2:
				if (exi[t] != NULL) {
					struct node_t* gomi = exi[t];
					exi[t] = exi[t]->next;
					free(gomi);
					if (exi[t] == NULL) ent[t] = NULL;
				}
				break;
		}
	}
	for (i = 0; i < n; i++) {
		while (exi[i] != NULL) {
			struct node_t* next = exi[i]->next;
			free(exi[i]);
			exi[i] = next;
		}
	}
	return 0;
}



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

int main(){

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

  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1 - i; j++) {
      k = n - i - j;
      if (10000 * i + 5000 * j + 1000 * k == y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }


  cout << "-1 -1 -1" << endl;






}


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

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

    int l;

    int sum = 0;
    int count = 1;
    for (int i = 0; i < n; i++) {
        cin >> l;
        sum += l;

        if (sum > x) {
            break;
        }

        count++;
    }

    cout << count << endl;

    return 0;
}


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

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn INT_MIN
#define imx INT_MAX

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(long 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...) 20
#endif

ll power(ll a,ll b,ll m=1e9+7)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1LL;
    ll ret=power(a,b/2);
    ret=(ret*ret)%m;
    if(b&1)
    ret=(ret*a)%m;
    return ret;
}

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

void solve()
{
    ll n,i,j;
    cin>>n;
    ll a[n][2];
    for(i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1];
    ll flag=0;
    for(i=0;i<n-2;i++)
    {
        if(a[i][0]==a[i][1])
        {
            if(a[i+1][0]==a[i+1][1])
            {
                if(a[i+2][0]==a[i+2][1])
                {
                    flag=1;
                    break;
                }
            }
        }
    }
    if(flag)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

int main()
{
    make_it_fast;
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::HashSet;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: usize,
  mut d: [i64; n],
  }

  d.sort();
  let l = d[n / 2 - 1];
  let r = d[n / 2];

  let ans = r - l;

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


Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    int n;
    while( cin >> n ) {
        if ( n == 0 )
            break;

        map<char, char> pt;
        for( int i=0; i<n; ++i ) {
            string f, t;
            cin >> f >> t;
            pt[f[0]] = t[0];
        }

        int m;
        cin >> m;
        for( int i=0; i<m; ++i ) {
            char c;
            cin >> c;
            auto const it = pt.find( c );
            cout << ( ( it != pt.end() ) ? it->second : c );
        }
        cout << endl;
    }
}

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

int main()
{
  string s;
  cin >>s;
  if ( ((s[0]==s[1]) && (s[1]==s[2])) || ((s[1]==s[2])&&(s[2]==s[3])) )
  {
    cout <<"Yes"<<endl;
  }
  else cout <<"No"<<endl; 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{

    double r,menseki,ensyu;
    
    scanf("%lf",&r);
    
    menseki = r*r*3.141592653589;
    ensyu = r*2*3.141592653589;
    
    // insert code here...
    printf("%f %f\n",menseki,ensyu);
    return 0;
}

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

int main(){
  long int X, P;
  long int A = 100;
  long int c = 1;
  cin >> X;
  for(;;){
    P = A * 0.01;
    A = A + P;
    if(A >= X){
      cout << c << endl;
      break;
    }
    else if(A < X){
      c = c + 1;
    }
  }
}

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        int D = Integer.parseInt(sc.next());
        var c = new int[27];
        for(int i = 1; i <= 26; i++){
            c[i] = Integer.parseInt(sc.next());
        }
        var s = new int[D+1][27];
        for(int d = 1; d <= D; d++){
            for(int i = 1; i <= 26; i++){
                s[d][i] = Integer.parseInt(sc.next());
            }
        }
        var t = new int[D+1];
        for(int d = 1; d <= D; d++){
            t[d] = Integer.parseInt(sc.next());
        }
        
        var a = new int[27][D+1];
        long score = 0;
        for(int i = 1; i <= 26; i++){
            for(int d = 1; d <= D; d++){
                if(t[d] == i){
                    a[i][d] = 0;
                    score += s[d][i];
                }else{
                    a[i][d] = a[i][d-1]+1;
                    score -= c[i] * a[i][d];
                }
            }
        }
        
        int M = Integer.parseInt(sc.next());
        var sb = new StringBuilder();
        for(int i = 0; i < M; i++){
            int d = Integer.parseInt(sc.next());
            int q = Integer.parseInt(sc.next());
            int r = t[d];
            t[d] = q;
            score -= s[d][r];
            for(int j = d; j <= D; j++){
                if(t[j] == r) break;
                score += c[r] * a[r][j];
                a[r][j] = a[r][j-1]+1;
                score -= c[r] * a[r][j];
            }
            score += s[d][q];
            score += c[q] * a[q][d];
            a[q][d] = 0;
            for(int j = d+1; j <= D; j++){
                if(t[j] == q) break;
                score += c[q] * a[q][j];
                a[q][j] = a[q][j-1]+1;
                score -= c[q] * a[q][j];
            }
            sb.append(score).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 60368
n = int(raw_input())
L = map(int,raw_input().split())

L = sorted(L)
ans = 0

for a in xrange(n-2):
	c = a+2
	for b in xrange(a+1,n-1):
		while c < n and L[a] + L[b] > L[c]:
			c += 1
		if c > b:
			ans += (c-b-1)
print ans			

Measured memory_bytes: 2820
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    ps=[]
    for i in range(2,int((N**0.5))+1):
        if N%i==0:
            cnt=0
            for j in range(40):
                if N%i==0:
                    N//=i
                    cnt+=1
            ps.append([i,cnt])
    if N!=1:
        ps.append([N,1])
        
    ans=0
    for p in ps:
        ans+=int(((8*p[1]+1)**0.5-1)/2)
    print(ans)
    
    
if __name__=="__main__":
    main()


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

int main(){
  int N;
  cin >> N;
  using vppsii=vector<pair<pair<string,int>,int>>;
  vppsii a(N);
  for(int i=0;i<N;i++){
    string s;
    int p;
    cin>>s>>p;
    a.at(i)=make_pair(make_pair(s,-p),i+1);
  }
  sort(a.begin(),a.end());
  for(auto e:a){
    cout<<e.second<<endl;
  }
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys
import bisect

MOD = 998244353  # type: int

class BitIndexedTree(object):
    def __init__(self, N):
        self.V = [0] * N
        self.N = N
    
    def __getitem__(self, key):
        return self.sum(key, key+1)
    
    def __setitem__(self, key, value):
        diff = value - self[key]
        self.add(diff, key)

    def add(self, w, a):
        if w == 0:
            return
        x = a
        while x <= self.N:
            self.V[x-1] += w
            x += x & -x
    
    def sum(self, start=0, end=0):
        if end <= start:
            return 0
        if start > 0:
            return self.sum(0, end) - self.sum(0, start)
        x = end
        ret = 0
        while x > 0:
            ret += self.V[x-1]
            x -= x & -x
        return ret


def solve(N: int, P: "List[tuple]"):
    res = 0
    power = [1] * N
    for i in range(1, N):
        power[i] = power[i-1] * 2 % MOD

    P.sort(key=lambda x: x[1])
    for i, p in enumerate(P):
        p[1] = i
    
    P.sort()
    for i, p in enumerate(P):
        p[0] = i
    left = BitIndexedTree(N)
    right = BitIndexedTree(N)

    ll = [0] * N
    lg = [0] * N
    gl = [0] * N
    gg = [0] * N

    for i, p in enumerate(P):
        ll[i] = left.sum(0, p[1])
        lg[i] = i-ll[i]
        left.add(1, p[1]+1)

    for i, p in enumerate(P[::-1]):
        gl[-1-i] = right.sum(0, p[1])
        gg[-1-i] = i-gl[-1-i]
        right.add(1, p[1]+1)

    for a1, a2, a3, a4 in zip(gg, lg, ll, gl):
        b1 = power[a1]
        b2 = power[a2]
        b3 = power[a3]
        b4 = power[a4]

        res += (b1 - 1) * (b3 - 1) * b2 * b4
        res += (b2 - 1) * (b4 - 1) * b1 * b3

        res -= (b1 - 1) * (b2 - 1) * (b3 - 1) * (b4 - 1)

        res += b1 * b2 * b3 * b4

        res %= MOD
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [()] * (N)  # type: "List[tuple]" 
    for i in range(N):
        x = int(next(tokens))
        y = int(next(tokens))
        P[i] = [x, y]
    solve(N, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 85004
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int x;
  rep(i,5)
  {
    cin >> x;
    if (x == 0) {
      cout << i + 1;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && B == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  char c;
  char cc[] = {'a', 'e', 'i', 'o', 'u'};
  cin >> c;
  REP(i, 5) {
    if (c == cc[i]) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
h = []
w = []
while True:
    h1,w1 = map(int,input().split())
    if (h1 == 0)*(w1 == 0) :
        break
    h.append(int(h1))
    w.append(int(w1))
    

for i in range(len(h)):
    for j in range(h[i]):
        if (j % 2 == 0) and (w[i] %2 ==0):
            print("#."*(w[i]//2))
        elif (j % 2 == 0) and (w[i] %2 ==1):
            print("#."*(w[i]//2)+"#")
        elif (j % 2 == 1) and (w[i] %2 ==0):
            print(".#"*(w[i]//2))
        elif (j % 2 == 1) and (w[i] %2 ==1):
            print(".#"*(w[i]//2)+".")      
    print()



Measured memory_bytes: 5628
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l,reverse=True)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

def main():
  n,k,q=LI()
  l=[I() for _ in range(q)]

  l=summarize_list(l)
  # print(l)

  for i in range(n):
    x=i+1

    if len(l)>0 and l[-1][0]==x:
      if l[-1][1]+k-q>0:
        print('Yes')
      else:
        print('No')
      l.pop()
    else:
      if k-q>0:
        print('Yes')
      else:
        print('No')

main()
# print(main())


Measured memory_bytes: 17316
#include<stdio.h>
int main(void){
  
  double x=0,y=0;
  int a,b,c,d,e,f,p=0,q=0,r=0,s=0;
  
  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF)
    {
      p=a*e-b*d;
      q=c*e-b*f;
      x=(double)q/p;
      
      r=b*d-a*e;
      s=c*d-a*f;
      y=(double)s/r;
      
      if(x==-0)x=0;
      if(y==-0)y=0;

      printf("%.3f %.3f\n",x,y);
    }
  return 0;
}

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

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

    int n = sc.nextInt(); //展望台の数
    int m = sc.nextInt(); //道の数

    int[] h = new int[n]; //展望台の高さ
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    Set<Integer> set = new HashSet<>();
    for (int i = 0; i < m; i++) {
      int t1 = sc.nextInt() - 1;
      int t2 = sc.nextInt() - 1;

      if (h[t1] <= h[t2]) {
        set.add(t1);
      }

      if (h[t1] >= h[t2]) {
        set.add(t2);
      }
    }

    System.out.println(n - set.size());
  }
}


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


int main(){
  int N , K  ;
  cin >> N >> K  ;
  
  int64_t cnt = K; 
  
  for(int i = 1 ; i < N ; i++){
    cnt = cnt*(K-1) ; 
  }
  cout << cnt << endl ;
  
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
    int n, p;
    cin >> n >> p;
    Vi A(n);
    rep(i, n)  cin >> A[i];

    Vll dp(n, Vl(2, 0));
    dp[0][0] = 1;
    if (A[0] % 2 == 0) {
        dp[0][0]++;
    }
    else {
        dp[0][1] = 1;
    }

    for (int i = 1; i < n; i++) {
        if (A[i] % 2 == 0) {
            dp[i][0] = dp[i - 1][0] * 2;
            dp[i][1] = dp[i - 1][1] * 2;
        }
        else {
            dp[i][0] = dp[i - 1][1] + dp[i - 1][0];
            dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
        }
    }
    cout << dp[n - 1][p] << endl;
}


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

using namespace std;

struct process {
    string name;
    int time;
};

int main(void) {
    int n, q;
    int time = 0;
    queue<process> p;

    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        process temp;
        cin >> temp.name >> temp.time;
        p.push(temp);
    }
    while (not p.empty()) {
        process top = p.front();
        p.pop();
        if (top.time <= q) {
            time += top.time;
            cout << top.name << " " << time << endl;
        }
        else {
            time += q;
            top.time -= q;
            p.push(top);
        }
    }
    
    return 0;
}



Measured memory_bytes: 6328
#include <iostream>
int gcd(int a, int b) {
	return (a ? gcd(b % a, a) : b);
}
int main() {
	int a, b, x;
	while (std::cin >> a >> b) {
		x = gcd(a, b);
		std::cout << x << " " << a / x * b << std::endl;
	}
}

Measured memory_bytes: 1160
module vector_int32_mod
    use,intrinsic :: iso_fortran_env
    type vector
        integer(int64),pointer:: array(:) =>null()
        integer(int64):: l
    contains
        procedure :: push_back => vector_regist
    end type

    interface vector
        module procedure vector_init
    end interface
    private
    public:: vector
contains
    function vector_init() result(vec)
        type(vector):: vec
        allocate(vec%array(1))
        vec%l = 0
    end function

    subroutine vector_regist(vec, v)
        class(vector):: vec
        integer(int64):: v

        if (vec%l+1 > size(vec%array)) call add_(vec)
        vec%l=vec%l+1
        vec%array(vec%l) = v
    end subroutine


    subroutine add_(vec)
        type(vector):: vec
        integer(int64),pointer:: tmp(:)
        integer(int64):: l

        tmp => vec%array
        l = size(vec%array)
        vec%array => null()
        allocate(vec%array(l*2))
        vec%array(1:l) = tmp(:)
        deallocate(tmp)
    end subroutine
end module

program main
    use,intrinsic :: iso_fortran_env
    use vector_int32_mod
    implicit none
    integer(int64):: n,q,k,i
    integer(int64), allocatable:: a(:), b(:), c(:), x(:), y(:)
    integer(int64), allocatable:: k_dist(:)
    type(vector), allocatable:: to(:), d(:)
    
    read*, n
    allocate(a(n-1), b(n-1), c(n-1))
    allocate(to(n), d(n))
    allocate(k_dist(0:n))

    do i=1,n
        to(i) = vector()
        d(i) = vector()
    end do
    
    do i=1,n-1
        read*, a(i), b(i), c(i)
        call to(a(i))%push_back(b(i))
        call to(b(i))%push_back(a(i))
        call d(a(i))%push_back(c(i))
        call d(b(i))%push_back(c(i))
    end do

    read*, q,k
    allocate(x(q), y(q))
    k_dist(0)=0_8
    call dfs(k,0_8,0_8)

    do i=1,q
        read*, x(i), y(i)
    end do

    do i=1,q
        print'(i0)', k_dist(x(i)) + k_dist(y(i))
    end do
contains
    recursive subroutine dfs(self, from, distance)
        integer(int64), intent(in):: self, from, distance
        integer(int64):: i, next, next_d

        k_dist(self) = k_dist(from)+distance

        do i=1,to(self)%l
            next = to(self)%array(i)
            next_d = d(self)%array(i)
            if (next == from) cycle
            call dfs(next, self,next_d)
        end do
    end subroutine
end program main

Measured memory_bytes: 37128
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;

using namespace std;

int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        ll x,y; cin >> x >> y;
        bool flg = false;
        for(ll i = 0; i <= x; i++){
          ll legs = i * 2 + (x - i) * 4;
          if(legs == y) flg = true;
        }
        if(flg) cout << "Yes" << endl;
        else cout << "No" << endl;

        return 0;
}


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

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

vector <int> conn[100050];
int dis[100050];
int rev[100050];
void BFS(int st, int N) {
	int i, j;
	vector <int> Vu;
	memset(dis, 0x3f, sizeof(dis));
	dis[st] = 0;
	Vu.push_back(st);
	for (i = 0; i < Vu.size(); i++) {
		for (auto it : conn[Vu[i]]) {
			if (dis[it] == INF) {
				dis[it] = dis[Vu[i]] + 1;
				rev[it] = Vu[i];
				Vu.push_back(it);
			}
		}
	}
}

int cnt[100050];
int ch[100050];
int main() {
	int N, i, j, k;
	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
	}

	BFS(1, N);
	int r = 1;
	for (i = 2; i <= N; i++) if (dis[i] > dis[r]) r = i;
	BFS(r, N);

	int st = r, en = r;
	for (i = 1; i <= N; i++) if (dis[i] > dis[en]) en = i;
	
	vector <int> Vl;
	Vl.push_back(en);
	while (Vl.back() != st) Vl.push_back(rev[Vl.back()]);
	for (i = 0; i < Vl.size(); i++) ch[Vl[i]] = i + 1;

	for (i = 0; i < Vl.size(); i++) {
		for (auto it : conn[Vl[i]]) {
			if (ch[it]) continue;
			ch[it] = -i - 1;
		}
	}
	for (i = 1; i <= N; i++) {
		if (!ch[i]) return !printf("-1\n");
		if (ch[i] > 0) continue;
		cnt[-ch[i]]++;
	}

	vector <int> Va[3];
	for (i = 1, j = 0; i <= Vl.size(); i++) {
		for (k = j + 2; k <= j + cnt[i] + 1; k++) Va[0].push_back(k);
		Va[0].push_back(j + 1);
		j += cnt[i] + 1;
	}
	for (i = Vl.size(), j = 0; i >= 1; i--) {
		for (k = j + 2; k <= j + cnt[i] + 1; k++) Va[1].push_back(k);
		Va[1].push_back(j + 1);
		j += cnt[i] + 1;
	}

	Va[2] = min(Va[0], Va[1]);
	for (auto it : Va[2]) printf("%d ", it);
	return !printf("\n");
}

Measured memory_bytes: 9704
#include <bits/stdc++.h> 
using namespace std;
#define     mod             1e9+7
#define     ll              long long int 
#define     mp              make_pair
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     vi              vector<int>
#define     vvi				vector<vector<int>>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int>>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            '\n'


void solve(){

	int n;
	cin>>n;
	string str;
	cin>>str;
	int red = 0,cnt = 0;
	for(int i=0;i<n;i++){
		if(str[i] == 'R') red++;
	}
	for(int i=0;i<red;i++){
		if(str[i] == 'W') cnt++;
	}
	cout<<cnt;
}
 
int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif

    IOS;
    int t = 1;

    solve();
    // t(){
    // 	cout<<"Case #"<<t<<": ";
    // 	solve();
    // 	t++;
    // }


}


Measured memory_bytes: 3728
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    N = I()
    X = S()
    bit_cnt = X.count('1')
    one_inv_cnt = bit_cnt - 1
    zero_inv_cnt = bit_cnt + 1
    MAX = 2 * 10 ** 5 + 1

    # 大きい数の余り
    # 繰り返し２乗法の発展？
    zero_inv_mod = 0
    one_inv_mod = 0
    # for i in range(len(X)-1, -1, -1):
    for i in range(0, len(X)):
        b = int(X[i])
        if one_inv_cnt != 0:
            one_inv_mod = (one_inv_mod * 2 + b) % one_inv_cnt
        zero_inv_mod = (zero_inv_mod * 2 + b) % zero_inv_cnt

    f = [0] * MAX
    pop_count = [0] * MAX
    for i in range(1, MAX):
        pop_count[i] = pop_count[i//2] + i % 2
        f[i] = f[i % pop_count[i]] + 1


    #pow2 の前計算
    one_pow2 = [1] * 220000
    zero_pow2 = [1] * 220000
    for i in range(1, 220000):
        if one_inv_cnt != 0:
            one_pow2[i] = one_pow2[i-1] * 2 % one_inv_cnt
        zero_pow2[i] = zero_pow2[i-1] * 2 % zero_inv_cnt

    for i in range(len(X)-1, -1, -1):
        if X[N-1-i] == '1':
            if one_inv_cnt != 0:
                nxt = one_inv_mod
                # nxt -= pow(2, i, one_inv_cnt)
                nxt -= one_pow2[i]
                nxt %= one_inv_cnt
                print(f[nxt] + 1)
            else:
                print(0)
        else:
            nxt = zero_inv_mod
            # nxt += pow(2, i, zero_inv_cnt)
            nxt += zero_pow2[i]
            nxt %= zero_inv_cnt
            print(f[nxt] + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87020
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 100000
#define INFTY 1000000001

struct Card{
  char suit;
  int value;
};

Card A[MAX],B[MAX],L[MAX/2+1],R[MAX/2+1];


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

}

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


int partition(Card B[],int p,int r){
  int x=B[r].value;
  int i=p-1;
  for(int j=p;j<r;j++){
    if(B[j].value<=x){
      i++;
      swap(B[i],B[j]);
    }
  }
  swap(B[i+1],B[r]);
  return i+1;
}

void quickSort(Card B[],int p,int r){
  if(p<r){
    int q=partition(B,p,r);
    quickSort(B,p,q-1);
    quickSort(B,q+1,r);
  }
}

int main(){
  int n,stable=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int value;
    char suit;
    cin>>suit>>value;
    A[i].suit=B[i].suit=suit;
    A[i].value=B[i].value=value;
  }
  mergeSort(0,n);
  quickSort(B,0,n-1);
  for(int i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable++;
  }
  if(stable) cout<<"Not stable"<<endl;
  else cout<<"Stable"<<endl;

  for(int i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }



}



Measured memory_bytes: 5564
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_ALDS1_10_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            int[] r = new int[n + 2];   // c.lastを追加
            for (int i = 0; i < n; i++)
            {
                var input = ReadInt();
                r[i + 1] = input[0];
                if (i == n - 1) r[n + 1] = input[1];//最後を修正
            }

            int[,] dp = new int[n + 1, n + 1];
            for (int i = 1; i < n; i++)
            {
                dp[i, i + 1] = r[i] * r[i + 1] * r[i + 2];
            }

            for (int i = n - 2; i >= 1; i--)
            {
                for (int j = i + 2; j <= n; j++)
                {
                    int min = int.MaxValue;

                    for (int k = i; k <= j - 1; k++)
                    {
                        int cand = dp[i, k] + dp[k + 1, j] + r[i] * r[k + 1] * r[j + 1];
                        min = Math.Min(min, cand);
                    }

                    dp[i, j] = min;
                }
            }

            Console.WriteLine(dp[1, n]);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 18204
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

using namespace std;
int main()
{
	string str;
	getline(cin, str);
	int N = stoi(str);
	
	string s1, s2, s3;
	vector<string> sv;
	int flag = 1;
	for (int i = 0; i < N; i++) {
		getline(cin, str);
		s1 = s3;
		s2 = str.substr(0, 1);
		s3 = str.substr(str.size() - 1, 1);
		if (i != 0 && s1 != s2) {
			flag = 0;
		}
		sv.push_back(str);
	}

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (sv[i] == sv[j]) {
				flag = 0;
				break;
			}
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int n;


int main()
{
    int a , b;
    cin>>a>>b;
    if(a<10 &&  b< 10)
        cout<<a*b;
    else cout<<-1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> a(N);
    rep(i,N)cin >> a[i];
    int res = 0,upper=0;
    for(int i=0;i<N-1;i++){
        if(upper==0){
            if(a[i+1]>a[i])upper=1;
            if(a[i+1]<a[i])upper=-1; 
        }
        else if(upper==-1&&a[i+1]>a[i]){
            upper=0;
            res++;
        }else if(upper==1&&a[i+1]<a[i]){
            upper=0;
            res++;
        }
    }
    cout << res+1 << endl;
    return 0;
}

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

int main() {
    int N;
    cin>>N;
    int *A = new int[N];
    int *B = new int[N];
    int *C = new int[N-1];

    for (int i = 0; i < N; i++){
        cin>>A[i];
    }
    for (int i = 0; i < N; i++){
        cin>>B[i];
    }
    for (int i = 0; i < N-1; i++){
        cin>>C[i];
    }
    int ans=0;
    for (int i = 0; i < N; i++){
        ans+=B[A[i]-1];
    }
    for (int i = 1; i < N; i++){
        if(A[i]-A[i-1]==1)ans+=C[A[i]-2];
        //cout<<C[A[i]-2]<<endl;
    }
    
    
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	long long n;
	cin >> n;
	if (n == 2){
		cout << 1;
		return 0;
	}
	long long ans = 0;
	for (long long i = 2; i * i <= n; ++i){
		if (n % i == 0){
			long long temp = n;
			while (temp % i == 0){
				temp /= i;
			}
			if (temp % i == 1){
				ans++;
			}
			if (n / i == i){
				continue;
			}
			long long x = n / i;
			temp = n;
			while (temp % x == 0){
				temp /= x;
			}
			if (n % x == 1){
				ans++;
			}
		}
	}
	if (--n > 0){
		ans++;
	}
	for (long long i = 2; i * i <= n; ++i){
		if (n % i == 0){
			ans++;
			if (n / i != i){
				ans++;
			}
		}
	}
	cout << ans + 1;
	return 0;
}



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

signed main(){
	int q;
	map<string,int>m;
	cin>>q;
	while(q--){
		int t,y;
		string x;
		cin>>t;
		if(t==0){
			cin>>x>>y;
			m[x]=y;
		}
		if(t==1){
			cin>>x;
			if(m.count(x))cout<<m[x]<<endl;
			else cout<<0<<endl;
		}
		if(t==2){
			cin>>x;
			m.erase(x);
		}
		if(t==3){
			string l,r;
			cin>>l>>r;
			map<string,int>::iterator end,it;
			it=m.lower_bound(l);
			end=m.upper_bound(r);
			for(;it!=end;it++){
				cout<<(*it).first<<' '<<(*it).second<<endl;
			}
		}
	}
}


Measured memory_bytes: 27828
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
#
total_all = []
for i in range(2**n):
    b = [0]*m
    total = 0
    check = 'OK'
    for j in range(n):
        if ((i >> j) & 1):
            total += a[j][0]
            for k in range(1,m+1):
                b[k-1] += a[j][k]
    for l in range(m):
        if b[l] < x:
            check = 'NG'
            break
    if check == 'OK':
        total_all.append(total)
if len(total_all) == 0:
    print(-1)
else:
    print(min(total_all))


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

int main() {
  string S; cin >> S;
  int firstTwo = stoi(S.substr(0, 2)), lastTwo = stoi(S.substr(2, 2));
  int result = 0;
  if (firstTwo >= 1 && firstTwo <= 12) {
    result += 2;
  }
  if (lastTwo >= 1 && lastTwo <= 12) {
    result += 1;
  }
  if (result == 1) {
    cout << "YYMM";
  } else if (result == 2) {
    cout << "MMYY";
  } else if (result == 3) {
    cout << "AMBIGUOUS";
  } else {
    cout << "NA";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[100010];
int main(void){
    int n;
    cin >>n;
    for(int i=0;i<=n;i++){
        cin >>a[i];
        a[i]--;
    }
    int x=0;
    for(int i=0;i<100010;i++){
        if(x==1){
            cout <<i<<endl;
            return 0;
        }
        x=a[x];
    }
    cout <<-1<<endl;
    return 0;
    
}

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

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

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

#define mp make_pair
#define fi first
#define se second

using namespace std;

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

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m;
int f[100005],du[100005];
vector<int> adj[100005];
bool vis[100005];

void dfs1(int u){
	for(auto x:adj[u]){
		if(vis[x]) continue;
		vis[x]=true;
		f[x]=u;
		dfs1(x);
	}
}

void dfs2(int u){
	for(auto x:adj[u]){
		if(f[x]!=u) continue;
		dfs2(x);
		if(du[x]==1) printf("%d %d\n",x,u);
		else printf("%d %d\n",u,x),du[u]^=1;
	}
}

int main(){
	n=readint(); m=readint();
	int x,y;
	for(int i=1;i<=m;i++){
		x=readint(); y=readint();
		adj[y].push_back(x),adj[x].push_back(y);
	}
	if(m%2==1) return printf("-1\n"),0;
	vis[1]=true; dfs1(1);
	for(int i=1;i<=n;i++) for(auto x:adj[i]) if(i<=x&&f[x]!=i&&f[i]!=x) printf("%d %d\n",i,x),du[i]^=1;
	dfs2(1);
	return 0;
}

Measured memory_bytes: 13952
using namespace std;
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <ctime>

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //srand(time(NULL));
    int mx = 0;
    string s;
    cin >> s;
    int cur = 0;
    for (char c : s) {
        if (c == 'R') cur++;
        else cur = 0;
        mx = max(mx, cur);
    }
    cout << mx << endl;


}

Measured memory_bytes: 3636