akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn in_digit(mut x: u32, a: u32, b: u32) -> bool {
    let mut sum = 0;
    while x > 0 {
        sum += x % 10;
        x /= 10;
    }
    a <= sum && sum <= b
}

use std::collections::HashSet;

fn main() {
    input! {
        n: u32,
        m: [u32; n]
    }
    let mut v: Vec<u32> = m;
    v.sort();
    let mut mochi = HashSet::new();
    for &item in v.iter() {
        mochi.insert(item);
    }
    println!(
        "{}",
        mochi.len()
    )
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
	string tap;
  int flg = 0;
    cin >> tap;
 
  for(int i = 0;i < tap.length();i++)
  {
  	if(i % 2 )
    {
      if(tap[i] == 'R')
        flg = 1;
    }
      else
      {
        if(tap[i] == 'L')
          flg = 1;
      }
  }
  
  if(flg)
    cout << "No";
  else
    cout << "Yes";
  
  return 0;
}

Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  vector<ll> S(n+1, 0);
  rep(i, n) S[i+1] = S[i] + a[i];
  vector<vector<ll>> dp(n, vector<ll>(n+1, 0));
  rep(w, 2, n+1) rep(l, n) {
    ll r = l + w;
    if (r > n) break;
    dp[l][r] = linf;
    rep(m, l+1, r) {
      chmin(dp[l][r], dp[l][m] + dp[m][r] + S[r] - S[l]);
    }
    // cout << l << " " << r << " " << dp[l][r] << endl;
  }
  cout << dp[0][n] << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
#define TRACE(x) cerr << #x << " = " << x << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define SZ(x) (int)(x).size()
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
template<class Num>
Num mabs(Num A){
  if(A < 0) return -A;
  return A;
}

const int N = 1 << 18;

struct Tour{
  int n, off;
  vector<int> tree;
  
  Tour(int _n){
    n = _n;
    int i;
    for(i = 1; i <= n; i *= 2);
    off = i;
    tree.resize(2 * off + 1);
  }
  
  void build(int node, int a, int b){
    if(a == b){
      tree[node] = 0;
      return;
    }
    int mid = (a + b) / 2;
    build(node * 2, a, mid);    
    build(node * 2 + 1, mid + 1, b);    
    tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
  }
  
  void update(int node, int a, int b, int pos, int val){
    if(a == b){
      tree[node] = max(tree[node], val);
      return;
    }
    int mid = (a + b) / 2;
    if(pos <= mid)
      update(node * 2, a, mid, pos, val);
    else
      update(node * 2 + 1, mid + 1, b, pos, val);
      
    tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
  }
  
  pii walk(int node, int a, int b, int least){
    if(a == b) return mp(a, tree[node]);
    int mid = (a + b) / 2;
    if(tree[node * 2] >= least)
      return walk(node * 2, a, mid, least);
    else return walk(node * 2 + 1, mid + 1, b, least);
  }
  
  int query(int least){
    if(tree[1] < least) return n;
    return walk(1, 0, off - 1, least).fi;
  }
  
  void build(){
    build(1, 0, off - 1);
  }
  
  void update(int p, int val){
    update(1, 0, off - 1, p, val);
  }
  
  
  /*
   
  int get(int least){    
    if(tree[1] < least) return N;
    return walk(1, 0, off - 1, least).se;
  }
  
  
  int qq(int node, int a, int b, int pos){
    if(a == b) return tree[node];
    int mid = (a + b) / 2;
    if(pos <= mid) return  qq(node * 2, a, mid, pos);
    return qq(node * 2 + 1, mid + 1, b, pos);
  }
  
  int get_pos_val(int p){
    return qq(1, 0, off - 1, p);
  }
   
  */
  
};

int n, q;

int main(){
  scanf("%d %d", &n, &q);
  Tour rows(n), cols(n);
  rows.build(); cols.build();
  
  ll ans = (ll)(n - 2) * (ll)(n - 2);
  
  while(q--){
    int f, x; scanf("%d %d", &f, &x);
    if(f == 1){
      //x-ta kolona, spustam dolje
      int dokle = rows.query(x);
      ans -= (ll)(dokle - 2);
      cols.update(x, dokle);
    }
    
    else{
      int dokle = cols.query(x);
      ans -= (ll)(dokle - 2);
      rows.update(x, dokle);
    }
  }
  
  printf("%lld\n", ans);
  
  return 0;
}


