akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac;void setFac(int n, int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e6;
int n, h, d;
ll s, t, DP[N+1];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setFac(N, MOD);
  cin >> n >> h >> d;
  FOR(i, 1, n+1) s += fac[i];
  s %= MOD;
  DP[0] = 1;
  FOR(i, 1, h+1){
    t += DP[i-1];
    if(i>d) t -= DP[i-d-1];
    t %= MOD;
    DP[i] = t*s%MOD;
  }
  (DP[h]+=MOD)%=MOD;
  cout << DP[h]*fac[n]%MOD*modInv(s, MOD)%MOD << endl;
}

Measured memory_bytes: 23680
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
int amo,h,jjj=0,x;
int wie[100001]={},thr[100001]={};
cin>>amo>>h;
for(int i=0;i<amo;i++)
cin>>wie[i]>>thr[i];
sort(wie,wie+amo);
reverse(wie,wie+amo);
sort(thr,thr+amo);
reverse(thr,thr+amo);
x=wie[0];
for(int i=0;h>0 && i<amo && thr[i]>x;i++)
{h-=thr[i];
 jjj++;}
if (h>0) jjj+=(h+x-1)/x;
cout<<jjj;
system("pause"); 
return 0;
}


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

typedef pair<int, int> P;

int main() {
int n,r;
long long m=0,c=1,q=1e9+7;
P p[200000];
cin>>n;
for(int i=0;i<n*2;i++){
    cin>>p[i].first;
    p[i].second=i/n;
}
sort(p,p+n*2);
for(int i=0;i<n*2;i++){
    if(m==0){
        m++;
        r=p[i].second;
    }else if(p[i].second==r){
        m++;
    }else{
        c=(c*m)%q;
        m--;
    }
}
cout<<c<<endl;


	return 0;
}

Measured memory_bytes: 1792
N = int(input())

ans = 0
for i in range(1, N+1):
    num = N//i
    k = 0
    if num % 2 == 0:
        k = (num+1)*(num//2)
    else:
        k = num * ((num+1)//2)
    ans += i * k

print(ans)


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

void getPerms(int index, int limit, vector<string>& v, vector<int>& visited, string cur)
{
	if(index == limit)
	{
		v.push_back(cur);
		return;
	}

	for(int i = 0; i < limit; ++i)
	{
		if(visited[i] == 0)
		{
			visited[i] = 1;
			getPerms(index+1, limit, v, visited, cur + to_string(i+1));
			visited[i] = 0;
		}
	}
}

int main()
{
	int n; cin >> n;
	vector<string> v;
	vector<int> visited(n+1, 0);
	getPerms(0, n, v, visited, "");
	string p = "";
	for(int i = 0; i < n; ++i)
	{
		int num; cin >> num; p += to_string(num);
	}
	string q = "";
	for(int i = 0; i < n; ++i)
	{
		int num; cin >> num; q += to_string(num);
	}
	auto p1 = find(v.begin(), v.end(), p) - v.begin();
	auto p2 = find(v.begin(), v.end(), q) - v.begin();
	cout << abs(p1-p2);
	return 0;
}

Measured memory_bytes: 5424
#include <bits/stdc++.h>
using namespace std;
inline int sqr(int x) 
{
	return x*x;
}
int main()
{
	int n,x,a[101];
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ans+=sqr(a[i]-0);
	}
	for(x=-100;x<=100;x++)
	{
		int tmp=0;
		for(int i=1;i<=n;i++)
		{
			tmp+=sqr(a[i]-x);
		}
		ans=min(ans,tmp);
	}
	cout<<ans;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int N;
ll A[100010];
ll B[100010];
priority_queue<ll> pq_p;
ll sh;
ll sum_a, sum_b;
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
        sum_a+=A[i];
    }
    REP(i,0,N){
        cin>>B[i];
        sum_b+=B[i];
    }
    if(sum_a<sum_b){
        p(-1);
    }else{
        ll ans=0;
        REP(i,0,N){
            if(A[i]>=B[i]) pq_p.push(A[i]-B[i]);
            else{
                ans++;
                sh+=B[i]-A[i];
            }
        }
        while(!pq_p.empty() && sh>0){
            ll a=pq_p.top();
            pq_p.pop();
            sh-=a;
            ans++;
        }
        p(ans);
    }
    return 0;
}


