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

partial class Solver
{
    public void Run()
    {
        var A = ni();
        var P = ni();
        int ans = (A * 3 + P) / 2;
        cout.WriteLine(ans);
    }
}


// PREWRITEN CODE BEGINS FROM HERE
partial class Solver : Scanner
{
    public static void Main(string[] args)
    {
        new Solver(Console.In, Console.Out).Run();
    }

    TextReader cin;
    TextWriter cout;

    public Solver(TextReader reader, TextWriter writer)
        : base(reader)
    {
        this.cin = reader;
        this.cout = writer;
    }
    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer)
    {
    }

    public int ni() { return NextInt(); }
    public int[] ni(int n) { return NextIntArray(n); }
    public long nl() { return NextLong(); }
    public long[] nl(int n) { return NextLongArray(n); }
    public double nd() { return NextDouble(); }
    public string ns() { return Next(); }
}

public class Scanner
{
    private TextReader Reader;
    private Queue<String> TokenQueue = new Queue<string>();
    private readonly CultureInfo ci = CultureInfo.InvariantCulture;

    public Scanner()
        : this(Console.In)
    {
    }

    public Scanner(TextReader reader)
    {
        this.Reader = reader;
    }

    public int NextInt() { return Int32.Parse(Next(), ci); }
    public long NextLong() { return Int64.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size)
    {
        var array = new string[size];
        for (int i = 0; i < size; i++) array[i] = Next();
        return array;
    }
    public int[] NextIntArray(int size)
    {
        var array = new int[size];
        for (int i = 0; i < size; i++) array[i] = NextInt();
        return array;
    }

    public long[] NextLongArray(int size)
    {
        var array = new long[size];
        for (int i = 0; i < size; i++) array[i] = NextLong();
        return array;
    }

    public String Next()
    {
        if (TokenQueue.Count == 0)
        {
            if (!StockTokens()) throw new InvalidOperationException();
        }
        return TokenQueue.Dequeue();
    }

    public bool HasNext()
    {
        if (TokenQueue.Count > 0)
            return true;
        return StockTokens();
    }

    private bool StockTokens()
    {
        while (true)
        {
            var line = Reader.ReadLine();
            if (line == null) return false;
            var tokens = line.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (tokens.Length == 0) continue;
            foreach (var token in tokens)
                TokenQueue.Enqueue(token);
            return true;
        }
    }
}


Measured memory_bytes: 11220
// #0023
// Time-stamp: <2012-07-10 17:44:59 naga>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  // (x, y) r
  double a[3],b[3];
  int n;

  cin >> n;
  while(n > 0){
    // input
    for(int i = 0; i < 3; i++){
      cin >> a[i];
    }
    for(int i = 0; i < 3; i++){
      cin >> b[i];
    }

    // distance
    double distance;
    distance = sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2));

    // judgment
    if(distance > a[2] + b[2]){
      cout << "0" << endl;
    }
    else if(distance < a[2] - b[2]){
      cout << "2" << endl;
    }
    else if(distance < b[2] - a[2]){
      cout << "-2" << endl;
    }
    else{
      cout << "1" << endl;
    }
    
    n--;
  }

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <climits> // INT, LONG, LLONG, UINT, ULONG, ULLONG
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define INF (INT_MAX >> 1)

using namespace std;

int n, q, k;

map<int, long long> cost;
map<int, map<int, long long>> tree;

void dfs(int v, int p, long long c) {
    cost[v] = c;
    for (auto e : tree[v]) {
        if (e.first == p)
            continue;
        dfs(e.first, v, c + e.second);
    }
}

