akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Run(Console.In);
        }

        private static void Run(TextReader textReader)
        {
            // Sunny, Cloudy, Rainy
            var item = textReader.ReadLine();

            switch (item)
            {
                case "Sunny":
                    Console.Out.WriteLine("Cloudy");
                    return;
                case "Cloudy":
                    Console.Out.WriteLine("Rainy");
                    return;
                case "Rainy":
                    Console.Out.WriteLine("Sunny");
                    return;
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<stack>
#include<map>
#include<queue>
#include <climits>
#include <math.h>
#include <unordered_map>
#include <set>
#include <functional>   // std::greater

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
       cout << "ARC";
    else
        cout << "ABC";
	return 0;
}

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

template< class T >
struct Dinic {
  static const int MAXV = 10000;
  static const T INF = 0x3f3f3f3f;
  struct Edge {
    int v;
    T f;
    int re;
    Edge( int _v, T _f, int _re ): v( _v ), f( _f ), re( _re ) {}
  };
  int n, s, t, level[ MAXV ];
  vector< Edge > E[ MAXV ];
  int now[ MAXV ];
  Dinic( int _n, int _s, int _t ): n( _n ), s( _s ), t( _t ) {}
  void add_edge( int u, int v, T f, bool bidirectional = false ) {
    E[ u ].emplace_back( v, f, E[ v ].size() );
    E[ v ].emplace_back( u, 0, E[ u ].size() - 1 );
    if( bidirectional ) {
      E[ v ].emplace_back( u, f, E[ u ].size() - 1 );
    }
  }
  bool BFS() {
    memset( level, -1, sizeof( level ) );
    queue< int > que;
    que.emplace( s );
    level[ s ] = 0;
    while( not que.empty() ) {
      int u = que.front();
      que.pop();
      for( auto it: E[ u ] ) {
        if( it.f > 0 and level[ it.v ] == -1 ) {
          level[ it.v ] = level[ u ] + 1;
          que.emplace( it.v );
        }
      }
    }
    return level[ t ] != -1;
  }
  T DFS( int u, T nf ) {
    if( u == t ) return nf;
    T res = 0;
    while( now[ u ] < E[ u ].size() ) {
      Edge &it = E[ u ][ now[ u ] ];
      if( it.f > 0 and level[ it.v ] == level[ u ] + 1 ) {
        T tf = DFS( it.v, min( nf, it.f ) );
        res += tf; nf -= tf; it.f -= tf;
        E[ it.v ][ it.re ].f += tf;
        if( nf == 0 ) return res;
      } else ++now[ u ];
    }
    if( not res ) level[ u ] = -1;
    return res;
  }
  T flow( T res = 0 ) {
    while( BFS() ) {
      T temp;
      memset( now, 0, sizeof( now ) );
      while( temp = DFS( s, INF ) ) {
        res += temp;
        res = min( res, INF );
      }
    }
    return res;
  }
};

const int MAXH = 100;
const int MAXW = 100;

int H, W;
string G[ MAXH ];

signed main() {
  ios::sync_with_stdio( 0 );
  cin >> H >> W;
  for( int i = 0; i < H; ++i ) {
    cin >> G[ i ];
  }
  int SOURCE = H + W;
  int SINK = H + W + 1;
  Dinic< int > din( H + W + 2, SOURCE, SINK );
  for( int i = 0; i < H; ++i ) {
    for( int j = 0; j < W; ++j ) {
      if( G[ i ][ j ] == 'S' ) {
        din.add_edge( SOURCE, i, din.INF );
        din.add_edge( SOURCE, H + j, din.INF );
      } else if( G[ i ][ j ] == 'T' ) {
        din.add_edge( i, SINK, din.INF );
        din.add_edge( H + j, SINK, din.INF );
      } else if( G[ i ][ j ] == 'o' ) {
        din.add_edge( i, H + j, 1, true );
      }
    }
  }
  int ans = din.flow();
  if( ans >= din.INF ) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

struct mcxi_t {
  uint32_t m = 0;
  uint32_t c = 0;
  uint32_t x = 0;
  uint32_t i = 0;

  mcxi_t(string str) {
    uint32_t val = 1;
    for (uint32_t j = 0; j < str.size(); j++) {
      switch (str[j]) {
      case 'm':
        m = val;
        val = 1;
        break;
      case 'c':
        c = val;
        val = 1;
        break;
      case 'x':
        x = val;
        val = 1;
        break;
      case 'i':
        i = val;
        val = 1;
        break;
      default:
        val = str[j] - '0';
        break;
      }
    }
  }

  const mcxi_t operator+(const mcxi_t &mcxi) {
    mcxi_t added("");
    added.i = i + mcxi.i;
    added.x = x + mcxi.x;
    added.c = c + mcxi.c;
    added.m = m + mcxi.m;
    if (added.i >= 10) {
      added.i %= 10;
      added.x++;
    }
    if (added.x >= 10) {
      added.x %= 10;
      added.c++;
    }
    if (added.c >= 10) {
      added.c %= 10;
      added.m++;
    }
    return added;
  }

  void print_digit(int32_t val, char disp) {
    if (val == 1) {
      cout << disp;
    } else if (val >= 2) {
      cout << val << disp;
    }
  }

  void println() {
    print_digit(m, 'm');
    print_digit(c, 'c');
    print_digit(x, 'x');
    print_digit(i, 'i');
    cout << endl;
  }
};

int32_t main() {
  uint32_t n;
  cin >> n;
  for (uint32_t i = 0; i < n; i++) {
    string str1, str2;
    cin >> str1 >> str2;
    mcxi_t mcxi = mcxi_t(str1) + mcxi_t(str2);
    mcxi.println();
  }

  return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


int dp[3001][3001] = {};
int dir[3001][3001] = {};

int main() {
    nfs
    
    string s, t;
    stack<char> out;

    cin >> s >> t;

    for (int i = 1; i <= s.length(); i++) {
        for (int j = 1; j <= t.length(); j++) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                dir[i][j] = 0;
            }
            else if (dp[i-1][j] > dp[i][j-1]){
                dp[i][j] = dp[i-1][j];
                dir[i][j] = 1;
            }
            else {
                dp[i][j] = dp[i][j-1];
                dir[i][j] = 2;
            }
        }
    }

    int i = s.length(), j = t.length();
    while (i && j) {
        switch (dir[i][j]) {
            case 0:
                out.push(s[i-1]);
                i--;
                j--;
                break;
            
            case 1:
                i--;
                break;
            
            case 2:
                j--;
                break;
        }
    }

    while (!out.empty()) {
        cout << out.top();
        out.pop();
    }
}

Measured memory_bytes: 73900
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
ll dp[200005][5];
int a[200005];
int n;

inline int s0(int x)
{
	return x;
}

inline int s1(int x)
{
	if(x==0) return 2;
	return (x&1?1:0);
}

inline int s2(int x)
{
	return (x&1?0:1);
}

inline int s3(int x)
{
	if(x==0) return 2;
	return (x&1?1:0);
}

inline int s4(int x)
{
	return x;
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	dp[0][0]=s0(a[0]);
	dp[0][1]=s1(a[0]);
	dp[0][2]=s2(a[0]);
	dp[0][3]=s3(a[0]);
	dp[0][4]=s4(a[0]);
	for(int i=1;i<n;i++)
	{
		ll temp=1LL*inf*inf;
		temp=min(temp,dp[i-1][0]);
		dp[i][0]=temp+s0(a[i]);
		temp=min(temp,dp[i-1][1]);
		dp[i][1]=temp+s1(a[i]);
		temp=min(temp,dp[i-1][2]);
		dp[i][2]=temp+s2(a[i]);
		temp=min(temp,dp[i-1][3]);
		dp[i][3]=temp+s3(a[i]);
		temp=min(temp,dp[i-1][4]);
		dp[i][4]=temp+s4(a[i]);
	}
	ll res=1LL*inf*inf;
//	for(int i=0;i<n;i++)
//	{
//		for(int j=0;j<5;j++)
//		{
//			cout<<dp[i][j]<<' ';
//		}
//		cout<<endl;
//	}
	for(int i=0;i<5;i++)
	{
		res=min(res,dp[n-1][i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 8832
import math

n, d = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    num = (xy[i][0])**2 + (xy[i][1])**2
    if d >= math.sqrt(num):
        ans += 1
print(ans)

Measured memory_bytes: 45304
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; ++i) {
    if (N % i == 0) return false;
        
  }
  return true;
  
}

int main(void){
  ll n;
  cin >> n;
  int ans = 0;
  int num = 2;
  
  while(num < sqrt(n)){
    int cnt = 0;
    while(n%num == 0){
      n /= num;
      cnt++;
    }
    int del = 1;
    while(del <= cnt){
      cnt -= del;
      ans++;
      del++;
    }
    //    cout << n << endl;
    num++;
  }
  if(n != 1){
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3680
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{//dpっぽい?
	auto weight = [1000, 1200, 1500, 200, 300, 500];
	auto tplace =  [380*5*0.8, 550*4*0.85, 850*3*0.88, 380, 550, 850];
	auto place = tplace.map!(to!int).array;

	int[10000] dp;
	dp[] = int.max;
	foreach (i; 0..6) {
		dp[weight[i]] = place[i];
	}

	foreach (i; iota(100, 5001, 100)) {
		if (dp[i] == int.max) continue;
		foreach (j; 0..6) {
			dp[i + weight[j]] = min(dp[i + weight[j]], dp[i] + place[j]);
		}
	}

	int n;
	while (n = readln.chomp.to!int, n) {
		dp[n].writeln;
	}
}

Measured memory_bytes: 1076
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        Point p1 = new Point();
        Point p2 = new Point();
 
        p1.setX(scanner.nextDouble());
        p1.setY(scanner.nextDouble());
        p2.setX(scanner.nextDouble());
        p2.setY(scanner.nextDouble());
 
        System.out.printf("%.10f\n", calcDistance(p1,p2));
    }
 
    public static double calcDistance(Point p1,Point p2){
        return Math.sqrt((p1.getX()-p2.getX())*(p1.getX()-p2.getX())+(p1.getY()-p2.getY())*(p1.getY()-p2.getY()));
    }
}
 
class Point{
 
    private double x;
    private double y;
 
    Point(){
        x = 0;
        y = 0;
    }
 
    public double getX() {
        return x;
    }
    public void setX(double x) {
        this.x = x;
    }
    public double getY() {
        return y;
    }
    public void setY(double y) {
        this.y = y;
    }
}


Measured memory_bytes: 28228
#include <iostream>
#include <algorithm>

size_t min_mod(size_t L, size_t R) {
    constexpr size_t DENOM = 2019;
    if (R - L >= DENOM)
        return 0;
    else {
        size_t min = DENOM - 1;
        for (size_t i = L; i < R; ++i)
            for (size_t j = i + 1; j <= R; ++j)
                min = std::min(min, (i*j)%DENOM);
        return min;
    }
}

int main() {
    size_t L, R;
    std::cin >> L >> R;
    std::cout << min_mod(L, R) << std::endl;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;


LL n,ans,t,ls,a[K];
int main(void)
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cin>>n>>t;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ans+=t;
    for(int i=2;i<=n;i++)
    {
        if(a[i]-a[i-1]<=t)
            ans+=a[i]-a[i-1];
        else
            ans+=t;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;


#define INF 1000000000

const long long DIM = 3007;
const long long MODULO = 1000000007;

long long d[DIM][DIM], p[DIM][DIM];
long long n,res,sum;
string s;

int main() {
    //freopen("input.txt", "r", stdin);

    cin >> n >> s;
    d[1][1] = 1;
    for(int j = 1; j <= n; j++)
        p[1][j] = p[1][j-1] + d[1][j];

    for(int i = 2; i <= n; i++) {
        for(int last = 1; last <= i; last++) {
            sum = 0;
            if(s[i-2] == '>') {
                //for(int k = last; k <= i; k++) sum += d[i-1][k];
                //sum(last,i)
                sum = p[i-1][i] - p[i-1][last-1];

            } else {
                //for(int k = 1; k < last; k++) sum += d[i-1][k];
                //sum(1,last-1)
                sum = p[i-1][last-1];
            }
            sum = (sum + MODULO) % MODULO;
            d[i][last] = sum % MODULO;
        }
        for(int j = 1; j <= n; j++) p[i][j] = p[i][j-1] + d[i][j];
    }

    sum = 0;
    for(int i = 1; i <= n; i++) sum += d[n][i];
    sum %= MODULO;
    cout<<sum<<endl;
/*
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) cout<<d[i][j]<<' ';
        cout<<endl;
    }
*/
    return 0;
}


Measured memory_bytes: 141440
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector < pair<int, int>>vs;
		for (int i = 0; i < M; ++i) {
			vs.push_back(make_pair(0, i + 1));
		}
		for (int i = 0; i < N; ++i) {
			for (size_t j = 0; j < M; j++)
			{
				int a; cin >> a;
				if (a)vs[j].first--;
			}
		}
		sort(vs.begin(), vs.end());
		for (int i = 0; i < vs.size(); ++i) {
			cout << vs[i].second;
			if (i != vs.size() - 1)cout << " ";
			else cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3072
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    ans = 0
    while n:
        n //= k
        ans += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define F(i,a,b) for(ll i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-7
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e6+10;
const int N = 1e5+10;
const int E = 1e6+10; 

int n;
ll a[maxn];
ll fac;
ll prime[maxn];	//下标从1开始
bool not_prime[maxn];

int sieve(int n){	//把2到n内所有素数筛选出来
    int p = 0;
    for (int i = 2; i <= n; ++i){
        if(!not_prime[i])
           prime[++p] = i;
        for(int j = 1; j <= p&&i*prime[j]<=n; j++){
        	not_prime[i*prime[j]] = true;	//把比最小素因子的素数的倍数筛除
        	if(i%prime[j]==0) break;	//已找到最小素因子
		}
    }
    return p;   //  返回素数个数
}
int cnt[maxn];
bool flg = 1;
void pri_fac(int x){
	for(int i = 1;prime[i]*prime[i]<=x;i++){
		if(x%prime[i]==0){
			if(cnt[prime[i]]){
				flg = 0;
				break;
			}
			else cnt[prime[i]] = 1;
			while(x%prime[i]==0) x/=prime[i];
		}
	}
	if(x>1) {
		if(cnt[x]){
			flg = 0;
			return;
		}
		else cnt[x] = 1;
	} 
} 

int main(){
	int len = sieve(1000000);
	cin>>n;
	F(i,1,n){
		cin>>a[i];
	}
	ll gg = a[1];
	F(i,2,n){
		gg = __gcd(gg,a[i]);
	}
	if(gg!=1){
		printf("not coprime\n");
		return 0; 
	}
	F(i,1,n){
		pri_fac(a[i]);
		if(!flg) break;
	}
	if(flg){
		printf("pairwise coprime\n");
	}
	else {
		printf("setwise coprime\n");
	}
}

Measured memory_bytes: 12984
N = int(input())
num_list = list(map(int, input().split()))

from collections import defaultdict
d = defaultdict(int)
for i in num_list:
  d[i] += 1
 
total = 0
for i in set(num_list):
  x = d[i]
  total += x*(x-1)/2
 
for i in num_list:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;
typedef pair< int, P > PP;

//-------------------------------------------------

int a, b;

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

	cin >> a >> b;
	cout << (max(a, b) > 8? ":(": "Yay!") << endl;

	return 0;
}



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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    for (int a = M / N; 1 <= a; --a){
        if (M % a != 0) continue;
        cout << a << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

#define T 1
#define F 0

int n,A[100];

int saiki(int a,int b){
  int c;
 
  if(b==0) return T;
  if(a>=n) return F;

  c=saiki(a+1,b)||saiki(a+1,b-A[a]);
  return c;

}

int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(saiki(0,m)==T){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    vector<int> B(N - 1, 0);
    for (int i = 0; i < N - 1; ++i) cin >> B[i];
    for (int i = 1; i < N; ++i) {
        if (i == 1) A[i - 1] = B[i - 1];
        else {
            if (A[i - 1] < B[i - 1]) int nothing;
            else if (A[i - 1] >= B[i - 1]) A[i - 1] = B[i - 1];
        }
        A[i] = B[i - 1];
    }
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += A[i];
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;
        var A = cin.Scanint;
        int ans = 1;
        bool flag = true;
        bool check = false;
        for (int i = 1; i < N; i++)
        {
            //WriteLine(i);
            if (flag)
            {
                if (A[i] - A[i - 1] > 0)
                {
                    flag = false;
                    check = true;
                }
                else if (A[i] - A[i - 1] < 0)
                {
                    flag = false;
                    check = false;
                }
                

            }
            else if (check)
            {
                if (A[i] - A[i - 1] < 0)
                {
                    ans++;
                    flag = true;
                    //i++;
                }

            }
            else if (!check)
            {
                if (A[i] - A[i - 1] > 0)
                {
                    ans++;
                    flag = true;
                    //i++;
                }
            }
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 20572
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int dp[1 << 23];

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	auto cl = clock();
	std::vector<std::vector<int> > gr(n, std::vector<int> (n));
	for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cin >> gr[i][j];
		int mod = 1e9 + 7;
	dp[0] = 1;
	for (int i = 0; i < n; ++i)
		for (int mask = 0; mask < (1 << n); ++mask) {
			int cn = 0;
			for (int j = 0; j < n; ++j) if (mask & (1 << j)) cn++;
			if (cn == i && dp[mask] != 0)
				for (int k = 0; k < n; ++k)
					if (gr[i][k] && (!(mask & (1 << k)))) {
						dp[mask | (1 << k)] = (dp[mask | (1 << k)] + dp[mask]);
						if (dp[mask | (1 << k)] >= mod) 
							dp[mask | (1 << k)] -= mod;
					}
		}
	cout << dp[(1 << n) - 1] << "\n";
	auto cl1 = clock();
	// cout << (double) (cl1 - cl) / CLOCKS_PER_SEC;
}

Measured memory_bytes: 18688
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        long x[] = new long[N];
        long y[] = new long[N];
        long z[] = new long[N];
        for(int i = 0; i < N; i++) {
            x[i] = sc.nextLong();
            y[i] = sc.nextLong();
            z[i] = sc.nextLong();
        }
        
        long max = Long.MIN_VALUE;
        for( int i = 0; i < (1<<3); i++ ) {
            PriorityQueue<Long> pq = new PriorityQueue<Long>( (a, b) -> b.compareTo(a) );
            for(int j = 0; j < N; j++ ) {
                long sum = 0;
                if( (i>>0 & 1) == 1 ) {
                    sum += x[j];
                } else {
                    sum -= x[j];
                }
                
                if( (i>>1 & 1) == 1 ) {
                    sum += y[j];
                } else {
                    sum -= y[j];
                }
                
                if( (i>>2 & 1) == 1 ) {
                    sum += z[j];
                } else {
                    sum -= z[j];
                }
                pq.add( sum );
            }
            
            long total = 0;
            for(int k = 0; k < M; k++) {
                long v = pq.poll();
                total += v;
            }
            max = Math.max( max, total );
        }

        System.out.println( max );
    }
}


Measured memory_bytes: 41472
import java.util.*;

class Main {
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      double  a    = Double.parseDouble(scan.next());
      double  b    = Double.parseDouble(scan.next());

      int sum = (int)(a + b);

      if(sum % 2 == 1){
         System.out.println((sum / 2) + 1);
         }
      else{
          System.out.println(sum / 2);
          }
   }
}


Measured memory_bytes: 21588
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i,N) {
		cin >> A[i];
	}
	for (int i = 1; i < N ;++i) {
		int v = A[i];
		int j = i - 1;
		rep(i, N - 1)cout << A[i] << " ";
		cout << A[N - 1] << endl;
		while (0<=j&&v<A[j])
		{
			A[j + 1] = A[j];
			j--;
			A[j + 1] = v;
		}
	}
	rep(i, N - 1)cout << A[i] << " ";
	cout << A[N - 1] << endl;
	return 0;
}




Measured memory_bytes: 3096
import itertools
def MI(): return map(int, input().split())
H,W,K=MI()
Map=[input() for _ in range(H)]
ans=0
for gyou in range(1<<H):
  for retsu in range(1<<W):
    count=0
    for i in range(H):
      if (gyou>>i)&1:
        for j in range(W):
          if (retsu>>j)&1:
            if Map[i][j]=='#':
              count+=1
    if count==K:
      ans+=1
print(ans)

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    char a,b;
    cin >> a >> b;
    cout << ((a == b)?'H':'D');
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool check(string s,string t){
    bool j = true;
    int l = s.size();
    for(int i = 0;i < l;i++){
        if(s[i] == '?' || s[i] == t[i]);
        else j = false;
    }
    return j;
}
int main(){
    bool judge = true;
    string s,t;
    cin >> s >> t;
    int s_siz = s.size();
    int t_siz = t.size();
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    for(int i = 0;i <= s_siz - t_siz+1;i++){
        if(i == s_siz - t_siz+1){
            cout << "UNRESTORABLE" << endl;
            judge = false;
            break;
        }
        string sub = s.substr(i,t_siz);
        if(check(sub,t)){
            for(int j = 0;j < t_siz;j++)s[i+j] = t[j];
            break;
        }
    }
    reverse(s.begin(),s.end());
    if(judge && s_siz < t_siz)cout << "UNRESTORABLE" << endl;
    else if(judge){
        for(int i = 0;i < s_siz;i++){
            if(s[i] == '?')cout << "a";
            else cout << s[i];
        }
    }
    //cin >> s;
}

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

using namespace std;

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

int main(){
  int n, k; cin >> n >> k;
  vector<int> h(n); int i; rep(i, n) cin >> h[i];
  
  vector<int> cost(n);
  cost[0] = 0;
  for(int i = 1; i < n; i++){
    int min_cost = cost[i - 1] + abs(h[i] - h[i - 1]);
    for(int j = 1; j < k; j++){
      if(i - j - 1 >= 0) min_cost = min(cost[i - j - 1] + abs(h[i] - h[i - j - 1]), min_cost);
    }
    cost[i] = min_cost;
  }
  
  cout << cost[n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    dp = [[0]*3 for i in range(N+1)]
    #dp[i][j] iまでで、j=0はaを選ぶ,j=1はbを選ぶ,j=2はcを選ぶ
    for i in range(1,N+1):
        a, b, c=map(int,input().split())
        dp[i][0] = max(dp[i-1][1]+a, dp[i-1][2]+a, dp[i][0])
        dp[i][1] = max(dp[i-1][2]+b, dp[i-1][0]+b, dp[i][1])
        dp[i][2] = max(dp[i-1][0]+c, dp[i-1][1]+c, dp[i][2])

    print(max(dp[N]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 22816
#include<stdio.h>
#include<string.h>
int p[1000],q=0,i,x;
char w[1000][31],t[31];
int main()
{
	for(;scanf("%s%d",t,&x)==2;q++)
	{
		for(i=q;i>0&&(strcmp(w[i-1],t)>0||(strcmp(w[i-1],t)==0&&p[i-1]>x));i--)
		{
			strcpy(w[i],w[i-1]);
			p[i]=p[i-1];
		}
		strcpy(w[i],t);
		p[i]=x;
	}
	for(i=0;i<q;i++)
	{
		if(i==0||strcmp(w[i],w[i-1])!=0)
			printf("%s\n%d%s",w[i],p[i],strcmp(w[i],w[i+1])==0?" ":"\n");
		else
			printf("%d%s",p[i],strcmp(w[i],w[i+1])==0?" ":"\n");
	}
	return 0;
}

Measured memory_bytes: 628
line=input()

a=['R','U','D']
b=['L','U','D']
flag=True

for i in range(len(line)):
  if not flag:
    break
  if (i+1)%2==1:
    if line[i] not in a:
      flag=False
      print('No')
  else:
    if line[i] not in b:
      flag=False
      print('No')
if flag==True:
  print('Yes')         

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int a = Integer.parseInt(ss0[0]);
		int b = Integer.parseInt(ss0[1]);
		int c = Integer.parseInt(ss0[2]);

		if (a+b == c) {  System.out.println("Yes"); return; }
		if (b+c == a) {  System.out.println("Yes"); return; }
		if (c+a == b) {  System.out.println("Yes"); return; }

		System.out.println("No");
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}


Measured memory_bytes: 8148
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n,q=MI()
v=[0]*n
c=[0]*n
g=[[] for i in range(n)]
for i in range(n-1):
    a,b=MI()
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x=MI()
    c[p-1]+=x

#print(c)


def bfs(x):
    p=deque()
    p.append(x)
    while p:
        cur=p.popleft()
        v[cur]=1
        for i in g[cur]:
            if v[i]==0:
                p.append(i)
                c[i]+=c[cur]
bfs(0)

print(*c)


Measured memory_bytes: 106900
#include <bits/stdc++.h>
//#include "stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = max(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<vector<int>> v(15, vector<int>(15, -1));
	rep(i, n) {
		int a;
		cin >> a;
		while (a--) {
			int x, y;
			cin >> x >> y;
			x--;
			v[i][x] = y;
		}
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		vector<int> honest(n);
		for (int i = 0; i < n; i ++) {
			if (bit >> i & 1) {
				honest[i] = 1;
			}
		}
		bool ok = true;
		rep(i, n) {
			if (honest[i]) {
				rep(j, n) {
					if (v[i][j] == -1) continue;
					if (v[i][j] != honest[j]) ok = false;
				}
			}
		}
		if (ok) chmax(ans, __builtin_popcount(bit));
	}
	cout << ans << endl;
}


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

int main(){
  int count=10;
  int time=0;
  vector<int>X(5);
  rep(i,5){
    cin>>X[i];
  }
  rep(i,5){
    if(count>X[i]%10 && X[i]%10){
      count=X[i]%10;
    }
  }
    rep(i,5){
      time+=((X[i]+9)/10)*10;
    }
    cout<<time+count-10;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793238
signed main(){
  double x,y,t,w;
  cin>>x>>y>>t>>w;
  double R=sqrt(x*x+y*y); 
  t*=(2*PI)/360;
  double t1=atan2(y,x),t2=t;
  if(t1<0) t1+=2*PI;
  if(t1>t2) swap(t1,t2);
  double dt=min(t2-t1,t1+2*PI-t2);
  double lb=0,ub=w/360*2*PI*R;
  for(int k=0;k<2000;k++){
    double v=(lb+ub)/2;
    double r=v/(2*PI)*(360/w);
    double e=sqrt(R*R-r*r);
    double th=atan2(e,r);
    if(th<0) th+=2*PI;
    double len=(dt+th)*r;
    if(e<=len) ub=v;
    else lb=v;
  }
  printf("%.12f\n",ub);
  return 0;
}

Measured memory_bytes: 3492
#include <iostream>

using namespace std;

int main()
{
    char b;
    cin >> b;
    switch (b){
        case 'A':
            cout << 'T';
            break;
        case 'C':
            cout << 'G';
            break;
        case 'G':
            cout << 'C';
            break;
        case 'T':
            cout << 'A';
            break;
    }
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		Console.WriteLine(Console.ReadLine().Split(' ').ToList().IndexOf("0") + 1);
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 26508
X=int(input())
if X<=599:
    print(8)
elif X<=799:
    print(7)
elif X<=999:
    print(6)
elif X<=1199:
    print(5)
elif X<=1399:
    print(4)
elif X<=1599:
    print(3)
elif X<=1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9200
def main():
    N = int(input())
    h = list(map(int, input().split()))
    l = []
    r = 0
    for i in range(N-1, 0, -1):
        if h[i] <= h[i-1]:
            r += 1
        else:
            l.append(r)
            r = 0
    l.append(r)
    return max(l)
print(main())


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size() - 1; ++i) {
    os << v[i] << " ";
  }
  if (v.size() > 0) {
    os << v[v.size() - 1] << endl;
  }
  return os;
}
ll extgcd(ll a, ll b, ll &x, ll &y) {  // extended Euclidean algorithm, used for
                                       // modular multiplicative inverse
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;  // return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD) {  // return inv(a) mod m, ax+my=gcd(a,m)=1, m is
                                // prime int, ax-1=mq equiv. ax-mq=1
  ll x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;  // From (possibly) negative x to positive x
}

vector<ll> fact, invfact;
void calc_fact(int n, ll m = MOD) {  // Calculate factorial up to n
  fact.resize(n + 1);
  invfact.resize(n + 1);
  fact[0] = invfact[0] = 1;
  REP(i, n) {
    fact[i + 1] = fact[i] * (i + 1) % m;
    invfact[i + 1] = invfact[i] * mod_inv(i + 1) % m;
  }
}
ll perm(int n, int k, ll m = MOD) {
  if (n < 0 || k < 0 || k > n) return 0;
  return fact[n] * invfact[n - k] % m;
}
ll comb(int n, int k, ll m = MOD) {
  if (n < 0 || k < 0 || k > n) return 0;
  return (fact[n] * invfact[n - k] % m) * invfact[k] % m;
}

int main() {
  int n,k;
  cin>>n>>k;
  vll a;
  set<ll> se;
  REP(i, n) {
    ll tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  int sz = a.size();
  sort(a.begin(), a.end());
  calc_fact(n);
  ll maxv = 0, minv = 0;
  FOR(i, k - 1, n) {
    ll tmp = a[i]*comb(i,k-1) % MOD;
    maxv = (maxv + tmp) % MOD;
  }
  FOR(i, 0, n-k+1){
    ll tmp = a[i]*comb(n - i - 1,k-1) % MOD;
    minv = (minv + tmp) % MOD;
  }
  cout << (maxv + MOD - minv) % MOD << endl;
}

Measured memory_bytes: 2804
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;
int w,h;
int dp[100][100][2][2][3];
int solve(int x,int y,int x_f,int y_f,int prev){
  //1:true 0:false
  //prev 1: x , 2: y
  if(x>w || y>h)return 0;
  if(x==w&&y==h){
    //ans++;
    return 1;
  }
  if(dp[y][x][x_f][y_f][prev] != -1)
    return dp[y][x][x_f][y_f][prev];


  int ret = 0;
  if(x_f==1&&y_f==1){
    // cout<<"ff:"<<x<<"\t"<<y<<endl;
    if(prev == 1){
      ret = solve(x+1,y,1,1,1) + solve(x,y+1,0,1,2);
    }else if(prev == 2){
      ret = solve(x,y+1,1,1,2) + solve(x+1,y,1,0,1);
    }else{
      ret = solve(x,y+1,1,1,2) + solve(x+1,y,1,1,1);
    }
  }else if(x_f==0&&y_f==1){
    // cout<<"ft"<<x<<"\t"<<y<<endl;
    ret = solve(x,y+1,1,1,2);
  }else if(x_f==1&&y_f==0){
    //cout<<"tf"<<x<<"\t"<<y<<endl;
    ret = solve(x+1,y,1,1,1);
  }

  return dp[y][x][x_f][y_f][prev] = ret % 100000;

}


int main(){

  while(cin>>w>>h){
    if(w==0&&h==0)
      break;
    w--;h--;
    memset(dp,-1,sizeof(dp));
    cout<< solve(0,0,1,1,0) % 100000<<endl;
  }
  

  return 0;
}

Measured memory_bytes: 1644
import * as fs from 'fs'
const reader = (s: string) => s.trim()

function Main(input: string) {
  const S = reader(input).split('')
  const eve = S.map((x, i) => {
    if (i % 2 === 0) {
      return x
    }
  })
  const odd = S.map((x, i) => {
    if (i % 2 === 1) {
      return x
    }
  })

  if (eve.indexOf('L') !== -1) {
    console.log('No')
    return
  }

  if (odd.indexOf('R') !== -1) {
    console.log('No')
    return
  }

  console.log('Yes')
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9420
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    int x,t;cin >> x >> t;
    cout << max(x-t,0) << endl;
}

Measured memory_bytes: 256
o=list(input())
e=list(input())
tmp=""
n=len(o)
if len(o)==len(e):
  for i in range(n):
    tmp+=o[i]+e[i]
else:
  for i in range(n):
    tmp+=o[i]
    if i < n-1:
      tmp+=e[i]
print(tmp)

Measured memory_bytes: 3064
import math
import itertools

N=int(input())
XY=[list(map(int,input().split())) for _ in range(N)]

ans=0
for v in itertools.permutations(range(N)):
    for i in range(N-1):
        ans+=math.sqrt((XY[v[i]][0]-XY[v[i+1]][0])**2+(XY[v[i]][1]-XY[v[i+1]][1])**2)

print(ans/math.factorial(N))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iterator>
#include <vector>
#include <unordered_map>
#include <algorithm>

struct pair_hash {
	template <class T1, class T2>
	std::size_t operator() (const std::pair<T1, T2> &pair) const {
		return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
	}
};


int main()
{
  int N;
  std::cin >> N;
  std::string s;
  int blue = 0;
  std::cin >> s;
  for (int i=0; i<s.length(); i++) {
    if (s[i]=='B') blue++;
    else blue--;
  }
  if (blue<0) std::cout <<"Yes";
  else std::cout << "No";
  //std::cout << blue;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MAXN 205
//#define N 262144
#define ULL unsigned long long
#define ll long long
int main(){
    LL n;
    scanf("%lld",&n);
    n--;
    LL now=26;
    int len=1;
    while(n>=now){
        n-=now;
        now*=26;
        len++;
    }
    vector<int> v;
    for(int i = 0;i<len;i++){
        v.pb(n%26);
        n/=26;
    }
    reverse(v.begin(),v.end());
    for(auto it:v){
        printf("%c",it+'a');
    }
    printf("\n");
}

Measured memory_bytes: 3692
class Node
  # property parent : Int32
  # property s : Int32
  attr_accessor :parent, :s # Ruby
    
  def initialize(n)
    @parent = n
    @s = 0
  end
end

class UnionFindTree
  
  # property nodes : Array(Node) # Crystal
  attr_accessor :nodes        # Ruby

  def initialize(n)
    @nodes = (0..n).to_a.map{ |i| Node.new(i) }
  end

  def root(x)
    return x if x == nodes[x].parent
    nodes[x].parent = root(nodes[x].parent)
  end
  
  def unite(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += 1 if nodes[a].s == nodes[b].s # by rank
    # nodes[a].s += nodes[b].s                    # by size
    true
  end
  
  def unite_by_size(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += nodes[b].s
    true
  end
  
  def unite_by_rank(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += 1 if nodes[a].s == nodes[b].s
  end

  def same?(a, b)
    root(a) == root(b)
  end

  def size(node)
    nodes[root(node)]
  end
end

n, m = gets.to_s.chomp.split.map{|i| i.to_i}
perm = gets.to_s.chomp.split.map{|i| i.to_i - 1 }
xys  = Array.new(m){ gets.to_s.chomp.split.map{|i| i.to_i - 1 } }

uf = UnionFindTree.new(n)
xys.each{|x,y| uf.unite(x,y) }
ans = (0...n).count{ |i| uf.same?(i, perm[i]) }

puts ans

Measured memory_bytes: 17732
S = input()
prev = ''
K = ['']

i = 0

while i < len(S):
    text = S[i]
    prev = K[-1]
    if text == prev:
        if len(S) == i+1:
            K[-1] += text
            break
        else:
            j = i
            i += len(prev)
            text = S[j:i+1]
    K.append(text)
    i += 1

# print(K)
print(len(K)-1)

Measured memory_bytes: 8064
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect();
    let (a, b, c) = (vec[0], vec[1], vec[2]);
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 5024
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, i, ans=0;
    cin >> n;
    ll a[n+1], cnt[n+1];
    for(i=0; i<=n; i++)
        cnt[i]=0;
    for(i=1; i<=n; i++)
        cin >> a[i];
    
    ll j=1;
    while(1) {
        j=a[j];
        ans++;
        if(j==2) {
            cout << ans << endl;
            return 0;
        }
        if(cnt[j]>=1) {
            cout << -1 << endl;
            return 0;
        }
        cnt[j]++;
    }
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleAppAtCoderBeginnerContest116A
{
    class Program
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            var inputABC = Console.ReadLine().Split().Select(int.Parse).ToList();

             int AB = inputABC[0];
            int BC = inputABC[1];
            //
            Console.WriteLine(AB*BC/2);
        }
    }
}


Measured memory_bytes: 13268