Measured memory_bytes: 2936
h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
else:
    if h%2==0:
        print(((w+1)//2+(w//2))*(h//2))
    else:
        print(((w+1)//2+(w//2))*(h//2)+(w+1)//2)

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

int digit(int n){
  int left;
  while(n>0){
    left=n%10;
    n/=10;
  }
  return left;
}

int n;
vector<int> vec(100);

void dfs(int left,int now,int d=1){
  if(now<=n) {vec[left*10+now%10]++;}
  if(d==6) return;
  for(int i=0; i <=9; i++){
    dfs(left,now*10+i,d+1);
  }
}

int main(){
  cin>>n;
  rep(i,100) vec[i]=0;
  for(int left=1; left<=9; left++){
    dfs(left,left);
  }
  int ans=0;
  for(int a=1; a<=n; a++){
    if(a%10==0) continue;
    int left=digit(a),right=a%10;
    ans+=vec[right*10+left];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#define llint long long

using namespace std;

llint n, m, s;
llint dp[25][15][165];

int main(void)
{
	while(1){
		cin >> n >> m >> s;
		if(n == 0 && m == 0 && s == 0) break;
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= m; j++){
				for(int k = 0; k <= s; k++){
					dp[i][j][k] = 0;
				}
			}
		}
		dp[0][0][0] = 1;
		for(int i = 0; i < n; i++){
			for(int j = 0; j <= m; j++){
				for(int k = 0; k <= s; k++){
					dp[i+1][j][k] += dp[i][j][k];
					dp[i+1][j+1][k+i+1] += dp[i][j][k];
				}
			}
		}
		cout << dp[n][m][s] << endl;
	}
	return 0;
}


Measured memory_bytes: 3392
#include <stdio.h>

int main(void)
{
	int n;
	int x, y, h, w;
	int i;
	int size[6] = {0};
	int sum;
	
	while (1){
		sum = 0;
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d %d %d %d", &x, &y, &h, &w);
			if (x + y + h <= 60 && w <= 2){
				size[0]++;
			}
			else if (x + y + h <= 80 && w <= 5){
				size[1]++;
			}
			else if (x + y + h <= 100 && w <= 10){
				size[2]++;
			}
			else if (x + y + h <= 120 && w <= 15){
				size[3]++;
			}
			else if (x + y + h <= 140 && w <= 20){
				size[4]++;
			}
			else if (x + y + h <= 160 && w <= 25){
				size[5]++;
			}
		}
		
		size[0] *= 600;
		size[1] *= 800;
		size[2] *= 1000;
		size[3] *= 1200;
		size[4] *= 1400;
		size[5] *= 1600;
		
		for (i = 0; i < 6; i++){
			sum += size[i];
			size[i] = 0;
		}
		printf("%d\n", sum);
	}
	
	return (0);
}

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

int main(){
    int a,b,c,d,t,cnt=0;
    int i,j,k,l,r,da,db,dc,dd,o,m;
    int ot[4],cur[4]={10,50,100,500};

    while(1){
        fill(ot,ot+4,0);
        m=0;
        cin>>t;
        if(!t){break;}
        cin>>a>>b>>c>>d;
        for(i=0;i<=a;i++){
            for(j=0;j<=b;j++){
                for(k=0;k<=c;k++){
                    for(l=0;l<=d;l++){
                        r=i*10+j*50+k*100+l*500;
                        o=r-t;
                        if(r>=t){
                            dd=o/500;
                            if(dd && l){continue;}
                            dc=(o-dd*500)/100;
                            if(dc && k){continue;}
                            db=(o-dd*500-dc*100)/50;
                            if(db && j){continue;}
                            da=(o-dd*500-dc*100-db*50)/10;
                            if(da && i){continue;}
                            if(i+j+k+l>m){
                                ot[0]=i;ot[1]=j;ot[2]=k;ot[3]=l;
                            }
                        }
                    }
                }
            }
        }
        if(cnt){cout<<endl;}
        for(i=0;i<4;i++){
            if(ot[i]){cout<<cur[i]<<" "<<ot[i]<<endl;}
        }
        cnt++;
    }
    return 0;
}



Measured memory_bytes: 3060
// AOJ ALDS1_6_A Counting Sort
// 2018.4.27 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20]; int w;
void mypr(int n)
{
	int i;
	w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
	i = w; while (i--) pc(buf[i]);
}

// 計数ソート（整数用）昇順
#define MAX_N 10002
int f[MAX_N];
void counting_sort(int n, int *a, int *b, int max)
{
	int i, x;
//	memset(f, 0, sizeof(f));
	for (i = 0; i < n; i++) f[a[i]]++;
	for (i = 1; i <= max; i++) f[i] += f[i-1];
	for (i = n-1; i >= 0; i--) {
		x = a[i], b[--f[x]] = x;
	}
}

int a[2000002], b[2000002];

int main()
{
	int N, i, j;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	counting_sort(N, a, b, 10000);
	if (!b[0]) pc('0'); else mypr(b[0]);
	for (i = 1; i < N; i++) {
		pc(' ');
		if (!b[i]) pc('0');
		else if (b[i] != b[i-1]) mypr(b[i]);
		else { j = w; while (j--) pc(buf[j]); }
	}
	pc('\n');
	return 0;
}



Measured memory_bytes: 17168
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin>>s;
  rep(i,1<<3){
    bitset<3> b(i);
    int ans =s[0]-'0';
    rep(j,3){
      if(b[j]==0)ans-=s[j+1]-'0';
      else ans+=s[j+1]-'0';
    }
    if(ans==7){
      string t ="";
      t+=s[0];
      rep(j,3){
        if(b[j]==0)t+="-";
        else t+="+";
        t+=s[j+1];
      }
      t+="=7";
      cout<<t<<endl;
      return 0;
    }
  }
  return 0;
}

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);
vector<int> enum_div(int n);

// ================ Main Loop ================
int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    map<int, int> p;
    rep(i, n) {
        cin >> a[i];
        if(p.count(a[i]))
            p[a[i]]++;
        else
            p[a[i]] = 1;
    }

    rep(i, n) {
        bool flg = false;
        vector<int> divs;
        divs = enum_div(a[i]);
        for(auto v : divs) {
            // cout << "checking " << v;
            if((v == a[i]) ? (p.at(v) - 1) : p.count(v)) {
                // cout << " x" << endl;
                flg = true;
                break;
            }
            // cout << endl;
        }
        if(!flg) ans++;
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

//入力nを除く約数列挙 O(sqrt(N))
vector<int> enum_div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    ret.push_back(n);
    //n自身もくわえたければ

    //sort(ret.begin(),ret.end());
    //最小順であることは保証されないので、必要に応じて。
    //この場合、O(sqrt(N)*(log(N)+1))
    return ret;
}

Measured memory_bytes: 13500
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

///----------------------------------------------

int main() {

	int n; cin>>n;
	cout << (1+n)*n/2;

}

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

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

mt19937 rnd(51);

int ans = 0, n, m, q;
vector<pair<pair<int,int>, pair<int,int>>> v(50);
vector<int> now;

void check(){
    int lol = 0;
    for (int i = 0; i < q; i++){
        if (now[v[i].first.first] - now[v[i].first.second] == -v[i].second.first){
            lol += v[i].second.second;
        }
    }
    ans = max(ans, lol);
}

void func(){
    if (now.size() == n){
        check();
        return;
    }
    if (now.size() == 0){
        for (int i = 1; i <= m; i++){
            now.pb(i);
            func();
            now.pop_back();
        }
    }
    else{
        for (int i = now.back(); i <= m; i++){
            now.pb(i);
            func();
            now.pop_back();
        }
    }
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++){
        cin >> v[i].first.first >> v[i].first.second >> v[i].second.first >> v[i].second.second;
        v[i].first.first--, v[i].first.second--;
	}
	func();
	cout << ans;
	return 0;
}


