akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <string>
#include <iostream>
using namespace std;
int main(){
	int i,r;
	string s;
	map<char,int>m;
	for(m['I']=1,m['V']=5,m['X']=10,m['L']=50,m['C']=100,m['D']=500,m['M']=1000;getline(cin,s);cout<<r<<endl)for(i=r=0;i<s.size();i++)r+=m[s[i]]*(m[s[i]]<m[s[i+1]]?-1:1);
}

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


int main()
{
	    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,k;
    cin>>n>>k;
    vector<ll>v,v1(n,INT_MAX);
          ll t;
          for(int i=0;i<n;i++)
          {
          	cin>>t;
          	v.push_back(t);
          }
          v1[0]=0;
         
           ll p,h;
         for(int i=1;i<n;i++)
         {
         	p=i-1,h=k-1;
         	  while(p>=0&&h>=0)
         	  {
         	  	  v1[i]=min(v1[i],v1[p]+abs(v[p]-v[i]));
         	  	  p--;
         	  	  h--;
         	  }
         	  // cout<<v1[i]<<" "<<i<<endl;
         }
         cout<<v1[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,X;
  cin>>N>>X;
  vector<int> s(N);
  for(int i=0;i<N;i++){
    cin>>s[i];
  }
  
  vector<vector<ll> > dp(N+1,vector<ll>(X+1,0));
  for(int i=0;i<=X;i++){
    dp[0][i]=i;
  }

  sort(s.begin(),s.end());

  for(int i=0;i<N;i++){
    for(int j=0;j<=X;j++){
      dp[i+1][j] += dp[i][j%s[i]];
      dp[i+1][j] %= MOD;
      dp[i+1][j] += dp[i][j]*i%MOD;
      dp[i+1][j] %= MOD;
    }
  }

  cout<<dp[N][X]<<endl;
}


Measured memory_bytes: 158592
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
int main()
{
    ll t,n,i,j,k,l,r,mn=0, mx=0;
    sl(n);
    ll xr=0;
    for(int i=0; i<n; i++)
    {
        sl(a[i]); xr^=a[i];
    }

    for(int i=0; i<n; i++)
    {
        printf("%lld ",xr^a[i]);
    }
}

Measured memory_bytes: 5336
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7
// https://atcoder.jp/contests/abc167/tasks/abc167_c
int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));

    rep(i, 0, n) {
        cin >> c[i];
        rep(j, 0, m) {
            cin >> a[i][j];
        }
    }

    int ans = INT_MAX;
    for (int i = 1; i < pow(2, n); i++) {
        int sum = 0;
        vector<int> effect(m, 0);
        int cnt = 0;
        int sub = i;
        while (sub > 0) {
            if (sub % 2 == 1) {
                sum += c[cnt];
                rep(k, 0, m) {
                    effect[k] += a[cnt][k];
                }
            }
            sub /= 2;
            cnt++;
        }

        bool flag = true;
        rep(k, 0, m) {
            if (effect[k] < x) flag = false;
        }
        if (flag) {
            ans = min(ans, sum);
        }
    }

    if (ans == INT_MAX) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 4016
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        d1 = random.randint(0,D-19)
        d2 = random.randint(d1+1,d1+18)
        if d1 == d2:
            continue
        tmp_d1 = ans[d1]
        tmp_d2 = ans[d2]
        ans[d1] = tmp_d2
        ans[d2] = tmp_d1
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp_d1
            ans[d2] = tmp_d2
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()

"""
101283559

"""

Measured memory_bytes: 9688
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

map<string,int> mp;

void out(string s){
    cout << s << " x " << mp[s] << endl;
}

int main(){
    ll n; cin >> n;
    mp["AC"] = 0, mp["TLE"] = 0, mp["WA"] = 0, mp["RE"] = 0;
    rep(i,n){
        string s; cin >> s;
        mp[s]++;
    }
    out("AC");
    out("WA");
    out("TLE");
    out("RE");
}

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

vector<pair<int, int>> A;

