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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

typedef struct UnionFind{
	vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
	vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

	UnionFind(int N){/*最初はすべてが根であると初期化*/
		REP(i,0,N){
			par.push_back(i);
			size.push_back(1);
		}
	}

	lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unite(lli x,lli y){/*xとyの併合*/
		lli rx = root(x);
		lli ry = root(y);
		if(rx == ry)return;
		par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
		lli resize = size[rx] + size[ry];
		size[rx] = resize;
		size[ry] = resize;
	}

	bool same(lli x,lli y){
		lli rx = root(x);
		lli ry = root(y);
		return rx == ry;
	}

	lli getSize(lli x){
		lli rx = root(x);
		return size[rx];
	}
};

vector<vector<lli>> friends;
lli data[100100];

signed main(){

	lli n,m,k;
	cin>>n>>m>>k;

	UnionFind unions(n);
	friends.resize(n);

	REP(i,0,m){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		friends[a].push_back(b);
		friends[b].push_back(a);
		unions.unite(a,b);
	}

	if(DEBUG)cout<<"unko"<<endl;
	REP(i,0,n)data[i]=unions.getSize(i);

	if(DEBUG)cout<<"unko"<<endl;
	REP(i,0,n){
		data[i] -= friends[i].size();
	}

	if(DEBUG)cout<<"unko"<<endl;
	REP(i,0,k){
		lli c,d;
		cin>>c>>d;
		c--,d--;
		if(unions.same(c,d)){
			data[c]--;
			data[d]--;
		}
	}

	REP(i,0,n){
		cout<<data[i]-1<<" ";
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 9836
import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
 class Main{
    static int h,w;
    static char arr[][];
    static int dr[]={1,0,-1,0};
    static int dc[]={0,1,0,-1};
    static int mem[][];
    static int status[][]; // 0 for white, 1 for grey, 2 for black
    public static void bfs(){
        ArrayDeque<Integer> rq=new ArrayDeque<>();
        ArrayDeque<Integer> cq=new ArrayDeque<>();
        rq.addLast(1);
        cq.addLast(1);
        mem[1][1]=1;
        while(!rq.isEmpty()){
            int r=rq.removeFirst();
            int c=cq.removeFirst();
            for(int i=0;i<4;i++){
                int R=dr[i]+r;
                int C=dc[i]+c;
                if(R>=1 && R<=h && C>=1 && C<=w && status[R][C]==0 && arr[R][C]!='#'){
                    rq.addLast(R);cq.addLast(C);
                    status[R][C]=1;
                    mem[R][C]=mem[r][c]+1;
                }
            }
            status[r][c]=2;
        }//end of while
    }
    public static void main(String[] args) {
        MyScanner sc=new MyScanner();
        h=sc.ni();
        w=sc.ni();
        arr=new char[h+1][w+1];
        mem=new int[h+1][w+1];
        status=new int[h+1][w+1];
        int hash=0;
        for(int i=1;i<=h;i++){
            String s=sc.next();
            for(int j=1;j<=w;j++){
                if(s.charAt(j-1)=='#') hash++;
                arr[i][j]=s.charAt(j-1);
            }
        }
        bfs();
        if(mem[h][w]==0) System.out.println(-1);
        else{
            int ans=h*w-hash-mem[h][w];
            System.out.println(ans);
        }
    }

    private static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int ni() {
          return Integer.parseInt(next());
      }
      float nf() {
        return Float.parseFloat(next());
      }
      long nl() {
          return Long.parseLong(next());
      }

      double nd() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

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

using ll = long long int;

const int MAX_N = (int)1e5 + 5;
const ll MOD = (ll)1e9 + 7;

int n;
int a[MAX_N];

int times[MAX_N];
int indexs[MAX_N];

int l, r;

/////////////////////////////////////////////////////////////
ll fact[MAX_N];
ll inv[MAX_N];
ll factinv[MAX_N];

void initFact(int m) {
  inv[1] = fact[0] = factinv[0] = 1;
	for (int i = 2; i <= m; i++) inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
	for (int i = 1; i <= m; i++) fact[i] = fact[i - 1] * i % MOD;
	for (int i = 1; i <= m; i++) factinv[i] = factinv[i - 1] * inv[i] % MOD;
}

ll C(int n, int r) {
  if (r > n) return 0;
	return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
}
/////////////////////////////////////////////////////////////

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n + 1; ++i) {
    scanf("%lld", &a[i]);
  }

  for (int i = 0; i <= n; ++i) {
    times[a[i]] += 1;
    if (times[a[i]] >= 2) {
      l = indexs[a[i]];
      r = i;
    }
    indexs[a[i]] = i;
  }

  initFact(n + 1);

  for (int i = 1; i <= n + 1; ++i) {
    // cout << C(n + 1, i) << "-" << C(l + n - r, i - 1) << endl;
    ll ans = (C(n + 1, i) - C(l + n - r, i - 1)) % MOD;
    if (ans < 0) ans += MOD;
    printf("%lld\n", ans);
  }

  return 0;
}

Measured memory_bytes: 4736
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<set>
#include<string>
#include<climits>
using namespace std;

static int N;

int main()
{
	while (scanf("%d", &N) != EOF)
	{
		string s = "";
		do
		{
			s += N % 10 + '0';
			N /= 10;
		} while (N);
		reverse(s.begin(), s.end());
		bool flag = false;
		for (int i = 0; i < s.length();)
		{
			int j = i + 1;
			while (j < s.length() && s[j] == s[i]) ++j;
			if (j - i >= 3)
			{
				flag = true;
				break;
			}
			else
			{
				++i;
			}
		}
		printf(flag ? "Yes\n" : "No\n");
	}
	return 0;
}

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

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

suma = 0
if N >= M:
    print(0)
else:
    for i in range(M-N):
        suma += diff[i]
    print(suma)


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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}