Measured memory_bytes: 3620
use std::cmp::min;
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $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")
    };
}
//usage
//input! {
//  h: i32;
//  v: [i32; n]
//  x: [[i32; n]; m]
//  f: chars <- Vec<char>
//}

fn main() {
    input! {
        n: i64,
        k: i64,
        mut h: [i64; n]
    }

    h.sort_by_key(|&x| -x);
    let mut ans: i64 = 0;
    for i in 0..n {
        if i >= k{
            ans += h[i as usize];
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

ans=0

while True:
	
	if N<(K**ans):
		break
	
	if N==(K**ans):
		ans+=1
		break
	
	ans+=1


print(ans)


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

int dp[3005][3005];
string str;

const int MOD = 1000000007;

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

    dp[1][1] = 1;
    for(int i = 2; i <= n; ++i){
        dp[i][0] = 0;
        for(int j = 1; j <= i; ++j){
            dp[i][j] = dp[i][j - 1];
            if(str[i - 2] == '<'){
                dp[i][j] += dp[i - 1][j - 1];
            }else{
                dp[i][j] += (dp[i - 1][i - 1] - dp[i - 1][j - 1] + MOD) % MOD;
            }
            dp[i][j] %= MOD;
        }
    }

    cout << dp[n][n] << "\n";
    return 0;
}


Measured memory_bytes: 34176
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

void TopDown(vector<int>&depth, vector<int>&l, vector<int>&r, vector<vector<int>>&edge, int node) {
	for (auto i : edge[node]) {
		if (depth[i] > depth[node]) {
			if (l[i] == l[node])l[i]++;
			l[i] = max(l[i], l[node] - 1);
			if (r[i] == r[node])r[i]--;
			r[i] = min(r[i], r[node] + 1);
			TopDown(depth, l, r, edge, i);
		}
	}
	return;
}

void BottomUp(vector<int>&depth, vector<int>&l, vector<int>&r, vector<vector<int>>&edge, int node) {
	for (auto i : edge[node]) {
		if (depth[i] > depth[node]) {
			BottomUp(depth, l, r, edge, i);
			if (l[node] == l[i])l[node]++;
			l[node] = max(l[node], l[i] - 1);
			if (r[node] == r[i])r[node]--;
			r[node] = min(r[node], r[i] + 1);
		}
	}
	return;
}

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

	cin >> N;
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>l(N,-MOD);
	vector<int>r(N,MOD);
	cin >> K;
	for (int i = 0; i < K; i++) {
		cin >> L >> M;
		L--;
		l[L] = M;
		r[L] = M;
	}
	vector<int>depth(N,MOD);
	Calculate_Depth(edge, depth, L);
	TopDown(depth, l, r, edge, L);
	BottomUp(depth, l, r, edge, L);
	TopDown(depth, l, r, edge, L);
	BottomUp(depth, l, r, edge, L);
	for (int i = 0; i < N; i++) {
		if (l[i] > r[i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (auto i : l)cout << i << endl;
	return 0;
} 

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll cnt = 0, l = 0;
  rep(i, n) {
    if(s[i] == '(')
      cnt++;
    else
      cnt--;
    l = min(l, cnt);
  }
  l *= -1;
  rep(i, l) cout << '(';
  cout << s;
  rep(i, cnt + l) cout << ')';
  cout << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#define S 1046527
#define N 14

char H[S][N];

int getChar(char ch);
long long getKey(char str[]);
int h1(int key);
int h2(int key);
int find(char str[]);
int insert(char str[]);

int main(){
  int i,n;
  char str[N],c[9];
  for(i = 0;i<S;i++){
    H[i][0] = '\0';
  }
  scanf("%d",&n);
  
  for(i = 0; i<n; i++){
   scanf("%s %s",c,str);
  if(c[0] == 'i'){
    insert(str);
  }
  else{
    if(find(str)){
      printf("yes\n");
    }
    else{
      printf( "no\n");
    }
  }
}
  return 0;
}

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }
  else if(ch == 'C'){
    return 2;
  }
  else if(ch == 'G'){
    return 3;
  }
  else if (ch == 'T'){
    return 4;
  }
  return 0;
}









long long getKey(char str[]){
  long long sum = 0;
  long long p,i;
  p = 1;
  for(i = 0; i<strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}




int h1(int key){
  int r;
  r = key %  S;
    return r;
}

int h2(int key){
  int r;
  r = 1 + (key % (S-1));
  return r;
}

int find (char str[]) {
  int key,i,h;
  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key) )%S;
    if(strcmp(H[h],str) == 0){
      return 1;
    }
    else if(strlen(H[h]) == 0){
      return 0 ;
    }
  }
    return 0;
  }

