akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<int> a(n),b(n),c(n-1);
	rep(i,n){
		int x;
		cin >> x;
		x--;
		a[i] = x;
	}
	rep(i,n){
		cin >> b[i];
	}
	rep(i,n-1){
		cin >> c[i];
	}
	int sum = 0;
	int pre = -2;
	rep(i,n){
		sum += b[a[i]];
		if(pre+1 == a[i]){
			sum += c[pre];
		}
		pre = a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int N, M, X;
vector<int> C;
int a[12][12];
int ans = 100000001;


int main(){
  cin >> N >> M >> X;
  C = vector<int>(N);
  for(int i=0; i<N; i++){
    cin >> C[i];
    for(int j=0; j<M;j++){
      cin >> a[i][j];
    }
  }
  
  //全パターンは2^N通り
  int all = 1<<N;
  //ビット全探索
  for(int mask = 0; mask<all;mask++){
    //習熟度計算
    vector<int> level(M);
    int cost = 0;
    for(int i=0; i<N;i++){
      //i冊目のフラグが建っているか
      if((mask>>i)&1){
        cost += C[i];
        for(int j=0; j<M; j++){
          //習熟度加算
          level[j] += a[i][j];
        }
      }
    }
    //条件を満たすかどうか
    bool ok = true;
    for(int j=0; j<M;j++){
      if(level[j]<X) ok =false;
    } 
    if(ok){
      ans = min(ans, cost);
    }
  }  
  if(ans == 100000001) cout << -1 <<endl;
  else cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<long> x(n);
    vector<long> y(n);
    vector<long> z(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>z[i];
    }
    long long ans=0;
    for(int i=0;i<8;i++){
        vector<long long> tmp(n,0);
        for(int j=0;j<n;j++){
            if(i==0)tmp[j]=x[j]+y[j]+z[j];
            if(i==1)tmp[j]=x[j]+y[j]-z[j];
            if(i==2)tmp[j]=x[j]-y[j]+z[j];
            if(i==3)tmp[j]=x[j]-y[j]-z[j];
            if(i==4)tmp[j]=-x[j]+y[j]+z[j];
            if(i==5)tmp[j]=-x[j]+y[j]-z[j];
            if(i==6)tmp[j]=-x[j]-y[j]+z[j];
            if(i==7)tmp[j]=-x[j]-y[j]-z[j];
        }
        sort(tmp.begin(),tmp.end(),greater<long long>());
        long long sum=0;
        for(int j=0;j<m;j++)sum+=tmp[j];
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv){
	char str[200];
	scanf("%s\n", str);
	for (int i = strlen(str) - 2;; i -= 2) {
		int flag = 1;
		for (int j = 0; j < (i / 2); j++) {
			if(str[j] != str[j + (i / 2)]){
				flag = 0;
				break;
			}
		}
		if(flag) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,h; cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
    int n;
    string a ,b, c;
    int count = 0, ab = 0, bc = 0, ac = 0;
    int min1 = 9999999, min2 = 9999999;
    vector<int> abc(3, 0);
    int d = 0;

    cin >> n >> a >> b >> c;

    if(a == b && b == c){
        cout << 0 << endl;
        return 0;
    }

    count = n*2;

    for(int i = 0; i < a.length(); i++){
        if(a[i] == b[i]) count--;
        if(b[i] == c[i]) count--;
        if(a[i] == c[i] && (b[i] != c[i] || a[i] != b[i])) count--;
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int N = scanner.nextInt();
		int receiveCount = 0;
		int receive = 0;
		receiveCount = N / 15;
		receive = receiveCount * 200;
		
		System.out.println(N * 800 - receive);
	}
}

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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1 ;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int k,s; cin >> k >> s; 
		int ans = 0; 
		for(int x = 0; x <= k; x++){
			for(int y = 0; y <=k; y++){
				int z = s - x - y; 
				if(z >= 0 && z <= k)ans++;
			}
		}
		cout << ans << endl;
				
	}
	return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> st(26);
  for(int i = 0; i < n; i++) {
    st[s[i] - 'a'].insert(i + 1);
  }
  vector<int> ans;
  ans.reserve(q);
  for(int i = 0; i < q; i++) {
    int in;
    cin >> in;
    if(in == 1) {
      int ip;
      char c;
      cin >> ip >> c;
      if(c == s[ip - 1]) {
        continue;
      }
      st[s[ip - 1] - 'a'].erase(ip);
      st[c - 'a'].insert(ip);
      s[ip - 1] = c;
    } else {
      int l, r;
      cin >> l >> r;
      int cnt = 0;
      for(int j = 0; j < 26; j++) {
        auto p = st[j].lower_bound(l);
        if(p != st[j].end() && *p <= r) {
          cnt++;
        }
      }
      ans.push_back(cnt);
    }
  }
  for(auto p : ans) {
    cout << p << "\n";
  }
  return 0;
}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int, int>

#define PI 3.14159265358979323846
const int N = 100 + 10;
const int INF=2e9;

int maxi,cnt;

void solve() {
  string s;
  cin>>s;
  int len=s.size();
  
  for(int i=0;i<len;i++) {
	     for(int j=i;j<len;j++) {
			 cnt=0;
			   for(int k=j;k<len;k++) {
				     if(s[k]=='A' || s[k]=='G' || s[k]=='T' || s[k]=='C')
				         cnt++;
				     else {
						    maxi=max(maxi,cnt);
						    cnt=0;
						 }			            
				   }
				   maxi=max(maxi,cnt);
				   
			 }
	   
	    }
  
  /*for(int i=0;i<len;i++) {
	     for(int j=0;j<len;j++) {
			   string h=s.substr(i,j);
			   cnt=0;
			   int yax=h.size();
			    for(int p=0;p<yax;p++) {
					  if(h[p]=='A' || h[p]=='G' || h[p]=='C' || h[p]=='T')
					     cnt++;
					  else {
						    maxi=max(maxi,cnt);
						    cnt=0;
						  }   
					}
					maxi=max(maxi,cnt);
					
			 }
	  }*/
	  
	  cout<<maxi;	   
 
}


int32_t main() {
  fast;
  int t = 1;
  while (t--)
	solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    set<ll> s;
    for (auto &&i: boost::irange(A, min(A + K, B+1))) {
        s.insert(i);
    }
    for (auto &&i: boost::irange(max(B - K + 1, A), B + 1)) {
        s.insert(i);
    }
    for (auto &&i : s) {
        cout << i << endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N, D, X; cin >> N >> D >> X;
	ll A[100] = {};
	ll sum = 0;
	rep(i, 0, N) {
		cin >> A[i];

		int n = 0;
		while (n*A[i] + 1 <= D) {
			sum += 1;
			n++;
		}
	}
	cout << sum + X << endl;

	return 0;
}

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

long gcd(long a,long b){
	if(b==0){
		return a;
	}else{
		return gcd(b,a%b);
	}
}

long icm(long x,long y){
	return x/gcd(x,y)*y;
}

long so(long x, long y, long z){
	long ans;
	ans=x-(x/y + x/z - x/(icm(z, y)));
	return ans;
}

int main(){
	long a,b,c,d,ans;
	cin>>a>>b>>c>>d;

	ans=so(b,c,d)-so(a-1,c,d);
	cout<<ans;
}



Measured memory_bytes: 256
#include <iostream>			//cout,endl,cin
#include <string>			//string,to_string,stoi
#include <vector>			//vector
#include <algorithm>		//min,max,swap,sort,reverse,lower_bound,upper_bound
#include <utility>			//pair,make_pair
#include <tuple>			//tuple,make_tuple
#include <cstdint>			//int64_t,int*_t
#include <cstdio>			//printf
#include <map>				//map
#include <queue>			//queue,priority_queue
#include <set>				//set
#include <stack>			//stack
#include <deque>			//deque
#include <unordered_map>	//unordered_map
#include <unordered_set>	//unordered_set
#include <bitset>			//bitset
#include <cctype>			//isupper,islower,isdigit,toupper,tolower
#include <math.h>
#include <cstdio>
#include <cstring>
#include <iomanip>

using namespace std;

int main(void){
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else
	{
		cout << "safe" << endl;
	}



}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    Scanner sc;
    void run() {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[10];
        A:
        for (int i=0;i<n;i++) {
            int[] box = new int[2];
            boolean flg = false;
            for (int h=0;h<10;h++) x[h] = sc.nextInt();
            for (int h=0;h<10;h++) {
                int p = 0;
                flg = false;
                for (int j=0;j<2;j++) {
                    if (box[p] < x[h]) {
                        box[p] = x[h];
                        flg = true;
                        break;
                    }
                    else p = (p + 1) % 2;
                }
                if (!flg) {
                    System.out.println("NO");
                    break;
                }
            }
            if(flg) System.out.println("YES");
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n)	cin >> a[i];

	a.push_back(a[0] + k);
	int l = 0;
	rep(i, n) {
		l = max(l, a[i + 1] - a[i]);
	}
	cout << k - l << endl;


}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
ll divisor(ll a,ll b){
  if(a % b == 0)return b;
  ll acopy = 0;
  acopy = a;
  a = b;
  b = acopy % b;
  divisor(a,b);
}
int main(){
  ll n = 0;
  cin >> n;
  ll first = 0;
  cin >> first;
  ll ans = 0;
  ans = first;
  for(int i = 1;i <= n - 1;i++){
    ll num = 0;
    cin >> num;
    ans = ans / divisor(max(ans,num),min(ans,num)) * num;
  }
  cout << ans << endl;
  return 0;
}

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


class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = cin.nextInt();
            y[i] = cin.nextInt();
        }
        int[] sx = (int[])x.Clone();
        int[] sy = (int[])y.Clone();
        Array.Sort(sx);
        Array.Sort(sy);


        long ans = long.MaxValue;

        for (int l = 0; l < N; l++)
        {
            for (int r = l + 1; r < N; r++)
            {
                List<int> pos = new List<int>();
                for (int i = 0; i < N; i++)
                {
                    if(x[i] >= sx[l] && x[i] <= sx[r])
                    {
                        pos.Add(y[i]);
                    }
                }
                pos.Sort();
                for (int i = 0; i < pos.Count - K + 1; i++)
                {
                    ans = Math.Min(ans, ((long)sx[r] - sx[l]) * ((long)pos[i + K - 1] - pos[i]));
                }
            }
        }

        Console.WriteLine(ans);
    }


}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    for(int i=0; i<N; i++) {
        cin >> x[i];
    }

    vector< vector<int64_t> > cnt(N+1, vector<int64_t>(50*N+1));
    cnt[0][0] = 1;

    for(int i=0; i<N; i++) {
        for(int j=i; j>=0; j--) {
            for(int k=50*N-x[i]; k>=0; k--) {
                cnt[j+1][k+x[i]] += cnt[j][k];
            }
        }
    }

    int64_t ans = 0;
    for(int j=1; j<=N; j++) {
        for(int k=1; k<=50*N; k++) {
            if(j*A == k) {
                ans += cnt[j][k];
            }
        }
    }

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


