akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
int n;
int h[N][3],dp[N][3],vis[N][3];
int calc(int day,int pre)
{
  if(day==n) 
    return 0;
  if(vis[day][pre])
    return dp[day][pre];
  vis[day][pre]=1;
  if(pre==1)
  {
    int x=calc(day+1,2)+h[day][1];
    int y=calc(day+1,3)+h[day][2];
    return dp[day][pre]=max(x,y);
  }
  else if(pre==2)
  {

    int x=calc(day+1,1)+h[day][0];
    int y=calc(day+1,3)+h[day][2];
    return dp[day][pre]=max(x,y);
  }
  else if(pre==0)
  {
    int x=calc(day+1,1)+h[day][0];
    int y=calc(day+1,2)+h[day][1];
    int z=calc(day+1,3)+h[day][2];
    return dp[day][pre]=max({x,y,z});
  }
  else
  {
    int x=calc(day+1,1)+h[day][0];
    int y=calc(day+1,2)+h[day][1];
    return dp[day][pre]=max(x,y);
  }
}
int main() {
 // freopen("in.txt", "r", stdin);
 // freopen("out.txt", "w", stdout);
  scanf("%d", &n);
  for(int i=0;i<n;++i)
    scanf("%d%d%d",&h[i][0],&h[i][1],&h[i][2]);
  cout<<calc(0,0);


}






Measured memory_bytes: 8448
import numpy as np
n=int(input())
p=list(map(float,input().split()))
dp = np.zeros((n+1,n+1),dtype=np.float64)
dp[0][0]=1
for i in range(n):
    dp[i+1][0]=dp[i][0]*(1-p[i])
for i in range(n):
    dp[i+1][1:]=dp[i][1:]*(1-p[i])+dp[i][:-1]*p[i]
print(np.sum(dp[n][n//2+1:]))

Measured memory_bytes: 82748
use std::io::*;

fn main(){
    let n : usize = input();
    let mut d : Vec<usize> = (0..n).map(|_| input()).collect();
    d.sort();
    let ans = std::cmp::max(0, d[n / 2] - d[n / 2 - 1]);
    println!("{}", ans);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

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

using Graph = vector<vector<int>>;

void dfs(Graph& G, vector<int>& count, int now, int prev) {
  for(int next : G[now]) {
    if(next==prev) continue;
    count[next] += count[now];
    dfs(G,count,next,now);
  }
}

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

  Graph G(n);
  for(int i=0; i<n-1; i++) {
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  vector<int> count(n);
  for(int i=0; i<n; i++) count[i] = 0;
  for(int i=0; i<q; i++) {
    int p,x;
    cin>>p>>x;
    count[p-1] += x;
  }

  dfs(G, count, 0, -1);

  for(int i=0; i<n-1; i++) {
    cout<<count[i]<<' ';
  }
  cout<<count[n-1]<<endl;

  return 0;
}

Measured memory_bytes: 29696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B;cin >> A >> B;
  cout << A * B << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	bool operator<(const struct Info &arg) const{
		return B < arg.B;
	}
	int A,B;
};

int N;
int dp[1001],next_dp[1001];
Info info[1001];


int main(){

	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].A,&info[i].B);
	}

	sort(info,info+N);

	for(int i = 0; i <= N; i++){
		dp[i] = BIG_NUM;
		next_dp[i] = BIG_NUM;
	}

	dp[0] = 0;
	next_dp[0] = 0;

	vector<int> UPDATED;

	int max_solved = 0,next_max_solved = 0;

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

		for(int solved = 0; solved <= max_solved; solved++){

			if(dp[solved]+info[problem].A <= info[problem].B){
				if(next_dp[solved+1] > dp[solved]+info[problem].A){
					next_dp[solved+1] = dp[solved]+info[problem].A;
					UPDATED.push_back(solved+1);
					next_max_solved = max(next_max_solved,solved+1);
				}
			}
		}
		for(int i = 0; i < UPDATED.size(); i++){
			dp[UPDATED[i]] = next_dp[UPDATED[i]];
		}
		UPDATED.clear();
		max_solved = next_max_solved;
	}

	printf("%d\n",max_solved);
}