int insert (char str[]) {
  int key,i,h;
  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key) )%S;
    if(strcmp(H[h],str) == 0){
      return 1;
    }
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0 ;
    }
  }
    return 0;
  }




Measured memory_bytes: 16068
#include<stdio.h>
int main(void)
{
  int i,top=0,price;
  char str[4];
  
  fgets(str,sizeof(str),stdin);
  
  for(i=0;i<3;i++)
  {
    if(str[i] == 'o')
    {
      top++;
    }
  }
  
  price = top*100 + 700;
  
  printf("%d",price);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            bool[] dp = new bool[101000];
            dp[0] = true;
            for (int i = 0; i < 100000; i++)
            {
                if (dp[i])
                {
                    dp[i + 100] = true;
                    dp[i + 101] = true;
                    dp[i + 102] = true;
                    dp[i + 103] = true;
                    dp[i + 104] = true;
                    dp[i + 105] = true;
                }
            }
            WriteLine(dp[n] ? 1:0);
        }
    }
}

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

int main() {
    int n, co = 0;
    cin >> n;
    vector<int> l(n);
    rep(i, n) {
        cin >> l[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            for (int k = j; k < n; ++k) {
                if (l[i] != l[j] && l[k] != l[j] && l[k] != l[i]) {
                    if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
                        co++;
                    }
                }
            }
        }
    }
    cout << co << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m=0;
  string  s;
  cin>>n>>s;
  n=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='I') n++;
    else n--;
    m=max(m,n);
  }
  cout<<m<<endl;
}

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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define in insert
#define mp(a, b) make_pair(a, b)
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int n; cin>>n;
	map<string, int> cnt;
	forn(i, n){ string s; cin>>s; cnt[s]++; }
	int freq = 0;
	for(auto elem: cnt)
		freq = max(freq, elem.S);
	for(auto elem: cnt)
		if(elem.S==freq) cout<<elem.F<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 23808
