akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  cin >> S;
  ll ans1 = 0;
  ll ans2 = 0;
  REP(i, S.size()){
    if(i%2==0 && S[i]=='0') ans1++;
    else if(i%2==0 && S[i]=='1') ans2++;
    else if(i%2==1 && S[i]=='0') ans2++;
    else if(i%2==1 && S[i]=='1') ans1++;
  }

  cout << min(ans1, ans2) << "\n";

  return 0;
}

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

int main() {
  int N, Q, l, r;
  cin >> N >> Q;

  string S;
  cin >> S;

  vector<int> s(N+1, 0);
  for (int i = 0; i < N; ++i) {
    if (i + 1 < N && S.at(i) == 'A' && S.at(i + 1) == 'C')
      s.at(i + 1) = s.at(i) + 1;
    else
      s.at(i + 1) = s.at(i);
  }

  for (int i = 0; i < Q; i++) {
    cin >> l >> r;
    l--;
    r--;
    cout << s.at(r) - s.at(l) << endl;
  }
}

Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
int n, k, q;
int a[2005];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> n >> k >> q;
  vector<int> v;
  f(i,0,n)
    cin >> a[i], v.pb(a[i]);

  sort(v.begin(),v.end());
  v.resize(unique(v.begin(),v.end()) - v.begin());

  int ans = INT_MAX;
  for(auto x : v){
    int lo = x, hi = 2e9;
    while(lo<hi){
      int md = lo+(hi-lo)/2;
      int cnt = 0;
      for(int i = 0, j = 0; i < n; i = j){
        if(a[i] < x)j=i+1;
        else {
          int c = 0,cnt2=0;
          for(;j<n&&a[j]>=x;j++)c++,cnt2+=(a[j]<=md);
          cnt+=min(cnt2,max(0,c-k+1));
        }
      }
//      cout<<md<<' '<<cnt<<'\n';
      if(cnt>=q)
        hi = md;
      else
        lo = md + 1;
    }
    ans =min(ans,lo-x);
  }

  cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 256
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;	
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}

template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;

int fpow(int a, int n) {
	int ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	double den = 0;
	int n; cin >> n;
	For(i,0,n) {
		double x; cin >> x;
		den += 1/x;
	}
	cout << fixed << setprecision(9) << 1/den;
	return 0;
}

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