int main() {
    int N, M, a, b;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; i++) {
        scanf("%d %d", &a, &b);
        A.push_back(make_pair(b, a));
    }
    sort(A.begin(), A.end());

    int maxb = 0;
    int ans = 0;
    for (int i = 0; i < A.size(); i++) {
        b = A[i].first;
        a = A[i].second;
        if (a >= maxb) {
            ans++;
            maxb = max(b, maxb);
        }
    }

    printf("%d\n", ans);
    return 0;
}

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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int X = nextInt();

        int h500 = X/500;
        X = X % 500;
        int h5 = X/5;
        
        int ans = h500 * 1000 + h5 * 5;
         
        System.out.println(ans);
     
    }
    
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32768
function main()
  
  S = split(chomp(readline()), "")
  
  check = false
  
  for i in 1:length(S), j in 1:length(S)
    
    if S[i] == S[j] && i != j
      check = true
    end
    
  end
  
  if check == true
    println("no")
  else
    println("yes")
  end
  
end
 
main()

Measured memory_bytes: 111796
#include<bits/stdc++.h>
#define int long long
#define log(x,b) (log(x)/log(b))
using namespace std;

string s[101];

int32_t main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        cout<<s[i]<<endl;
        cout<<s[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Int = long long;
Int solve() {
    Int N, H;
    cin >> N >> H;
    vector<Int> a(N), b(N);
    for (Int i = 0; i < N; i++) cin >> a[i] >> b[i];
    sort(b.rbegin(), b.rend());
    auto ma = *max_element(a.begin(), a.end());
    Int ans = 0, damage = 0;
    for (Int i = 0; i < b.size(); i++) {
        if (b[i] < ma) break;
        ans++;
        damage += b[i];
        if (damage >= H) return ans;
    }
    ans += (H - damage) / ma + ((H - damage) % ma != 0);
    return ans;
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 1792
import sys
s=input()
while(s):
  if(s[-7:]=="dreamer"):
    s=s[:-7]
  elif(s[-5:]=="dream"):
    s=s[:-5]
  elif(s[-6:]=="eraser"):
    s=s[:-6]
  elif(s[-5:]=="erase"):
    s=s[:-5]
  else:
    print("NO")
    sys.exit()
print("YES")


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back
#define eb emplace_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    constexpr ll a = 1000000000;
    ll n = in(), k = in(), s = in();
    vll ans;
    ans.reserve(n);
    rep(i, k) ans.pb(s);
    rep(i, n - k) ans.pb(s == a ? a - 1 : a);

    rep(i, n) cout << ans[i] << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n,A,B,C;
int l[10];
int ans=1e9;

void dfs(int cost,int num ,int a, int b, int c){
  if(num==n){
    if(a==0||b==0||c==0)return ;
    cost+=abs(a-A)+abs(b-B)+abs(c-C)-30;
    chmin(ans,cost);
    return;
  }
  dfs(cost+10,num+1,a+l[num],b,c);
  dfs(cost+10,num+1,a,b+l[num],c);
  dfs(cost+10,num+1,a,b,c+l[num]);
  dfs(cost,num+1,a,b,c);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> n >> A >> B >> C;
  rep(i,n) cin >> l[i];
  
  dfs(0,0,0,0,0);
  cout << ans << endl;
  return 0;     
}


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

int main(){
  int A[3][3];

  int n;

  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> A[i][j];
    }
  }
  cin >> n;
  int b[n];
  for(int i=0; i<n; i++){
    cin >> b[i];
  }

  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<n; k++){
        if(A[i][j]-b[k] == 0){
          A[i][j] = 0;
        }
      }
    }
  }

  for(int i=0; i<3; i++){
    if(A[i][0] == A[i][1] && A[i][0] == A[i][2]){
      cout << "Yes";
      return 0;
    }
  }

  for(int j=0; j<3; j++){
    if(A[0][j] == A[1][j] && A[0][j] == A[2][j]){
      cout << "Yes";
      return 0;
    }
  }
  if(A[0][0] == A[1][1] && A[0][0] == A[2][2]){
    cout << "Yes";
    return 0;
  }

  if(A[0][2] == A[1][1] && A[0][2] == A[3][0]){
      cout << "Yes";
      return 0;
  }

  cout << "No";

}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt(); //number of spot
      	int T = scan.nextInt(); //state temperature
      	int A = scan.nextInt(); // temperature that princess wants
      	int[] H = new int[n]; // list of height
      	for (int i = 0; i < n; i++){
        	H[i] = scan.nextInt();
        }
      	double[] t = new double[n]; //list of temperature
      	for (int i = 0; i < n; i++){
        	t[i] = T - 0.006 * H[i];
        }
      	double rest = Math.abs(t[0]-A);
      	int key = 0;
      	for (int i = 0; i < n; i++){
        	if(rest > Math.abs(t[i]-A)){
            	rest = Math.abs(t[i]-A);
              	key = i;
            }
        }
      	System.out.print(key + 1);
    }
}

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