Measured memory_bytes: 7496
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int t = 0;
	char s[4];
	REP(i,4){
		cin >> s[i];
		if(s[i] == '+'){
			t++;
		}else{
			t--;
		}
	}
	cout << t << endl;
	return 0;
}


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

int main()
{
	int a,b;		
	cin>>a>>b;		
	if(a%3==0 || b%3==0 || (a+b)%3==0)
cout<<"Possible"<<endl;
	else
	cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r*g*b
for x in range(N):
    for a in range(N):
        y = x+a
        z = y+a
        if z >= N:
            continue
        if S[x] == S[y]:
            continue
        if S[y] == S[z]:
            continue
        if S[x] == S[z]:
            continue
        ans = ans-1
print(ans)

Measured memory_bytes: 73704
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	int n,m;
	int A[100][100],b[100],v[100];

	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			A[i][j] = 0;
		}
		b[i] = 0;
		v[i] = 0;
	}
	 
	cin >> n >> m;

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> A[i][j];
		}
	}
	for(int i=0;i<m;i++){
		cin >> b[i];
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			v[i] += A[i][j] * b[j];
		}
		cout << v[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3132
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n;cin>>n;
  cout<<((n+1)/2)*(n/2)<<endl;

  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

ll gcb(ll a, ll b){/// ユークリッドの互除法: O(log)
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}

int getDigit(ll num){
    return log10(abs(num))+1;
}


int main() {
    int n;cin>>n;
    int x;cin>>x;
    vector<int>a(n);cin>>a;
    sort(all(a));
    int i = 0;
    int c = 0;
    while(i<n){
        
        if(x>=a[i]){
            c++;
            x -=a[i];
        }else{
            break;
        }
        i++;
    }
    
    if(i== n && x!=0) c--;
    
    cout<<c<<endl;
    return 0;
}










Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

map<string, vector<string> > recipe;
map<string, int> cost;

int search(string item){
    if(recipe[item].size() == 0) return cost[item];
    else {
        int sum = 0;
        for(int i=0; i<recipe[item].size(); i++){
            sum += search(recipe[item][i]);
        }
        return min(cost[item], sum);
    }
}

int main(){
    int n;
    while(cin >> n, n){
        recipe.clear(); cost.clear();
        for(int i=0; i< n; i++){
            string name; int m;
            cin >> name >> m;
            cost[name] = m;
        }
        cin >> n;
        for(int i=0; i< n; i++){
            string item;
            cin >> item;
            int m;
            cin >> m;
            for(int j=0; j < m; j++){
                string material;
                cin >> material;
                recipe[item].push_back(material);
            }
        }
        string item;
        cin >> item;
        cout << search(item) << endl;
    }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int i,arr[1005];
    double ans;
    ans=1*1.0/(4*m);
    //cout<<"ans "<<ans<<endl;
    long long int sum=0;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    int c=0;
    int flag=0;
    for(i=0;i<n;i++)
    {
        double value;
        value=arr[i]*1.0/sum;
        //cout<<value<<endl;
        if(value>=ans)
        {
            c++;
        }
        if(c==m)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
w = list(input())
w_num = {}

for i in w:
    if i in w_num.keys():
        w_num[i] += 1
    else:
        w_num[i] = 0
        w_num[i] += 1

flag = True
for value in w_num.values():
    if value % 2 == 1:
        flag = False
        break

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

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
    int a,b;
    for(int i = 0; i < 3000;i++){
        cin >> a >> b;
        if(a == 0 && b == 0)break;
        if(a > b)cout << b << " " << a << endl;
        else cout << a << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 2996
#include<stdio.h>
#include<math.h>
int main()
{
          int T,A[1000],i,j,k;
          double m,Tot=0,a=0,ans1,ans;
         while(1){
                    scanf("%d",&T);
         if(T==0)
         {
                   return 0;
         }
          for(j=0;j<T;j++)
          {
                    scanf("%d",&A[j]);
          }
          for(i=0;i<T;i++)
          {
                    Tot=Tot+A[i];
          }
          m=Tot/T;
          for(i=0;i<T;i++)
          {
                    a=a+((A[i]-m)*(A[i]-m));
          }
          ans1=a/T;
          ans=sqrt(ans1);
          printf("%.8lf\n",ans);
          ans=0;
          ans1=0;
          Tot=0;
          m=0;
          a=0;
         }

          return 0;

}



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

//cmdで g++ test.cpp とするとコンパイルできる
typedef long long ll;
typedef pair<int,int> pii;

const int MOD=1000000007;

int main() {
    vector<vector<int>> A(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A.at(i).at(j);
        }
    }
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int b;
        cin>>b;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(A.at(j).at(k)==b){
                    A.at(j).at(k)=0;
                }
            }
        }
    }
    bool bingo=false;
    for(int i=0;i<3;i++){
        if(A.at(i).at(0)==0 && A.at(i).at(1)==0 && A.at(i).at(2)==0)bingo=true;
    }
    for(int i=0;i<3;i++){
        if(A.at(0).at(i)==0 && A.at(1).at(i)==0 && A.at(2).at(i)==0)bingo=true;
    }
    if(A.at(0).at(0)==0 && A.at(1).at(1)==0 && A.at(2).at(2)==0)bingo=true;
    if(A.at(2).at(0)==0 && A.at(1).at(1)==0 && A.at(0).at(2)==0)bingo=true;
    cout<<(bingo?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){ 
    vector<int> v{0,1,3,1,2,1,2,1,1,2,1,2,1};
    int n, m; cin >> n >> m;
    if(v[n]==v[m])cout << "Yes" << ln;
    else cout << "No" << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,maxa=0,c=0,ans=0;
  cin>>N;
  if(N==1){cout<<1<<endl;return 0;}
  unordered_map<ll,ll> mp;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    mp[A.at(i)]++;
    if(i>0&&A.at(i)==A.at(i-1)){c++;}
    if(maxa<A.at(i)){maxa=A.at(i);}
  }
  if(c==N-1){cout<<0<<endl;return 0;}
  if(mp[1]==1){cout<<1<<endl;return 0;}
  if(mp[1]>1){cout<<0<<endl;return 0;}
  sort(A.begin(),A.end());
  for(ll i=0;i<N;i++){
    ll a=A.at(i);
    if(mp[A.at(i)]>1){mp[A.at(i)]=0;}
    for(ll j=2;j*a<=maxa;j++){
      if(mp[j*a]>0){mp[j*a]=0;}
    }
  }
  for(ll i=2;i<=maxa;i++){
    if(mp[i]>0){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 44136
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] s = new int[N];
		for(int i = 0 ; i < N ; i++) {
			s[i] = sc.nextInt();
		}
		Arrays.sort(s);
		int total = 0;
		for(int i = 0 ; i < N ; i++) {
			total += s[i];
		}
		for(int i = 0 ; i < N ; i++) {
			if(total % 10 != 0) {
				System.out.println(total);
				return;
			} else if(s[i]%10!=0){
				total -= s[i];
				
			}
		}
		System.out.println(0);
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N,D,X; cin>>N>>D>>X;
  vector<int> A(N);
  for(auto& a : A) {
    cin >> a;
  }

  int eated = 0;
  for(auto a : A) {
    int day = 1;
    while(day <= D) {
      eated++;
      day += a;
    }
  }

  cout << eated + X << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if (n <= k) cout << x*n << endl; 
    else cout << x*k + y*(n-k) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



string s;

int main () {
  cin >> s;
  stack<char> st;

  Rep(i, s.size()) {
    char tmp = s[i];

    if (tmp == 'S') {
      st.push('S');
    } else {
      if (st.size() >= 1 && st.top() == 'S') {
        st.pop();
      } else {
        st.push('T');
      }
    }
  }

  cout << st.size() << "\n";
}

Measured memory_bytes: 644
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int h, w;
string masu[2001];
int intMasu[2001][2001] = {0};

int wRenzoku (int nowH, int index, int count)
{
  if (index == w - 1) {
    if (masu[nowH][index] == '#') {
      intMasu[nowH][index] = 0;
    } else {
      intMasu[nowH][index] += ++count;
    }
    return count;
  } else if (masu[nowH][index] == '#') {
    intMasu[nowH][index] = 0;
    wRenzoku(nowH, index + 1, 0);
    return count;
  } else {
    int res;
    res = wRenzoku(nowH, index + 1, count + 1);
    intMasu[nowH][index] += res;
    return res;
  }
}

int hRenzoku (int nowW, int index, int count)
{
  if (index == h - 1) {
    if (masu[index][nowW] == '#') {
      intMasu[index][nowW] = 0;
    } else {
      intMasu[index][nowW] += ++count;
    }
    return count;
  } else if (masu[index][nowW] == '#') {
    intMasu[index][nowW] = 0;
    hRenzoku(nowW, index + 1, 0);
    return count;
  } else {
    int res;
    res = hRenzoku(nowW, index + 1, count + 1);
    intMasu[index][nowW] += res;
    return res;
  }
}

int main()
{
  cin >> h >> w;

  for (int i = 0; i < h; i++) {
    string tmp;
    cin >> tmp;
    masu[i] = tmp;
  }

  for (int i = 0; i < h; i++) {
    wRenzoku(i, 0, 0);
  }
  for (int i = 0; i < w; i++) {
    hRenzoku(i, 0, 0);
  }

  int res = -1;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      res = max(res, intMasu[j][i]);
    }
  }
  cout << res - 1 << endl;
}


