akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  bool isok=true;
  lvector A(n,0);rep(i,n) cin>>A[i];
  rep(i,n) {
    if(A[i]%2==0) {
      if(A[i]%3==0||A[i]%5==0) continue;
      else {isok=false;break;}
    }
    if(!isok) break;
  }
  if(isok) puts("APPROVED");else puts("DENIED");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
 
  ll  a,b,k; cin >> a >> b >> k;
  if(a>=k) cout << a-k << " " << b << endl;
  else if(a+b>k) cout << 0 << " " << a+b-k << endl;
  else cout << 0 << " " << 0 << endl;
 
}

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

vector<pair<bool, int> > v;

signed main() {

    int n, k;
    scanf("%d %d", &n, &k);
    string s;
    cin >> s;
    bool prev = s[0] - '0';
    int cnt = 1;
    for ( int i = 1; i < n; i++ ) {
        if ( prev != s[i]-'0' ) {
            prev = s[i] - '0';
            v.push_back ( make_pair ( !prev, cnt ) );
            cnt = 1;
        }
        else cnt++;
    }
    v.push_back ( make_pair ( prev, cnt ) );

    int mx = 0;
    int sum = 0;
    cnt = 0;
    int sta = 0;
    int end = 0;
    for ( ;; ) {
        bool tmp = v[end].first ? 0 : 1;
        while ( end < v.size() && (cnt + tmp) <= k ) {
            cnt += v[end].first ? 0 : 1;
            sum += v[end].second;
            end++;
            tmp = v[end].first ? 0 : 1;
        }
        if ( v.size() <= sta ) break;
        mx = max ( mx, sum );
        cnt -= v[sta].first ? 0 : 1;
        sum -= v[sta++].second;
    }
    cout << mx << endl;

    return 0;
}

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