Measured memory_bytes: 3276
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0; i<A.length; i++) {
			A[i] = sc.nextInt();
		}
 
		
		for (int i=0; i<N-1; i++) {
			while (true) {
				if (A[i] < A[i+1]) {
					if (A[i+1] % A[i] == 0) {
						A[i+1] = A[i];
						break;
					}
					
					A[i+1] = A[i+1] % A[i];
				}
				else if (A[i] > A[i+1]) {
					if (A[i] % A[i+1] == 0) {
						A[i] = A[i+1];
						break;
					}
					
					A[i] = A[i] % A[i+1];
				}
				else {
					break;
				}
			}
			
		}
		
		System.out.println(A[N-1]);
	}
 
}

Measured memory_bytes: 50356
#include <iostream>
#include <vector>
using namespace std;
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; }
const long long INF = 1LL<<60;

//入力
int N,M;
vector<vector<int>>G;//グラフ

//メモ化再帰
int dp[100100];
//dp[v]:=ノードvを視点とした時のGの有効パスの長さの最大値
int rec(int v){
    if(dp[v]!=-1)return dp[v];//すでに更新済み

    int res=0;
    for(auto nv:G[v]){
        chmax(res,rec(nv)+1);//長さの最大値で更新
    }
    return dp[v]=res;//メモしながらリターン
}

int main(){
    cin>>N>>M;
    //N個のvector<int>を再代入
    G.assign(N,vector<int>());

    for(int i=0;i<M;i++){
        int x,y;
        cin>>x>>y;
        --x,--y;//0-indexed にする
        G[x].push_back(y);
    }

    //初期化
    for(int v=0;v<N;v++)dp[v]=-1;

    //全ノードを一通り更新しながら答えを求める
    int res=0;
    for(int v=0;v<N;v++)chmax(res,rec(v));
    cout<<res<<endl;
}
/*
4 5
1 2
1 3
3 2
2 4
3 4

3


6 3
2 3
4 5
5 6

2

5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3

3

*/

Measured memory_bytes: 8192
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static final void main(String[] args) {
        Main m = new Main();
        m.init();
        m.solve();
        out.flush();
    }

    // ========================================================================= //

    public void init() {

    }

    public void solve() {
        int n = sc.nextInt();
        int k = sc.nextInt();

        int ans = 1;
        for (int i = 0; i < n; i++) {
            int a = ans * 2;
            int b = ans + k;
            if (a > b) {
                ans += k;
            }
            else {
                ans *= 2;
            }
        }
        out.println(ans);
    }
}


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

#define ll long long
#define MAX 300005
#define pp pair<ll, pair<ll, ll>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    int ans = 0;
    int temp = 0;
    for (int i = 1; i < n; i++) {
        if (h[i] <= h[i - 1]) {
            temp++;
            continue;
        } else {
            ans=max(ans,temp);
            temp=0;
        }
    }
    ans=max(ans,temp);
    cout<<ans;
    return 0;
}

ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 1000000007
#define ll long long
using namespace std;