N,A,B = map(int,input().split())
if N == 1:
  if A != B:
    print(0)
    exit()
  else:
    print(1)
    exit()
if A>B:
  print(0)
  exit()
MIN = A*(N-1)+B
MAX = A+B*(N-1)
ans = MAX-MIN +1
print(ans)

Measured memory_bytes: 9088
n,m,q= map(int, input().split())
s = [list(map(int, input().split()))for i in range(q)]
a =[1]*(n+1)
z =[]
def dfs(n,m,a,now):
    if now==n:
        b=a.copy()
        z.append(b)
        return
    for i in range(a[now],m+1):
        a[now]=i
        a[now+1]=i
        dfs(n,m,a,now+1)
dfs(n,m,a,0)
ma = 0
for i in range(len(z)):
    ans=0
    for j in range(q):
        if z[i][s[j][1]-1]-z[i][s[j][0]-1]==s[j][2]:
            ans+=s[j][3]
    ma=max(ma,ans)
print(ma)


Measured memory_bytes: 24316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int d=0;
  vector<int> as(n);
  for(int i=0;i<n;i++){cin>>as.at(i);}
  sort(as.begin(),as.end());
  cout<<as.at(as.size()-1)-as.at(0)<<endl;
}

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

typedef long long ll;
typedef long double ld;

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

    ll mod = pow(10, 9) + 7;

    ll N;
    cin >> N;

    ll ans = 1;

    for(ll i = 1; i <= N; i++){
        ans *= i;
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxN = 300010;
const int maxM = 100010;
const int N = 5000; 
const int MOD = 1000000007;

ll a[maxN];
ll b[maxN][30];
ll s[maxN][30];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		ll tmp = a[i];
		for(int j=1;j<=20;j++)
		{
			b[i][j] = ((tmp>>(j-1))&1);
			//printf("%d ",b[i][j]);
		}
		//cout<<endl;
	}
	for(int j=1;j<=20;j++)
	{
		for(int i=1;i<=n;i++)
		{
			s[i][j] = s[i-1][j]+ b[i][j];
			//printf("%d ",s[i][j]);
		}
	//	cout<<endl;
	}
	ll ans = 0;

	for(int i=1;i<=n;i++)
	{
		int minn = INF;
		for(int j=1;j<=20;j++)
		{
			int flag = s[i-1][j] + 2;
			int l = 1,r = n;
			while(l<r)
			{
				int mid = (l+r)/2;
				if(s[mid][j] >= flag)
				{
					r = mid;
				}
				else if(s[mid][j] < flag)
				{
					l = mid+1;
				}
			}
			if(s[l][j] < flag)
				l = l+1;
			if(l < minn)
				minn = l;	
		}
		ans += minn - i;
	}
	printf("%lld\n",ans);
	return 0;
}  

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

