akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////

int arr[5][5];

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	REP(i,1,3) REP(j,1,3) cin >> arr[i][j];
	int n; cin >> n;
	while(n--) {
		int x; cin >> x;
		REP(i,1,3) REP(j,1,3) if(arr[i][j] == x) arr[i][j] = -1;
	}
	bool flag = false;
	REP(i,1,3) {
		int tot = 0;
		REP(j,1,3) {
			tot += arr[i][j];
		}
		if(tot == -3) flag = true;
	}
	REP(j,1,3) {
		int tot = 0;
		REP(i,1,3) tot += arr[i][j];
		if(tot == -3) flag = true;
	}
	int tot = 0;
	REP(i,1,3) {
		tot += arr[i][i];
		if(tot == -3) flag = true;
	}
	tot = 0;
	REP(i,1,3) {
		tot += arr[i][4-i];
		if(tot == -3) flag = true;
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vec<int> d(n);
    int abc = 0;
    int agc = 0;
    rep(i, n) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    if (n%2 != 0) cout << 0 << endl;
    else {
        cout << d[n/2] - d[n/2-1] << endl; 
    }

}

Measured memory_bytes: 640
#include<stdio.h>
using namespace std;
const int maxn = 100005;

struct node{
	int d;//球的数量 
	bool flag;//false:白球   true：红球 
}box[maxn];
int n, m; 

void solve(int x, int y){
	if(box[x].d>1 && box[x].flag==true){//x可能有红球   y也可能有红球 
		box[x].d--;
		box[y].d++;
		box[y].flag = true;
	}else if(box[x].d==1 && box[x].flag==true){//x无红球    y有红球 
		box[x].d--;
		box[x].flag = false;
		box[y].d++;
		box[y].flag = true;
	}else{ 
		box[x].d--;
		box[y].d++;
	}
	
}

int main(){
//	freopen("inb.txt","r",stdin);
	scanf("%d%d", &n, &m);
	//初始化每个盒子
	for(int i=1;i<=n;i++){
		box[i].d = 1;
		box[i].flag = false;
	} 
	box[1].flag = true;
	int x, y;
	for(int i=1;i<=m;i++){
		scanf("%d%d", &x, &y);
		solve(x,y);
	}	
	
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(box[i].flag)ans++;
	} 
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 896
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10,9) + 7;
ll modw(ll n,long long int k);
int main() {
    ll N, K;
    cin >> N >> K;
    cout << modw(N, K) << endl;
   
   

}
ll modw(ll n, ll k) {
    ll ans = 0;
    while (k <= (n+1)) {
        ll dif = (n - k + 1) * k;
        ans += (dif+1);
        k++;
        ans %= mod;
        if (ans < 0)ans += mod;
    }
    return ans;
}











































































































































Measured memory_bytes: 3632
n = int(input())
res = []
d = dict()
for _ in range(n):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] +=1
mm = -1
for k,v in d.items():
    if v > mm:
        mm = v

for k,v in d.items():
    if v == mm:
        res.append(k)

res.sort()
for i in range(len(res)):
    print(res[i]) 

Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    int x3 = x2 - dy, y3 = y2 + dx;
    int x4 = x3 - dx, y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <utility>
#include <map>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

map<string,int> mapa;

int main () {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mapa[s]=1;
	}
	cout<<mapa.size();
	



return 0;
}



Measured memory_bytes: 19120
#include<stdio.h>