int main(){
  string s; cin >> s ;
  string dest="";
  rep(i, s.size()){
    
    dest+="x";
  }
  cout << dest;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

struct edge{
    int to,cost,id;
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<vector<edge>> g(n);
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[a].push_back({b,c,int(i)});
        g[b].push_back({a,c,int(i)});
    }
    vector<bool> used(m,false);
    auto dijkstra=[&](int st,int en){
        priority_queue<Pi,vector<Pi>,greater<Pi>> que;
        vector<int> dist(n,INF);
        vector<Pi> pre(n);
        dist[st]=0;
        que.push({0,st});
        while(!que.empty()){
            auto hoge=que.top();
            que.pop();
            int v=hoge.se,d=hoge.fi;
            if(dist[v]<d) continue;
            for(auto e:g[v]){
                if(chmin(dist[e.to],dist[v]+e.cost)){
                    que.push({dist[e.to],e.to});
                    pre[e.to]=Pi(v,e.id);
                }
            }
        }
        for(int v=en;v!=st;v=pre[v].fi){
            used[pre[v].se]=true;
        }
    };
    rep(i,n)FOR(j,i+1,n){
        dijkstra(i,j);
    }
    int ans=0;
    rep(i,m) if(!used[i]) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

const ll mod = 1e9+7;
struct mint
{
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod){}
    mint operator-() const {return mint(-x);}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    ll val(){ return x; }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x;}
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
};

