akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
void solve()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int b[n] = {0};
    for (int i = 0; i < 34; i++)
    {
        int c = 0;
        int d = 0;
        for (int j = 0; j < n; j++)
        {
            int f = ((a[j] >> i)&1);
            
             c=c^f;
        }
        
        if (c==0)
        {
            for (int j = 0; j < n; j++)
            {
                int f = ((a[j] >> i)&1);
                if (f)
                {
                    int d = pow(2, i);
                    b[j] += d;
                }
            }
        }
        else
        {
            for (int j = 0; j < n; j++)
            {
                int f = ((a[j] >> i)&1);
                if (f == 0)
                {
                    int d = pow(2, i);
                    b[j] += d;
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << b[i] << " ";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 7200
N = int(input())
A = list(map(int,input().split()))

r = 0
ans = 0
s = x = 0
for l in range(N):
    r = max(l,r)
    while r < N and (s+A[r]) == (x^A[r]):
        s += A[r]
        x ^= A[r]
        r += 1
    s -= A[l]
    x ^= A[l]
    ans += r - l
print(ans)

Measured memory_bytes: 24840
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s;
    cin >> s;
    ll sum=0;
    for(auto ch:s){
        ll i=ch-'0';
        sum+=i;
    }
    Yes(sum%9==0);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>l(m);
    vector<int>r(m);
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i];
    }
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    int a=r[0]-l[m-1]+1;
    if(a<0)a=0;
    cout<<a;
}

Measured memory_bytes: 3940
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

void call(int n) {
    for (int i=1; i<=n; ++i) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    call(n);
    return 0;
}

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

int main(){
	string s;int a[10];
	while(cin >> s){
		for(int i = 0;i < 10;i++)a[i] = s[i]-'0';
		for(int i = 9;i > 0;i--){
			for(int j = 0;j < i;j++){
				a[j] = (a[j] + a[j+1]) % 10;
			}
		}
		//for(int i = 0;i < 10;i++)cout << a[i] << " ";
		//cout << endl;
		cout << a[0] << endl;
	}
	return 0;
}

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

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

  int n = s.size();
  int ret = n;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) {
      if (i + 1 > n - i - 1) {
        ret = min(ret, i + 1);
      } else {
        ret = min(ret, n - i - 1);
      }
    } 
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
//#define int long long
int main(){
  int n,m,k,f=0,cnt=0;
  cin>>n>>m>>k;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(i*m+j*n-i*j*2==k)f++;
    }
  }
  if(f)cout<<"Yes";
  else cout<<"No";
  return 0;
}


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

int main()
{
int A;
int B;

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

	cin >> A;
	cin >> B;

	if( A + B >= 10 )
		cout << "error" << endl;
	else
		cout << A + B << endl;

	return 0;
}






Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		int n,m;

		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String[] inputline = stdIn.readLine().split(" ");


		n = Integer.parseInt(inputline[0]);
		m = Integer.parseInt(inputline[1]);

		int[][] matrixA = new int[n][m];

		for(int i = 0; i < n; i++) {
			inputline = stdIn.readLine().split(" ");
			for(int j = 0; j < m; j++) {
				matrixA[i][j] = Integer.parseInt(inputline[j]);
			}
		}

		int[] vectorB = new int[m];

		for(int i = 0; i < m; i++) {
			inputline = stdIn.readLine().split(" ");
			vectorB[i] = Integer.parseInt(inputline[0]);
		}

		int[] vectorC = new int[n];

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				vectorC[i] += (matrixA[i][j] * vectorB[j]);
			}
		}

		for(int i : vectorC) {
			System.out.println(i);
		}
	}

}