int main(){
    int data[33] = {0 , 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << data[k] << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=gets.split.map &:to_i;
d=[0]*m;
d[0]=1;
$<.map{|s|
	a=0;
	d=s.chop.chars.zip(d).map{|c,d|a=c==?. ? (d+a)%(10**9+7) : 0}
}
p d[-1]

Measured memory_bytes: 10620
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#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, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,M;
    cin>>N>>M;
    
    VEC(ll,to1,0);
    //MAP(ll,toN,0);
    map<ll,ll> aa;
    REP(i,M){
        ll a,b;
        cin>>a>>b;
        if(a==1){
            to1.push_back(b);
        }
        if(b==1){
            to1.push_back(a);
        }
        if(a==N){
            aa[b]=0;
        }
        if(b==N){
            aa[a]=0;
        }
    }
    
    REP(i,to1.size()){
        if(aa.count(to1[i])!=0){
            cout<<"POSSIBLE";return 0;
        }
    }
    
    cout<<"IMPOSSIBLE";
    
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 7284
#include<stdio.h>
int main(){
  int k,s;
  scanf("%d%d",&k,&s);
  int count=0;
  int x,y;
  for(x=0;x<=k;x++){
    for(y=0;y<=k;y++){
      if(0<=s-x-y && s-x-y<=k)
        count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1684
Public Class Program
  Shared Sub Main()
    Dim nd As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim n As Integer = nd(0)
    dim d As Integer = nd(1)
    Dim output As Long = Math.Ceiling(n / (d * 2 + 1))
    Console.WriteLine(output.ToString())
  End Sub
End Class

Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){

    ll n,l;
    cin >> n >> l;
    vector <string> s(n);
    REP(i,n)
    {
        cin >> s[i];
    }
    sort(s.begin(),s.end());

    REP(i,n)
    {
        cout << s[i];
    }
    cout << endl;

    return 0;    

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

ans = "APPROVED"
for v in A:
    if v % 2 == 0:
        if v % 3 != 0 and v % 5 != 0:
            ans = "DENIED"
            break
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    cout << ((a+b)%3 == 0 || a%3 == 0 || b%3 == 0 ? "Possible" : "Impossible") << endl;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    vector<int> v;
    map<int,ll> mp;
    int N; cin >> N;
    REP(i, N) {
        int tmp; cin >> tmp;
        v.push_back(tmp);
        mp[tmp]++;
    }
    ll res_sum = 0;
    for (auto x: mp) {
        res_sum += (x.second * (x.second - 1) )/ 2;
    }
    REP(i, N) {
        cout << res_sum - (mp[v[i]] - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 10356
import numpy as np

N, W = map(int, input().split())
dp = np.array([W + 1] * (N * 1000 + 1))
dp[0] = 0
for _ in range(N):
  w, v = map(int, input().split())
  dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
max_value = 0
for v, w in enumerate(dp):
  if w <= W:
    max_value = v
print(max_value)

Measured memory_bytes: 14804
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);

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

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

  vector<int> fac(n);
  for (int i = 0; i < n; i++)
  {
    fac[i] = i + 1;
  }

  int a   = 0;
  int b   = 0;
  int cnt = 0;
  do
  {
    bool yes = true;
    for (int i = 0; i < n; i++)
    {
      if (p[i] != fac[i])
      {
        yes = false;
        break;
      }
    }

    if (yes)
    {
      break;
    }

    cnt++;

  } while (next_permutation(fac.begin(), fac.end()));  // 次の順列を生成
  a = cnt;

  // 再度初期化

  for (int i = 0; i < n; i++)
  {
    fac[i] = i + 1;
  }

  cnt = 0;
  do
  {
    bool yes = true;
    for (int i = 0; i < n; i++)
    {
      if (q[i] != fac[i])
      {
        yes = false;
        break;
      }
    }

    if (yes)
    {
      break;
    }

    cnt++;

  } while (next_permutation(fac.begin(), fac.end()));  // 次の順列を生成

  b = cnt;

  cout << abs(a - b) << endl;

  return 0;
}

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

using i64 = int64_t;

map<i64, i64> prime_factor(i64 n) {
    map<i64, i64> res;
    for (i64 i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}

int main(){
    i64 a, b;
    cin >> a >> b;
    auto mp = prime_factor(a);
    i64 ans = 1;
    for(auto e: mp){
        if(b%e.first == 0)ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    if(k==1)
    {
        cout<<"OK"<<endl;
        return 0;
    }
    int flag=0;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag++;
            cout<<"OK"<<endl;
            return 0;
        }
    }
    if(!flag)
        cout<<"NG"<<endl;

}


Measured memory_bytes: 3620
def main():
    s = int(input())
    e = set([s])
    i = 1
    while True:
        i += 1
        s = f(s)
        if s in e:
            print(i)
            return
        e.add(s)
    
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3*n + 1
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    int ans = 0;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        if(h[i] >= K){
            ans++;
        }
    }    

    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int H, W, K;
string A[805];
int mc[805][805];

int main() {
        queue<Pi> que;
        fill_n(*mc, 805 * 805, INF);
        cin >> H >> W >> K;
        for (int i = 0; i < H; i++) {
                cin >> A[i];
                for (int j = 0; j < W; j++) {
                        if (A[i][j] == 'S') {
                                mc[i][j] = 0;
                                que.emplace(i, j);
                        }
                }
        }

        while (!que.empty()) {
                int y, x;
                tie(y, x) = que.front(); que.pop();
                for (int i = 0; i < 4; i++) {
                        int ny = y + dy[i], nx = x + dx[i];
                        if (ny < 0 || nx < 0 || H <= ny || W <= nx || A[ny][nx] == '#' || mc[ny][nx] != INF) continue;
                        mc[ny][nx] = mc[y][x] + 1;
                        que.emplace(ny, nx);
                }
        }

        int minv = INF;
        for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                        if (A[i][j] != '#') {
                                int dist = min(min(H - 1 - i, i), min(W - 1 - j, j));
                                chmin(minv, max(0, (mc[i][j] - 1) / K) + (dist + K - 1) / K + 1);
                        }
                }
        }
        cout << minv << endl;
        return (0);
}

Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int m,n,book[101]={0};
        int nowans,nowmin=0,nowmax=1500001;
        scanf("%d %d",&m,&n);
        if(m==0&&n==0)
            break;
        for(int i=0;i<n;i++)
            scanf("%d",&book[i]);
        for(int i=0;i<100;i++){
            int po=0;
            int dan[21]={0};
            nowans=(nowmin+nowmax)/2;
            for(int j=0;j<n+1;j++){
                if(j==n){
                    nowmax=nowans;
                    break;
                }
                if(dan[po]+book[j]<=nowans){
                    dan[po]+=book[j];
                    continue;
                }
                else if(book[j]>nowans){
                    nowmin=nowans;
                    break;
                }
                else if(dan[po]+book[j]>nowans){
                    po++;
                    if(po==m){
                        nowmin=nowans;
                        break;
                    }
                    dan[po]+=book[j];
                }
            }
        }
        printf("%d\n",nowans+1);
    }
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long n, std::vector<long long> a) {
    vll b = a;
    RSORT(b);
    rep(i, n) { cout << (a[i] == b[0] ? b[1] : b[0]) << endl; }
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
int x;
cin>>x;
if(x==1)
{
	cout<<0<<endl;
}
else
{
	cout<<1<<endl;
}
}