Measured memory_bytes: 1280
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.List

main :: IO ()
main = do
  [s] <- readStrings
  print . showAnswer $ solve (s)

type Input  = (String)
type Output = Bool

solve :: Input -> Output
solve n = elem n $ permutations "abc"

showAnswer :: Output -> Answer
showAnswer = YesNo

-- utils
readStrings :: IO [String]
readStrings = map C8.unpack . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

vl fact(100002), finv(100002);

ll modpw(ll x, ll k) {
	ll res = 1;
	while (k != 0) {
		if (k & 1) res = res*x % MOD;
		x = x*x % MOD;
		k = k >> 1;
	}
	return res;
}

ll comb(ll n, ll k) {
	if (n == 0 && k == 0)return 1;
	if (n < k || n < 0)return 0;
	return fact[n] * finv[n - k] % MOD * finv[k] % MOD;;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	ll n, d, fi = -1, se = 0;
	cin >> n;
	vl v(n + 1), b(n + 1);
	fact[0] = 1;
	finv[0] = 1;
	rep(i, 100001) {
		fact[i + 1] = (fact[i] * (i + 1)) % MOD;
		finv[i + 1] = modpw(fact[i + 1], MOD - 2);
	}

	rep(i, n + 1) {
		cin >> v[i];
		b[v[i]]++;
		if (b[v[i]] == 2)d = v[i];
	}
	rep(i, n + 1) {
		if (v[i] == d) {
			if (fi == -1)fi = i + 1;
			else se = i + 1;
		}
	}
	ll tmp = n - se + fi;
	rep(i, n + 1) {
		ll ans;
		ans = comb(n + 1, i + 1);
		if (i >= 0 && i <= tmp)ans = (ans + MOD - comb(tmp, i)) % MOD;
		printf("%lld\n", ans);
	}
}



Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;

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

  scan(n);

  int k;
  scan(k);