int main(){
    ll n; cin>>n;
    ll a[n];
    ll sum[n];
    sum[0]=0;
    for(ll i=0; i<n; i++) cin>>a[i];
    for(ll i=1; i<n; i++){
        sum[i]=sum[i-1]+a[n-i];
        sum[i]%=N;
    }
    
    ll ans=0;
    
    for(ll i=0; i<n-1; i++){
        ll p=a[i]*sum[n-i-1];
        p%=N;
        ans+=p;
        ans%=N;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 6756
#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(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n;
  cin >> n;
  int ans=0;
  VI v(n),c(n);
  REP(i,n)cin >> v[i];
  REP(i,n)cin >> c[i];

  REP(i,n)if(v[i]>c[i])ans+=v[i]-c[i];
  cout << ans << endl;
}



Measured memory_bytes: 256
x,y = map(int,input().split())
mod = 10**9 + 7
if (x+y)%3 != 0:
    print(0)
    exit()
if (2*y-x)%3 !=0 or (2*x-y)%3 != 0 or 2*y-x <0 or 2*x-y<0:
    print(0)
    exit()

a = (2*y-x)//3
b = (2*x-y)//3

def inverse(a,p):
    return pow(a,p-2,p)

def combination_modp(n, r, p): # nCr modpを求める
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
        result %=p
    for i in range(1, r+1):
        result *= inverse(i,p)
        result %= p
    return result

ans = combination_modp(a+b,a,mod)
print(ans)

Measured memory_bytes: 38768
#include <iostream>
#include <vector>
#include <deque>

int main() {
    int n;
    long long pos = 0, neg = 0;
    std::cin >> n;
    std::vector<long long> v(n);
    //std::deque<int> pos, neg;
    for (auto i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    for (auto i = 0; i < n; i++) {
        long long b;
        std::cin >> b;
        v[i] = b - v[i];
        if (v[i] < 0ll) neg += -v[i];
        else pos += v[i] - (v[i] & 1);
    }

    if (pos >= neg * 2ll) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
//	ll n,x,t;
//	cin>>n>>x>>t;
	string s;
	cin>>s;
	ll sum=0;
	for(int i=0;i<s.length();i++)
	sum=(sum%9+(s[i]-'0'))%9;
	if(sum)
	cout<<"No"<<endl;
	else 
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    bool ok=true;
    cin>>a>>b>>c;
    for (int i=1; i<=3600 && ok; i++)
    {
        if (i%60==c && i%(a+b)<=a) { cout<<i<<'\n'; ok=false; }
    }
    if (ok) cout<<"-1\n";
    return 0;
}



Measured memory_bytes: 3108
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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


fn main() {
    input!{
        mut x: usize,
    }
    let mut ans = 0;
    ans += 2 * (x / 11) + (x % 11 + 5) / 6;
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    
    long ans = Math.max(Math.max(a * c,a * d),Math.max(b * c,b * d));
    
    System.out.print(ans);
  }
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> v;
    double tmp;
    REP(i, n){
        cin >> tmp;
        v.push(tmp);
    }
    while(n > 1){
        double t1 = v.top();
        v.pop();
        double t2 = v.top();
        v.pop();
        v.push((t1+t2)/2);
        n--;
    }
    cout << v.top();
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)res = res * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return res;
}
ll n, k, z, ma;
bool ze, p;
int main() {
    cin >> n >> k;
    vector<ll> s(n), t1, t2, v1, v2;
    REP(i, n){
        cin >> s[i];
        if (s[i] == 0) z++;
        else if (s[i] < 0) t2.push_back(s[i] * -1);
        else t1.push_back(s[i]);
    }
    sort(ALL(t1));
    sort(ALL(t2));
    ll t2s = t2.size(), t1s = t1.size();
    if (z > 0) ze = true;
    v1.push_back(0);
    v2.push_back(0);
    //正判定
    REP(i, k + 1){
        //cout << i << " " << k - i << " " << t1s << " " << t2s << endl;
        if (i % 2 == 1) continue;
        if (t1s < k - i) continue;
        if (t2s < i) continue;
        p = true;
        ma = max(i, ma);
    }
    //正が作れない
    if(!p){
        if(ze){
            cout << 0 << endl;
            return 0;
        }
        vector<ll> l;
        REP(i, t1s){
            l.push_back(t1[i]);
        }
        REP(i, t2s){
            l.push_back(t2[i]);
        }
        sort(ALL(l));
        ll ans = 1;
        REP(i, k){
            ans *= l[i];
            ans %= MOD;
        }
        cout << (MOD * 2 - ans) % MOD << endl;
        return 0;
    }
    vector<P> l;
    REP(i, t1s){
        l.push_back(P(t1[i], 1));
    }
    REP(i, t2s){
        l.push_back(P(t2[i], -1));
    }
    sort(ALL(l), greater<P>());
    ll ans = 1, cnt = 0, m1 = -1, p1 = -1, m2 = -1, p2 = -1;
    REP(i, k){
        ans *= l[i].first;
        ans %= MOD;
        if (l[i].second == -1) cnt++;
        if (l[i].second == -1) m1 = l[i].first;
        if (l[i].second == 1) p1 = l[i].first;
    }
    if(cnt % 2 == 0){
        cout << ans << endl;
        return 0;
    }
    FOR(i, k, n){
        if (m2 == -1 and l[i].second == -1) m2 = l[i].first;
        if (p2 == -1 and l[i].second == 1) p2 = l[i].first;
    }
    if(m1 == -1 or p2 == -1){
        ans = ans * m2 % MOD * powmod(p1, MOD - 2) % MOD;
    }
    else if(m2 == -1 or p1 == -1){
        ans = ans * p2 % MOD * powmod(m1, MOD - 2) % MOD;
    }
    else if(p1 * p2 >= m1 * m2) {
        ans = ans * p2 % MOD * powmod(m1, MOD - 2) % MOD;
    }
    else{
        ans = ans * m2 % MOD * powmod(p1, MOD - 2) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
int ans;
char s[1000005];
int main()
{
	gets(s);
	int ls=strlen(s);
	for(int i=0;i<=ls-1;++i)
	{
		if(s[i]!=s[i+1]&&i!=ls-1)
		++ans;
	}
	cout<<ans;
	return 0;
}

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

int main() {
  string N, f_N;
  int sum = 0;
  cin >> N;

  for (int i = 0; i < N.size(); i++){
    f_N = N.at(i); //i文字目の取得(str)
    int f_n = atoi(f_N.c_str());  //translation from str to int
    sum += f_n;
  }

  int X = atoi(N.c_str()); //Nを数値に置き換え
  if (X % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    ll n,a,b; cin >> n >> b >> a;
    cout << (n/(a+b)*b + min(b, n%(a+b))) << endl;
    return 0;
}



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

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int dp[n+5][n+5];
    memset(dp,0,sizeof(dp));
    string s;
    cin>>s;
    dp[1][1]=1;
    int mo=1000000007;
    int prf[n+5]={0};
    int suf[n+5]={0};
    prf[1]=1;
    suf[1]=1;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            if(s[i-2]=='<')
                dp[i][j]=prf[j-1];
            else
                dp[i][j]=suf[j];
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
        }

        prf[0]=0;
        for(int j=1;j<=i;j++)
            prf[j]=(prf[j-1] + dp[i][j])%mo;
        suf[i+1]=0;
        for(int j=i;j>=1;j--)
            suf[j]=(suf[j+1] + dp[i][j])%mo;
    }
    cout<<prf[n];
}


