akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n;
    v l(n);in(l,n);
    sort(all(l));
    int ans=0;
    f(i,n)
    {
    	for(int j=i+1;j<n;j++)
    	{
    		if(l[i]==l[j])continue;
    		for(int k=j+1;k<n;k++)
    		{
    			if(l[i]==l[k] || l[j]==l[k])
    				continue;
    			if(l[k] < l[i]+l[j])
    				ans++;
    		}
    	}
    }
    cout<<ans<<endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool in(int64 f, int64 t, int64 x) {
	t = t - 60*(f/60); f = f%60; x = x%60;
	if (f > t) f -= 60;
	return f <= x && x <= t;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while (cin >> s && s != "#") {
		int64 n = 0, two = 1;
		int64 dc = 0, dm = 1;
		reverse(all(s));
		for (int i = 0; i < s.size();) {
			n++;
			if (s.substr(i, 4) == "tsew") {
				if (90 * dm != dc) {
					dc = dc * (two/dm) + 90;
					dm = two;
				}
				i += 4;
			} else {
				if (0 != dc) {
					dc = dc * (two/dm) - 90;
					dm = two;
				}
				i += 5;
			}
			two *= 2;
		}
		int64 d = __gcd(dc, dm);
		dc /= d; dm /= d;
		if (dm == 1) cout << dc << endl;
		else cout << dc << "/" << dm << endl;
	}
}



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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}

template<typename U>
void pprint(U a){
    cout<<a;
}

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

    ll n;
    cin>> n;
    ll ans9 = 1;
    ll ans8 = 1;
    ll ans7 = 1;
    ll dev = 1000000000+7;

    rep(i,n){
        ans9*=10;
        ans8*=9;
        ans7*=8;
        if(ans9>dev){
            ans9 %=dev;
        }
        if(ans8>dev){
            ans8 %=dev;
        }
        if(ans7>dev){
            ans7 %=dev;
        }
    }

    ll ans = ans9+ans7-2*ans8;
    ans %= dev;

    if(ans>=0){
        fin(ans);
    }else{
        fin(dev+ans);
    }



    return 0;
}




Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	int Numero;
	int Soma = 0;
	scanf("%d",&Numero);
	
	for(int i = 1; i <=Numero; i++)
	{
			for(int j = i+1;j <= Numero;j++){
				
				if(j%2!= 0){
					if(i%2 ==0)
					{
						Soma++;
					}
					
				}
				else
				{
					if(i%2!=0)
					{
						Soma++;
					}
					
				}
			}
		
	}
	printf("%d\n",Soma);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

bool o(P p1,P p2){
    return p1.ft-p1.sd>p2.ft-p2.sd;
}