Measured memory_bytes: 27944
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define asd(i,n,N) for(int i=n;i< N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>> " << #x << " -> " << x << endl
#define mems(x,y) memset(x,y,sizeof x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e6+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;

ll tc,x,k,d,mv;

int main(){
//	cout<<fixed<<setprecision(2);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>x>>k>>d;
    x = abs(x);
    if(x/d>=k)cout<<x-k*d<<endl;
    else {
    	mv = x/d;
    	x-= d*mv, k-= mv;
    	if(k&1)cout<<abs(x-d)<<endl;
    	else cout<<x<<endl;
	}
    return 0;
}

Measured memory_bytes: 3648
N=int(input())
a1=input().split()
a2=[int(i) for i in a1]
for x in a2:
    if x%2==0:
        if x%3==0:
            continue
        if x%5==0:
            continue
        else:
            print("DENIED")
            break
else:
    print("APPROVED")

Measured memory_bytes: 9208
#include "bits/stdc++.h"
using namespace std;
int a , b , c , d , e , f;
int num , den;
int main(){
	cin >> a >> b >> c >> d >> e >> f;
	num = 0;
	den = 100 * a;
	for(int i = 0 ; i <= 50 ; ++i){
		for(int j = 0 ; j <= 50 ; ++j){
			int mx = e * (i * a + j * b);
			mx = min(mx , f - (i * a + j * b) * 100);
			if(mx <= 0){
				continue;
			}
			for(int k = 0 ; k * c <= mx ; ++k){
				int rem = mx - k * c;
				int l = (rem / d);
				int newnum = k * c + l * d;
				int newden = newnum + (i * a + j * b) * 100;
				if(newnum * den > num * newden){
					num = newnum;
					den = newden;
				}
			}
		}
	}
	printf("%d %d\n" , den , num);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
int main(){
   dd r;
   cin>>r;
   dd pi=acos(-1);
   cout<<2.00*pi*r;
   
  
}


Measured memory_bytes: 3784
N,M = map(int,input().split())
SCdash = [[int(i) for i in input().split()] for m in range(M)]
SC = [[scc[0]-1,str(scc[1])] for scc in SCdash]
SG = [(0,10),(10,100),(100,1000)]
for x in range(*SG[N-1]):
    keta = str(x)
    if all([keta[s]==c for s,c in SC]):
        print(x)
        exit()
print(-1)


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

int main() {
  long long N, X, D; cin >> N >> X >> D;
 
  if (D == 0) {
    if (X == 0) cout << 1 << endl;
    else cout << N + 1 << endl;
    return 0;
  }

  if (D < 0) {
    X += D * (N - 1);
    D = -D;
  }

  set<long long> s;
  rep(i, N + 1) {
    long long tmp = (X * i) % D;
    if (tmp < 0) tmp += D;
    s.insert(tmp);
  }
  map<long long, int> map;
  int cnt = 0;
  for (long long x : s) {
    map[x] = cnt;
    cnt++;
  }

  vector<vector<pair<long long, long long>>> vec(s.size());

  rep(i, N + 1) {
    long long num = (X * i) / D;
    long long m = (X * i) % D;
    if (m < 0) {
      m += D;
      num--;
    }
    long long minD = (long long)i * (i - 1) / 2;
    long long maxD = (long long)i * (N - 1) - minD;
    int k = map[m];
    vec[k].emplace_back(minD + num, 1);
    vec[k].emplace_back(maxD + num + 1, -1);
  }


  long long ans = 0;
  rep(i, s.size()) {
    sort(vec[i].begin(), vec[i].end());
    long long now;
    int check = 0;
    for (auto x : vec[i]) {
      if (check == 0) {
        now = x.first;
        check++;
        continue;
      }
      if (x.second == 1) {
        check++;
      }
      if (x.second == -1) {
        check--;
        if (check == 0) {
          ans += x.first - now;
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 36224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int maxx = 2e5 + 5;
//int a[101];
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
       ios_base::sync_with_stdio(false);
       cin.tie(0);
       string ans = "YES";
 int n;  
 cin>>n;
 int a[n];
 for(int i =0; i<n ;i++){
 	cin>>a[i];
 }
 sort(a,a+n);
 for(int i =0 ;i<n;i++){
 	if(a[i]== a[i+1]){
 		ans = "NO";
 	}
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 4328
dictionary = dict()

for i in range(int(input())):
    query = [i for i in input().split()]
    if query[0] == "0":
        dictionary.update({query[1]:query[2]})
        
    elif query[0] == "1":
        if not query[1] in dictionary.keys():
            print(0)
        else:
            print(dictionary[query[1]])    
    elif query[0] == "2":
        try:
            dictionary.pop(query[1])
        except:
            pass



Measured memory_bytes: 41876
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <cstddef>
#include <memory>

using namespace std;

class Node
{
public:
    shared_ptr<Node> left;
    shared_ptr<Node> right;
    int  value;
    Node()
    {
        left  = nullptr;
        right = nullptr;
        value = 0;
    }
};

using node_ptr = shared_ptr<Node>;

vector<Node> Aar;
vector<Node> Bar;


void input(vector<Node> & ar,const string & str,int & i,node_ptr & ptr)
{
    if(str[i]==')')
    {
        ++i;
        return;
    }

    ptr = make_shared<Node>();


    if(str[i]=='(')
    {
        ++i;
        input(ar,str,i,ptr->left);
    }
    if(str[i]=='[')
    {
        ++i;
        while(str[i]!=']')
        {
            ptr->value*=10;
            ptr->value+=(int)(str[i]-'0');
            ++i;
        }
        ++i;
    }
    if(str[i]=='(')
    {
        ++i;
        input(ar,str,i,ptr->right);
    }
    if(str[i]==')')
    {
        ++i;
        return;
    }
}

void output(node_ptr a, node_ptr b)
{
    if(a==nullptr || b==nullptr) return;

    cout << "(" << flush;
    output(a->left,b->left);
    cout << ")" << flush;

    cout << "[" <<a->value + b->value << "]" << flush;

    cout << "(" << flush;
    output(a->right,b->right);
    cout << ")" << flush;
}

int main()
{
    string A,B;
    cin >> A >> B;

    int si=0;
    node_ptr Aptr;
    input(Aar,A,si,Aptr);

    si = 0;
    node_ptr Bptr;
    input(Bar,B,si,Bptr);

    output(Aptr,Bptr);

    cout << endl;
}


Measured memory_bytes: 3240
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_least8_t;
using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u8 = std::uint_least8_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  usize n;
  std::cin >> n;
  u32 ans = 0;
  std::vector<u32> v(n);
  for (auto &e : v) {
    std::cin >> e;
  }
  for (const auto e : v) {
    u32 c;
    std::cin >> c;
    if (c < e) {
      ans += e - c;
    }
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

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

  int a = N / 1.08;
  if (ceil(N / 1.08) < ceil((N + 1) / 1.08))
    cout << ceil(N / 1.08) << endl;
  else
    cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    set<int> toN;
    vector<int> fromzero;

    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        if(a == 1)
            fromzero.push_back(b-1);
        else if(b == n)
            toN.insert(a-1);
    }
    bool flag = false;
    for(auto c: fromzero){
        if(toN.count(c)){
            flag = true;
            break;
        }
    }
    cout << (flag?"POSSIBLE":"IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 5368
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    int i;
    for(i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p,p+n);
    int c=0;
    for(i=0;i<k;i++){
        c+=p[i];
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3644
x = int(input())

a = x % 100
b = (x - a)//100

fa = False
fb = False

if 0 < a <= 12:
    fa = True
if 0 < b <= 12:
    fb = True
if fa & fb:
    print("AMBIGUOUS")
elif fa:
    print("YYMM")
elif fb:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
using namespace std;


int main(void) {

  string s;
  getline(cin, s);
  for(int i=0; i<s.size(); i++){
    if( s[i]-'A' >= 0 && s[i]-'A' < 26 ) s[i] += 32;
    else if( s[i]-'a' >= 0 && s[i]-'a' < 26 ) s[i] -= 32;

    cout << s[i];
  }
  cout << endl;


  return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#include<cstdio>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)


int main() {
	string S;
	cin >> S;
	for (int j = 1; j < S.size(); j++) {
		for (int i = 0; i < j; i++) {
			if (S[i] == S[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

Matrix mat;
int n, m;

int cost(int mask, int x) {
  int k = 0, a = 0, b = 0, c = 0;
  vector<int> arr(m);
  for (int i = 0; i < (n); ++i) {
    if ((mask >> i) & 1ll) {
      k += mat[i].front();
      for (int j = 1; j <= m; ++j) {
        arr[j - 1] += mat[i][j];
      }
    }
  }
  if (*min_element(all(arr)) < x)
    return INF;

  return k;
}

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;

  // cin >> t;
  t = 1;

  while (t--) {
    int x;
    cin >> n >> m;

    cin >> x;
    mat = Mat(n, m + 1, 0);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m + 1; ++j)
        cin >> mat[i][j];

    int ans = INF;
    for (int i = 0; i < (1ll << n); ++i) {
      ans = min(ans, cost(i, x));
    }

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


Measured memory_bytes: 3660
use proconio::input;
//use proconio::marker::{Bytes, Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}

fn main() {
    input!{
        n: usize,
    }
    let mut ans = 0;
    for i in 1..n+1 {
        let y = n/i;
        ans += y * (y+1) * i / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2136
from collections import deque

def nearlist(N, LIST):
    NEAR = [set() for _ in range(N)]
    for a, b in LIST:
        NEAR[a - 1].add(b - 1)
        NEAR[b - 1].add(a - 1)
    return NEAR


def bfs(NEAR):  # 幅優先探索  # キュー
    que, frag = deque([0]), set([0])
    while que:
        q = que.popleft()
        for i in NEAR[q]:  # 移動先の候補
            if i in frag:  # 処理済みか否か
                continue
            ans[i] += ans[q]
            que.append(i), frag.add(i)
    return

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]
px = [list(map(int, input().split())) for _ in range(q)]

ans = [0] * n
for p, x in px:
    ans[p - 1] += x

near = nearlist(n, ab)
bfs(near)
print(*ans, sep='\n')


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class Mod{
  public:
    ll mod;
    // mod must be a prime number
    Mod(ll m){
        mod = m;
    }
    //a^p
    ll modpow(ll a, ll p){
        if(p == 0) return 1;
        if(p%2 == 0){
            ll half = modpow(a, p/2);
            return half * half % mod;
        }
        else return a * modpow(a,p-1) % mod;
    }

    //nCr
    ll comb(ll n, ll r){
        if(r > n-r) return comb(n,n-r);
        ll mul = 1;
        ll div = 1;
        for (int i = 0;i < r;i++){
            mul *= n-i;
            mul %= mod;
            div *= i+1;
            div %= mod;
        }
        return mul * modpow(div,mod-2) % mod;
    }
};

long long gcd(long long x,long long y){
	if(x==0) return y;
	return gcd(y%x, x);
}

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

    Mod m(1e9+7);
    ll N; cin >> N;
    ll A[100005];
    map<ll,ll> lis;
    for (int i = 0;i < N;i++){
        cin >> A[i];
        ll tmp = A[i];
        map<ll,ll> cnt;
        for (ll j = 2;j*j <= A[i];j++){
            ll tt = 1;
            while(tmp%j == 0){
                tmp /= j;
                tt *= j;
                tt %= m.mod;
                cnt[j] = tt;
            }
            //cout << i << " " << tmp << endl;
        }
        if(tmp != 1) cnt[tmp] = tmp;
        for(auto&& j:cnt){
            lis[j.first] = max(lis[j.first],j.second);
        }
    }  

    ll lcm = 1;
    for(auto&& i:lis){
        //cout << i.first << " " << i.second << endl;
        lcm *= i.second;
        lcm %= m.mod;
    }

    //cout << lcm << endl;

    ll ans = 0;
    for (int i = 0;i < N;i++){
        ans += lcm*(m.modpow(A[i],m.mod-2)%m.mod);
        ans %= m.mod;
        //cout << ans << endl;
    }

    cout << ans << endl;

    return 0;

}

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

int main() {
  int i;
  ll N,m,x,nx;
  cin >> N;
  for(i=0; i<5; i++) {
    cin >> x;
    if(i==0 || x<nx)
      nx = x;
  }
  
  m = N/nx+4;
  if(N%nx!=0)
    m++;
  cout << m << endl;
}

Measured memory_bytes: 384
from itertools import combinations as comb
N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]
Cans = -1
for i in range(1, N+1):
    for lsts in comb(CA, i):
        Csum = 0
        buf = [0]*M
        for lst in lsts:
            Csum += lst[0]
            for j, v in enumerate(lst[1:]):
                buf[j] += v

        if Cans == -1 or Csum < Cans:
            flag = True
            for v in buf:
                if v < X:
                    flag = False
                    break
            if flag:
                Cans = Csum

print(Cans)


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

void char_replace(char a, char b, string &s) {
  REP(i, s.size()) {
    if (s[i] == a) s[i] = b;
  }
}

int main() {
  string s, t;
  cin >> s >> t;
  reverse(ALL(s));
  reverse(ALL(t));
  priority_queue<string, vector<string>, greater<string>> ans;
  REP(i, s.size() - t.size() + 1) {
    bool flag = true;
    FOR(j, 0, t.size()) {
      if (s[i + j] != t[j] && s[i + j] != '?') {
        flag = false;
        break;
      }
    }
    if (flag) {
      string tmp(s);
      tmp.replace(i, t.size(), t);
      char_replace('?', 'a', tmp);
      reverse(ALL(tmp));
      ans.push(tmp);
    }
  }

  string ans_str = ans.empty() ? "UNRESTORABLE" : ans.top();
  cout << ans_str << endl;
}

Measured memory_bytes: 256
// Name: Kanisht Agarwal Copyright Think before u copy //
//Connect with me at LinkedIn

#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.1415926535897932
#define nui 100
#define INF 100000000000
using namespace std;


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}

clock_t time_p = clock();

void TLE()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

struct point
{
    int x; int y;
};
bool segment(point p, point q, point r)
{
    if (q.x <= max(p.x, r.x) && q.y <= max(p.y, r.y) && q.x >= min(p.x, r.x) && q.y >= min(p.y, r.y))
        return true;

    return false;
}
int orientation(point p, point q, point r)
{
    int o = (r.x - q.x) * (q.y - p.y) - (r.y - q.y) * (q.x - p.x);
    if (o == 0)return 0;
    return (o > 0) ? 1 : 2;
}
bool intersection(point p, point q, point r, point s)
{
    int o1 = orientation(p, q, r);
    int o2 = orientation(p, q, s);
    int o3 = orientation(r, s, p);
    int o4 = orientation(r, s, q);
    if (o1 != o2 && o3 != o4)return true;
    if (o1 == 0 && segment(p, r, q))return true;
    if (o2 == 0 && segment(p, s, q))return true;
    if (o3 == 0 && segment(r, p, s))return true;
    if (o4 == 0 && segment(r, q, s))return true;

    return false;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    int a[n];
    int ct = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (i & 1 && a[i] & 1)
        {
            ct++;
        }
    }
    cout << ct << "\n";

    return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll INF = 1LL << 58;
const int SZ = 1000 * 1000 * 4 + 10;
int H, W;
ll K;
vector<string> t;

ll memo[SZ];

int id(int r, int c, int d) {
  return (r * W + c) * 4 + d;
}
int getD(int id) { return id % 4; }
int getR(int id) { return (id / 4) / W; }
int getC(int id) { return (id / 4) % W; }

bool canEnter(int r, int c) {
  return 0 <= r && r < H && 0 <= c && c < W && t[r][c] == '.';
}
const int dr[4] = {0, -1, 0, 1};
const int dc[4] = {1, 0, -1, 0};

struct State {
  int id;
  ll cost;
  bool operator < (const State& o) const {
    return cost > o.cost;
  }
};

int main2() {
  REP(i, SZ) memo[i] = INF;

  H = nextLong();
  W = nextLong();
  K = nextLong();

  int x1 = nextLong() - 1;
  int y1 = nextLong() - 1;
  int x2 = nextLong() - 1;
  int y2 = nextLong() - 1;

  t = vector<string>(H);
  REP(i, H) cin >> t[i];

  priority_queue<State> q;
  REP(i, 4) {
    q.push(State{ id(x1, y1, i), 0} );
    memo[id(x1, y1, i)] = 0;
  }
  while (!q.empty()) {

    State s = q.top(); q.pop();
    const int curr = s.id;
    const int r = getR(curr);
    const int c = getC(curr);
    const int d = getD(curr);

    REP(i, 4) { // 今いる場所で、方向転換する。次の状態のコストは、今のコストの切り上げ。
      int nr = r;
      int nc = c;
      if (!canEnter(nr, nc)) continue;
      int next = id(nr, nc, i);
      ll n_cost = (memo[curr] + K - 1) / K * K;
      if (memo[next] > n_cost) {
        memo[next] = n_cost;
        q.push(State{next, memo[next]});
      }
    }
    REP(i, 4) if (i == d) { // 今向いている方向へコスト 1/K
      int nr = r + dr[i];
      int nc = c + dc[i];
      if (!canEnter(nr, nc)) continue;
      int next = id(nr, nc, i);
      if (memo[next] > memo[curr] + 1) {
        memo[next] = memo[curr] + 1;
        q.push(State{next, memo[next]});
      }
    }

  }

  ll ans = INF;
  REP(d, 4) chmin(ans, ((ll)memo[id(x2,y2,d)] + K - 1) / K);
  if (ans >= H*W) ans = -1;
  cout << ans << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 44216
/*
❤️❤️❤️I_love_QMsh❤️❤️❤️
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // <int> .find_by_order(int) .order_of_key(int)

template<typename T> bool smin(T &a, const T &b) { bool ret = b < a; return a = (ret ? b : a), ret; }
template<typename T> bool smax(T &a, const T &b) { bool ret = a < b; return a = (ret ? b : a), ret; }

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd;

const int N = 1e5 + 30;
const int B = 17;

int dp[N][B];

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) {
    cin >> i;
  }
  int L;
  cin >> L;
  a.push_back(a.back() + L);

  dp[n - 1][0] = n;
  dp[n][0] = n;
  for (int i = n - 2; i >= 0; i--) {
    dp[i][0] = dp[i + 1][0];
    while (a[dp[i][0]] - a[i] > L) {
      dp[i][0]--;
    }
  }

  for (int b = 1; b < B; b++) {
    for (int i = 0; i <= n; i++) {
      dp[i][b] = dp[dp[i][b - 1]][b - 1];

    }
  }

  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) {
      swap(a, b);
    }
    int ans = 0;
    
    for (int bit = B - 1; a < b && bit >= 0; bit--) {
      if (dp[a][bit] < b) {
        a = dp[a][bit];
        ans += (1 << bit);
      }
    }
    cout << ans + 1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 10348
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;

  vector<bool> A(N);
  for (ll j = 0; j < K; j++) {
    ll d;
    cin >> d;
    for (ll i = 0; i < d; i++) {
      ll x;
      cin >> x;
      A[x - 1] = true;
    }
  }
  ll ans = count_if(begin(A), end(A), [](auto x) { return !x; });

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




Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> v;
    
    for(int i = 0, tmp; i < N; i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    if(v[N/2] >= v[(N/2)-1]){
        cout << v[N/2] - v[(N/2)-1] << endl;
    }
    return 0;
    
}

Measured memory_bytes: 892
# 138a https://atcoder.jp/contests/abc138/tasks/abc138_a

# 入力
a = int(input())
s = input()

# 処理
if a < 2800 or a >= 5000:
    answer = '制約値外です'
elif a >= 3200:
    answer = s
elif a < 3200:
    answer ='red'

# 出力
print(answer)

Measured memory_bytes: 9024
from collections import Counter
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, k, l = map(int, sys.stdin.buffer.readline().split())
    a = UnionFind(n)
    b = UnionFind(n)
    cnt = 0
    for x in sys.stdin.buffer.readlines():
        p, q = map(int, x.split())
        cnt += 1
        if cnt <= k:
            a.union(p-1, q-1)
        else:
            b.union(p-1, q-1)

    pairs = [(a._root(i), b._root(i)) for i in range(n)]
    d = Counter(pairs)
    ans = [d[x] for x in pairs]
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n;
    string s;
    cin >> n >> s;

    map<pair<string, string>, ll> mp;
    zep(bit, 0, (1LL << n)){
        string r = "", b = "";

        zep(i, 0, n){
            if(bit & (1LL << i)){
                r += s[i];
            }
            else{
                b += s[i];
            }
        }
        reverse(r.begin(), r.end());
        reverse(b.begin(), b.end());
        
        auto p = make_pair(b, r);
        if(mp.find(p) == mp.end())
            mp[p] = 0;
        mp[p]++;
    }

    ll ans = 0;
    zep(bit, 0, (1LL << n)){
        string r = "", b = "";

        zep(i, 0, n){
            if(bit & (1LL << i)){
                r += s[i+n];
            }
            else{
                b += s[i+n];
            }
        }
        auto p = make_pair(r, b);
        if(mp.find(p) != mp.end())
            ans += mp[p];
    }
    print(ans)

    return 0;
}

Measured memory_bytes: 41216
#include<stdio.h>

int main(){
  int x1,y1,x2,y2,a,b;
  scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
  a=y2-y1,b=x2-x1;
  printf("%d %d %d %d\n",(x1 + b - a),(y1 + a + b),(x1 - a),(y1 + b));
  return 0;
}


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

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

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

ll n, k;
ll num[100100];

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll solve() {
    ll res = 0;
    for (ll i = k; i >= 1; i--) {
        ll cnt = 1;
        ll cnt_over = 0;
        for (ll j = i+i; j <= k; j+=i) {
            cnt++;
            cnt_over += num[j];
            cnt_over %= mod;
        }
        ll p = mod_pow(cnt, n);
        p = (p - cnt_over + mod) % mod;
        num[i] = p;
        res += p * i;
        res %= mod;
    }
    return res;
}

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

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

    input();
    cout << solve() << endl;
}


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

int main() {
 int N;
  int X;
  int Y;
  cin >> N >> X >> Y;
  int a;
  int b;
  int c;
  int d;
 vector<int> ans(N-1);
  for(int i=1; i<N; i++){
  for(int j=i+1; j<(N+1); j++){
   a= j-i;
    if(i-X>0){
    c=i-X;
  }
    else{
      c=X-i;
    }
    if(j-Y>0){
    d=j-Y;
  }
    else{
      d=Y-j;
    }
    b = c + d +1;
    
    
    if(a<b){
      ans.at(a-1) = ans.at(a-1) +1;
    }
    else{
      ans.at(b-1) = ans.at(b-1) +1;
    
  }
  
  }
  }
  
    for(int i=0; i<(N-1); i++){
      cout << ans.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import Control.Applicative
import qualified Data.HashMap.Strict as Map
 
main = do
  [_,capa] <- map (read :: String -> Int) . words <$> getLine
  goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
  print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)
 
resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] (capa-w)
    koushin capaMap [v,w] n
      | n == 0 && capaMap Map.! w <= v        = Map.insert w v capaMap
      | n == 0                                = capaMap
      | oldValue == 0                         = next
      | capaMap Map.! (n+w) >= v + oldValue   = next
      | otherwise = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n-1)
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n-1)

Measured memory_bytes: 7824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace app1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            int N = int.Parse(NK[0]);
            int K = int.Parse(NK[1]);
            char[] S = new char[N];

            S = Console.ReadLine().ToCharArray();

            K -= 1;

            if(K >= 0)
            {
                switch (S[K])
                {
                    case 'A':
                        S[K] = 'a';
                        break;
                    case 'B':
                        S[K] = 'b';
                        break;
                    case 'C':
                        S[K] = 'c';
                        break;
                    default:
                        break;
                }
            }
            string str = new string(S);

            Console.WriteLine($"{str}");
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

int main(void){

int n,s[100000],a;

while(scanf("%d",&n) != EOF){
if(n==0){
break;
}
int sum=0;
for(int i=1; i<=n; i++){
scanf("%d",&s[i]);
sum += s[i];
}
a=sum/n;
int count=0;
for(int i=1; i<=n; i++){
if(s[i]<=a){
count++;
}
}
printf("%d\n",count);
}
return 0;
}



Measured memory_bytes: 2044
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 10000
#define MAX_M 100

typedef long long int ll;
using namespace std;



int main(){

	int a,b;

	scanf("%d %d", &a, &b);

	if(a < b)
		printf("a < b\n");
	else if(a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;

}

Measured memory_bytes: 1168
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#include "./Lib/Timer.h"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;
	cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    }

}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	ll sum=0;
	cin>>s;
	for(ll i=0;i<s.length();i++){
		sum+=stoll(s.substr(i,1));
	}
	if(sum%9==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3744
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,x;
void solve()
{
    cin>>n>>x;ll ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    ans=1;
    ll chk=0;
    for(int i=0;i<n;i++)
    {
        chk+=ar[i];
        if(chk>x)
            break;
        ans++;
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
al = [chr(ord('a') + i) for i in range(26)]
li = ['a']
for i in range(1,N):
    k = []
    li = set(li)
    for s in li:
        count = len(set(list(s)))
        for m in range(count+1):
            nk = s+al[m]
            k.append(nk)
    li = k
n = len(li)
li.sort()
for i in range(n):
    print(li[i])

Measured memory_bytes: 13192