main(void){
  
  int s[100000],n,t[50000],q,i,count=0,j,temp;
  int left,mid,right,value;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  
 
    
  
  for(i=0;i<q;i++){
    right=n;
    left=0;
    value=t[i];
   
    while(left<=right){
      mid=(left+right)/2;

      if(s[mid]==value){
	count=count+1;
	break;
      }

      else if(s[mid]<value)left=mid+1;

      else right=mid-1;

    }
  }
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>

    using namespace std;

   
    int main() {
       long long  a, b, c; cin >> a >> b >> c;
 
       long long  x = a / (b+c);
        cout << (x*b) + min(b,(a % (b + c)));
		return 0;
	}
    

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

namespace CSharpSample01
{

    class Program
    {
        


        static void Magic(int n)
        {           
            int[,] point = new int[n, n];  //n×nマス
            int count = 1;
            int i = n / 2 + 1;
            int j = n / 2;          
    
            point[i, j] = count;           
            count++;            

            while (true)
            {

                i += 1;
                j += 1;

                while (true)
                {
                    //右領域外
                    if(j >= n)
                    {
                        j = 0;
                    }

                    //下領域外
                    if(i >= n)
                    {
                        i = 0;
                    }

                    

                    //すでに埋まっている
                    if(point[i, j] != 0)
                    {
                        i += 1;
                        j -= 1;
                    }

                    //左領域外
                    if(j < 0)
                    {
                        j = n - 1;
                    }
                    
                    //何もないので埋める
                    if(0 <= j && j < n && 0 <= i && i < n && point[i, j] == 0)
                    {
                        point[i, j] = count;
                        count++;
                        break;
                    }

                }

                if(count == n * n + 1)
                {
                    break;
                }

            }

            Print(point, n);
        }

        


        static void Print(int[,] data, int n)
        {
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    Console.Write("{0, 4}", data[i, j]);
                }
                Console.WriteLine();
            }
            
        }
                   
        static void Main(string[] args)
        {

            var data = new List<int>();

            while (true)
            {
                string str = Console.ReadLine();

                if (int.Parse(str) == 0)
                {
                    break;
                }

                data.Add(int.Parse(str));

            }
           
            foreach(var s in data)
            {
                Magic(s);
            }

        }
    }
}



Measured memory_bytes: 15904
n=int(input())
c=input()

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

last_c='R'*r_cnt+'W'*w_cnt

num=0
for i in range(n):
  if c[i]!=last_c[i]:
    num+=1

print((num+2-1)//2)

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

int main() {
    int N; cin >> N;
    int A[N + 1] = {};
    for (int i = 0;i < N;i++) cin >> A[i];
    int B[N] = {};
    int M = 0;
    for (int i = N - 1;i >= 0;i--){
        int n = i + 1;
        int d = 0;
        for (int j = 2;n * j <= N;j++){
            d += B[(n * j) - 1];
        }
        if (d % 2 == A[i]) B[i] = 0;
        else B[i] = 1;
        if (B[i] == 1) M++;
    }
    cout << M << endl;
    for (int i = 0;i < N;i++){
        if (B[i] == 1) cout << i + 1 << endl;
    }
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
using namespace std;
#define INF 100000000000000000LL
#define MAX_N 500000
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>Q;
vector<pair<long long, long long>>X[MAX_N]; long long WHITE = 0, GRAY = 1, BLACK = 2;
long long COLOR[MAX_N], DIST[MAX_N], POINT[MAX_N], N, M, A, B, C;
long long classcal() {
	for (int i = 0; i < MAX_N; i++) { POINT[i] = INF; DIST[i] = INF; COLOR[i] = WHITE; }
	DIST[0] = 0; COLOR[0] = GRAY; Q.push(make_pair(0, 0));
	while (!Q.empty()) {
		pair<long long, long long>pa = Q.top(); Q.pop();
		long long a1 = pa.first, a2 = pa.second;
		COLOR[a2] = BLACK;
		for (int i = 0; i < X[a2].size(); i++) {
			long long to = X[a2][i].first, dist = X[a2][i].second;
			if (DIST[to] > dist && COLOR[to] < BLACK) {
				for (int j = 0; j < X[to].size(); j++) {
					if (X[to][j].first == a2) { POINT[to] = j; }
				}
				DIST[to] = dist; Q.push(make_pair(DIST[to], to));
			}
		}
	}
	long long sum = 0;
	for (int i = 0; i < N; i++) { if (POINT[i] < INF) { sum += X[i][POINT[i]].second; } }
	return sum;
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) { cin >> A >> B >> C; X[A].push_back(make_pair(B, C)); X[B].push_back(make_pair(A, C)); }
	cout << classcal() << endl;
	return 0;
}

Measured memory_bytes: 32056
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def map_int():
        return [int(x) for x in Scanner.string().split()]
    def string_list(n):
        return [input() for i in range(n)]
    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]
    def int_cols_list(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N,M = Scanner.map_int()
    if not abs(N - M) <= 1:
        print(0)
        return
    
    n ,m = 1,1
    for i in range(2,N + 1):
        n *= i
        n%=MOD
    for i in range(2,M + 1):
        m *= i
        m %= MOD
    ans = 0
    if N == M:
        ans = (n * m) % MOD * 2 % MOD
    else:
        ans = n * m % MOD
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
using lint = long long;
using pi = pair<int, int>;
const int mod = 1e9 + 7;

struct disj{
	int pa[MAXN];
	void init(int n){
		iota(pa, pa + n + 1, 0);
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q){
		p = find(p);
		q = find(q);
		if(p == q) return 0;
		pa[q] = p; return 1;
	}
}disj;

struct pnt{
	int x, y, idx;
}a[MAXN];

struct edg{
	int s, e, x;
};

int n;

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d %d",&a[i].x,&a[i].y);
		a[i].idx = i;
	}
	vector<edg> v;
	sort(a, a + n, [&](const pnt &a, const pnt &b){
		return pi(a.x, a.y) < pi(b.x, b.y);
	});
	for(int i=1; i<n; i++) v.push_back({a[i-1].idx, a[i].idx, a[i].x - a[i-1].x});
	for(int i=0; i<n; i++) swap(a[i].x, a[i].y);
	sort(a, a + n, [&](const pnt &a, const pnt &b){
		return pi(a.x, a.y) < pi(b.x, b.y);
	});
	for(int i=1; i<n; i++) v.push_back({a[i-1].idx, a[i].idx, a[i].x - a[i-1].x});
	sort(v.begin(), v.end(), [&](const edg &a, const edg &b){
		return a.x < b.x;
	});
	lint ret = 0;
	disj.init(n);
	for(auto &i : v){
		if(disj.uni(i.s, i.e)) ret += i.x;
	}
	cout << ret << endl;
}