struct Func {
    const ll mod;
    vector<ll> fact, ifact;
    ll mod_pow(ll x, ll n){
        ll ans = 1;
        while(n){
            if(n & 1) ans = ans*x%mod;
            x = x*x%mod;
            n >>= 1;
        }
        return ans;
    }
    Func(ll n, ll mod) : fact(n+1), ifact(n+1), mod(mod) {
        fact[0] = 1;
        for(ll i = 1; i <= n; i++) fact[i] = fact[i-1] * i % mod;
        ifact[n] = mod_pow(fact[n], mod-2);
        for(ll i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i % mod;
    }
    ll comb(ll n, ll k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
    ll perm(ll n, ll k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k]%mod;
    }
};

int main(){
    int k; string s; cin >> k >> s;
    int n = s.size();

    Func f = Func(n+k, mod);
    mint p25 = 25;
    mint p26 = 26;
    mint ans = 0;
    for(int i = 0; i <= k; i++) {
        mint tmp = f.comb(n+k-i-1, n-1);
        tmp *= p26.pow(i);
        tmp *= p25.pow(k-i);
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35600
#include<bits/stdc++.h>
using namespace std;
int m,a,b,p[205],c,d;
 
int main(){
  while(1){
    cin>>m>>a>>b;
    if(!m&&!a&&!b)break;
    c=d=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=b-1;i>=a-1;i--)
      if(p[i]-p[i+1]>c)c=p[i]-p[i+1],d=i+1;
    cout<<d<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#define REP(i, n) for(int i = 1; i < n+1; i++)
using ll = long long;
using namespace std;



int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n, s, t, ans=0, cst=60, tmp=0;
  cin >> n;
  ll tmp1[15] = {0,1,3,3,7,7,7,14,22,22,22,33,33,46,60};
  ll tmp2[15] = {0,1,2,2,3,3,3,4,5,5,5,6,6,7,8};

  s = n / 15;
  t = n % 15;

  ans = cst*s*s + tmp1[t] + tmp2[t]*15*s;

  cout << ans << endl;
   
}


Measured memory_bytes: 3652
n, m = map(int, input().split())
lmax, rmin = map(int, input().split())
for i in range(m-1):
  l, r = map(int,input().split())
  if l > lmax:
    lmax = l
  if r < rmin:
    rmin = r
if (rmin - lmax >= 0):
  print(rmin - lmax + 1)
else:
  print('0')

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace abc122_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var mod = (int)Math.Pow(10, 9) + 7;

      var dp = new int[n + 1, 4, 4, 4];

      dp[0, 3, 3, 3] = 1;

      for (var len = 0; len < n; len++)
      {
        for (var c1 = 0; c1 < 4; c1++)
        {
          for (var c2 = 0; c2 < 4; c2++)
          {
            for (var c3 = 0; c3 < 4; c3++)
            {
              if (dp[len, c1, c2, c3] == 0)
              {
                continue;
              }

              for (var c4 = 0; c4 < 4; c4++)
              {
                if ((c2 == 0 && c3 == 1 && c4 == 2) || (c2 == 1 && c3 == 0 && c4 == 2) || (c2 == 0 && c3 == 2 && c4 == 1) || (c1 == 0 && (c2 == 1 || c3 == 1) && c4 == 2))
                {
                  continue;
                }

                dp[len + 1, c2, c3, c4] += dp[len, c1, c2, c3];
                dp[len + 1, c2, c3, c4] %= mod;
              }
            }
          }
        }
      }

      var ans = 0;

      for (var c1 = 0; c1 < 4; c1++)
      {
        for (var c2 = 0; c2 < 4; c2++)
        {
          for (var c3 = 0; c3 < 4; c3++)
          {
            ans += dp[n, c1, c2, c3];
            ans %= mod;
          }
        }
      }

      Console.WriteLine(ans);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 11316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int r,a,b,c,d,ans=0;
	cin>>r;
	a=r/1000;
	b=(r/100)%10;
	c=(r%100)/10;
	d=r%10;
	for(int i=43;i<=45;i+=2)
		for(int j=43;j<=45;j+=2)
			for(int k=43;k<=45;k+=2)
			{
				ans=a;
				if(i==43) ans+=b;
				else ans-=b;
				if(j==43) ans+=c;
				else ans-=c;
				if(k==43) ans+=d;
				else ans-=d;
				if(ans==7)
				{
					cout<<a<<char(i)<<b<<char(j)<<c<<char(k)<<d<<"=7"<<endl;
					return 0;	
				} 
			}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No");
    
    
    
    return 0;
}

Measured memory_bytes: 3596
itemCount = int(input())
items = list(map(int, input().split(" ")))

def bubbleSort(items, itemCount):
    hasPrevious = True
    swapCount = 0
    while hasPrevious:
        hasPrevious = False
        for index in reversed(range(1, itemCount )):
            if items[index] < items[index - 1]:
                items[index], items[index - 1] = [items[index - 1], items[index]]
                hasPrevious = True
                swapCount += 1
    print(" ".join(map(str, items)))
    print(swapCount)

bubbleSort(items, itemCount)

Measured memory_bytes: 7708
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> row(h, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				break;
			}
		}
	}
    
    vector<bool> col(w, false);
    for (int j = 0; j < w; j++) {
        for (int i = 0; i < h; i++) {
            if (a[i][j] == '#') {
                col[j] = true;
                break;
            }
        }
    }
 
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int K;
  string S;
  cin >> K >> S;
  if(S.size()<=K)cout << S;
  else{
    rep(i,K){
      cout << S.at(i);
    }
    cout << "..."<< endl;
  }
  return 0;
}


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

int main(int argc, char *argv[]){
  int s;
  cin >> s;
  unsigned int data[9];
  for (int i = 0; i < s; i++) {
    unsigned int ans = 0;
    for (int j = 0; j < 9; j++) {
      scanf("%x", &data[j]);
    }
    for (int j = 0; j < 32; j++) {
      unsigned int sum = 0;
      for (int k = 0; k < 8; k++) {
        sum += data[k]^ans;
      }
      if((sum&(1<<j)) != (data[8]&(1<<j)))
        ans |= 1<<j;
    }
    printf("%x\n", ans);
  }
  return 0;
}

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