Measured memory_bytes: 20224
import std.stdio, std.ascii, std.conv, std.math, std.string;

uint strToUint(string str) {
  char[] chars = str.to!(char []);
  uint res = 0;
  foreach(i, c; chars) {
    uint n;
    if (isAlpha(c)) n = (c - 'a') + 10;
    else if (isDigit(c)) n = c - '0';
    res += n;
    if (i != 7) res <<= 4;
  }
  return res;
}

void show(uint n) {
  int integer = (n & 0x7FFFFFFF) >> 7;
  int dec = (n & 0x7F) * 78125;
  int len = 7;
  // 符号ビット
  if (((n >> 31) & 1) == 1) write("-");
  while (len > 1 && (dec % 10) == 0) {
    len--;
    dec /= 10;
  }
  writef("%d.%0*d\n", integer, len, dec);
}

void main() {
  for(int n; readf("%d\n", &n);) {
    foreach(t; 0..n) {
      readln.chomp.strToUint.show;
    }
  }
}

Measured memory_bytes: 1232
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = [list(map(int, readline().split())) for _ in range(3)]
    N, *B = map(int, read().split())

    nums = [False] * 101
    for b in B:
        nums[b] = True

    for i in range(3):
        ok = True
        for j in range(3):
            if not nums[A[i][j]]:
                ok = False
                break

        if ok:
            print('Yes')
            return

    for j in range(3):
        ok = True
        for i in range(3):
            if not nums[A[i][j]]:
                ok = False
                break

        if ok:
            print('Yes')
            return

    if nums[A[0][0]] and nums[A[1][1]] and nums[A[2][2]]:
        print('Yes')
        return

    if nums[A[0][2]] and nums[A[1][1]] and nums[A[0][2]]:
        print('Yes')
        return

    print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

   ll n;
   cin>>n;
   ll arr[n+5]={0};
   ll alice=0;
   ll bob=0;
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];

   }
   sort(arr,arr+n,greater<ll>());
   for(int i=0;i<n;i++)
   {
       if(i%2==0)
       {
           alice+=arr[i];
       }
       else
       {
           bob+=arr[i];
       }
   }
   cout<<alice-bob<<endl;

}


