akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
   int n;
   cin>>n;
   double d;
   cin>>d;
   double p,k,k1;
   double x1,x2;
   ll sum = 0;
   while(n--)
   {
    cin>>x1>>x2;
     k = abs(x1);
     k1 = abs(x2);
     p = sqrt(k*k + k1*k1);
     if(p<=d)
        sum++;
   }
   cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3820
S = input()
count = 0

for i, n in enumerate(S):
    if (i + 1) % 2 == 0:
        if n == "L" or n == "U" or n == "D":
            count += 1
    else:
        if n == "R" or n == "U" or n == "D":
            count += 1

if len(S) == count:
    print("Yes")
else:
    print("No")

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

int main() {
	long long n, a, b; cin >> n >> a >> b;
	vector<int>x(n); for (auto&& xx : x)cin >> xx;
	long long ans = 0;
	for (int i = 1; i < n; i++) {
		ans += min((x[i] - x[i - 1]) * a, b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void solve();
int main()
{
//	freopen("SNOOKER.inp","r",stdin);
//	freopen("SNOOKER.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}
/*----------------------------------------------------------------------
 
-----------------------------------------------------------------------*/
using ll =  long long;
#define endl "\n"
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define what_is(x)  cerr << #x << " is :" << (x) << endl
const int MOD =  1e9+7;
const ll inf = LLONG_MAX;
const int MAX_N = 1e5 + 7;

int n;

int a[MAX_N], b[MAX_N], c[MAX_N], dp[MAX_N][4];
void solve()
{
	
	cin >> n ;
	for(int i = 1; i <= n ; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	
	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	
	for(int i = 2; i <= n; i ++)
	{
		dp[i][1] = a[i] + max(dp[i-1][2], dp[i-1][3]);
		dp[i][2] = b[i] + max(dp[i-1][1], dp[i-1][3]);
		dp[i][3] = c[i] + max(dp[i-1][2], dp[i-1][1]);
	}
	
	cout << max({dp[n][1], dp[n][2], dp[n][3] });
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
using namespace std;
 
class Dice{
public:
    int x[24],t[2];
    Dice(){
	for(int i = 0 ; i < 4 ; i++){ x[i] = 0; }
	for(int i = 0 ; i < 2 ; i++){
	    for(int j = 0 ; j < 8 ; j++){ x[j+i*8+4] = j/2+1; }
	}
	for(int i = 0 ; i < 4 ; i++){ x[i+20] = 5; }
    }
    char c(int a){
	switch(a){
	case 0:
	    return 'r';
	case 1:
	    return 'g';
	case 2:
	    return 'y';
	case 3:
	    return 'b';
	case 4:
	    return 'w';
	case 5:
	    return 'o';
	}
    }
    void U(){
	t[0] = x[4]; t[1] = x[5];
	x[4] = x[6]; x[5] = x[7];
	x[6] = x[8]; x[7] = x[9];
	x[8] = x[10]; x[9] = x[11];
	x[10] = t[0]; x[11] = t[1];
	t[0] = x[0]; x[0] = x[2];
	x[2] = x[3]; x[3] = x[1];
	x[1] = t[0];
    }
    void F(){
	t[0] = x[2]; t[1] = x[3];
	x[2] = x[13]; x[3] = x[5];
	x[13] = x[21]; x[5] = x[20];
	x[21] = x[8]; x[20] = x[16];
	x[8] = t[0]; x[16] = t[1];
	t[0] = x[6]; x[6] = x[14];
	x[14] = x[15]; x[15] = x[7];
	x[7] = t[0];
    }
    void R(){
	t[0] = x[1]; t[1] = x[3];
	x[1] = x[7]; x[3] = x[15];
	x[7] = x[21]; x[15] = x[23];
	x[21] = x[18]; x[23] = x[10];
	x[18] = t[0]; x[10] = t[1];
	t[0] = x[8]; x[8] = x[16];
	x[16] = x[17]; x[17] = x[9];
	x[9] = t[0];
    }
    void D(){
	t[0] = x[12]; t[1] = x[13];
	x[12] = x[18]; x[13] = x[19];
	x[18] = x[16]; x[19] = x[17];
	x[16] = x[14]; x[17] = x[15];
	x[14] = t[0]; x[15] = t[1];
	t[0] = x[20]; x[20] = x[22];
	x[22] = x[23]; x[23] = x[21];
	x[21] = t[0];
    }
    void B(){
	t[0] = x[0]; t[1] = x[1];
	x[0] = x[9]; x[1] = x[17];
	x[9] = x[23]; x[17] = x[22];
	x[23] = x[12]; x[22] = x[4];
	x[12] = t[0]; x[4] = t[1];
	t[0] = x[10]; x[10] = x[18];
	x[18] = x[19]; x[19] = x[11];
	x[11] = t[0];
    }
    void L(){
	t[0] = x[0]; t[1] = x[2];
	x[0] = x[19]; x[2] = x[11];
	x[19] = x[20]; x[11] = x[22];
	x[20] = x[6]; x[22] = x[14];
	x[6] = t[0]; x[14] = t[1];
	t[0] = x[4]; x[4] = x[12];
	x[12] = x[13]; x[13] = x[5];
	x[5] = t[0];
    }
    void print(){
	printf("..%c%c....\n",c(x[0]),c(x[1]));
	printf("..%c%c....\n",c(x[2]),c(x[3]));
	for(int i = 0 ; i < 2 ; i++){
	    for(int j = 0 ; j < 8 ; j++){
		printf("%c",c(x[j+i*8+4]));
	    }
	    printf("\n");
	}
	printf("..%c%c....\n",c(x[20]),c(x[21]));
	printf("..%c%c....\n",c(x[22]),c(x[23]));
    }
};
 
int main(){
    Dice d;
    char ch;
    while(cin >> ch){
	if(ch == 'U') d.U(); 
	if(ch == 'F') d.F(); 
	if(ch == 'R') d.R(); 
	if(ch == 'D') d.D(); 
	if(ch == 'B') d.B(); 
	if(ch == 'L') d.L(); 
    }
    d.print();
    return 0;
}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n;
    cin >> n;
    cout << n*(n-1)/2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b,x;
    a=read(), b=read(), x=read();
    if(a>x || a+b<x) puts("NO");
    else puts("YES");
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S;
  cin >> S;

  if(S.size() >= 4){
    if(S.substr(0,4) == "YAKI"){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl; 
  
  return 0;
}



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

int main() {
  long long int N;
  cin >> N;
  vector<long long int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  long long int SA = 0, SB = 0;
  for (int i = 0; i < N; i++) {
    SA += A.at(i);
    SB += B.at(i);
  }
  long long int K = SB - SA;
  long long int k1 = 0, k2 = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == B.at(i)) continue;
    else if (A.at(i) > B.at(i)) k1 += A.at(i) - B.at(i);
    else k2 += (B.at(i) - A.at(i) + 1) / 2;
  }
  if (max(k1, k2) <= K) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, A, X;
  cin >> N >> A;
  X = N % 500;
  if (A >= 500) {
    cout << "Yes" << endl;
  }
  else if (A >= X) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// dp[i][s]:=i人目までの弾性をペアとして決め、すでにペアになっている女性がbit表現でsであるようなペアの決め方の数

int dp[25][(1<<21)+5];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<vi> a(n, vi(n));
  rep(i,n) rep(j,n) cin>>a[i][j];
  
  dp[0][0]=1;
  
  rep(i,n){
    for(int s=0; s<(1<<n); s++){
      if(dp[i][s]!=0){
        rep(j,n){
          if(!(s&(1<<j)) && a[i][j]==1){
            dp[i+1][s|(1<<j)] = (dp[i+1][s|(1<<j)] + dp[i][s]) % MOD;
          }
        }
      }
    }
  }
  cout<<dp[n][(1<<n)-1]<<endl;
}

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

int graph[701][701];
bool bipartite = true;
int color[701];
vector<int> curr;
vector<pair<int,int>> pos;
bool dp[701][701];
int n;
void dfs(int x){
    curr.push_back(x);
    for(int next=0;next<n;next++){
        if(graph[x][next]){
            if(color[next]==color[x]) bipartite = false;
            else{
                if(color[next]==-1){
                    color[next] = (color[x]+1)%2;
                    dfs(next);
                }
            }
        }
    }
}
int main(){
    int m; 
    cin >> n >> m;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            graph[i][j] = 1;
    for(int i=0;i<m;i++){
        int u,v; cin >> u >> v;
        --u; --v;
        graph[u][v] = 0;
        graph[v][u] = 0;
    }
    for(int i=0;i<n;i++) graph[i][i] = 0;
    for(int i=0;i<n;i++) color[i] = -1;
    for(int i=0;i<n && bipartite;i++){
        if(color[i]==-1){
            color[i] =0;
            curr.clear();
            dfs(i);
            int x = 0;
            for(int a : curr)
                x+=color[a];
            pos.push_back({x,curr.size()-x});
        }
    }
    if(!bipartite){
        cout << -1 << endl;
        return 0;
    }
    dp[0][pos[0].first] = true;
    dp[0][pos[0].second] = true;
    for(int i=1;i<pos.size();i++){
        for(int j=0;j<701;j++){
            if(pos[i].first<=j){
                dp[i][j] = dp[i][j]||dp[i-1][j-pos[i].first];
            }
            if(pos[i].second<=j){
                dp[i][j] = dp[i][j]||dp[i-1][j-pos[i].second];
            }
        }
    }
    int best = 10000000;
    for(int j=0;j<=n;j++){
        if(dp[pos.size()-1][j]){
            best = min(best,(j*(j-1)+(n-j)*(n-j-1))/2);
        }
    }
    cout << best << endl;
}


Measured memory_bytes: 5432
import math
n,m=map(int,input().split())

if n >=2 and m >=2:
    ans=(n*(n-1))//2 +(m*(m-1))//2
elif n>=2:
    ans=(n*(n-1))//2
elif m >=2:
    ans=(m*(m-1))//2
else:
    ans=0

print(ans)

Measured memory_bytes: 3064
n,m = [int(i) for i in input().split()]

l = [[int(i) for i in input().split()] for _ in range(n)]

food_set = {i for i in range(1,m+1)}
for i in l:
    food_set = food_set & set(i[1:])
    
print(len(food_set))

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll n;
  scanf("%lld", &n);
  vll a(n);
  vvll positive;
  positive.reserve(n);
  ll current_max = 0;
  set<int> indexes;
  rep (i, n) {
    scanf("%lld", &a[i]);
    if (current_max < a[i]) {
      positive.push_back((vll){a[i], (ll)i});
      indexes.insert(i);
      current_max = a[i];
    }
  }
  int sz = (int)positive.size();

  vvll column_total(sz, vll(2, (ll)0));
  vll ans(n, (ll)0);
  for (int i = n-1; i >= 0; --i) {
    int lb = lower_bound(all(positive), (vll){a[i]}) - begin(positive);
    if (indexes.find(i) == end(indexes)) {
      column_total[lb][0] += 1;
      column_total[lb][1] += a[i];
    } else if (lb > 0) {
      column_total[lb][0] += 1;
      column_total[lb][1] += a[i];
      ans[positive[lb][1]] = column_total[lb][1] - column_total[lb][0] * positive[lb-1][0];
      column_total[lb-1][0] += column_total[lb][0];
      column_total[lb-1][1] += column_total[lb][0] * positive[lb-1][0];
    } else {
      ans[0] = column_total[0][1] + a[0];
    }
  }
  rep (i, n) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;

int a[200005];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    llong last = a[0], sum = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] < last)
        {
            sum += last - a[i];
            a[i] = last;
        }
        else 
        {
            last = a[i];
        }
    }
    printf("%lld\n", sum);
    return 0;
}

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

using namespace std;

constexpr int modulo = 1000000007;

std::vector<int> primeFactorization(int n) {
  std::vector<int> ret{};
  int const maxPrimteCandidate = static_cast<int>(sqrt(n));
  for (int i = 2; n > 1 && i <= maxPrimteCandidate; i++) {
    while (n % i == 0) {
      ret.push_back(i);
      n /= i;
    }
  }
  if (n > 1) {
    ret.push_back(n);
  }
  return ret;
}

int solve(int n) {
  if (n == 1) {
    return 1;
  }
  std::vector<int> allPrimes{};
  for (int i = 2; i <= n; i++) {
    auto primes = primeFactorization(i);
    allPrimes.insert(allPrimes.end(), primes.begin(), primes.end());
  }
  std::sort(allPrimes.begin(), allPrimes.end());
  int64_t ret = 1;
  for (auto itr = allPrimes.begin(); itr != allPrimes.end();) {
    auto const nextItr = std::upper_bound(itr, allPrimes.end(), *itr);
    ret *= ((nextItr - itr) + 1);
    ret %= modulo;
    itr = nextItr;
  }
  return static_cast<int>(ret);
}

int main() {
  int n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    int x;
    cin >> x;
    if (x >= 30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m; cin>>n>>m;
    int cnt = 0;
    int ans = 1005;
    vector <int> as;
    vector <vector<int>> g(1005,vector <int>());
    rep(i,m) {
        int a,b; cin>>a>>b; 
        g[a-1].push_back(b-1);
    }
    bool v[1005];
    memset(v, 0, 1005);
    vector <int> mu;
    rep(i,n){
        queue <pair <int, vector <int>> > q;
        q.push({i,mu});
        while(!q.empty()){
            cnt++;
            if(cnt == 100000) {cnt = 0; break;}
            auto p = q.front(); q.pop();
            if(p.S.size()>=ans) continue;
            if(v[p.F]) {
               if(p.F == i){
                   if(ans > p.S.size()){
                       ans = p.S.size();
                       as = p.S;
                   }
               }
               continue;
            }
            v[i] = 1;
            p.S.push_back(p.F);
            for(int j=0;j<g[p.F].size();j++){
               q.push({g[p.F][j], p.S});
           }
           
        }
        memset(v, 0, 1005);
    }
    
    if(ans != 1005) {cout<<ans<<'\n'; rep(i,ans) cout<<as[i]+1<<' ';}
    else cout<<-1<<endl;
}


Measured memory_bytes: 20096
n, m = map(lambda x: int(x), input().split())
a = [0] * m
b = [0] * m
c = [0] * m
for i in range(m):
    a[i], b[i], c[i] = map(lambda x: int(x), input().split())

inf = 100 * 1000
dist = [[inf for i in range(n+1)] for j in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
for i in range(m):
    dist[a[i]][b[i]] = c[i]
    dist[b[i]][a[i]] = c[i]

for k in range(1, n+1):
    for i in range(1, n+1):
        for j in range(1, n+1):
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])

count = 0
for i in range(m):
    if dist[a[i]][b[i]] < c[i]:
        count += 1
print(count)

Measured memory_bytes: 3428
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  int s = 0;
  int mx = 0;
  for(int i=0; i<n; i++) {
    cin >> p[i];
    p[i]++;
    s += p[i];
    if (i>=k) s -= p[i-k];
    mx = max(mx, s);
  }
  cout << fixed << setprecision(9) << (double)mx/2 << endl;
}  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
   vector<int>dp(n,1e9);
