akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;

int main(){
	IOS
	string a, b;
	cin >> a >> b;
	a=a+b;
	int ans=stoi(a);
	int burik=sqrt(ans);
	if(burik*burik==ans){
		cout << "Yes" << '\n';
	}
	else{
		cout << "No" << '\n';
	}
}

Measured memory_bytes: 256
//カルノー図っぽいものをメモっていたら分かった
#include<iostream>
using namespace std;

int pointer = 0;
int Re[10000],I[10000],J[10000],K[10000];

int main(){
	int n;
	int x1,y1,z1,w1,x2,y2,z2,w2;
	
	while( cin >> n ){
		if(n == 0)
			break;
		for( int i = 0;i < n;i++ ){
			cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
			Re[ pointer ] = x1*x2 - y1*y2 -z1*z2 - w1*w2;
			I[ pointer ] = x1*y2 + x2*y1 + z1*w2 - z2*w1;
			J[ pointer ] = x1*z2 + x2*z1 -y1*w2 + y2*w1;
			K[ pointer ] = x1*w2 + y1*z2 - y2*z1 + x2*w1;
			pointer++;
		}
	}
	for(int i = 0;i < pointer;i++)
		cout << Re[i] << " "<< I[i] << " "<< J[i]<< " " << K[i] << endl;
	return 0;
}

Measured memory_bytes: 1180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		n = sc.nextInt();
		m = sc.nextInt();
		sc.close();
		int ans;
		int tmp = m * 1900 + (n - m) * 100;
		int r = (int)Math.pow(2,  m);
	//	System.out.println(tmp);
		ans = (r * tmp);
		System.out.println(ans);
	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int dp[10000005]={0};
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,w;
    cin>>n>>w;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
    	for(int j=w;j>=0;j--){
    		dp[j+a[i]]=max(dp[j+a[i]],dp[j]+b[i]);
        }
    }
    int ans=0;
    for(int i=0;i<=w;i++){
    	ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5092
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 310000;

int n;
int p[MAXN];
int ad[MAXN];

void no() {
	cout << "No\n";
	exit(0);
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i], --p[i];
		if (i % 2 != p[i] % 2)
			no();
	}
	for (int i = 0; i < n; ++i) {
		if (i < p[i]) {
			++ad[i + 1];
			--ad[p[i] + 1];
		}
		else if (i > p[i]) {
			++ad[p[i] + 1];
			--ad[i + 1];
		}
	}
	int now[2] = {};
	for (int i = 0; i < n; ++i) {
		now[i % 2] += ad[i];
		if (now[i % 2] && p[i] != i)
			no();
	}
	set<int> ss[2];
	for (int i = 0; i < n; ++i) {
		int x = i % 2;
		if (i <= p[i]) {
			if (ss[x].size() && *ss[x].rbegin() > p[i])
				no();
		}
		ss[x].insert(p[i]);
	}
	for (int i: {0, 1})
		ss[i].clear();
	for (int i = n - 1; i >= 0; --i) {
		int x = i % 2;
		if (i >= p[i]) {
			if (ss[x].size() && *ss[x].begin() < p[i])
				no();
		}
		ss[x].insert(p[i]);
	}
	cout << "Yes\n";
	return 0;
}




Measured memory_bytes: 16640
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, n) for (ll i = n; i >= 0; i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cerr << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cerr << e << " "; } cerr << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************

int main() {

    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }

    vector<bool> dp(K + 1, false);

    FOR(i, 1, K + 1) {
        bool flag = false;
        for (auto& a : A) {
            if (i - a < 0) continue;
            if (dp[i - a] == false) {
                flag = true;
                dp[i] = true;
                break;
            }
        }
        if (!flag) dp[i] = false;
    }

    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;


#ifdef _MSC_VER
    system("PAUSE");
