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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int a = sc.intarr[0];
            string s = sc.str;

            if(a>= 3200)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
a, b, K = gets.split.map(&:to_i)

(K/2).times do
  b = b + a/2
  a = a/2

  a = a + b/2
  b = b/2
end

if K % 2 == 1 then
  b = b + a/2
  a = a/2
end

print a, " ", b, "\n"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
int main()
{
  int n,x;
  cin>>n>>x;
  int arr[n];
  forn cin>>arr[i];
  int ans[n+1];
  ans[0]=0;
  for(int i=1;i<=n;i++) ans[i]=ans[i-1]+arr[i-1];
  int cnt=0;
  for(int i=0;i<=n;i++) if(ans[i]<=x) cnt++;
  cout<<cnt;
  return 0;
  
   
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int length, width;
    
    std::cin >> length >> width;
    
    if(length >= 1 && length <= 100 && width >= 1 && width <= 100)
    {
        std::cout << length * width << " " << (length * 2) + (width * 2) << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
int main()
{
    int a,b,j,bi,g;
    scanf("%d%d",&a,&b);
    j=a+b;
    bi=a-b;
    g=a*b;
    if(j>=bi&&j>=g)
        printf("%d\n",j);
    else if(bi>=j&&bi>=g)
        printf("%d\n",bi);
    else
        printf("%d\n",g);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()

oder = N
l = [0 for i in range(N)]
r = [0 for i in range(N)]

for i in range(1, N):
  l[i] = l[i-1] + (S[i-1] == 'W')
  r[-i-1] = r[-i] + (S[-i] == 'E')

for i in range(N):
  oder = min(oder, l[i]+r[i])

print(oder)


Measured memory_bytes: 27384
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(str(type(var)) + name +":" + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    W = list(map(int,input().split()))
    asum = [0]
    for i in range(N):
        asum.append(asum[-1] + W[i])
    anss = []
    for i in range(1,N):
        anss.append(abs(asum[-1]-2*asum[i]))
    debug(anss)
    print(min(anss))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38588
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

ll f(ll a, ll b, ll c, ll d) {
  ll ans = a;
  ans -= a/b;
  ans -= a/c;
  ans += a/d;
  //  cout << ans << " " << a << " " << b << " " << c << " " << d << endl;                       
  return ans;
}

ll gcd(ll m, ll n) {
  while(n != 0LL) {
    ll r = m % n;
    m = n; n = r;
  }
  return m;
}

ll lcm(ll m, ll n) {
  return m / gcd(m, n) * n;
}

int main() {
  ll A, B, C, D; cin>>A>>B>>C>>D;
  ll G = lcm(C, D);
  ll ans = f(B, C, D, G) - f(A-1LL, C, D, G) ;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 888
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000
/*
Merge Sort
2019. 5/1
*/
int L[MAX/2+2], R[MAX/2+2];
int cnt;

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

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

int main() {
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, n, 0, n);

    for (i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 6896
n, m = map(int, input().split())
a = [0]*m

l = [0] * (n+1)
for i in range(m):
  a = int(input())
  l[a] = -1

for i in range(n+1):
  if not l[i] == -1:
    if i == 0 or i == 1:
      l[i] = 1
    else:
      l[i] = max(l[i-2], 0) + max(l[i-1], 0)

print(l[-1] % 1000000007)

Measured memory_bytes: 459980
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], b[100010], c[100010];
int main(){
  int n;
  while(cin>>n){
    for(int i=1; i<n; ++i){
        scanf("%d",b+i);
    }
    a[n]=b[n-1];
    a[1]=b[1];
    int sm=0;
    for(int i=n-1; i>=2; --i){
        a[i]=min(b[i], b[i-1]);
    }
    for(int i=1; i<=n; ++i){
        sm+=a[i];
    }
    cout<<sm<<endl;
  }
  return 0;
}




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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    
    vector<int> x(m);
    rep(i, m) cin >> x[i];
    
    sort(x.begin(), x.end());
    
     vector<int> d(m-1); // 次の目標までの距離
    rep(i, m-1) d[i] = x[i + 1] - x[i];
    
    // まず距離を楽な順に並び替える
    // 「コマをn置く = n-1だけしんどい距離を飛ばす」
    // なのでrep(i, (m-1) - (n-1))で楽な(m-1) - (n-1)個の距離だけ全体で移動する
    sort(d.begin(), d.end());
    int cost = 0;
    rep(i, (m-1) - (n-1))
    {
        cost += d[i];
    }
    
    cout << cost << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int calc(int a)
{
	int i,count1 = 0, m = 1;
	for( i = 0 ; m  <= a; i++){
		m *= 10;
		count1 ++;
	}
	return (count1 );
}

int main(void)
{
	int a , b ;
	while (scanf("%d %d",&a,&b) != EOF){
		printf("%d\n", calc(a + b));
	}
	return 0;
}

Measured memory_bytes: 596
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

s=[[1,3,5,7,8,10,12],[4,6,9,11],[2]]
uf=UnionFind(13)
for i in range(len(s)):
    for j in range(len(s[i])):
        uf.union(s[i][0],s[i][j])

x,y=map(int,input().split())
if uf.same(x,y):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include<stdio.h>

typedef struct{
  char mark[2];
  int number;
  int order;
} Card;

int partition(Card *A, int p, int r){
  int i, j, a;
  Card x;

  a = A[r].number;
  i = p - 1;

  for(j = p; j < r; j++){
    if(A[j].number <= a){
      i++;

      x = A[i];
      A[i] = A[j];
      A[j] = x;
    }
  }

  x = A[i + 1];
  A[i + 1] = A[r];
  A[r] = x;

  return i + 1;
}

void quickSort(Card *A, int p, int r){
  int q;

  if(p < r){
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main(){
  Card A[100000];
  int n, i, j, v = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%s %d",A[i].mark, &A[i].number);
    A[i].order = i + 1;
  }

  quickSort(A, 0, n - 1);

  for(i = 0; i < n; i++){
    if(A[i].order > A[i + 1].order && A[i].number == A[i + 1].number){
      v++;
      break;
    }
  }

  if(v == 0) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0; i < n; i++) printf("%s %d\n",A[i].mark, A[i].number);

  return 0;
}

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

#define int long long

int H, W, N;
int sy, sx;
int ty, tx;
string s, t;

signed main() {
  cin >> H >> W >> N;
  cin >> sy >> sx;
  cin >> s >> t;

  bool ok = true; // ハミ出ない

  // 右に行く
  ty = sy, tx = sx;
  for (int i = 0; i < N; i++) {
    // T
    if (s[i] == 'R') tx++;
    if (tx > W) ok = false;

    // A
    if (t[i] == 'L' and tx >= 2) {
      tx--;
    }
  }

  // 左に行く
  ty = sy, tx = sx;
  for (int i = 0; i < N; i++) {
    // T
    if (s[i] == 'L') tx--;
    if (tx <= 0) ok = false;

    // A
    if (t[i] == 'R' and tx <= W-1) {
      tx++;
    }
  }

  // 上に行く
  ty = sy, tx = sx;
  for (int i = 0; i < N; i++) {
    // T
    if (s[i] == 'U') ty--;
    if (ty <= 0) ok = false;

    // A
    if (t[i] == 'D' and ty <= H-1) {
      ty++;
    }
  }

  // 下に行く
  ty = sy, tx = sx;
  for (int i = 0; i < N; i++) {
    // T
    if (s[i] == 'D') ty++;
    if (ty > H) ok = false;

    // A
    if (t[i] == 'U' and ty >= 2) {
      ty--;
    }
  }

  puts(ok ? "YES" : "NO");

  return 0;
}


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

struct LazySegmentTree {
    int size;
    vector<int> node, lazy;

    LazySegmentTree(int n) {
        size = 1;
        while (size < n) size <<= 1;
        node.resize(2 * size, (unsigned int) (1 << 31) - 1);
        lazy.resize(2 * size, -1);
    }

    void eval(int k) {
        if (lazy[k] == -1) return;
        if (k >= size) {
            node[k] = lazy[k];
        } else {
            lazy[2 * k] = lazy[2 * k + 1] = lazy[k];
        }
        lazy[k] = -1;
    }

    void update(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;
        eval(k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] = x;
            eval(k);
        } else {
            int m = (l + r) / 2;
            update(a, b, x, 2 * k, l, m);
            update(a, b, x, 2 * k + 1, m, r);
        }
    }

    int query(int i, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;

        eval(k);
        int m = (l + r) / 2;
        if (k >= size && l == i) return node[k];
        if (l <= i && i < m) return query(i, 2 * k, l, m);
        else return query(i, 2 * k + 1, m, r);
    }
};

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

    int n, q;
    cin >> n >> q;
    LazySegmentTree st(n);
    for (int j = 0; j < q; j++) {
        int type;
        cin >> type;
        if (type == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            st.update(s, t + 1, x);
        } else {
            int i;
            cin >> i;
            cout << st.query(i) << '\n';
        }
    }
}


Measured memory_bytes: 4952
from bisect import bisect_right, bisect_left

N = int(input())
S = input()
W = [i for i, s in enumerate(S) if s == 'W']
E = [i for i, s in enumerate(S) if s == 'E']
m = 10**8
for i in range(N):
    turn_E = bisect_left(W, i)
    turn_W = len(E) - bisect_right(E, i)
    m = min(m, turn_E + turn_W)
print(m)


Measured memory_bytes: 15776
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    int lmdays[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

    ll M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    
    if(lmdays[M1-1] == D1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

}

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

void divide(const string& s, string& s1, string& s2) {
  int n = s.size();
  int brackets = 0;
  for(int i=1; ; ++i) {
    if(s[i] == '(') ++brackets;
    else if(s[i] == ')') --brackets;
    else if(brackets == 0) {
      s1 = s.substr(1, i-1);
      s2 = s.substr(i+1, n-i-2);
      return;
    }
  }
}

string rec(const string& op, const string& s, const string& t) {
  if(s == "" || t == "") {
    if(op == "i") return "";
    else return max(s, t);
  }

  string s1, s2, t1, t2;
  divide(s, s1, s2);
  divide(t, t1, t2);

  return '(' + rec(op, s1, t1) + ',' + rec(op, s2, t2) + ')';
}

int main() {
  string op, strL, strR;

  while(cin >> op >> strL >> strR)
    cout << rec(op, strL, strR) << endl;

  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s[10] ={"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"};
	int n;
	while(cin >> n, (n!=-1))
	{
		string now = "0000000";
		for(int i = 0; i < n; i++)
		{
			int x;
			cin >> x;
			string change = "0000000";
			for(int j = 0; j < 7; j++)
			{
				if(s[x][j] != now[j])
				{
					change[j] = '1';
				}
			}
			cout << change << endl;
			now = s[x];
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 1
/*------------------------------------------------------------*/
int k=0;
int n;
int a[100];
void dfs(int x,bool ans){
	if(x==n+1){
		k+=ans;
		return ;
	}
	dfs(x+1,ans||(!((a[x]-1)%2)));
	dfs(x+1,ans||(!(a[x]%2)));
	dfs(x+1,ans||(!((a[x]+1)%2)));
}
int main(){
	in(n);
	FOR(i,1,n)in(a[i]);
	dfs(1,0);
	out(k);
}

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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

}

int main()
{

    textIO();
    fastIO();
    long long a;
    long double b;
    cin >> a >> b;
    b=round(b*100);

    a*=b;

    cout << a/100 << '\n';

    return 0;
}


Measured memory_bytes: 3788
#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()

const ll INF = 1e18;

int N, W;
vector<int> w, v;

int main() {
  cin >> N >> W;
  w.resize(N), v.resize(N);

  rep(i, N) cin >> w[i] >> v[i];

  int V = accumulate(all(v), 0);
  vector<ll> dp(V + 1, INF);
  dp[0] = 0;

  rep(i, N) for (int j = V; j >= 0; --j) {
    if (j - v[i] >= 0) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
  }

  for (int v = V; v >= v; --v) {
    if (dp[v] <= W) {
      cout << v << endl;
      return 0;
    }
  }

  return 0;
}


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

class Answer
{
public:
	Answer(){day = 10; year = 365;}
	
	int N;	//??\???
	int day;
	int year;
	unsigned long long count(int cnt);	//??¨??¢?´¢(???)
	void set();	//??\???
	void OutPut();	//???????????????
	
	bool empty();	//???????????¶?????????
	bool ans();	//?§£???
};

unsigned long long Answer::count(int cnt)
{
	if( cnt < 0)
		return 0;
	
	else if(cnt == 0)
		return 1;
	
	return count(cnt - 1) + count(cnt - 2) + count(cnt - 3);
}

void Answer::OutPut()
{
	if( N == 0 )
		return;
	int ans_ = 1;	//??????????????´???
	ans_ += (count( N )) / (day * year);	//??\???
	
	cout << ans_ << endl;;
}

void Answer::set()
{
	cin >> N;
}

bool Answer::empty()
{
	if( N == 0 )return false;
	else return true;
}

bool Answer::ans()
{
	set();
	OutPut();
	return empty();
}

int main()
{
	Answer ans;

	while( ans.ans() );
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>p(n),c(n),rev(n),local_solutions;
    REP(i,n){
        cin >> p[i];
        p[i]--;
        rev[p[i]]=i;
    }
    bool all_negative = true;
    REP(i,n){
        cin >> c[i];
        if(c[i] >= 0){
            all_negative = false;
        }
    }
    if(all_negative){
        SORT(c);
        reverse(ALL(c));
        cout << c[0] << endl;
        return 0;
    }


    REP(i,n){
        int now = i;
        ll sum = 0;
        ll summax=0;
        int period = 0;
        do{
            now = p[now];
            sum +=c[now];
            summax = max(summax,sum);
            period++;
        }while(now!=i);
        if(sum > 0){
            ll local_solution = 0;
            local_solution+=(k / period)*sum;
            now = i;
            REP(i,k%period){
                now = p[now];
                local_solution+=c[now];
            }
            ll answer = 0;
            REP(i,period){
                answer=max(answer,local_solution);
                local_solution -= c[now];
                now = rev[now];
            }
            local_solutions.push_back(answer);
        }else{
            local_solutions.push_back(summax);
        }
    }
    SORT(local_solutions);
    reverse(ALL(local_solutions));
    cout << local_solutions[0] << endl;

    return 0;
}

Measured memory_bytes: 3852
#include<stdio.h>
int main(void)
{
	int n,b[100],a[101],g=0,i;
	scanf("%d", &n);
	for(i=0; i<n-1; i++)
	scanf("%d", &b[i]);
	a[0]=b[0];
	a[1]=b[0];
	for(i=1; i<n-1; i++)
	{
		if(a[i]>b[i])
		a[i]=b[i];
		a[i+1]=b[i];
	}
	for(i=0; i<n; i++)
	g+=a[i];
	printf("%d\n", g);
	
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

gp_hash_table<int, int> dist[101010];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<gp_hash_table<int, vector<int>>> G(N);
    rep(i,M) {
        int u,v,c; cin >> u >> v >> c;
        --u; --v;
        G[u][c].emplace_back(v);
        G[v][c].emplace_back(u);
    }

    dist[0][0] = 0;
    deque<pii> deq;
    deq.emplace_back(0,0);
    while (!deq.empty()) {
        int v,c;
        tie(v,c) = deq.front(); deq.pop_front();
        if (c) {
            for (auto nv : G[v][c]) {
                if (dist[nv].find(c)!=dist[nv].end() and dist[nv][c] <= dist[v][c]) continue;
                dist[nv][c] = dist[v][c];
                deq.emplace_front(nv,c);
            }
            if (dist[v].find(0)!=dist[v].end() and dist[v][0] <= dist[v][c]) continue;
            dist[v][0] = dist[v][c];
            deq.emplace_front(v,0);
        } else {
            for (auto i : G[v]) {
                if (dist[v].find(i.first)!=dist[v].end() and dist[v][i.first] <= dist[v][0] + 1) continue;
                dist[v][i.first] = dist[v][0] + 1;
                deq.emplace_back(v,i.first);
            }
        }
    }

    cout << (dist[N-1].find(0)!=dist[N-1].end() ? dist[N-1][0] : -1) << ln;
}

Measured memory_bytes: 122512
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

lld modInv(lld x, lld m)
{
	return power(x,m-2,m);
}

lld *fact, *inv, *fact_inv;
void nCrModInit(lld n=500000, lld m=mod)
{
	fact = new lld[n+7];
	fact[0]=1;
	FORG(i,1,n+1)
		fact[i]=i*fact[i-1]%m;

	//Niche sbko comment krdo agar kaam na aae to(agar jyada queries na ho to). :D
	inv = new lld[n+7];
	fact_inv = new lld[n+7];
	
	inv[1]=1;
	fact_inv[0]=fact_inv[1]=1;

	
	FORG(i,2,n+1)
		inv[i]=(m-m/i)*inv[m%i]%m;

	FORG(i,1,n+1)
		fact_inv[i]=inv[i]*fact_inv[i-1]%m;
}

lld nCrMod(lld n=500000, lld r=1, lld m=mod)
{
	//return (fact[n]*(modInv(fact[r],m)%m)*(modInv(fact[n-r],m))%m)%m;
	return (fact[n]*fact_inv[r]%m * fact_inv[n-r]%m)%m; 
}

void swagWaalaFunction()
{
	lld n,m,ans=0;
	cin>>n>>m;

	if(m>=2)
	ans+=nCrMod(m,2,mod);
	if(n>=2)
	ans+=nCrMod(n,2,mod);
	cout<<ans;
	return;
}

int main()
{
    SPEEDUP;
    nCrModInit();
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();

 	return 0;
}

Measured memory_bytes: 12032
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=1e5+10;
const int inf=0x3f3f3f;
int v[110];
long long w[110];
long long dp[maxn];
int main()
{
	int n,m;
	cin>>n>>m;
	int ans=0;
	for(int i=1;i<=n;++i)
	 cin>>v[i]>>w[i];
	memset(dp,inf,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=100000;j>=w[i];--j)
		 dp[j]=min(dp[j],dp[j-w[i]]+v[i]);
	}
	for(int i=1;i<=1e5;++i)
	{
		if(dp[i]<=m)
		 ans=max(ans,i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4316
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

const int MaxN = 100;
const int MaxM = 100;

const int INF = 0x3f3f3f3f;

int n, m;
char s[MaxN + 1][MaxM + 2];

int sum[MaxN + 1][MaxM + 1];

int f[MaxN + 1][MaxM + 1][MaxM + 1];

int res = 0;

inline int query(int x1, int y1, int x2, int y2)
{
	x1 = max(x1, 1), y1 = max(y1, 1);
	x2 = min(x2, n), y2 = min(y2, m);
	return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);

	int ex, ey;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (s[i][j] == 'E')
				ex = i, ey = j;
			else if (s[i][j] == 'o')
				sum[i][j] = 1;
		}

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];

	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= m; ++j)
			fill(f[i][j], f[i][j] + m + 1, -INF);

	f[0][0][0] = 0;
	for (int u = 0; u <= ex - 1; ++u)
		for (int d = 0; d <= n - ex; ++d)
		{
			int x1 = max(ex - u, 1 + d);
			int x2 = min(ex + d, n - u);
			if (x1 > x2)
				continue;

			for (int l = 0; l <= ey - 1; ++l)
				for (int r = 0; r <= m - ey; ++r)
				{
					int y1 = max(ey - l, 1 + r);
					int y2 = min(ey + r, m - l);
					if (y1 > y2)
						continue;

					relax(res, f[d][l][r]);

					if (u + d < n - ex)
						relax(f[d + 1][l][r], f[d][l][r] + query(ex + d + 1, y1, ex + d + 1, y2));
					if (l + r < ey - 1)
						relax(f[d][l + 1][r], f[d][l][r] + query(x1, ey - l - 1, x2, ey - l - 1));
					if (l + r < m - ey)
						relax(f[d][l][r + 1], f[d][l][r] + query(x1, ey + r + 1, x2, ey + r + 1));
					if (u + d < ex - 1)
						f[d][l][r] += query(ex - u - 1, y1, ex - u - 1, y2);
				}
		}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4352
*D, = open(0)
n, m = map(int, D[0].split())
edges = [list(map(int, it.split())) for it in D[1:]]
edges = sorted(edges, key=lambda x:x[1])

cnt = 0
while len(edges)>0:
    cnt += 1
    new_edges = []
    bridge = edges[0][1]
    for it in edges:
        if it[0]>=bridge:
            new_edges.append(it)
            
    edges = new_edges
print(cnt)

Measured memory_bytes: 128776
#include <cstdio>
#include <utility>
#include <string>
#include <cctype>
#include <stack>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
bool scan(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef vo

int decode() {
	string s;
	scan(s);
	int n = 0;
	for (auto i = s.begin(); i != s.end(); i++) {
		int d = isdigit(*i) ? *i++ - '0' : 1;
		switch (*i) {
		case 'm': d *= 1000; break;
		case 'c': d *= 100; break;
		case 'x': d *= 10; break;
		}
		n += d;
	}
	return n;
}

stack<char> encode(int n) {
	stack<char> s;
	static const string suffix = "ixcm";
	for (auto i = suffix.begin(); n; i++, n /= 10) {
		char d = n % 10;
		if (d) {
			s.push(*i);
			if (d > 1)
				s.push(d + '0');
		}
	}
	return move(s);
}

int main() {
	for (int n = in(); n--;) {
		int a = decode();
		for (stack<char> s = encode(a + decode()); !s.empty();s.pop())
			out(s.top());
		out('\n');
	}
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr long long LINF=334ll<<53; constexpr int INF=15<<26; constexpr long long MOD=1E9+7;

long long modpow(long long a, long long n,long long mod=MOD){
    long long i=1,ret=1,p=a;
    while(i<=n){
        if(i&n) ret=(ret*p)%mod;
        i=(i<<1);
        p=(p*p)%mod;
    }
    return ret;
}

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

    int n,k;
    cin >> n >> k;
    if(k==1){cout << 1 <<"\n"; return 0;}

    vector<vector<LL>> dp (n+1,vector<LL>(n+1));
    vector<LL> fac(n*k+1),inv(n*k+1);
    fac[0]=1;
    for(int i=1; i<=n*k; ++i){
         fac[i]=fac[i-1]*i%MOD;
     }
     inv[n*k]=modpow(fac[n*k],MOD-2);
     for(int i=n*k-1; i>=0; --i){
         inv[i]=inv[i+1]*(i+1)%MOD;
     }
     dp[0][0]=1;
     for(int i=1; i<=n; ++i){
        dp[i][0]=1;
         for(int j=1; j<=i; ++j){
             dp[i][j]=(dp[i-1][j]+((dp[i][j-1]*fac[n*k-i-(j-1)*(k-1)-1]%MOD)*inv[k-2]%MOD)*inv[n*k-i-(j-1)*(k-1)-k+1])%MOD;
         }
     }

     cout <<dp[n][n]*fac[n]%MOD<<"\n";
    return 0;
}



Measured memory_bytes: 94080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll n , m;
  cin >> n >> m;

  ll ans = 0;
  if (m / 2 >= n) {
    ans += n;
    m -= 2 * n;
    ans += (m / 4);
  } else {
    ans = m / 2;
  }

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


Measured memory_bytes: 3584
#include <iostream>
#include <vector>

void printVector(std::vector<int> v) {
    for (auto it = v.begin(); it != v.end(); it++) {
        std::cout << *it << std::endl;
    }
}

int main() {
    long DOTS_COUNT, DISTANCE;
    long x, y;
    int total = 0;
    std::vector<long> X;
    std::vector<long> Y;

    std::cin >> DOTS_COUNT >> DISTANCE;
    for (int i = 0; i < DOTS_COUNT; i++) {
        std::cin >> x >> y;
        X.push_back(x);
        Y.push_back(y);
    }
    for (auto itX = X.begin(), itY = Y.begin();
         itX != X.end() && itY != Y.end();
         itX++, itY++) {
        if (*itX * *itX + *itY * *itY <= DISTANCE * DISTANCE) {
            total++;
        }
    }
    std::cout << total << std::endl;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 6292
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    int r, g, b;
    
    cin >> r >> g >> b;
    
    auto number = 100 * r + 10 * g + b;
    
    printf("%s\n", number % 4 == 0 ? "YES" : "NO");
    
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a > 0) cout << "Positive\n";
    else if (b < 0) {
        if ((b - a + 1) & 1) cout << "Negative\n";
        else cout << "Positive\n";
    } else cout << "Zero\n";
    return 0;
}

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

int n;
vector<int> arr(100004, 0);
vector<int> memo(100004, -1);

int cost(int i) {
	if(i>=n-1) return 0;
	if(i==n-2) return abs(arr[n-2]-arr[n-1]);

	if(memo[i]==-1)
	{
		int a = abs(arr[i+1]-arr[i]) + cost(i+1);
		int b = abs(arr[i+2]-arr[i]) + cost(i+2);
		memo[i] = min(a, b);
	}
	return memo[i]; 
}


int main() {

	cin >> n;
	for(int i=0; i<n; ++i) cin >> arr[i];

	cout << cost(0) << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
	
    int n;
    cin >> n;
    long long ans=0;
    rep(i,n){
        if(i%3!=0&&i%5!=0) ans +=i;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3532
import itertools
n,m = map(int,input().split())
k = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
s = []
for i in range(n):
    s.append(i)
count = 0
for i in range(n+1):
    for item in itertools.combinations(s, i):
        li = [0] * m
        onoff = [0]*n
        for j in item:
            onoff[j] = 1
        for k_i in range(m):
            c = 0
            for k_j in range(k[k_i][0]):
                if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
            if c % 2 == p[k_i]:
                li[k_i] = 1
        if all(li):
            count += 1
print(count)

Measured memory_bytes: 9104
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    string abc;
    rep(i,26){
        abc.push_back('A'+i);
    }
    rep(i,26){
        abc.push_back('A'+i);
    }
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,s.size()){
        int now=s[i]-'A';
        //cout<<now<<endl;
        now+=n;
        s[i]=abc[now];
    }
    cout<<s<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void C();

int main()
{
	C();
	fflush(stdout);
	return 0;
}

static int wdfs(std::vector<int>& row, std::vector<int>& col,
	std::vector<std::vector<int>>& cross, int noww,
	std::vector<bool>& hUse,
	std::vector<bool>& wUse,
	int total, int H, int W, int K)
{
	int val = 0, ans = 0;
	if (noww >= W) {
		val = 0;
		for (int h = 0; h < H; h++) {
			if (hUse[h]) {
				val += row[h];
			}
		}
		for (int w = 0; w < W; w++) {
			if (wUse[w]) {
				val += col[w];
			}
		}
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if (hUse[h] && wUse[w]) {
					val -= cross[h][w];
				}
			}
		}
		if ((total - val) == K) {
			ans = 1;
		}
	}
	else {
		for (int i = 0; i <= 1; i++) {
			wUse[noww] = i;
			ans += wdfs(row, col, cross, noww + 1, hUse, wUse, total, H, W, K);
		}
	}
	return ans;
}

static int hdfs(std::vector<int>& row, std::vector<int>& col,
	std::vector<std::vector<int>>& cross, int nowh,
	std::vector<bool>& hUse,
	std::vector<bool>& wUse,
	int total, int H, int W, int K)
{
	int ans = 0;
	if (nowh >= H) {
		ans = wdfs(row, col, cross, 0, hUse, wUse, total, H, W, K);
	}
	else {
		for (int i = 0; i <= 1; i++) {
			hUse[nowh] = i;
			ans += hdfs(row, col, cross, nowh + 1, hUse, wUse, total, H, W, K);
		}
	}
	return ans;
}

static void C()
{
	int H, W, K;
	getval(H, W, K);

	std::vector<std::string> grid(H);
	for (int h = 0; h < H; h++) {
		getval(grid[h]);
	}

	int total = 0;
	std::vector<int> row(H, 0), col(W, 0);
	std::vector<std::vector<int>> cross(H, std::vector<int>(W, 0));
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (grid[h][w] == '#') {
				row[h]++;
				col[w]++;
				cross[h][w] = 1;
				total++;
			}
		}
	}
	std::vector<bool> hUse(H, false), wUse(W, false);
	printf("%d\n", hdfs(row, col, cross, 0, hUse, wUse, total, H, W, K));
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define INFLL 1000000000000000000
#define eps 0.000000000001
#define mod 1000000007
template<class C> void mini(C&a, C b){ a=min(a, b);}
template<class C> void maxi(C&a, C b){a=max(a,b);}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//
/*
dp[i][j] = maneras de resolver el problema para permutaciones de 1..i, tal que el ultimo elemento es j.
*/
int n;
string s;

int main () {
	//FIN
	cin >> n >> s;
	vvll dp(n+1,vll(n+1));
	dp[1][1] = 1;
	for (int i = 2; i <= n; i++) {
		vll prefix_sum(n+1);
		prefix_sum[1] = dp[i-1][1];
		for(int k=2; k<=n; k++) {
			prefix_sum[k] = (prefix_sum[k-1] + dp[i-1][k]) % mod;
		}
		for (int j = 1; j <= i; j++) {
			if(s[i-2] == '<') {
				// dp[i][j] es la suma de los dp[i-1][k] con k menor a j.
				dp[i][j] = prefix_sum[j-1]; dp[i][j] %= mod;
			}
			else {
				// dp[i][j] es la suma de los dp[i-1][k] con k mayor o igual a j.
				dp[i][j] = prefix_sum[i] - prefix_sum[j-1]; dp[i][j] = modulo(dp[i][j], mod);
			}
		}
	}
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		res += dp[n][i]; res %= mod;
	}
	cout << res << "\n";

	return 0;
}










Measured memory_bytes: 73712
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll fp(ll x)
{
	ll res = x * x * x * x * x;
	return res;
}

void solve()
{
	ll x;
	cin >> x;
	for (ll i = -1000; i < 1001; i++)
	{
		for (ll j = -1000; j < 1001; j++)
		{
			ll temp = fp(i) - fp(j);
			if (temp == x)
			{
				db(temp);
				cout << i << " " << j << ln;
				return;
			}
		}
	}
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<ll,ll>
#define  F   first
#define  S   second
const int N=2e3+3;
pi a[N];
ll n,d[N][N];
ll go(ll l,ll r)
{
    if(l>r)
    {
        return 0ll;
    }
    else if(d[l][r]!=-1)
    {
        return d[l][r];
    }
    ll i=n-(r-l+1);
    ll lv=abs(a[i].S-l)*a[i].F+go(l+1ll,r);
    ll rv=abs(a[i].S-r)*a[i].F+go(l,r-1ll);
    return d[l][r]=max(lv,rv);
}
int main()
{
    ft
    cin>>n;
    for(ll m,i=0ll;i<n;i++)
    {
        cin>>m;
        a[i]={m,i};
    }
    sort(a,a+n);
    reverse(a,a+n);
    memset(d,-1,sizeof(d));
    cout<<go(0ll,n-1ll)<<"\n";
    return 0;
}

Measured memory_bytes: 35112
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF 0x3f3f3f3f
#define MAX (1<<20)
#define MOD 1000000007
#define i64 long long
#define all(x) (x).begin() , (x).end()
#define sz(x) (int)(x).size()
#define ii pair<i64, i64>
#define fs first
#define sc second
#define eb emplace_back
#define vi vector<i64>
#define vvi vector<vi>
#define vii vector<ii>
#define vvii vector<vii>
#define lsb(x) ((x) & (-x))
#define gcd(x,y) __gcd((x),(y))

using namespace std;

map<ii, i64> f;
vii dir;
vi pot2;
i64 n, xz, yz, zz, a, b, ans, fator;

int main(){_
    cin >> n;
    
    pot2.eb(1);
    for (int i=n; i--;){
        pot2.eb((2*pot2.back())%MOD);
    }

    dir = vii(n);
    for (auto &[x, y] : dir){
        cin >> x >> y;

        if (!x) {
            if (!y){
                ++zz;
                continue;
            }else{
                ++xz;
            }
        }else if (!y){
            ++yz;
        }
        
        if (x<0){
            x = -x; y = -y;
        }

        i64 mdc = abs(gcd(x, y));
        x /= mdc; y/=mdc;
        
        ++f[{x,y}];
    }
    
    ans = 1LL;
    
    fator = (pot2[xz] + pot2[yz] - 1LL + MOD)%MOD;
    ans = (ans * fator) % MOD;

    for (auto [p, c] : f){
        i64 x = p.fs, y=p.sc;

        if (!x || !y || !c) continue;

        a = (y > 0 ? y : -y);
        b = (y > 0 ? -x : x);

        fator = (pot2[c] + pot2[f[{a,b}]] - 1LL + MOD) % MOD;
        ans = (ans * fator) % MOD;

        f[{a,b}] = 0;
    }


    cout << (ans-1LL+zz+MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 32900
k,c,i=11,j,y,z,p[2001],t[11][2000];f(int*x){z=*1[&x]-*x;}main(g){for(scanf("%*d%d",&k);~scanf("%d%d",&c,&g);)t[g][j++]=c;for(;--i;)for(qsort(t+i,j,4,f),z=k;z;--z)for(c=g=0;y=t[i][c];z>c++?p[z]=fmax(p[z],p[z-c]+g):0)g+=y+c+c;z=!printf("%d\n",p[k]);}

Measured memory_bytes: 560
#include "bits/stdc++.h"
using namespace std;

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

  int a[n];

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

  int jud = 0;
  for (int i = n-1; i >= -1; i -= 2) {
    if(i == n-1) {
      printf("%d", a[i]);
      continue;
    }
    if (i == -1) {
      printf(" %d", a[0]);
      jud = 1;
      break;
    }
    printf(" %d", a[i]);
  }
  
  if (jud == 1) {
    for (int i = 2; i < n; i += 2) {
	printf(" %d", a[i]);
    }
  } else {
    for (int i = 1; i < n; i += 2) {
	printf(" %d", a[i]);
    }
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 2944
while True:
  n,m,a = tuple(map(int,input().split()))
  if n==0 and m==0 and a == 0:
    break
  l = []
  max_h = 0

  for i in range(m):
    h,p,q = tuple(map(int,input().split()))
    if max_h < h:
      max_h = h
    l.append([h,p,q])
  pos = max_h
  while pos > 0:
    for i in l:
      if i[0]==pos:
        if a == i[2]:
          a = i[1]
        elif a == i[1]:
          a = i[2]
    pos -= 1
  print(a)

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

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

    int N, M;
    cin >> N >> M;

    vector<pair<long long, long long> > AB;
    long long a, b;
    for (int i=0; i<N; ++i) {
        cin >> a >> b;
        AB.push_back(make_pair(a, b));
    }
    sort(AB.begin(), AB.end());

    long long ans = 0;
    for (int i; i < AB.size(); ++i) {
        ans += AB[i].first * min((long long)M, AB[i].second);
        M -= min((long long)M, AB[i].second);
        if (M == 0) break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//
ll N /*値*/;
bool prime[114514];
void eratosthenes() {
  REP(i, N) prime[i] = 1;
  prime[0] = prime[1] = 0;
  REP(i, N) {
    if (prime[i]) {
      for (int j = i + i; j < N; j += i) {
        prime[j] = 0;
      }
    }
  }
}
ll imos[114514];
int main() {
  ll q;
  cin >> q;
  N = 114513;
  eratosthenes();
  REP(i, 114513) {
    if (i % 2 && prime[i] && prime[(i + 1) / 2]) {
      imos[i]++;
    }
    if (i) {
      imos[i] += imos[i - 1];
    }
  }
  REP(i, q) {
    ll l, r;
    cin >> l >> r;
    cout << imos[r] - imos[l - 1] << endl;
  }
}


Measured memory_bytes: 1664
using System;
using System.Linq;
namespace ABC153B
{
    public class EmptyClass
    {
        public static void Main(string[] args)
        {
            long[] n = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            Console.WriteLine(arr.Sum() >= n[0] ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 16992