akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const int maxn=1e6+10;
int a[maxn];
int main()
{
    int n,h;
    cin>>h>>n;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        int k;
        sint(k);
        sum+=k;
    }
    if(h<=sum)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


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

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

llong P = 1000000007;

llong mpow(llong a,llong b){
	llong ans = 1;
	while(b){
		if( b&1 ) ans=ans*a%P;
		b = b>>1; a=a*a%P;
	}
	return ans;
}

int main(){
	llong N;
	cin >> N;
	if( N==1 ){
		cout << "0";
	}else{
		llong X=mpow(10,N),A=mpow(9,N),C=mpow(8,N);
		llong ans= (X+C)%P;
		ans = (ans-2*(A%P)+2*P)%P;
		cout << ans;
	}
}

Measured memory_bytes: 3624
def solve(string):
    *nkrsp, t = string.split()
    *t, = map(int, t.replace("r", "2").replace("s", "0").replace("p", "1"))
    n, k, *rsp = map(int, nkrsp)
    ans = 0
    for s in range(k):
        u = t[s::k]
        i = 0
        while i < len(u):
            c = 1
            while i < len(u) - 1 and u[i] == u[i + 1]:
                i += 1
                c += 1
            ans += (c + 1) // 2 * rsp[u[i]]
            i += 1
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 4980
import java.io.*;
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int dnum = scan.nextInt();
		scan.nextLine();
		ArrayList<Dice> dlist = new ArrayList<Dice>();
		for(int i=0; i<dnum; i++){
			Dice tmp = new Dice(scan.nextLine());
			for(int j=0; j<dlist.size();j++)
				if(dlist.get(j).rollAllPattern(tmp)){
					System.out.println("No");
					return;
				}
			dlist.add(tmp);
		}
		System.out.println("Yes");
			
	}

}
class Dice{
	int top;
	int back;
	int right;
	int left;
	int front;
	int bottom;
	public Dice(String line){
		String[] face = line.split(" ");
		top = Integer.parseInt(face[0]);
		back = Integer.parseInt(face[1]);
		right = Integer.parseInt(face[2]);		
		left = Integer.parseInt(face[3]);
		front = Integer.parseInt(face[4]);
		bottom = Integer.parseInt(face[5]);
	}
	void rotate(){
		int tmp = front;
		front = right;
		right=back;
		back = left;
		left = tmp;
	}
	public void roll(char c){
		int tmp = top;
		switch(c){
			case 'N':
				top = back;
				back=bottom;
				bottom = front;
				front = tmp;
				break;
			case 'E':
				top = left;
				left = bottom;
				bottom = right;
				right = tmp;
				break;
			case 'S':
				top = front;
				front = bottom;
				bottom = back;
				back = tmp;
				break;
			case 'W':
				top = right;
				right = bottom;
				bottom = left;
				left = tmp;
				break;
		}
	}

	@Override
	public int hashCode() {
	    final int prime = 31;
	    int result = 1;
	    result = prime * result + top;
	    result = prime * result + bottom;
	    result = prime * result + right;
	    result = prime * result + left;
	    result = prime * result + front;
	    result = prime * result + back;
	    return result;
    }
	@Override
	public boolean equals(Object obj) {
		Dice d = (Dice) obj;
		if(this.top == d.top && 
		   this.bottom == d.bottom &&
		   this.right == d.right &&
		   this.left == d.left &&
		   this.front == d.front &&
		   this.back == d.back)
			return true;
		else
			return false;
	}
	public boolean rotateCheck(Dice d){
		for(int j=0;j<4;j++){
			rotate();
			if(this.equals(d))
				return true;
		}
		return false;
	}
	public boolean rollAllPattern(Dice d){
		for(int i=0; i<4;i++){
			roll('N');
			if(rotateCheck(d))
				return true;
		}
		roll('W');
		if(rotateCheck(d))
			return true;		
		roll('E');
		roll('E');		
		if(rotateCheck(d))
			return true;	
		return false;			
	}
}	
	
	