Measured memory_bytes: 3604
#include<bits/stdc++.h>
    #define ll long long
    using namespace std;
    int gcd(int a, int b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
    int main()
    {
    	int n;
    	cin>>n;
    	int sum=0;
    	for(int i=1; i<=n; i++)
    	{
    		for(int j=1; j<=n; j++)
    		{
    			for(int k=1; k<=n; k++)
    			{
    				sum+=gcd(gcd(i,j),k);
    			}
    		}
    	}
    	cout<<sum<<endl;
     
    }

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

int main() {
  int n,i,cnt=0;
  cin>>n;
  long long int a[n],tmp;
  for(i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  tmp=a[0];
  cnt++;
  for(i=1;i<n;i++){
    if(a[i]==tmp){
      cnt--;
      tmp=0;}
    else{
      cnt++;
      tmp=a[i];}
    
  }
  cout<<cnt;    
  
}

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

int main(){
  string N;
  bool flag_7 = false;
  cin >> N;
  rep(i, 3){
    if (N.at(i) == '7') flag_7 = true;
  }
  if (flag_7) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3604
N = int(input())
S = input()
cnt = 0
ans = 0
for i in range(N):
    if S[i] == "A":
        if cnt == 0:
            cnt += 1
        else:
            cnt = 1
    if S[i] == "B":
        if cnt == 1:
            cnt += 1
        else:
            cnt = 0
    if S[i] == "C":
        if cnt == 2:
            ans += 1
            cnt = 0
        else:
            cnt = 0

print(ans)

Measured memory_bytes: 3064
import sys
def parse_btree(s):
    l = r = -1
    paren = 0
    comma = -1
    if s == "(,)":
        return (["node"])
    if s == "":
        return (["None"])
    for i in range(len(s)):
        c = s[i]
        if c == "(":
            paren += 1
            if paren == 1 and r < 0:
                l = i
        elif c == "," and paren == 1:
            r = i
        elif c == ")":
            paren -= 1
    
    return ([parse_btree(s[l + 1:r]), parse_btree(s[r + 1:-1])])

def deparse_btree(bt):
    if bt == ["None"]:
        return ("")
    elif bt == ["node"]:
        return ("(,)")
    else:
        return ("(" + deparse_btree(bt[0]) + "," + deparse_btree(bt[1]) + ")")

def intersection_btree(s, t):
    if s == ["node"] and t != ["None"]:
        return (["node"])
    elif s != ["None"] and t == ["node"]:
        return (["node"])
    elif s == ["None"] or t == ["None"]:
        return (["None"])
    return [intersection_btree(s[0], t[0]), intersection_btree(s[1], t[1])]

def union_btree(s, t):
    if s == ["node"]:
        if t != ["None"]:
            return (t)
        else:
            return (["node"])
    elif s == ["None"]:
        if t != ["None"]:
            return (t)
        else:
            return (["None"])
    if t == ["node"]:
        if s != ["None"]:
            return (s)
        else:
            return (["node"])
    elif t == ["None"]:
        if s != ["None"]:
            return (s)
        else:
            return (["None"])
    return [union_btree(s[0], t[0]), union_btree(s[1], t[1])]

for line in sys.stdin:
    s = line.strip().split()
    a = parse_btree(s[1])
    b = parse_btree(s[2])
    if s[0] == 'i':
        c = intersection_btree(a, b)
        print(deparse_btree(c))
    elif s[0] == 'u':
        print(deparse_btree(union_btree(a, b)))


Measured memory_bytes: 4708
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;

static const int MAX = 1000;
int dp[MAX + 1][MAX + 1];

void lcs(string s1, string s2){
    for (int i = 0; i < MAX + 1; i++){
        for (int j = 0; j < MAX + 1; j++) dp[i][j] = 0;
    }
    
    for (int i = 0; i < s1.size(); i++){
        for (int j = 0; j < s2.size(); j++){
            if (s1[i] == s2[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
            else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        }
    }
    cout << dp[s1.size()][s2.size()] << endl;
}

int main(){
    int n;
    cin >> n;

    string s1, s2;
    for (int i = 0; i < n; i++){
        cin >> s1 >> s2;
        lcs(s1, s2);
    }

    return 0;
}


Measured memory_bytes: 7116
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,K;
cin >> N >> K;
vector<int> vec(N);
int len = 0;
for (int i = 0;i < N;i++) {
  cin >> vec.at(i);
}
sort(vec.begin(),vec.end());
reverse(vec.begin(),vec.end());
for (int i = 0;i < K;i++) {
len += vec.at(i);
}
cout << len << endl;

return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
      s: chars,
      t: chars,
      q: usize,
      abcds: [(usize1, usize1, usize1,usize1); q],
    }
    let n = s.len();
    let m = t.len();

    let mut dp1 = vec![vec![0i64; 2]; n+1];
    let mut dp2 = vec![vec![0i64; 2]; m+1];

    for i in 0..n {
        let idx = if s[i] == 'A' { 0 } else { 1 };
        dp1[i+1][idx] += dp1[i][idx] + 1;
        dp1[i+1][1-idx] += dp1[i][1-idx];
    }

    for i in 0..m {
        let idx = if t[i] == 'A' { 0 } else { 1 };
        dp2[i+1][idx] += dp2[i][idx] + 1;
        dp2[i+1][1-idx] += dp2[i][1-idx];
    }


    for i in 0..q {
        let (a, b, c, d) = abcds[i];

        let sa = dp1[b+1][0] - dp1[a][0];
        let sb = dp1[b+1][1] - dp1[a][1];

        let ta = dp2[d+1][0] - dp2[c][0];
        let tb = dp2[d+1][1] - dp2[c][1];


        let sn = sa + sb * 2;
        let tn = ta + tb * 2;

        if (tn - sn) % 3 == 0 {
            puts!("{}\n", "YES");
        } else {
            puts!("{}\n", "NO");
        }
    }
}


Measured memory_bytes: 20988
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		long A = scan.nextLong();
		long B = scan.nextLong();
		long C = scan.nextLong();
		long D = scan.nextLong();
		if(A+B >C+D){
			System.out.println("Left");
		}else if(A+B == C+D){
			System.out.println("Balanced");
		}else{
			System.out.println("Right");
		}
		
	}

}

Measured memory_bytes: 21844
N, L = map(int, input().split())
lst = [i + L for i in range(N)]
y = sum(lst)
a1 = 10**9
a2 = 10**9
for x in lst:
    if abs(x) < a1:
        a1 = abs(x)
        a2 = x
print(y - a2)

Measured memory_bytes: 3064
#include <iostream>
#include "algorithm"
using namespace std;
int main() {
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long int ans[4];
    ans[0] = a*c;
    ans[1] = a*d;
    ans[2] = b*d;
    ans[3] = b*c;
    sort(ans,ans+4);
    cout << ans[3] << endl;
    return 0;
}


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

int main() {
     int n , sum =0 , k ;

     cin >> n ;
     cin >> k ;
     int arr[ n ] ;

     for(int i =0 ; i < n ; ++i)cin >> arr[i] ;

     sort(arr , arr+n) ;
     for(int j =0 ; j < k ; j++)sum+=arr[j] ;

     cout << sum ;
}

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

deque<int> v;
int n, x;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d", &x);
		if (i&1) v.push_front(x);
		else v.push_back(x);
	}
	vector<int> ans(v.begin(), v.end());
	if (n&1) reverse(ans.begin(), ans.end());
	for (int u: ans) printf("%d ", u); printf("\n");
	return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+')
		cout<<a+b;
	else
		cout<<a-b;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, A, B; cin >> N >> A >> B;
    if (A > B || (N==1 && A != B)) {
        cout << 0 << endl;
        return 0;
    }

    ll low = (N - 1) * A + B;
    ll hig = A + (N - 1) * B;
    cout << hig - low + 1 << endl;
}