//    memset(dp,1e9,sizeof(dp));
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=min(i,k);j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

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

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

const int MOD = 1e9 + 7;

i64 mod_pow(i64 x, i64 n = MOD - 2) {
	i64 ret = 1;
	while(n) {
		if(n & 1) (ret *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return ret;
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	
	std::vector<i64> inv(n + 1);
	for(int i = 1; i <= n; i++) inv[i] = mod_pow(i);
	
	std::vector<i64> sum(inv.size() + 1);
	for(int i = 0; i < inv.size(); i++) sum[i + 1] = (sum[i] + inv[i]) % MOD;
	
	i64 latte = 1;
	for(i64 i = 1; i <= n; i++) (latte *= i) %= MOD;
	
	i64 ans = 0;
	for(int i = 0; i < n; i++) {
		i64 p = (sum[i + 2] - sum[2] + MOD) % MOD;
			p += (sum[n - i + 1] - sum[1] + MOD) % MOD;
			p %= MOD;
		(ans += p * latte % MOD * a[i] % MOD) %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
using namespace std;

int bubble(int A[], int n){
  int i,j;
  bool flag=1;
  int sw = 0;
  for ( i = 0; flag; i++ ){
      flag=0;
      for ( j = n-1; i < j; j-- ){
        if(A[j] < A[j-1]){
        swap(A[j],A[j-1]);
        sw += 1;
        flag=1;
        }
      }
  }
  return sw;
}

int main(){
  int n, i, j,sw;
  int A[100];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  sw=bubble(A,n);
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d", sw);
  printf("\n");
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;
 
#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  int n,m,k;
    cin>>n>>m>>k;
    Graph G(n);
    Graph block(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,k){
        int c,d;
        cin>>c>>d;
        c--; d--;
        block[c].pb(d);
        block[d].pb(c);
    }
    vbl seen(n,0);
    vin ans(n,0);
    
    
    rep(i,n){
        if(seen[i]){
            cout<<ans[i]<<" ";
            continue;
        }
        queue<int> q;
        set<int> r;
        q.push(i);
        r.insert(i);
        while(!q.empty()){
            int x=q.fn();
            q.pop();
            for(int y:G[x]){
                if(seen[y]) continue;
                q.push(y);
                r.insert(y);
                seen[y]=true;
                
            }
        }
        for(auto x: r){
            ans[x]=r.size();
            for(auto y:block[x]){
                if(r.count(y)) ans[x]--;
            }
            ans[x]-=G[x].size();
            ans[x]--;
        }
        cout<<ans[i]<<" ";
    }
    cout<<endl;
   
   
   
  }


Measured memory_bytes: 19824
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S; cin >> S;
	if (S[S.size()-1] == 's')cout << S << "es" << endl;
	else cout << S << "s" << endl;

	return 0;
}



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

using namespace std;
int gcd(int m, int n) {
	if(m < n) {
		int t = m;
		m = n;
		n = t;
	}
	while(true) {
		if(m % n == 0) {
			return n;
		} else {
			int t = m % n;
			m = n;
			n = t;
		}
	}
}

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> vv;
	vv.push_back(x);
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		vv.push_back(t);
	}
	sort(vv.begin(), vv.end());
	int g = 0;
	for(int i = 0; i < n; i++) {
		if(g == 0) {
			g = vv[i+1] - vv[i];
		} else {
			g = gcd(g, vv[i+1] - vv[i]);
		}
	}
	cout << g << endl;
}


Measured memory_bytes: 892
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	}
}


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