int main(){
    ll x,y,z,a,b,c,s=0,sb[100010]={},sc[100010]={};
    P p[100010];
    cin>>x>>y>>z;
    fr(i,x+y+z){
        cin>>a>>b>>c;
        s+=a;
        p[i]=mp(b-a,c-a);
    }
    sort(p,p+x+y+z,o);
    priority_queue<ll,vector<ll>,greater<ll>> pqb;
    fr(i,y){
        sb[i+1]=sb[i]+p[i].ft;
        pqb.push(p[i].ft);
    }
    for (int i = y; i < y+x; ++i) {
        pqb.push(p[i].ft);
        sb[i+1]=sb[i]+p[i].ft-pqb.top();
        pqb.pop();
    }
    priority_queue<ll,vector<ll>,greater<ll>> pqc;
    for(int i=x+y+z;i>x+y;i--){
        sc[i-1]=sc[i]+p[i-1].sd;
        pqc.push(p[i-1].sd);
    }
    for(int i=x+y;i>y;i--){
        pqc.push(p[i-1].sd);
        sc[i-1]=sc[i]+p[i-1].sd-pqc.top();
        pqc.pop();
    }
    ll ans=-1e18;
    for (int i = y; i <= y+x; ++i) {
        ans=max(ans,s+sb[i]+sc[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3704
from math import sqrt, ceil

def check(n):
    minf = len(str(n))
    square = ceil(sqrt(n)) # 10^5
    for a in range(1, square+1):
        b, r = divmod(n, a)
        if r == 0:
            f = max(len(str(a)), len(str(b)))
            minf = min(f, minf)
    return minf

#print(check(10**10))
N = int(input())
print(check(N))


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

typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int L[n];
    for (int i = 0; i < n; i++)cin >> L[i];
    int ans = 0;
    sort(L, L + n);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (L[i] != L[j] && L[i] != L[k] && L[j] != L[k] &&
                    L[k] < L[i] + L[j]) {
                    ans++;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


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

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    char a, b, c, d;
    scanf("%*c%*c%c%c%c%c", &a, &b, &c, &d);
    puts(a == b && c == d ? "Yes" : "No");
}

Measured memory_bytes: 256
num = int(input())

# Order 40000 / approve
ct = 0

for i in range(105,num + 1,2):
    i_primes = 0
    for j in range(1, i + 1):
        if i % j == 0:
            if (i // j) <= j:
                break
            i_primes += 2
    
    ct += 1 if i_primes == 8 else 0

print(ct)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
  int X,Y,Z;
  int i,j;
  cin>>X>>Y>>Z;
  i=Y+Z;
  for(j=0;i<=X-Z;j++)
    {
      i=Z+Y+i;
    }
  cout<<j<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int s1 = a * b;
  int s2 = c * d;
  if(s1 > s2) {
    cout << s1 << endl;
  }else if(s1 < s2) {
    cout << s2 << endl;
  }else {
    cout << s1 << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(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() {
  ll a,b,c;
  cin >> a >> b >> c;

  ll start = -1;
  ll sum = 0;
  while (true) {
    sum += a;
    ll tmp = -1;
    if (start == -1) {
      start = sum % b;
      if (start == c) {
        cout << "YES" << endl;
        return 0;
      }
      continue;
    } else {
      tmp = sum % b;
    }
    if (tmp == c) {
      cout << "YES" << endl;
      return 0;
    }

    if (tmp == start) {
      break;
    }
  }

  cout << "NO" << endl;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    auto sum = make_vec<int>(n+1,n+1);

    REP(i,m) {
        int l,r;
        cin >> l >> r;

        sum[l][r]++;
    }

    rep(i,1,n+1) rep(j,1,n+1) sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1]; 

 
    vector<int> ans(q);
    REP(i,q){
        int p,q;
        cin >> p >> q;

        ans[i] = sum[q][q] - sum[p-1][q] - sum[q][p-1] + sum[p-1][p-1];
    }

    REP(i,q) pl(ans[i])


    return 0;
}


Measured memory_bytes: 2304
from math import gcd
n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            if i==j and j==k: ans+=i
            else:
                tmp = gcd(k, gcd(i,j))
                ans+=tmp
print(ans)


Measured memory_bytes: 68240
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

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

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

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif

int main(){
	cout << fixed << setprecision(15);

	int N,M;cin>>N>>M;
	intv A(N);cin>>A;

	int s=sum(A),cnt=0;

	for(auto e : A){
		if(e*4*M>=s)cnt++;
	}
	cout<<(cnt>=M?"Yes":"No");
}


Measured memory_bytes: 256
N, M = list(map(lambda x: int(x), input().split(' ')))

if N == 1 and M == 1:
    print(1)
    exit()
elif N == 1:
    print(M-2)
    exit()
elif M == 1:
    print(N-2)
    exit()

print((N-2)*(M-2))




Measured memory_bytes: 38256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define Eps (1e-10)

int X, Y, Z;
int V[5], E[52], A[52];
double dp[52][6002];

int main() {
  while (scanf("%d",&X),X) {
    scanf("%d%d",&Y,&Z);
    rep(i,X) scanf("%d",V+i);
    memset(E, 0, sizeof E);
    memset(A, 0, sizeof A);
    rep(i,Z) {
      int n; scanf("%d",&n);
      scanf("%d%d",E+n,A+n);
    }
    
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 0; i < Y; ++i) {
      for (int j = 0; j <= 5000; ++j) {
        if (dp[i][j] > Eps) {
          for (int k = 0; k < X; ++k) {
            int next = i + V[k], next_j = j;
            if (E[next] == 1) {
              next += A[next];
            } else if (E[next] == 2) {
              next_j += A[next];
            } else if (E[next] == 3) {
              next_j -= A[next];
            }

            if (next > Y) next = Y;
            if (next_j < 0) next_j = 0;
            dp[next][next_j] += dp[i][j] * (1.0/X);
          }
        }
      }
    }

    double ret = 0;
    rep(i,5001) {
      ret += i * dp[Y][i];
    }
    printf("%d\n",(int)ret);
    // for (int i = 0; i <= Y; ++i) {
    //   for (int j = 0; j <= 5; ++j) {
    //     printf("%.2lf ",dp[i][j]);
    //   }
    //   puts("");
    // }
    
  }
  return 0;
}

Measured memory_bytes: 3316
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;
 
void task(){
 	int n; cin >> n;
 	map<int,int>mp;
 	for(int i = 0; i<n; i++){
 		int a;cin >> a;
 		mp[a]++;
 	}
 	int ans = 0;
 	for(auto x:mp){
 		int F = x.ff;
 		int S = x.ss;
 		if(S>=F)ans+=S-F;
 		else ans+=S;
 	}
 	cout << ans << endl;
}

int main(){
        _
        #ifdef OJ
        freopen("inputf.in", "r", stdin);
        freopen("outputf.in", "w", stdout);
        #endif

        int T = 1; //cin >> T;
        while(T--){
            task();
        }
        
return 0;
}




Measured memory_bytes: 8044
n = int(input())
s = input()
MOD = 10**9 + 7

dp = [[0]*n for i in range(n)]
for i in range(n):
    dp[0][i] = 1

for i in range(n - 1):
    ruiseki = [0] * (n + 1)
    for j in range(n):
        ruiseki[j+1] = ruiseki[j] + dp[i][j]
        ruiseki[j+1] %= MOD

    if s[i] == "<":
        for j in range(n-i-1):
            dp[i+1][j] += ruiseki[n] - ruiseki[j+1]
            dp[i+1][j] %= MOD

    if s[i] == ">":
        for j in range(n-i-1):
            dp[i+1][j] += ruiseki[j+1]
            dp[i+1][j] %= MOD

print(dp[-1][0] % MOD)

Measured memory_bytes: 113756
import java.util.Scanner;
public class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.print(a*b + " ");
    System.out.println(2 * (a + b));
  }
}

Measured memory_bytes: 26064
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,f[3030][3030],sum[3030],ans;
string sa;
int main()
{
	cin>>n>>sa;
	f[1][1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
			sum[j]=(sum[j-1]+f[i-1][j])%mod;
		for(int j=1;j<=i;j++)
		{
			if(sa[i-2]=='<')
			{
				f[i][j]=sum[j-1];
			}
			else
				f[i][j]=(sum[i]+mod-sum[j-1])%mod;
//			cout<<f[i][j]<<endl;
		}
	}
	for(int i=1;i<=n;i++)
		ans=(ans+f[n][i])%mod;
	cout<<ans<<endl;
	return 0;
}

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

long long f(long long n)
{
	if (n == 0) return 1;
	long long x = f(n / 2);
	x *= x;
	if (n % 2 != 0) x *= 2;
	return x % mod;
}

long long calc(long long a, long long b, long long p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		long long d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}
long long nCr(long long n, long long r) {
  long long x = 1;
  long long y  = 1;
  for (long long i = 1; i <= r; ++i ) {
    x *= (n-i+1);
    y *= i;
	x %= mod;
	y %= mod;
  }
  return x * calc(y, mod - 2, mod) % mod;
}

signed main(void)
{
	long long n, a, b;
	long long sum;

	cin >> n >> a >> b;
	sum = f(n);
	sum %= mod;
	sum -= 1;
	sum %= mod;
	sum -= nCr(n, a); 
	sum %= mod;
	sum -= nCr(n, b);
	sum %= mod;
	while (sum < 0) sum += mod;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
    tmp = input.split("\n");
    n = parseInt(tmp[0], 10);
    a = tmp[1].split(" ");
    a = a.map(Number);
    total = 0;


    for (let i = 0; i < n - 1; i++) {

      first = a[i];
      second = a[i+1];
      count = i;
      
       if (first > second) {
           total += first - second;
           a.splice(count+1, 1, first);
       }
    }

    console.log(total);
    



}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int MOD = 1e9 + 7;

class mint {
public:
    long long x;
    mint(long long x=0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


int k;
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20);

    cin >> k;
    MOD = k;
    mint m(0);
    if(k == 1) {
        cout << 1;
        return 0;
    }
    if(k % 2 == 0) {
        cout << -1;
        return 0;
    }
    for(int i = 1; i < 1000000; i++) {
        m *= 10;
        m += 7;
        if(m.x == 0) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
}

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

using namespace std;

int main(){

 int s,b,c;

 cin>>s>>b>>c;

 int a[3];
 a[0] = s;
 a[1] = b;
 a[2] = c;

 sort(a,a+3);

 cout<<a[0]+a[1]<<endl;


 return 0;
 }


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






int main(){
    int N,D,cnt=0;
    cin >> N >> D;

    float X[N][D];
    for (int i=0;i<N;++i){
        for (int j=0;j<D;++j) {cin >> X[i][j];} 
    }

    for (int i=0;i<N;++i){
        for (int j=i+1;j<N;++j){
            float d = 0;
            for (int k=0;k<D;++k) {
                d += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
                if(sqrt(d)==int(sqrt(d))){
                     cnt += 1;                
                }
            }
        }

    cout << cnt << endl;

    }



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

int main()
{
    int a[100];int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n-1;i++)
        printf("%d ",a[i]);
    printf("%d\n",a[n-1]);
    for(int i=1;i<n;i++)
    {
        for(int j=i;j>0;j--)
        {
            if(a[j]<a[j-1])
            {
                int t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
        for(int i=0;i<n-1;i++)
            printf("%d ",a[i]);
        printf("%d\n",a[n-1]);
    }
}



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

int main(void){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int time = 0, temp = a;
    if(a < 0) {
        for(temp = a; temp < 0; temp++) {
            time += c;
        }
        temp = 0;
        time += d;
    }
    for(; temp < b; temp++) {
        time += e;
    }
    cout << time << endl;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int t=max({a,b,c});
  for (int i=1;i<k+1;i++){
    t*=2;
  }
  cout << a+b+c-max({a,b,c})+t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <map>

using namespace std;
using ll = long long;

const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

ll N, M;
map<string, ll> price;
map<string, vector<string>> G;

ll dfs(const string &target)
{
    if(G.count(target) == 0) return price[target];
    ll res = 0;
    for(auto &&x : G[target]) res += dfs(x);
    return min(res, price[target]);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N, N)
    {
        price.clear();
        G.clear();
        for(ll i = 0; i < N; i++)
        {
            string s; ll p; cin >> s >> p;
            price[s] = p;
        }
        cin >> M;
        for(ll i = 0; i < M; i++)
        {
            string s; ll k; cin >> s >> k;
            for(ll j = 0; j < k; j++)
            {
                string q; cin >> q;
                G[s].push_back(q);
            }
        }
        string target; cin >> target;
        cout << dfs(target) << endl;
    }
    return 0;
}




Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int x = scanner.nextInt();
        final int n = scanner.nextInt();
        final Set<Integer> set = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextInt())
            .collect(Collectors.toSet());
        int nearest = Integer.MAX_VALUE;
        for (int i = 0; i <= 200; i++) {
            if (set.contains(i)) {
                continue;
            }

            if (Math.abs(i - x) < Math.abs(nearest - x)) {
                nearest = i;
            }
        }

        System.out.println(nearest);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 34428
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned  long long int
#define pb push_back
#define sx 2000007
vector<int> adj[200007];
int vis[200007];
void dfs(int n)
{
    vis[n]=1;
    for(int i=0; i<adj[n].size(); i++)
    {
        if(vis[adj[n][i]]==0)
                dfs(adj[n][i]);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    memset(vis,0,sizeof(vis));
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(!vis[i])
        {
            dfs(i);
            cnt++;
        }
    }
    cnt--;
   cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 12680
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = MAP()
L = [LIST() for i in range(M)]

tree = UnionFind(N)
friends = defaultdict(list)
for a, b in L:
    friends[a-1].append(b-1)
    friends[b-1].append(a-1)
    tree.union(a-1, b-1)
# print()
# print(tree.group_count())
dic = defaultdict(int)
for i in range(N):
    al = tree.find(i)
    # print(al)
    dic[al] += 1
# print(dic.values())
# exit()
l = list(dic.values())
# print(friends)
# exit()
# l = []
# for key in al:
#     l.append(len(al[key]))
l.sort()
sl = set(l)
tmp = 0
ans = 0
for y in sl:
    # y -= ans
    y -= tmp
    ans += y
    tmp += y

    #  += y
print(ans)

    


Measured memory_bytes: 150312
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
int main(void)
{
    int n;
    cin>>n;
    map < int , int > M;
    while (n --)
    {
        int v;
        cin>>v;
        M[v] += 1;
    }
    int m;
    cin>>m;
    while (m --)
    {
        int v;
        cin>>v;
        M[v] -= 1;
        if (M[v] < 0)
            return puts("NO") * 0;
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 9600
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cheapest = min(a) + min(b)
for i in range(M):
    l,m,n = map(int, input().split())
    x = a[l-1] + b[m-1]- n
    if x < cheapest:
        cheapest = x
print(cheapest)


Measured memory_bytes: 18736
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = input()

n = int(N[-1])
if n in [2,4,5,7,9]:
    print("hon")
elif n in [0,1,6,8]:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 65560
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],c[N],b[N],d[N],idx,h[N],ne[N<<1],e[N<<1],w[N<<1];
void add(int a,int b,int c){e[idx]=b;ne[idx]=h[a];w[idx] =c;h[a]=idx ++;}
bool vis[N],use[N];
int get(int x)
{
    return lower_bound(d+1,d+1+n,x)-d;
}
bool dfs(int u)
{
    vis[u]=true;
    int x=c[u];
    for(int i=h[u];~i;i=ne[i])
    {
        int v=e[i];
        if(!vis[v]&&dfs(v))
        {
            x^=1;use[w[i]]=true;
        }
    }
    return x;
}
int main()
{
    // scanf("%d%d",&n,&m);
    // for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
    // for(int i=1;i<=n;i++)
    //     scanf("%d%d",&a[i],&b[i]),d[i]=a[i];
    // sort(d+1,d+1+n);
    // for(int i=1;i<=n;i++)
    //     a[i]=get(a[i]),c[a[i]]=b[i];
    // for(int i=n+1;i>=1;i--)
    //     c[i]^=c[i-1];
    // for(int i=1;i<=m;i++)
    // {
    //     int l,r;scanf("%d%d",&l,&r);
    //     l=get(l);
    //     r=upper_bound(d+1,d+1+n,r)-d -1;
    //     if(l<=r)
    //         add(l,r+1,i),add(r+1,l,i);
    // }
    for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
    ios::sync_with_stdio(false) ;
    cin.tie(0) , cout.tie(0) ;
    cin >> n >> m ;
    for(int i = 1; i <= n ; i ++) cin >> a[i] >> b[i] , d[i] = a[i] ;
    sort(d + 1 , d + n + 1) ;
    for(int i = 1; i <= n ;i ++)
     c[get(a[i])] = b[i] ;
    for(int i = n + 1; i >= 1 ;i --) c[i] ^= c[i - 1] ;
    for(int i = 1; i <= m ;i ++)
     {
       int l , r ;
       cin >> l >> r ;
       l = get(l) , r = upper_bound(d + 1 , d + n + 1 , r) - d - 1 ;
       if(l <= r)
       add(l , r + 1 , i) , add(r + 1 , l , i) ;
     }
    for(int i=1;i<=n+1;i++)
        if(!vis[i]&&dfs(i))
    {
        cout << -1 << endl ;;return 0;
    }
    int ans=0;
    for(int i=1;i<=m;i++)
        if(use[i]) ans++;
    cout << ans << endl ;
    for(int i=1;i<=m;i++)
    if(use[i])
       cout << i << " " ;
}


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

r = {}

for i in range(N):
  x = input()
  r[x] = r.get(x,0) +1

print("AC x {}".format(r.get("AC",0)))
print("WA x {}".format(r.get("WA",0)))
print("TLE x {}".format(r.get("TLE",0)))
print("RE x {}".format(r.get("RE",0)))

Measured memory_bytes: 74788
c,b=gets.chomp.split(" ").map(&:to_i);a=gets.chomp;p="";p += a[0..(b-2)] if (b-2)>0;p += a[b-1].downcase if (b-1)>0;p += a[0].downcase if (b-1)<=0;p += a[b..(a.length)];puts p

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

static const double pi = 3.141592653589793;

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  pair<double, double> a =
      make_pair(A * cosf64(2 * pi * (H / 12 + M / 12 / 60)),
                A * sinf64(2 * pi * (H / 12 + M / 12 / 60)));
  pair<double, double> b =
      make_pair(B * cosf64(2 * pi * (M / 60)), B * sinf64(2 * pi * (M / 60)));

  cout << fixed << setprecision(15)
       << sqrt((a.first - b.first) * (a.first - b.first) +
               (a.second - b.second) * (a.second - b.second))
       << endl;
}

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

int main() {
  long n,k,q;
  cin >> n >> k >> q;
  
  vector<long> m(n);
  
  for(int i=0; i<q; i++){
    long a;
    cin >> a;
    m.at(a-1) = m.at(a-1) + 1;
  }
  for(int i=0; i<n; i++){
    //cout << m.at(i) <<endl;
    if(m.at(i)-q+k<=0){
      cout << "No" <<endl;
    }else{
      cout << "Yes" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1408
data class XYH(val x: Int, val y: Int, val h: Int) {
    constructor(xyh: List<Int>): this(xyh[0], xyh[1], xyh[2])
}
fun main(args: Array<String>) {
    val N = nextInt()
    val xyh = Array(N) { XYH(listOfInt()) }
    for (x in 0 .. 100) {
        for (y in 0 .. 100) {
            var H: Int? = null
            var good = true
            for (it in xyh) {
                if (it.h > 0) {
                    val tmp = it.h + Math.abs(y - it.y) + Math.abs(x - it.x)
                    if (H == null) H = tmp
                    else if (H != tmp) {
                        good = false
                        break
                    }
                }
            }
            if (!good) continue
            val h = H!!
            for (it in xyh) {
                if (it.h == 0) {
                    val dist = Math.abs(y - it.y) + Math.abs(x - it.x)
                    if (h > dist) {
                        good = false
                        break
                    }
                }
            }
            if (!good) continue
            println("$x $y $h")
        }
    }
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 37968
import sys
sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

S = input().rstrip()

for i, s in enumerate(S):
    if i % 2 == 0:
        if s == "L":
            print("No")
            break
    else:
        if s == "R":
            print("No")
            break
else:
    print("Yes")


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 R, C, K;
  cin >> R >> C >> K;
  vector<int64> r(K), c(K), v(K);
  vector<vector<PLL>> ri(R);
  REP(i, K) {
    cin >> r[i] >> c[i] >> v[i];
    r[i]--; c[i]--;
    ri[r[i]].push_back({c[i], v[i]});
  }
  REP(i, R) sort(all(ri[i]));
  auto dp = make_v<int64>(C+1, 4);
  REP(i, R) {
    vector<int64> item(C+1, 0);
    REP(j, ri[i].size()) item[ri[i][j].fs] = ri[i][j].sc;
    auto dp2 = make_v<int64>(C+1, 4);
    REP(j, C) {
//      cout << item[j] << " ";
      REP(k, 4) {
        chmax(dp2[j][0], dp[j][k]);
        chmax(dp[j + 1][k], dp[j][k]);
        if (k < 3) {
          chmax(dp2[j][0], dp[j][k] + item[j]);
          chmax(dp[j + 1][k + 1], dp[j][k] + item[j]);
        }
      }
    }
//    cout << endl;
    swap(dp, dp2);
  }
  cout << (*max_element(all(dp[C-1]))) << endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,c;cin>>a>>b>>c;

  if(a+b==c||b+c==a||c+a==b)out("Yes")
  else out("No")


  return 0;
}


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

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    sort(h.begin(), h.end());
    int diff_min = h[N-1];
    for (int i = 0; i < N-K+1; i++) {
        diff_min = min(diff_min, h[i+K-1] - h[i]);
    }

    cout << diff_min << endl;
}

Measured memory_bytes: 640
import math

N = int(input())
sN = int(math.sqrt(N))
ans = int(1e11)

for i in range(1, sN + 1):
    if N % i == 0:
        a = i
        b = N // i
        ans = min(ans, max(len(str(a)), len(str(b))))
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//CLOCKS_PER_SEC
#define se second
#define fi first
#define ll long long
#define Pii pair<int,int>
#define Pli pair<ll,int>
#define ull unsigned long long
#define pb push_back
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const double Pi=3.14159265;
const int N=4e5+10;
const ull base=163;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
using namespace std;
int a[N];
int main(){
    int n,m;
    cin>>n>>m;
    ll ans=INF;
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
    }
    int l=1,r=m;
    while(r<=n){
        if(a[r]>=0&&a[l]<=0){
            ans=min(ans,1LL*min(abs(a[r]),abs(a[l]))*2+max(abs(a[r]),abs(a[l])));
        }
        else if(a[r]<=0&&a[l]<=0){
            ans=min(ans,-1LL*a[l]);
        }
        else {
            ans=min(ans,1LL*a[r]);
        }
        l++,r++;
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    string name;
    cin>>name;
    cout<<name.substr(0,3);
    output();
    return 0;
}

Measured memory_bytes: 3628
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0015
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_DIGITS 80
#define MAX_INPUTS 101

char           *add(const char *n1, const char *n2);
char           *overflowmsg();
char           *stralloc(const size_t length);

int
main(int argc, char *argv[])
{
    int             n, i;
    char            n1[MAX_INPUTS];
    char            n2[MAX_INPUTS];
    char           *r;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s", n1);
        scanf("%s", n2);
        r = add(n1, n2);

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

        free(r);
    }

    return 0;
}

char           *
add(const char *n1, const char *n2)
{
    int             l1, l2, lr;
    int             c = 0;
    int             d;
    int             i = 0;
    char           *r;
    char           *n;

    l1 = strlen(n1);
    l2 = strlen(n2);
    if (l1 > MAX_DIGITS || l2 > MAX_DIGITS) {
        return overflowmsg();
    }
    lr = l1 > l2 ? l1 : l2;

    r = stralloc(lr + 1);
    while (lr >= 0) {
        d = c + (l1-- > 0 ? n1[l1] - '0' : 0) + (l2-- > 0 ? n2[l2] - '0' : 0);
        c = d / 10;
        r[lr--] = d % 10 + '0';
    }
    if (r[0] == '0') {
        i++;
    }
    if (strlen(r + i) > MAX_DIGITS) {
        free(r);
        return overflowmsg();
    }
    if (i != 0) {
        n = r;
        r = stralloc(strlen(n + i));
        strcpy(r, n + i);
        free(n);
    }
    return r;
}

char           *
overflowmsg()
{
    const char     *e = "overflow";
    char           *r;
    r = stralloc(strlen(e));
    strcpy(r, e);
    return r;
}

char           *
stralloc(const size_t length)
{
    return (char *)calloc(length + 1, sizeof(char));
}

Measured memory_bytes: 1780