Measured memory_bytes: 3588
// AOJ 2769: 28
// 2018.1.6 bal4u@uu

#include <stdio.h>
#include <math.h>

#define HASHSIZ 1000033
typedef struct { long long p; char k; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int lookup(long long n)
{
	HASH *p = hash + (int)(n % HASHSIZ);
	while (p->p) {
		if (p->p == n) return p->k;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(long long n, char k)
{
	HASH *p = hash + (int)(n % HASHSIZ);
	while (p->p) {
		if (p->p == n) { p->k = k+1; return; }
		if (++p == hashend) p = hash;
	}
	p->p = n, p->k = k+1;
}

int sz;
long long p[524300];		// 2^19
int ans;

long long special[20] = {
8, 88, 888, 8888, 88888, 888888, 8888888, 88888888, 222888288,
888888888, 8888888888LL, 88888888888LL, 888888888888LL, 8888888888888LL,
88888888888888LL, 888888888888888LL, 8888888888888888LL,
88888888888888888LL, 888888888888888888LL, 0};

//#define getchar_unlocked()  getchar()
long long in()
{
	long long n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(long long n, int i, int s)
{
	int k, a, b, c;
	long long n1;

	if (n & 1) return 0;
	if ((k = lookup(n)) > 0) { if (s+k > ans) ans = s+k; return 1; }
	if (n == 4) { if (s+2 > ans) ans = s+2; return 1; }
	if (n < 15) return 0;

	b = (int)sqrt((double)n);
	for ( ; p[i] <= b; i++) {
		if (!p[i]) continue;
		if (n % p[i]) continue;
		c = (int)p[i];
		n1 = n / c, a = 1;
		while (1) {
			if (n1 % c || n1 < c) break;
			n1 /= c, a++;
		}
		if (n1 == 1) { if (s+a > ans) ans = s+a; return 1; }
		if (n1 < c) n1 *= c, a--;
		while (a >= 0) {
			if (calc(n1, i+1, s+a)) return 1;
			n1 *= c, a--;
		}
	}
	return 0;
}

void init()
{
	int i, j, k, k2;
	long long t;

	sz = 3;
	p[1] = 2, p[2] = 8, insert(2, 0), insert(8, 0);
	k = 1; for (i = 2; i <= 19; i++) {
		k2 = k << 1;
		for (j = k; j < k2; j++) {
			t = p[j]*10;
			t += 2, p[sz++] = t, insert(t, 0);
			t += 6, p[sz++] = t, insert(t, 0);
		}
		k = k2;
	}
	for (i = 0; special[i]; i++) insert(special[i], 2);
	p[2] = p[6] = p[14] = 0;
}

int main()
{
	long long n;

	init();
	n = in();
	calc(n, 1, 0);
	if (ans <= 0) puts("-1");
	else printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 21572
#include<stdio.h>
#include<string.h>

#define MAX 36

int main(){

  int i, j, a, b, num, min, ans1, ans2;
  int temp[MAX];

  char oridata[MAX][3];
  char data1[MAX][3];
  char data2[MAX][3];

  ans1 = 0;
  ans2 = 0;

  scanf("%d", &num);

  for(i = 0; i < num; i++){

    scanf("%s", &oridata[i]);

    data1[i][0] = oridata[i][0];
    data1[i][1] = oridata[i][1];
    data1[i][2]='\0';
    data2[i][0] = oridata[i][0];
    data2[i][1] = oridata[i][1];
    data2[i][2]='\0';
  }

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

    for(j = num - 1; j > i; j--){

      if(data1[j][1] < data1[j - 1][1]){
	
	temp[0] = data1[j - 1][0];
	temp[1] = data1[j - 1][1];

	data1[j - 1][0] =  data1[j][0];
	data1[j - 1][1] =  data1[j][1];

	data1[j][0] = temp[0];
	data1[j][1] = temp[1];
	
      }
	
    }

  }

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

    min = i;

    for(j = i + 1; j < num; j++){

      if(data2[min][1] > data2[j][1]){
	
	min = j;
	
      }
	
    }


    if(data2[i][1] != data2[min][1]){

      temp[0] = data2[min][0];
      temp[1] = data2[min][1];

      data2[min][0] =  data2[i][0];
      data2[min][1] =  data2[i][1];

      data2[i][0] = temp[0];
      data2[i][1] = temp[1];

    }
     
  }



  for(i = 0; i < num; i++){

    for(j = i + 1; j < num; j++){

      for(a = 0; a < num; a++){

	for(b = a + 1; b < num; b++){

	  if(oridata[i][1] == oridata[j][1] && (strcmp(oridata[i],data1[b])==0) && (strcmp(oridata[j],data1[a])==0))
	    ans1 = 1;

	}	

      }

    }

  }

  for(i = 0; i < num; i++){

    for(j = i + 1; j < num; j++){

      for(a = 0; a < num; a++){

	for(b = a + 1; b < num; b++){

	  if(oridata[i][1] == oridata[j][1] && (strcmp(oridata[i],data2[b])==0) &&( strcmp(oridata[j],data2[a])==0)) 
	    ans2 = 1;

	}	

      }

    }

  }

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

    printf("%c%c ", data1[i][0],data1[i][1]);

  }
   
  if(ans1 == 0)
    printf("%c%c\nStable\n", data1[i][0], data1[i][1]);
  else
    printf("%c%c\nNot stable\n", data1[i][0], data1[i][1]);


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

    printf("%c%c ", data2[i][0],data2[i][1]);

  }

  if(ans2 == 0)
    printf("%c%c\nStable\n", data2[i][0], data2[i][1]);
  else
    printf("%c%c\nNot stable\n", data2[i][0], data2[i][1]);

  return 0;

}

Measured memory_bytes: 608
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <functional>
#include <time.h>
#include <math.h>

using namespace std;


int main() {

	int n;
	int t = 0;
	

	cin >> n;
	vector<int> d(n);

	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int k = 0; k < n; k++) {
			for (int j = k+1; j < (int)(d.size()); j++) {
				t += d[k] * d[j];
			}
		
	}

	cout << t;


}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.next();
        long n = Long.parseLong(line);
        for (int b = 1; b < 63; b <<= 1) {
            n |= (n >>> b);
        }
        System.out.println(n);
    }
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  map<long, long> mp{};
  for (int i = 0; i < N; i++)
  {
    long A; cin >> A;
    mp[A]++;
  }
  long B[100005], C[100005];
  for (int j = 0; j < M; j++)
    cin >> B[j] >> C[j];
  
  for (int j = 0; j < M; j++)
  {
    long b = B[j], c = C[j];
    while (b > 0)
    {
      long num = mp.begin() -> first;
      long cnt = mp.begin() -> second;
      if (num < c && cnt <= b)
      {
        mp.erase(num);
        mp[c] += cnt;
        b -= cnt;
      }
      else if (num < c && cnt > b)
      {
        mp[num] -= b;
        mp[c] += b;
        b = 0;
      }
      else break; // num >= c
    }
  }
  
  long sum = 0;
  for (auto p : mp)
  {
    long x = p.first, y = p.second;
    sum += x * y;
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vi vector<int>
#define sl set<ll>
#define sc set<char>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mpi map<ll,ll>
#define mpc map<char,ll>
#define forn(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf        1000000000000
#define MOD        1000000007


int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	//dp[i][j] denotes the number of ways to distribute j candies to children from 1 to i
    ll dp[n+1][k+1];
    ll prefix[n+1][k+1];
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=k;j++){
			if(j==0 || i==0){
				dp[i][j]=1;
				prefix[i][j]=1;
			}
			else{
				dp[i][j]=prefix[i-1][j]-((j-a[i]-1>=0)?prefix[i-1][j-a[i]-1]:0);
			    if(dp[i][j]<0)
			    dp[i][j]+=MOD;
			    prefix[i][j]=(prefix[i][j-1]+dp[i][j])%MOD;
			}
		}
	}
	cout<<dp[n][k];
}
		