int main() {
    cin >> n;
    
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        tree[a - 1][b - 1] = c;
        tree[b - 1][a - 1] = c;
    }

    cin >> q >> k;

    dfs(k - 1, INF, 0);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << cost[x - 1] + cost[y - 1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 38400
#include <stdio.h>
    int main (){
      int a,b,c,tmp;
      scanf("%d",&a);
      scanf("%d",&b);
      scanf("%d",&c);
      tmp=a;
      a=b;
      b=tmp;
      tmp=a;
      a=c;
      c=tmp;
      printf("%d %d %d",a,b,c);
      return 0;
    }

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

int main()
{ 
int A,B;
cin>>A>>B;
    
if     ((A==1 && B==2) || (A==2 && B==1 ))cout<<3<<endl;
else if((A==1 && B==3) || (A==3 && B==1 ))cout<<2<<endl;
else if((A==3 && B==2) || (A==2 && B==3 ))cout<<1<<endl;

else {
cout<<0<<endl;
}
}


Measured memory_bytes: 3576
function Main(input){
    input = input.split("\n");
    var arr = input[1].split("").map(Number);
    var sum = 0;
    for(var i=0;i<10;i++){
        var p_1 = -1
        for(var p=0;p<arr.length;p++){
            if(arr[p]==i){
                p_1 = p;
                break;
            }
        }
        if(p_1==-1) continue;
      //  console.log("1:"+i)
        for(var j=0;j<10;j++){
            var p_2 = p_1
            for(var p=p_2+1;p<arr.length;p++){
                if(arr[p]==j){
                    p_2 = p;
                    break;
                }
            }
            if(p_2==p_1) continue;
            //console.log("2:"+j)
            for(var k=0;k<10;k++){
                for(var p=p_2+1;p<arr.length;p++){
                    if(arr[p]==k){
                        sum++;
                        break;
                    }
                }  
            }      
        }
    }
    console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 33096
N,M = map(int,input().split())
X = list(map(int,input().split()))

d = []

X.sort()
for i in range(M-1):
    d.append(X[i+1]-X[i])
else:
    d.sort()
    d = d[::-1]

res = sum(d) - sum(d[0:N-1])

print(res)



Measured memory_bytes: 13968
N = int(input())
z = [0] * N
w = [0] * N
for i in range(N):
  x, y = map(int, input().split())
  z[i] = x + y
  w[i] = x - y
  
z = sorted(z)
w = sorted(w)
#print(z)
#print(w)
ans = max(abs(z[-1] - z[0]), abs(w[-1] - w[0]))
print(ans)

Measured memory_bytes: 26964
// https://atcoder.jp/contests/abc147/tasks/abc147_b

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  string S;
  cin >> S;

  ll res = 0;

  rep(i, S.size()) {
    if (S[i] != S[S.size() - 1 - i]) {
      S[S.size() - 1 - i] = S[i];
      res++;
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w, a, b := nextInt(), nextInt(), nextInt(), nextInt()

	s := make([][]int, h)
	for i := range s {
		s[i] = make([]int, w)
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			val := 1
			if i < b && j < a {
				val = 0
			} else if i >= b && j >= a {
				val = 0
			}
			s[i][j] = val
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			putf("%d", s[i][j])
		}
		puts()
	}
}


Measured memory_bytes: 17024
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String str = sc.next();
    
	int count = 0;
    
    for(int i=0; i<4; i++){
      for(int j=i+1; j<4; j++){
        if(str.charAt(i) == str.charAt(j)){
          count++;
        }
      }
    }
    
    if(count == 2){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

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

int main(){
  int n, z = 0;
  cin >> n;
  vector<tuple<int, int, int>> p(2 * n);
  rep(i, 2 * n) {
    int a, b;
    cin >> a >> b;
    p[i] = make_tuple(a, b, i / n);
  }
  vector<int> q(2 * n);
  sort(p.begin(), p.end());
  rep(i, 2 * n){
    int a, b, c;
    tie(a, b, c) = p[i];
    if (c == 0){
      q[b]++;
    }else{
      for (int j=b; j>=0; j--){
        if (q[j] == 1){
          z++;
          q[j] = 0;
          break;
        }
      }
    }
  }
  cout << z << endl;
  return 0;
}


Measured memory_bytes: 3632
n = int ( input() )

def find_gcd(x, y): 
      
    while(y): 
        x, y = y, x % y 
      
    return x 

dicts = {}
total = 0 
storedict = {}
for i in range(1, n + 1):
    for j in range(1, n + 1):
        
        strin = str(i) + "," + str(j)
        if strin not in dicts:
            gh = find_gcd(i, j)
            strin3 = str(j) + "," + str(i)
            dicts[strin] = gh 
            dicts[strin3] = gh 
            
        else:
            gh = dicts[strin]
        
        if gh not in storedict:
            storedict[gh] = 1 
        else:
            storedict[gh] += 1 

for k in range( 1 , n + 1):
    for key, value in storedict.items():
        gh = find_gcd(key, k)
        
        strin2 = str(gh) + "," + str(k)
        
        if strin2 not in dicts:
            gh = find_gcd(gh, k)
            strin4 = str(k) + "," + str(gh)
            dicts[strin2] = gh 
            dicts[strin4] = gh 
        else:
            gh = dicts[strin2]
            
        ans1 = gh * value    
        total += ans1 
print(total)
                        


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(false);\
				cin.tie(0);\
				cout.tie(0)
#define REP(_i, _a) for(int _i = 0; _i < (int)_a; ++_i)
#define FOR(_i, _a, _b) for(int _i = (int)_a; _i <= (int)_b; ++_i)
#define FORD(_i, _a, _b) for(int _i = (int)_a; _i >= (int)_b; --_i)
#define RESET(_a, _value) fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define ALL(_a) _a.begin(), _a.end()
#define SIZE(_a) _a.size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define newline '\n';

// DEBUG UTIL
#define DEBUG(args...) { cerr << "> "; \
						 string _s = #args; \
						 replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); istream_iterator<string> _it(_ss); \
						 err(_it, args); }

void err(istream_iterator<string> it) { cerr << endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << ": " << a << " ";
	err(++it, args...);
}

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int INF = 2e9;

int a[3];
int K;

void test() {

}

void read() {
	cin >> a[0] >> a[1] >> a[2];
	cin >> K;
}

void solve() {
	sort(a, a + 3);
	FOR(i, 1, K) {
		a[2] *= 2;
	}
	cout << a[0] + a[1] + a[2] << endl;
}

int main() {
	FAST_IO;
	
	test();

	int TC = 1;
	// cin >> TC;
	FOR(tc, 1, TC) {
		read();
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
##import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n,m=map(int,input().split())
res=[[0]*8 for _ in range(n)]
ans=0
for i in range(n):
    x,y,z=map(int,input().split())
    res[i]=[x+y+z,x+y-z,x-y+z,x-y-z,-x+y+z,-x+y-z,-x-y+z,-x-y-z]
for i in range(8):
    c=0
    res=sorted(res,key=lambda x: x[i],reverse=True)
    for j in range(m):
        c+=res[j][i]
    ans=max(ans,c)
print(ans)

Measured memory_bytes: 78472
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const int MAX_N = 101010;

vector<int> graph[MAX_N];
int color[MAX_N];

bool dfs(int node, int _color) {
    color[node] = _color;
    bool res = true;
    rep(i, 0, graph[node].size()) {
        int next_node = graph[node][i];
        if (color[next_node] < 0) res &= dfs(next_node, _color ^ 1);
        else if (color[next_node] == _color) {
            res = false;
            break;
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    int A, B;
    rep(i, 0, M) {
        cin >> A >> B;
        A--, B--;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    rep(i, 0, N) color[i] = -1;
    ll ans = 0;
    if (dfs(0, 0)) {
        ll B = 0, W = 0;
        rep(i, 0, N) {
            if (color[i] == 0) B++;
            else W++;
        }
        ans += B * W - M;
    }
    else {
        ans += N * (N - 1) / 2 - M;
    }
    cout << ans << endl;
    return 0;
}

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

int ppcnt(ll n)
{
	int res = 0;
	while(n)
	{
		res += n%2;
		n/=2;
	}
	return res;
}

ll f(ll x)
{
	int cnt = 0;
	while(x)
	{
		x = x%ppcnt(x);
		cnt++;
	}
	return cnt;
}

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

int main()
{
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll mod = 0;
	for(int i = 0;i<n;i++)
		if(s[i]=='1')mod++;
	ll mod0 = mod+1;
	ll mod1 = mod-1;
	ll xmd0 = 0,xmd1=0;
	bool onee = false;
	if(mod1==0)
	{
		mod1 = 1;
		onee = true;
	}
	for(int i = 0;i<n;i++)
	{
		if(i)
		{
			(xmd0 *=2)%=mod0;
			(xmd1 *=2)%=mod1;
		}
		if(s[i]=='1')
		{
			xmd0 = (xmd0+1)%mod0;
			xmd1 = (xmd1+1)%mod1;
		}
	}
	for(int i = 0;i<n;i++)
	{
		int now = 0;
		if(s[i]=='0')
		{
			int a = xmd0;
			a += mod_pow(2LL,n-i-1,mod0);
			a %= mod0;
			cout << f(a) + 1 << endl;
		}
		else
		{
			if(onee)
			{
				cout << 0 << endl;
				continue;
			}
			int a = xmd1;
			a =a + mod1 -  mod_pow(2LL,n-i-1,mod1);
			
			a += mod1;
			a %= mod1;
			cout << f(a) + 1 << endl;
			
		}
		
	}
	
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, s;
    cin >> k >> s;
    int count = 0;
    rep2(x, 0, min(k + 1, s + 1))
    {
        const int t = s - x;
        rep2(y, x, min(k+1, t+1))
        {
            const int u = t - y;
            rep2(z, y, min(k+1, u+1))
            {
                if (z == u) {
                    int k;
                    if ((x != y) && (y != z)) k = 6;
                    else if ((x == y) && (y == z)) k = 1;
                    else k = 3;
                    count += k;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}



Measured memory_bytes: 384
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
from heapq import heappush, heappop, heapify
import sys
stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(rr())
rrm = lambda: list(map(int, rr().split()))

def solve(S):
    if S=='A': return 'T'
    if S=='T': return 'A'
    if S=='C': return 'G'
    if S=='G': return 'C'
    

T = 1 #rri()
for tc in range(1, T+1):
    S = rr()
    ans = solve(S)
    print(ans)
    #print("Case #{}: {}".format(tc, ans))


Measured memory_bytes: 3444
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
s = tuple(map(int,input().split()))
t = tuple(map(int,input().split()))

mod = 10**9+7

dp = [[0]*m for _ in [0]*n]
a = [[0]*m for _ in [0]*n]

for i in range(n):
    a[i][0] = a[i-1][0]
    if t[0] == s[i]:
        dp[i][0] = 1
        a[i][0] += 1

for i in range(m):
    a[0][i] = a[0][i-1]
    if s[0] == t[i]:
        dp[0][i] = 1
        a[0][i] += 1

for i in range(1,n):
    for j in range(1,m):
        if s[i] == t[j]:
            dp[i][j] = (a[i-1][j-1]+1)%mod
        a[i][j] = (a[i-1][j] + a[i][j-1] - a[i-1][j-1] + dp[i][j]) %mod

res = 1
for i in range(n):
    res = (res + sum(dp[i]))%mod
print(res%mod)

Measured memory_bytes: 105436
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << en; cout << endl;}
#define shop(n,x) {for(int i = 0; i < n; i++) cout << x << en; cout << endl;}
#define ff first
#define ss second
#define sq(x) (x*x)
#define endl '\n'
#define en " "
#define pb push_back
#define mpair make_pair
ll mod=1000000007;
double pi=3.1415926536;
ll n, k;
ll dp[200003];
ll cost(ll a[], ll idx)
{
	if(dp[idx] != -1)
		return dp[idx];

	if(idx >= n-2)
		return abs(a[n-1] - a[idx]);
	
	ll m = mod, p = mod;
	for(int i = 1; i <= k; i++)
	{
		if(idx + i >= n)
			break; 
		p = abs(a[idx + i] - a[idx]) + cost(a, idx + i);
		m = min(m, p);
	}
	return dp[idx] = m;
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// go fast 		check		//		CHECK -> if()   else if()
		
		ll x = 0, m = 0, y = 0, d = 1;
		cin >> n >> k;
		ll a[n];
		memset( dp, -1, sizeof(dp) );
		for(int i = 0; i < n; i++)
			cin >> a[i];

		cout << cost(a, 0) << endl;
	}
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    string s;
    cin>>s;
    int a = s.size();

    for(int i=0; i<a; i+=2)
    {
        if(s[i]=='R' || s[i]=='U' || s[i]=='D')
        {
            x = 1;
        }
        else
        {
            x=0;
            break;
        }
    }

    for(int i=1; i<a; i+=2)
    {
        if(s[i]=='L' || s[i]=='U' || s[i]=='D')
        {
            y = 1;
        }
        else
        {
            y=0;
            break;
        }

    }
    if(x==1 && y==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;

}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


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


int main(){
  ll n;
  cin >> n;
  vector<ll> d(n);
  rep(i, n) cin >> d[i];


  sort(all(d));

  cout << d[n/2] - d[n/2 - 1] << endl;



  return 0;
}


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

using namespace std;

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

  vector<string> sv(n);
  for (int i = 0; i < n; i++) {
    cin >> sv[i];
  }

  sort(sv.begin(), sv.end());

  string ans = "";
  for (int i = 0; i < n; i++) {
    ans += sv[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		
		int sn = 0;
		
		int tmpN = n;
		while(tmpN > 0) {
			sn += tmpN % 10;
			tmpN /= 10;
		}
		
		if(n % sn == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  string S;

  bool bef[30000][10] = {}, aft[30000][10] = {};

  cin >> N >> S;

  for (int i=0; i<N; i++) {
    bef[i][S[i]- '0'] = true;
    for (int j=0; j<10; j++)
      bef[i+1][j] |= bef[i][j];
  }

  for (int i=N-1; i>=0; i--) {
    aft[i][S[i]- '0'] = true;
    if (i > 0)
      for (int j=0; j<10; j++)
        aft[i-1][j] |= aft[i][j];
  }

  set<int> ss;

  for (int i=1; i<N-1; i++) {

    for (int x=0; x<10; x++) {
      for (int y=0; y<10; y++) {
        int z = S[i] - '0';

        if (bef[i-1][x] && aft[i+1][y]) {
          ss.insert(x * 100 + z * 10 + y);
        }
      }
    }
  }

  cout << ss.size() << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int a,b;
  cin >> a >> b;
  
  if (a>=0 && a<b) {
    cout << b-a <<endl;
  }else if (a>=0 && b>0){ cout <<2+a-b<< endl;
        }else if (b<=0 && a<b){ cout << b-a <<endl;
             }else if (a<0 && b<a){ cout << 2+a-b <<endl;
} else{ cout << 1+abs(abs(a)-abs(b)) <<endl;
      }
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define REP(i, x, y)   for(int i = (int)(x); i <= (int)(y); i++)
#define FOR(i, x, y)   for(int i = (int)(x); i <  (int)(y); i++)
#define PER(i ,x, y)  for(int i = (int)(x); i >= (int)(y); i--)
#define CH	         ch = getchar()
#define Exit(...)    printf(__VA_ARGS__), exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI > VII;
typedef PR<int,int> PII;
typedef vector<PII> VPI;
const	int inf=2e9;
const	LL Inf=1e10;
const	int P=1e9+7;
const	int N=100005;

inline LL IN(){
	LL x = 0;
	int ch = 0, f = 0;
	for (CH; ch != -1 && (ch < 48 || ch > 57); CH) f = (ch == '-');
	for (; ch >= 48 && ch <= 57; CH) x = (x << 1) + (x << 3) + ch - '0';
	return f ? (-x) : x;
}
template<typename T> inline int chkmin(T &a, const T &b){if(b < a) return a = b, 1; return 0;}
template<typename T> inline int chkmax(T &a, const T &b){if(b > a) return a = b, 1; return 0;}

void renew(int &x, const int &y){
	x += y;
	if(x >= P) x -= P;
	if(x <  0) x += P;
}

int Pow(int x, LL y, int p){
	int a = 1;
	for (; y; y >>= 1, x = (LL)x * x %p) if(y & 1) a=(LL)a * x%p;
	return a;
}

int W, H;
LL K;
int row = 0, col = 0, S, T, V;
char str[1005][1005], rv[1005][1005];

struct mtx{
	int v[5][5];
}c, e, trs;

mtx operator *(const mtx &a, const mtx &b){
	REP(i, 1, 2) REP(j, 1, 2){
		c.v[i][j] = 0;
		REP(k, 1, 2) c.v[i][j] = (c.v[i][j] + (LL)a.v[i][k] * b.v[k][j]) % P;
	}
	return c;
}

int main(){
	scanf("%d%d%lld", &W, &H, &K);
	if(K == 1){
		printf("1\n");
		return 0;
	}
	REP(i, 1, W) scanf("%s", str[i] + 1);
	REP(i, 1, W) if(str[i][1] == '#' && str[i][H] == '#') row = 1;
	REP(i, 1, H) if(str[1][i] == '#' && str[W][i] == '#') col = 1;
	if(row && col){
		printf("%d\n", 1);
		return 0;
	}
	if(!row && !col){
		int S = 0;
		REP(i, 1, W) REP(j, 1, H) if(str[i][j] == '#') S ++;
		printf("%d\n", Pow(S, K - 1, P));
		return 0;
	}
	if(col){
		REP(i, 1, H) REP(j, 1, W) rv[i][j] = str[j][i];
		swap(H, W);
		memcpy(str, rv, sizeof str);
	}
	REP(i, 1, W){
		REP(j, 1, H) if(str[i][j] == '#') S ++;
		FOR(j, 1, H) if(str[i][j] == '#' && str[i][j + 1] == '#') ++ V;
		if(str[i][1] == '#' && str[i][H] == '#') T ++;
	}
	int res = Pow(S, K - 1, P);
	e.v[1][1] = V, e.v[1][2] = T;
	trs.v[1][1] = S, trs.v[1][2] = 0, trs.v[2][1] = V, trs.v[2][2] = T;
	for(LL t = K - 2; t; t >>= 1, trs = trs * trs) if(t & 1) e = e * trs;
	renew(res, -e.v[1][1]);
	printf("%d\n", res);
	return 0;
}

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

using namespace std;

int main(){
    
    string a;
    getline(cin,a);
    for(int i=0;i<a.length();i++){
        if(isupper(a[i])){ putchar(tolower(a[i]));}
        else{putchar(toupper(a[i]));}
    }
    cout << endl;
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  string S;
  for(int a=1;a<=9;a++){
    for(int b=1;b<=9;b++){
      int sum = a*b;
      if(N==sum){
        S = "Yes";
        break;
      }
    }
  }

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


  return 0;
}


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


int main(){
    int l, i=0, j=0, w[100], min, N;
    int left=0, right=0;
    cin >> N;
    for(i=0; i<N; i++){
        cin >> w[i];
    }

    for(i=0; i<N; i++){
        for(j=0; j<=i; j++){
            left += w[j];
        }
        for(j=i+1; j<N; j++){
            right += w[j];
        }
        if(i == 0) min = abs(left-right);
        else if(min > abs(left-right)) min = abs(left-right);
        left = 0, right = 0;
    }
    std::cout << min << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    
    ll n;
    cin>>n;
    vector<ll> v(n);
    cin>>v;
    
    ll x = 1;
    for(auto it:v){
        if(it == x){
            x++;
        }
    }
    if(x == 1){
        pr(-1);
    }else{
        pr(v.size()-x+1);
    }

 

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a+b)/2 + (a+b)%2 << endl;
    return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	for (int i = 0; i <= x; i++){
		int L = i*2 + (x-i)*4;
		if (L == y){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
}


Measured memory_bytes: 3752
def submit():
    n, m = map(int, input().split())
    
    dislike = [tuple(map(int, input().split())) for _ in range(m)]
    dislike.sort(key=lambda x: x[1])

    cnt = 0
    prev_cut = -1
    for da, db in dislike:
        if da <= prev_cut < db:
            continue
        else:
            cnt += 1
            prev_cut = db - 1

    print(cnt)


submit()
                    

Measured memory_bytes: 61528
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    std::vector<ll> dp(3);
    ll n;
    cin >> n;
    rep(i,0,n){
        ll a,b,c;
        ll p,q,r;
        cin >> a >> b >> c;
        p=max(dp[1],dp[2])+a;
        q=max(dp[0],dp[2])+b;
        r=max(dp[0],dp[1])+c;
        dp[0]=p;
        dp[1]=q;
        dp[2]=r;
        //cout << dp[0] << " " << dp[1] << " " << dp[2] << "\n";
    }
    //cout << dp[0] << " " << dp[1] << " " << dp[2] << "\n";
    cout << max3(dp[0],dp[1],dp[2]);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	printf("%c%c%c\n", toupper(a[0]), toupper(b[0]), toupper(c[0]));
	return 0;
}

Measured memory_bytes: 256
/*  ex2_3
    Rikuta */

#include<stdio.h>

int main(void){

    int N,wh,bl,N2;
    //マス目の一辺の数，白のマス数の入力
    scanf("%d",&N);
    scanf("%d",&wh);
    //マスの数の計算
    N2 = N*N;
    //黒のマス数の計算
    bl = N2 - wh;
    //黒のマス数の出力
    printf("%d\n",bl);
}

Measured memory_bytes: 1724
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int ss;
int d[14];
int wa[14];
int ans;
int main()
{
	cin>>s;
	ss=s.size();
	rep(i,ss)
	{
		if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')d[i]=1;
	}
	rep(i,ss)
	{
		rep2(j,i,ss)
		{
			int flag=1;
			rep2(k,i,j+1)
			{
				if(d[k]==0)flag=0;
			}
			if(flag)
			{
				ans=max(ans,j-i+1);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 998244353;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

bool check(vpii P){
  int now = 0;
  for(auto p:P){
    if(p.first + now < 0)return false;
    now += p.second;
  }
  return true;
}
signed main()
{   
  gearup;
  int n; cin >> n;
  vpii l,r;
  int res = 0;
  rep(i,n){
    string s; cin >> s;
    int f = 0,b = 0; //fが最終的な高さ,bは一番低い高さ
    rep(j,s.size()){
      if(s[j] == '(')f++;
      else f--;
      b = min(f,b);
    }
    if(f>0)l.emplace_back(b,f);
    else r.emplace_back(b-f,-f);
    res += f;
  }
  sort(rall(l));
  sort(rall(r));
  if(check(l) && check(r) && res == 0){
    out("Yes");
  }
  else out("No");
}

Measured memory_bytes: 18884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;

int N;
string s;

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

  vector<vector<ModInt>> dp(N, vector<ModInt>(N, 0));
  rep(i, N) dp[0][i] = 1;

  rep(i, N - 1) {
    if (s[i] == '<') {
      for (int j = N - 2; j >= 0; --j) {
        dp[i + 1][j] = dp[i + 1][j + 1] + dp[i][j + 1];
      }
    } else {
      for (int j = 0; j < N - i - 1; ++j) {
        dp[i + 1][j] = dp[i][j];
        if (j - 1 >= 0) dp[i + 1][j] += dp[i + 1][j - 1];
      }
    }
  }

  cout << dp[N - 1][0] << endl;

  return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void ToInfinity() {
	string S;
	i64 K;
	cin >> S;
	cin >> K;
	bool isOne = true;
	bool hit = false;
	int n = 1;
	for (size_t i = 0; i < S.size(); i++)
	{
		if (S[i] != '1') {
			n = S[i] - '0';
			isOne = false;
			break;
		}
		else if(i + 1 == K){
			break;
		}
	}
	cout << n << "\n";
}
int main() {
	ToInfinity();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


void solve(){
	int n, i;
	cin>>n>>i;
	cout<<n+1-i<<endl;	
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

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

using namespace std;

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    string tmp;
    cin>>tmp;
    if(tmp=="ABC")
        cout<<"ARC"<<endl;
    if(tmp=="ARC")
        cout<<"ABC"<<endl;
}



Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(string S, string T)
        {
            int N = S.Length;
            for (int i = 0; i < N; ++i)
            {
                if (S.Substring(i, N - i) + S.Substring(0, i) == T) { return true; }
            }
            return false;
        }
        static void Main(string[] args)
        {
            string S = Read();
            string T = Read();
            Console.WriteLine(Solve(S, T) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include<iomanip>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
using namespace std;

const int NN=1e6+10;

char str1[100],str2[100];
char str3[200];

int main()
{
    scanf("%s",&str1);
    scanf("%s",&str2);
    int len1=strlen(str1);
    int len2=strlen(str2);
    int k1=0,k2=0;
    for(int i=0;i<len1+len2;i++){
        if(i%2==0){
            str3[i]=str1[k1++];
        }
        else{
            str3[i]=str2[k2++];
        }
    }
    printf("%s\n",str3);
}


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

const ll MOD = 1e9 + 7;
const ll MAX = 1e6;

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

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    
    for(int i = 2 ; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 or k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    
    ll x,y;
    cin >> x >> y;
    
    if((x+y)%3!=0){
        cout << 0 << endl;
        return 0;
    }

    ll steps = (x + y) / 3;
    
    ll i=0,j=0;
    for(i = 0 ; i <= steps; i++){
        j = steps - i;
        if(i + j * 2 == x and j + i * 2 == y) break;
    }
    
    COMinit();
    
    cout << COM(steps,i) << endl;
}



Measured memory_bytes: 23808