akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   

int main(){
 lint N,s;
 cin>>N;
s=N;
s/=11;

if(N%11==0&&s!=0)cout<<s*2;
else if(N-s*11>6)cout<<s*2+2;
else cout<<s*2+1;
}

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

const int nlimit = 40;
const int alimit = 10, blimit = 10;
const int inf = 1e7;

int main(){
  int n, ma, mb; cin >> n >> ma >> mb;
  int a[n], b[n], c[n];
  for(int i=0; i<n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }

  int dp[n+1][nlimit*alimit+1][nlimit*blimit+1];
  for(int i=0; i<=n; i++){
    for(int j=0; j<=nlimit*alimit; j++){
      for(int k=0; k<=nlimit*blimit; k++){
        dp[i][j][k] = inf;
      }
    }
  }
  dp[0][0][0] = 0;

  for(int i=0; i<n; i++){
    for(int j=0; j<=nlimit*alimit; j++){
      for(int k=0; k<=nlimit*blimit; k++){
        if(j < a[i] || k < b[i]) dp[i+1][j][k] = dp[i][j][k];
        else dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a[i]][k-b[i]]+c[i]);
      }
    }
  }

  int ans = inf;
  for(int j=1; j<=nlimit*alimit; j++){
    for(int k=1; k<=nlimit*blimit; k++){
      if(j/ma == k/mb && j%ma==0 && k%mb==0) ans = min(ans, dp[n][j][k]);
    }
  }

  cout << (ans==inf? -1: ans) << endl;

  return 0;
}


