akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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

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

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

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


ll eL[SIZE], eR[SIZE], eL2[SIZE], eR2[SIZE];

int main(){
  int L;
  ll a[SIZE];

  scanf("%d", &L);

  for(int i=0;i<L;i++) scanf("%lld", a+i);

  for(int i=0;i<L;i++){
    eL2[i] += a[i]%2 == 0;
    eL2[i+1] += eL2[i];
  }

  for(int i=0;i<L;i++){
    if (i == 0) eR2[i] = eL2[L];
    else eR2[i] = eL2[L] - eL2[i-1];
  }

  for(int i=0;i<L;i++){
    debug(make_pair(eL2[i], eR2[i]));
  }

  ll p = 0, q = 0, r1 = 0, r2 = 0;
  for(int i=0;i<L;i++){
    if (a[i] == 0) {
      q += 2;
      if (r1 < q + p) {
        r2 += r1;
        r1 = 0;
        q = p = 0;
      }
    } else {
      p += a[i] % 2;
      r1 += a[i];
    }
    eL[i+1] = p + q + r2;
  }

  p = 0, q = 0, r1 = 0, r2 = 0;
  for(int i=0;i<L;i++){
    if (a[L-i-1] == 0) {
      q += 2;
      if (r1 < p + q) {
        r2 += r1;
        r1 = 0;
        q = p = 0;
      }
    } else {
      p += a[L-i-1] % 2;
      r1 += a[L-i-1];
    }
    eR[L-i-1] = p + q + r2;
  }

  for(int i=0;i<=L;i++){
    debug(eL[i]);
  }

  for(int i=0;i<L;i++) eL[i+1] -= eL2[i];
  for(int i=0;i<L;i++) eR[i] -= eR2[i];

  eR[L] = eL2[L];
  for(int i=L-1;i>=0;i--){
    eR[i] = min(eR[i] + eL2[L], eR[i+1]);
  }

  ll ans = eL2[L];

  for(int i=0;i<=L;i++){
    ans = min(ans, eL[i] + eR[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8064
import math
a, b, c = map(int, input().split())

S = a*b*math.sin(math.radians(c))/2
L = a+b+math.sqrt((a**2+b**2-2*a*b*math.cos(math.radians(c))))
h = 2*S/a

print(S)
print(L)
print(h)



Measured memory_bytes: 5708
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1359",problemID = "C",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,decimal
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def qw(n): 
    q = []
    # Print the number of two's that divide n 
    while n % 2 == 0: 
        q.append(2)
        n = n // 2
          
    # n must be odd at this point 
    # so a skip of 2 ( i = i + 2) can be used 
    for i in range(3,int(math.sqrt(n))+1,2): 
          
        # while i divides n , print i ad divide n 
        while n % i== 0: 
            q.append(i) 
            n = n // i 
              
    # Condition if n is a prime 
    # number greater than 2 
    if n > 2: 
        q.append(n)
    return(q)

def solve():
    n = inp()
    if n == 1:
        print(0)
        return
    a = qw(n)
    c = 0
    q = a[0]
    w = 0
    qq = 0
    for i in range(len(a)):
        if a[i] == q:
            c = c + 1
            if c > w:
                qq = qq + 1
                w = c
                c = 0
        else:
            qq = qq + 1
            c = 0
            w = 1
            q = a[i]
    print(qq)
                
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(float,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)
 
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
   
  
  
main()

Measured memory_bytes: 72664
def d(u):
 global t
 C[u]=0;t+=1;D[u]=t
 for v in R:
  if M[u][v]and C[v]:d(v)
 t+=1;F[u]=t
N=int(input());R=range(N)
M=[[0]*N for _ in R]
for e in[input().split()for _ in R]:
 for v in e[2:]:M[int(e[0])-1][int(v)-1]=1
C,D,F=[1]*N,[0]*N,[0]*N
t=0
for i in R:
 if C[i]:d(i)
for i in R:print(i+1,D[i],F[i])


Measured memory_bytes: 5796
n,c,k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
wait = t[0]+k
kyaku = 1
cnt = 1
for i in range(1,n):
    kyaku += 1
    if t[i] > wait or kyaku > c:
        cnt += 1
        kyaku = 1
        wait = t[i] + k
print(cnt)

Measured memory_bytes: 7492
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>
using namespace std;

int main(void) {
    int i,j;
    int n;
    cin>>n;
    vector<int> a(n);
//    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    int min =0;
    i =0;
    while(i<n){
        j = 0;
        while(a[i]==a[i+j]) j++;
//        cout << c << endl;
        if(j>=a[i]){
            min+=j-a[i];           
        }else {
            min+=j;  
        }
        i+=j;
    }
   
    cout << min << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=200200;
int n,m,u,v,mx, a[N],b[N],c[N],d[N],s[2][N],t[N]; 
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	FOR(i,1,m) scanf("%d%d",&a[i],&b[i]),d[a[i]]++,d[b[i]]++;
	FOR(i,1,n)
		if(d[i]&1) return puts("No"),0;
		else c[d[i]]++,mx=max(mx,d[i]);
	if(mx>=6 || c[4]>=3) return puts("Yes"),0;
	if(c[4]<=1) return puts("No"),0;
	FOR(i,1,m) s[t[a[i]]++][a[i]]=b[i],s[t[b[i]]++][b[i]]=a[i];
	FOR(i,1,n)if(d[i]==2){
		u=s[0][i],v=s[1][i];
		if(u==v) return puts("Yes"),0;
		s[i==s[1][u]][u]=v;
		s[i==s[1][v]][v]=u;
	}
	return puts("No"),0;
}

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

using namespace std ;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
#define ll long long int 

#define fr first
#define se second

#define all(v) v.begin(),v.end() 
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size() 

#define pb push_back
#define mp make_pair 

#define PI 3.141592653589793238



ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b / gcd(a,b) ;}


//bool valid(int x, int y){return x > 0 && x < 9 && y > 0 && y < 9;}

string s;

int main(){
  cin >> s;
  string s1 = s.substr(0,2);
  string s2 = s.substr(2);
  int x ,y;
  if(s1[0]=='0')
    x = s1[1]-'0';
  else
    x = stoi(s1);

  if(s2[0] == '0')
    y = s2[1]-'0';
  else
    y = stoi(s2);

  if(x <= 12 && y <= 12 && x && y)
    return cout << "AMBIGUOUS",0;
  if(x <= 12 && x)
    return cout << "MMYY",0;
  if(y <= 12 && y)
    return cout << "YYMM",0;
  cout << "NA";
  return 0;
}


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

int main() {
  int x = 0;
  string a;
  cin >> a;
  if(a.size() % 2 == 1){
  	cout << "No" << endl;
  	return 0;
  }
  vector<char> vec (a.size());
  for(int i = 0;i < a.size();i++){
    vec.at(i) = a.at(i);
  }
  sort(vec.begin(),vec.end());

  for(int i = 0;i < vec.size();i = i + 2){
  if(vec.at(i) == vec.at(i + 1)){
    x++;}
  }

  if (x == vec.size() / 2){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

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


int main() {
    int a,b;
	cin >> a>> b;
    if(a>12)a=2;
    else if(a>5)a=1;
    else a=0;
      cout << b*a/2 << endl;
}

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


int main()
{
	int N;
	cin>>N;
	vector<int> X(N);
	rep(i,N) cin>>X[i];
	ll ans=1e9;
	Rep(x,1,101)
	{
		ll v=0;
		rep(j,N)
		{
			v+=(ll)pow((X[j]-x),2.0);
		}
		ans=min(ans,v);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,t;
  cin>>n>>t;
  int a[n];
  int b[n];
  rep(i,0,n){
    cin>>a[i];
    cin>>b[i];
  }
  int dp1[n+1][t];
  int dp2[n+1][t];
  rep(i,0,t) dp1[0][i]=0;
  rep(i,0,n){
    rep(j,0,t){
      if(j<a[i]) dp1[i+1][j]=dp1[i][j];
      else dp1[i+1][j]=max(dp1[i][j],dp1[i][j-a[i]]+b[i]);
    }
  }
  rep(i,0,t) dp2[0][i]=0;
  rep(i,0,n){
    rep(j,0,t){
      if(j<a[n-1-i]) dp2[i+1][j]=dp2[i][j];
      else {
        dp2[i+1][j]=max(dp2[i][j],dp2[i][j-a[n-1-i]]+b[n-1-i]);
      }
    }
  }
  int ans=0;
  rep(i,0,n){
    rep(j,0,t){
      ans=max(ans,dp1[i][j]+dp2[n-i-1][t-1-j]+b[i]);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector < vector <int> > mv;
int c[100001];
int vi[100000];
int res[100000];

void vis(int ac, int cc){
	c[cc]++;
	vi[ac] = cc;
	for(int i=0;i<mv[ac].size();i++)if(vi[mv[ac][i]]==0)vis(mv[ac][i],cc);
}
int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n,m,k;
	cin>>n>>m>>k;
	int u,v;
	mv.resize(n);
	while(m--){
		cin>>u>>v;
		u--;
		v--;
		mv[u].push_back(v);
		mv[v].push_back(u);
	}
	int cc=1;
	for(int i=0;i<n;i++)if(vi[i]==0){
		vis(i,cc);
		cc++;
	}
	while(k--){
		cin>>u>>v;
		u--;
		v--;
		if(vi[u]==vi[v]){
			res[u]++;
			res[v]++;
		}
	}
	for(int i=0;i<n;i++)cout<<c[vi[i]]-mv[i].size()-1-res[i]<<' ';
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 7552
fun main(args: Array<String>) {
        val n = readLine()!!.toInt()
        val a = readLine()!!.split(' ').map { it.toInt() }

        val employees = Array<Int>(n) { 0 }

        a.forEach {
            employees[it - 1]++
        }

        employees.forEach {
            println(it)
        }
    }


Measured memory_bytes: 70120
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

#define N 101000
long long  arr[N];

void Eratosthenes(){
    for(long long  i = 0; i < N; i++){
        arr[i] = 1;
    }
    for(long long  i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(long long  j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }

}

int main(void)
{
    Eratosthenes();
    int x;
    cin >>x;

    for(int i = x; i < N; i++){
        if(arr[i]){
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n;
int a[N];
int b[N];
int l[N];
int r[N];
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , a + i);
    }
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , b + i);
    }
    for(int i = 1 ; i <= n ; ++i){
        if(a[i] > a[i - 1]){
            l[i] = a[i];
            r[i] = a[i];
        }
        else{
            l[i] = 1;
            r[i] = a[i];
        }
    }
    for(int i = n ; i >= 1 ; --i){
        if(b[i] > b[i + 1]){
            l[i] = max(b[i] , l[i]);
            r[i] = min(b[i] , r[i]);
        }
        else{
            l[i] = max(1 , l[i]);
            r[i] = min(b[i] , r[i]);
        }
    }
    int ans = 1;
    for(int i = 1 ; i <= n ; ++i){
        ans = (1LL * ans * max(0 , r[i] - l[i] + 1)) % mod;
    }
    printf("%d\n" , ans);
}

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

int main(){
    int n; cin>>n;
    vector<int> w(n);
    rep(i,n) cin >>w[i];
    int sum;
    for(int i=0;i<n;i++){
        sum+=w[i];
    }
    int ssum; int ans=100000;
    for(int i=0;i<n;i++){
        ssum+=w[i];
        ans = min(ans,abs(sum-2*ssum));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 or W==0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if i==0 or i==(H-1) or j==0 or j==(W-1):
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        print()


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

int main()
{
    vector<int> st(30,-1);
    for (int i=0;i<28;++i){
        int n;
        cin>>n;
        st[n-1]=1;
    }
    for(int i=0;i<30;++i){
        if(st[i]==-1){
            cout << i+1<<endl;
        }
    }
    return 0;

}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int g[11234];

int find(int x) {
	if (g[x] == x) return x;
	return g[x] = find(g[x]);
}

bool same(int x, int y) {
	x = find(x); y = find(y);
	return x == y;
}

void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y) return;
	g[x] = y;
}

int main() {
	int n, q;
	cin >> n >> q;
	
	// UnionFind????????????
	for (int i = 0; i < n; i++) g[i] = i;
	
	for (int i = 0; i < q; i++) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		
		if (com == 0) { // unite
			unite(x, y);
		}
		else { // same
			printf("%d\n", same(x, y));
		}
	}
	return 0;
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
const int N=2e5+10;
using namespace std;
int a[N],exis[N],n;
inline bool check(int x){
	for(int i=1;i<=2*n-1;i++)exis[i]=a[i]>x;
	if(exis[n]==exis[n-1]||exis[n]==exis[n+1])return exis[n];
	int l,r;
	for(l=n;l>1&&exis[l]!=exis[l-1];l--);
	for(r=n;r<2*n-1&&exis[r]!=exis[r+1];r++);
	if(exis[l]==exis[r])return exis[r];
	int mid=(l+r)>>1;if(n<=mid)return exis[l];else return exis[r];
}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int main(){
	n=read();
	for(int i=1;i<=2*n-1;i++)a[i]=read();
	int l=1,r=2*n-1;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))l=mid+1;
		else r=mid;
	}
	printf("%d\n",l);
}

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

int main(){
	ios::sync_with_stdio(0);
	long long l , r;
	cin >> l >> r;
	r = min(r , l + 2019);
	for (long long i = l ; i < r; i++){
		for (long long j = i + 1; j <= r; j++){
			ans = min(ans , (i * j) % 2019ll);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
x_1,y_1,x_2,y_2=gets.split.map(&:to_i)

x_3=x_2-(y_2-y_1)
y_3=y_2+(x_2-x_1)
x_4=x_3-(y_3-y_2)
y_4=y_3+(x_3-x_2)
puts "#{x_3} #{y_3} #{x_4} #{y_4}"


Measured memory_bytes: 14388
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	k := io.NextInt()
	q := Queue{}
	for i := 1; i <= 9; i++ {
		q.Push(i)
	}
	for i := 0; i < k-1; i++ {
		x := q.Pop()
		if x%10 != 0 {
			q.Push(10*x + x%10 - 1)
		}
		q.Push(10*x + x%10)
		if x%10 != 9 {
			q.Push(10*x + x%10 + 1)
		}
	}
	io.Println(q.Pop())
}

// Queue for Lunlun number
type Queue []int

// Push appends x to end of queue
func (q *Queue) Push(x int) { *q = append(*q, x) }

// Pop returns first item
func (q *Queue) Pop() int {
	x := (*q)[0]
	*q = (*q)[1:]
	return x
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 8268
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int MAX_C = 2010;
long long Com[MAX_C][MAX_C] = {0};

int main(){
  int a, b; cin >> a >> b;
  if(a>b) cout << a-1 << endl;
  else cout << a << endl;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define fore(i, x) for (auto &i : n)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

template<typename T > struct SparseTable { //[a, b)
    vector<vector<T> > st;
    vector< int > lookup;
    int type;
    SparseTable(const vector<T> &v, const int t) { // type == 1 range minimum type == 2 range maximum
        int b = 0;
        type = t;
        while((1 << b) <= v.size()) ++b;
        st.assign(b, vector< T >(1 << b));
        for(int i = 0; i < v.size(); i++) {
            st[0][i] = v[i];
        }

        for(int i = 1; i < b; i++) {
            for(int j = 0; j + (1 << i) <= (1 << b); j++) {
                st[i][j] = type ? min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]) : max(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
            }
        }
        
        lookup.resize(v.size() + 1);
        
        for(int i = 2; i < lookup.size(); i++) {
            lookup[i] = lookup[i >> 1] + 1;
        }
    }
        
    inline T rmq(int l, int r) {
        int b = lookup[r - l];
        return type ? min(st[b][l], st[b][r - (1 << b)]) : max(st[b][l], st[b][r - (1 << b)]);
    }
};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, t;
    cin >> n >> t;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    map<int, int> M;
    SparseTable<int> st(A, 0);
    for (int i = 0; i < n - 1; ++i) {
        ++M[st.rmq(i + 1, n + 1) - A[i]];
    }

    auto itr = M.end();
    --itr;
    cout << itr-> second << endl;

    return 0;
}

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

using namespace std;

int ans[10000 + 5];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 1; i <= (int)s.size(); i++){
		int x = (int) s[i - 1];
		x -= 65;
		x += n;
		x %= 26;
		x += 65;
		ans[i] = x;
	}
	for(int i = 1; i <= (int)s.size(); i++)
		cout << (char) ans[i];
	
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,a,b;  cin>>k>>a>>b;
    for(int i =a;i<=b;++i){
        if(i%k==0){
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}

    


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int k;
	cin>>k;
	int arr[n+1];
	arr[0]=-1;
	for(int i=1;i<=n;i++){cin>>arr[i];}
	vector<int> dp(n+1,INT_MAX);
	dp[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			if((i-j)>0){
				dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
				}
			}
		}
	cout<<dp[n]<<endl;
	
	}


Measured memory_bytes: 1024
import collections

n = int(input())
s_list = [input() for _ in range(n)]
s_cnt = collections.Counter(s_list)
s_sorted = s_cnt.most_common()
ans_list = [s[0] for s in s_sorted if s[1] == s_sorted[0][1]]
ans_list.sort()
for ans in ans_list:
    print(ans)

Measured memory_bytes: 47636
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	l := map[string]int{}

	for i := 0; i < len(s); i++ {
		l[string(s[i])]++
	}

	ans := true
	for _, value := range l {
		if value != 2 {
			ans = false
			break
		}
	}

	if ans  {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

using namespace std;

int n;

void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

int main(){
    solve();
}


Measured memory_bytes: 256
import math
import decimal
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

class Library():
    @staticmethod
    def Swap(a,b):
        return [b,a]

    @staticmethod
    def myRound(a,dig=0): # 四捨五入
        p = 10 ** dig
        return (a * p * 2 + 1) // 2 / p

    @staticmethod
    def Roundup(a,dig=0): # 切り上げ
        if a < 0:
            return int(a)
        else:
            return int(a + 0.9)

    @staticmethod
    def Gcd(a,b): #最大公約数
        if (a<b):
            a,b = Library.Swap(a,b)
        if (b==0):
            return a
        else:
            return Library.Gcd(b,a%b)

    @staticmethod
    def Lcm(a,b): #最小公倍数
        return a//Library.Gcd(a,b)*b

    @staticmethod
    def Divisors(a): # 約数列挙
        divisors = []
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                divisors.append(i)
                if i!=a//i:
                    divisors.append(a//i)
        divisors.sort()
        return divisors

class Prime():
    # コンストラクタ
    # エラストテネスの篩
    def __init__(self,num):
        self.num = num
        self.sieve = [0] * (self.num + 1)
        self.sieve[0] = -1
        self.sieve[1] = -1
        for i in range(2,self.num + 1):
            if not self.sieve[i]:
                self.sieve[i] = i
                for j in range(i * i,self.num + 1,i):
                    if self.sieve[j]:
                        self.sieve[j] = i
    
    # 素数判定
    def isPrime(self,num = None):
        if num is None:
            num = self.num
        if self.sieve[num] == num:
            return True
        else:
            return False
    
    # 素数列挙
    def PrimeNum(self,num = None):
        if num is None:
            num = self.num
        prime = []
        for i in range(2,num):
            if self.sieve[i] == i:
                prime.append(i)
        return prime
    
    # 素因数分解
    def PrimeFact(self,num = None):
        if num is None:
            num = self.num
        fact = []
        while self.sieve[num] != num:
            fact.append(self.sieve[num])
            num //= self.sieve[num]
        fact.append(num)
        return fact

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    h.sort()
    ans = 0
    for i in range(k):
        if len(h) == 0:
            break
        del h[-1]
    ans += sum(h)
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 108908
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;
const ll MOD = 1000000007ll;

ll n, DP[MAXN][13];
char s[MAXN];

int get_rem(int pow) {
    if (pow == 0) {
        return 1;
    } else if (pow % 2 == 1) {
        return (10 * get_rem(pow - 1)) % 13;
    } else {
        int res = get_rem(pow / 2);
        return (res * res) % 13;
    }
}

int main() {
    scanf(" %s", s);
    n = strlen(s);

    if (s[n - 1] == '?') {
        for (int i = 0; i < 10; i++) {
            DP[n - 1][i] = 1;
        }
    } else {
        DP[n - 1][s[n - 1] - '0'] = 1;
    }

    for (int i = n - 2; i >= 0; i--) {
        if (s[i] == '?') {
            for (int k = 0; k < 10; k++) {
                for (int j = 0; j < 13; j++) {
                    DP[i][(k * get_rem(n - i - 1) + j) % 13] = (DP[i][(k * get_rem(n - i - 1) + j) % 13] + DP[i + 1][j]) % MOD;
                }
            }
        } else {
            for (int j = 0; j < 13; j++) {
                DP[i][((s[i] - '0') * get_rem(n - i - 1) + j) % 13] = (DP[i][((s[i] - '0') * get_rem(n - i - 1) + j) % 13] + DP[i + 1][j]) % MOD;
            }
        }
    }

    printf("%lld\n", DP[0][5]);

    return 0;
}

Measured memory_bytes: 10496
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
long long n;
int a[105];
int main() {
	int n, m, x,t;
	cin >> n >> m >> x ;
	for (int i = 0; i < m; i++) {
		cin >> t;
		a[t]++;
	}
	int l = 0;
	for (int i = 0; i < x; i++) {
		if (a[i])
			l++;
	}
	int r = 0;

	for (int i = x; i < n; i++) {
		if (a[i])
			r++;
	}
	cout << min(l, r) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    char a, b;
    cin >> a >> b;
    int c = (a == 'H' ? 1 : -1), d = (b == 'H' ? 1 : -1);
    if (c * d > 0) {
        cout << 'H';
    } else cout << 'D';
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const ll INF = 1LL << 60;
ll dist[100005];
int main() {
	int k;
	scanf("%d", &k);
	typedef pair<ll, int> Pair;
	priority_queue<Pair, vector<Pair>, greater<Pair>> pq;
	fill(dist, dist + k, INF);
	for (int i = 1; i <= 9; ++i) {
		if (i < dist[i % k]) {
			dist[i % k] = i;
			pq.emplace(i, i % k);
		}
	}
	while (!pq.empty()) {
		int u = pq.top().second;
		ll cdist = pq.top().first;
		pq.pop();
		if (u == 0) {
			printf("%lld\n", dist[u]);
			return 0;
		}
		if (cdist > dist[u]) continue;
		for (int i = 0; i <= 9; ++i) {
			int v = (u * 10 + i) % k;
			ll val = dist[u] + i;
			if (val < dist[v]) {
				dist[v] = val;
				pq.emplace(val, v);
			}
		}
	}
}


Measured memory_bytes: 7024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<pair<ll, ll> > ps;
  for(int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    ps.emplace_back(x, y);
  }
  sort(ps.begin(), ps.end());
  for(auto p : ps) cout << p.first << " " << p.second << endl;
  return 0;
}



Measured memory_bytes: 4932
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int A, B, K;
  cin >> A >> B >> K;

  for( int i = 0; i < K; i++ ){
    if( i % 2 == 0 ){
      A -= (A%2);
      B += A/2; A /= 2;
    }else{
      B -= (B%2);
      A += B/2; B /= 2;
    }
    
  }
  cout << A << " " << B << endl;
  
}

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  
  int wa, w, s, sw, ans_sw = 100 * A, ans_s = 0, limit, dmax;
  while (wa < F) {
    w = wa;
    while (w < F) {
      limit = min(w / 100 * E, F - w);
      dmax = limit / D;
      s = dmax * D;
      for (int i = 0; i <= dmax; i++) {
        s += (limit - s) / C * C;
        sw = w + s;
        if (s * ans_sw > ans_s * sw) {
          ans_sw = sw;
          ans_s = s;
        }
        s -= D;
      }
      w += 100 * B;
    }
    wa += 100 * A;
  }
  
  cout << ans_sw << " " << ans_s << endl;
}


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

#define fmm(x) cerr << "[!] " << #x << " e " << x << "\n";
using ll = long long;

using namespace std;

const int MAX = 100005;

int viz[MAX];

int main(){
  // ENGAGE MODUL RACHETĂ ᕦ(ò_ó)ᕤ
  ios::sync_with_stdio(false);
  cin.tie(0);

  #ifdef ACAS_LA_SEFU
  freopen("valoare.in", "r", stdin);
  #endif

  int k; cin >> k;
  queue<ll> a;
  for (int i=1; i<=9; i++) a.push(i);

  ll cnt=0;
  set<ll> st;
  while(a.size()){
    ll el = a.front(); a.pop();
    cnt++;
//    cout << cnt << ": " << el << "\n";
    if (cnt==k){
      cout << el;
      return 0;
    } else {
      int last=el%10;
      for (int i=last-1; i<=last+1; i++){
        if (i>=0 && i<=9){
          ll nr = el*10+i;
          if (st.count(nr)==0){
            st.insert(nr);
            a.push(el*10+i);
          }
        }
      }
    }
  }
}



Measured memory_bytes: 15488
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string sa, sb;
	cin >> sa >> sb;
	if ((sa[0] == sb[2]) && (sa[1] == sb[1]) && (sa[2] == sb[0])) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = ((a * b) % 2 == 0) ? "Even" : "Odd";
    System.out.println(s);
  }
}

Measured memory_bytes: 21460
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

long long e, v;

class pass
{
public:
	long long t;
	long long c;
	long long p;
};

pass p[250000];

long long noded[2000];
pair<long long, long long> nodef[2000];
vector<long long> node[2000];

void add(long long f, long long t, long long c)
{
	p[e].t = t;
	p[e].c = c;
	p[e].p = e + 1;
	p[e + 1].t = f;
	p[e + 1].c = 0;
	p[e + 1].p = e;
	node[f].push_back(e);
	node[t].push_back(e + 1);
	e += 2;
}

void push()
{
	queue<long long> q;
	for (int i = 0; i < v; i++)
	{
		noded[i] = 0;
		nodef[i] = make_pair(0, 0);
	}
	noded[0] = v;
	for (auto i : node[0])
	{
		if (p[i].c > 0)
		{
			p[p[i].p].c += p[i].c;
			nodef[p[i].t].first += p[i].c;
			nodef[0].second += p[i].c;
			p[i].c = 0;
			q.push(p[i].t);
		}
	}
	nodef[v - 1].second = (1 << 20);
	while (!q.empty())
	{
		long long np = q.front();
		q.pop();
		while (1)
		{
			for (auto i : node[np])
			{
				if (p[i].c > 0)
				{
					long long t = p[i].t;
					if (noded[np] == noded[t] + 1)
					{
						long long kae = min(p[i].c, nodef[np].first - nodef[np].second);
						p[i].c -= kae;
						p[p[i].p].c += kae;
						nodef[np].second += kae;
						bool w = (nodef[t].first <= nodef[t].second);
						nodef[t].first += kae;
						if (w && nodef[t].first > nodef[t].second)
						{
							q.push(t);
						}
						if (nodef[np].first <= nodef[np].second)
						{
							break;
						}
					}
				}
			}
			if (nodef[np].first > nodef[np].second && np != 0)
			{
				long long minw = (1 << 20);
				for (auto i : node[np])
				{
					if (p[i].c > 0)
					{
						minw = min(minw, noded[p[i].t]);
					}
				}
				noded[np] = minw + 1;
			}
			else
			{
				break;
			}
		}
	}
}

long long dn[2000];
long long dm[2000];

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

int main()
{
	while (1)
	{
		long long n, m;
		scanf("%lld%lld", &n, &m);
		if (n == 0)
		{
			break;
		}
		v = n + m + 2;
		e = 0;
		for (long long i = 0; i < n; i++)
		{
			scanf("%lld", &dn[i]);
			add(0, 1 + i, 1);
		}
		for (long long i = 0; i < m; i++)
		{
			scanf("%lld", &dm[i]);
			add(n + 1 + i, n + m + 1, 1);
		}
		for (long long i = 0; i < n; i++)
		{
			for (long long ii = 0; ii < m; ii++)
			{
				if (1 < gcd(dn[i], dm[ii]))
				{
					add(1 + i, n + 1 + ii, 1);
				}
			}
		}
		push();
		long long all = 0;
		for (auto i : node[0])
		{
			if (i % 2 == 0)
			{
				all += p[p[i].p].c;
			}
		}
		printf("%lld\n", all);
		for (long long i = 0; i < v; i++)
		{
			node[i].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 10956
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<int MOD>
class ModInt {
public:
    ModInt() :value(0) {}
    ModInt(long long val) :value((int)(val<0 ? MOD + val % MOD : val % MOD)) { }

    ModInt& operator+=(ModInt that) {
        value = value + that.value;
        if (value >= MOD)value -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        value -= that.value;
        if (value<0)value += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that) {
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) const {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) const {
        return ModInt(*this) *= that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const {
        ModInt n = *this, res = 1;
        while (k) {
            if (k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const { return value; }

private:
    int value;
};
typedef ModInt<1000000007> mint;
ostream& operator<<(ostream& os, const mint& x) {
    os << x.toi();
    return os;
}

mint dp[3001][3001];

void solve() {
    int N;
    char S[3003];
    cin >> N >> (S + 1);
    S[0] = '<';

    dp[0][0] = 1;

    rep(i, N) {
        mint sm = 0;
        if (S[i] == '<') {
            for (int r = N - i; r >=1; --r) {
                int l = N - i - r;
                sm += dp[i][l];
                dp[i + 1][N - i - r] += sm;
            }
        } else {
            for (int l = N - i; l >= 1; --l) {
                sm += dp[i][l];
                dp[i + 1][l - 1] += sm;
            }
        }
    }

    cout << dp[N][0] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

    ll n, s;
    cin >> n >> s;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    rep(i,n) x[i] = abs(x[i]-s);

    ll ans = gcd(x[0], x[1]);
    rep(i,n-1){
        ans = min(ans, gcd(x[i], x[i+1]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
def main(s)
  min_count = s.size
  pre_change_count = 0
  suf_change_count = s.count("E")
  s.each_char do |char|
    suf_change_count -= 1 if char == "E"
    min_count = [min_count, pre_change_count + suf_change_count].min
    pre_change_count += 1 if char == "W"
  end
  min_count
end

_ = gets.to_i
s = gets.chomp
puts main(s)

Measured memory_bytes: 2436
import math
 
 
def comb(n, r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)
 
 
def main():
    n, p = map(int, input().split())
    a = tuple(map(lambda x: int(x) % 2, input().split()))
 
    if n == 1 and a[0] % 2 != p:
        print(0)
        return 0
 
    t = len(tuple(filter(lambda x: x == 1, a)))
    f = n - t
 
    f_comb = 0
    for j in range(f + 1):
        f_comb += comb(f, j)
 
    t_comb = 0
    if p == 0:
        for i in range(t + 1):
            if i % 2 == 0:
                t_comb += comb(t, i)
    else:
        for i in range(t + 1):
            if i % 2 == 1:
                t_comb += comb(t, i)
 
    print(int(t_comb * f_comb))
 
    return 0
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
#include<math.h>

int sprInput(char *retstr, char *str, int strnum)
{
	char buf[256]={};
	int h, i, j;

	i = 0;
	for(h=0;h<strnum;h++){
		memset(buf, '\0', sizeof(buf));
		j = 0;
		if (str[i] == '\0') break;
		while(str[i] != ' ' && str[i] != '\n' && str[i] != '\0')
		{
			buf[j] = str[i];
			i++;
			j++;
		}
		i++;
	}
	memcpy(retstr, buf, sizeof(buf));

	return (retstr[0] == '\0' ? 0 : 1);
}

int main(int argc, char *argv[])
{
	int sInput;
	int a, b, c, buf2;
	int i;
	char str[256]={};
	char buf[256]={};

	fgets(str, 256, stdin);

	sprInput(buf, str, 1);
	a = atoi(buf);
	sprInput(buf, str, 2);
	b = atoi(buf);
	sprInput(buf, str, 3);
	c = atoi(buf);

	for( i=0; i<2; i++){
		if( a>b ){
			buf2 = a;
			a = b;
			b = buf2;
		}
		else{
			/* 処理なし	*/
		}
		if( b>c ){
			buf2 = b;
			b = c;
			c = buf2;
		}
		else{
			/* 処理なし	*/
		}
	}

	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 528
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;

    return res;
}
int findlcm(int arr[], int n) 
{ 
    // Initialize result 
    int ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans))); 
  
    return ans; 
}
bool prime[100001];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}

//Define mx for maximum range and MOD for large numbers
#define mx 101
#define MOD 1000000007;

// Declare all the variables and global functions here - 
int n,m;
int32_t main()
{
    IOS;
 //    #ifndef ONLINE_JUDGE
 //    freopen("input.txt","r",stdin);
 //    freopen("output.txt","w",stdout);
	// #endif
    /********************* From here **********************/
    
    int r,d,x;
    cin >> r >> d >> x;
    rep(i, 0, 10){
    	cout << r*x - d << endl;
    	x = r*x - d;
    }

    
}

Measured memory_bytes: 256
using System;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

class program{
  static void Main(string[] args){
    program p= new program();
      p.Run();
  }
  void Run(){
    int[] inp=Readint();
    int r=inp[0];
    int D=inp[1];
    int x=inp[2];
    for(int i=0;i<10;i++){
      x=r*x-D;
      WriteLine(x.ToString());
    }
  }
  int[] Readint(){
    string[] inp= ReadLine().Split();
    int n=inp.Length;
    int[] res=new int[n];
    for(int i=0;i<n;i++){
      res[i]=int.Parse(inp[i]);
    }
    return res;
  }
}

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

int main()
{
    char S[4];

    cin >> S;
    if (S[0] == S[1] || S[1] == S[2] | S[2] == S[3])
    {
        cout << "Bad";
    }
    else
    {
        cout << "Good";
    }
}

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

ll com(ll a){
	ll res = a*(a-1);
    res /= 2;
	return res;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> in(n);
    vector<ll> ns(n);
    ll ans = 0;
    rep(i, n) ns.at(i) = 0;
    rep(i, n){
        cin >> in.at(i);
        ns.at(in.at(i)-1)++;
    }
    rep(i, n){
        if(ns.at(i) >= 2) ans += com(ns.at(i));
    }
    ll out = 0;
    rep(i, n){
        out = 0;
        if(ns.at(in.at(i)-1) >= 3){
            out = ans - com(ns.at(in.at(i)-1)) + com(ns.at(in.at(i)-1)-1);
        }else if(ns.at(in.at(i)-1) == 2){
            out = ans - 1;
        }else{
            out = ans;
        }
        cout << out << endl;
    }
    return 0;
}


Measured memory_bytes: 5760