Measured memory_bytes: 158080
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // 解説pdfとyoutube確認後

        Scanner sc = new Scanner(System.in);
        String[] NK = sc.nextLine().split(" ");
        int N = Integer.parseInt(NK[0]);
        int K = Integer.parseInt(NK[1]);
        String S = sc.nextLine();

        int happy = 0;
        for (int i = 1; i < N; i++) {
            if (S.charAt(i) == S.charAt(i - 1)) {
                happy++;
            }
        }
        int happiest = N - 1;
        int changeHappy = happy + 2 * K;
        int ans = Math.min(happiest, changeHappy);
        System.out.println(ans);
    }
}


Measured memory_bytes: 27348
import copy
import itertools
h,w,k = map(int,input().split())
c = [[0]*w]*h
for i in range(h):
	c[i] = input()
	c[i] = list(c[i])

counter = 0	
ans = 0
b = 0
for (i,j) in itertools.product(range(h), range(w)):
	if c[i][j] == '#':
		b += 1

for hl in range(h+1):
	for wl in range(w+1):
		for	hi in itertools.combinations(range(h),hl):
			for wj in itertools.combinations(range(w),wl):
				C = copy.deepcopy(c)
				for i in hi:
					for j in range(w):
						if C[i][j] == '#':
							counter += 1
							C[i][j] = '.'
				for j in wj:
					for i in range(h):
						if C[i][j] == '#':
							counter += 1
				if b - counter == k:
					ans += 1
				counter = 0