//  vint s(n);
//  REP(i, n) scan(s[i]);

  cout << n-k+1 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int [] map = new int [N];
		for(int i = 0; i < N ; i++) {
			map[i] = sc.nextInt();
		}
		int H1 = map[0];
		int max = 0;
		int answer = 0;


		for(int j = 0; j < N; j++) {
			if(max <= map[j]) {
				max = map[j];
				answer++;
			}
		}

		System.out.println(answer);

	}

}


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

int a[100010];

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

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

    int sum=0;
    for(int i=0;i<=n;i++)sum+=abs(a[i+1]-a[i]);

    for(int i=0;i<n;i++)
    {
        cout<<sum-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i])<<"\n";
    }

    return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=200010;
long long ans=0;
int a[MAX_N],n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int l=1,r=1,sum=0,xsum=0;
	while(l<=n){
		while(r<=n){
			if((sum+a[r])==(xsum^a[r])){
				sum+=a[r];
				xsum^=a[r];
				r++;
			}else{
				sum-=a[l];
				xsum^=a[l];
				break;
			}
		}
	//	printf("%d %d\n",l,r);
		ans+=r-l;
		l++;
	}
	printf("%lld",ans);
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
typedef vector<vector<int> > matrix; 
matrix mult(matrix a, matrix &b)
{
    matrix ans(50,vector<int>(50,0));
    for(int i=0;i<50;i++)
        for(int j=0;j<50;j++)
            for(int k=0;k<50;k++)
            {
                ans[i][j] += a[i][k]*b[k][j];
                ans[i][j]%=mod;
            }
    return ans;
}
matrix power(matrix base, int expo)
{
    matrix ans(50,vector<int>(50,0));
    for(int i=0;i<50;i++)
    {
        ans[i][i] = 1;
    }
    while(expo)
    {
        if(expo&1)
        {
            ans = mult(base,ans);
        }
        base = mult(base,base);
        expo >>=1;
    }
    return ans;
}
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n,k;
    cin>>n>>k;
    matrix base(50,vector<int>(50,0));
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>base[i][j];
    matrix ans = power(base,k);
    int fin = 0;
    for(int i=0;i<50;i++)
        for(int j=0;j<50;j++)
            fin = (fin+ans[i][j])%mod;
    cout<<fin;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------