Measured memory_bytes: 6132
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        dis = 0
        for k in range(d):
            dis += (x[i][k]-x[j][k])**2
        if math.sqrt(dis) % 1 == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n;
int a[N],b[N];
int s[N];
long long tmp;
int c[N];
void gb(int l,int r)
{
	if(l==r)return;
	int mid=(l+r)/2,h1=l,h2=mid+1,cnt=l;
	gb(l,mid);
	gb(mid+1,r);
	while(h1<=mid&&h2<=r)
	{
		if(s[h1]<=s[h2]) c[cnt++]=s[h1++];
		else c[cnt++]=s[h2++],tmp+=(mid-h1+1);
	}
	for(int i=h1;i<=mid;++i)c[cnt++]=s[i];
	for(int i=h2;i<=r;++i)c[cnt++]=s[i];
	for(int i=l;i<=r;++i) s[i]=c[i];
	//cout<<l<<" "<<r<<" "<<tmp<<endl;
}
bool check(int x)
{
	memset(s,0,sizeof(s));
	for(int i=1;i<=n;++i)
		if(a[i]<x) s[i]=s[i-1]-1;
		else s[i]=s[i-1]+1;
	//for(int i=0;i<=n;++i)
	//cout<<s[i];
	//	cout<<endl;
	tmp=0;gb(0,n);
	//for(int i=0;i<=n;++i)cout<<s[i];
	//cout<<x<<" "<<tmp<<endl;
	if(tmp<=1ll*n*(n+1)/4) return 1;
	else return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int l=1,r=n+1;
	while(l<r-1)
	{
		int mid=(l+r)/2;
		//cout<<b[mid]<<" "<<endl;
		if(check(b[mid]))l=mid;
		else r=mid;
	}
	printf("%d",b[l]);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>

using namespace std;

int t[200];

int main(){
	int n,m,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&t[i]);
		sum+=t[i];
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		cout<<sum-t[x]+y<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return (this - 1) >> 1; };
    Number.prototype.leftIdx = function() { return this * 2 + 1; };
    Number.prototype.rightIdx = function() { return this * 2 + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const keys = this.keys;
    const res = keys[0];
    keys[0] = keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys;
    const n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && Number(keys[left]) > Number(keys[largest])) largest = left;
      if (right < n && Number(keys[right]) > Number(keys[largest])) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.pop();
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()|0}\n`; break;
    }
  });
  process.stdout.write(str);
})();




Measured memory_bytes: 203956
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int w,h,sum,dx[]={0,1,0,-1},dy[]={-1,0,1,0};
string s[11],t;
map<int,char>m;
void dfs(int y,int x,int d,char p){
  if(d==sum){
    cout<<t<<endl;
    exit(0);
  }
  else{
    char a=p;
    s[y][x]='.';
    r(i,4){
      int yy=y,xx=x;
      if(a=='U'&&i==2||a=='D'&&i==0||a=='R'&&i==3||a=='L'&&i==1)continue;
      r(j,50){
        yy+=dy[i],xx+=dx[i];
        if(yy>=h||xx>=w||xx<0||yy<0)break;
        if(s[yy][xx]=='o'){
          t+=m[i];
          dfs(yy,xx,d+1,m[i]);
          t.erase(t.end()-1);
          break;
        }
      }
    }
    s[y][x]='o';
  }
}
int main(){
  m[0]='U';m[1]='R';m[2]='D';m[3]='L';
  cin>>h>>w;
  r(i,h)cin>>s[i];
  r(i,h)r(j,w)if(s[i][j]=='o')sum++;
  r(i,h)r(j,w)if(s[i][j]!='.'&&s[i][j]!='o')dfs(i,j,0,s[i][j]);
}

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


int main(){
    ll N,M; cin >> N >> M;
    vector<pair<ll,ll>> Ene(N);
    for (int i = 0; i < N; i++)
    {
        cin >> Ene[i].first >> Ene[i].second;
    }
    sort(Ene.begin(),Ene.end());

    ll now,ans;
    now = ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(now + Ene[i].second < M){
            ans += Ene[i].first*Ene[i].second;
            now += Ene[i].second;
        }else{
            ans += Ene[i].first * (M-now);
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,x; cin >> n >> x;
    int a[n];
    rep(i,n) cin >> a[i];
    int h = 0,ans = 1;
    rep(i,n){
        h += a[i];
        if(h <= x) ans++;
    }
    ANS;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int a,b;
  string s;
  cin >> a >> b;
  cout << (a+b)%24 << endl;

   return 0;
}



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

int main(void)
{
  while (true)
  {
    double x, h;
    cin >> x >> h;
    if (x == 0 and h == 0) break;
    double t_h = hypot(x/2, h);
    double result = x * t_h * 2 + pow(x, 2);
    printf("%.6lf\n", result);
  }
  return 0;
}

Measured memory_bytes: 1248
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 300005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

void makeTree( int pos );
void treeAdd( int pos, int sum );

vector< int > tree[SIZE], graph[SIZE];
int total[SIZE];
int res;
bool visit[SIZE];

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

    int n, q;
    cin >> n >> q;
    for( int i = 0; i < n - 1; ++i ) {
        int a, b;
        cin >> a >> b;
        graph[a].pb( b );
        graph[b].pb( a );

    }
    
    makeTree( 1 );

    for( int i = 0; i < q; ++i ) {
        int p, x;
        cin >> p >> x;
        total[p] += x;

    }

    treeAdd( 1, 0 );
    cout << total[1];
    for( int i = 2; i <= n; ++i ) {
        cout << " " << total[i];

    }
    cout << endl;
    return 0;
}

void makeTree( int pos ) {
    visit[pos] = true;
    for( int i = 0; i < graph[pos].size(); ++i ) {
        if( visit[graph[pos][i]] ) continue;
        tree[pos].pb( graph[pos][i] );
        makeTree( graph[pos][i] );

    }
    return;

}

void treeAdd( int pos, int sum ) {
    sum += total[pos];
    total[pos] = sum;
    res += sum;
    for( int i = 0; i < tree[pos].size(); ++i ) {
        treeAdd( tree[pos][i], sum );

    }
    return;

}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 100005
#define INF 1061109567
#define rep(i,n) for((i)=0;(i)<(n);(i)++)

int n,m;
int s,t;
vector<int> e[N];
int d[N][3];
priority_queue<pii,vector<pii>,greater<pii> > q;

int main()
{
	
	int i;
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		u--; v--;
		e[u].pb(v);
	}
	scanf("%d%d",&s,&t);
	s--; t--;
	
	memset(d,63,sizeof(d));
	q.push(mp(0,s));
	while(!q.empty())
	{
		int v=q.top().second;
		int dist=q.top().first; 
		q.pop();
		if(dist>d[v][dist%3]) continue;
		rep(i,e[v].size())
		{
			int to=e[v][i];
			int &Di=d[to][(dist+1)%3];
			if(Di<=dist+1) continue;
			Di=dist+1;
			q.push(mp(Di,to));
		}
	}
	printf("%d\n",(d[t][0]!=INF)?(d[t][0]+2)/3:-1);
		
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int times = 0;
  while (1) {
    bool candiv = true;
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0) {
        a[i] = a[i] / 2;
      } else {
        candiv = false;
      }
    }
    if (candiv) {
      times++;
    } else {
      break;
    }
  }

  cout << times << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
template<class T,class U>void cinpb(T &v, U n) { rep(i, n){cill(a);v.pb(a);} }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    cis(s);
    string ans = n % 2 == 0
            ?s.substr(0, n/2) == s.substr(n/2, n/2)
                ?"Yes"
                :"No"
            :"No";
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <fstream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstring>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <bitset>
#define MOD 8192
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define NMAX 105

using namespace std;

typedef pair<int, int> pii;

bool v[NMAX][NMAX];

int main() {
	int w,h,n,x,y,t,i,j,total=0;

	cin>>w>>h>>n;
	swap(w,h);

	while(n--) {
		cin>>x>>y>>t;

		if(t==1) {
			for(i=1;i<=x;++i)
				for(j=1;j<=w;++j) v[i][j]=1;
		}
		else if(t==2) {
			for(i=x+1;i<=h;++i)
				for(j=1;j<=w;++j) v[i][j]=1;
		}
		else if(t==3) {
			for(i=1;i<=h;++i)
				for(j=1;j<=y;++j) v[i][j]=1;
		}
		else {
			for(i=1;i<=h;++i)
				for(j=y+1;j<=w;++j) v[i][j]=1;
		}
	}

	for(i=1;i<=h;++i)
		for(j=1;j<=w;++j) if(v[i][j]==0) ++total;

	cout<<total;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

const int MN = 1005, MM = 200005;

int N, M, eu[MM], ev[MM], Ans[MM];
std::vector<int> G[MN];
bool vis[MN], rch[MN][MN]; int col[MN];
void DFS(int u, int c) {
	vis[u] = 1, col[u] ^= c;
	for (auto i : G[u]) if (!vis[ev[i]]) DFS(ev[i], c);
}

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; ++i) {
		scanf("%d%d", &eu[i], &ev[i]);
		G[eu[i]].push_back(i);
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) vis[j] = 0;
		DFS(i, 0);
		for (int j = 1; j <= N; ++j) if (vis[j]) rch[i][j] = 1;
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) col[j] = vis[j] = 0; vis[i] = 1;
		for (auto j : G[i]) if (!vis[ev[j]]) DFS(ev[j], ev[j]);
		std::reverse(G[i].begin(), G[i].end());
		for (int j = 1; j <= N; ++j) vis[j] = 0; vis[i] = 1;
		for (auto j : G[i]) if (!vis[ev[j]]) DFS(ev[j], ev[j]);
		for (auto j : G[i]) Ans[j] = rch[ev[j]][i] ^ !!col[ev[j]];
	}
	for (int i = 1; i <= M; ++i) puts(Ans[i] ? "diff" : "same");
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int n,a[1000005],p,vis[5];
char s[1000005];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	scanf("%s",s+1);
	for(int i=1;i<n;i++){
		a[i]=abs(s[i]-s[i+1]);
		vis[a[i]]=1;
	}
	if(!vis[1]){
		for(int i=1;i<n;i++)
		a[i]/=2;
	}
	else{
		for(int i=1;i<n;i++)
		a[i]%=2;
	}
	int nn=n-2;
	for(int i=0;i<n-1;i++){
		if((nn&i)==i)
		p+=a[i+1];
	}
	int ans=p%2;
	if(!vis[1]){
		if(ans)
		ans=2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5120
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():
    n, k = get_li()
    A = get_li()
    ds = make_divisors(sum(A))
    ans = 1
    for d in ds[1:]:
        pdiff = [0] * n
        ndiff = [0] * n
        for i, a in enumerate(A):
            pdiff[i] = a % d
            ndiff[i] = a % d - d
        hoge = list(sorted(zip(pdiff, ndiff)))
        ps = [0] + [h[0] for h in hoge]
        ns = [h[1] for h in hoge] + [0]
        pacc = list(its.accumulate(ps))
        nacc = list(reversed(list(its.accumulate(reversed(ns)))))
        for p_, n_ in zip(pacc, nacc):
            if p_ + n_ == 0 and p_ <= k:
                ans = d
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 71944
// arock - 2019-08-18

#include <functional>
#include <iostream>
#include <vector>

struct graph : public std::vector<std::vector<int>> {
	graph(int n) : std::vector<std::vector<int>>(n) {}
	void add_edge(int u, int v) {
		(*this)[u].push_back(v);
		(*this)[v].push_back(u);
	}
};

struct tree : public graph {
	tree(int n) : graph(n) {}
};

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

	int N, Q;
	std::cin >> N >> Q;

	tree T(N);
	for (int i = 0; i + 1 < N; i++) {
		int a, b;
		std::cin >> a >> b;
		T.add_edge(a - 1, b - 1);
	}

	std::vector<int> inc(N);
	while (Q --> 0) {
		int p, x;
		std::cin >> p >> x;
		inc[p - 1] += x;
	}

	std::vector<int> ans(N);
	std::function<void(int, int, int)> dfs = [&](int cur, int prv, int sum) {
		sum += inc[cur];
		ans[cur] = sum;
		for (int nxt : T[cur]) if (nxt != prv) {
			dfs(nxt, cur, sum);
		}
	};
	dfs(0, -1, 0);

	for (int a : ans) {
		std::cout << a << ' ';
	}
	std::cout << '\n';
}


Measured memory_bytes: 30592
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 102 B "Maximum Difference"
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int[] A = in.nextIntArray(N);

		int ans = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				int diff = Math.abs(A[i] - A[j]);
				ans = Math.max(ans, diff);
			}
		}

		out.println(ans);

		in.close();
		out.close();

	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner{

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

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

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

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String splitStr) {
			String[] ret = scanner.next().split(splitStr);
			return ret;
		}

		public void close() {
			scanner.close();
		}
	}

}


Measured memory_bytes: 23892
R,C=map(int,input().split())
mp = [[i for i in input().rstrip()] for i in range(R)]
for i in range(R):
  mp[i]=list(mp[i])
ans=[[3000 for i in range(C)] for j in range(R)]
ans[0][0]=0
start=[0,0]
goal=[R-1,C-1]
nsx=[1,0,-1,0]
nsy=[0,1,0,-1]

def bfs(graph,st,end):
  queue=[st]
  while queue:
    nw=queue.pop(0)
    if nw==end:
      return ans[end[0]][end[1]]
    else:
      for i in range(4):
        ns1=nw[0]+nsx[i]
        ns2=nw[1]+nsy[i]
        if (0 <= ns1)and(ns1<=(R-1))and(0<=ns2)and(ns2<=(C-1)) and ans[ns1][ns2]==3000 and mp[ns1][ns2]==".":
          ans[ns1][ns2]=ans[nw[0]][nw[1]]+1
          queue.append([ns1,ns2])
  return 

bfs(mp,start,goal)
if ans[R-1][C-1]==3000:
  print("-1")
else:
  max_ans=R*C-ans[R-1][C-1]-1
  for i in range(R):
    for j in range(C):
      if mp[i][j]=='#':
        max_ans-=1
  print(max_ans)


Measured memory_bytes: 3188
N=int(input())
s=input()
assum=["SS","SW","WS","WW"]
for item in assum:
  t=item
  for i in range(1,N-1):
    if ((s[i]=="o") and (t[i]=="S")) or ((s[i]=="x") and (t[i]=="W")):
      t+=t[i-1]
    else:
      if t[i-1]=="S":
        t+="W"
      else:
        t+="S"
  if (t[N-2]==t[0] and ((s[N-1]=="o" and t[N-1]=="S") or (s[N-1]=="x" and t[N-1]=="W"))) or (t[N-2]!=t[0] and ((s[N-1]=="o" and t[N-1]=="W") or (s[N-1]=="x" and t[N-1]=="S"))):
    if (t[N-1]==t[1] and ((s[0]=="o" and t[0]=="S") or (s[0]=="x" and t[0]=="W"))) or (t[N-1]!=t[1] and ((s[0]=="o" and t[0]=="W") or (s[0]=="x" and t[0]=="S"))):
      print(t)
      break
else:
  print(-1)

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

int main(void){
  int x, y;
  int i,j;
  scanf("%d %d", &x, &y);
  
  for(i=0;i<=100;i++){
    for(j=0;j<=100;j++){
      if(i+j==x && 2*i+4*j==y){
        printf("Yes");
        goto flag;
      }
    }
  }
  
  printf("No");
  flag:
  
  return 0;
}




Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) (a).begin(), (a).end()
#define pw(x) (1ll<<(x))
#define lb(x) ((x) & -(x))
#define endl "\n"
#define FI(x) freopen(#x".in","r",stdin)
#define FO(x) freopen(#x".out","w",stdout)
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
//typedef uniform_int_distribution<ll> RR;
const int P = 1e9 + 7;
//ll rnd(ll l, ll r) { mt19937 gen(rand()); RR dis(l, r); return dis(gen); }
int add(int a, int b) {if((a += b) >= P) a -= P; return a < 0 ? a + P : a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 1e5 + 7;
ll n, m, A, B, a[N], s[N], f[N];
int r, l[N];
int main(){
	//FI(a);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	cin >> n >> A >> B; 
	if (A < B) swap(A, B);
	rep(i, 1, n+1) cin >> a[i];
	a[n+1] = a[n] + A; a[0] = a[1] - A;
	n++;
	rep(i, 1, n+1) {
		if (a[i] >= a[i-1] + B) l[i] = l[i-1];
		else if (a[i] >= a[i-2] + B) l[i] = i - 1;
		else l[i] = i;
	}
	r = 0;f[0] = s[0] = 1;
	rep(i, 1, n+1) {
		while (r + 1 < i && a[r + 1] + A <= a[i]) r++;
		if (r >= l[i-1]) {
			if (l[i-1] > 0) f[i] = ((s[r] - s[l[i-1] - 1]) % P + P) % P;
			else f[i] = s[r];
			
		}
		s[i] = (s[i-1] + f[i]) % P;
	}
	cout << f[n] << endl;
	return 0; 
}



Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100007;
typedef long long ll;
struct node {
    int v,w;
    node(int x=0,int y=0) {
        v=x,w=y;
    }
};
int deg[MAXN],X,n,m,x1,x2,y,tot[MAXN];
ll pos[MAXN];
bool vis[MAXN];
char c;
vector<node> edge[MAXN];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p2==p1&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
int read() {
    X=0,c=nc();
    while(!isdigit(c))c=nc();
    while(isdigit(c))X=(X<<1)+(X<<3)+c-'0',c=nc();
    return X;
}
bool ok;
bool check(int &u) {
    vis[u]=true;
    for(int i=0; i<tot[u]; i++) {
        if(vis[edge[u][i].v]) {
            if(pos[edge[u][i].v]-edge[u][i].w!=pos[u])return false;
        } else {
            pos[edge[u][i].v]=pos[u]+edge[u][i].w;
            if(!check(edge[u][i].v))return false;
            else continue;
        }
    }
    return true;
}
int main() {
        n=read(),m=read();
        if(!m){
            puts("Yes");
            return 0;
        }
        for(int i=0; i<m; i++) {
            x1=read(),x2=read(),y=read();
            tot[x1]++;
            deg[x2]++;
            edge[x1].push_back(node(x2,y));
        }
        for(int i=0; i<n; i++)if(!deg[i]&&tot[i]) {
                ok=1;
                if(!check(i)) {
                    puts("No");
                    return 0;
                }
            };
        if(!ok) {
            puts("No");
            return 0;
        }
        puts("Yes");
        return 0;
}

Measured memory_bytes: 10624
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long int;

int main() {
    string s; cin >> s;
    ll K; cin >> K;

    int ans = 1;
    for(ll i=0; i<min(K,(ll)s.length()); i++) {
        if(s[i] != '1') {
            ans = s[i] - '0';
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    vector<ll> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    ll ans = 0;
    ll last = A[0];
    int ud = 0;
    for(int i = 1; i < N; i++){
        ll a = A[i];
        if(a > last){
            if(ud == -1){
                ans++;
                ud = 0;
            }
            else if(ud == 0){
                ud = 1;
            }
        }
        else if(a < last){
            if(ud == 1){
                ans++;
                ud = 0;
            }
            else if(ud == 0){
                ud = -1;
            }
        }
        last = a;
    }
    ans++;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{

        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        this.MatiCount = inpt[0];
        this.RoadCount = inpt[1];
        this.MustCount = inpt[2];
        MustList = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.Saitan = new Nullable<int>[MatiCount + 1, MatiCount + 1];
        for (int i = 0; i < RoadCount; i++) {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            Saitan[inpt[0], inpt[1]] = inpt[2];
            Saitan[inpt[1], inpt[0]] = inpt[2];
		}
        SetSaitan();
		int ans = int.MaxValue;
        for (int i = 0; i < MustList.Length; i++) {
            int key = 1 << i;
            ans = Math.Min(ans, GetAns(MustList[i], key, MustCount - 1));
        }
        Console.WriteLine(ans);
	}

    int[] MustList;

    Nullable<int>[,] Saitan;

    private Dictionary<int, Dictionary<int, int>> dic = new Dictionary<int, Dictionary<int, int>>();
    private int GetAns(int pos, int flag, int remain) {
        if(remain<=0) {
            return 0;
        }
        if(!dic.ContainsKey(pos)) {
            dic.Add(pos, new Dictionary<int, int>());
        }
        if(dic[pos].ContainsKey(flag)) {
            return dic[pos][flag];
        }

        int ans = int.MaxValue;
        for (int i = 0; i < this.MustCount; i++) {
            int next = MustList[i];
            int key = 1 << i;
            if((flag&key)>0) {
                continue;
            }
            ans = Math.Min(ans,GetAns(next, flag + key, remain - 1) + Saitan[pos, next].Value);
        }
        dic[pos][flag] = ans;
        return ans;
    }

    private void SetSaitan() {
        for (int i = 1; i <= MatiCount; i++) {
            for (int j = 1; j <= MatiCount; j++) {
                for (int k = 1; k <= MatiCount; k++) {
                    if(Saitan[j, i] == null || Saitan[i,k] == null) {
                        continue;
                    }
                    if(Saitan[j,k] == null || Saitan[j,k]>Saitan[j,i].Value +Saitan[i,k]) {
                        Saitan[j, k] = Saitan[j, i] + Saitan[i, k];
                    }
                }
            }
        }
    }


    private int MatiCount;
    private int RoadCount;
    private int MustCount;


	public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"
 
 
4 6 3
2 3 4
1 2 4
2 3 3
4 3 1
1 4 1
4 2 2
3 1 6
 
";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 17752
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

typedef long long int ll;
const int maxn = 1e5+7;
const ll mod = 1e9+7;

bool compare(const pair<ll,ll>& x, const pair<ll,ll>& y) {
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
}

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

ll gcd(ll a,ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}

double dp[3000][3000];
double p[3000];

int main() {
    dp[0][0] = 1.0;
    int n;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> p[i];
    }
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=n;j++) {
            dp[i][j] =  dp[i-1][j]*(1-p[i-1]);
            if(j-1 >= 0) {
                dp[i][j] += dp[i-1][j-1]*p[i-1];
            }
        }
    }
    double ans = 0.0;
    for(int i=n/2+1;i<=n;i++) {
        ans += dp[n][i];
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 70528
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	if (N >= 3200)
	{
		cout << S << endl;
	}
	else
	{
		cout << "red" << endl;
	}
	return 0;
}


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

int large = 100000000;

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <cmath>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
//#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define bs(yup,x) binary_search(yup.begin(),yup.end(),x) //it will return bollean value
#define lb(yup,x) lower_bound(yup.begin(),yup.end(),x)  //it will return the adress of the number which is equal to or just greater than x ,and if it is equal to yup.end() than their in no such number exist
#define ub(yup,x) upper_bound(yup.begin(),yup.end(),x)
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long N=100001, INF=2000000000000000000;
const long double EPS= 0.000000000001;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            isprime[j]=false;
            prime.pb(i);
        }
    }
    return;
}


 
int32_t main()
{
    
    IOS;
    //fill(isprime, true);
    //pre();
   int n;
   cin>>n;
   int a[n];
   int x,y;
   for(int i=0;i<n;i++)
   {
       cin>>x>>y;
       if(x==y) a[i]=1;
       else a[i]=0;
   }
   int count=0;
   int po=0;
   for(int i=0;i<n;i++)
   {
       if(a[i]==1)
       {
           count++;
       }
       else
       {
           if(count>=3)
           {
               po=1;
           }
           count=0;
       }
   }
   if(count>=3)
    {
        po=1;
    }
    if(po)
    {
        cout<<"Yes";
    }
    else cout<<"No";
 
}


Measured memory_bytes: 3608