Measured memory_bytes: 25984
#include <stdio.h>
#include <set>
#define ll long long
using namespace std;
int fu[200010];
int getv(int x)
{
	if(x==fu[x])
		return x;
	return fu[x]=getv(fu[x]);
}
int fa[200010];
struct SPx
{
	int u,s0,s1;
	SPx(){}
	SPx(int S0,int S1,int U)
	{
		s0=S0;s1=S1;u=U;
	}
};
SPx operator+(SPx a,SPx b)
{
	return SPx(a.s0+b.s0,a.s1+b.s1,a.u);
}
bool operator<(const SPx &a,const SPx &b)
{
	ll x=1ll*a.s0*b.s1,y=1ll*b.s0*a.s1;
	if(x==y)
		return a.u<b.u;
	return x>y;
}
set<SPx> pq;SPx sz[200010];
int main()
{
	int n;ll ans=0;
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		fa[i]=a;
	}
	for(int i=1;i<=n;i++)
	{
		int a;fu[i]=i;
		scanf("%d",&a);
		sz[i].u=i;
		if(a==0)sz[i].s0+=1;
		else sz[i].s1+=1;
		if(i>1)
			pq.insert(sz[i]);
	}
	for(int s=0;s<n-1;s++)
	{
		set<SPx>::iterator tp=pq.begin();
		fflush(stdout);
		int u=tp->u,f=fa[u];
		u=getv(u);f=getv(f);
		fu[u]=f;pq.erase(tp);
		ans+=1ll*sz[f].s1*sz[u].s0;
		if(f>1)pq.erase(pq.find(sz[f]));
		sz[f]=sz[f]+sz[u];
		if(f>1)pq.insert(sz[f]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 19712
from collections import Counter
from bisect import bisect_left


def main():
    N, M = map(int, input().split())
    *A, = map(int, input().split())
    BC = [
        list(map(int, input().split()))
        for _ in range(M)
    ]

    ans = f_replace(N, M, A, BC)
    ans1 = ref(N, M, A, BC)
    assert ans == ans1
    print(ans)


def ref(N, M, A, BC):
    """
    元々のAをBCと混ぜて最大化するようにN個選ぶ
    全体は2 * (10^5) なので、sortを考慮しても問題ない
    """
    counter = Counter(A)
    for b, c in BC:
        counter[c] += b

    ans = 0
    rem = N
    vn = sorted(counter.items(), key=lambda x: -x[0])
    for v, n in vn:
        use = min(n, rem)
        ans += use * v
        rem -= use

    return ans


def f_replace(N, M, A, BC):
    """
    2分探索なんて必要なかった
    順々に変更する要素を見つけ、変える必要がなければ終了
    """
    A = sorted(A)
    BC = sorted(BC, key=lambda x: -x[1])
    i = 0
    for b, c in BC:
        if i >= N:
            break
        for _ in range(b):
            if i >= N:
                break
            elif A[i] < c:
                A[i] = c
                i += 1
            else:
                i = N
                break

    ans = sum(A)
    return ans


def WA_RE(N, M, A, BC):
    """
    A,Cの値: 10^9
        配列用意できない
    A,BCの数: 10^5

    書き換えると順番がバラバラになる
    個数10^5より、実際の種類数は10^5
    2分探索？

    BCに着目
    最大にする書き換え方を検証する
    """

    A = sorted(A)
    min_a = A[0]
    min_pos = 0

    # 小さい値から、大きい値に書き換える
    bc = sorted(BC, key=lambda x: -x[1])
    bc = list(filter(lambda x: x[1] > min_a, bc))
    ans = 0
    for b, c in bc:
        # 入れ替える必要の確認
        # cはだんだん小さくなり、min_aは大きくなるため
        if c < min_a:
            break
        # 二分探索を行えるように最小値の設定
        pos = bisect_left(A, c, lo=min_a)
        # if pos >= N:
        #    break

        # 書き換えすぎないように設定
        pos_to = min(min_pos + b, pos)
        for i in range(min_pos, pos_to):
            # 比較対象はだんだんと右にずれるので、計算量はAの数だけ
            # bだけ書き換えるが、大きい場合は対象外
            if A[i] < c:
                ans += c
            else:
                break

        min_pos = i + 1
        min_a = A[i]

    ans += sum(A[min_pos:])
    return ans


def TLE(N, M, A, BC):
    for b, c in BC:
        A = sorted(A)
        for i in range(b):
            if A[i] < c:
                A[i] = c
            else:
                break

    ans = sum(A)
    return ans


def editorial(N, M, A, BC):
    ans = 0
    return ans


if __name__ == '__main__':
    main()


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

typedef long long int ll;
string s, t;

int main() {
    cin >> s >> t;

    ll ans = t.length();
    for(ll i = 0; i < s.length() - t.length() + 1; ++i) {
        ll cnt = 0;

        for(ll j = 0; j < t.length(); ++j) {
            if(s[i + j] == t[j]) cnt++;
        }

        ans = min(ans, (ll)t.length() - cnt);
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
  while(1){
    int N,count;
    cin >> N;
    count =0;

    if(N==0)break;


    for(int j=1;j<N;j++){
      int sum=0;
    for(int i=j;i<N;i++){

      sum+=i;
      if(sum == N){
        count+=1;
        break;
      }else if(sum > N) {

        break;
      }


    }
    }

    cout <<count <<endl;




  }
}



Measured memory_bytes: 2992
#include <iostream>
using namespace std;
int N;
int mini(int a,int b) {return a<b?a:b;}
void solve()
{
    int K,ans=0;
    cin>>K;
    while(N--)
    {
        int x;
        cin>>x;
        ans+=mini(2*x,2*(K-x));
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>N)
        solve();
}

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

int main()
{
    ll n,x,ans=0,diff;
    cin>>n>>x;
    vector<ll> v(n);
    for(int i=0;i<n;i++)    cin>>v[i];
    if(v[0]>x)
    {
        ans+=v[0]-x;
        v[0]=x;
    }
    for(int i=0;i<v.size()-1;i++)
    {
        if(v[i]+v[i+1]>x)
        {
            diff=v[i+1]+v[i]-x;
            v[i+1]-=diff;
            ans+=diff;
        }
    }
    cout<<ans;
}


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

IL int gi(){
    int data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

int n , K ;

int main() {
	//freopen("testdata.in","r",stdin) ;
	n = gi() ; K = gi() ;
	if((n + 1) / 2 >= K) return puts("YES") , 0 ;
	else return puts("NO") , 0 ; 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}


Measured memory_bytes: 2732
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	string s; cin >> s;
	rep(i,s.size()){
		s[i] = 'x';
	}
	cout << s << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//#include <vector>
//#include <climits>
std::vector<long long> bellman_ford(long long n, long long m, std::vector<std::vector<long long>> &edge, long long start) {
	std::vector<long long> ret(n, LLONG_MAX);
	ret[start] = 0;
	for (long long i = 0; i < n - 1; i++) {
		for (long long j = 0; j < m; j++) {
			long long u = edge[j][0], v = edge[j][1], w = edge[j][2];
			if (ret[u] < LLONG_MAX) ret[v] = std::min(ret[v], ret[u] + w);
		}
	}
	for (long long i = 0; i < m; i++) {
		long long u = edge[i][0], v = edge[i][1], w = edge[i][2];
		if (ret[u] < LLONG_MAX && ret[u] + w < ret[v]) return {};
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m, p;
	cin >> n >> m; p = 0;
	vector<vector<vector<ll>>> v(n, vector<vector<ll>>(0));
	for (ll i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		c -= p; c *= -1;
		v[a].push_back({c, b});
	}

	vector<vector<vector<ll>>> w(n, vector<vector<ll>>(0));
	queue<ll> task;
	task.push(0);
	vector<ll> seen(n, false);
	seen[0] = true;
	while (task.size()) {
		ll x = task.front();
		task.pop();
		for (auto i : v[x]) {
			w[i[1]].push_back({i[0], x});
			if (!seen[i[1]]) {
				task.push(i[1]);
				seen[i[1]] = true;
			}
		}
	}
	vector<vector<ll>> edge(0);
	task.push(n - 1);
	vector<bool> seen2(n, false);
	seen2[n - 1] = true;
	while (task.size()) {
		ll x = task.front();
		task.pop();
		for (auto i : w[x]) {
			edge.push_back({i[1], x, i[0]});
			if (!seen2[i[1]]) {
				task.push(i[1]);
				seen2[i[1]] = true;
			}
		}
	}

	m = edge.size();
	vector<ll> x = bellman_ford(n, m, edge, 0);
	x = bellman_ford(n, m, edge, 0);
	if (x.empty()) cout << "inf" << endl;
	else cout << -x[n - 1] << endl;
}


Measured memory_bytes: 3952
def answer(a)
  num_count = a.each_with_object({}) do |aa, h|
    (-1..1).each do |d|
      h[aa + d] ||= 0
      h[aa + d] += 1
    end
  end
  num_count.values.max
end

gets
p answer(gets.split.map(&:to_i))


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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string t;
  cin>>t;
  if(t[0]=='?' && t[1]!='?'){
    if(t[1]=='D'){
    t[0]='P';
  }else{
    t[0]='D';
  }
  }
  if(t[0]=='?' && t[1]=='?'){
    t[0]='D';
  }

  
  for(int i=1;i<t.length()-1;i++){
    if(t[i]=='?'){
      if(t[i-1]=='P' || (t[i+1]=='P')){
        t[i]='D';
      }else{
        t[i]='P';
      }
    }
  }
  int d=t.length()-1;
  if(t[d]=='?'){
    t[d]='D';
  }
  cout<<t<<endl;

}

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

const int SZ = 2 * 1e5 + 1;

vector<int> parent(SZ, -1);

int root(int x) {
    return parent[x] == -1 ? x : root(parent[x]);
}

void merge(int a, int b) {
    int x = root(a);
    int y = root(b);
    if (x == y) return;
    if (x < y) {
        parent[y] = x;
    } else {
        parent[x] = y;
    }
}

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

    int N, M;
    cin >> N >> M;
    set<pair<int, int>> inp;
    set<int> st;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        inp.emplace(a, b);
        st.insert(a);
        st.insert(b);
    }

    for (const pair<int, int>& p : inp) {
        int a = p.first, b = p.second;
        merge(a, b);
    }

    int ans = 1;
    vector<int> cnt(N + 1, 0);
    for (int f : st) {
        int idx = root(f);
        cnt[idx]++;
        ans = max(ans, cnt[idx]);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 23500
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    TXY = [[0,0,0]]
    for i in range(N):
        tmp = list(map(int,input().split()))
        TXY.append(tmp)
    TXY = sorted(TXY)
    flag = 0
    
    for i in range(N):
        dt = TXY[i+1][0] - TXY[i][0]
        dx = TXY[i+1][1] - TXY[i][1]
        dy = TXY[i+1][2] - TXY[i][2]
        if not (abs(dt)%2 == (abs(dx)+abs(dy))%2 and abs(dt) >= abs(dx)+abs(dy)):
            flag = 1
            break
            
    if flag == 1:
        print("No")
    else:
        print("Yes")

    
    
main()

Measured memory_bytes: 57436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<" "<<#x<<"="<<x

#define bit(k) (1LL<<(k))

typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    int N;
    cin>>N;
    vector<ll> X(N);
    rep(i,N)cin>>X[i];
    ll ans = INFLL;
    rep1(p,101){
        ll sum = 0;
        rep(i,N){
            sum+= (X[i] - p) * (X[i] - p);
        }
        chmin(ans, sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    long long num = 0;
    cin>>N;
    int A[N],B[N];
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    for(int i=N-1;i>=0;i--){
        if((A[i]+num)%B[i]!=0){
            num+=B[i]-(A[i]+num)%B[i];
        }
    }
    cout <<num;
    return 0;
}

Measured memory_bytes: 4368
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T>inline bool chmax(T& a,T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>inline bool chmin(T& a,T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

long long h[100010];
long long dp[100010];

int main() {
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for(int i = 0; i < 100010; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        chmin(dp[i],dp[i-1] + abs(h[i]-h[i-1]));
        if(i>1) chmin(dp[i],dp[i-2] + abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << endl;
}



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

using namespace std;

int main()
{
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int ans = 0, c = 0;
  for(int i = 0; i < N && x - a.at(i) >= 0; i++){
    x -= a.at(i);
    ans++;
    c = i;
  }
  if(x > 0 && c >= N - 1){
    ans--;
  } 
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );



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

    ll N;
    cin>>N;
    vector<ll> ab(N),a(N),b(N);
    FOR(i,0,N) cin>>a[i];
    FOR(i,0,N) cin>>b[i];
    ll sum=0;
    FOR(i,0,N){
        ab[i]=a[i]-b[i];
        sum+=a[i]-b[i];
    }
    sum=abs(sum);

    ll plus=0;
    ll minus=0;

    FOR(i,0,N){
        if(ab[i]<0){
            if(ab[i]%2==0) plus+=(-1*ab[i])/2;
            else{
                plus+=(-1*ab[i])/2+1;
                minus++;
            }
        }else{
            minus+=ab[i];
        }
    }
    
    //cout<<sum-plus<<' '<<sum-minus<<endl;

    if((sum-plus)*2==sum-minus && sum-minus>=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 512
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
// always use 1LL instead of 1
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
// just comment the line below in case of interactive problems
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		double a,b,c;
		cin >> a >> b >> c;
		if( (a/c) <= b)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3740
#include <stdio.h>
#define max_len 100010
#define Min(a,b) a<b?a:b
void initArray(char a[], int len)
{
    for(int i = 0; i < len; i++)
    {
        a[i] = 0;
    }
}

int retlen(char a[])
{
    int len  = 0;
    while(a[len] >= '0')
    {
        len++;
    }
    return len;
}

int count_char_0(char a[], int len)
{
    int count = 0;
    for(int i = 0; i < len; i++)
    {
        if(a[i] == '0')
        {
            count++;
        }
    }
    return count;
}

int main(void)
{
    char tiles[max_len];
    initArray(tiles, max_len);
    fgets(tiles, max_len, stdin);
    int len = retlen(tiles);
    if(len == 0)
    {
        puts("0");
        return 0;
    }
    char odd_tiles[max_len], even_tiles[max_len];
    initArray(odd_tiles, max_len);
    initArray(even_tiles, max_len);
    int iter = 0, odd_iter = 0, even_iter = 0;
    while(iter < len)
    {
        odd_tiles[odd_iter++] = tiles[iter++];
        even_tiles[even_iter++] = tiles[iter++];
    }
    int odd_len = retlen(odd_tiles);
    int even_len = retlen(even_tiles);
    
    int num_of_0_odd = count_char_0(odd_tiles, odd_len);
    int num_of_0_even = count_char_0(even_tiles, even_len);
    
    int need_odd_0 = (odd_len - num_of_0_odd) + num_of_0_even;
    int need_odd_1 = num_of_0_odd + (even_len - num_of_0_even);
    printf("%d\n", Min(need_odd_1, need_odd_0));
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    string s;
    cin>>s;
    if(s=="AAA" || s=="BBB"){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*3
#define ll long long
int pa[nn],siz[nn];
int n,m;
vector<int> v[nn],c[nn],rev[nn];
int modi(int x)
{
	x+=3;return x%3;
}
void add_edge(int x,int y)
{
	v[x].push_back(y);v[y].push_back(x);
	c[x].push_back(1);c[y].push_back(-1);
}


int cnt[4];int fail;int vis[nn];int col[nn];
void dfs(int x,int cc)
{
	vis[x]=1;col[x]=cc;cnt[cc]++;
	for(int i=0;i<v[x].size();i++)
	{
		int y=v[x][i];
		if(c[x][i]==1) cnt[3]++;
		if(!vis[y]) dfs(y,modi(cc+c[x][i]));
		else if(col[y]!=modi(cc+c[x][i])) fail=1;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int x,y;scanf("%d%d",&x,&y);
		add_edge(x,y);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i]) 
		{
			cnt[0]=cnt[1]=cnt[2]=cnt[3]=0;fail=0;
			dfs(i,0);int tot=cnt[0]+cnt[1]+cnt[2];
			
			if(fail==1) ans+=1ll*tot*tot;
			else if(!cnt[0] or !cnt[1] or !cnt[2]) ans+=cnt[3];
			else ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 26752
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    x1,y1,x2,y2 = map(int,input().split())
    x12 = (x2-x1)
    y12 = (y2-y1)
    x3 = (x12-y12)+x1
    y3 = (x12+y12)+y1
    x4 = -y12+x1
    y4 = x12+y1
    print('{} {} {} {}'.format(x3, y3, x4, y4))

if __name__=="__main__":
    main()

Measured memory_bytes: 9192
n,w=map(int,input().split())
#wv=[[int(i) for i in input().split()] for j in range(n)]
dp=[0]*(w+1)

for i in range(n):
    new_dp=[0]*(w+1)
    ww,v=map(int,input().split())
    for j in range(w+1):
        if j<ww:
            new_dp[j]=dp[j]
        else:
            new_dp[j]=max(dp[j],dp[j-ww]+v)
    dp=new_dp
print(dp[-1])

Measured memory_bytes: 67604
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans;
string s;

int main() {
    scanf(" %d", &k);
    cin >> s;
    if (s.length() <= k) cout << s << endl;
    else {
        rep(0, k) cout << s[i];
        cout << "..." << endl;
    }
}

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



int main(){
    ll N, L; cin >> N >> L;
    vector<string> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    sort(V.begin(), V.end());
    for(auto s : V) cout << s;
    cout << endl;
}

Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 2147483647;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, k;
  cin >> n >> k;
  vector<int> cnt(n + 1, 0);
  while (k--) {
    int d;
    cin >> d;
    int v;
    for (int i = 0; i < d; i++) {
      cin >> v;
      cnt[v]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (cnt[i] == 0);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<numeric>
using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }
    for (int i = K; i < N; ++i) {
        if (A[i -K] < A[i]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
#define MAX 10000

typedef struct{
    int p,left,right;
}point;
int n;
point t[MAX];
void pre(int x){
    if(x==-1)return;
    printf(" %d",x);
    pre(t[x].left);
    pre(t[x].right);
}
void in(int x){
    if(x==-1)return;
    in(t[x].left);
    printf(" %d",x);
    in(t[x].right);
}
void post(int x){
    if(x==-1)return;
    post(t[x].left);
    post(t[x].right);
    printf(" %d",x);
}
int main(){
    int i,left,right,root,x;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        t[i].p=-1;
    }
    for(i=0;i<n;i++){
        scanf("%d %d %d",&x,&left,&right);
        t[x].right=right;
        t[x].left=left;
        if(right!=-1)t[right].p=x;
        if(left!=-1)t[left].p=x;
    }
    for(i=0;i<n;i++){
        if(t[i].p==-1)root=i;
    }
    printf("Preorder\n");
    pre(root);
    printf("\n");
    printf("Inorder\n");
    in(root);
    printf("\n");
    printf("Postorder\n");
    post(root);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main(){
    string S,T;cin>>S>>T;
    bool flag=true;
    for(int i=0;i<S.size();i++){
        if(S.at(i)!=T.at(i)){
            flag=false;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
s = input()
sl = [s[i] for i in range(4)]
for i in range(2**3):
	formula = sl[0]
	for j in range(3):
		if (i >> j) & 1:
			formula += "+"
		else:
			formula += "-"
		formula += sl[j+1]
	if eval(formula) == 7:
		print(formula+"=7")
		exit()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<functional>
using namespace std;

#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define yes cout << "yes\n"
#define NO cout << "NO\n"
#define No cout << "No\n"
#define no cout << "no\n"
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  int n, m;
  cin >> n >> m;
  map<i64, i64> mp;
  mp[0] = 1;
  i64 cou = 0, sum = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    sum += a;
    sum %= m;
    cou += mp[sum];
    mp[sum]++;
  }
  cout << cou << endl;
}


Measured memory_bytes: 4224
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
AB.sort(key=lambda x: x[1])

ans = 1
t = AB[0][1]-1

for i in range(M):
    if t < AB[i][0]:
        t = AB[i][1]-1
        ans += 1
print(ans)


Measured memory_bytes: 29084
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==1 && b==1 && c==0){
		cout<<"Open"<<endl;
	}else if(a==0 && b==0 && c==1){
		cout<<"Open"<<endl;
	}else{
		cout<<"Close"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<string, int> mp;
    vector<string> v;
    rep(i, N) {
        string S; cin >> S;
        sort(S.begin(), S.end());
        v.push_back(S);
        mp[S]++;
    }
    int ans = 0;
    rep(i, N) {
        int t = mp[v[i]];
        mp[v[i]] = 0;
        //cout << t << endl;
        ans += t * (t - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16628
#include <iostream>

using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    cout<<A<<' '<<B<<' '<<3*C-A-B<<endl;
    cout<<4*C-2*A-B<<' '<<C<<' '<<2*A+B-2*C<<endl;
    cout<<A+B-C<<' '<<2*C-B<<' '<<2*C-A<<endl;

    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int D; std::cin >> D;
    std::vector<int> c(26), t(D+1);
    std::vector<std::set<int>> days(26);
    for(int i(0); i < 26; ++i){
        days[i].emplace(0);
    }
    std::vector<std::vector<int>> s(D+1, std::vector<int>(26));
    for(int i(0); i < 26; ++i) std::cin >> c[i];
    for(int i(1); i <= D; ++i){
        for(int j(0); j < 26; ++j) std::cin >> s[i][j];
    }

    for(int i(1); i <= D; ++i){
        std::cin >> t[i];
        --t[i];
        days[t[i]].emplace(i);
    }
    long long v(0);
    
    for(int i(1); i <= D; ++i){
        long long dcr(0);
        for(int j(0); j < 26; ++j){
            auto itr(std::upper_bound(std::begin(days[j]), std::end(days[j]), i));
            dcr += c[j] * (i - *(--itr));
        }
        v += s[i][t[i]] - dcr;
        std::cout << v << "\n";
    }
    return 0;
}


Measured memory_bytes: 3668
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int r = inpt[0];
        int c = inpt[1];
        int[,] hyo = new int[r + 1, c + 1];
        int[] cTotal = new int[c];
        for (int i = 0; i <= r; i++) {
            if(i<r) {
				inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            } else {
                inpt = cTotal;
            }
            hyo[i, c] = inpt.Sum();
            for (int j = 0; j < c; j++) {
                hyo[i, j] = inpt[j];
                cTotal[j] += inpt[j];
            }
        }
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        for (int i = 0; i <= r; i++) {
            for (int j = 0; j <= c; j++) {
                if(j>0) {
                    ans.Append(" ");
                }
                ans.Append(hyo[i,j]);
            }
            ans.AppendLine(string.Empty);
        }
        Console.Write(ans.ToString());
    
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


4 5
1 1 3 4 5
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

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

int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}



Measured memory_bytes: 3228
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();
        if (s.length() <= k) {
            System.out.println(s);
        }
        else {
            System.out.println(s.substring(0, k) + "...");
        }
        
    
    }
}


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

using namespace std;

int h, w, k;

char mp[10][10];

int res = 0;

int visx[10], visy[10];

int cnt; 

void update() {
	int now = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (visx[i] || visy[j]) continue;
			if (mp[i][j] == '#') now++;
		}
	}
	if (now == k) res++;
}

void dfs2(int y, int ok) {
	visy[y] = ok;
	if (y == w) { update(); return;} 
	if (y+1 <= w) dfs2(y+1, 0), dfs2(y+1, 1);
}

void dfs1(int x, int ok) {
	visx[x] = ok;
	if (x == h) {dfs2(0,0);return;}
	if (x+1 <= h) dfs1(x+1, 0), dfs1(x+1, 1);
}

int main() {
	cin >> h >> w >> k;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> mp[i][j];
		}
	}
	dfs1(0,0);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3576
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
if n <= 3:
  print(max(a))
  exit()

a = tuple(a)
dp = [[-10**15]*3 for i in range(n)]

dp[0][2] = a[0]
dp[1][2] = a[1]
dp[2][2] = a[0]+a[2]
dp[3][2] = max(a[0],a[1])+a[3]
dp[3][1] = a[0]+a[3]
for i in range(2,n-2):
  if i%2 == 0:
    dp[i+2][2] = dp[i][2]+a[i+2]
    dp[i+2][0] = max(dp[i][0]+a[i+2],dp[i-1][1]+a[i+2],dp[i-2][2]+a[i+2])
  else:
    dp[i+2][2] = max(dp[i][2],dp[i][1],dp[i-1][2])+a[i+2]
  dp[i+2][1] = max(dp[i][1]+a[i+2],dp[i-1][2]+a[i+2])
if n%2 == 1:
  c = min(a[0],a[-1])
  dp[n-1][2] -= c
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

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

int main(){
  int n,x,i;
  cin>>n>>x;
  vector<int> l(n,0);
  for(i=0;i<n;i++)
    cin>>l[i];
  int count = 1;
  long temp= 0;
  for(i=0;i<n;i++){
    temp+= l[i];
    if(temp<=x)
      count++;
  }
  cout<<count<<"\n";
  return 0;
}

Measured memory_bytes: 256
import math
def get_prime(n):
    if n<=1:
      return []
    prime=[2]
    limit=int(math.sqrt(n))
    
    data=[i+1 for i in range(2,n,2)]
    while limit>data[0]:
      prime.append(data[0])
      
      data=[j for j in data if j % data[0]!=0]
      
    return prime+data

xxx=get_prime(55555)

zzz=[i for i in xxx if i%5==1]

n=int(input())

yyy=zzz[:n]

kkk=[str(i) for i in yyy]

print(' '.join(kkk))

Measured memory_bytes: 74696
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc143/tasks/abc143_e
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const LL mod = 1000000007ll;

LL N,M,L;
vector<vector<LL>> cost;
LL Q;
LL s[300*(300-1)],t[300*(300-1)];

LL ans[300*(300-1)];

void solve(){
	//ワーシャルフロイド
	for(int k=0;k<N;k++){//中間点を外側に持ってくるのが肝
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
	}
	//これで任意のi,j間の最短距離がもとまった
	//i,j間が燃料補給なしで行けるかどうかをdistance[i][j]とする
	vector<vector<LL>> distance(N,vector<LL>(N,INF));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(cost[i][j]<=L) distance[i][j] = 1;
		}
	}
	//distanceに対してワーシャルフロイド
	//もし
	//distance[i][k]=1 かつdistance[k][j]=1 かつ
	//distance[i][k]+distance[k][j]=1になるようなのがあっても、
	//それはもうすでにdistance[i][j]=1になっている
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				distance[i][j] = min(distance[i][j],distance[i][k]+distance[k][j]);
			}
		}
	}
	//s,tに対して燃料補給の回数を求める
	for(int i=0;i<Q;i++){
		ans[i] = ((distance[s[i]-1][t[i]-1]==INF)? -1 : distance[s[i]-1][t[i]-1]-1);
	}
}
 
int main(){
	cin >> N >> M >> L;
	cost = vector<vector<LL>>(N,vector<LL>(N,INF));
	for(int i=0;i<N;i++) cost[i][i] = 0;
	for(int i=0;i<M;i++){
		LL a,b,c;
		cin >> a >> b >> c;
		cost[a-1][b-1] = c;
		cost[b-1][a-1] = c;
	}
	cin >> Q;
	for(int i=0;i<Q;i++) cin >> s[i] >> t[i];
 
	solve();

	for(int i=0;i<Q;i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	int N; cin >> N;
	vector<pair<int, int>> arr(N);
	vector<pair<int, int>> arr2(N);
	vector<bool> used(N, false);
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		arr[i] = { a, b };
	}
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		arr2[i] = { a, b };
	}
	sort(arr.begin(), arr.end());
	reverse(arr.begin(), arr.end());
	sort(arr2.begin(), arr2.end());
	int count = 0;
	for (int i = 0; i < N; i++)
	{
		int kasa = -1, memo = 114514;
		for (int j = 0; j < N; j++)
		{
			if (arr[j].first < arr2[i].first && arr[j].second < arr2[i].second)
			{
				if (kasa < arr[j].second && used[j] == false)
				{
					kasa = arr[j].second;
					memo = j;
				}
			}
		}
		if (kasa != -1)
		{
			count++;
			used[memo] = true;
		}
	}
	cout << count << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define REP(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

char in[120];
pair<pair<string,int>,int> p[110];
int main(){
  int a;cin>>a;
  rep(i,a){
  int t;cin>>in>>t;
  p[i]=make_pair(make_pair(in,-t),i);
  }
  sort(p,p+a);
  rep(i,a) cout<<p[i].second+1<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(){
  int h,m,s;
  cin>>s;

  if(0<=s&&s<=86400){
    h=s/3600;
    m=(s-h*3600)/60;
    s=s-h*3600-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;
  }
  else{}

  return 0;

}

Measured memory_bytes: 3104
n,m= map(int,input().split())
if n == 1 and m == 0:
    print(0)
    exit()
d = {}
for _ in range(m):
    s,c = map(int,input().split())
    if d.get(s) != None and d[s] != c:
        print(-1)
        exit()
    d[s] = c

ret = 0
for k in range(1,n+1):
    if k == 1 and d.get(k) == None:
        ret = 1
    elif k == 1:
        ret = d[k]
    elif d.get(k) == None:
        ret = 10*ret
    else:
        ret = 10*ret + d[k]
if len(str(ret)) != n:
    print(-1)
    exit()
print(ret)


Measured memory_bytes: 3064
#! /usr/bin/python
from sys import stdin
n = int(input())
W = stdin.read().splitlines()
if n != len(set(W)):
    print("No")
    exit()
for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	cout << n * 800 - 200 * (n / 15) << endl;
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  string ans = "";
  int N;
  cin >> N;
  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }

  while (N != 0) {
    int rem = N % -2;
    N /= -2;

    if (rem < 0) {
      rem += 2;
      N++;
    }

    ans = (char)(rem + '0') + ans;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,a;
	cin >> n >> m;
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		cin >> a;
		sum += a;
	}

	sum = n - sum;
	sum = (sum < 0) ? -1 : sum;

	cout << sum << "\n";
}

Measured memory_bytes: 3640