int main() {


  ll n, min = INF_LONG, move;
  cin >> n;

  for(ll i=1; i*i<=n; ++i) {
    if(n%i==0) {
      move = n/i-1 + i-1;
      if(move<min) min = move;
    }
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int dec = int.Parse(s[1]) - int.Parse(s[0]);
            int blength = 0;
            for (int i = 1; i <= dec; i++)
            {
                blength += i;
            }
            int ans = blength - int.Parse(s[1]);

            
            Console.WriteLine( ans);
            Console.ReadLine();
        }

    }


}


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

#define rep(i,n) for (int i = 0; i < (n); i++)
// 隣接リスト グラフ, 可変長配列
vector<int> to[100005];
int dp[100005];


int DP(int i) {
    if (dp[i] != -1) {
        return dp[i];
    }

    int tmp = 0;
    for(auto e : to[i]) {
        tmp = max(tmp, DP(e) + 1);
    }
    dp[i] = tmp;
    return tmp;
}


int main(void){
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        to[x].push_back(y);
    }
    // dp初期化
    rep(i, 100005) {
        dp[i] = -1;
    }


    // 出力
    int ans = 0;
    rep(i, N){
        ans = max(ans, DP(i));
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  if(n==m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


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

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

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

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

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


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int N;
    cin >> N;
    int A[N + 2];
    A[0] = A[N + 1] = 0;
    REP(i, N) cin >> A[i + 1];
    int totalMoney = 0;
    for (int i = 1; i < N + 2; ++i) totalMoney += abs(A[i] - A[i - 1]);
    // cout << totalMoney << endl;
    for (int i = 1; i <= N; ++i)
    {
        int ans = totalMoney - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
int main(){
	int x,ans=1,max,i=2,j=2;
	scanf("%d",&x);
	while(j!=1){
		max=i;
		j=1;
		if(x==1)break;
		while(max*i<=x){
			max*=i;
			j++;
		}
		if(ans<max&&j!=1)ans=max;
		i++;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100001
bool used[MAXN];
bool start[MAXN];
vector<ll> vec[MAXN]; //to
int memo[MAXN];
int depth(int x) {
    if (used[x]) return memo[x];
    int max = 0;
    for (int i = 0; i < vec[x].size(); i++) {
        if (max < depth(vec[x][i])) {
            max = depth(vec[x][i]);
        }
    }
    memo[x] = max + 1;
    used[x] = true;
    return max + 1;
}
int main() {
    int n, m;
    cin >> n >> m;
    memset(start, true, sizeof(start));
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        vec[x].push_back(y);
        start[y] = false;
    }
    memset(used, false, sizeof(used));
    int ret = 0;
    for (int i = 1; i <= n; i++) {
        if (start[i]) {
            if (depth(i) > ret) {
                ret = depth(i);
            }
        }
    }
    cout << ret - 1 << endl;
    return 0;
}

Measured memory_bytes: 14148
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

#define LL long long

const int MAXN = 200000 + 5;

struct BTree{
    int lt, rt, v;
}bt[MAXN * 3];

struct Camel{
    int K, L, R;
};

struct Camel a[MAXN], b[MAXN];

void build(int i, int l, int r){

    bt[i].v = 0;
    bt[i].lt = l;
    bt[i].rt = r;

    if (l == r){
        return ;
    }

    int mid = (l + r) / 2;
    build(i << 1, l, mid);
    build((i << 1) + 1, mid + 1, r);
}

bool insert(int i, int K){
    bool res = false;
    if (bt[i].v == bt[i].rt - bt[i].lt + 1){
        return false;
    }
    if (bt[i].lt == bt[i].rt){
        if (bt[i].v == 0){
            bt[i].v ++;
            return true;
        }
        return false;
    }
    int mid = (bt[i].rt + bt[i].lt) >> 1;
    if (K <= mid){
        res =  insert(i << 1, K);
    }
    else{
        res = insert((i << 1) + 1, K);
        if (res == false){
            res = insert((i << 1), mid);
        }
    }
    if (res){
        bt[i].v ++;
    }
    return res;
}

bool cmp(Camel x, Camel y){
    return (x.L - x.R) > (y.L - y.R);
}

LL solve(Camel * a, int n){
    LL ret = 0;
    build(1, 1, n);
    for (int i = 0; i < n; i ++){
        int K = a[i]. K;
        if (K > 0 && insert(1, K)){
            ret += (LL)a[i].L;
        }
        else{
            ret += (LL)a[i].R;
        }
    }
    return ret;
}

int main()
{
    int T, N, na, nb;
    cin >> T;
    while (T --){
        cin >> N;
        na = nb = 0;
        int K, L, R;
        for (int i = 0; i < N; i ++){
            cin >> K >> L >> R;
            if (L >= R){
                a[na].K = K;
                a[na].L = L;
                a[na].R = R;
                na ++;
            }
            else{
                b[nb].K = N - K;
                b[nb].L = R;
                b[nb].R = L;
                nb ++;              
            }
        }
        LL ans = 0;
        
        if (na > 0){
            sort(a, a + na, cmp);
            ans += solve(a, na);
        }
        if (nb > 0){
            sort(b, b + nb, cmp);
            ans += solve(b, nb);
        }
        cout << ans << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

    string Sa,Sb,Sc;

    cin>>Sa>>Sb>>Sc;

    int t=0;
    while(1){
        //cout<<Sa<<","<<Sb<<","<<Sc<<endl;
        if(t==0){
            if(Sa.empty()){
                cout<<"A"<<endl;
                return 0;
            }
            t=Sa[0]-'a';
            Sa.erase(0,1);
        }
        else if(t==1){
            if(Sb.empty()){
                cout<<"B"<<endl;
                return 0;
            }
            t=Sb[0]-'a';
            Sb.erase(0,1);
        }
        else if(t==2){
            if(Sc.empty()){
                cout<<"C"<<endl;
                return 0;
            }
            t=Sc[0]-'a';
            Sc.erase(0,1);
        }
    }
}


Measured memory_bytes: 256
eval"H,W,*A="+`dd`.split*?,
a=A.pop(H*W).zip(A).map{|a,b|(a-b).abs}
d=[1<<t=10**4]+[0]*~-W
H.times{N=0
d=d.zip(a.shift W).map{|d,t|d|=N
N=d<<t|d>>t}}
p (0..2*t).map{|i|(t-i*N[i]).abs}.min

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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  vector<int> memo(N);
  cin >> W.at(0);
  memo.at(0) = W.at(0);
  for (int i = 1; i < N; i++) {
    cin >> W.at(i);
    memo.at(i) = memo.at(i - 1) + W.at(i);
  }
  int memo2 = abs(memo.at(N - 1) - memo.at(0)- memo.at(0)), memo3 = abs(memo.at(N - 1) - memo.at(1) - memo.at(1));
  for (int i = 0; i < N - 1; i++) {
    if (memo.at(i) < memo.at(N - 1) / 2) {
      memo2 = abs(memo.at(N - 1) - memo.at(i) - memo.at(i));
      memo3 = abs(memo.at(N - 1) - memo.at(i + 1) - memo.at(i + 1));
    }
    else {
      break;
    }
  }
  cout << min(memo2, memo3) << endl;
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &k)

	mod := 1000000007
	ans := 0
	for i := k; i <= n+1; i++ {
		sumMin := sumOfNums(0, i-1)
		sumMax := sumOfNums(n-i+1, n)
		ans += sumMax - sumMin + 1
		ans %= mod
	}

	fmt.Println(ans)
}

func sumOfNums(l, r int) int {
	return (l + r) * (r - l + 1) / 2
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


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

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

    rep(i,0,s.size()){
        if(s[i]==','){
            s[i]=' ';
        }
    }

    cout<<s<<endl;
}


Measured memory_bytes: 384
#再起関数で書いてみた
def count(n):
    #終了条件
    if n < 1:
        return 0
    
    #処理
    keta = len(str(n))-1
    if keta % 2 == 1:
        ans = 0
        n = 10**keta-1
    else:
        ans = n - 10**keta + 1
        n = 10**(keta-1)-1
    return ans + count(n)


n = int(input())
print(count(n))

Measured memory_bytes: 3060
using System;

namespace ITP1_8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                int value = 0;
                string input = Console.ReadLine();

                if (input == "0") break; 

                for (int k=0; k<input.Length; k++)
                {
                    //value += int.Parse(input[k]);
                    value += int.Parse(input[k].ToString());
                }

                Console.WriteLine(value);
            }
        }
    }
}

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