int main(){
    string S;
    cin >> S;
    int N = S.size();
    bool uniq = true;
    for(int i=0; i<N; i++) if(S[0] != S[i]) uniq = false;
    if(uniq){
        cout << 1 << endl;
        return 0;
    }

    if(N <= 3){
        set<string> st;
        st.insert(S);
        queue<string> que;
        que.push(S);
        while(que.size()){
            string s = que.front(); que.pop();
            for(int i=0; i<N-1; i++) if(s[i] != s[i+1]){
                char c = 'a';
                while(c == s[i] || c == s[i+1]) c++;
                string s2 = s;
                s2[i] = s2[i+1] = c;
                if(!st.count(s2)){
                    st.insert(s2);
                    que.push(s2);
                }
            }
        }
        cout << st.size() << endl;
        return 0;
    }

    static int64_t dp[200001][4][3][2];
    dp[0][3][0][0] = 1;
    for(int i=0; i<N; i++) for(int p=0; p<4; p++) for(int r=0; r<3; r++) for(int k=0; k<2; k++) for(int a=0; a<3; a++){
        add(dp[i+1][a][(r+a)%3][k|(p==a)], dp[i][p][r][k]);
    }
    int R = 0, dub = 0;
    for(int i=0; i<N; i++){
        R = (R+S[i]-'a') % 3;
        if(i && S[i-1] == S[i]) dub = 1;
    }
    int64_t ans = 1-dub;
    for(int p=0; p<4; p++) add(ans, dp[N][p][R][1]);
    cout << ans << endl;
}

Measured memory_bytes: 38020
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

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