char next_char(char c, int n) {
  return c + (n % 26);
}

int main() {
  char WORD[100000];
  int N;

  scanf("%s", WORD);
  scanf("%d", &N);

  int len = strlen(WORD);

  int n = N;

  for (int i = 0; i < len; i++) {
    if (WORD[i] == 'a') { continue; }

    int required_n = (122 - WORD[i] + 1);

    if (n >= required_n) {
      WORD[i] = 'a';
      n -= required_n;
    }
    else {
      continue;
    }
  }

  if (n >= 0) {
    WORD[len-1] = next_char(WORD[len-1], n);
  }

  printf("%s\n", WORD);

  return 0;
}



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

int N;

int main(){
	cin>>N;
	if((N / 100 == 7) || (N / 10 % 10 == 7) || (N % 10 == 7)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3632
mod = 1e9+7
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    m = {}
    N = int(raw_input())
    
    for i in range(1, N+1):
        s = str(i)
        first = s[0]
        last = s[-1]
        key = first + last
        m[key] = m.get(key, 0) + 1
    
    ans = 0
    
    #print(m)
    for k in m:
        if k[0] == k[1]:
            ans += m[k] * m[k]
        else:
            swap = k[1] + k[0]
            ans += m[k] * m.get(swap, 0)
    """
    for key1 in m:
        for key2 in m:
            #if key1 == key2:
            #    continue
            if key1[0] == key2[1] and key1[1] == key2[0]:
                ans += m[key1] * m[key2]
    """
    
    print(ans)
    
    
    

main()

Measured memory_bytes: 32668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cassert>
#include <string>
#include <cmath>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
using namespace std;
typedef long long ll;
const int MAX = 0x7ffffff;
int t;
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b , a % b);}
void slove()
{
	ll n , k;
	cin >> n >> k;
	if(n * 2 <= k)cout << n << endl;
	else if(n % k == 0)cout << 0 << endl;
	else cout << min(n % k , abs(n % k - k));
}
int main()
{
	SIS;
	slove();
}

Measured memory_bytes: 256
x, y, X, Y = map(int, input().split())
L, R, U, D = "L", "R", "U", "D"
print("".join([R]*(X-x)+[U]*(Y-y)+[L]*(X-x)+[D]*(Y-y)+[D]+[R]*(X-x+1)+[U]*(Y-y+1)+[L, U]+[L]*(X-x+1)+[D]*(Y-y+1)+[R]))

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