using namespace std;
int a[100000+5];
int b[100000+5];
int main(){
	int n;
	cin>>n;
	long long sum = 0;
	for(int i = 0;i < n+1;i++){
		cin>>a[i];
	}
	for(int i = 0;i < n;i++){
		cin>>b[i];
	}
	for(int i = 0;i < n;i++){
		long long k = 0;
		if(a[i] >= b[i]){
			k = b[i];
		}else{
			k += a[i];
			if(a[i+1] <= b[i] - a[i]){
				k += a[i+1];
				a[i+1] = 0;
			}else{
				a[i+1] = a[i+1] - b[i] + a[i];
				k += b[i] - a[i];
			}
		}
		sum += k;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1024
n=int(input().strip())
slis={'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
tlis={'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
st=''
S=input().strip()
for j in range(len(S)):
        slis[S[j]]+=1
for i in range(n-1):
    S=input().strip()
    for j in range(len(S)):
        tlis[S[j]]+=1
    for j in tlis:
        slis[j]=min(tlis[j],slis[j])
    for j in tlis:
        tlis[j]=0
stup=[]
for i in slis:
    stup.append((i,slis[i]))
stup.sort()

for i in range(26):
    st=st+stup[i][0]*stup[i][1]
    
print(st)

Measured memory_bytes: 3188
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
N = len(A)

c = np.bincount(A)
# 無駄なやつ
useless = c[c >= 2]
sub = useless.sum() - len(useless)
print(N - math.ceil(sub / 2) * 2)


Measured memory_bytes: 24412
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,x; cin >> N >> x;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<priority_queue<ll, vector<ll>, greater<ll>>> pq(N);
    ll ans = 1e18;
    rep(i,N) {
        rep(j,N) {
            pq[j].emplace(A[(j-i+N)%N]);
        }
        ll val = x*i;
        rep(j,N) {
            val += pq[j].top();
        }
        chmin(ans,val);
    }

    cout << ans << ln;
}



Measured memory_bytes: 32512
#include <iostream>
#include <cstring>

using namespace std;

const int N = 3010;

int n, m, d[N][N], i, j, k;
char a[N], b[N], v[N];

inline int maxim(int x, int y){
    return (x > y ? x : y);
}

int main(){
    cin >> a + 1;
    cin >> b + 1;
    n = strlen(a + 1);
    m = strlen(b + 1);
    for (i = 1; i <= n; ++i) {
        for (j = 1; j <= m; ++j) {
            if (a[i] == b[j]) {
                d[i][j] = 1 + d[i - 1][j - 1];
            } else {
                d[i][j] = maxim(d[i][j - 1], d[i - 1][j]);
            }
        }
    }
    i = n;
    j = m;
    while (d[i][j] != 0) {
        if (a[i] == b[j]) {
            v[++k] = a[i];
            --i;
            --j;
        } else {
            if (d[i - 1][j] < d[i][j - 1]) {
                j--;
            } else {
                i--;
            }
        }
    }
    for (i = k; i > 0; --i) {
        cout << v[i];
    }
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<double> vec(n);
    for(int i=0;i<n;i++){
        double x;
        cin >> x;
        vec[i]=x;
    }
   /* long long s=1;
    for(int i=0;i<n;i++){
        s *= vec[i];
    }
    long long t=0;
    for(int i=0;i<n;i++){
        int a=1;
        for(int j=0;j<n;j++){
            if(i!=j){
                a *= vec[i];
            }
        }
        t += a;
    }
    double T=t;
    double S=s;
   // float ans = S/T;
   // cout<<s <<" "<<t<<endl;
    cout<<setprecision(15)<<S/T<<endl;
*/
    double sum=0;
    for(int i=0;i<n;i++){
        sum += 1/vec[i];
        //cout<<sum<<endl;
    }
 //   cout<<setprecision(15)<<sum<<endl;
 cout<<setprecision(15)<<1/sum<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

typedef long long ll;
const ll maxn=2e5+10,maxa=2e3+10,mod=1e9+7;
ll n,a[maxn],b[maxn],ans;
ll dp[maxa<<1][maxa<<1];
ll fac[maxa<<2],inv[maxa<<2];

inline ll qpow(ll a,ll n){
	ll res=1;
	while(n){
		if(n&1)
			res=res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}
inline void init(){
	fac[0]=1;
	for(ll i=1;i<(maxa<<2);++i)
		fac[i]=fac[i-1]*i%mod;
	inv[(maxa<<2)-1]=qpow(fac[(maxa<<2)-1],mod-2);
	for(ll i=(maxa<<2)-1;i;--i)
		inv[i-1]=inv[i]*i%mod;
}

int main(){
	scanf("%lld",&n);
	init();
	for(ll i=1;i<=n;++i)
		scanf("%lld%lld",&a[i],&b[i]);
	for(ll i=1;i<=n;++i)
		++dp[maxa-a[i]][maxa-b[i]];
	for(ll i=1;i<(maxa<<1);++i)
		for(ll j=1;j<(maxa<<1);++j)
			dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
	for(ll i=1;i<=n;++i)
		ans=(ans+dp[maxa+a[i]][maxa+b[i]]-fac[a[i]+b[i]<<1]*inv[a[i]<<1]%mod*inv[b[i]<<1]%mod)%mod;
	printf("%lld\n",(ans*qpow(2,mod-2)%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 129664
n, l = map(int, input().split())

ai=0
if 1 <= 1-l <= n:
  ai=1-l
elif n<1-l:
  ai=n
else:
  ai=1

ans=0
for i in range(1,n+1):
  if i == ai: continue
  ans+=(l-1+i)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

int main()
{	
    std::ios_base::sync_with_stdio(0);
	  cin.tie(0);
	  cout.tie(0);
    
    ll r;
    cin>>r;

    ld ans = 6.28318530717958623200L;

    cout<<ans*r<<endl;

}

Measured memory_bytes: 3772
#include <stdio.h>

int main(void){
	char c;
	while((c = getchar()) != EOF && c != '\n'){
		if(c >= 'a' && c <= 'z'){
			printf("%c", c - 32);
		}else{
			printf("%c", c);
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	int money = 100000;

	cin >> n;

	FOR(i, 1, n) {
		money *= 1.05;
		if (money % 1000 != 0) {
			money = money - (money % 1000);
			money += 1000;
		}
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 3044
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)


int main(void) {
	int n;
	scanf("%d", &n);
	long long pow = 1;
	for (int i = 1; i <= n; ++i) {
		pow = (pow*i) % 1000000007;
	}

	printf("%lld", pow);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	int ctr = 0;
	for (int i = 0; i < n; ++i)
	{
		int x;
		scanf("%d", &x);
		if(x%2)
			ctr++;
	}
	cout<<((ctr%2)?"NO":"YES")<<"\n";
	return 0;
}

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

int main()
{
    long long a,b,k;
    cin >> a >> b >> k;
    
    if(k <= a){
        a -= k;
    }else{
        b = b-(k-a);
        b = max(0ll,b);
        a = 0;
    }
    cout << a << " " << b << endl;
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


Node treeSearch(Node u, int k){
	while(u!=NIL&&k!=u->key){
		if(k<u->key) u=u->left;
		else u=u->right;
	}
	 return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){
if(u!=NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}


Measured memory_bytes: 20496
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

long long a[100005];
long long sum[100005];
long long sum2[100005];

int main(){
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        if (!i) sum[i] = a[i];
        else sum[i] = a[i] + sum[i-1];
        sum2[i] = sum[i];
    }

    bool positive = true;
    long long ans[2] = {0};
    long long add = 0;
    for (int i = 0; i < N; i++) {
        sum[i] += add;
        if (positive) {
            if (sum[i] < 1) {
                ans[0] += 1 - sum[i]; 
                add += 1 - sum[i];
            }
        } else {
            if (sum[i] > -1) {
                ans[0] += sum[i] + 1;
                add -= sum[i] + 1;
            }
        }

        if (positive) positive = false;
        else positive = true;
    }

    positive = false;
    add = 0;
    for (int i = 0; i < N; i++) {
        sum2[i] += add;
        if (positive) {
            if (sum2[i] < 1) {
                ans[1] += 1 - sum2[i]; 
                add += 1 - sum2[i];
            }
        } else {
            if (sum2[i] > -1) {
                ans[1] += sum2[i] + 1;
                add -= sum2[i] + 1;
            }
        }

        if (positive) positive = false;
        else positive = true;
    }


    cout << min(ans[0], ans[1]) << endl;
}




Measured memory_bytes: 2560
// Aizu Vol0 0046: Differential
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

int main()
{
	double h, max, min;
	int f;

	f = 1;
	while (scanf("%lf", &h) == 1) {
		if (f) max = min = h, f = 0;
		else {
			if (h > max) max = h;
			else if (h < min) min = h;
		}
	}
	if (f) puts("0.0");
	else printf("%lf\n", max - min);
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

const int mod=1000000007;

int n;
vi a,b,c;

int main(){
	cin>>n;
	a=b=c=vi(n);
	int tmp=-1;
	for(int i=0;i<n;i++){
		cin>>b[i];
		if(tmp!=b[i]){
			tmp=b[i];
			a[i]=b[i];
		}
	}
	tmp=-1;
	for(int i=0;i<n;i++) cin>>c[i];
	for(int i=n-1;i>=0;i--){
		if(tmp!=c[i]){
			tmp=c[i];
			a[i]=c[i];
		}
	}
	vi s(n),t(n);
	for(int i=0;i<n;i++) s[i]=max(((!i)?s[i]:s[i-1]),a[i]);
	for(int i=n-1;i>=0;i--) t[i]=max(((i==n-1)?t[i]:t[i+1]),a[i]);
	if(b!=s||c!=t){
		cout<<0<<endl;
		return 0;
	}
	ll ans=1;
	for(int i=0;i<n;i++){
		if(!a[i]){
			ans=(ans*min(b[i],c[i]))%mod;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2176
import numpy as np

A,B,H,M=list(map(int,input().split()))

short_angle = 360*(1-(H+M/60)/12)
long_angle = 360*(1-M/60)

angle=abs(short_angle-long_angle)

if angle > 180:
    angle =360-angle
    
# print(angle)

ans_2=A**2+B**2-2*A*B*np.cos(np.pi*angle/180)
ans=np.sqrt(ans_2)

print(ans)

Measured memory_bytes: 27212
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    double N; cin >> N;
    if(floor(ceil(N/1.08)*1.08)!=N) cout << ":(" << endl;
    else cout << (int)ceil(N/1.08) << endl; 
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a>b){
     swap (a,b);
    }
    if (b>c){
     swap (b,c);
    }
    if (a>b){
     swap (a,b);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


int memo[50][101010];
int K;
int f(int rest,int mo){
	if (rest < 0)return 0;
	if (memo[rest][mo] != -1) {
		if (memo[rest][mo] == 0 || memo[rest][mo] == 1)return memo[rest][mo];
		else return 0;
	}
	if (rest == 0 && mo == 0)return 1;

	int fl = 0;
	memo[rest][mo] = 2;
	for (int i = 0; i <= 9; i++)if (f(rest - i, (10 * mo + i) % K))fl = 1;
	return memo[rest][mo] = fl;
}

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

	cin >> K;

	int ketawamax = 0;
	int k = K;
	while (k > 0) {
		ketawamax += k;
		k /= 10;
	}

	for (int i = 1; i <= ketawamax; i++) {
		memset(memo,-1,sizeof(memo));
		if (f(i,0)) {
			puts(i);
			break;
		}
	}

	return 0;
}


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

int N;
string S, T;


int main(){
  cin >> N;
  cin >> S >> T;

  string ST[2*N];
  for(int i = 0; i < N; i++){
    cout << S[i];
    cout << T[i];
  }

  cout << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <functional>
#include <utility>

using namespace std;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pli;

int n,m;
vector<pii> adj[100001];
lli l[100001],r[100001],cost[100001];
int vis[100001],depth[100001];
int f=1;
lli c=-1;

void dfs(int cur,int p,lli sum,int d) {
	vis[cur]=1;
	depth[cur] = d;
	cost[cur] = sum;
	for(auto &it:adj[cur]) {
		if(!vis[it.second]) dfs(it.second, cur, sum+(d%2==1 ? -it.first : it.first),d+1);
	}
	for(auto &it:adj[cur]) {
		if(it.second!=p && depth[it.second]<d) {
			if((d-depth[it.second])%2==1) {
				lli val = sum-cost[it.second];
				if(d%2==0) val=-val;
				if(it.first != val) f=0;
				else {
					l[it.second] = max(l[it.second],it.first-r[cur]);
					r[it.second] = min(r[it.second],it.first-l[cur]);
				}
			} else {
				lli val=sum-cost[it.second];
				if(d%2==0) val=-val;
				if(it.first+sum-cost[it.second]<=0 || (it.first + val)%2!=0) f=0;
				else {
					l[it.second] = max(l[it.second],it.first-(it.first+val)/2);
					r[it.second] = min(r[it.second],it.first-(it.first+val)/2);
					l[cur] = max(l[cur], (it.first+val)/2);
					r[cur] = min(r[cur], (it.first+val)/2);
				}
			}
		}
	}
	if(d%2==0) {
		l[1] = max(l[1], sum+l[cur]); r[1] = min(r[1], sum+r[cur]);
	} else {
		l[1] = max(l[1], sum-r[cur]); r[1] = min(r[1], sum-l[cur]);
	}
}

int main() {
	scanf("%d%d",&n,&m);
	for(int i=0,u,v,w;i<m;i++) {
		scanf("%d%d%d",&u,&v,&w);
		adj[u].push_back(pii(w,v));
		adj[v].push_back(pii(w,u));
	}
	
	for(int i=1;i<=n;i++) {
		int mx=1e9;
		for(auto &it:adj[i]) mx = min(mx,it.first-1);
		l[i]=1; r[i]=mx;
	}
	
	vis[1]=1;
	for(auto &it:adj[1]) if(!vis[it.second]) {
		dfs(it.second, 1, it.first, 1);
	}

	if(!f || l[1]>r[1]) puts("0");
	else printf("%lld\n",max(0ll,r[1]-l[1]+1));
	
	return 0;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	V a(N), b(N);  VECCIN(a);  VECCIN(b);
	ll count = 0;
	ll a_sum = 0, b_sum = 0;

	REP(i, N){
		a_sum += a[i], b_sum += b[i];
		if(a[i] <= b[i])  count += (b[i] - a[i] + 1) / 2;
	}

	if(count <= b_sum - a_sum)  cout << "Yes" << endl;
	else                    				cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
	
		int[] parent = new int[n];
		for (int i=0;i<n;i++) {
			parent[i]=i;
		}
		
		for (int i=0;i<m;i++) {
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			sc.nextInt();
			union(parent,x,y);
		}
		
		HashSet<Integer> set = new HashSet<>();
		
		for (int i=0;i<n;i++) {
			set.add(find(parent, i));
		}
		System.out.println(set.size());
	}

	
	static int find(int[] parent, int x) {
		if(parent[x] == x) {
			return x;
		} else {
			parent[x] = find(parent, parent[x]);
			return parent[x];
		}
	}

	static void union(int[] parent, int x, int y) {
		int xRoot = find(parent, x);
		int yRoot = find(parent, y);
		parent[xRoot]=yRoot;
	}
}


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

int main(void){
int H;
int W;
int a;
int i;
int c;

scanf("%d %d",&H,&W);

for(a=1;a>0;a++){
  for(i=1;i<=H;i++){
    for(c=1;c<=W;c++){
      if(i==1){
      printf("#");}
      else{
        if(i==H){
        printf("#");}
        else{
          if(c==1){
          printf("#");}
            else{
            if(c==W){
            printf("#");}
              else{
              printf(".");}}}}}
    printf("\n");}
  scanf("%d %d",&H,&W);
  printf("\n");
  if(H==0 && W==0){
  break;}
}
return 0;
}


Measured memory_bytes: 2044