Measured memory_bytes: 21624
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   


      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
         ll n,k;
         cin>>n>>k;
         vector<ll>v;
         for(int i=0;i<n;i++)
         {
             ll a;
             cin>>a;
             v.pb(a);
         }
         sort(all(v));
         reverse(all(v));
         ll ans = 0;
         if(n<=k)
         cout<<"0";
         else
         {
             for(int i=k;i<n;i++)
             ans+=v[i];
             cout<<ans;
         }
         



      }
      
}






Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,m;
    cin>>n;
    vl<string> s(n);
    for(i=0;i<n;i++) cin>>s[i];
    for(i=0;i<n;i++) sort(s[i].begin(),s[i].end());
    sort(s.begin(),s.end());
    ll count=0;
    ll ans=0;
    for(i=1;i<n;i++)
    {
        if(s[i]==s[i-1]) count++;
        else
        {
            ans+=((count)*(count+1))/2;
            count=0;
        }
    }
    ans+=((count)*(count+1))/2;
    cout<<ans;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; double cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

signed main()
{
   int N, A, B; cin >> N >> A >> B;

   if (A > B ||
       N == 1 && A != B) {
      cout << 0 << endl;
   } else {
      cout << ((N-1)*B + A) - ((N-1)*A + B) + 1 << endl;
   }

   return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_f
aa = gets.chomp.split(" ").map(&:to_i)
aa_sum = aa.inject(:+)
m = aa_sum / n
m1 = m.floor
m2 = m.ceil
aa2_sum = aa.map{|x| x**2}.inject(:+)
r1 = aa2_sum - 2 * m1 * aa_sum + n * (m1 ** 2)
r2 = aa2_sum - 2 * m2 * aa_sum + n * (m2 ** 2)
puts [r1, r2].min.to_i

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mnx 1000001
#define pr pair<ll,ll>
#define ez 
#define prin(x) cout<<setprecision(11)<<fixed<<x<<" ";
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define os tree < ll ,  null_type ,  less <ll>,  rb_tree_tag ,  tree_order_statistics_node_update >




void masterstroke()
{   
	ll n,m;
	cin>>n>>m;
	ll a[n],b[m];
	for(ll i=1;i<=n;i++)cin>>a[i];
	for(ll i=1;i<=m;i++)cin>>b[i];
    ll dp[n+1][m+1]={0};
    for(ll i=0;i<=n;i++){
    	for(ll j=0;j<=m;j++){dp[i][j]=0;}
    }
    ll val[m+1]={0};
    for(ll i=1;i<=n;i++){
    	for(ll j=1;j<=m;j++){
    		if(a[i]==b[j]){
    		//	cout<<i<<" "<<j<<endl;
    			dp[i][j]=(dp[i][j-1]+dp[i-1][j-1]+1+val[j])%pri;
    			val[j]=(val[j]+dp[i-1][j-1]+1)%pri;
    		}	
    		else {
    			dp[i][j]=(dp[i][j-1]+val[j])%pri;
    		}
    	}
    }
    
    
    cout<<(dp[n][m]+1)%pri<<endl;
	
}


int main(){

	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)
	masterstroke();

}