int main() {

  long long N, T;
  cin >> N >> T;

  vector<long long> t(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }

  long long answer = T;

  for (int i = 1; i < N; i++) {
    if (t[i] - t[i-1] < T) {
      answer += t[i] - t[i-1];
    } else {
      answer += T;
    }
  }
  
  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 1792
<?php

$input1 = fgets(STDIN);
$input2 = fgets(STDIN);
$array = explode(' ', $input2);

$message = 'NG';

for ($i = (int)$array[0]; $i <= (int)$array[1]; $i++) {
    if ($i % (int)$input1 === 0) {
        $message = 'OK';
        break;
    }
}

echo $message;

Measured memory_bytes: 15980
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if((b - a) == (c - b)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2e6+5;
char s[N];
int cs, ct, ans;
int main()
{
    scanf("%s", s);
    for(int i = 0; s[i]; ++i)
    {
        if(s[i] == 'S') ++cs;
        else if(cs) --cs;
        else ++ct;
    }
    printf("%d\n", cs+ct);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
vector <int> n;

int main(){
	long long n,a,ans=0,cur;
	cin>>n>>cur;
	for(int i=1;i<n;i++){
		cin>>a;
		if(a<=cur){
			ans+=cur-a;
		}else{
			cur=a;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    int mini = INF;
    int maxi = -INF;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int in;
        cin >> in;
        mini = min(mini, in);
        maxi = max(maxi, in);
    }
    cout << maxi - mini << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    string W[N];
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }
    bool f = true;
    for(int i = 1; i < N;  i++){

        for(int j = 0; j < i ; j++){
            if(W[i] == W[j]){
                f = false;
                break;
            }
        }
        if(!f) break;

        if(i == N-1){
            f = (W[i].front() == W[i-1].back());
        }else{
            f = (W[i].front() == W[i-1].back());
            f = (W[i].back() == W[i+1].front());
        }
    }
    cout << (f ? "Yes" : "No") <<  endl;
}


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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a,b; cin >> a >> b;
    cout << (a%2==1&&b%2==1?"Yes":"No") <<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, t;
  cin >> n >> t;
  vector<ll> a(n), b(n);
  vector<vector<ll>> dp1(n+1, vector<ll>(t+5000)), dp2(n+1, vector<ll>(t+5000));
  rep(i, n) {
    cin >> a[i] >> b[i];
  }

  rep(i, n) {
    rep(j, t) {
      dp1[i+1][j] = max(dp1[i][j], dp1[i+1][j]);
      dp1[i+1][j+a[i]] = max(dp1[i+1][j+a[i]], dp1[i][j] + b[i]);
    }
  }

  for (int i = n-1; i >= 0; --i) {
    rep(j, t) {
      dp2[i][j] = max(dp2[i][j], dp2[i+1][j]);
      dp2[i][j+a[i]] = max(dp2[i][j+a[i]], dp2[i+1][j] + b[i]);
    }
  }

  ll ans = 0;
  rep(i, n) rep(j, t) {
    chmax(ans, dp1[i][j] + b[i] + dp2[i+1][t-1-j]);
  }
  cout << ans << endl;

  /*for (auto itr : dp1) {
    for (auto it : itr) {
      cout << it << " ";
    }
    cout << endl;
  }*/
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int p[m];
    string s[m];
    int ac = 0;
    bool solved[n] = {};
    int counter[n] = {};
    int pen = 0;
    rep(i, m){
        cin >> p[i] >> s[i];
        if(s[i] == "AC"){
            solved[p[i]-1] = true;
        }else{
            if(solved[p[i]-1] == false) counter[p[i]-1]++;
        }
    }
    rep(i, n){
        if(solved[i]){
            ac++;
            pen += counter[i];
        }
    }
    cout << ac << endl;
    cout << pen << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int dp[1000000];
int ar[1000000];
int f(int i,int n)
{
	if(i==n)
	return 0;
	if(dp[i]!=-1)
	return dp[i];
	int cost=f(i+1,n)+abs(ar[i]-ar[i+1]);
	if(i+2<=n)
	{
		cost=min(cost,f(i+2,n)+abs(ar[i]-ar[i+2]));
	}
	return dp[i]=cost;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<f(1,n);
}

Measured memory_bytes: 11136
#include <stdio.h>

/*

????????¢????????????

????????¢?????????????????????????????????????????????????????°?????????????????????????????????????¬????????????????????????¢?????????????????????????????¨??????????????????????????§?¨? (W,H)(W,H) ????????????????????????????????????????????????????????§?¨? (x,y)(x,y) ??¨?????? rr ??§?????????????????????


????????¢???????????? 

Input
5????????´??° WW???HH???xx???yy???rr ????????????????????§1???????????????????????????

Output
??????????????¢????????¨????????????????????? Yes ??¨????????¨??§???????????????????????° No ??¨1?????????????????????????????????

*/

int main( void )
{
	int WW, HH, xx, yy, rr;

	scanf( "%d %d %d %d %d", &WW, &HH, &xx, &yy, &rr );

	if ( xx - rr < 0 ) {
		printf( "No\n" );
	}
	else if ( yy - rr < 0 ) {
		printf( "No\n" );
	}
	else if ( xx + rr > WW ) {
		printf( "No\n" );
	}
	else if ( yy + rr > HH ) {
		printf( "No\n" );
	}
	else {
		printf( "Yes\n" );
	}
	
	return 0;
}

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

using namespace std;
using P = pair<int, int>;

constexpr int INF = numeric_limits<int>::max() / 2;

int c[10][1005];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  int ans = INF;
  for (int b = 0; b <= 1 << (h - 1); b++) {
    bitset<10> bit(b);  // hのyoko区切り線

    int block = 0;

    vector<int> to(h);
    for (int i = 0; i < h; i++) {
      to[i] = block;
      if (bit[i]) {
        block++;
      }
    }

    block++;

    for (int i = 0; i < block; i++) {
      for (int j = 0; j < w; j++) {
        c[i][j] = 0;
      }
    }

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        c[to[i]][j] += s[i][j] - '0';
      }
    }

    int num = block - 1;

    vector<int> now(block);
    auto add = [&](int j) {
      for (int i = 0; i < block; i++) {
        now[i] += c[i][j];
      }

      for (int i = 0; i < block; i++) {
        if (now[i] > k) {
          return false;
        }
      }

      return true;
    };

    for (int j = 0; j < w; j++) {
      if (!add(j)) {
        num++;
        now = vector<int>(block);
        if (!add(j)) {
          num = INF;
          break;
        }
      }
    }

    ans = min(ans, num);
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
  i64 h, w, n;
  cin >> h >> w >> n;
  if (h < w)
    cout << (n + w - 1) / w << endl;
  else
    cout << (n + h - 1) / h << endl;
  return 0;
}


Measured memory_bytes: 256
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	int n;cin>>n;
	string s;cin>>s;
	string t=s;
	sort(all(t));
	int cntr=0,cntw=0;
	for(int i=0;i<size(t);i++)
	{
		if(t[i]=='R')
		{
			if(t[i]!=s[i])
			cntr++;
		}
		else
		{
			if(t[i]!=s[i])
			cntw++;
		}
	}
	cout<<min(cntr,cntw);
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3876
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val R = sc.nextInt()
    val C = sc.nextInt()
    val k = sc.nextInt()
    val items = Array(R) { LongArray(C) }
    for (i in 0 until k) {
        val r = sc.nextInt() - 1
        val c = sc.nextInt() - 1
        val v = sc.nextLong()
        items[r][c] = v
    }
    var dp = Array(4) { LongArray(C) }
    for (i in 0 until R) {
        val newdp = Array(4) { LongArray(C) }
        for (j in 0 until C) {
            newdp[0][j] = (0 until 4).map { dp[it][j] }.max()!!
            if (items[i][j] != 0L) {
                newdp[1][j] = newdp[0][j] + items[i][j]
            }
            for (k in 0 until 4) {
                val v = if (j > 0) newdp[k][j - 1] else 0L
                newdp[k][j] = maxOf(newdp[k][j], v)
                if (items[i][j] != 0L && k != 0) {
                    val w = if (j > 0) newdp[k - 1][j - 1] else 0L
                    newdp[k][j] = maxOf(newdp[k][j], w + items[i][j])
                }
            }
        }
        dp = newdp
    }
    println((0 until 4).map { dp[it][C - 1] }.max()!!)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 149456
import java.util.*;
import java.io.*;
public class Main {
			
    public void solve() throws IOException{
    	int n;
    	while( (n = nextInt()) != 0 ){
    		List<Integer> time = new ArrayList<Integer>();
    		for(int i = 0; i < n; i++){
    			time.add(nextInt());
    		}
    		Collections.sort(time);
    		long ans = 0;
    		long sum = 0;
    		for(int i = 0; i < time.size()-1; i++){
    			ans += time.get(i)+sum;
    			sum += time.get(i);
    		}
    		System.out.println(ans);
    	}
    }
    public static void main (String args[]) throws IOException{
        new Main().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer; 
    public void run() throws IOException{
        try{
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public int nextInt() throws IOException{
        return Integer.parseInt(nextToken());
    }
    public String nextToken() throws IOException{
        while( tokenizer == null || !tokenizer.hasMoreTokens() ){
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
} 

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

int main()
{
  char S[101];
  
  cin >> S;
  
  for(int i = 0; S[i] != '\0'; i++){
    if(i % 2 == 0){
     if(S[i] == 'L'){
        cout << "No" << endl;
      return 0;
      }
    }else{
      if(S[i] == 'R'){
        cout << "No" << endl;
      return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 256