print(ans)

Measured memory_bytes: 9280
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] a = new long[N];
		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		sc.close();
		int r = 1;
		{
			long tempk = K;
			while((tempk = tempk/2) != 0) r++;
		}
		ArrayList<Long> ks = new ArrayList<Long>();
		ks.add(K);
		for(int i=0; i<=r; i++) {
			long tempk = K;
			if((tempk>>>i)%2==0) continue;
			tempk = tempk & ~(pow(2, i));
			if(i!=0) {
				tempk = tempk | (pow(2, i) -1);
			}
			ks.add(tempk);
		}
		long ans = 0;
		for(int i=0; i<ks.size(); i++) {
			long tempans = 0;
			long k = ks.get(i);
			for(int j=0; j<N; j++) {
				if((a[j]|k) == k) {
					tempans += b[j];
				}
			}
			ans = Math.max(ans, tempans);
		}
		System.out.println(ans);
		
	}
	
	static long pow(long a, long r) {
		if(r==0) return 1;
		if(r==1) return a;
		if(r==2) return a*a;
		if(r%2==0) {
			return pow(pow(a, r/2), 2);
		} else {
			return pow(a, r-1) * a;
		}
	}
}


Measured memory_bytes: 94064
#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()
{
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    ll x;
    cin>>x;
    ll ans=0;
    ans+=(x/500)*1000;
    x-=(x/500)*500;
    ans+=(x/5)*5;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d %d",$n, $k);
$values = explode(" ", trim(fgets(STDIN)));

$max =0;
for($i=0;$i<=$k;$i++){
    $left=[];
    for($ii=0;$ii<$i;$ii++){
        $left[]=$values[$ii] ?? 0;
    }
    if($k > $n){
        $jend = $n - $i;
    }else{
        $jend = $k - $i;
    }
    for($j=0;$j<=$jend;$j++){
        $right = [];

        for($jj=0;$jj<$j;$jj++){

            $right[]=$values[$n - 1 - $jj] ?? 0;
        }
        $gomi = $k - $i -$j;
        $array = [];
        $array = array_merge($left,$right);
        sort($array);
        for($l=0;$l<$gomi;$l++){
            if(!isset($array[$l])){
                break;
            }
            if($array[$l] < 0){
                $array[$l] =0;
            }else{
                break;
            }
        }
        $max = max($max, array_sum($array));
    }
}

echo $max;

Measured memory_bytes: 4856
#include<stdio.h>
#include<string.h>
main(){
  char str;
  while(~scanf("%c",&str)){
    if(toupper(str)!=str)
      printf("%c",toupper(str));
    else if(tolower(str)!=str)
      printf("%c",tolower(str));
    else
      printf("%c",str);
  }
  return 0;
}

Measured memory_bytes: 524
//C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 20;
ll raw[maxn][maxn],c[maxn];
int main(){
	ll n,m,x;
	cin >> n >> m >> x;
	for(int i = 1;i <= n;i++){
		cin >> c[i];
		for(int j = 1;j <= m;j++)cin >> raw[i][j];
	}
	ll ans = 1e9;
	for(int i = 0;i <= (1<<n)-1;i++){
//		cout << endl;
		auto qwq = bitset<32>(i);
		bool ok = 1;
		ll tmp = 0;
		for(int j = 0;j < n;j++)if(qwq[j])tmp += c[j+1];
		for(int k = 1;k <= m;k++){
			ll yay = 0;
			for(int j = 0;j < n;j++)if(qwq[j])yay += raw[j+1][k];
			if(yay < x)ok = 0;
//			cout << yay << endl;
		}
		if(ok)ans = min(ans,tmp);
	}
	if(ans == 1e9)ans = -1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;


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;}

const ll INF=1e9+7;


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll cnt=0;
    while(a%2==0 && b%2==0 && c%2==0){
        ll p=(a+b)/2,q=(b+c)/2,r=(c+a)/2;
        a=q;
        b=r;
        c=p;
        cnt++;
        if(cnt>=100000){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t ans;
  if ((a%2 == 0) || (b%2 == 0) || (c%2 ==0)) {
    ans = 0;
  } else {
    ans = min(min(a*b, b*c), min(b*c, c*a));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 998244353
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

int isprime(int x)
{
	for (int i=2;i*i<=x;i++)
		if (x%i==0) return 0;
	return 1;
}
 
 bool cmp(ii a,ii b){
	return a.se<b.se;
}
void solve()
{	
	string inp;
	cin>>inp;
	for (auto x:inp){
		if (x=='7') {
			cout<<"Yes";
			return;
		}
	}
	cout<<"No"<<endl;
}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}

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

vector<int>E[101010];
int used[101010];
int N;

int ok = 1;
void dfs(int now, int p) {
	int cnt = 0;
	fore(x, E[now]) {
		if (x != p){
			dfs(x,now);
			cnt += 1 - used[x];
		}
	}
	if (cnt == 0)return;
	else if (cnt == 1) { used[now] = 1; return; }
	else ok = 0;
}


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

	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		E[a].pb(b);
		E[b].pb(a);
	}

	dfs(0,-1);

	if (!ok)puts("First");
	else if (used[0] == 0)puts("First");
	else puts("Second");


	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    string a,b,c;
    cin >> a >> b >> c;
    int ans=0;
    rep(i,N){
        int cn=0;
        if(a[i]==b[i])cn++;
        if(a[i]==c[i])cn++;
        if(b[i]==c[i])cn++;
        if(cn==0)ans+=2;
        else if(cn==1)ans+=1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb emplace_back
using ll = long long;
const int INF = 0x3f3f3f3f;
string s, t;

const int MAX_N = 3003;
int dp[MAX_N][MAX_N];

void solve()
{
	const int N=s.length(), M=t.length();
	memset(dp, 0, sizeof(dp));
	for(int i=1;i<=N;++i)for(int j=1;j<=M;++j){
		if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
	}
	string ans;
	int i=N, j=M;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){ 
			ans+=s[i-1];
			i--,j--;
		}else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}else{
			j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

int main()
{
	cin >> s >> t;
	solve();
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int dp[101][4][4][4];

int main() {
    int n; cin >> n;
    int mod = 1e9+7;
    dp[0][3][3][3] = 1;
    rep(len, n) {
        rep(c1, 4) {
            rep(c2, 4) {
                rep(c3, 4) {
                    if (dp[len][c3][c2][c1] == 0) continue;
                    rep(c0, 4) {
                        if (c1==2&&c2==0&&c0==1) continue;
                        if (c1==1&&c2==0&&c0==2) continue;
                        if (c1==0&&c2==2&&c0==1) continue;
                        if (c1==2&&c3==0&&c0==1) continue;
                        if (c2==2&&c3==0&&c0==1) continue;
                        dp[len+1][c2][c1][c0] += dp[len][c3][c2][c1];
                        dp[len+1][c2][c1][c0] %= mod;                        
                    }
                }
            }
        }
    }
    int ans = 0;
    rep(c1, 4) {
        rep(c2, 4) {
            rep(c3, 4) {
                ans += dp[n][c3][c2][c1];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let v: Vec<u32> = input.trim().split_whitespace()
        .map(|x| x.parse().unwrap()).collect();
    //println!("{}", v[0]+1);
    let mut ans = 0;
    for mut x in 1..v[0]+1 {
//            println!("{}", x);
        let mut sum = 0;
        let mut tmp = x;
        loop {
//            println!("tmp:{}", tmp);
            sum += tmp % 10; 
//            println!("sum:{}", sum);
            if (tmp / 10 == 0) {
                break;
            }
            tmp = tmp / 10;
        }
        if (sum >= v[1] && sum <= v[2]){
            ans += x;
//            println!("ans:{}", ans);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n ; cin>> n;
    bool ok= true;
    string tmp ; 
    vector <string> words(n);
    for (int i=0;i<n;i++){
        string s; cin>>s;
       
        //cout<<s.at(0)<<'*'<<tmp[tmp.size()-1]<<endl;
        if(i>=1&&tmp[tmp.size()-1]!=s.at(0)){
            ok=false;
        }
        for(int j=0;j<n;j++){
            if(words[j]==s) ok=false;
        }
        words[i]=s;
        tmp=s;
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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


    int n;
    cin >> n;
    vector<int> X(n);
    vector<int> Y(n);
    vector<long long> P(n);
    for (int i = 0; i < n; ++i) {
        cin >> X[i] >> Y[i] >> P[i];
    }

    int N = 1 << n;
    const long long INF = 1LL << 50;
    vector<vector<long long>> DX(N, vector<long long>(n, INF));
    vector<vector<long long>> DY(N, vector<long long>(n, INF));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < n; ++j) {
            DX[i][j] = min(DX[i][j], abs(0LL + X[j]));
            DY[i][j] = min(DY[i][j], abs(0LL + Y[j]));

            for (int k = 0; k < n; ++k) {
                if ((i >> k) & 1) {
                    DX[i][j] = min(DX[i][j], abs(0LL + X[j] - X[k]));
                    DY[i][j] = min(DY[i][j], abs(0LL + Y[j] - Y[k]));
                }
            }
        }
    }

    vector<long long> res(n + 1, INF);

    for (int i = 0; i < N; ++i) {
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) {
                ++cnt;
            }
        }

        for (int s = i; s >= 0; --s) {
            s &= i;
            long long ans = 0;
            for (int j = 0; j < n; ++j) {
                // if ((i >> j) & 1) {
                //     continue;
                // }
                ans += min(DX[s][j], DY[s ^ i][j]) * 1LL * P[j];
            }
            res[cnt] = min(res[cnt], ans);
        }


    }



    for (int i = 0; i <= n; ++i) {
        cout << res[i] << '\n';
    }


    return 0;
}

Measured memory_bytes: 12932