Measured memory_bytes: 74200
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //int answer = 0;
        String answer="No";
        //StringBuilder answer=new StringBuilder();

        //入力
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        System.out.println(3*(r*r));


        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        //System.out.println(answer);
    }
}

Measured memory_bytes: 21844
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int count = 0;
        for (int i = 0; i < n; i ++) {
            int min = i;
            for (int j = i; j < n; j ++) {
                if(s[j]<s[min]) min = j;
            }
            if (min != i) count ++;
            int tmp = s[i];
            s[i] = s[min];
            s[min] = tmp;
        }
        for (int i = 0; i < n; i ++) {
            if (i == n-1) Console.WriteLine(s[i]);
            else Console.Write(s[i]+" ");
        }
        Console.WriteLine(count);
    }
}


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

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

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

  int q;
  cin >> q;

  int cnt = 0;
  
  vector<string> t(q);
  for(int i = 0; i < q; i++){
    cin >> t[i];

    for(int j = 0; j < n; j++){
      if(t[i] == s[j]){
	cnt++;
	break;
      }
    }
  }

  cout << cnt << endl;
  
  return 0;
  
}



Measured memory_bytes: 3232
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	long long A, B, C, K;
	long long ans = 0;

	cin >> A >> B >> C >> K;

	if (K < A) {
		cout << K << "\n";
		return 0;
	}
	else if (K < A + B) {
		cout << A << "\n";
		return 0;
	}
	else {
		cout << A - (K - A - B) << "\n";
		return 0;
	}
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numC = 0;
		int numD = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numC = scanner.nextInt();
			numD = scanner.nextInt();

			if (numA + numB == numC + numD) {
				System.out.println("Balanced");
			} else if (numA + numB > numC + numD) {
				System.out.println("Left");
			} else if (numA + numB < numC + numD) {
				System.out.println("Right");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() 
{
	ll n,k,i,s,s1,m; cin>>k>>n; ll a[n]; s=s1=0;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=1;i<n;i++)
	{
	    s+=a[i]-a[i-1];
	} m=s;
	for(i=1;i<n;i++)
	{s1=s+((k-a[n-1])+a[0])-(a[i]-a[i-1]);
	m=min(m,s1);}
	cout<<m;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

int main(void){
    int a,b,c,K,i,j,k,ans;
    int sum = 0;

	scanf("%d",&K);

	for(i=1; i<=K; i++){
		for(j=1; j<=K; j++){
			for(k=1; k<=K; k++){
				ans = gcd_euclid(gcd_euclid(i,j),k);
				sum += ans;
			}
		}
	}
	
	printf("%d",sum);
	
    return 0;
}

Measured memory_bytes: 1736
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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" ) } ; }

fn main() {
    input! {
        n: u64
    }

    let mut is_ok = false;
    for i in 0..n/4+1 {
        if (n - 4*i) % 7 == 0 {
            is_ok = true;
        }
    }
    println!("{}", if is_ok {"Yes"} else {"No"});
}

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

// Connects a set of subsets and checks the belonging of the data.
// unite : near O(1)
// root : near O(1)
// same : near O(1)
// size : near O(1)
class UnionFind
{
  using Abel = int;
  std::vector<Abel> data;

public:
  UnionFind(int n) : data(n, -1) {}

  // Connects between x and y.
  bool unite(Abel x, Abel y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
      {
        std::swap(x, y);
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }

  // Finds the belonging of x.
  Abel root(Abel x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

  // Checks where x and y belong to the same subset.
  bool same(Abel x, Abel y) { return root(x) == root(y); }

  // Look up the size of the subset belonged to x.
  Abel size(Abel x) { return -data[root(x)]; }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    for(int i=0;i<m;++i){
        int x,y,z;
        cin>>x>>y>>z;
        x--,y--;
        uf.unite(x,y);
    }
    set<int>s;
    for(int i=0;i<n;++i){
        s.insert(uf.root(i));
    }
    cout<<s.size()<<endl;
}

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

using namespace std;

typedef long long int lint;

const int NMAX = 100000 + 5;

int N, A[NMAX];

int main()
{
    cin >> N;
    for (int i = 1; i <= N; ++ i)
        cin >> A[i];

    lint ans = 0;
    for (int i = 1; i <= N; ++ i) {
        if (A[i - 1] == 1 && A[i])
            ++ ans, -- A[i];
        ans += A[i] / 2;
        A[i] %= 2;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

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

	unsigned long long l[100];
	l[0] = 2;
	l[1] = 1;
	for (int i = 2; i <= n; i++)	
		l[i] = l[i-1]+l[i-2];

	cout << l[n] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
    vector<int>v,u,sum;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    for(int i=0;i<n;i++)
    {
        cin>>x;
        u.push_back(x);
    }
    for(int i=0;i<n;i++)
    {
        x=0;
        for(int j=i;j<n-i;j++)
        {
            x+=v[j];
        }
        for(int j=n-i-1;j<n-i;j++)
        {
            x+=u[j];
        }
        sum.push_back(x);
        x=0;
        for(int j=n-1;j>=n-(n-i);j--)
        {
            x+=u[j];
        }
        for(int j=n-(n-i);j>=0;j--)
        {
            x+=v[j];
        }
        sum.push_back(x);
    }
    sort(sum.begin(),sum.end());
    cout<<sum[sum.size()-1]<<endl;
    return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int A[n][m];
    int b[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];
    int ans[n]={0};
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j)ans[i]+=A[i][j]*b[j];
    }
    for(int i=0;i<n;++i)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3116
n, m, x = map(int,input().split())
li = [[] for i in range(n)]
minm = 10000000
argl = [0] * m
for i in range(n):
    li[i] = list(map(int,input().split()))

def a(item, money, arg):
    if item == n:
        return 10000000

    nobuy = a(item + 1, money, arg)
    # buy
    newarg = arg.copy()
    for i in range(m):
        newarg[i] += li[item][i + 1]
    
    flg = True
    for i in range(m):
        if newarg[i] < x:
            flg = False
    if flg:
        buy = money + li[item][0]
    else:
        buy = a(item + 1, money + li[item][0], newarg)
    
    return min(buy, nobuy)

res = a(0, 0, argl)
if res == 10000000:
    print(-1)
else:
    print(res)

Measured memory_bytes: 9192
#include <stdio.h>
int main()
{
    int i,n,ar[4],a,b,c,d;
    scanf("%d",&n);
    while(n>0){
        ar[i]=n%10;
        i++;
        n/= 10;
    }
    a=ar[3];
    b=ar[2];
    c=ar[1];
    d=ar[0];
    if(a+b+c+d==7){
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
    }
    else if(a-b+c+d==7){
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
    }
    else if(a+b-c+d==7){
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
    }
    else if(a+b+c-d==7){
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
    }
    else if(a-b-c+d==7){
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
    }
    else if(a+b-c-d==7){
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
    }
    else if(a-b+c-d==7){
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
    }
    else if(a-b-c-d==7){
        printf("%d-%d%d-%d=7\n",a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class UnionFind {
    int n;
    vector<int> uni;
    int forest_size;
public:
    explicit UnionFind(int n) : n(n), uni(static_cast<u32>(n), -1), forest_size(n) {};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        forest_size--;
        return true;
    }
    int size(){ return forest_size; }
    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

int main() {
    int n;
    while(cin >> n, n){
        array<int, 256> cnt{};
        int a = 0;
        fill(cnt.begin(), cnt.end(), -1);
        vector<int> in(26), out(26);
        UnionFind uf(26);
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            if(!~cnt[s.front()]) cnt[s.front()] = a++;
            if(!~cnt[s.back()]) cnt[s.back()] = a++;
            uf.unite(cnt[s.front()], cnt[s.back()]);
            in[cnt[s.front()]]++;
            out[cnt[s.back()]]++;
        }
        int ok = 1;
        for (int i = 0; i < a; ++i) {
            if(in[i] != out[i]) ok = 0;
        }
        if(uf.size(0) == a && ok) puts("OK");
        else puts("NG");
    }
    return 0;
}


Measured memory_bytes: 2976
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
vector<int> a(5,0);
void input(){
    int b;
    rep(i,6){
        cin>>b;
        a[b]++;
    }
}
void src(){
    int cnt1=0,cnt2=0;
    repi(i,1,5){
        if(a[i]==1) cnt1++;
        if(a[i]==2) cnt2++;
    }
    YES(cnt1==2 and cnt2==2);
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

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

int w,h;
int data[101][101];
int kx[6]={0,-1,0,1,1,1};
int gx[6]={-1,-1,-1,0,1,0};
int yy[6]={-1,0,1,1,0,-1};

int check(int x,int y){
	int res=0;
	if(data[x][y]==2) return 0;
	if(data[x][y]==1){
		if(x==1&&y==1) return 3;
		if(x==w&&y==1) return 4;
		if(x==1){
			if(y%2==0){
				if(y==h) return 4;
				else return 3;
			}else{
				if(y==h) return 3;
				else return 1;
			}
		}
		if(x==w){
			if(y%2==0){
				if(y==h) return 3;
				else return 1;
			}else{
				if(y==h) return 4;
				else return 3;
			}
		}
		return 2;
	}
	data[x][y]=2;
	int X[6],Y[6];
	for(int i=0;i<6;i++){
		X[i]=x+((y&1==1)?kx[i]:gx[i]);
		Y[i]=y+yy[i];
		if(X[i]<1||X[i]>w||Y[i]<1||Y[i]>h) continue;
		if(data[X[i]][Y[i]]==0) res+=check(X[i],Y[i]);
		else if(data[X[i]][Y[i]]==1) res++;
	}
	return res;
}
		

int main(){
	scanf("%d%d",&w,&h);
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)scanf("%d",&data[j][i]);
	int res=0;
	for(int i=1;i<=w;i++)res+=check(i,1)+check(i,h);
	for(int i=2;i<h;i++)res+=check(1,i)+check(w,i);
	printf("%d\n",res);
}

Measured memory_bytes: 1464
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=500010;

int N,K; int p[MAXN+1],q[MAXN+1];
set<int> s;
vector<int> vec[MAXN+1];
int tr[MAXN<<2];
int deg[MAXN+1];

inline void Add(int rt,int l,int r,int k,int x){
	if(l==r){tr[rt]=min(tr[rt],x); return ;} int mid=(l+r)>>1;
	if(k<=mid) Add(rt<<1,l,mid,k,x); else Add(rt<<1|1,mid+1,r,k,x);
	tr[rt]=min(tr[rt<<1],tr[rt<<1|1]); return ;
}
inline int Query(int rt,int l,int r,int L,int R){
	if(L<=l&&R>=r) return tr[rt]; int mid=(l+r)>>1,ans=INF;
	if(L<=mid) ans=min(ans,Query(rt<<1,l,mid,L,R));
	if(R>mid) ans=min(ans,Query(rt<<1|1,mid+1,r,L,R));
	return ans;
}
inline void insert(int u,int v){
	++deg[v]; vec[u].push_back(v); return ;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),K=read();
	for(int i=1;i<=N;i++){
		p[i]=read(); q[p[i]]=i;
	} memset(tr,127,sizeof(tr));
	for(int i=N;i>=1;i--){
		int x=Query(1,1,N,max(1,q[i]-K+1),q[i]);
		int y=Query(1,1,N,q[i],min(N,q[i]+K-1));
		if(x<=N) insert(q[i],q[x]); if(y<=N) insert(q[i],q[y]);
		Add(1,1,N,q[i],i);
	} for(int i=1;i<=N;i++) if(!deg[i]) s.insert(i); int cnt=0;
	while(s.size()){
		int k=(*s.begin()); q[++cnt]=k; s.erase(s.begin());
		for(int i=0;i<vec[k].size();i++){
			int v=vec[k][i]; if(!deg[v]) continue;
			deg[v]--; if(!deg[v]) s.insert(v);
		}
	} for(int i=1;i<=N;i++) p[q[i]]=i;
	for(int i=1;i<=N;i++) printf("%d\n",p[i]);
	return 0;
}


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

int main(){
	ll n,k;
	cin >> n >> k;
	ll ans = min(n%k, k-n%k);
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	cnt := 1
	sum := a

	if b == 1 {
		fmt.Println(0)
		return
	}
	for sum < b {
		cnt++
		sum += a - 1
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 512
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1ll<<i)<=x;i++);
    return i;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int n,d,s;
    cin >> n >> d >> s;
    
    int c=0;
    fff(i,n) {
        int x;cin >>x;
        
        int p=1;
        while(p<=d) {
            c++;
            p+=x;
        }
       // cout << c << " ";
    }
    //cout << endl;
    cout << c+s;
    
    
	return 0;
    
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

Vs split_string(const string &s, char delim){
    Vs elements;
    string item;
    for(char ch : s){
        if(ch == delim){
            if(!item.empty()) elements.pb(item);
            item.clear();
        }else{
            item += ch;
        }
    }
    if(!item.empty()) elements.pb(item);
    return elements;
}

int main(){
    int n;
    cin>>n;
    double total = 0.0;
    REP(i,n){
        double x;
        string u;
        cin>>x>>u;
        if(u=="JPY"){
            total += x;
        }else{
            total += x*380000.0;
        }
    }
    cout<<fixed<<setprecision(10)<<total<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,con=0;
    cin>>a;
    for(int z=0;z<=a;z++){
        cin>>b;
        if(b%2==0){
            if(b%3==0){
            }else{
                if(b%5==0){
                }else{
                    cout<<"DENIED"<<endl;
                    con++;
                    break;
                }
            }
        }
    }
    if(con==0){
        cout<<"APPROVED"<<endl;
    }
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct List {
  int key;
  struct List *before;
  struct List *next;
};

struct List l;

void insert(int key) {
  struct List *a = malloc(sizeof(struct List));
  a->key = key;
  a->before = &l;
  a->next = l.next;
  l.next = a;
  a->next->before = a;
}

void delete_Node(struct List *a) {
   a->next->before = a->before;
   a->before->next = a->next;
}

void delete(int b) {
  struct List *c;
  c = l.next;
  while(c->key != -1) {
    if (c->key == b) {
      delete_Node(c);
      break;
    }  
    c = c->next;
  } 
  }

void delete_First() {
  delete_Node(l.next);
}

void delete_Last() {
  delete_Node(l.before);
}

int main(void) {
  int n;
  char command[12];
  int key;
  struct List *box;
  l.key = -1;
  l.before = &l;
  l.next = &l;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", command);
    if (strcmp(command, "deleteFirst") == 0)
      delete_First();
    else if (strcmp(command, "deleteLast") == 0)
      delete_Last();
    else {
      scanf("%d", &key);
      if (strcmp(command, "insert") == 0) 
	insert(key);
      else if (strcmp(command, "delete") == 0)
	delete(key);
      }
    }
 
  
  box = l.next;
  while(box->key != -1) {
    printf("%d", box->key);
    box = box->next;
    if (box->key != -1)
      printf(" ");
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 36224
/*
Author : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


" when you are not practicing someone else is ,
 and the day u meet them u will lose "

*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 200050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 1000000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))

#define loop(i,n)  for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i++)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define makeuniq(v) v.resize(unique(all(v)) - v.begin()); //only uniq element in vector after this
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>

#define pii pair<lli,lli>

#define vi vector<lli>
#define vvi vector<vi>
#define vpi vector<pii>
#define vbool vector<bool>

#define seti set<lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename Head>
void print(Head&& head)
{
    cout<<head<<endl;
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail... tail)
{
    cout<<head<<" ";
    print(tail...);
}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

/*
1D vector -  vi dp(n,value);
2D vector -  vvi dp(n,vi(n,value));
*/

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    ld d,t,s;
    cin>>d>>t>>s;
    if((d/s)<=t)
        print("Yes");
    else
        print("No");
  }
return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++)
    {
        for (int j = s.length() - 1; i < j; j--)
        {
            if (s[j] <= s[j - 1])
            {
                swap(s[j], s[j - 1]);
            }
        }
    }
    for (int i = 0; i < t.length(); i++)
    {
        for (int j = t.length() - 1; i < j; j--)
        {
            if (t[j] >= t[j - 1])
            {
                swap(t[j], t[j - 1]);
            }
        }
    }
    for (int i = 0; i < min(s.length(), t.length()); i++)
    {
        if (s[i] == t[i])
            continue;
        else if (s[i] > t[i])
        {
            cout << "No\n";
            return 0;
        }
        else
        {
            cout << "Yes\n";
            return 0;
        }
    }
    if (s.length() < t.length())
    {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, m; cin >> n >> m;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	vector<int> b;

	vector<pair<int, int>> p(m);
	rep(i, 0, m) cin >> p[i].first >> p[i].second;
	sort(all(p), [](const pair<int, int> p1, const pair<int, int> p2) {
			return p1.second > p2.second;
			});

	b.reserve(n);
	rep(i, 0, m) while (b.size() < n && p[i].first > 0) {
		p[i].first--;
		b.push_back(p[i].second);
	}

	sort(all(a));
	sort(all(b));

	ll ans = 0;
	rep(i, 0, n) {
		if (b.size() && b.back() > a.back()) ans += b.back(), b.pop_back();
		else ans += a.back(), a.pop_back();
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define N 10000

int main(void){

  int n, q, C=0, i, j;
  int S[N], T[N];

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){

      if(S[i] == T[j]){
        C++;
        break;
      }
    }
  }

  printf("%d\n", C);

  return 0;
}

Measured memory_bytes: 644