int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; i++){
    cin >> P.at(i);
  }
  
  int thresh = N+1;
  
  
  int ans = 0;
/*  
  for(int i = 0; i < N; i++){
    bool smaller = true;
    for(int j = 0; j < i; j++){
      if(P.at(j) < P.at(i)){
        smaller *= false;
      }
    }
      if(smaller){
        ans += 1;
      }
  }
*/
  
  for (int i = 0; i < N; i++){
    if(P.at(i) < thresh){
       ans++;
       thresh = P.at(i);
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <vector>
#define endl '\n';
using namespace std;

int main()
{
    string s[100];
    int h, w; cin >> h >> w;
    for (int i = 0; i < h; ++i)
        cin >> s[i];
    for (int i = 1; i <= w + 2; ++i)
        cout << "#";
    cout << "\n";
    for (int i = 0; i < h; ++i) {   
        cout << "#" << s[i] << "#" << "\n";
    }
    for (int i = 1; i <= w + 2; ++i)
        cout << "#";
    return 0;
}

Measured memory_bytes: 3628
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

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

signed main(){
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    rep0(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n+1][3];
    rep0(i,3){
        rep0(j,n+1) dp[j][i]=0ll;
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;


    return 0;
}


Measured memory_bytes: 4864
"""n = 12
anoms = 0
for i in range(2**n):
    count = 0
    x=i
    while True:
        count += 1
        if x%2==1:
            x //= 2
        else:
            x //= 2
            x += 2**(n-1)
        if x == i:
            break
    if count != 2*n:
        t = bin(i)[2:]
        print("0"*(n-len(t))+t)
        anoms += 1


if x[0] == '0':
    k = 1
    while k<n and x[k] == '0':
        k += 1
    comp = "".join(str((i//k)%2) for i in range(n))
    if x < comp:
        k += 1
else:
    k = 1
    while k<n and x[k] == '1':
        k += 1
    comp = "".join(str((1+i//k)%2) for i in range(n))
    if x < comp:
        k -= 1"""


MOD = 998244353

n = int(input())
x = input()


def binToInt(x):
    result = 0
    t = 1
    i = 0
    while i < len(x):
        if x[~i] == '1':
            result += t
            result %= MOD
        i += 1
        t *= 2
        t %= MOD
    return result


def getCompStr(pref, copies):
    inv = "".join(str(1-int(c)) for c in pref)
    if copies%2 == 1:
        return (pref+inv)*(copies//2) + pref
    return (pref+inv)*(copies//2)


d = 1
factors = []
while d*d <= n:
    if n%d == 0:
        factors.append(d)
        if (d*d != n):
            factors.append(n//d)
    d += 1
factors.sort()

defects = 0
result = 0
computedDefects = {}
for size in factors:
    numComps = n//size
    if numComps%2==0 or numComps < 3:
        continue
    pref = x[:size]
    curDefects = binToInt(pref)
    for s in computedDefects:
        if size%s == 0 and (size//s)%2 == 1:
            curDefects -= computedDefects[s]
            curDefects %= MOD
    if getCompStr(pref, n//size) <= x:
        curDefects += 1
        curDefects %= MOD
    computedDefects[size] = curDefects
    defects += curDefects
    defects %= MOD
    result += curDefects*2*size
    result %= MOD


result += (binToInt(x)+1-defects)*2*n
result %= MOD
print(result)


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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

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

    ll n,m,x;
    cin >> n >> m >> x;
    ll min_cost = inf;

    vector<vector<ll>> v(n, vector<ll> (m));
    vector<ll> cost(n);

    for(ll i=0 ; i<n ; ++i)
    {
        cin >> cost[i];
        for(ll j=0; j<m ; ++j)
        {
            cin >> v[i][j];
        }
    } 

    for(ll i=0 ; i < (1 << n) ; ++i)
    {
        ll cst = 0;
        vector<ll> ans(m);
        for(ll j=0 ; j<n ; ++j)
        {
            if( (i >> j)&1 )
            {
                cst += cost[j];
                for(ll k=0 ; k<m ; ++k)
                {
                    ans[k] += v[j][k];
                }
            }
        }

        for(ll k=0 ; k<m ; ++k)
        {
            if(ans[k]<x) break;

            if(k==m-1)
            {
                min_cost = min(cst, min_cost);
            }
        }
    }
    
    if(min_cost!=inf)
    cout << min_cost;
    else
    cout << -1;

    return 0;
} 

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;

//140 A
int main(void) {
	ll n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.11 17:11:48
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int MOD = 1e9 + 7;
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((MOD+x)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    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) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};

struct Combination {
private:
    int N;
    
    mint pow(mint k, long long n) {
        mint res = 1;
        while (n > 0) {
            if (n & 1) {
                res *= k;
            }
            k *= k;
            n >>= 1;
        }
        return res;
    }
public:
    std::vector< mint > FACT, IFACT;
    
    Combination(int n) : N(n) {
        FACT.resize(n + 1);
        IFACT.resize(n + 1);
        FACT[0] = 1;
        IFACT[0] = 1;
        for (int i = 1; i <= n; i++) {
            FACT[i] = FACT[i - 1] * i;
            IFACT[i] = pow(FACT[i], MOD - 2);
        }
    }
    mint comb(int n, int r) {
        if (n < 0 || r < 0 || r > n) return 0;
        if (r > n / 2) r = n - r;
        return FACT[n] * IFACT[n - r] * IFACT[r];
    }
};
int main() {
    int n,m;cin >> n >> m;
    mint ans = 0;
    Combination cb(m);
    for (int i = 0; i <= n; i++) {
        if (i & 1) {
            ans -= cb.FACT[m-i] * cb.IFACT[n-i] * cb.IFACT[i];
        }
        else {
            ans += cb.FACT[m-i] * cb.IFACT[n-i] * cb.IFACT[i];
        }
    }
    ans *= cb.FACT[m] * cb.FACT[n] * cb.IFACT[m-n] * cb.IFACT[m-n];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11104
#include<cstdio>
#include<algorithm>
#include<set>
#define ll long long
using namespace std;
ll a[300010];
ll dp[300010];
ll dp1[300010];
multiset<ll> st;
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 1; i <= 3 * n; i++) {
		scanf("%lld", &a[i]);
	}
	ll dap = 0;
	for (int i = 1; i <= n; i++) {
		dap += a[i];
		st.insert(a[i]);
	}
	dp[n] = dap;
	for (int i = n + 1; i <= n*2; i++) {
		dap += a[i];
		st.insert(a[i]);
		auto it = st.begin();
		dap -= *it;
		st.erase(it);
		dp[i] = dap;
	}
	st.clear();
	dap = 0;
	for (int i = 3 * n; i > 2 * n; i--) {
		dap += a[i];
		st.insert(a[i]);
	}
	dp1[2 * n + 1] = dap;
	for (int i = 2 * n; i > n; i--) {
		dap += a[i];
		st.insert(a[i]);
		auto it = st.end();
		it--;
		dap -= *it;
		st.erase(it);
		dp1[i] = dap;
	}
	dap = -999999999999999;
	for (int i = n; i <= 2 * n; i++) {
		dap = max(dap, dp[i] - dp1[i + 1]);
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 10752