#endif
    return 0;
}



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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> words(N);

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

	map<string,int> counter;
	string tmp_str;
	long long cnt = 0;
	for (int i = 0; i < N; ++i) {
		tmp_str = words[i];
		sort(tmp_str.begin(), tmp_str.end());
		cnt += counter[tmp_str];
		++counter[tmp_str];
		//cout << tmp_str << ':' << counter[tmp_str] << endl;
	}

	//for (auto word : counter) {
	//	cnt += word.second * (word.second-1) / 2;
	//}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

  int N; cin>>N;
  string s; cin>>s;
  if(N%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  string t=s.substr(0,N/2);
  t+=t;
  cout<<(s==t? "Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
/**
 *   Praveen Fulera    
**/

// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;
#define endl '\n'
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>
#define debug(x) cerr << #x << " is " << x << endl;

const int mod = 1e9 + 7;
//const int mod = 998244353;

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   //freopen("output.txt", "w", stdout);
  // #endif
  int a, b; cin >> a >> b;
  if(a == 1 || b == 1){
    cout << "1\n"; return 0;
  }
  int ans = (a*b)/2 + (a*b)%2;
  cout << ans << '\n';
}


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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 50;
int n;
string s[MAX_N];


int main() {
  cin >> n;
  rep(i,n) cin >> s[i];
  rep(i,n) sort(all(s[i]));

  map<char, int> ans;
  for (char c = 'a'; c <= 'z'; ++c) {
    ans[c] = 50;
  }

  for (int i = 0; i < n; ++i) {
    map<char, int> tmp;
    for (int j = 0; j < s[i].length(); ++j) {
      tmp[s[i][j]]++;
    }
    for (char c = 'a'; c <= 'z'; ++c) {
      ans[c] = min(ans[c], tmp[c]);
    }
  }
  
  for (char c = 'a'; c <= 'z'; ++c) {
    for (int i = 1; i <= ans[c]; ++i) {
      cout << c;
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define int long long int
#define N 200005
void fast(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
main()
{
    string s;
    cin>>s;
    int k;
    cin>>k;
    // int a[105]={0};
    int ans=0;
    int n=s.length();
    for(int i=0;i<s.length();){
        char c=s[i];
        int x=0;
        while(i<n&&s[i]==c){
            x++;
            i++;
        }
        // a[i-1]=x;
        if(x==n){
            cout<<(x*k)/2<<endl;
            return 0;
        }
        ans+=(x/2);
    }
    if(s[0]!=s[n-1]||k==1){
        cout<<ans*k<<endl;
    }
    else {
        int i=0;
        while(i<n&&s[i]==s[0]){
            i++;
        }
        i--;
        int j=n-1;
        while(j>=0&&s[j]==s[n-1]){
            j--;
        }
        j++;
        // cout<<i<<" "<<j<<endl;
        ans=(((n-1-j+1)+((i-0+1)))/2)*(k-1);
        // cout<<ans<<endl;
        for(int l=i+1;l<=j-1;){
            char c=s[l];
            int x=0;
            while(l<n&&s[l]==c){
                x++;
                l++;
            }
            ans+=k*(x/2);
        }
        for(int l=0;l<=i;){
            char c=s[l];
            int x=0;
            while(l<n&&s[l]==c){
                x++;
                l++;
            }
            ans+=(x/2);
        }
        for(int l=j;l<=n-1;){
            char c=s[l];
            int x=0;
            while(l<n&&s[l]==c){
                x++;
                l++;
            }
            ans+=(x/2);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    string s,t;
    cin >> s >> t;
    ll result = 0;
    rep(i,s.size()){
        if(s[i] != t[i]){
            result++;
        }
    }
    cout << result;
}

Measured memory_bytes: 3800
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int ans;
    ans = c-a+b;
    if(ans < 0) ans = 0;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
 
#define ll long long 
#define repd(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) repd(i, 0, n)
using namespace std;
 
int main(){
  string s;
  string t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
#define Mx 1000000000005 
#define ll long long  
#define pi 3.141592653
#define vi vector<ll>
#define Mo 1000000007
#define mp make_pair
#define M map<ll,ll>
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define vii vector<pair<ll,ll> > 
#define fi first
#define se second
#define pb push_back
#define ld long double
#define fill(a,x) memset(a,x,sizeof(a))
using namespace std;
bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
  return a.second<b.second;
}
/*vi b=v;
   sort(b.begin(), b.end());
  b.resize(unique(b.begin(), b.end()) - b.begin());
  ll t; cin>>t; fr(f,0,t){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 */
ll func(ll l,ll r,ll a[])
{
  if(l==r) return a[l];
  if(r-l==1) return max(a[l],a[r]);

  ll x=a[l]+min(func(l+1,r-1,a),func(l+2,r,a));
  ll y=a[r]+min(func(l,r-2,a),func(l+1,r-1,a));
  return max(x,y);
}
int main()
{
  ll n,sum=0; cin>>n;
  ll a[n];
  fr(i,0,n)
  {
    cin>>a[i];
    sum+=a[i];
  }


  ll dp[n][n],x,y,z;

  fr(i,0,n)
    dp[i][i]=a[i];

  fr(l,2,n+1)
  {
    fr(i,0,n-l+1)
    {
      ll j=i+l-1;
      if(j-i==1) { dp[i][j]=max(a[i],a[j]); continue; }

      x=dp[i+1][j-1]; y=dp[i+2][j]; z=dp[i][j-2];
      dp[i][j]=max(a[i]+min(x,y),a[j]+min(z,x));
    }
  }

  cout<<2*dp[0][n-1]-sum;
}

Measured memory_bytes: 49840
#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+c > 21){
        cout << "bust";
    }
    else
    {
        cout << "win";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


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

	int cnt = 0;
	for (int i = 1; i <= N; i++)
	{
		if (i < 10) cnt++;
		else if (i >= 100 && i < 1000) cnt++;
		else if (i >= 10000 && i < 100000) cnt++;
	}

	cout << cnt << endl;
}











Measured memory_bytes: 256
A, B, C, D = map(int, input().split())


def gcd(a, b):
    if b > a:
        return gcd(b, a)
    
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)


def count(n, c, d):
    n_c = n // c
    n_d = n // d
    g = gcd(c, d)
    n_cd = n // (c * d // g)
    return n - n_c - n_d + n_cd


print(count(B, C, D) - count(A - 1, C, D))

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


int main() {

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n-1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
from math import gcd 
k = int(input())
sss = 0
for a in range(1,k+1):
    for b in range(a+1,k+1):
        tmp = gcd(a,b)
        sss += 6*tmp
        for c in range(b+1,k+1):
            sss += 6*gcd(tmp,c)
sss += k*(k+1)//2
print(sss)

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

int arr[200000] = { 0 };

int main()
{
	int n;
	long long result = 0;

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

	sort(arr, arr + n);

	int maxim = n - 1;
	for (int i = 1; i < n; i++)
	{
		if (i % 2 == 0)
		{
			maxim--;
		}

		result += arr[maxim];
	}

	cout << result << endl;
}


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


int main() {
  int A, B, C; cin >> A >> B >> C;
  
  if(A%2==1||B%2==1||C%2==1) {
    cout << 0 << endl;
    return 0;
  }
  
  int a=(B+C)/2,b=(A+C)/2,c=(A+B)/2;
  int ans = 1;
  
  while(a!=A||b!=B||c!=C) {
    if(a%2==1||b%2==1||c%2==1) {
      cout << ans << endl;
      return 0;
    }
    int aa=(b+c)/2,bb=(a+c)/2,cc=(a+b)/2;
    a=aa;b=bb;c=cc;
    ans++;
  }
  

  cout << -1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;
 
int main() {
	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	ll x = N / K;
	ans += x*x*x;
	if (K%2==0 && N >= K / 2) {
		ll y = (N - K / 2) / K + 1;
		ans += y*y*y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 10010020030040056ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if ((a[i] + a[j] > a[k]) and (a[i] + a[k] > a[j]) and (a[j] + a[k] > a[i]))
                {
                    if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

const ll inf = 10000000;

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;
    } else {
        return false;
    }
}

int N, M;
int a[1050], b[1050], c[1050][20];

void input() {
    cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        cin >> a[i] >> b[i];
        for (int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }
}

void solve() {
    input();
    const int INF = 1e9;
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for (int item = 1; item <= M; item++) {
        int now = 0;
        for (int j = 1; j <= b[item]; j++) {
            now |= (1 << (c[item][j]-1));
        }
        for (int bits = 0; bits < (1 << N); bits++) {
            chmin(dp[bits | now], dp[bits]+a[item]);
        }
    }
    if (dp[(1<<N)-1] == INF) dp[(1<<N)-1] = -1;
    cout << dp[(1<<N)-1] << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, K;

	cin >> N >> K;
	cout << N - K + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


 class Main {

    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static boolean isPalindrome(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }*/

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

            int h=sc.nextInt();
            int n=sc.nextInt();
            int a[]=new int[n];
            int s=0;
            for(int j=0;j<n;j++)
            {
                int m=sc.nextInt();
                s+=m;
            }
            if(s>=h)
            System.out.println("Yes");
            else
                System.out.println("No");
        }
    }




Measured memory_bytes: 50944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, m;
	cin >> n >> m;
	
	vector<set<int>> s(n);
	
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		x--;
		s[x].insert(y);
		
		if(n != 1 && x == 0 && y == 0){
			cout << -1 << endl;
			return 0;
		}
		
		if(s[x].size() > 1){
			cout << -1 << endl;
			return 0;
		}
	}
	
	vector<int> ans(n, -1);
	
	for(int i = 0; i < n; i++)
		for(auto &x : s[i])
			ans[i] = x;
	
	for(int i = 0; i < n; i++)
		if(ans[i] == -1){
			
			if(n > 1 && i == 0)
				ans[i] = 1;
			else
				ans[i] = 0;
		}
			
	
	for(int i = 0; i < n; i++)
		cout << ans[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

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

    for (size_t i = 0; i <= 1; i++) {
        if (n[i] == n[i + 1] && n[i + 1] == n[i + 2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

void go(int N, int n)
{
	if (n == 0) return;
	if (N >= n){
		go(N-n,n-1);
		printf ("%d\n",n);
	}
	else go(N,n-1);
}

int main()
{
	int N;

	scanf ("%d",&N);

	int n = 1, s = 0;
	while (N > s + n){
		s += n;
		n++;
	}

	go(N,n);
	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "3 1", "1 2" ].solve == 1 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	auto abs = new long[ 2 ][ m ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	
	auto uft = UnionFindTree( n );
	foreach( ab; abs )
	{
		uft.unite( ab[ 0 ], ab[ 1 ] );
	}
	return uft.rootnum - 1;
}

struct UnionFindTree
{
	long[] ps;
	long[] rs;
	long   rn;
	
	this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
		rn = n;
	}
	
	long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	auto same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	auto unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
		rn--;
	}
	
	auto weight( long i )
	{
		return -ps[ root( i ) ];
	}
	
	auto rootnum()
	{
		return rn;
	}
	
	auto toString()
	{
		return ps.to!( string );
	}
}


Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

bool check(vector<P> s) {
    int h = 0;
    for (P p : s) {
        int b = h + p.first;
        if (b < 0) return false;
        h += p.second;
    }
    return true;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    vector<P> ls, rs;
    int total = 0;
    rep(i,n) {
        string s;
        cin >> s;
        int h = 0, b = 0;
        for (char c: s) {
            if (c == '(') ++h; else --h;
            b = min(b, h);
        }
        if (h > 0) ls.emplace_back(b, h);   // 増減+ はb:最下点, h:増減を取る
        else rs.emplace_back(b-h, -h);      // 増減- は、上下左右逆さに考え、b:右から見た最下点、h:増減のマイナスを取る
        total += h;
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());  // 増減-は右から見るので、大きい順にsort

    if(check(ls) && check(rs) && total==0) {
	    cout << "Yes" << "\n";
    } else {
        cout << "No"  << "\n";
    }
	return 0;
}


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

min_cost = 10 ** 12
for n in range(-100, 100 + 1):
	cost = 0
	for a in A:
		cost += (n - a)** 2
	min_cost = min(min_cost, cost)
print(min_cost)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = INT_MAX;

int main(){
    string s;
    int a=0;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        if(a==0 && s[i]=='C') a++;
        if(a==1 && s[i]=='F') a++;
    }
    if(a==2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
s = gets
y = s.slice(0,4)
m1 = s.slice(5)
m2 = s.slice(6)
d = s.slice(8,9)
if y.to_i < 2019
	puts "Heisei"
elsif y.to_i > 2019
	puts "TBD"
else #y=2019の時
	if m1.to_i>0
		puts "TBD"
	else
		if m2.to_i < 4
			puts "Heisei"
		elsif m2.to_i > 4
			puts "TBD"
		else #m=<4の時
			if d.to_i <= 30
				puts "Heisei"
			else 
				puts "TBD"
			end
		end
	end
end


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

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

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, a, b;

signed main()
{
    cin >> N >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - N) << endl;
}
/*


*/




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,S,res=0;
  cin >> K >> S;
  
  vector<int> xy;
  for(int x=0; x<=K; x++) {
    for(int y=0; y<=K; y++) {
      int Z = S - (x + y);
      if( Z <= K && Z >= 0 ) res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k;cin>>n>>k;
    vin w(n);rep(i,n)cin>>w[i];
    int s=0;int l=10000*n+1;int m,res,j,sum;
    while(l-s>1){
        m=(s+l)/2;j=0;res=0;
        rep(i,k){
            res++;
            sum=0;
            while(j<n&&sum+w[j]<=m){
                sum+=w[j];
                j++;
            }
            if(j==n)break;
        }
        if(res==k&&j<n)s=m;
        else l=m;
    }
    cout<<l<<endl;
}


Measured memory_bytes: 3140
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] nums = Console.ReadLine().Split(' ');
            int allSum = calcSum(nums);
            int ans = allSum;
            int s1 = 0;
            for (int i = 0; i < nums.Length; i++)
            {
                s1 += int.Parse(nums[i]);
                int s2 = allSum - s1;
                if (Math.Abs(s2 - s1) < ans)
                    ans = Math.Abs(s2 - s1);
            }
            Console.WriteLine(ans);
        }

        static int calcSum(string[] nums)
        {
            int sum = 0;
            for(int i = 0; i < nums.Length; i++)
            {
                sum += int.Parse(nums[i]);
            }
            return sum;
        }
    }
}


Measured memory_bytes: 11092
mod segtree {
    pub trait Monoid {
        type Elem;
        fn id(&self) -> Self::Elem;
        fn ops(&self, lhs: &Self::Elem, rhs: &Self::Elem) -> Self::Elem;
    }

    pub struct SegmentTree<T: Monoid> {
        v: Vec<T::Elem>,
        n: usize,
        t: T,
    }

    impl<T: Monoid> SegmentTree<T>
    where
        T::Elem: ::std::clone::Clone,
    {
        pub fn new(n: usize, t: T) -> SegmentTree<T> {
            let mut st = SegmentTree {
                n: 1,
                t: t,
                v: Vec::new(),
            };
            while st.n < n {
                st.n *= 2;
            }
            st.v.resize(st.n * 2 - 1, st.t.id());
            if n >= 2 {
                for i in 0..st.n - 2 + 1 {
                    let i = st.n - 2 - i;
                    st.v[i] = st.t.ops(&st.v[i * 2 + 1], &st.v[i * 2 + 2]);
                }
            }
            st
        }
        #[allow(dead_code)]
        pub fn set(&mut self, i: usize, x: T::Elem) {
            let mut i = i + self.n - 1;
            self.v[i] = x;
            while i > 0 {
                i = (i - 1) / 2;
                self.v[i] = self.t.ops(&self.v[i * 2 + 1], &self.v[i * 2 + 2]);
            }
        }
        #[allow(dead_code)]
        pub fn get(&self, a: usize, b: usize) -> T::Elem { self.q(a, b, 0, 0, self.n) }

        fn q(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> T::Elem {
            if r <= a || b <= l {
                self.t.id()
            } else if a <= l && r <= b {
                self.v[k].clone()
            } else {
                let c = (l + r) / 2;
                self.t.ops(
                    &self.q(a, b, k * 2 + 1, l, c),
                    &self.q(a, b, k * 2 + 2, c, r),
                )
            }
        }
    }

    impl<T: Monoid> ::std::ops::Index<usize> for SegmentTree<T> {
        type Output = T::Elem;
        #[allow(dead_code)]
        fn index(&self, i: usize) -> &Self::Output { &self.v[i] }
    }
}

struct MinMonoid {}
impl segtree::Monoid for MinMonoid {
    type Elem = u64;
    fn id(&self) -> Self::Elem { (1u64 << 31) - 1 }
    fn ops(&self, lhs: &Self::Elem, rhs: &Self::Elem) -> Self::Elem { std::cmp::min(*lhs, *rhs) }
}

#[allow(unused_imports)]
use std::io;

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

#[allow(unused_macros)]
macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(n: usize, q: usize);
    let mut st = segtree::SegmentTree::new(n, MinMonoid {});
    for _ in 0..q {
        from_line!(comp: usize, x: usize, y: usize);
        match comp {
            0 => st.set(x, y as u64),
            1 => println!("{}", st.get(x, y + 1)),
            _ => unreachable!(),
        };
    }
}



Measured memory_bytes: 7100
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(15) << std::fixed;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    precise
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        bool f=1;
        fr(i,0,n) {cin>>a[i];if(a[i]==0) f=0;}
        if(f==0)
        {
            cout<<0<<endl;
            continue;
        }
        ll prod=1,prev=1;
        fr(i,0,n)
        {
            prod*=a[i];
            if(prod<prev || prod>1000000000000000000ll)
            {
                cout<<-1<<endl;
                return 0;
            }
            prev=prod;
        }
        cout<<prod<<endl;
    }
    return 0;
}


Measured memory_bytes: 4436
#include <iostream>
#include <set>
using namespace std;
const int MAX = 300001;


int main(){
	int list[MAX];
	for(int i = 2; i < MAX; i++){
		if(i % 7 == 1 || i % 7 == 6){
			list[i] = 1;
		}
		else{
			list[i] = 0;
		}
	}
	for(int i = 2; i < MAX; i++){
		if(list[i]){
			for(int j = i*2; j < MAX; j+=i){
				list[j] = 0;
			}
		}
	}
	list[1] = 0;
	list[0] = 0;

	int x;
	while(1){
		cin >> x;
		if(x == 1) break;

		set<int> sset;
		for(int i = 2; i <= x; i++){
			if(list[i]){
				if(x % i == 0){
					sset.insert(i);
				}
			}
		}

		cout << x << ":";
		set<int>::iterator ite = sset.begin();
		
		while(ite != sset.end()){
			cout << " " << *ite;
			ite++;
		}
		cout << endl;
	}
} 

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

water = A[:]
#print(water)

ans = []
x = 0
#print(x)
ans = [x]
for i, a in enumerate(water):
    y = 2*a - x
    #print(y)
    ans.append(y)
    x = y
#print(ans, sum(ans))

x = (ans[0] + ans[-1]) // 2
ans = [x]
for i, a in enumerate(water):
    y = 2*a - x
    #print(y)
    ans.append(y)
    x = y
#print(ans, sum(ans))





print(' '.join(list(map(str, ans[:-1]))))

Measured memory_bytes: 77668
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>
#define INF 1000000000000
const long long MOD = 1000000007;

using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

llong dfs(llong S, vector<llong> &dp){
    if(S==0){
        return 1;
    }
    if(S<0){
        return 0;
    }
    if(dp[S]!=-1){
        return dp[S];
    }
    llong ans=0;
    for(llong i=3; i<=S; i++){
        ans = ans%MOD + dfs(S-i, dp)%MOD;
    }
    dp[S] = ans;
    return ans;
}

int main(){
    llong S;
    cin >> S;
    vector<llong> dp(S+1, -1);
    cout << dfs(S, dp)%MOD << endl;
    return 0;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
int n;
long long he[2000010];
long long yh[2000010];
int x;
long long res;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		he[i]=he[i-1]+x;
		yh[i]=yh[i-1]^x;
	}
	int le=1;
	for(int ri=1;ri<=n;ri++){
		while((he[ri]-he[le-1])!=(yh[ri]^yh[le-1]))
			le++;
		res+=(long long)(ri-le+1);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 5888
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n % dig(n) == 0) System.out.println("Yes");
        else System.out.println("No");
    }
    public static int dig(int n){
        int cnt = 0;
        while(n != 0){
            cnt += n % 10;
            n /= 10;
        }
        return cnt;
    }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  vector<ll> dist(n+1);
  REP(i, n)
    cin >> a[i];
  
  dist[0] = a[0] - 0;
  REP1(i, n)
    dist[i] = a[i] - a[i-1];
  dist[n] = 0 - a[n-1];
  
  ll sum = 0;
  REP(i, n+1)
    sum += abs(dist[i]);
  
  REP(i, n){
    cout << sum - abs(dist[i+1]) - abs(dist[i]) \
    + abs(dist[i+1] + dist[i]) << "\n";
  }
  
}

Measured memory_bytes: 2816
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main()  {
	var N, M int
	sum := 0
	_, _ = fmt.Scan(&N, &M)

	inputs := strings.Split(nextLine(), " ")

	for i := 0; i < len(inputs); i++ {
		num, _ := strconv.Atoi(inputs[i])
		sum += num
	}

	tmp := N - sum

	if tmp >= 0{
		fmt.Println(tmp)
	}else{
		fmt.Println(-1)
	}
}


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

using namespace std;

const int INF = 1 << 30;

int main() {
  int a, b, c, d, e, f, g, h, i;
  cin >> a >> b >> e;
  g = a + b - e;
  f = a + g - e;
  c = a + e - f;
  d = b + c - g;
  h = a + e - g;
  i = b + e - g;
  cout << a << " " << b << " " << c << endl;
  cout << d << " " << e << " " << f << endl;
  cout << g << " " << h << " " << i << endl;
}

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

int main(){
int N;
  double r=0;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  cin>>A.at(i);
  r+=1.0/A.at(i);
}
cout<<1.0/r<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(void){
    int K, leng;
    string S;
    cin >> K;
    cin >> S;

    leng = (int)(S.length());

    if(leng<=K){
        cout << S << endl;
    }else{
        S.erase(K);
        S.insert(K,"...");
        cout << S << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;

using namespace std;
const int maxn=2e5+100;
int n,t;
int a[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
 	int x;
	cin>>n>>x>>t;
	cout<<n/x*t+(n%x!=0)*t;



    return 0;
}


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


int main() {

  int h1,m1,h2,m2,k;
  
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  
  int h1_min = h1 * 60 ;
  int time1 = h1_min + m1 ;
  
  int h2_min = h2 * 60 ;
  int time2 = h2_min + m2 ;
  
  int dtime = time2 - time1;
  
  int ans = dtime - k;
  
  //if(ans > 0)
    cout << ans;
  
  //else
    
  }


Measured memory_bytes: 3624
def 解():
    iN = int(input())
    aA = [int(_) for _ in input().split()]
    iD = 10**9+7

    #階乗(k!)
    aFr = [1]*(iN+1)
    for i in range(1,iN+1):
        aFr[i]= aFr[i-1]*i % iD
    #階乗の逆元(1/k!)
    aInvFr = [1]*(iN+1)
    aInvFr[iN] = pow(aFr[iN],iD-2,iD)
    for i in range(iN,0,-1):
        aInvFr[i-1]=aInvFr[i]*i % iD
    #1/k
    aInv = [1]*(iN+1)
    for i in range(1,iN+1):
        aInv[i] = aInvFr[i] * aFr[i-1] % iD
    #1/kの累積和
    aAcInv = [0]*(iN+1)
    for i in range(1,iN +1):
        aAcInv[i]=(aAcInv[i-1]+aInv[i] )%iD

    # A1, A2, .. Ai-1,Ai,Ai+1, .. An-1, An
    #
    # 連動して加算される可能性(期待値)が
    # 1/i+1,1/i, .. 1/3,1/2, Ai 1/2,1/3, .. ,1/n-i
    # なので1/k の累積和をAcInv(k)として
    # Ai * (AcInv(i+1) - 1) + Ai + Ai *(AcInv(n-1)-1)
    # ( -1 してるのは累積和の先頭が1だから)
    # それに全体の場合の数 N! をかけるとAiの出動コストがでる
    # 総和1→Nを取って終わり
    # なるほど。期待値ってこういう使い方できるんだな。

    iW = 0
    for i in range(iN):
        iW += aA[i]*(aAcInv[i+1]+aAcInv[iN-i]-1) %iD
        iW %= iD
    iW *= aFr[iN]

    print(iW  % iD)
解()


Measured memory_bytes: 22956
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	int N;

	cin >> N;

	int A[N];

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

	sort(A, A+N);

	long sum = 0;
	for(int i = 0; i<N-1; i++){
		sum += A[i];
	}

	if(sum > A[N-1]){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;++i) cin>>a[i];
  for(int i=0;i<n;++i){
    if(i) cout<<" ";
    cout<<a[n-i-1];
  }
  cout<<endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[2][n];
    rep(i, 0, n) cin >> a[0][i];
    rep(i, 0, n) cin >> a[1][i];

    int ans = 0;
    rep(i, 0, n) {
        int sum = 0;
        rep(j, 0, i + 1) sum += a[0][j];
        rep(k, i, n) sum += a[1][k];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n, m, k;
    cin >> n >> m >> k;
    bool ok = false;
    for(ll i = 0; i <= n; i++){
        for(ll j = 0; j <= m; j++){
            ll a = m*i-j*i+(n-i)*j;
            //cout << i << " " << j << " " << a << endl;
            if(a==k){
                ok=true;
                break;
            }
        }
        if(ok==true) break;
    }
    if(ok==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (500 * i + 100 * j + 50 * k == X) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256