Measured memory_bytes: 3640
n = int(input())
a = list(map(int, input().split()))
 
 
def gcd(x,y):
    while y:
        x,y = y, x % y
    return x
    
gcd_left = [0]
gcd_rigth = [0]
gcd_list = []

for i in range(n):
    s = gcd(gcd_left[i], a[i])
    gcd_left.append(s)
    
for i in range(n):
    t = gcd(gcd_rigth[i], a[-i-1])
    gcd_rigth.append(t)

for i in range(n):
    v = gcd(gcd_left[i], gcd_rigth[n-1-i])
    gcd_list.append(v)

print(max(gcd_list))


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

int main() {
	int x_1, y_1, x_2, y_2;
	cin >> x_1 >> y_1 >> x_2 >> y_2;
	
	int dif_x = x_2 - x_1;
	int dif_y = y_2 - y_1;

	int x_3 = x_2 - dif_y;
	int y_3 = y_2 + dif_x;
	int x_4 = x_1 - dif_y;
	int y_4 = y_1 + dif_x;
	
	cout << x_3 << ' ' << y_3 << ' ' << x_4 << ' ' << y_4 << endl;
}


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

int main(void){
	string S;
	cin >> S;
	vector<int> cnt(3);
	for(int i=0;i<S.size();i++){
		if(S[i]=='a')cnt[0]++;
		else if(S[i]=='b')cnt[1]++;
		else cnt[2]++;
	}
	sort(cnt.begin(),cnt.end());
	if(cnt[2]-cnt[0]<=1){
		cout << "YES" << endl;
	}else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int a[100][100]={0};
    int b[100][100]={0};
    long c[100][100]={0};

    int n,m,l;

    cin >>n >>m >>l;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >>a[i][j];
        }
    }

    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> b[i][j];
        }
    }


    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j==l-1){
                cout << c[i][j];
            }
            else{
                cout << c[i][j] << " ";
            }
        }
        cout <<endl;
    }


    return 0;
}