void solve()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> a(m);
	for(auto&& i : a)
	{
		cin >> i;
	}
	int ans1 = 0, ans2 = 0;
	for(int i = x; i < n; i++)
	{
		if (binary_search(begin(a), end(a), i)) ans1++;
	}
	for(int i = x; i > 0; i--)
	{
		if (binary_search(begin(a), end(a), i)) ans2++;
	}
	cout << min(ans1, ans2) << "\n";
}

int main()
{
	solve();
}


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

int main(){
  int n; cin>>n;
  int tmp;
  vector< pair<int,int> > aa;
  for(int i=0;i<n;i++){
    cin >>tmp;
    aa.push_back(make_pair(tmp,i+1));
  }
  sort(aa.begin(),aa.end());
  for(int i=0;i<n;i++){
    if(i) cout <<" ";
    cout <<aa[i].second;
  }
  cout <<endl;
}

Measured memory_bytes: 1780
#include<iostream>
using namespace std;
int main(){
    int s1s2s3;
    cin>>s1s2s3;
    int a=0;
    if(s1s2s3%10==1){
      a++;
    }
    if((s1s2s3/10)%10==1){
      a++;
    }
    if((s1s2s3/100)%10==1){
      a++;
    }
    cout<<a;
   return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	
	int n;
	string s,a,b,c;
	int count;
	
	while(cin>>n,n){
		cin>>s;
		for(int m=n;m>0;m--){
			a=b=c="";
			
			for(int i=0;i<s.size();i++){
				b=c="";
				c+=s[i];
				count=1;
				for(int j=i,k=1;j+1<s.size() && k;){
					if(s[j]==s[j+1]){
						j++;
						count++;
						i++;
					}
					else k=0;
				}
				while(count>0){
					b+=(count%10+48);
					count/=10;
				}
				reverse(b.begin(),b.end());
				a+=b;
				a+=c;
				//cout<<"*"<<b<<" "<<c<<endl;
				//cout<<b<<c<<endl;
				
			}
			//cout<<"#"<<s<<endl;
			s=a;
		}
		
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024 * 256;
const LL mod = 1e9 + 7;

LL dp[M], T[M];
int n, last[M];

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	scanf("%d", &n);
	FOR(i, 1, n)
	{
		scanf("%lld", T + i);
	}
	dp[1] = 1;
	last[T[1]] = 1;
	FOR(i, 2, n)
	{
		if (T[i] == T[i - 1])
		{
			dp[i] = dp[i - 1];
		}
		else
		{
			dp[i] = (dp[i - 1] + dp[last[T[i]]]) % mod;
		}
		last[T[i]] = i;
		debug(i, T[i], dp[i]);
	}
	
	printf("%lld\n", dp[n]);
	return 0;
}

Measured memory_bytes: 4608
mod=10**9+7
s=input()
dp1=[1]+[0]*12
for i in range(len(s)):
    dp2=[0]*13
    if s[i]!="?":
        p=int(s[i])
        for j in range(13):
            dp2[(j*10+p)%13]+=dp1[j]
    
    else:
        for p in range(10):
            for j in range(13):
                dp2[(j*10+p)%13]+=dp1[j]
    dp1=[dp2[j]%mod for j in range(13)]

print(dp1[5])

Measured memory_bytes: 43372
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,a[55],mx=51,mi=52,cnt;
int main()
{
	cin>>n;
	a[mx]=-1e9;
	a[mi]=1e9;
	if (n==1)
	{
		cout<<0;
		return 0;
	}
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]>a[mx]) mx=i;
		if (a[i]<a[mi]) mi=i;
	}
	cout<<2*n<<endl;
	if (abs(a[mx])>abs(a[mi]))
	{
		cout<<mx<<' '<<n<<endl;
		cout<<mx<<' '<<n<<endl;
		cout<<n<<' '<<n<<endl;
		cnt=3;
		for (i=2;i<n;i++)
		{
			cout<<n<<' '<<i<<endl;cnt++;
			if (a[i]>a[i+1]) {cout<<n<<' '<<n<<endl;cnt++;}
		}
		while (cnt++<2*n)
		{
			cout<<n<<' '<<n<<endl;
		}
	}
	else
	{
		cout<<mi<<' '<<1<<endl;
		cout<<mi<<' '<<1<<endl;
		cout<<1<<' '<<1<<endl;
		cnt=3;
		for (i=n-1;i>1;i--)
		{
			cout<<1<<' '<<i<<endl;cnt++;
			if (a[i]<a[i-1]) {cout<<1<<' '<<1<<endl;cnt++;}
		}
		while (cnt++<2*n)
		{
			cout<<1<<' '<<1<<endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
  int N, K;
  cin >>N >> K;
  int P[N];
  
  for(int i=0;i<N;i++){
    cin >> P[i]; 
  }
  
  sort(P,P+N);
  
  int O=0;
  for(int i=0;i<K;i++){
    O=O+P[i];
  }
  cout <<O;
  
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
const ll ARR = 1e5 + 2;
const ll INF = 1e4+2;
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define gof for(long long int i = 0 ; i < n ; i++)

void solve(){

	ll n;
	cin >> n;
	ll a[ARR];
	gof cin >> a[i];
	ll dp[ARR] = {INF};
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for(ll i = 2 ; i < n ; i++){
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
	}
	cout << dp[n-1] << endl;
	return;
}

int main(){
	ll t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

int n;
char x[200001];
long long d[200001];
long long e[200001];
int f[200000];

int main()
{
    ios_base::sync_with_stdio(false);

    for (int i = 0; i < 200000; i++)
    {
        int j = i;
        int c = 0;
        while (j)
        {
            int k = j;
            int p = 0;
            while (k)
            {
                if (k & 1) p++;
                k >>= 1;
            }
            j = j % p;
            c++;
        }
        f[i] = c;
    }

    scanf("%d %s", &n, x);
    int p = 0;
    for (int i = 0; i < n; i++)
    {
        if (x[i] == '1') p++;
    }
    if (p == 1)
    {
        for (int i = 0; i < n; i++)
        {
            if (x[i] == '0')
            {
                if (i == n - 1) printf("2\n");
                else if (x[n - 1] == '1') printf("2\n");
                else printf("1\n");
            }
            else printf("0\n");
        }
    }
    else
    {
        d[0] = 1 % (p + 1);
        e[0] = 1 % (p - 1);
        for (int i = 1; i < n; i++)
        {
            d[i] = d[i - 1] * 2 % (p + 1);
            e[i] = e[i - 1] * 2 % (p - 1);
        }
        long long a = 0, b = 0;
        for (int i = 0; i < n; i++)
        {
            if (x[n - 1 - i] == '1')
            {
                a = (a + d[i]) % (p + 1);
                b = (b + e[i]) % (p - 1);
            }
        }
        for (int i = 0; i < n; i++)
        {
            if (x[i] == '1')
            {
                printf("%d\n", 1 + f[(b - e[n - 1 - i] + p - 1) % (p - 1)]);
            }
            else
            {
                printf("%d\n", 1 + f[(a + d[n - 1 - i]) % (p + 1)]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 7956
import Data.Maybe
import Data.List
import Text.Printf
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as C

parseInt :: C.ByteString -> Int
parseInt = fst . fromJust . C.readInt

main :: IO ()
main = do
  n <- parseInt <$> C.getLine
  as <- map parseInt . C.words <$> C.getLine
  let update Nothing = Just 1
      update (Just y) = Just (y + 1)
      acc (cnt, mp) (j, aj) = (cnt + M.findWithDefault 0 (j - aj) mp, M.alter update (j + aj) mp)
      (ans, _) = foldl' acc (0 :: Int, M.empty) $ zip [1..n] as
  printf "%d\n" ans

Measured memory_bytes: 35132
def main3():
    N, M, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    Bsum = sum(B)
    ans = Asum = 0
    idx_b = len(B) - 1

    for i in range(N + 1):
        if i == 0:
            if Asum + Bsum <= K:
                ans = max(ans, i + idx_b + 1)

            else:
                while Asum + Bsum > K:
                    if idx_b >= 0:
                        Bsum -= B[idx_b]
                        idx_b -= 1
                    else:
                        break
                    
                if Asum + Bsum <= K:
                    ans = max(ans, i + idx_b + 1)

        else:
            Asum += A[i - 1]

            while Asum + Bsum > K:
                if idx_b >= 0:
                    Bsum -= B[idx_b]
                    idx_b -= 1
                else:
                    break
            if Asum + Bsum <= K:
                ans = max(ans, i + idx_b + 1)

    print(ans)

if __name__ == "__main__":
    main3()

Measured memory_bytes: 42292
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>

using namespace std;

namespace {
}

int DFS(long long tmpN, int N, unsigned bitFlags, int depth) // tmpNは一時的に1e10になる。
{
	if (tmpN > N) {
		return 0;
	}

	int sum = 0;
	if (bitFlags == 0b111) {
		sum = 1;
	}

	for (const auto& elem : map<int, int>{ {3,0b100}, {5, 0b010}, {7,0b001} }) {
		sum += DFS(tmpN * 10 + elem.first, N, bitFlags | elem.second, depth + 1);
	}
	//DFS(tmpN + 5 * 10, N, bit | 0b100);
	//DFS(tmpN + 7 * 10, N, bit | 0b100);
	return sum;
}


int main()
{
	int N = 0;
	cin >> N;

	unsigned bitFlags(0b00); // 3, 5, 7 
	cout << DFS(0, N, bitFlags,0) << endl;

	return 0;
}


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

#include <vector>

using namespace std;
using ll = long long;

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

    string S;
    cin >> S;

    vector<vector<int>> dp(N, vector<int>(26, 0));
    dp[0][S[0] - 'a'] = 1;
    for (int i = 1; i < N; i++) {
        for (char c = 'a'; c <= 'z'; c++) {
            if (S[i] == c)
                dp[i][c - 'a'] = dp[i - 1][c - 'a'] + 1;
            else
                dp[i][c - 'a'] = dp[i - 1][c - 'a'];
        }
    }

    int output = 0;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j < 26; j++) {
            if (dp[i][j] > 0 && dp[N - 1][j] - dp[i][j] > 0) {
                tmp++;
            }
        }
        if (output < tmp) output = tmp;
    }

    cout << output << endl;

    return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	string r1 = string(dx, 'R') + string(dy, 'U');
	string r2 = string(dx, 'L') + string(dy, 'D');
	string r3 = 'D' + string(dx + 1, 'R') + string(dy + 1, 'U') + 'L';
	string r4 = 'U' + string(dx + 1, 'L') + string(dy + 1, 'D') + 'R';

	cout << r1 + r2 + r3 + r4 << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<unordered_map>	
#include<unordered_set>
#define pb emplace_back
#define rt(v) return cout<<v,0
#define sz(v) (int)(v.size())
#define all(a) a.begin(),a.end()
#define endl '\n'
#define space " "
typedef long long ll;
typedef unsigned long long ull;
const int N = 10 + 1e5;
const int mod = 1e9 + 7;
/*

███╗   ███╗███████╗███╗   ███╗███████╗    ██╗      ██████╗ ██████╗ ██████╗
████╗ ████║██╔════╝████╗ ████║██╔════╝    ██║     ██╔═══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗  ██╔████╔██║█████╗      ██║     ██║   ██║██████╔╝██║  ██║
██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██║     ██║   ██║██╔══██╗██║  ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗    ███████╗╚██████╔╝██║  ██║██████╔╝
╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝

*/

using namespace std;
void Ferrari() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int main() {
	Ferrari();
	int n, m, x; cin >> m >> n >> x;
	vector<vector<int>>v(m, vector<int>(n + 1));
	for(int i = 0 ; i < m ; ++i)
		for (int j = 0; j <= n; ++j) {
			cin >> v[i][j];
		}
	int ans = INT_MAX;
	for (int i = 0; i < (1 << m); ++i) {
		//cout << (1 << m) << endl;
		vector<int>v1(n, 0);
		int cost = 0;
		for (int j = 0; j < m; ++j) {
			if (i & (1 << (j))) {
				cost += v[j][0];
				for (int k = 1; k <= n; ++k)
					v1[k - 1] += v[j][k];
			}
		}
	//	cout << cost << endl;
		bool ok = 1;
		for (int it : v1) {
			if (it < x) ok = 0;
		}
		if (ok) ans = min(ans, cost);
	}
	cout << (ans == INT_MAX ? -1 : ans);
	return 0;
}


	


/* stuff you should look for
	* keepin sharp mind.
	* int overflow, array bounds.
	* special cases (n=1?), set tle , make sure you understand the proble correctly.
	* don`t stuck in a problem.
	* test the idea on samples.
	*/

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}
/*
long long arr[N],n;
bool IsCover(long long d){
    long long lastcover=-1,used=0;
    for(int i=0;i<n;i++){
        if(arr[i]>lastcover){
        lastcover=arr[i]+(2*d);
        used++;
        }

    }
    return used<=3;
}
long long PS(){
    long long hi=1e5,lo=0,mid;
    while(hi-lo > 0){
        mid=(lo+hi)/2;
        if(IsCover(mid))hi=mid;
        else lo=mid+1;
    }
    return lo;
}
*/
set<int>s;
int main(){
     int n=d();
    for(int i=0;i<n;i++){
        int x=d();
        s.insert(x);
    }
    cout<<s.size()<<endl;
}


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

using namespace std;

void hawawa()
{
	int n;
	cin >> n;
	long long ans = 0;
	while (n--) {
		int num;
		cin >> num;
		ans += num - 1;
	}
	cout << ans << "\n";
}

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


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for i in range(N)]
s.sort()
s_min = 0

if sum(s) % 10 :
    print(sum(s))
else:
    for i in range(N):
        if s[i] % 10 != 0:
            s_min = s[i]
            break
    if s_min:
        print(sum(s) - s_min)
    else:
        print(0)

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

int main(){
	int k, s;
	cin >> k >> s;

	int x, y, z;
	int count=0;

	for(x=k; x>=0; x--){
		for(y=k; y>=0; y--){
			if(x+y > s) continue;
			if(s-x-y > k) continue;
			count += 1;
		}
	}

	cout << count << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

const int Maxn = 100010;

ll a[Maxn];
P p[Maxn];

int n, m;

struct comp {
    bool operator()(const P &p1, const P &p2) const {
        return p1.second > p2.second;
    }
};

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
    */
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", a + i);
    }
    sort(a, a + n);
    for (int i = 0; i < m; ++i) {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        p[i] = P(x, y);
    }
    sort(p, p + m, comp());
    int cur = 0;
    for (int i = 0; i < m; ++i) {
        while (cur < n && p[i].first > 0 && p[i].second > a[cur]) {
            a[cur++] = p[i].second;
            --p[i].first;
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += a[i];
    }
    printf("%lld\n", ans);
}

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

int main(){
    int n;
    cin>>n;
    float arr[n];
    for (int i=0;i<n;++i){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    float ans = (arr[0]+arr[1])/2;
    for (int i=2;i<n;++i){
        ans = (ans+arr[i])/2;
    }
    cout<<ans;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  judge=a%3==0||(a+b)%3==0||b%3==0;
  anss(judge,"Possible","Impossible");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    for(int i = 0; i < t; i++) {
        cin >> a[i];
    }
    sort(all(a), greater<int>());
    vector<int> rui(t + 1);
    for(int i = 0; i < t; i++) {
        rui[i + 1] = rui[i] + a[i];
    }
    int ans = INT_MAX;
    for(int i = 0; i < t; i++) {
        ans = min(ans, abs(rui[t] - 2 * rui[i]));
    }
    cout << max(0, ans - 1) << endl;
}

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

A = [[0 for i in range(c)] for j in range(100000)]
for i in range(n):
    s,t,c = [int(i) for i in input().split()]
    for i in range(s-1,t):
        A[i][c-1] = 1


ans = 0
for i in range(100000):
    val = sum(A[i])
    if val > ans:
        ans = val

print(ans)

Measured memory_bytes: 38260
k = 26
D = gets.to_i
c = gets.split.map(&:to_i)
s = D.times.map { gets.split.map(&:to_i) }
t = []
D.times do |d|
  t[d] = gets.to_i
end
last = Array.new(k, 0)
satis = 0
D.times do |d|
  satis += s[d][t[d] - 1]
  last[t[d] - 1] = d + 1
  k.times do |i|
    satis -= c[i] * ((d + 1) - last[i])
  end
  puts satis
end


Measured memory_bytes: 14204