akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;

struct SegmentTree {

    long long sum[1 << 18];
    long long lazy[1 << 18];
    int size;

    void init(int size) {
        this->size = 1 << (int)ceil(log2(size));
    }

    void propagate(int k) {
        if (lazy[k]) {
            sum[k] += lazy[k];
            if (k < size - 1) {
                lazy[k * 2 + 1] += lazy[k] / 2;
                lazy[k * 2 + 2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, int v, int k, int l, int r) {
        if (b <= l || r <= a) {
            propagate(k);
            return;
        }
        if (a <= l && r <= b) {
            lazy[k] += v * (r - l);
            propagate(k);
            return;
        }
        propagate(k);
        add(a, b, v, k * 2 + 1, l, (l + r) / 2);
        add(a, b, v, k * 2 + 2, (l + r) / 2, r);
        sum[k] = sum[k * 2 + 1] + sum[k * 2 + 2];
    }

    void add(int a, int b, int v) {
        add(a, b, v, 0, 0, size);
    }

    long long get(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return 0;
        }
        if (a <= l && r <= b) {
            propagate(k);
            return sum[k];
        }
        propagate(k);
        long long vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
        return vl + vr;
    }

    long long get(int a, int b) {
        return get(a, b, 0, 0, size);
    }
} st;

int main() {
    int n, q;
    cin >> n >> q;
    st.init(n);
    while (q--) {
        int i, s, t, x;
        cin >> i >> s >> t;
        --s;
        if (i) {
            cout << st.get(s, t) << endl;
        } else {
            cin >> x;
            st.add(s, t, x);
        }
    }
    return 0;
}

Measured memory_bytes: 6408
import sys
import math
n= int(input())
As = list(map(int, input().split()))
m = 1000
kab=0
for i in range(n-1):
    if As[i]<As[i+1]:
        kab+= math.floor(m/As[i])
        m=m%As[i]
        m=m+As[i+1]*kab
        kab=0
print(m)

Measured memory_bytes: 9176
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
	double  a, b, c, ans = 0, x, kaku;
	string s;
	cin >> a >> b >> x;
	double taiseki = a*a*b;
	if (taiseki / 2 <= x) {
		double unchi = taiseki - x;
		double t = unchi * 2 / a / a;
		kaku = (atan(t / a)>0 ? atan(t / a) : -1 * atan(t / a));
		kaku = kaku * 180 / PI;
	}
	else
	{
		double unchi = x;
		double t = unchi * 2 / a / b;
		kaku = (atan(t / b)>0 ? atan(t / b) : -1 * atan(t / b));
		kaku = kaku * 180 / PI;
		kaku = 90 - kaku;
	}
	cout.precision(15);
	cout << kaku;
}


Measured memory_bytes: 256
#ABC113-D Number of Amidakuji
"""
問題：
W本長さHの棒に任意に横線を引く時に、
1からスタートしてkにたどり着くあみだくじの通り数を求めよ
ただし、横線には以下の制約がある
同じ高さに何本引いても良いが、その端点が隣接してはいけない
同じ高さ同士にしか引けない
隣り合う棒にしか引けない
解法：
dpを用いて解く。
dp[i][j]:高さiの状態にいる時の、棒jにたどり着く通り数
dp[i+1][j-1],dp[i+1][j],dp[i+1][j+1]の三通りの遷移について、
(これは横線は必ず端点を共有しないことから言える)
それぞれあり得る通り数を全探索して足していった結果が答え。
最終的にd[h][k]が答え
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
mod = 10**9+7
h,w,g = map(int,readline().split())

dp = [[0]*w for _ in range(h+1)]
dp[0][0] = 1

def func(x):
    if x <= 0:
        return 1
    return func(x-2) + func(x-1)

for i in range(h):
    for j in range(w):
        for k in range(-1,2): #左下、直下、右下
            if not 0 <= j + k < w:
                continue
            #func:右側,左側の自由な状態の棒間の数を入れてやる
            if k == -1:
                l = max(0,j-2)
                r = max(0,w-1-(j+1))
            elif k == 0:
                l = max(0,j-1)
                r = max(0,w-1-(j+1))
            else:
                l = max(0,j-1)
                r = max(0,w-1-(j+2))
            dp[i+1][j+k] += dp[i][j]*func(l)*func(r)
            dp[i+1][j+k] %= mod


print(dp[h][g-1])

Measured memory_bytes: 46188
import sys
import numpy as np

line = sys.stdin.readline
N = int(line())
h = np.fromstring(line(), dtype=np.int64, sep=' ')
costs = np.zeros(N, dtype=np.int64)
costs[N - 1] = 0
costs[N - 2] = abs(h[N - 1] - h[N - 2])
for i in range(N - 3, -1, -1):
    costs[i] = min(costs[i + 1] + abs(h[i + 1] - h[i]), costs[i + 2] + abs(h[i + 2] - h[i]))
print(costs[0])


Measured memory_bytes: 14432
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
class mod_comb3:
    def __init__(self,mod=10**9+7,n_max=1):
        self.mod,self.n_max=mod,n_max
        self.fact,self.inv,self.factinv=[1,1],[0,1],[1,1]
        if 1<n_max:setup_table(n_max)
    def comb(self,n,r):
        if r<0 or n<r:return 0
        if self.n_max<n:self.setup_table(n)
        return self.fact[n]*(self.factinv[r]*self.factinv[n-r]%self.mod)%self.mod
    def setup_table(self,t):
        for i in range(self.n_max+1,t+1):
            self.fact.append(self.fact[-1]*i%self.mod)
            self.inv.append(-self.inv[self.mod%i]*(self.mod//i)%self.mod)
            self.factinv.append(self.factinv[-1]*self.inv[-1]%self.mod)
        self.n_max=t
def main():
    n,k=map(int,input().split())
    mod=10**9+7
    m=mod_comb3()
    for i in range(1,k+1):
        print(m.comb(n-k+1,i)*m.comb(k-1,i-1)%mod) 
if __name__=='__main__':
    main()

Measured memory_bytes: 42608
#include<iostream>
using namespace std;
int main(){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  if(x-r<0||x+r>w||y-r<0||y+r>h){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  string S, T;
  cin >> S >> T;
  if (S == T.substr(0, T.size() - 1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define ifr(a, value) insert(a.begin(), value)
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define str string
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(a, it) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)        // use fill() for value other than 0 //
#define rtn return 
#define clk fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define inf 1LL<<61
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }   // no need to swap a, b, it auto. happens after first call //
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k & 1) cout << b-a;
    else cout << a-b;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[200010];
int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		if(x==1||x==n){
			a[y]++;
		}
		else if(y==1||y==n){
			a[x]++;
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]==2){
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	return 0;
	// your code goes here
	return 0;
}

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

long long int N, a[3];

int main(){
    scanf("%lld", &N);
    a[1] = 1000;
    for(int i = 0; i < N; ++i){
        scanf("%lld", a);
        if(*a < a[1])a[1] = *a;
        if(*a > a[2])a[2] = *a;
    }
    cout << a[2] - a[1] << endl;
    return 0;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))

def main():
    if n == 0:
        print(x)
        return

    ans_l = list(range(-100, 201))

    diff_l = list(set(p) ^ set(ans_l))
    diff_l.sort()

    cnt = 100
    ans = 100
    for i in range(0, len(diff_l)):
        check = abs(diff_l[i]-x)
        if check < cnt:
            cnt = check
            ans = diff_l[i]
    print(ans)
    return

main()

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 t;
    cin >> t;

    for (i64 i = 0; i < t; i++) {
        i64 n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        vector<p64> div { { 2, a }, { 3, b }, { 5, c } };

        map<i64, i64> costs { { 0, INF } };
        priority_queue<p64, vector<p64>, greater<>> pq;
        pq.emplace(0, n);

        while (!pq.empty()) {
            i64 cost, remain;
            tie(cost, remain) = pq.top(); pq.pop();

            if (costs.find(remain) != costs.end() && costs[remain] < cost) continue;

            if (costs[0] / d == cost / d + remain) {
                costs[0] = min(costs[0], cost + remain * d);
            } else if (costs[0] / d > cost / d + remain) {
                costs[0] = cost + remain * d;
            }

            for (auto& p : div) {
                i64 e, x;
                tie(e, x) = p;
                i64 tmp = remain % e;
                i64 up = (remain + e - tmp) / e, down = (remain - tmp) / e;
                i64 upcost = cost + (e - tmp) * d + x, downcost = cost + tmp * d + x;
                if (costs.find(up) == costs.end() || costs[up] > upcost) {
                    pq.emplace(costs[up] = upcost, up);
                }
                if (costs.find(down) == costs.end() || costs[down] > downcost) {
                    pq.emplace(costs[down] = downcost, down);
                }
            }
        }

        cout << costs[0] << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 4944
#!/usr/bin/env python3
n, m = map(int, input().split())
li = [0] * (n + 1)
for _ in range(m):
    l, r = map(lambda x: int(x) - 1, input().split())
    li[0] += 1
    li[l] -= 1
    li[r + 1] += 1
    li[n] -= 1
for i in range(n):
    li[i + 1] += li[i]
print(sum(x <= 0 for x in li[:-1]))


Measured memory_bytes: 7668
#include <iostream>
#include <string>

using namespace std;

int main() {
    string cards;
    int32_t m, h;

    while (cin >> cards, cards != "-") {
        cin >> m;

        for (int32_t i = 0; i < m; i++) {
            cin >> h;
            cards = cards.substr(h, cards.length()) + cards.substr(0, h);
        }

        cout << cards << endl;
    }

    return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,L,x[200010],ans=0,suml[200010],sumr[200010];
int calc(){
    int res=0;
    suml[0]=sumr[0]=0;
    rep(i,n){
        suml[i+1]=suml[i]+x[i];
        sumr[i+1]=sumr[i]+(L-x[n-i-1]);
    }
    rep(i,n){
        int r=(n-i+1)/2,l=n-i-r;
        int sum=2*(suml[i+r]-suml[i])+2*sumr[l];
        if(l==r)sum-=L-x[n-l];
        else sum-=x[i+r-1];
        chmax(res,sum);
    }
    return res;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>L>>n;
    rep(i,n)cin>>x[i];
    chmax(ans,calc());
    rep(i,n)x[i]=L-x[i];
    reverse(x,x+n);
    chmax(ans,calc());
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8332
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

ll dp1[55][55][3000];

void mainmain(){
	int n;
	cin>>n;
	int a;
	cin>>a;
	vint v(n);
	rep(i,n){
		cin>>v[i];
	}
	sort(ALL(v));
	dp1[0][0][0] = 1;
	dp1[0][1][v[0]] = 1;
	rep(i,n-1){
		rep(j,n){
			rep(k,3000){
				dp1[i+1][j+1][k+v[i+1]] += dp1[i][j][k];
				dp1[i+1][j][k] += dp1[i][j][k];
			}
		}
	}
	ll ans = 0;
	rep(i,n+1){
		rep(j,3000){
			if(i==j && i==0) continue;
			if(1LL*a*i == j){
				ans += dp1[n-1][i][j];
			}
		}
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 59008
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

ll a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    int t=1,te=0;
    // cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;

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

        sort(a+1,a+n+1);
        ll s=0;
        for(int i=1;i<=max(n-k,0);++i){
            s+=a[i];
        }

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


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000


int main() {
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	long long ans = 0;
	
	map<char,long long> mp;
	
	for(int i=0;i<N;i++)mp[S[i]]++;
	
	ans = mp['R']*mp['G']*mp['B'];
	
	for(int i=0;i<N;i++){
		for(int j=0;true;j++){
			int x = i-j;
			int y = i+j;
			if(x<0||y>=N)break;
			if(S[i]!=S[x]&&S[x]!=S[y]&&S[y]!=S[i])ans--;
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 3632
#include <atcoder/fenwicktree>
#include <cstdio>
using namespace std;
using namespace atcoder;

int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	
	fenwick_tree<long long> fw(n);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		fw.add(i, a);
	}
	
	for (int i = 0; i < q; i++) {
		int t;
		scanf("%d", &t);
		if (t == 0) {
			int p, x;
			scanf("%d%d", &p, &x);
			fw.add(p, x);
		}
		else {
			int l, r;
			scanf("%d%d", &l, &r);
			printf("%lld\n", fw.sum(l, r));
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
	cin.sync_with_stdio(false);
	char a, b;
	cin >> a >> b;
	//atcodeer is honest.
	if (a == 'H') {
		cout << b << endl;
	}
	//atcodeer is dishonest.
	else {
		if (b == 'H') {
			cout << 'D' << endl;
		}
		else {
			cout << 'H' << endl;
		}
	}
	return 0;
}

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

int main(){
  ll N,K; cin >> N >> K;
  if(N > K){
    rep(i,N){
      cout << K;
    }
  }
  else{
    rep(i,K){
      cout << N;
    }
  }
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;

int main()
{
	li n,i,c=0,ans=0;
	cin>>n;
	li a[n];
	F cin>>a[i];
	fo(i,0,n-1)
	{
		if(a[i]>=a[i+1])
		c++;
		else
		{
			ans=max(c,ans),c=0;
		}
	}
	ans=max(c,ans);
	cout<<ans;
}

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

int n,d, c = 0;
std::vector<std::vector<long double>> vec;
long double ans;

int main() {
    std::cin >> n >> d;
    vec.assign(n, std::vector<long double>(d, 0));
    for (int i = 0; i < n; i++) {
        for (int p = 0; p < d; p++) {
            std::cin >> vec[i][p];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            if (i == k) {
                continue;
            }
            long double res = 0;
            for (int j = 0; j < d; j++) {
                res += std::pow(vec[i][j] - vec[k][j], 2);
            }
            ans = std::sqrt(res);
            if (ans == (int)ans) {
                c++;
            }

        }
    }
    std::cout << c/2 << std::endl;
}


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


int main () {
    vector<string> vec = {"MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"} ;
    string s;
    cin >> s;
    int ans ;
    rep(i, 7){
        if( s == vec[i]){
            ans = 7 - i - 1;
        }
        if (ans == 0){
            ans = 7;
        }
    }
    cout << ans << endl; 

}


Measured memory_bytes: 256
"use strict";

function Main(input) {
	input = input.split("\n");
    const n = parseInt(input[0].split(" ")[0], 10);

    const allLike = {};
    for (let i = 1; i <= n; i++) {
        const a = input[i].split(" ");
        const k = parseInt(a[0], 10);

        for (let j = 1; j <= k; j++) {
            if (a[j] in allLike) {
                allLike[a[j]]++;
            } else {
                allLike[a[j]] = 1;
            }
        }
    }

    let answer = 0;
    for (let k in allLike) {
        if (allLike[k] === n) answer++;
    }
    console.log(answer);
}

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


Measured memory_bytes: 7500
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        String R = "";
        
        for(int i=0;i<N;i++) {
        	R =R+ S.charAt(i) + T.charAt(i);
        }

        System.out.println(R);   
        

    }
}



Measured memory_bytes: 25428
#include<bits/stdc++.h>
using namespace std;
long long n,ans,S,s,w[100002],v[100002],dp[102][100002];
int main(){
cin>>n>>s;
for(int k=1;k<=n;k++){
    cin>>w[k]>>v[k];
    S+=v[k];
    }
    int ans=0;
    if(w[1]<=s)
        ans=v[1];
    for(int k=1;k<=n;k++)
        for(int i=1;i<=S;i++)
        dp[k][i]=INT_MAX;

        dp[1][v[1]]=w[1];


for(int k=2;k<=n;k++){
for(int i=0;i<=S;i++){
        if(i==0)
        continue;
   dp[k][i]=dp[k-1][i];
   // if(v[k]!=i)
       // continue;

    long long t=dp[k-1][i-v[k]];
    dp[k][i]=min(dp[k-1][i],t+w[k]);
    if(dp[k][i]<=s)
        ans=max(ans,i);
}
}
cout<<ans;
return 0;
}


Measured memory_bytes: 79360
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();
		int c = a*b;
		int d = 2*a + 2*b;
		System.out.println(c + " " + d);


	}
}



Measured memory_bytes: 26180
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


public class Main {

    static int res(String ss, String t) {
        int cnt = 0;
        for(int i=0;i<ss.length();i++) {
            if(ss.charAt(i) != t.charAt(i)) {
                cnt++;
            }
        }
        return cnt;
    }


    static void solve() {
        Scanner scan = new Scanner(System.in);

        String s = scan.next();
        String t = scan.next();
        int min = t.length();
        for(int i = 0; i + t.length() <= s.length(); i++) {
            String ss = s.substring(i, i+t.length());
            int cnt = res(ss, t);
            min = Math.min(cnt, min);
        }
        System.out.println(min);

//        int t = scan.nextInt();
//        for (int i = 0; i < t; i++) {
////            solveCase();
//        }


//        long t = scan.nextLong();

//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
////            scase(n);
//        }
    }


    static void solveCase(int zero1, int one1, int two1, int zero2, int one2, int two2) {

    }

    static void scase(int[] arr1, int[] arr2) {
    }


    public static void main(String[] args) {

        solve();
    }


    static class LoggerNode {
        String message;
        int ts;
    }


    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }
}

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

int main(void) {
    int k;
    string s;
    cin >> k >> s;
    if (s.length() < k+1) {
        cout << s << endl;
    } else {
        for (int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let n: usize = get_vec_input()[0];
    let x: Vec<f64> = get_vec_input();
    let y: Vec<f64> = get_vec_input();
    for p in 1..3 + 1 {
        let result = (0..n)
            .map(|i| (x[i] - y[i]).abs())
            .map(|x| x.powf(p as f64))
            .fold(0.0, |a, b| a + b);
        println!("{}", (result as f64).powf(1.0 / p as f64));
    }
    let result = (0..n).map(|i| (x[i] as i64 - y[i] as i64).abs()).max();
    println!("{}", result.unwrap());
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}



Measured memory_bytes: 5212
h,w=gets.split.map(&:to_i)
ss=[]
h.times do
  ss << gets.chomp.chars
end
m=2
h.times do |hi|
  w.times do |wj|
    next if ss[hi][wj]=="#"
    s=[]
    h.times do |ii|
      s << ss[ii].dup
    end
    q=[[hi,wj]]
    s[hi][wj]=0
    k=1
    while q!=[]
      z=[]
      q.each do |i,j|
        if i>0&&s[i-1][j]=="."
          z << [i-1,j]
          s[i-1][j]=k
        end
        if j>0&&s[i][j-1]=="."
          z << [i,j-1]
          s[i][j-1]=k
        end
        if i<h-1&&s[i+1][j]=="."
          z << [i+1,j]
          s[i+1][j]=k
        end
        if j<w-1&&s[i][j+1]=="."
          z << [i,j+1]
          s[i][j+1]=k
        end
      end
      q=z.dup
      k+=1
    end
    m=k if m<k
  end
end
puts m-2


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int a[100005];
int res[100005];
vector<P1> v;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>a[i];
        v.PB(P1(a[i],i));
    }
    sort(v.begin(),v.end(),greater<P1>());
    v.PB(P1(0,N));
    int min_y=INF;
    for(int i=0;i<N;++i){
        int y = v[i].second;
        if(min_y>y)min_y=y;
        res[min_y] +=(v[i].first-v[i+1].first)*(i+1);
    }
    for(int i=0;i<N;++i)cout<<res[i]<<endl;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

class WarshallFloyd{
    public:
        vector<vector<int>> d;
        WarshallFloyd(vector<vector<int>> g) : d(g){
            int V=g.size();
            for(int i=0;i<V;i++) d[i][i]=0;

            for(int k=0;k<V;k++)
                for(int i=0;i<V;i++)
                    for(int j=0;j<V;j++)
                        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }

        int get(int i,int j){
            return d[i][j];
        }
};

void solve(int n,int m,int s,int g1,int g2){
    s--;
    g1--;
    g2--;
    vector<vector<int>> g(n,vector<int>(n,INF));
    rep(i,m){
        int b1,b2,c;
        cin>>b1>>b2>>c;
        b1--;
        b2--;
        g[b1][b2]=c;
    }

    WarshallFloyd wf(g);
    int ans = INF;
    for(int i=0;i<n;i++){
        int cost = wf.get(s,i) + wf.get(i,g1) + wf.get(i,g2);
        ans = min(ans,cost);
    }
    cout << ans << endl;
}

int main(){
    int n,m,s,g1,g2;
    while(cin>>n>>m>>s>>g1>>g2){
        if(n==0 and m==0 and s==0 and g1==0 and g2==0) break;
        solve(n,m,s,g1,g2);
    }
}

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace  std;

struct StCst
{
  int m_nNo;
  int m_nInSeq;
  bool m_bDone;

  static bool AsdNo(const StCst& roLeft, const StCst& roRight) { return roLeft.m_nNo < roRight.m_nNo; }
};

void fnInput(int &rnMaxSiz, vector<StCst> &rvoSort, int &rnMinNo)
{
  int nCnt = 0;
  cin >> rnMaxSiz;

  rvoSort.resize(rnMaxSiz);
  for (int i = 0; i < rnMaxSiz; i++)
  {
    cin >> rvoSort[i].m_nNo;
    rnMinNo = min(rnMinNo, rvoSort[i].m_nNo);
    rvoSort[i].m_nInSeq = nCnt++;
  }
}

void fnMinCostSort(vector<StCst> &rvoSort, int nMinNo, int &rnSwpCnt)
{
  sort(begin(rvoSort), end(rvoSort), StCst::AsdNo);

  int nCost;
  for (int i = 0; i < rvoSort.size(); i++)
  {
    if (rvoSort[i].m_bDone)  continue;

    int nTotal = rvoSort[i].m_nNo;
    int nCurSize = 1;
    int nCurMin = rvoSort[i].m_nNo; 
    rvoSort[i].m_bDone = true;

    int j = rvoSort[i].m_nInSeq;
    while  (rvoSort[j].m_nInSeq != rvoSort[i].m_nInSeq)
    {
      nTotal += rvoSort[j].m_nNo;
      nCurSize++;
      nCurMin = min(nCurMin, rvoSort[j].m_nNo);
      rvoSort[j].m_bDone = true;
      j = rvoSort[j].m_nInSeq;
    }

    if (nCurSize == 1)
        nCost = 0;
    else
      if (nMinNo == nCurMin)
        nCost = nTotal + (nCurSize - 2) * nCurMin;
      else
        nCost = min(nTotal + (nCurSize - 2) * nCurMin, 
                    nTotal + nCurMin + (nCurSize + 1) * nMinNo);
    rnSwpCnt += nCost;
  }
}

void fnResult(int nSwpCnt)
{
  cout << nSwpCnt << endl;
}

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

  int nMaxSiz;
  vector<StCst> voSort;
  int nMinNo = INT_MAX;

  fnInput(nMaxSiz, voSort, nMinNo);

  int nSwpCnt = 0;
  fnMinCostSort(voSort, nMinNo, nSwpCnt);

  fnResult(nSwpCnt);
  return 0;
}

Measured memory_bytes: 1228
from time import time
import random


def main():
    random.seed(0)

    now = time()

    MAX = 26

    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]
    t = []
    for row in s:
        mxi = 1
        mx = 0
        for i, e in enumerate(row, 1):
            if e > mx:
                mx = e
                mxi = i

        t.append(mxi)

    last = [0] * MAX

    score = 0
    for day, e in enumerate(t, 1):
        score += s[day-1][e-1]
        last[e-1] = day

        for ec, elast in zip(c, last):
            score -= ec * (day - elast)

    d_li = []
    for i in range(1, d + 1):
        ln = (-(i - d // 2) ** 2 + d ** 2 // 4) // 500
        d_li += [i] * ln

    di_max = len(d_li) - 1

    c_sum = sum(c)
    c_li = []
    for i, e in enumerate(c, 1):
        c_li += [i] * e

    while time() - now <= 1.85:
        prev_score = score

        di = random.randint(0, di_max)
        ed = d_li[di]
        qi = random.randint(0, c_sum - 1)
        eq = c_li[qi]

        q_old = t[ed-1]
        d_prev = {q_old: 0, eq: 0}

        c_old = c[q_old-1]
        c_new = c[eq-1]

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

        score += c_old * (day - d_prev[q_old])
        score += c_new * (day - d_prev[eq])

        score -= s[ed-1][q_old-1]
        score += s[ed-1][eq-1]

        t[ed-1] = eq

        d_prev = {q_old: 0, eq: 0}

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score -= c_old * (day - d_prev[q_old])
            score -= c_new * (day - d_prev[eq])

        if prev_score > score:
            t[ed-1] = q_old
            score = prev_score

    print(*t, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 80708
#include <stdio.h>

int main (){
	int baris,kolom,warna,x;
	
	scanf ("%d",&baris);
	scanf ("%d",&kolom);
	scanf ("%d",&warna);
	
	if (baris > kolom){
        x = (warna - 1)/baris +1;
    }
    else {
        x = (warna - 1)/kolom +1;
    }
    
	printf ("%d",x);
	
	return 0;
}

Measured memory_bytes: 3232
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

ll N, M;
const ll SIZE = 5000005;
ll c[SIZE];
ll A[SIZE];
ll Next[SIZE];
ll res[5000005];
ll show[5000005];
bool fir[SIZE];


struct Q
{
    ll l, r;
    ll pos;
}q[5000005];


ll lowbit(ll k)
{
    return k & (-k);
}


void modify(ll n, ll v)
{
    while (n <= N)
    {
        c[n] += v;
        n += lowbit(n);
    }
}


ll sum(ll n)
{
    ll ans = 0;
    while (n > 0)
    {
        ans += c[n];
        n -= lowbit(n);
    }
    return ans;
}


ll cmp(Q a, Q b)
{
    return a.l < b.l;
}


int main()
{
    cin >> N >> M;
    for (ll i = 1;i <= N;i++) cin>>A[i];
    for (ll i = N;i >= 1;i--)
    {
        if (!show[A[i]])
        {
            show[A[i]] = i;
            fir[i] = true;
        }
        else
        {
            Next[i] = show[A[i]];
            fir[Next[i]] = false;
            fir[i] = true;
            show[A[i]] = i;
        }
    }
    for (ll i = 1;i <= M;i++)
    {
        cin >> q[i].l >> q[i].r;
        q[i].pos = i;
    }
    sort(q + 1, q + 1 + M, cmp);


    for (ll i = 1;i <= N;i++)
        if (fir[i])
        {
            modify(i, 1);
        }
    ll qtemp = q[1].l;
    ll ptr = 1;
    for (ll i = 1;i <= M;i++)
    {
        for (;ptr < q[i].l;ptr++)
        {
            if (fir[ptr])
            {
                modify(ptr, -1);
                fir[ptr] = false;
                if (Next[ptr])
                {
                    fir[Next[ptr]] = true;
                    modify(Next[ptr], 1);
                }
            }
        }
        ptr = q[i].l;
        qtemp = q[i].l;
        res[q[i].pos] = sum(q[i].r) - sum(q[i].l - 1);
    }
    for (ll i = 1;i <= M;i++) printf("%lld\n", res[i]);
    return 0;
}


Measured memory_bytes: 34516
#include<stdio.h>

int BubbleSort(int A[],int N){
  int i,j,count=0,tmp;
  
  for(i = 0 ; i < N-1 ; i++){
    for(j = N-1 ; j >= 1 ; j--){
      if(A[j] < A[j - 1]){
	tmp = A[j];
	A[j] = A[j - 1];
	A[j - 1] = tmp;
	count++;
      }
    }
  }
  return count;
}


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

  scanf("%d",&N);
  
  int A[N];

  for(i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
  }
  
  count = BubbleSort(A,N);

  printf("%d",A[0]);
  for(i = 1 ; i < N ; i++){
    printf(" %d",A[i]);
  }
  
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2140
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

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

    public static void main(String[] args) {
        long A = in.nextLong();
        BigDecimal B = in.nextBigDecimal();
        B = B.multiply(BigDecimal.valueOf(100));
        long BB = B.longValue();
        out.println(A * BB / 100);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  vector<llint> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n % 2) {
    llint l = a[n / 2];
    llint r = b[n / 2];
    cout << r - l + 1 << endl;

  } else {
    llint ans = 0;
    if ((a[n / 2 - 1] + a[n / 2]) % 2) {
      ans--;
    }
    if ((b[n / 2 - 1] + b[n / 2]) % 2) {
      ans++;
    }
    llint l = (a[n / 2 - 1] + a[n / 2]) / 2;
    llint r = (b[n / 2 - 1] + b[n / 2]) / 2;
    ans += r - l + 1;
    ans += r - l;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 6372
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>

using namespace std;

int main()
{
    std::string s, t;
    std::cin >> s >> t;
    std::cout << t << s;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int ans1 = 0;
		for (int i = 0; i < 4; i++)
			ans1 += scanner.nextInt();
		int ans2 = 0;
		for (int i = 0; i < 4; i++)
			ans2 += scanner.nextInt();
		System.out.println(Math.max(ans1, ans2));
	}
}

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

const int mod=1e9+7;
int dp[44][1<<18];


int main()
{
    int n,x,y,z; cin>>n>>x>>y>>z;
    int sum=x+y+z;
    int pre1=z;
    int pre2=z+y;
    int pre3=sum;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=10;j++)
        {
            for(int pop_mask=0;pop_mask<(1<<(sum+1));pop_mask++)
            {
                int akt_mask=(pop_mask<<j);
                akt_mask|=(1<<j);
                akt_mask&=((1<<(sum+1))-1);
                if(akt_mask&(1<<pre1) && akt_mask&(1<<pre2) && akt_mask&(1<<pre3))
                {
                    continue;
                }
                else
                {
                    dp[i][akt_mask]+=dp[i-1][pop_mask];
                    if(dp[i][akt_mask]>=mod) dp[i][akt_mask]-=mod;
                }
            }
        }
    }
    ll ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=10;
        ans%=mod;
    }
    for(int i=0;i<(1<<(sum+1));i++)
    {
        ans-=dp[n][i];
        if(ans<0) ans+=mod;
    }
    cout<<ans;
    return 0;
}


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


typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair
#define mt make_tuple
#define fi
#define se second

#define forz(i,n) for(long long int i=0;i<n;i++)

#define forl(i, n) for(int i = 1; i< n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

using namespace std;


int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w" , stdout);
// #endif
	lli n;

	cin >> n;
	lli dp[n + 2] = { -1};
	// cout << n;
	std::vector<int> v(n, 0);
	forz(i, n)
	{
		cin >> v[i];
	}
	// cout << dp[n - 1] << endl;
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);
	for (int i = 2; i < n; i++)
	{

		dp[i] = min((dp[i - 1] + abs(v[i] - v[i - 1])), (dp[i - 2] + abs(v[i] - v[i - 2])));
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1408
s = int(input())
li = []
i = 1

while True:
    li.append(s)

    if s % 2 == 0:
        s = s / 2
    elif s % 2 != 0:
        s = 3 * s + 1

    i += 1

    if s in li:
        break

print(i)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
ll arr[mxN];
ll b[mxN];
ll srt[mxN];
int n;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    ll sum = 0;
    owo(i, 0, n) {
        cin>>arr[i];
        sum+=arr[i];
    }
    owo(i, 0, n) {
        cin>>b[i];
        srt[i] = arr[i]-b[i];
        sum-=b[i];
    }
    if(sum<0) {
        cout<<"-1\n";
    }else {
        ll diff = 0;
        int ans = 0;
        owo(i, 0, n) {
            if(arr[i]<b[i]) {
                ans++;
                diff+=b[i]-arr[i];
            }
        }
        sort(srt, srt+n);
        reverse(srt, srt+n);
        owo(i, 0, n) {
            if(diff<=0)break;
            diff-=srt[i];
            ans++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

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

int n, id, k, ch, node;

int main() {
    cin >> n;
    vector<int> v[n];
    int d[n], pa[n], vis[n];
    for (int i=0; i<n; i++) pa[i] = -1;
    for (int i=0; i<n; i++) {
        cin >> id >> k;
        for (int j=0; j<k; j++) {
            cin >> ch;
            v[id].push_back(ch);
            pa[ch] = id;
        }
    }
    for (int i=0; i<n; i++) {
        if (pa[i] == -1) node = i;
    }
    for (int i=0; i<n; i++) d[i] = 0;
    queue <int> q;
    q.push(node);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int tem : v[u]) {
            if (d[tem]) continue;
            d[tem] = d[u] + 1;
            q.push(tem);
        }
    }
    d[node] = 0;
    for (int i=0; i<n; i++) {
        cout << "node " << i << ": parent = " << pa[i] << ", depth = " << d[i] << ", ";
        if (d[i] == 0) cout << "root";
        else {
            if (v[i].empty()) cout << "leaf";
            else cout << "internal node";
        }
        cout << ", [";
        for (int j=0; j<v[i].size(); j++) {
            if (!j) cout << v[i][j];
            else cout << ", " << v[i][j];
        }
        cout << "]" << endl;
    }
}


Measured memory_bytes: 7132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll x=1;
  for(int i=1; i<=7; i++) x*=i;
  int n;
  while(cin>>n&&n) {
    ll ans=0;
    if(n%2) {
      ll dp[n][8];
      memset(dp,0,sizeof(dp));
      dp[0][0]=1;
      for(int i=2; i<n-1; i++) {
        for(int j=7; j>0; j--) {
          for(int k=0; k<i-1; k++) {
            dp[i][j]+=dp[k][j-1];
          }
        }
        ans+=dp[i][7];
      }
    } else {
      ll dp[n/2][8][3];
      memset(dp,0,sizeof(dp));
      dp[0][0][0]=1;
      for(int i=1; i<n/2; i++) {
        for(int j=7; j>=0; j--) {
          if(j<7) {
            dp[i][j+1][0]+=dp[i-1][j][1]+dp[i-1][j][2];
            dp[i][j+1][1]+=dp[i-1][j][0]+dp[i-1][j][2];
          }
          dp[i][j][2]+=dp[i-1][j][0]+dp[i-1][j][1]+dp[i-1][j][2];
        }
        ans+=dp[i][7][0];
        if(i<n/2-1) ans+=dp[i][7][1];
      }
    }
    cout<<ans*n*x<<endl;
  }
  return 0;
}


Measured memory_bytes: 3028
def length(strings):
  N = len(strings)
  dp = [0 for _ in range(N)]
  max_l = [0 for _ in range(N)]
  i = 0
  if strings[i] in ["A", "C", "G", "T"]:
    dp[i] = 1
  else:
    dp[i] = 0 
  max_l[i] = dp[i]
  for i in range(1, N, 1):
    if strings[i] in ["A", "C", "G", "T"]:
      dp[i] = dp[i-1] + 1
    else:
      dp[i] = 0
    max_l[i] = max(max_l[i-1], dp[i])
    
  return max_l[N-1]

if __name__ == "__main__":
  string = input()
  print(length(string))

Measured memory_bytes: 3064