Measured memory_bytes: 3256
import numpy as np

def multiple(nums):
    result_log = 0
    result = 1
    if (np.any(np.array(a) == 0)): return 0

    for a_ in a:
        result_log += np.log10(a_)
        if (result_log > 18.0):
            return -1
        result *= a_
        if (result > 10**18):
            return -1
    return result

n = int(input())
a = list(map(int, input().split()))
print(multiple(a))



Measured memory_bytes: 40032
X = int(input())
n = 1
if X<=3:
    print(1)
elif X==4:
    print(4)
else:
    n = 4
    for i in range(2,int(X**0.5)+1):
        b = i
        k = 1
        while b**k<=X:
            k += 1
        k -= 1
        if k>=2:
            n = max(n,b**k)
    print(n)

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

int main()
{
    double n, X;
    cin >> n;
    X = n / 1.08;
    if(floor(floor(X)*1.08) == n)
    	cout << floor(X) << endl;
    else if(floor(ceil(X)*1.08) == n)
    	cout << ceil(X) << endl;
    else
    	cout << ":(" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=((ans%mod)*(x%mod))%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
int main()
{
fast_io
string s;
cin>>s;
li a[2]={0};
for(li i=0;i<3;i++)
a[s[i]-'A']++;
if((a[0]==0)||(a[1]==0))
cout<<"No";
else
cout<<"Yes";

  return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + (y1 - y2) << " " << y2 - (x1 - x2) << " " << x1 + (y1 - y2) << " " << y1 - (x1 - x2) << endl;
    return 0;
}

Measured memory_bytes: 3656
from math import atan2

class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

class Vector(object):
    def __init__(self, p1, p2):
        self.x = p2.x - p1.x
        self.y = p2.y - p1.y

    def cross(self, other: "Vector") -> float:
        return self.x*other.y - self.y*other.x

def grahams_scan(a: list):
    a.sort(key=lambda p: p.y)
    bottom_x, bottom_y = a[0].x, a[0].y
    _a = sorted(a[1:], key=lambda p: atan2(bottom_y-p.y, bottom_x-p.x)) + [a[0]]
    result = [a[0], _a[0]]

    for next_point in _a[1:]:
        while Vector(result[-1], result[-2]).cross(Vector(result[-1], next_point)) >= 0:
            result.pop()
        result.append(next_point)
    return result

while True:
    n = int(input())
    if not n:
        break
    a = [Point(*map(float, input().split(","))) for _ in [0]*n]
    result = grahams_scan(a)
    print(n-len(result)+1)


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

int main(void){
  int n,x;
  while(1){
    int ans=0;
    cin >> n >> x;
    if (n==0 && x==0) break;
    for (int i=1; i<=n; i++){
      for (int j=i+1; j<=n; j++){
        int k=x-i-j;
        if (k>j && k<=n){
          //cout << i << " " << j << " " << k << endl;
          ans++;
        }
      }
    }cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            var output = double.PositiveInfinity;
            for (var A = 1L; A <= Math.Sqrt(N); A++)
            {
                if (N % A == 0)
                {
                    var B = N / A;
                    output = Math.Min(output, Math.Max(NumberOfDigits(A), NumberOfDigits(B)));
                }
            }

            Console.WriteLine(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13140
/*
    [Gnana Deepak]
    [August 01, 2020 5:39 PM]
    [B - Frog 2]
    [https://atcoder.jp/contests/dp/tasks/dp_b]
    [2000 ms]
    [1024 MB]
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ld = long double;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define F first
#define S second
#define orderKey order_of_key
#define findOrder find_by_order
#define s(x) set<x>
#define um(x, y) unordered_map<x, y>
#define m(x, y) map<x, y>
#define p(x, y) pair<x, y>
#define v(x) vector<x>
#define min_heap(t) priority_queue<t, vector<t>, greater<t>>
#define max_heap(t) priority_queue<t>
#define ordered_set(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define eb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define ss(v) stable_sort(all(v))
#define fori(i, a, b) for (int i = a; i <= b; i++)
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define stprs(x) cout << fixed << setprecision(x);
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define bs binary_search
#define deb(x) cout << #x << "=" << x << '\n';
#define scn(v1)        \
    for (auto &x : v1) \
        cin >> x;
#define R(x) reverse(all(x));
#define lb lower_bound
#define ub upper_bound
const char nl = '\n';
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const ld PI = acos(-1);
const int N = 1e5;
const int INF = 3e18 + 5;
const int imx = LLONG_MAX;
int DP[N + 1];
int H[N + 1];
void accio_ac(void)
{
    int n, k;
    cin >> n >> k;
    fori(i, 1, n) cin >> H[i];
    DP[1] = 0;
    fori(i, 2, n)
    {
        DP[i] = INF;
        int cnt = 0;
        for (int j = i - 1; j > 0 and cnt != k; --j)
        {
            DP[i] = min(DP[i], DP[j] + abs(H[j] - H[i]));
            cnt += 1;
        }
    }
    cout << DP[n] << endl;
}
int32_t main(void)
{
    fastio;
    int __ = 1;
    // cin >> __;
    while (__--)
    {
        accio_ac();
    }
    return 0;
}


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

int n;
long double p, ans, dp[3005][2];

int main() {
    cin >> n;
    dp[0][1] = 1;
    for (int i = 0; i < n; i++){
        cin >> p;
        dp[0][i&1] = 0;
        for (int j = 0; j <= i; j++){
            dp[j+1][i&1] = dp[j][(i&1)^1] * p;
            dp[j][i&1] += dp[j][(i&1)^1] * (1.0-p);
        }
    }
    for (int i = n; i > n/2; i--){
        ans += dp[i][0];
    }
    cout << fixed << setprecision(15) << ans << "\n";
}


Measured memory_bytes: 3916
#include <stdio.h>
#include <string.h>

int x, y;
const int dx[2][6] = {{-1, -1, -1, 0, 1, 0}, {0, -1, 0, 1, 1, 1}};
const int dy[2][6] = {{-1, 0, 1, -1, 0, 1}, {-1, 0, 1, -1, 0, 1}};

void paint(int ty, int tx, int map[102][102]){
    int my, mx;
    int i, j;
    
    map[ty][tx] = 2;
    
    for (i = 0; i < 6; i++){
        mx = tx + dx[ty % 2][i];
        my = ty + dy[ty % 2][i];
        if (0 <= mx && mx <= x + 1 && 0 <= my && my <= y + 1 && map[my][mx] == 0){
            paint(my, mx, map);
        }
    }
}

int main(void)
{
    int map[102][102];
    int mx, my;
    int i, j, k;
    int ans;
    
    scanf("%d%d", &x, &y);
    
    memset(map, 0, sizeof(map));
    for (i = 1; i <= y; i++){
        for (j = 1; j <= x; j++){
            scanf("%d", &map[i][j]);
        }
    }
    
    paint(0, 0, map);
    
    ans = 0;
    for (i = 1; i <= y; i++){
        for (j = 1; j <= x; j++){
            if (map[i][j] == 1){
                for (k = 0; k < 6; k++){
                    if (map[i + dy[i % 2][k]][j + dx[i % 2][k]] == 2){
                        ans++;
                    }
                }
            }
        }
    }
    
    printf("%d\n", ans);
    
    return (0);
}

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

int main(){
    string date;

    cin >> date;
    if(date[6] != '1' && date[6] != '2' && date[6] != '3' && date[6] != '4')
        cout << "TBD" << endl;
    else if (date[5] == '1')
        cout << "TBD" << endl;
    else 
        cout << "Heisei" << endl;

    return 0;
}

Measured memory_bytes: 256
//前置き
#pragma region

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

bool EVEN(ll a);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

#pragma endregion
ll calc(ll a, ll b, ll  x){
    if(a % x == 0) return  b / x - a / x +1;
    else return  b / x  - a / x;
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = lcm(c, d);
    ll cntc = calc(a, b, c), cntd = calc(a, b, d), cnte = calc(a, b, e);
    
    cout << b - a + 1 - (cntc + cntd - cnte) << endl;
}

//関数定義
#pragma region 
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2-1;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}  

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

#pragma endregion


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,a[200005];
    int count=1,i;
    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i] == count)
            count++;
    //printf("%d ",count);
    }
    if(count != 1)
        printf("%d ",n-count+1);
    else
        printf("-1");
return 0;
}


Measured memory_bytes: 896
def TwoInt(x, y):
    if x % y == 0:
        return -1
    i = 2
    while (x * i) <= 1e+18:
        if (x * i) % y != 0:
            return x * i
        i += 1
    return -1

if __name__ == '__main__':
    e = input().rstrip().split(' ')
    e = [int(e[i]) for i in range(len(e))]

    print(TwoInt(e[0], e[1]))

Measured memory_bytes: 3060
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    } else if (s == "Rainy"){
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define mp make_pair
#define pb push_back
void solve(){
	ll n,k;
	cin>>n>>k;
	int a[n+1];
	for (int i = 1; i <= n; i++)
	{
		cin>>a[i];
	}
	int steps[n+1]={0};
	int cur=1;
	ll i=1;
	for(;i<=k;i++){
		cur=a[cur];
		if(!steps[cur])
			steps[cur]=i;
		else
			break;
	}
	
	if(i<=k){
		int cyc=(k-steps[cur])%(i-steps[cur]);
		for(int j=1;j<=cyc;j++){
			cur=a[cur];
		}
		cout<<cur<<endl;
	}
	else
		cout<<cur<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--)
		solve();
}



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

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;

int n,a;
int arr[100100];

int main(){
    memset(arr,0,sizeof arr);
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%d", &a);
        arr[a]++;
        arr[a+1]++;
        arr[a+2]++;
    }
    a = -1;
    for (int i=0; i<100100; i++){
        a = max(a, arr[i]);
    }
    printf("%d\n", a);
    return 0;
}


Measured memory_bytes: 640
// Problem : T - Permutation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_t
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 3005

//Solution

int n;
string s;
int dp[N][N];
int pre[N],suf[N];

void solve(){
    cin>>n>>s;
    dp[1][1] = 1;
    pre[1] = 1;
    suf[1] = 1;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(s[i-2] == '<') (dp[i][j] += pre[j-1]) %= mod;
            else (dp[i][j] += suf[j]) %= mod;
        }
        pre[1] = dp[i][1];
        for(int j=2;j<=i;j++) pre[j] = (pre[j-1]+dp[i][j])%mod;
        suf[i] = dp[i][i];
        for(int j=i-1;j>=1;j--) suf[j] = (suf[j+1]+dp[i][j])%mod;
    }
    int ans = 0;
    for(int i=1;i<=n;i++) (ans += dp[n][i]) %= mod;
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 74056
##B - Making Triangle
N = int(input())
L = list(map(int,input().split()))

ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (L[i] + L[j] > L[k]) and (L[j] + L[k] > L[i]) and (L[k] + L[i] > L[j]) and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                ans += 1

print(ans)

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

int main(){
  string s;
  int n,i,a,maxa;
  cin >> s;
  n=s.size();
  
  a=0;
  maxa=0;
  for(i=0;i<n;i++){
    if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
      a++;
    }else{
      maxa=max(a,maxa);
      a=0;
    }
  }
  
  maxa=max(maxa,a);
  cout << maxa << endl;
}

Measured memory_bytes: 3616
from itertools import combinations
N = int(input())
d = {}
for _ in range(N):
    s = input()
    if not s[0] in ("M","A","R","C","H"):
        continue
    if s[0] in d.keys():
        d[s[0]] += 1
    else:
        d[s[0]] = 1
ret = 0
comb = combinations(d.values(), 3)
for i in comb:
    tmp = 1
    for j in i:
        tmp *= j
    ret += tmp

print(ret)


Measured memory_bytes: 45544
#include <stdio.h>

int Ans(int N){
  int n;
  for(n = 111;n < 999;n += 111) if(n - 111 < N && N <= n) break;
  return n;
}

int main(void){
  int N;
  scanf("%d", &N);
  printf("%d\n", Ans(N));
  return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();

    rep(i, n) {
        if (s == t) break;
        string ns;
        ns += s[n - 1];
        rep(i, n - 1) ns += s[i];
        s = ns;
    }

    if (s == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    string s;
    cin>>s;
    bool p=s[0]=='R';
    bool q=s[1]=='R';
    bool r=s[2]=='R';
    if(p && q && r)cout<<3<<endl;
    else if((p && q)||(q&&r))cout<<2<<endl;
    else if(p||q||r)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,c=0;cin>>n;
  int m=M,a;
  rep(i,n){
    cin>>a;
    if(chmin(m,a))c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
k = ni()

ans = 1
for i in range(n):
    if ans <= k:
        ans *= 2
    else:
        ans += k
print(ans)


Measured memory_bytes: 2940
while True:
    a, op, b = input().split()

    if(op == '+'):
        print(int(a) + int(b))
    elif(op == '-'):
        print(int(a) - int(b))
    elif(op == '*'):
        print(int(a) * int(b))
    elif(op == '/'):
        print(int(a) // int(b))
    else:
        break


Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <cmath>
#include<set>
using namespace std;
int main()
{	int n, k,q,j,t;
cin>>n>>k;
    bool status[n+1];
    for(int i=0;i<=n;i++) status[i]=0;
    for(int i=0;i<k;i++)
    {
        cin>>t;
        while(t--)
        {
            cin>>q;
            status[q]=1;
        }
    }
    int c=0;
    for(int i=1;i<=n;i++) if(status[i]==0) c++;
    cout<<c<<endl;
    return 0;
}


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

int main(){
	int D, G;
	cin >> D >> G;
	vector<int> p(D), c(D);
	for(int i=0; i<D; i++){
		cin >> p.at(i) >> c.at(i);
	}

	long long score;
	int cnt;
	int mincnt=1000;
	for(int i=0; i<( 1<<10 ); i++){
		bitset<10> bit(i);
		score=0;
		cnt=0;
		for(int j=0; j<D; j++){
			if( bit.test(j) == 1 ){
				cnt += p.at(j);
				score +=p.at(j) *100*(j+1)+c.at(j);
			}
		}
		if( score >= G ){
			if( mincnt > cnt ){
				mincnt = cnt;
			}
		}
		else{
			for(int j=D-1; j>-1; j--){
				if( bit.test(j) == 0 ){
					for(int k=0; k<p.at(j)-1; k++){
						cnt++;
						score += 100*(j+1);
						if( score >= G ){
							if( mincnt > cnt ){
								mincnt = cnt;
							}
						}
					}
				break;
				}
			}
			
		}
		if( i == pow(2,D)-1) break;
	}
	cout << mincnt << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(f.readLine());
        for(int i = 0; i < k; i++){
            n-=Integer.parseInt(st.nextToken());
        }
        if(n < 0) n = -1;
        out.println(n);

        out.close();
    }
}


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

a=list(map(int, input().split()))

now=a[0]
c=1

ans=0

for i in range(1, n):
    if now==a[i]:
      c+=1
    else:
      now=a[i]
      ans+=c//2
      c=1
else:
    ans+=c//2
      
print(ans)

Measured memory_bytes: 3064