int main(){
	ll a,b;
	for(;cin>>a>>b;){
		cout<<gcd(a,b)<<" "<<a*b/gcd(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N,M=map(int,input().split())
S=input() # 元の双六
T=S[::-1] # 逆順の双六
l=[]

f=True
i=0 # ゴールから辿る
while i<N:
    t=T[i+1:i+M+1][::-1] # 逆順の双六で今いるマスの1~Mマス先（元の双六ではM~1マス前）
    # print(t) #DB
    if '0' not in t: # 通常のマスがない場合
        f=False
        break
    else: # 通常のマスがある場合
        x=min(M-t.index('0'),len(t)) # 元の双六で，最も手前にある通常のマスまでのマス数
        # print(x) #DB
        l.append(x)
        i+=x
# print(l) #DB

if not f:
    print('-1')
else:
    print(*l[::-1],sep=' ')

Measured memory_bytes: 48492
n = int(input())
d = {
	'AC': 0,
	'WA': 0,
	'TLE': 0,
	'RE': 0
}

for i in range(n):
  	d[input()] += 1

print('{} x {}'.format('AC', d['AC']))
print('{} x {}'.format('WA', d['WA']))
print('{} x {}'.format('TLE', d['TLE']))
print('{} x {}'.format('RE', d['RE']))

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=4005,INF=1<<30;
//const ll INF=1LL<<60;

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

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

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

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

const double eps=1e-10;

bool dp[MAX][3][3];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<int> S={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int N;cin>>N;
    N--;
    cout<<S[N]<<endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b;

  scanf("%d",&a);
  scanf("%d",&b);

  if(a>b)
    printf("a > b\n");

  if(a<b)
    printf("a < b\n");

  if(a==b)
    printf("a == b\n");

  return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    int[] m = new int[12+1];
    m[1] = 1;
    m[3] = 1;
    m[5] = 1;
    m[7] = 1;
    m[8] = 1;
    m[10] = 1;
    m[12] = 1;
    
    m[4] = 2;
    m[6] = 2;
    m[9] = 2;
    m[11] = 2;
    
    m[2] = 3;
    
    System.out.println(m[x] == m[y] ? "Yes" : "No");
  }
}

Measured memory_bytes: 21716
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()
aa.sort()

def product():
    if N%3 == 0:
        ax = aa[0:N//3]
        bx = aa[N//3:N//3*2]
        cx = aa[N//3*2:]
        if len(set(ax)) != 1:
            return 'No'
        if len(set(bx)) != 1:
            return 'No'
        if len(set(cx)) != 1:
            return 'No'
        if ax[0]^bx[0] != cx[0]:
            return 'No'
        if bx[0]^cx[0] != ax[0]:
            return 'No'
        if cx[0]^ax[0] != bx[0]:
            return 'No'
        return 'Yes'

    else:
        for a in aa:
            if a != aa[0]:
                return 'No'
        return 'Yes'



print(product())


Measured memory_bytes: 63020
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    int ans = 0;
    cin >> a >> b >> c >> d;
    if(b <= c || d <= a){
        ans = 0;
    }
    else if(a <= c){
        if(b <= d){
            ans = b-c; 
        }
        else ans = d-c;
    }
    else if(a > c){
        if(b <= d){
            ans = b-a;
        }
        else ans = d-a;
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,a;
    cin >> n >> a;
    if((n % 500) <= a)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int n;
int t;	
int m;
int p,q;
void change()
{
	if(p>t)
	{
		p=n+1-p;
	}
	if(q>t)
	{
		q=n+1-q;
	}
	return;
}
int main()
{
	cin >> n;
	t=(n+1)/2;
	cin >> m;
	for(int i=0;i<m;i++)
	{
		cin >> p >> q;
		change();
		int ans=min(p,q)%3;
		if(ans==0)ans+=3;
		cout << ans << endl;
	}
	return 0;
}

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

#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,maxo=0,maxe=0,oo,ee;
int v[200000];
map<int,int>odd,even;
vector<int>o,e;
signed main(){
    cin>>n;
    if(n==2){
        if(v[0]==v[1])cout<<1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    else if(n==3){
        int ans;
        if(v[0]==v[2]){
            if(v[0]==v[1])ans=1;
            else ans=0;
        }
        else{
            ans=1;
        }
        return 0;
    }
    rep(i,n){
        cin>>v[i];
        if(i%2)even[v[i]]++;
        else odd[v[i]]++;
    }
    rep(i,n){
        if(i%2){
            if(even[v[i]]>maxe){
                maxe=even[v[i]];
                ee=v[i];
            }
        }
        else{
            if(odd[v[i]]>maxo){
                maxo=odd[v[i]];
                oo=v[i];
            }
        }
    }
    rep(i,n){
        if(i%2){
            e.push_back(even[v[i]]);
            even[v[i]]=0;
        }
        else{
            o.push_back(odd[v[i]]);
            odd[v[i]]=0;
        }
    }
    sort(e.begin(),e.end());
    reverse(e.begin(),e.end());
    sort(o.begin(),o.end());
    reverse(o.begin(),o.end());
    if(ee!=oo){
        int ans=n-(e[0]+o[0]);
        cout<<ans<<endl;
    }
    else{
        int x=e[0]+o[1],y=e[1]+o[0];
        int ans=n-max(x,y);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 8316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int s[200005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",s+i);
	}
	if(s[1]){cout<<-1;return 0;}
	ll ans=0,cnt=0;
	for(int i=2;i<=n;i++){
		if(s[i]>=i || s[i]>s[i-1]+1){
			cout<<-1;
			return 0;
		}
		if(s[i]==s[i-1]+1) ans++;
		else{
			ans+=s[i];
		}		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

// lib/quo.hpp
#ifndef QUO_H
#define QUO_H

/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T quo(const T lhs, const T rhs) {
    return lhs > 0 ? lhs / rhs : rhs > 0 ? -((-lhs - 1 + rhs) / rhs) : (-lhs - 1 + -rhs) / -rhs;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/extgcd.hpp
#ifndef EXTGCD_HPP
#define EXTGCD_HPP


/*
usage:

std::tuple<int, int, int> result = tools::extgcd(4, 5);
int gcd = std::get<0>(result);
int x0 = std::get<1>(result);
int y0 = std::get<2>(result);
*/

namespace tools {
  template <typename T>
  std::tuple<T, T, T> extgcd(T prev_r, T r) {
    T prev_s = 1;
    T prev_t = 0;
    T s = 0;
    T t = 1;
    while (r != 0) {
      const T q = quo(prev_r, r);
      const T next_r = prev_r - q * r;
      prev_r = r;
      r = next_r;
      const T next_s = prev_s - q * s;
      prev_s = s;
      s = next_s;
      const T next_t = prev_t - q * t;
      prev_t = t;
      t = next_t;
    }
    return std::make_tuple(std::abs(prev_r), prev_s, prev_t);
  }
}

#endif

// main.cpp

int main() {
  i64 N, X;
  std::cin >> N >> X;
  std::vector<i64> x;
  tools::read(x, N);

  std::transform(x.begin(), x.end(), x.begin(), [&X](const i64 x_i) { return x_i - X; });
  std::cout << std::accumulate(x.begin(), x.end(), x.front(), [](const i64 x_i, const i64 x_j) { return std::get<0>(tools::extgcd(x_i, x_j)); }) << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

#define ll long long
#define pb push_back
#define st first
#define nd second
#define N 2005
#define ii pair<int,int>
#define fr freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define mod 1000000007
ll dp[N][N];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
//	fr
	int r,c;
	cin>>r>>c;
	char ar[r+1][c+1];
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			cin>>ar[i][j];
		}
	}
	bool flag1=1,flag2=1;
	for(int i=1;i<=max(r,c);i++){
		if(i<=r && ar[i][1]=='.' && flag1)dp[i][1]=1;
		else flag1=0;
		if(i<=c && ar[1][i]=='.' && flag2)dp[1][i]=1;
		else flag2=0;
	}
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			if(j==1 || i==1) continue;
			if(ar[i][j]=='.')dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
		}
	}
	cout<<dp[r][c];
}


Measured memory_bytes: 17152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
int N, M, K, Q;
ll xA[MAX], yA[MAX];

int main()
{
	int i, j, k;
	scanf("%d%d", &N, &M);
	for (i = 1; i <= N; ++i) scanf("%lld", &xA[i]);
	for (i = 1; i <= M; ++i) scanf("%lld", &yA[i]);
	ll xsum, ysum;
	xsum = ysum = 0;
	for (i = 1; i < N; ++i) xsum = (xsum + (((xA[i + 1] - xA[i]) * (ll)(N - i) %MOD) * (ll)i % MOD)) % MOD;
	for (i = 1; i < M; ++i) ysum = (ysum + (((yA[i + 1] - yA[i]) * (ll)(M - i) %MOD) * (ll)i % MOD)) % MOD;
	printf("%lld", xsum*ysum %MOD);
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

double w, h, x, y;
int main() {
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << ' ' << ((x == w / 2 && y == h / 2) ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 3792
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

long n, m;

long cal(long use)
{
	long s = n + use / 2;
	long c2 = (m - use) / 2;
	return min(s, c2);
}

void main() {
	auto nm = readln.chomp.split.map!(to!long);
	n = nm[0];
	m = nm[1];
	long left = 0;
	long right = m + 1;
	while (right - left > 2) {
		long midL = (left * 2 + right) / 3;
		long midR = (left + right * 2) / 3;
		long resL = midL.cal;
		long resR = midR.cal;
		if (resL < resR) {
			left = midL;
		} else {
			right = midR;
		}
	}
	debug stderr.writeln([left, right]);
	debug stderr.writeln([left.cal, cal((left * 2 + right) / 3), cal((left + right * 2) / 3), right.cal]);
	// cal((left + right * 2) / 3) がそれ？　よく分からないので全部試す…
	long ans = 0;
	for (long ite = left; ite < right; ++ite) {
		ans = max(ans, ite.cal);
	}
	ans.writeln;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    char c; cin>>c;
    if(c<='Z') cout<<"A"<<endl;
    else cout<<"a"<<endl;
    return 0;
}


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

typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    string s = to_string(n);
    int sum = 0;
    rep(i, s.size())
    {
        sum += s.at(i) - '0';
    }

    if(n % sum == 0)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(32);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve()
{
    ll n, x, tmp = 0; cin>>n;
    ll ans = 1;
    vll a(n); bool ok = 0;
    rep(i , 0, n){
        cin>>a[i];
        if(!a[i])ok = 1;
    }
    if(ok){
        cout<<0<<nl;return;
    }
    ll num = 1000000000000000000;
    rep(i, 0, n){
        if(a[i] > num/ans){
            cout<<-1<<nl;return;
        }
        ans *= a[i];
    }
    cout<<ans<<nl;

} 
 
int main(){
    // boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

// 入れ替えるときは必ず違う色同士にする

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

    int Left = 0, Right = C.size() - 1;
    int res = 0;
    while (Left < Right) {
        while (Left < N && C[Left] != 'W') ++Left;
        while (Right >= 0 && C[Right] != 'R') --Right;
        if (Right <= Left || Left >= N || Right < 0) break;
        swap(C[Left], C[Right]);
        ++res;
    }
    //cout << C << endl;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3720
//A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str,str1;
    cin>>str>>str1;
    if(str1.substr(0,str1.length()-1)==str)puts("Yes");
    else puts("No");
    
    return 0;
}

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

int main(){

    int N,K;
    cin >> N >>K;
    vector<double> p(N);
    vector<double> q(N);
    double mx,sum;

   
    for (int i = 0;i< N;i++){
        sum = 0;
        cin >> p.at(i) ;
        q.at(i) = ((p.at(i)+1)/2) ;          
        } 
    

    for(int i = 0;i < K ;i++) sum += q.at(i);
    mx = sum;

    for(int i=K;i<N;i++){
        sum = sum + q.at(i)-q.at(i-K);

        if(sum > mx) mx = sum;
    }
    cout << fixed << setprecision(10);
    cout << mx;
}



Measured memory_bytes: 3328
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
flag = True
for i in range(n - 1):
    # print(i)
    if h[i] > h[i + 1]:
        flag = False
        break
    elif h[i] <= h[i + 1] - 1:
        h[i + 1] -= 1

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b, c, d) = in.readLine.split(" ").map(_.toInt)
  val ans = if((c-a).abs <= d || (b-a).abs <= d && (c-b).abs <= d) "Yes" else "No"
  println(ans)
}

Measured memory_bytes: 25412
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  ll N,K;
  cin >> N >> K;
  if(K%2){
    if(N < K){
      cout << 0 << endl;
    }else{
      ll res = 1;
      for(int i=0; i<3; i++){
        res *= N/K;
      }
      cout << res << endl;
    }
  }else{
    ll a,b;
    if(N<K){
      a = 0;
    }else{
      a = 1;
      for(int i=0; i<3; i++){
        a *= N/K;
      }
    }
    ll cnt = 0;
    ll half = K/2;
    while(half <= N){
      cnt++;
      half += K;
    }
    if(cnt){
      b = 1;
      for(int i=0; i<3; i++){
        b *= cnt;
      }
    }else{
      b = 0;
    }
    cout << a+b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_N = 1e5+10, MAX_Q = 5e4+10;
const int INF = (1<<30);

int s[MAX_N], t[MAX_Q], n;

int binarySearch(int key){
	int left = 0, right = n;
	while (right-left>0){
		int mid = (right+left)/2;
		if (s[mid]==key) return 1;
		else if (s[mid]<key) left = mid + 1;
		else if (s[mid]>key) right = mid;
	}
	return 0;
}

int main(int argc, char const *argv[])
{
	int q;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> s[i];
	for (int i = n; i < MAX_N; ++i) s[i] = INF;
	cin >> q;
    for (int i = 0; i < q; ++i) cin >> t[i];
    int ans = 0;

    for (int i = 0; i < q; ++i)
    {
    	ans += binarySearch(t[i]);
    }

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


Measured memory_bytes: 3604
//pku 2041
//std::stringのれんしぅでしゅ
 
#include <iostream>
#include <algorithm>
#define between(n,x,m) (((n)<=(x))&&((x)<=(m)))
using namespace std;

void J(string &str){rotate(str.begin(),str.begin()+(str.size()-1),str.end());}
void C(string &str){rotate(str.begin(),str.begin()+1,str.end());}
void E(string &str){
	int i=(str.size())/2;
	string tmp=str;
	str.replace(0,i,tmp,str.length()-i,i);
	str.replace(str.length()-i,i,tmp,0,i);
}

void A(string &str){reverse(str.begin(),str.end());}

void P(string &str){
	int i=str.size();
	for(;i>=0;--i){
		if(between('0',str[i],'9')){
			str[i]--;
			if(str[i]=='/')str[i]='9';
		}
	}
}

void M(string &str){
	int i=str.size();
	for(;i>=0;--i){
		if(between('0',str[i],'9')){
			str[i]++;
			if(str[i]==':')str[i]='0';
		}
	}
}


struct x{
	string &str;
	x(string &_str):str(_str){}
	void operator()(char c){
		switch(c){
			case 'J': J(str);break;
			case 'C': C(str);break;
			case 'E': E(str);break;
			case 'A': A(str);break;
			case 'P': P(str);break;
			default:  M(str);break;
		}
	}
};

int main(){
	string filter,str;
	int n;
	for(cin>>n;n--;cout<<str<<endl){
		cin>>filter>>str;
		for_each(filter.rbegin(), filter.rend(), x(str));
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, m; cin >> h >> w >> m;
	using P = pair<int, int>;
	vector<P> v(m);
	for(int i=0; i<m; ++i){
		int x, y; cin >> x >> y;
		--x; --y;
		v[i] = P(x, y);
	}
	vector<int> nh(h), nw(w);
	for(auto i:v){
		++nh[i.first];
		++nw[i.second];
	}
	set<P> st;
	for(auto i:v) st.insert(i);

	vector<P> sh(h), sw(w);
	for(int i=0; i<h; ++i)
		sh[i] = P(nh[i], i);
	for(int i=0; i<w; ++i)
		sw[i] = P(nw[i], i);
	sort(sh.begin(), sh.end(), greater<>());
	sort(sw.begin(), sw.end(), greater<>());
	int bh = 0, bw = 0;
	for(int i=0; i<h; ++i)
		if(sh[i].first == sh[0].first)
			bh = i;
	for(int i=0; i<w; ++i)
		if(sw[i].first == sw[0].first)
			bw = i;
	cerr << "bh " << bh << " " << "bw " << bw << "\n";
	cerr << sh[0].first << " " << sw[0].first << "\n";
	bool f = false;
	for(int i=0; i<=bh; ++i){
		if(f) break;
		for(int j=0; j<=bw; ++j){
			if(st.find(P(sh[i].second, sw[j].second)) == st.end()){
				cerr << "i " << i << " " << "j " << j << "\n";
				f = true;
				break;
			}
		}
	}
	int ans = sh[0].first + sw[0].first;
	if(!f) --ans;
	cout << ans << "\n";
}

Measured memory_bytes: 26676
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,ctr=0;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i].s>>v[i].f;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {
        if(ctr+v[i].s>v[i].f)
            return cout<<"No",0;
        ctr+=v[i].s;
    }
    cout<<"Yes";
    return 0;
}



Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod1;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod1;
        a = a * a % mod1;
        b /= 2;
    }
    return ans;
}

int main(){

 
   ios_base :: sync_with_stdio(0);
   cin.tie(0);
    ll k,n;
    cin>>k>>n;
    ll a[n];
    vector<ll> diff;
    rep(i ,0 ,n){
        cin>>a[i];
        if(i != 0 ){
            diff.push_back(abs(a[i]-a[i-1]));
        }
        if(i == n-1){
            ll t= k-a[i];
            t += a[0];
            diff.push_back(t);
        }
    }
    sort(diff.begin() , diff.end());
    ll ans =0;
    for(int i = diff.size()-2;i>=0;i--){
        ans += diff[i];
    }
    cout<<ans;


}


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

using namespace std;

int f(int n, int a, int b) {
    return std::min(n * a, b);
}

int main() {

    int n, a, b;
    cin >> n >> a >> b;

    int result = f(n, a, b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<functional>
#include<queue>
#include<math.h>
#define INF 999999

using namespace std;

int main()
{
	int ans[210];

	int a, b;
	int k = 0;
	while(cin>>a>>b){
			int c = a + b;
			int d = c;
			int count = 0;
			while (d != 0) {
				d = d / 10;
				count++;
			}
			ans[k] = count;
			k++;
		
	}

	for (int i = 0; i < k; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


int main()
{
	int n;
	int a,b;

	cin >> n;
	
	if (n == 1) {
		cout << "Hello World" << endl;
	}else if (n == 2) {
		cin >> a >> b;
		cout << (a+b) << endl;
	}
	
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define pb push_back
#define mp make_pair
#define ip pair<int, int>
#define it pair<int, pair<int, int>>
#define F first
#define S second
#define fori(p, n) for(int i = p; i < n; i++)
#define forj(q, m) for(int j = q; j < m; j++)
#define fork(r, l) for(int k = r; k < l; k++)
#define revi(h) for(int i = h; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define PI 3.14159265358
#define debug(x) cout<<"DEBUGGING --- "<<x<<endl;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file freopen("output.txt", "w", stdout);
vector<int>P(405);
int gets(int l, int r){
    if(l == 0) return P[r];
    return P[r] - P[l - 1];
}
signed main(){
    fastio;
    //input_from_file; 
    //output_to_file;
    int n; cin>>n;
    vector<int>A(n);
    fori(0, n) cin>>A[i];
    P[0] = A[0];
    fori(1, n) P[i] = P[i - 1] + A[i];
    vector<vector<int>>dp(n + 1, vector<int>(n + 1, 0));
    fori(0, n) dp[i][i] = 0;
    fork(2, n + 1){
        fori(0, n - k + 1){
            int l = i + k - 1;
            dp[i][l] = LONG_LONG_MAX;
            forj(i, l) dp[i][l] = min(dp[i][l], dp[i][j] + dp[j + 1][l] + gets(i, j) + gets(j + 1, l));
        }
    }
    // fori(0, n){
    //     forj(0, n) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<dp[0][n - 1]<<endl;                
}

Measured memory_bytes: 1536
N = int(input())
A = list(map(int, input().split()))
B=[]
if N%2 ==0:
    for a in range(1, N, 2):
        B.append(a)
    B+=B
    if sorted(A) == sorted(B):
        print(2**len(set(A))%(10**9+7))
    else:
        print(0)
else:
    for a in range(2, N, 2):
        B.append(a)
    B=B+B+[0]
    if sorted(A) == sorted(B):
        print(2**(len(set(A))-1)%(10**9+7))
    else:
        print(0)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

    int res = 0;
    for (int i = 1; i < n-1; ++i) {
        if (p[i-1] < p[i] && p[i] < p[i+1]) res++;
        else if (p[i-1] > p[i] && p[i] > p[i+1]) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3552
N, K = gets.split.map(&:to_i)

ans = 0

0.upto(K-1) do |i|
  if 2*i % K == 0
    if i == 0 || i > N%K
      ans += (N/K)**3
    else
      ans += (N/K + 1)**3
    end
  end
end

puts ans


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

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

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

mint dp[10010][2][101];

int main() {
    string K;
    int D;
    cin >> K >> D;
    dp[0][0][0] = 1;
    rep(i, K.size()) {
        rep(k, D) {
            int cur = K[i] - '0';
            int nd = (k + cur) % D;
            dp[i + 1][0][nd] += dp[i][0][k];

            rep(d, cur) {
                nd = (k + d) % D;
                dp[i + 1][1][nd] += dp[i][0][k];
            }

            rep(d, 10) {
                nd = (k + d) % D;
                dp[i + 1][1][nd] += dp[i][1][k];
            }
        }
    }

//    rep(i, K.size() + 1) {
//        rep(j, 2) {
//            cout << "i:" << i << " j:" << j << endl;
//            rep(k, D) cout << dp[i][j][k].x  << " ";
//            cout << endl;
//        }
//        cout << "----------" << endl;
//    }
    cout << (dp[K.size()][0][0] + dp[K.size()][1][0] - 1).x << endl;
}


Measured memory_bytes: 16128
N=int(input())
S=str(input())
P=10**9+7

DP=[[0]*(N+1) for _ in range(N+1)]
#初期
for index1 in range(N):
    DP[1][index1]=1

for i in range(2,N):
    #累積和
    C=[0]*(N+1)
    C[0]=DP[i-1][0]%P
    for index2 in range(1,N+1):
        C[index2]=(C[index2-1]+DP[i-1][index2])%P
    for j in range(N-i+1):
        if S[i-2]=='>':
            DP[i][j]=(C[N-i+1]-C[j])%P
        else:
            DP[i][j]=C[j]

if S[N-2]=='>':
    DP[N][0]=DP[N-1][1]
else:
    DP[N][0]=DP[N-1][0]

print(DP[N][0]%P)



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

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
struct Problem{
    LL n,q;
    vector<LL> qq,query;
    Problem(LL n, LL q):n(n),q(q),qq(q){};

    void solve(){
        if(q==0){
            for(int i=0; i<n; ++i){
                cout << 1 <<"\n";
            }
            return;
        }
        for(int i=0; i<q; ++i){
            cin >> qq[i];
        }
        query.push_back(qq.back());
        for(int i=(int)qq.size()-2; i>=0; --i){
            if(qq[i]<query.back())query.push_back(qq[i]);
        }
        if(query.back()>n)query.push_back(n);
        vector<LL> ans(query.back()+1),coeff((int)query.size());
        map<LL,LL> m;
        m[query[0]]=1;
        coeff[0]=1;
        for(int i=1; i<(int)query.size(); ++i){
            vector<LL> to_erase;
            LL add=0;
            for(auto it= m.lower_bound(query[i]); it!=m.end();++it){
                coeff[i]+=coeff[i-1]*(it->first/query[i]);
                add+=(it->first/query[i])*it->second;
                m[it->first%query[i]]+=it->second;
                to_erase.push_back(it->first);
            }
            for(auto x:to_erase)m.erase(x);
            m[query[i]]=add;
        }
        for(auto p : m){
            ans[p.first]+=p.second;
        }
        for(int i=(int)ans.size()-2; i>=1; --i){
            ans[i]+=ans[i+1];
        }
        for(int i=1; i<=n; ++i){
            if(i<(int)ans.size())cout << ans[i] <<"\n";
            else cout << 0 << "\n";
        }


    }
};


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,q;
    cin >> n>>q;
    Problem p(n,q);
    p.solve();
    return 0;
}



Measured memory_bytes: 14408
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cstring>
#include <bits/stdc++.h>
#include <search.h>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include<stack>
#include <utility>
using namespace std;
int main()
{
    int res,a,b;
    cin>>a>>b;
    cout<<(int)ceil ( double(b-1) / double(a-1));

return 0;
}


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

Measured memory_bytes: 3596
def main():
    n = int(input())
    a = []

    m = 0
    s = 0

    for i in range(n):
        tmp = int(input())
        if tmp>=m:
            s = m
            m = tmp
        elif tmp>=s:
            s = tmp
            
        a.append(tmp)

    for i in a:
        if i == m:
            print(s)
        else:
            print(m)


main()




Measured memory_bytes: 12532
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			while(N-- != 0) {
				double[][] cir = new double[2][3];
				for(int i=0; i<2; i++) {
					for(int j=0; j<3; j++) {
						cir[i][j] = sc.nextDouble();
					}
				}
				
				int ans = 0;
				double dis = Math.sqrt((cir[0][0]-cir[1][0])*(cir[0][0]-cir[1][0]) + (cir[0][1]-cir[1][1])*(cir[0][1]-cir[1][1]));
				
				if(dis > cir[0][2]+cir[1][2]) ans = 0;
				else {
					if(dis + Math.min(cir[0][2], cir[1][2]) < Math.max(cir[0][2], cir[1][2])) {
						ans = cir[0][2] < cir[1][2] ?-2:2;
					}
					else ans = 1;
				}
				System.out.println(ans);
			}
		}
	}
}



Measured memory_bytes: 28248
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;


class BIT{


public:
    vector<LL> table;
    BIT(int n){
        table = vector<LL>(n+1,0);        
    }
    LL query(int x){
        LL ans = 0;
        while(x){
            ans += table[x];
            x-=lowbit(x);
        }
        return ans;
    }
    void update(int x,LL val){
        if(x==0) return;
        int n = table.size()-1;
        while(x<=n){
            table[x]+=val;
            x+=lowbit(x);
        }
    }
    int lowbit(int x){
        return x &(-x);
    }
};
void solve(){
    int n,d,a;
    cin>>n>>d>>a;
    vector<vector<int>> table(n,vector<int>(2,0));
    for(int i=0;i<n;i++) cin>>table[i][0]>>table[i][1];
    sort(table.begin(),table.end(),
        [](vector<int>&a,vector<int> &b){
        return a[0]<b[0];
    });
    LL ans = 0;
    BIT tree(n);
    for(int i=0;i<n;i++){
        // int x = i+1;
        auto tsum = tree.query(n);
        tsum-=tree.query(i);
        if(tsum>=table[i][1]) continue;
        int l = i;
        int r = n;
        LL threshold = table[i][0]+2ll * d;
        while(l<r){
            int m = (l+r)/2;
            if(table[m][0]>threshold) r = m;
            else l=m+1;
        }
        l--;
        tsum = table[i][1]-tsum;
        LL cnt = (tsum-1)/a+1;
        // cout<<cnt<<endl;
        ans+=cnt;
        LL xxx = cnt*a;
        tree.update(i,-xxx);
        // cout<<"****"<<endl;
        tree.update(l+1,xxx);
    }
    cout<<ans<<endl;
}

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



Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int A, B; cin >> A >> B;
	cout << (A+B) % 24 << endl;
}


Measured memory_bytes: 256
using System;
public class Test{
  public static void Main(){
    var num = Console.ReadLine().Split(' ');
    int A = int.Parse(num[0]);
    int B = int.Parse(num[1]);
    double H = double.Parse(num[2]);
    double M = double.Parse(num[3]); 
    double Hrad = (H*60+M)/720;
    double Mrad = M/60;
    double X = A*A + B*B - 2*A*B*Math.Cos((Hrad-Mrad)*2*Math.PI);    
    Console.Write(Math.Sqrt(X));
  }
}

Measured memory_bytes: 27932
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    
    int n,k;
    cin>>n>>k;
    
    int ans = n%k;
    if(k>n || ans!=0) cout<<"1\n";
    else cout<<"0\n";
    
    
    return 0;
}


Measured memory_bytes: 256