Measured memory_bytes: 31616
/**
 *      purpose : CODE FESTIVAL 2016 qual A B
 *      author  : kyomukyomupurin
 *      created : 2018-11-07 23:34:58
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int a[N + 5] = {};
    for (int i = 1; i <= N; ++i) cin >> a[i];

    int cnt = 0;

    for (int i = 1; i <= N; ++i) {
        if (i == a[a[i]]) ++cnt;
    }

    print(cnt / 2);
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdint>

int64_t const MOD = 1e9+7;
int const MAXN = 2e5;
int64_t C[MAXN];
int N;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
  operator int64_t() const { return v_; }
};
typedef mod_int<MOD> mint;

int main() {
  int N; std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> C[i];
  if(N==1) {
    mint ans(C[0]*2);
    std::cout << ans << std::endl;
    return 0;
  }
  std::sort(C, C+N, [](int64_t l, int64_t r){ return l > r; });
  mint ans;
  auto p2 = mint(2).pow(N-2);
  for(int i = 0; i < N; ++i) ans += mint(C[i])*p2*mint(i+2);
  ans *= p2*mint(4);
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main() {

    double a, b, x;
    cin >> a >> b >> x;

    double ans;

    ans = atan(2 * (a * a * b - x) / a / a / a) / M_PI * 180;

    if (ans > atan(b / a) / M_PI * 180) {
        ans = (M_PI / 2 - atan(2 * x / (a * b * b))) / M_PI * 180;
    }

    cout << setprecision(10) << ans;

    return 0;
}


Measured memory_bytes: 4048
N = int(input())
WS = [int(i) for i in input().split()]

min = sum(WS)
for i in range(1, N):

    s1 = 0
    s2 = 0
    for j in range(N):
        if j <= i :
            s1+=WS[j]
        else:
            s2 += WS[j]

    if abs(s1-s2)< min :
        min = abs(s1-s2)

print(min)


Measured memory_bytes: 39152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
#include<algorithm>
using namespace std;
#define debug(x) cout << #x << " = " << X << endl
typedef long long LL;

int main()
{	
	string s;
	while(cin >> s)
	{
		int f = 1;
		int len = s.length();
		int sum = 0;
		for(int i = 0; i < len; i++)
		{
			if(s[i] <= 'Z' && s[i] >= 'A') sum++;
		}
		if(sum != 2) f = 0;
		if(s[0] != 'A') f = 0;
		sum = 0;
		for(int i = 2; i <= len - 2; i++) if(s[i] == 'C') sum++;
		if(sum != 1) f = 0;
		if(f) printf("AC\n");
		else printf("WA\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
typedef long long ll;
int main(){
  	ll n;
  	ll mod = 1000000007;
	ll dp[2005] = {0};
	dp[0] = 1;
	
	cin >> n;
	for (ll i = 0; i < n; i++) {
		for (ll j = i + 3; j <= n; j++) {
			dp[j] = (dp[j] + dp[i]) % mod;
		}
	}
	
	cout << dp[n] << '\n';
  
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int INF = 1e9;

int dp[500001][3];

int main(void) {
    int i, n;
    string s;
    cin >> n >> s;

    // 0: any, 1: 10, 2: .0..1...1
    REP (i,0,n) dp[i][0] = dp[i][1] = -INF;
    dp[0][0] = 0;
    REP (i,n) {
        dp[i][0] = max(dp[i][0],dp[i][1]);
        dp[i+1][0] = max(dp[i+1][0],dp[i][0]);
        if (s[i] == '1') {
            dp[i+1][1] = max(dp[i+1][1],dp[i][1] + 1);
            dp[i+1][2] = max(dp[i][0],dp[i][2]) + 1;
        }
        if (i == n-1) break;
        if (s[i] == '1' && s[i+1] == '0')
            dp[i+2][1] = max(dp[i][0],dp[i][1]);
        else if (s[i] == '0' && s[i+1] == '1')
            dp[i+2][0] = dp[i][2];
    }
    cout << max(dp[n][0],dp[n][1]) << endl;
    return 0;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
#define mod 1000000007
int n,k;
int a[101];
int pre[101];
int dp[101][100001];
int func(int i,int j)
{   if(i<0 || j<0)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    if(pre[i]<j)return dp[i][j]=func(i,j-1);

    if(i==0 || j==0){ 
                   if(i==0){return dp[i][j]=min(j+1,a[i]+1);
                            }
                   if(j==0){return dp[i][j]=1;}}
    //dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-a[i]-1];
    dp[i][j]=((func(i,j-1)+func(i-1,j))%mod-func(i-1,j-a[i]-1)%mod+mod)%mod;
    return dp[i][j];

}
signed main()
{   //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n>>k;
    //int a[n];
    //int pre[n];
    cin>>a[0];
    pre[0]=a[0];
    for(int i=1;i<n;i++)
    	{cin>>a[i];
    	 pre[i]=pre[i-1]+a[i];}
	
    for(int i=0;i<n;i++)
    	for(int j=0;j<k+1;j++)	
    		dp[i][j]=-1;
  
    
    
    
  
    cout<<((func(n-1,k)-func(n-1,k-1))%mod+mod)%mod<<endl;


    

    return 0;
}

Measured memory_bytes: 83072
#include<stdio.h>
int main(void) {
	char s[5];
	int i;
	scanf("%s", s);

	for (i = 0; i < 4; i++) {
		if (s[i] == s[i + 1]) {
			printf("Bad\n");
			break;
		}
		else {
			if (i == 3) {
				printf("Good\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int count=0;
		long l=lcm(c,d);
		System.out.println(b-b/c-b/d+b/l-a+1+(a-1)/c+(a-1)/d-(a-1)/l);
	}

	private static long lcm(long m,long n){
		return m*n/gcd(m,n);
	}

	private static long gcd(long m,long n){
		if(m<n)return gcd(n,m);
		if(n==0) return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int main()
{
	int n;
	cin>>n;
	int now=n%1000;
	if(now==0) cout<<"0";
	else
	{
		cout<<1000-now;
		 } 	
	return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    vi a(x),b(y),c(z);
    rep(i,x)cin>>a[i];
    rep(i,y)cin>>b[i];
    rep(i,z)cin>>c[i];
    vi d;
    rep(i,x){
        rep(j,y){
            d.pb(a[i]+b[j]);
        }
    }
    RSORT(d);
    d.resize(k);
    vi e;
    rep(i,k){
        rep(j,z){
            e.pb(d[i]+c[j]);
        }
    }
   RSORT(e);
    rep(i,k)cout<<e[i]<<endl;
}

Measured memory_bytes: 43240
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc140/tasks/abc140_b

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
e = 0
last = -1
for ax in a:
    e += b[ax - 1]
    if ax == last + 1:
        e += c[last - 1]
    last = ax
print(e)


Measured memory_bytes: 3064
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[200000];
int b[200000];

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b >= c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=10000023;
int isprime[N];
void solve()
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        isprime[i]=i;
    }
    for(int i=2;i<=n;i++)
    {
        if(isprime[i]!=i)
            continue;
        for(int j=2*i;j<N;j+=i)
            isprime[j]=i;
    }
    ll ans=0;
    int temp;
    int i;
    ll divi=0;
    int cnt=0;
    for(i=1;i<=n;i++)
    {
        if(i==1)
        {
            ans+=1;
        }
        else
        {
            temp=i;
            divi=1;
            while(temp!=1)
            {
                cnt=0;
                int p=isprime[temp];
                while((temp%p)==0)
                {
                    temp/=p;cnt++;
                }
                divi*=(cnt+1);
            }
            ans+=((ll)divi*i);
        }
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 42864
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

static const int N = 10000;
static const int INF = 1000000;

struct Vertex {
    int id;
    bool in_S;
    int min_cost;
};

bool operator>(const Vertex &vertex1, const Vertex &vertex2)
{
    return vertex1.min_cost > vertex2.min_cost;
}


class SSSP {
private:
    vector<pair<int, int> > adj[N];
    Vertex vertex[N];
    int n;

public:
    SSSP()
    {
        cin >> n;
        int id;
        int degree;
        int v;
        int c;
        for (int i = 0; i < n; i++)
        {
            cin >> id;
            vertex[id].id = id;
            cin >> degree;
            for (int j = 0; j < degree; j++)
            {
                cin >> v >> c;
                adj[id].push_back(make_pair(v, c));
            }
        }
    }

    void dijkstra(int start)
    {
        priority_queue<Vertex, vector<Vertex>, greater<Vertex> > PQ;
        for (int i = 0; i < n; i++)
        {
            vertex[i].in_S = false;
            vertex[i].min_cost = INF;
        }
        vertex[start].min_cost = 0;

        PQ.push(vertex[start]);

        while (!PQ.empty())
        {
            int u = PQ.top().id;
            int cost = PQ.top().min_cost;
            PQ.pop();

            vertex[u].in_S = true;

            if (vertex[u].min_cost < cost)
                continue;

            for (int j = 0; j < adj[u].size(); j++)
            {
                int v = adj[u][j].first;
                if (!vertex[v].in_S)
                {
                    if (vertex[u].min_cost + adj[u][j].second < vertex[v].min_cost)
                    {
                        vertex[v].min_cost = vertex[u].min_cost + adj[u][j].second;
                        PQ.push(vertex[v]);
                    }
                }
            }
        }
    }

    void print()
    {
        for (int i = 0; i < n; i++)
            cout << i << " " << (vertex[i].min_cost == INF ? -1 : vertex[i].min_cost) << endl;
    }
};

int main()
{
    SSSP mst;
    mst.dijkstra(0);
    mst.print();
}


Measured memory_bytes: 8096
// ABC123
// A - Five Antennas
#include<bits/stdc++.h>

using namespace std;

int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int a, b; cin >> a >> b;
	int c, d; cin >> c >> d;
	dump(c - 1);
	dump((a) % 12);
	cout << (c - 1 == (a) % 12) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }
    sort(all(r));

    vector<vector<ll>> d(N, vector<ll>(N, INF));
    rep(i, N) d[i][i] = 0;
    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        d[A][B] = C;
        d[B][A] = C;
    }

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    ll ans = INF;

    do {
        ll res = 0;
        rep(i, R - 1) {
            res += d[r[i]][r[i + 1]];
        }
        chmin(ans, res);
    } while (next_permutation(all(r)));

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

Measured memory_bytes: 3828
import math

a, b, h, m = map(int, input().split())
ang1 = (h*60 + m)/2
x = (h*60 + m) % 60
ang2 = (6 * x)
# print(ang1 , ang2)
ang = abs( ang1 - ang2 )
ang = min(ang, 360 - ang) * math.pi / 180

ans = a*a + b*b - 2*a*b*math.cos(ang)
print("%.12f" % math.sqrt(ans) )





Measured memory_bytes: 62500
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
string s;
ll pw[2][500005],rev[2][500005];
ll c[2] = {37,41}, mod[2] = {1000000007,1000000009};
ll modpow(ll x,ll n,ll modd){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%modd;
		x=x*x%modd;
		n>>=1;
	}
	return res;
}
int pt[250005];
ll cur_hash[2][250005];

int main(){
	cin >> n >> s;
	rep(i,2){
		pw[i][0] = rev[i][0] = 1;
		ll d = modpow(c[i],mod[i]-2,mod[i]);
		
		rep(j,500000){
			pw[i][j+1] = pw[i][j] * c[i] % mod[i];
			rev[i][j+1] = rev[i][j] * d % mod[i];
		}
	}
	rep(i,n){
		pt[i+1] = pt[i];
		rep(ii,2) cur_hash[ii][i+1] = cur_hash[ii][i];
		if(s[i] == '+'){
			if(pt[i+1] >= 0){
				rep(ii,2) cur_hash[ii][i+1] += pw[ii][pt[i+1]];
			}
			else{
				rep(ii,2) cur_hash[ii][i+1] += rev[ii][-pt[i+1]];
			}
		}
		else if(s[i] == '-'){
			if(pt[i+1] >= 0){
				rep(ii,2) cur_hash[ii][i+1] -= pw[ii][pt[i+1]];
			}
			else{
				rep(ii,2) cur_hash[ii][i+1] -= rev[ii][-pt[i+1]];
			}
		}
		else if(s[i] == '>') pt[i+1]++; else pt[i+1]--;
	}
	
	rep(i,2) rep(j,250005){
		cur_hash[i][j] = (cur_hash[i][j]%mod[i]+mod[i])%mod[i];
		
		//if(j <= n) cout << cur_hash[0][j] << " " << pt[j] << endl;
	}
	map<pair<ll,ll>,int>cnt;
	ll ans = 0;
	for(int i=n;i>=1;i--){
		cnt[mp(cur_hash[0][i],cur_hash[1][i])]++;
		
		ll check[2];
		rep(j,2) check[j] = cur_hash[j][i-1];
		
		if(pt[i-1] >= 0){
			rep(j,2) check[j] += cur_hash[j][n] * pw[j][pt[i-1]];
		}
		else{
			rep(j,2) check[j] += cur_hash[j][n] * rev[j][-pt[i-1]];
		}
		
		rep(j,2) check[j] = (check[j]%mod[j]+mod[j])%mod[j];
		
		if(cnt.find(mp(check[0],check[1])) != cnt.end())
			ans += cnt[mp(check[0],check[1])];
		
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 36612
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=1e8;
const int oo=0x3f3f3f3f;
const double eps=1e-10;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,m;
const int Maxn=2e5+5;
vector<int>G[Maxn],rG[Maxn];
int b[Maxn],f[Maxn];
int dp[Maxn];
int color[Maxn];
int t;
deque<int>order;
void toposort(int u){
	b[u]=++t;
	color[u]=1;
	rep(i,SZ(G[u])){
		int to=G[u][i];
		if(!color[to]){
			toposort(to);
		}
	}
	order.push_front(u);
	color[u]=2;
	f[u]=++t;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		G[u].push_back(v);
		rG[v].push_back(u);
	}
	rep(i,n)if(!color[i])toposort(i);
	rep(i,SZ(order)){
		int now=order[i];
//		cout<<now<<endl;
		rep(j,SZ(rG[now])){
			int from=rG[now][j];
			chkmax(dp[now],dp[from]+1);
		}
	}
//	rep(i,n){
//		printf("%d:color=%d beginTime=%d finishTime=%d\n",i+1,color[i],b[i],f[i]);
//	}
	printf("%d\n",*max_element(dp,dp+n));
	return 0;
}

Measured memory_bytes: 21248
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n+1, 0);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        v[a]++; v[b]++;
    }
    for (int i = 0; i < n; ++i) {
        cout << v[i+1] << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
const ll INF = 1e18;
const ll mod =1000000007;
#define foreach(ix,a) for(auto& (ix) : (a) 
struct UnionFind {
    vector<int> par;
 
    UnionFind(int N) : par(N,-1) {}
 
    int root(int x) { 
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return; 
        if(size(x)<size(y))swap(rx,ry);
        par[rx]+=par[ry];
        par[ry]=rx;
    }
    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    ll n,m;
    cin>>n>>m;
    UnionFind f(n);
    rep(i,m){
        int a,b;cin>>a>>b;
        a--;b--;
        f.unite(a,b);
    }
    int ans =0;
    rep(i,n){
        ans=max(ans,f.size(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

void ansYes(bool flag){
    if (flag) cout << "Yes" << endl; else  cout << "No" << endl;
}

void ansYES(bool flag){
    if (flag) cout << "YES" << endl; else  cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

int nanko(string s,Int n,Int i){
    Int length = min(n - i - 1,i);
    Int ans = 0;
    for (int k = i-length;k < i;k++){
        if (s.at(k) == 'R' && s.at(i +  (i - k) == 'B')) ans++;
    }
    return ans;
}


int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    REP(n-1,i){
        Int x;
        cin >> x;
        a.at(x-1)++;
    }
    REP(n,i){
        cout << a.at(i) << endl;
    }
}

Measured memory_bytes: 4840
n, m = map(int, input().split())

a=[True]*(n+1)
for i in range(m):
    a[int(input())]=False

r=[0]*(n+1)
r[0]=1

for i in range(1,n+1):
    if not a[i]:
        continue
    r[i]=(r[i-1]+r[i-2])%1000000007

print(r[n])


Measured memory_bytes: 7668
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
string s;

bool solve() {
    int r = 0, b = 0;
    for (char c : s) {
        if (c == 'R') r++;
        else b++;
    }
    return r > b;
}

void input() {
    cin >> n >> s;
}

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

    input();
    cout << (solve()?"Yes":"No") << endl;
}


Measured memory_bytes: 256
n = int(input())
ai = 0
aj = 0
nums = list(map(int, input().split()))
nums.sort()
ai = nums[n-1]
i = 0
while nums[0] < ai//2:
    aj = nums[0]
    del nums[0]
else:
    if ai > nums[0] + aj:
        aj = nums[0]
print(str(ai) + " " + str(aj))

Measured memory_bytes: 14428
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    ll ans = 0;
    ll mx = 0;
    REP(i, 0, n) {
        ll a;
        cin, a;
        ans += max(0LL, mx - a);
        chmax(mx, a);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
  ll t;
  while(b) {
    t = a % b, a = b, b = t;
  }
  return a;
}

int main(void) {
  ll i, j, k, n, a, b, c, l, m;
  scanf("%lld%lld", &n, &m);
  char s[n + 10], t[m + 10];
  scanf("%s%s", s, t);
  ll g = gcd(n, m), lc = n * m / g;
  for(i = 0; i < g; ++i) {
    if(s[lc / m * i] != t[lc / n * i]) {
      printf("-1");
      return 0;
    }
  }
  printf("%lld", lc);
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner (System.in);
         int n = input.nextInt();
    int[] array = new int[n];
    int count =0;
    for(int i=0;i<n;i++){
      array[i] = input.nextInt();
    }
    for(int j=0;j<n;j++){
      if(array [j] != j+1){
        count++;
      }
    }
    if(count == 2 || count == 0){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
    }
          
}


Measured memory_bytes: 23764
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int N=int.Parse(str[0]);
      int K=int.Parse(str[1]);
      int Q=int.Parse(str[2]);
      int[] points=new int[N];
      int[] AC=new int[Q];
      for(int i=0;i<Q;i++){
        AC[i]=int.Parse(Console.ReadLine());
      }
      foreach(var e in AC){
      points[e-1]++;
        
      }
      for(int i=0;i<N;i++){
        
        if(Q-points[i]<K){
          Console.WriteLine("Yes");
        }else{
          Console.WriteLine("No");
        }
      }
    }
    
  }

}


Measured memory_bytes: 21056
n,k = map(int,input().split())
a = [int(_) for _ in input().split()]

dp = [[-1,-1] for i in range(51)]
dp[50][0] = 0

for i in range(50)[::-1]:
    mask = 1<<i
    num = 0
    for j in range(n):
        num += (a[j]>>i)&1
    cost0 = num * mask
    cost1 = (n-num)*mask
    if not (k>>i)&1:
        dp[i][0] = dp[i+1][0] + cost0
        if dp[i+1][1]!=-1: dp[i][1] = dp[i+1][1] + max(cost0,cost1)
    if (k>>i)&1:
        dp[i][0] = dp[i+1][0] + cost1
        if dp[i+1][1] != -1:
            dp[i][1] = max(dp[i+1][0] + cost0,dp[i+1][1]+max(cost0,cost1))
        else:
            dp[i][1] = cost0
print(max(dp[0][0],dp[0][1]))
    

Measured memory_bytes: 14620
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;

using namespace std;


int main(){
    long long N;
    cin >> N;

    vector<long long> A(N);
    int num_minus = 0;
    for(int i = 0; i < N; ++i){
        cin >> A.at(i);
        if(A[i] < 0){
            ++num_minus;
        }
        A[i] = abs(A[i]);
    }

    long long sum = accumulate(A.begin(), A.end(), 0LL);

    if(num_minus % 2 == 1){
        sort(A.begin(), A.end());
        sum -= 2 * A[0];
    }

    cout << sum;
}


Measured memory_bytes: 1024
#abc125d
n=int(raw_input())
a=map(int,raw_input().split())
suma=0
mina=10**5+1
minuscnt=0
for i in range(n):
 suma+=abs(a[i])
 mina=min(mina,abs(a[i]))
 if a[i]<0:
  minuscnt+=1
if minuscnt%2:
 print suma-2*mina
else:
 print suma


Measured memory_bytes: 11328
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int t, x;
  cin >> t >> x;
  double ans = (double)t / x;
  print10(ans);
  return 0;
}

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

int N, K, a[100005], sump[100005], sum[100005], ans;

signed main()
{
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        cin >> a[i];
        sump[i] = sump[i - 1] + a[i] * (int)(a[i] > 0);
        sum[i] = sum[i - 1] + a[i];
    }
    for(int i = 1; i <= N - K + 1; i++){
        ans = max(ans, sump[i - 1] + sump[N] - sump[i + K - 1] + (sum[i + K - 1] - sum[i - 1]) * (int)(sum[i + K - 1] - sum[i - 1] > 0));
    }
    cout << ans << endl;

    return 0;
}


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

int d[200010] = {0};

int main(){
	int n, k, a;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> a;
		d[a-1]++;
	}
	sort(d, d+n);
	long long ans = 0;
	for(int i=0; i<n-k; i++) ans += d[i];
	cout << ans << endl;
}

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

string s,t;
int dp[3005][3005];

string get_string(int i, int j){
	if(i == 0|| j==0 )
		return string();


	string str;
	if(s[i-1] == t[j-1]){
		str = get_string(i-1,j-1);
		str.append(s,i-1,1);
	}

	else{

		if(dp[i][j-1] >= dp[i-1][j])
			j--;
		else if(dp[i][j-1] < dp[i-1][j])
			i--;		
		str = get_string(i,j);

	}

	// cout << str << endl;
	return str;

}

int main(){

	cin >> s;
	cin >> t;


	for (int i = 0; i <= s.size(); ++i){
		for (int j = 0; j <= t.size(); ++j){
			if(i == 0 || j==0)
				dp[i][j] = 0;

			else if(s[i-1] == t[j-1]){
				dp[i][j] = 1 + dp[i-1][j-1];		
			}
			else
				dp[i][j] = max(dp[i][j-1],dp[i-1][j]);

			// printf("%d ",dp[i][j] );	
		}
		// printf("\n");
	}

	// printf("%d\n",dp[s.size()][t.size()]);
	string str = get_string(s.size(),t.size());	
	cout << str << endl;
}

Measured memory_bytes: 36096
n=int(input())
ans=0
c=0
for i in range(0,n):
    x,y=list(map(int,input().split()))
    if(x==y):
        c+=1
        if(c==3):
            ans=1
            break
    else:
        c=0
        continue
    
if(ans==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9100
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N+1];
        for(int i = 1; i < N+1; i++){
            H[i] = sc.nextInt();
        }
        sc.close();
        int[] dp = new int[N+1];
        dp[2] = Math.abs(H[2] - H[1]);
        for(int i = 3; i <= N; i++){
            dp[i] = Math.min(dp[i-2] + Math.abs(H[i] - H[i-2]), dp[i-1] + Math.abs(H[i] - H[i-1]));
        }
        System.out.println(dp[N]);

    }

}


Measured memory_bytes: 50684
n=int(input())
a=list(map(int,input().split()))

ans_l=[]
ans1=0
s=0
for i in reversed(a):
 if s%2==0:
  ans1+=i
 else:
  ans1-=i
 s+=1

ans_l.append(ans1)
for i in range(n-1):
 ans_l.append((a[i]-ans_l[-1]//2)*2)
print(*ans_l)

Measured memory_bytes: 14092
#include<iostream>
#include<cstring>
using namespace std;
char a[10001];
long long c=-1,f=-1,len;
int main()
{
	cin>>a;
	len=strlen(a);
	for(long long i=0;i<len;i++)
	{
		if(a[i]=='C')
		{
			c=i;
			for(long long j=c;j<len;j++)
			{
				if(a[j]=='F')
				{
					f=j;
					break;
				}
			}
		}
	}
	if(c<f)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256