int main()
{
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n+1, 0);
  vector<ll> b(m+1, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i+1];
    a[i+1]+=a[i];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> b[i+1];
    b[i+1]+=b[i];
  }
 
  int res = 0;
  int j = m;
  for (int i = 0; i < n+1; i++)
  {
    if (a[i] > k) 
    {
      break;
    }
    while (a[i] + b[j] > k) 
    {
      j--;
    }
    res = max(res, i+j);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6416
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
const lli mx=100001;
vector<pii>adj[mx];
bool vis[mx];
lli clr[mx];
void dfs(lli sn,lli dis)
{
    vis[sn]=true;
    for(lli i=0;i<adj[sn].size();i++)
    {
        lli d=adj[sn][i].first;
        lli v=adj[sn][i].second;
        if((dis+d)%2==0)
        {
            clr[v]=1;
        }

        if(!vis[v])
        {
            dfs(v,dis+d);
        }
    }
    return ;
}
int main()
{
    lli n,u,v,w;
    cin>>n;
    for(lli i=0;i<n-1;i++)
    {
        cin>>u>>v>>w;
        u--;
        v--;
        adj[u].pb({w,v});
        adj[v].pb({w,u});
    }
    memset(clr,0,sizeof(clr));
    memset(vis,false,sizeof(vis));
    clr[0]=1;
    dfs(0,0);
    for(lli i=0;i<n;i++)
    {
        cout<<clr[i]<<endl;
    }
}


Measured memory_bytes: 11896
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{

    ll i,j,k,n,m,c,cnt,s=0;
    vector<ll>v[30];
    vector<ll>u;

    cin>>n>>m>>c;
    for(i=0;i<m;i++)
    {
        cin>>k;
        u.push_back(k);
    }
    for(i=0;i<n;i++)
    {
        cnt=0;
        for(j=0;j<m;j++)
        {
            cin>>k;
            cnt+=k*u[j];

        }
        cnt+=c;
        if(cnt>0)
        {
            s++;
        }
    }
    cout<<s<<endl;
    return 0;
}


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

int main() {
  
  vector<int> vec = {1,3,1,2,1,2,1,1,2,1,2,1};
  
  int x,y;
  cin >> x >> y;
  
  if(vec.at(x-1) == vec.at(y-1)) {
    cout << "Yes" <<endl;
  }
  
  else {
    cout << "No" <<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using ld=long double;

void solve(long long a, long long b, long long x){
  if(x*2>=a*a*b){
    cout<<fixed<<setprecision(10)<<180.0L*atan2(2.0L*(a*a*b-x),1.0L*a*a*a)/M_PI<<endl;
  }else{
    cout<<fixed<<setprecision(10)<<90.L-180.0L*atan2(2.0L*x,1.0L*a*b*b)/M_PI<<endl;
  }
}

int main(){
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
  long long x;
  scanf("%lld",&x);
  solve(a, b, x);
  return 0;
}


Measured memory_bytes: 256
n,m,x,y=map(int ,input().split())
a=list(map(int ,input().split()))
b=list(map(int ,input().split()))
l=a[0]
r=b[0]
for i in a:
    l=max(l,i)
        
    
           
for i in b:
    r=min(r,i)
if l==r:
    if r==y:
        print('No War')
    else:
        print('War')
elif l>r:
    print('War')
elif l>x and r<=y:
    print('No War')
else:
    print('War')

Measured memory_bytes: 38384
#include <cstring>
#include <algorithm>
#include <cstdio>

const int N = 3010;
const int MOD = 1e9+7;
int _w;

void add_mod( int &a, int b ) {
	a += b;
	a -= a >= MOD ? MOD : 0;
}

int n, m, f[N][N][2];

void solve() {
	for( int i = 0; i <= n; ++i )
		f[0][i][0] = 1;
	for( int i = 0; i < m; ++i ) {
		for( int j = 0; j <= n; ++j ) {
			if( f[i][j][0] ) {
				if( j ) {
					if( j == 1 ) {
						add_mod( f[i+1][j][1], f[i][j][0] );
						add_mod( f[i+1][j-1][1], f[i][j][0] );
					} else {
						add_mod( f[i+1][j][0], f[i][j][0] );
						add_mod( f[i+1][j-1][0], f[i][j][0] );
					}
				}
				if( j < n ) {
					if( !j ) {
						add_mod( f[i+1][j][1], f[i][j][0] );
						add_mod( f[i+1][j+1][1], f[i][j][0] );
					} else {
						add_mod( f[i+1][j][0], f[i][j][0] );
						add_mod( f[i+1][j+1][0], f[i][j][0] );
					}
				}
			}
			if( f[i][j][1] ) {
				if( j ) {
					add_mod( f[i+1][j][1], f[i][j][1] );
					add_mod( f[i+1][j-1][1], f[i][j][1] );
				}
				if( j < n ) {
					add_mod( f[i+1][j][1], f[i][j][1] );
					add_mod( f[i+1][j+1][1], f[i][j][1] );
				}
			}
		}
	}
	int ans = 0;
	for( int i = 0; i <= n; ++i )
		add_mod( ans, f[m][i][1] );
	printf( "%d\n", ans );
}

int main() {
	_w = scanf( "%d%d", &n, &m );
	solve();
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, m; cin >> n >> m;
    vector<vector<ll>> sw(n, vector<ll>());
    rep(i, m){
        ll k; cin >> k;
        rep(j, k){
            ll s; cin >> s;
            sw[s-1].push_back(i);
        }
    }
    vector<ll> cond(m);
    rep(i, m) cin >> cond[i];

    ll cnt = 0;
    for(ll i = 0; i < (1LL << n); ++i){
        vector<ll> light(m, 0);
        for(ll j = 0; j < n; ++j){
            if(!(i & (1LL << j))) continue;
            for(auto k : sw[j]){
                light[k]++;
            }
        }
        ll tmp = 0;
        rep(j, m){
            if(light[j]%2 == cond[j]){
                tmp++;
            }
        }
        if(tmp == m) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

typedef long double ld;
typedef long long int lli;
typedef pair <lli, lli> pii;
#define pb push_back
#define recout(x) return cout << (x), 0
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
#define all(x) x.begin(), x.end()
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const lli N = 1e5 + 10, N2 = 2e5, delta = 46639, mod = 1e9 + 7, oo = 1e18, LOG = 20, SQ = 300;
const ld PI = 3.141592653589793;

lli dp[102][N];

int32_t main() {
	fast;
	lli n, W, ans = 0;
	cin >> n >> W;
	for (lli i = 0; i < 101; i++)
		memset (dp, 63, sizeof dp);
	dp[0][0] = 0;
	for (lli i = 1; i <= n; i++) {
		lli w, v;
		cin >> w >> v;
		for (lli j = 0; j < N; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= v)
				dp[i][j] = min (dp[i][j], dp[i - 1][j - v] + w);
			if (dp[i][j] <= W)
				ans = max (ans, j);
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 80000
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            bool flag = false;
            for (int i = 0; ; i++)
            {
                string[] num = Console.ReadLine().Split();

                if (int.Parse(num[0]) == 0 && int.Parse(num[1]) == 0) return;

                for (int j = 1; j <= int.Parse(num[0]); j++)
                {

                    for (int k = 1; k <= int.Parse(num[1]); k++)
                    {
                        if (j == 1 || j == int.Parse(num[0]))
                        {
                            flag = true;
                        }
                        else
                        {
                            flag = false;
                        }
                        if (k == 1 || k == int.Parse(num[1]) || flag == true)
                        {
                            flag = true;
                        }
                        else
                        {
                            flag = false;
                        }
                        if (flag)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");

                        }
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }
}



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

bool g[10][10];

int main() {
  int n,m;
  cin >> n >> m;
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a][b] = true;
    g[b][a] = true;
  }

  std::vector<int> v(n);
  rep(i,n) v[i] = i;


  int ans = 0;
  do {

    if (v[0] != 0) break;
    bool ok = true;
    rep(i,n-1) {
      if (!g[v[i]][v[i+1]]) ok = false;
    }
    if (ok) ans++;
  }while (next_permutation(v.begin(),v.end()));

  cout << ans << endl;
}


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

string S;

bool check(string str) {
    int len = str.length();
    int af = len / 2;
    for (int i = 0; i < af; i++) {
        if (str[i] != str[len-i-1]) {
            return false;
        }
    }
    return true;
}

void Main(){
    int len = S.length();
    int af = len / 2;
    if (check(S) && check(S.substr(0, af))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return;
}

int main() {
    
    cin >> S;
    Main();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000000
 
int A[MAX],B[MAX],C[MAX];
int main(){
    int n,i;
 
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&A[i]);
}
for(i = 1;i <= MAX;i++){
    C[i]=0;
}
for(i=1;i<=n;i++){
    C[A[i]]++;
}
for(i=1;i<=MAX;i++){
    C[i] = C[i] + C[i - 1];
}
for(i = n; i >= 1;i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
}

for(i=1;i<=n;i++){
  if(i==n){
  printf("%d\n",B[i]);
      }else{   
 printf("%d ",B[i]);
 }
}
return 0;
}

Measured memory_bytes: 55892
n,k = map(int,input().split())
a = [0] +list(map(int,input().split()))
for i in range(n):
    a[i+1] += a[i] 
nums = []
for i in range(n):
    for j in range(i+1,n+1):
        nums.append(a[j]-a[i])
nums.sort(reverse = True)
def count(x,lis):
    res = 0
    for i in range(len(lis)):
        if (lis[i]&x) == x:res+=1
    return res
def ok(x,lis):
    if count(x,lis) >=k:return True
    else:return False
ans = 0
for i in range(40,-1,-1):
    if ok(ans|1<<i,nums):ans|=1<<i

print(ans)


Measured memory_bytes: 69756
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  int n;
  ll ans=1;
  string s;
  cin >> n;
  cin >> s;
  map<char,int> mp;
  for(char c='a';c<='z';c++) mp[c]=0;
  for(int i=0;i<n;i++){
    mp[s[i]]++;
  }
  for(char c='a';c<='z';c++){
    if(mp[c] != 0){
      ans = ans*(mp[c] + 1)%1000000007;
    }
  }
  cout << ans - 1;
  return 0;
}

Measured memory_bytes: 512
n = int(input())


def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


ans = 0
for i in range(105, n+1, 2):
    if len(set(make_divisor_list(i))) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n;
    cin >> n;
    REP(a, 1, 3501) {
        REP(b, 1, 3501) {
            int bunshi = n * a * b;
            int bunbo = 4 * a * b - (a+b) * n;
            if(bunbo > 0 && bunshi % bunbo == 0 && bunshi / bunbo > 0) {
                cout << a << " " << b << " " << bunshi / bunbo << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c;
    }
    else if(a ==c){
        cout << b;
    }
    else{
        cout << a;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <ctype.h>

int main() {

  char s1[10];
  char s2[10];
  char s3[10];

  scanf("%s %s %s", s1, s2, s3);

  putchar(toupper(s1[0]));
  putchar(toupper(s2[0]));
  putchar(toupper(s3[0]));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  bool flag = false;
  int k = -1;
  for(int i=0; i*i<=2*N; i++){
    if(2*N == i*(i+1)){
      flag = true;
      k = i;
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
    cout << k+1 << endl;
    vector<vector<int>> ans(k+1,vector<int>(k));
    int cnt = 1;
    for(int i=0; i<k+1; i++){
      for(int j=i; j<k; j++){
        ans.at(i).at(j) = cnt;
        cnt++;
      }
    }
    cnt = 1;
    for(int j=0; j<k; j++){
      for(int i=j+1; i<k+1; i++){
        ans.at(i).at(j) = cnt;
        cnt++;
      }
    }
    for(int i=0; i<k+1; i++){
      cout << k << " ";
      for(int j=0; j<k; j++){
        cout << ans.at(i).at(j);
        if(j == k-1){
          cout << endl;
          break;
        }
        cout << " ";
      }
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;


// 凸包(を構成する点集合)を求める
// (x, y)が小さい点から反時計回りに入る
// O(NlogN)
// 頂点数はO(\sqrt(N))個になる
template<class X>
vector<int> convex_hull(vector<pair<X, X>> &xy){
    int n = xy.size();

    vector<tuple<X, X, int>> xyid(n);
    for(int i=0; i<n; i++)
        xyid[i] = make_tuple(xy[i].first, xy[i].second, i);

    sort(xyid.begin(), xyid.end());
    vector<int> ch;
    ch.reserve(n);

    // 下側凸包の作成
    // x が小さい点から追加していく
    // 更新のたびに古い点を消すかどうか判断する
    for(int i=0; i<n; i++){
        X x, y;
        int id;
        tie(x, y, id) = xyid[i];
        for(int j = ch.size() - 1; j > 0; j--){
            int id0 = ch[j-1], id1 = ch[j];
            X x0 = xy[id0].first, y0 = xy[id0].second;
            X x1 = xy[id1].first, y1 = xy[id1].second;
            X dx0 = x1 - x0, dy0 = y1 - y0;
            X dx1 = x - x1, dy1 = y - y1;
            X cross = dx0 * dy1 - dy0 * dx1;
            if(cross < 0) ch.pop_back();
            else break;
        }
        ch.push_back(id);
    }
    // 上側凸包の作成
    // 下側の時に n-1 番目の点は必ず追加されているので n-2 から
    // 0 まで見てから最後に pop_back する
    int k = ch.size() - 1;
    for(int i=n-2; i>=0; i--){
        X x, y;
        int id;
        tie(x, y, id) = xyid[i];
        for(int j = ch.size() - 1; j >= k; j--){ // k は下側まで戻るのを防ぐために必要
            int id0 = ch[j-1], id1 = ch[j];
            X x0 = xy[id0].first, y0 = xy[id0].second;
            X x1 = xy[id1].first, y1 = xy[id1].second;
            X dx0 = x1 - x0, dy0 = y1 - y0;
            X dx1 = x - x1, dy1 = y - y1;
            X cross = dx0 * dy1 - dy0 * dx1;
            if(cross < 0) ch.pop_back();
            else break;
        }
        ch.push_back(id);
    }
    ch.pop_back();
    ch.shrink_to_fit();

    return ch;
}

int main(){
    int N;
    cin >> N;
    vector<pair<double, double>> xy(N);
    for(int i=0; i<N; i++) cin >> xy[i].first >> xy[i].second;
    if(N == 2){
        cout << 0.5 << endl;
        cout << 0.5 << endl;
        return 0;
    }

    vector<int> ch = convex_hull(xy);
    vector<double> ans(N, 0.0);
    int M = ch.size();

    //for(int i=0; i<N; i++)
    //    cerr << xy[i].first << " " << xy[i].second << endl;
    //cerr << endl << endl;
    //for(auto i : ch)
    //    cerr << xy[i].first << " " << xy[i].second << endl;


    for(int i=0; i<M; i++){
        int id = ch[i]; 
        int j = ch[(i + 1) % M];
        int k = ch[(i - 1 + M) % M];
        double x0 = xy[k].first,  y0 = xy[k].second;
        double x1 = xy[id].first, y1 = xy[id].second;
        double x2 = xy[j].first,  y2 = xy[j].second;

        double dx0 = x1 - x0, dy0 = y1 - y0;
        double dx1 = x2 - x1, dy1 = y2 - y1;

        double nrm0 = sqrt(dx0*dx0+dy0*dy0);
        double nrm1 = sqrt(dx1*dx1+dy1*dy1);
        double dot = dx0*dx1+dy0*dy1;
        double tmp = dot / (nrm0*nrm1);

        double theta = acos(tmp);
        ans[id] = theta / (2*M_PI);
    }
    for(int i=0; i<N; i++)
        cout << fixed << setprecision(32) << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 256
n,l = map(int,input().split())
aji = [l+i for i in range(n)]
mn= 100
for i in range(n):
    mn= min(mn,abs(aji[i]))
if mn in aji:del aji[aji.index(mn)]
else:del aji[aji.index(-mn)]
print(sum(aji))

Measured memory_bytes: 9092
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head




int main() {
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if (n==1&&a!=b) return puts("0"),0;
	if (a>b) return puts("0"),0;
	ll L = a*(n-1ll)+b;
	ll R = a+b*(n-1ll);
	printf("%lld\n", R-L+1);
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
const int num = 100005;
typedef long long ll;
ll a[num],dp[num];
int main()
{
	int n;
	cin >> n;
	rep(i,1,n+1)
	{
		cin >> a[i];
	}
	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	rep(i,3,n+1)
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
	//rep(i,1,n+1)
	//	cout << dp[i] << " ";
	 cout << dp[n] << "\n";
	 return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int sz=1e5 + 5;

string k;
int d,n;

void add_self(int& a,int b){
	a+=b;
	if(a>=mod){
		a-=mod;
	}
}

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>k>>d;
    n=k.length();
    vector<vector<int>> dp(d,vector<int>(2));
    dp[0][0]=1;
    
    for(int digit=0;digit<n;digit++){
    	vector<vector<int>> new_dp(d,vector<int>(2));
    	for(int j=0;j<d;j++){
    		for(int already_small: {false,true}){
    	        for(int i=0;i<10;i++){
    	        	
    				if(i > k[digit]-'0' && !already_small){
    					break;
					}
					add_self(new_dp[(j+i)%d][already_small || (i<k[digit]-'0')],
					dp[j][already_small]);
				}
			}
		}
		dp=new_dp;
	}
	int answer=(dp[0][0]+dp[0][1])%mod;
	answer-=1;
	if(answer<0)answer+=mod;
	cout<<answer<<"\n";
   
}



Measured memory_bytes: 256
#include<stdio.h>
int cost[100000];
int min(int a,int b){
        if(a>b) return b;
        return a;
}
int aabs(int n){
        if(n>0) return n;
        return -n;
}
int main(void){
        int n;
        int i;
        int h[100000];
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d",&h[i]);
        }
        if(h[1]>h[0]){
                cost[1]=h[1]-h[0];
        }else{
                cost[1]=h[0]-h[1];
        }
        for(i=2;i<n;i++){
                cost[i]=min(cost[i-2]+aabs(h[i]-h[i-2]),cost[i-1]+aabs(h[i]-h[i-1]));
        }
        printf("%d\n",cost[n-1]);
        return 0;
}

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

int main(void){
  int n;
  cin>>n;
  
  vector<int>rate(n);
  for(int i=0;i<n;i++){
    cin>>rate.at(i);
  }
  
  int count[9]={0};
  for(int i=0;i<n;i++){
    if(rate.at(i)<400)count[0]++;
    else if(rate.at(i)<800)count[1]++;
    else if(rate.at(i)<1200)count[2]++;
    else if(rate.at(i)<1600)count[3]++;
    else if(rate.at(i)<2000)count[4]++;
    else if(rate.at(i)<2400)count[5]++;
    else if(rate.at(i)<2800)count[6]++;
    else if(rate.at(i)<3200)count[7]++;
    else count[8]++;
  }
  
  int ans=0;
  for(int i=0;i<=7;i++){
    if(count[i]!=0)ans++;
  }
  
  if(count[8]==0){
    cout<<ans<<' '<<ans<<endl; 
  }else{
    if(ans==0)cout<<1<<' '<<ans+count[8]<<endl;
    else cout<<ans<<' '<<ans+count[8]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=4005,MOD=924844033;

int C[MAXN][MAXN],dp[MAXN][MAXN][2];
int len[MAXN];
bool ed[MAXN];
vector<int> chain;
int fac[MAXN];
void Init()
{
    C[0][0]=1;
    for(int i=1;i<MAXN;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
    fac[0]=1;
    for(int i=1;i<MAXN;i++)
        fac[i]=1LL*fac[i-1]*i%MOD;
}

int main()
{
    Init();
    int N,K;
    scanf("%d%d",&N,&K);

    for(int i=1;i<=N;i++)
    {
        len[i]=(i-K>0)+(i+K<=N);
        ed[i]=true;
        if(i>2*K)
            len[i]+=len[i-2*K],ed[i-2*K]=false;
    }
    for(int i=1;i<=N;i++)
        if(ed[i]&&len[i])
            chain.push_back(len[i]);
    dp[0][0][0]=1;
    int mx;
    for(int i=1,j=-1,k=1;j<(int)chain.size();i++,k++)
    {
        if(j==-1||k>chain[j])
        {
            j++,k=1;
            if(j>=(int)chain.size())
                break;
            for(int p=1;p<=i;p++)
                dp[i][p][1]=(dp[i-1][p-1][0]+dp[i-1][p-1][1])%MOD;
        }
        else
        {
            for(int p=1;p<=i;p++)
                dp[i][p][1]=dp[i-1][p-1][0];
        }
        for(int p=0;p<=i;p++)
            dp[i][p][0]=(dp[i-1][p][0]+dp[i-1][p][1])%MOD;
        mx=i;
    }

    int ans=fac[N];
    for(int i=1,f0=-1;i<=N;i++,f0=-f0)
    {
        int tmp=0;
        tmp=(tmp+(dp[mx][i][0]+dp[mx][i][1])%MOD)%MOD;
        tmp=(tmp+MOD)%MOD;
        tmp=1LL*tmp*fac[N-i]%MOD;
        ans=(ans+f0*tmp)%MOD;
    }
    ans=(ans+MOD)%MOD;
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 186496
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;

}
//##################################################################
int main(){
    int n=D(),k=D(),c=D();
    string a;
    cin>>a;
    int l[n],r[n];
    int ind=0;
    for(int i=0;i<n;i++){
        if(a[i]=='o'){
            l[ind++]=i;
            i+=c;
            if(ind==k)break;
        }

    }
    ind=k-1;
    for(int i=n-1;i>=0;i--){
        if(a[i]=='o'){
            r[ind--]=i;
            i-=c;
            if(ind==-1)break;
        }

    }
    for(int i=0;i<k;i++){
        if(l[i]==r[i])cout<<l[i]+1<<"\n";
    }

}

Measured memory_bytes: 3332
<?php

$line = explode(' ', fgets(STDIN));

$A = (int)$line[0];
$B = (int)$line[1];
$C = (int)$line[2];
$K = (int)$line[3];

if($A > $K){
  echo $K; 
}else if($A >= $K || $A + $B >= $K){
  echo $A;
}else {
  echo $A - ($K - ($A + $B));
}


Measured memory_bytes: 16156
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n;
pair<pair<string, int>, int> p[1010];


int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> p[i].first.first >> p[i].first.second;
		p[i].second = i+1;
	}
	sort(p, p+n);
	
	for(int i = 0; i < n; i++){
		int j = i;
		while(p[j].first.first == p[j+1].first.first){
			j++;
		}
		for(int k = j; k >= i; k--){
			cout << p[k].second << endl;
		}
		i = j;
	}
	
	return 0;
}

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

using namespace std;

#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_N 201

int N;
int score[MAX_N][3];
int table[MAX_N][3];

int main() {
  cin >> N;
  rep(i, N) {
    rep(j, 3) cin >> table[i][j];
  }
  rep(game, 3) {
    rep(i, N) score[i][game] = table[i][game];
    rep(i, N) {
      for (int j=i+1; j<N; j++) {
        // ????????°?????\?????????????????¢??????????????¢???0?????????
        if (table[i][game] == table[j][game]) {
          int x = table[i][game];
          score[i][game] = 0;
          score[j][game] = 0;
        }
      }
    }
  }
  rep(i, N) cout << score[i][0]+score[i][1]+score[i][2] << '\n';
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s;
    cin >> s;
    set<int> se;
    for(int i = 1; i < 100000; i++)
    {
        if(!se.insert(s).second)
        {
            cout << i << endl;
            return 0;
        }
        if(s % 2 == 0)
        {
            s /= 2;
        }
        else
        {
            s = 3*s + 1;
        }
    }
}



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

long long MOD = 1000000007;
long long SUM[401][401] = {};

long long Calc(long long L, long long R, long long K) {
	return (SUM[K][R] - SUM[K][L] + MOD) % MOD;
}

int main() {
	long long N, C;
	cin >> N >> C;
	vector<long long> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 1; i <= 400; i++) {
		long long NOW = 1;
		for (int j = 0; j <= 400; j++) {
			SUM[j][i] = (SUM[j][i - 1] + NOW) % MOD;
			NOW = (NOW * i) % MOD;
		}
	}
	vector<vector<long long> > DP(N + 1, vector<long long>(C + 1, 0));
	DP[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= C; j++) {
			for (int l = 0; j + l <= C; l++) {
				DP[i + 1][j + l] += (DP[i][j] * Calc(A[i] - 1, B[i], l)) % MOD;
				DP[i + 1][j + l] %= MOD;
			}
		}
	}
	cout << DP[N][C] << endl;
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int count = 0;
        int bcount = 0;

        for(int i=0;i<n; i++) {
        	if(sc.nextInt()==count+1) {
        		count++;
        	}else {
        		bcount++;
        	}
        }

        System.out.println(bcount!=n?bcount:-1);
        sc.close();
    }
}


Measured memory_bytes: 63112
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,A[100001],sum[100001],cnt=0;
  cin >> N;
  REP(i,N)cin >> A[i];
  sort(A,A+N);
  sum[0] = A[0];
  for(int i=1;i<N;i++)
    sum[i] = sum[i-1] + A[i];
  cnt++;
  for(int i=N-2;i>=0;i--){
    if(2*sum[i] >= A[i+1]){
      cnt++;
    }
    else
      break;
  }
  cout << cnt << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 1792
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[]) {
		
		int n = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for (int i=0; i<n; i++) list.add(sc.nextInt());
		
		for (int i=0; i<n; i++) {

			for (int j=0; j<i; j++) {
				if (list.get(i) < list.get(j)) {
					Collections.swap(list, i, j);
				}
			}

			for (int j=0; j<n; j++) {
				System.out.print((j==0?"":" ")+list.get(j));
			}
			System.out.println();
			
		}
		
	}
}


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

#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;



int32_t main()
{
            IOS;

            int n, a, b;
            cin>>n>>a>>b;


            int full = floor(n/(a+b));

            int ans = full*a;

            n -= full*(a+b);

            ans += n > a ? a : n;
            
            cout<<ans<<endl;



            



      


        
























            return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	n--;
	int l = 0;
	int h=n;
	int ans=0;
	while(l<h)
	{
		if(s[l]!=s[h])
			ans++;
		l++,h--;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	 if(a<b && b<c){
	 	printf("Yes\n");
	 }else{
	 	printf("No\n");
	 }
	return 0;
}

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

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

const ll INF = 1e15;

int main(){
  ll N,M,R;
  cin >> N >> M >> R;
  vector<ll> r(R);
  for(int i=0;i<R;i++){
    cin >> r[i];
    r[i]--;
  }
  vector<vector<ll>> dist(N, vector<ll>(N, INF));
  for(int i=0;i<M;i++){
    ll A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    dist[A][B] = C;
    dist[B][A] = C;
  }
  for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        if(i == j)
          dist[i][j] = 0;
        else
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  vector<vector<ll>> dp((1 << R) + 1,vector<ll>(R, INF)); // dp[mati][now] = kyori
  ll ans = INF;
  for(int i=0; i<R;i++)
    dp[1<<i][i] = 0;
  for(int mati=1;mati<(1<<R)-1;mati++){
    for(int from=0;from<R;from++){
      for(int use = 0; use<R; use++){
        if((mati & (1<<use)) != 0)
          continue;
        dp[mati | (1<<use)][use] = min(dp[mati | (1<<use)][use], dp[mati][from] + dist[r[from]][r[use]]);
        ans = min(ans, dp[(1<<R)-1][use]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;

const int MOD = 1000000007;


int dp[100001];

void add_self(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

void sub_self(int& a, int b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}


int main() {


	FAST_IO;
	int n, k, sum = 0;
	cin >> n >> k;
	vector<int> a(n + 1);
	dp[0] = 1;
	int up_to;
	for (int child = 1; child <= n; ++child) {
		cin >> up_to;
		vector<int> fake(k + 1);
		for (int used = k; used >= 0; --used) {
			int tmp = dp[used];
			int L = used + 1;
			int R = used + min(up_to, k - used);
			if (L <= R) {
				add_self(fake[L], tmp);
				if (R + 1 <= k)
					sub_self(fake[R + 1], tmp);
			}
		}
		int prefix_sum = 0;
		for (int i = 0; i <= k; ++i) {
			add_self(prefix_sum, fake[i]);
			add_self(dp[i], prefix_sum);
		}
	}
	cout << dp[k];
	return 0;
}


Measured memory_bytes: 1024
#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 <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
    long long x;
    cin >> x;
    long long x500, x5;
    x500=x/500;
    x-=x500*500;
    x5=x/5;
    cout << (x500*1000)+(x5*5) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt = 0;
  int i;
  for(i=0;i<=(s.size()-1)/2;i++){
    if(s[i]!=s[s.size()-1-i]) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x,y; cin >> x >> y;
    ll cnt = 0;
    ll j = 1;
    ll t = x;
    for (ll i=x; i<=y; ++i) {
        if (t<=y) {
            cnt++;
            t *= 2;
        }
        if (t>y) break;
    }
    cout << cnt << "\n";

}



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

int main() {
	// your code goes here
	int data[10],ansdata[3];
	for (int j = 0;j<3;j++) {
		ansdata[j] = 0;
	}
	for (int i=0;i<=9;i++) {
		cin >> data[i];
		if (i==0) {
			ansdata[0] = data[i];
		}
		if (i>0) {
			if (data[i] > ansdata[2]) {
				if (data[i] > ansdata[1]) {
					ansdata [2] = ansdata [1];
					if (data[i] > ansdata[0]) {
						ansdata [1] = ansdata [0];
						ansdata [0] = data [i];	
					}
					else {
						ansdata[1] = data[i];
					}
					
				}
				else {
					ansdata[2] = data[i];
				}
			}

		}
	}
	cout << ansdata[0] << endl << ansdata[1] << endl << ansdata [2] <<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>

struct pizza {
	std::size_t v, n;
	pizza(std::size_t v_, std::size_t n_) :v{ v_ }, n{n_} {}
};

int main() {
	std::size_t A, B, C, X, Y;
	std::cin >> A >> B >> C >> X >> Y;

	pizza a(A, X), b(B, Y);
	size_t total[5]{};
	std::fill(total, total+5, 100'000'000'000);

	total[0] = a.n * a.v + b.n *b.v;
	total[1] = 2 * C * std::max(b.n, a.n);

	total[2] = 2 * C*std::min(b.n, a.n);
	//total[2]+= (b.n < a.n) ? (a.n - b.n)*a.v : (b.n - a.n)*b.v;
	total[2] += (X < Y?(Y - X)*B :(X-Y) * A);
	/*for (auto&e : total) {
		//std::cout << e << "\n";
	}*/
	auto it = std::min_element(std::begin(total), std::end(total));
	std::cout << *it << "\n";
//	std::cin >> A;
	return 0;
}


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

 int main()
{
    int N, u, v;
     cin >> N;
     vector<int> X(N);
     for(int i = 0;i<N;i++){
     cin >> X.at(i);
     }
     sort(X.begin(),X.end());
     u = X.at(0);
     v = X.at(N-1);
     vector<int> s(v-u+1);
     for(int i = u;i<=v;i++){
        for(int j =0;j<N;j++){
         s.at(i-u) += (X.at(j)-i)*(X.at(j)-i);
     }
     }
     sort(s.begin(),s.end());
     cout << s.at(0) << endl;
    return 0;
}


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



int main(){
    set <string> ST;
    ll N; cin >> N;
    for(int i = 0; i < N; i++){
        string temp; cin >> temp;
        ST.insert(temp);
    }
    cout << (ll)ST.size() << endl;
}


Measured memory_bytes: 19208
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
 
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n){
    cin >> l.at(i);
  }
  int count = 1;
  int d = 0;
  rep(i,n){
    d += l.at(i);
    if(d <= x) count++;
    else{
      cout << count;
      return 0;
    }
  }
  cout << count;
}

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

int N, K, x[100005], ans = 1e15;

signed main(){
  
  cin>>N>>K;
  
  int f1 = 0, f2 = 0;
  
  for(int i=0;i<N;i++){
    cin>>x[i];
    if( x[i] < 0 ) f1 = 1;
    if( x[i] > 0 ) f2 = 1;
  }
  
  if( f1 && f2 ){
    
    int idx = 0;
    
    for(int i=0;i<N;i++){
      
      if( x[i] >= 0 ){
	idx = i;
	break;
      }
      
    }
    
    for(int i=0;i<idx;i++){
      
      if( idx - i == K ) ans = min( ans, abs( x[i] ) );
      
      else if( idx - i + N - idx >= K ){
	
	ans = min( ans, abs( x[i] ) * 2 + x[ idx + K - ( idx - i ) - 1 ] );
	
      }
      
    }
    
    for(int i=0;i<N;i++) x[i] = -x[i];
    
    sort( x, x + N );
    
        for(int i=0;i<N;i++){
      
      if( x[i] >= 0 ){
	idx = i;
	break;
      }
      
    }
    
    for(int i=0;i<idx;i++){
      
      if( idx - i == K ) ans = min( ans, abs( x[i] ) );
      
      else if( idx - i + N - idx >= K ){
	
	ans = min( ans, abs( x[i] ) * 2 + x[ idx + K - ( idx - i ) - 1 ] );
	
      }
      
    }

    cout<<ans<<endl;
    
  }else{
    
    for(int i=0;i<N;i++) x[i] = abs( x[i] );
    
    sort( x, x + N );
    
    cout<<x[K-1]<<endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 1024
W,H,n = map(int,input().split())
H_ls = [1] * H
W_ls = [1] * W
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        for i in range(x):
            W_ls[i] = 0
    elif a == 2:
        for i in range(x,W):
            W_ls[i] = 0
    elif a == 3:
        for i in range(y):
            H_ls[i] = 0
    else:
        for i in range(y,H):
            H_ls[i] = 0
ans = 0
for x in range(W):
    for y in range(H):
        if H_ls[y] and W_ls[x]:
            ans += 1
print(ans)




Measured memory_bytes: 9200
#include <iostream>

using namespace std;

int dp0(int a, int b, int c, int x);
int dp1(int b, int c, int x);

int dp0(int a, int b, int c, int x ){
    if(x==0) return 1;
    else if (x<0 || a<0) return 0;
    else return dp0(a-1, b, c, x-10) + dp1(b,c,x);
}

int dp1(int b, int c, int x) {
    if(x==0) return 1;
    else if (x<0 || b<0) return 0;
    else return dp1(b-1, c, x-2) + ((c>=x)? 1: 0);
}

int main(int argc, char const *argv[])
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    x/=50;
    cout << dp0(a,b,c,x) << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys
A, B = map(int, input().split())
if A == B:
    print("Draw")
    sys.exit()
if A > B:
    if B == 1:
        print("Bob")
    else:
        print("Alice")
else:
    if A == 1:
        print("Alice")
    else:
        print("Bob")

Measured memory_bytes: 3316
import numpy as np
s=input()
k=int(input())
cnt=1
a=[]
ss=s+"."
for i in range(len(s)):
    if ss[i]==ss[i+1]:
        cnt+=1
    else:
        a.append(cnt)
        cnt=1

pp=0
if s[0]==s[len(s)-1]:
    pp=a[0]+a[-1]
    
    b=[]
    if len(a)>1:
        b.append(pp)
        b+=a[1:len(a)-1]

    else:
        a=[len(s)*k]
        b=[]

else:
    
    b=a
arr=np.array(a)
arr2=np.array(b)

a=arr//2
b=arr2//2
if len(s)>=2:
    print(np.sum(a)+int((k-1)*np.sum(b)))
else:
    print(k//2)

Measured memory_bytes: 12392