akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prl puts("\n------------------\n")
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prl 
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 1e4 + 5;
ll dp[maxn][105];
int a[maxn], len, d;
char str[maxn];

ll dfs(int pos, int now, bool limit) {
    if (pos == len + 1) {
        return dp[pos][now] = (now == 0);
    }
    if (!limit && dp[pos][now] != -1) {
        return dp[pos][now];
    }
    int up = limit ? a[pos] : 9;
    ll sum  = 0;
    for (int i = 0;i <= up; ++i) {
        sum += dfs(pos + 1, (now + i) % d, limit && i == up);
        if (sum >= mod) sum -= mod;
    }
    if (!limit) dp[pos][now] = sum;
    return sum;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    cin >> str + 1;
    cin >> d;
    len = strlen(str + 1);
    rep(i, 1, len) a[i] = str[i] - '0';
    memset(dp, -1, sizeof(dp));
    ll ans = dfs(1, 0, true) - 1;
    cout << (ans + mod) % mod << endl;

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 8960
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


int solve(int n,int d){
	if( n == 1 ) return d;
	int ans = 0;

	for(int i = 0 ; i < n-1 ; i++){
		int a = d^127;
		int b = 127;
		//cout << a << " " << b << endl;
		if( a > b ) swap(a,b);
		d = a;
		ans += b;
	}
	//cout << d << endl;
	return ans + d;
}
int main(){
	int T;
	cin >> T;
	for(int i = 0 ; i < T ; i++){
		int d,n;
		cin >> n >> d;
		cout << solve(n,d) << endl;
	}

}





























Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> P;
static const int INF=1<<24;

string s[15];

int main(){
	s[1]=".,!? ";
	s[2]="abc";
	s[3]="def";
	s[4]="ghi";
	s[5]="jkl";
	s[6]="mno";
	s[7]="pqrs";
	s[8]="tuv";
	s[9]="wxyz";
	
	string st;
	int n;
	cin>>n;
	rep(k,n){
		cin>>st;
		P res(0,0);
		//cout<<"size "<<st.size()<<endl;
		rep(i,st.size()){
			if(st[i]!='0'){
				res.F++;
				res.S=st[i]-'0';
			}
			else if(res.S!=0){
				int t;
				if(res.S==1) t=5;
				else if(res.S==7||res.S==9) t=4;
				else t=3;
				cout<<s[res.S][(res.F-1)%t];
				res.F=0;res.S=0;
			}
		}
		if(res.S!=0){
			int t;
			if(res.S==1) t=5;
			else if(res.S==7||res.S==9) t=4;
			else t=3;
			cout<<s[res.S][(res.F-1)%t];
		}
		cout<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 3.141592653589;

int main(){
  cout << fixed << setprecision(20);
  ll a, b, x;
  cin >> a >> b >> x;
  double tanx;
  if(a * a * b >= x * 2){ // 三角柱の形 a * b * b / tan(theta) / 2
    tanx = a * b * b / 2.0 / x;
  }
  else{ // 直方体 - 三角柱の形 a * a * b - a * a * atan(theta) / 2
    tanx = 2.0 * (a * a * b - x) / a / a / a;
  }
    cout << atan(tanx) * 180 / PI << endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

template <int mod>
class ModInt {
 public:
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt<1000000007>;

void SetBin(vector<bool> &bin_vec, ll a) {
  FOR(i, 0, 60) {
    bool bin = (a % 2);
    bin_vec.push_back(bin);
    a /= 2;
  }
}

int main() {
  int n;
  cin >> n;
  vector<vector<bool> > vec(n);
  vector<modint> bit_true_count(60);
  FOR(i, 0, n) {
    ll a;
    cin >> a;
    SetBin(vec[i], a);
    FOR(j, 0, 60) { bit_true_count[j] += (modint)vec[i][j]; }
  }

  modint result;
  modint pow_(1);
  FOR(i, 0, 60) {
    modint o = bit_true_count[i] * (modint(n) - bit_true_count[i]);
    result += o * pow_;
    pow_ *= 2;
  }
  cout << result.x << endl;
  return 0;
}

Measured memory_bytes: 21436
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }





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

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

map<ll,ll> res;
void prime_factor(ll n){
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1) res[n]++;
    return;
}




void solve() {
    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    ll cnt[500010]={};
    for(ll i = k;i>0;i--){
        ll a = k/i;
        ll sum = mod_pow(a,n,MOD);
        cnt[i] = sum;
        // ans += i * sum;
        // cout<<i<<" "<<a<<" "<<mod_pow(a,n,MOD)<<" "<<ans<<endl;
        ans%=MOD;
        for(ll j = 2*i;j <=k;j+=i){
            cnt[i] += MOD - cnt[j];
        }
    }

    rep2(i,1,k+1){
        ans+=i*cnt[i];
        ans%=MOD;
    }

    cout<<ans<<endl;


}


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


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;

  vll a(n);
  rep(i, n) {
    ld tmp;
    cin >> tmp;
    tmp *= 1e9;
    tmp += 5e-1;
    a[i] = tmp;
  }

  vvll m(19, vll(19));
  for (auto it : a) {
    ll t = 0, f = 0;
    while (it > 0 && it % 2 == 0) {
      it /= 2;
      t++;
    }
    while (it > 0 && it % 5 == 0) {
      it /= 5;
      f++;
    }
    chmin(t, (ll)18);
    chmin(f, (ll)18);
    m[t][f]++;
  }

  ll ans = 0;
  for (auto it : a) {
    ll t = 0, f = 0;
    while (it > 0 && it % 2 == 0) {
      it /= 2;
      t++;
    }
    while (it > 0 && it % 5 == 0) {
      it /= 5;
      f++;
    }
    chmin(t, (ll)18);
    chmin(f, (ll)18);
    FOR(i, 18 - t, 19) {
      FOR(j, 18 - f, 19) {
        ans += m[i][j];
        if (i == t && j == f) {
          ans--;
        }
      }
    }
    m[t][f]--;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int n; cin >> n;
      	vector<int> a(n);
      	for (int& i : a) cin >> i;
      	
      	double ans = 0;
      	for (int i : a) ans += 1.0 / i;
      	ans = 1.0 / ans;
      	cout << ans << endl;
      	return 0;
    }

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> data(2, vector<int>(n));
	for (int i = 0; i < n; i++) {
		cin >> data.at(0).at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> data.at(1).at(i);
	}
	int result = 0;
	for (int i = 0; i < n; i++) {
		int check = 0;
		for (int j = 0; j <= i; j++) {
			check += data.at(0).at(j);
		}
		for (int j = i; j < n; j++) {
			check += data.at(1).at(j);
		}
		result = max(result, check);
	}
	cout << result << endl;
}



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

int main() {
  int n,m;
  cin>>n>>m;

  vector<vector<int>> G(n);
  for(int i=0; i<m; i++) {
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  int ans[n];
  for(int i=0; i<n; i++) ans[i]=0;

  queue<int> todo;
  bool seen[n];
  for(int i=0; i<n; i++) seen[i]=false;
  seen[0]=true;
  todo.push(0);
  while(!todo.empty()) {
    int now = todo.front();
    todo.pop();
    for(int next : G[now]) {
      if(seen[next]) continue;

      seen[next]=true;
      ans[next]=now;
      todo.push(next);
    }
  }

  cout<<"Yes"<<endl;
  for(int i=1; i<n; i++) cout<<ans[i]+1<<endl;


  return 0;
}

Measured memory_bytes: 10312
#include <iostream>
#include <cstdio>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    int count=0;
    int num=1;
    if(A==B&&B==C){
        if(A%2==0){
         count=0;
        }else{
            count=1;
        }
    }else{
        for(int i=0;;i++){
            if(A%num==B%num&&B%num==C%num&&A%2==0){
                count++;
            }else{
                break;
            }
            num*=2;
        }
    }
    cout << count-1;
    
    
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll N,i,k;
  ll A[1111111];
  cin >> N;
  ll count[1111111] = {0};
  ll check[1111111];
  for(i=0;i<=N-1;i++)
    cin >> A[i];
  for(i=0;i<=N-1;i++)
    check[i] = 1;
  for(i=0;i<=N-1;i++)
    count[A[i]]++; //正ならA[i]存在
  for(i=0;i<=N-1;i++)
    for(k=2;k*k<=A[i];k++){
      if(A[i] % k == 0)
        if(count[A[i]/k] >= 1 || count[k] >= 1) {check[i] = 0; break;}
      }
  for(i=0;i<=N-1;i++)
    if(count[A[i]] >= 2) check[i] = 0;
  ll ans = 0;
  for(i=0;i<=N-1;i++)
    ans += check[i];
  if(count[1]==1) ans = 1;
  if(count[1] >= 2) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 15444
#include <stdio.h>

int main(void)
{
	int c, a, n;
	int t;
	int q;
	int i;
	
	scanf("%d", &q);
	
	for (i = 0; i < q; i++){
		t = 0;
		scanf("%d %d %d", &c, &a, &n);
		while (c > 0 && a > 0 && n > 0){
			a--;
			n--;
			c--;
			t++;
		}
		while (c > 1 && a > 0){
			a--;
			c -= 2;
			t++;
		}
		while (c > 2){
			c -= 3;
			t++;
		}
		
		printf("%d\n", t);
		
	}
	
	return (0);
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> sw(N, vector<int>());
    vector<int> light(M, 0);
    vector<int> check(M);
    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            sw[s - 1].push_back(i);
        }
    }
    rep(i, M) {
        cin >> check[i];
    }
    ll ans = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        fill(light.begin(), light.end(), 0);
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                for (auto a : sw[i]) {
                    light[a]++;
                }
            }
        }
        bool ok = true;
        rep(i, M) {
            if (light[i] % 2 != check[i]) {
                ok = false;
                break;
            }
        }
        if (ok)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}







Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>

int main(){
	int n;
	while (std::cin>>n,n){
		std::map<std::string, int>items;
		for (int i = 0; i < n; i++){
			std::string str;
			int a;
			std::cin >> str >> a;
			items.insert(std::make_pair(str, a));
		}
		int renkinn;
		std::cin >> renkinn;
		for (int i = 0; i < renkinn; i++){
			std::string item;
			int sum = 0, a;
			std::cin >> item >> a;
			for (int j = 0; j < a; j++){
				std::string b;
				std::cin >> b;
				sum += items[b];
			}
			if (sum < items[item])items[item] = sum;
		}
		std::string ans;
		std::cin >> ans;
		std::cout << items[ans] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	char S[6];
	scanf("%s",S);
	if(S[2] == S[3] && S[4] == S[5]){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    int h, w, n;
    scanf("%d %d %d", &h, &w, &n);

    vector< pair< int, int> > v;
    while (n--) {
        int r, c;
        scanf("%d %d", &r, &c);

        for (int i = 0; i < 3; ++i)
            for (int j = 0; j < 3; ++j) {
                int nr = r - i;
                int nc = c - j;
                if (1 <= nr and nr + 2 <= h and 1 <= nc and nc + 2 <= w) {
                    v.emplace_back(nr, nc);
                }
            }
    }

    sort(begin(v), end(v));
    n = v.size();

    vector< ll> ans(10);
    ll total = (h - 2) * 1LL * (w - 2);

    ll sum = 0;
    for (int i = 0; i < n; ) {
        int j = i;
        while (j < n and v[j] == v[i]) j++;
        int cnt = j - i;
        ans[cnt]++;
        sum ++;
        i = j;
    }

    ans[0] = total - sum;
    for (int i = 0; i < 10; ++i) printf("%lld\n", ans[i]);

}

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

using namespace std;
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)N; i++)

#define M 20
#define N 50001

int d[M];
int DP[M][N];

int solve(int i, int x) {
  int res = N;
  if(DP[i][x] != N) return DP[i][x];
  res = solve(i-1, x);
  if(x - d[i] >= 0) res = min(res, solve(i, x - d[i]) + 1);
  DP[i][x] = res;
  return res;
}

int main () {
  int n, m;

  cin >> n >> m;
  REP(i,M) cin >> d[i];

  for(int x = 0; x <= n; x++) {
    for(int i = 0; i < m; i++) DP[i][x] = N;
  }
  for(int k = 0, kMax = n / d[0]; k <= kMax; k++) DP[0][k*d[0]] = k;

  cout << solve(m-1, n) << endl;

  return 0;
}

Measured memory_bytes: 8144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc054/tasks/abc054_c

int ab[10][10];

int main() {
    int N, M; cin >> N >> M;
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[a][b] = 1;
        ab[b][a] = 1;
    }

    vector<int> perm(N-1);
    REP(i, N-1) {
       perm[i] = i+2;
    }
    sort(perm.begin(), perm.end());

    int ans = 0;
    do {
        int now = 1;
        for (int i = 0; i < perm.size(); i++) {
            if (!ab[now][perm[i]]) break;
            now = perm[i];
            if (i == perm.size()-1) ans++;
        }
    } while(next_permutation(perm.begin(), perm.end()));

    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll N;
    scanf("%lld", &N);
    for (ll h = 1; h <= 3500; ++h)
    {
        for (ll n = 1; n <= 3500; ++n)
        {
            ll f = N * h * n;
            ll d = 4LL * n * h - N * h - N * n;
            if (d <= 0) continue;
            ll r = f % d;
            if (r != 0) continue;
            ll w = f / d;

            printf("%lld %lld %lld\n", h, n, w);
            return 0;
        }
    }
    return 0;
}


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

int main(){
    
    int n;
    string s;
    cin >> n >> s;
    
    int res = 0;
    for(int i = 0; i < n; i++){
        string first = s.substr(0, i);
        string last = s.substr(i);
        
        set<char>one;
        set<char>two;
        set<char>intersect;
        for(auto v : first){
            one.insert(v);
        }
        for(auto v: last){
            two.insert(v);
        }
        
        auto it = set_intersection(one.begin(), one.end(), two.begin(), two.end(), inserter(intersect, intersect.begin()));
        
        
        res = max(res, (int)intersect.size());
        //if(i == 3){
            //cout << first << " " << last << endl;
        //}
        one.clear();
        two.clear();
        intersect.clear();
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, t[55];
string x, s[55];

int main() {
    cin >> n;
    rep(i, n) cin >> s[i] >> t[i];
    cin >> x;

    int ans = 0;
    rep(i, n) ans += t[i];
    rep(i, n) {
        ans -= t[i];
        if (s[i] == x) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;
int main(){
    ll l,r;cin>>l>>r;
 	if(r-l>=2019){
      cout<<0<<endl;
    }else{
      ll ans=2018;
      for(ll i=l;i<r;++i){
        for(ll j=i+1;j<=r;++j){
          ans=min(ans,(i*j)%2019);
        }
      }
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m, x, y; cin >> n >> m >> x >> y;
  vector<int> a(n), b(m);
  for(int & v : a) cin >> v;
  for(int & v : b) cin >> v;
  a.push_back(x);
  b.push_back(y);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if(a[n] < b[0]) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

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

  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0)
      ans += i;
  }
  cout << ans << endl;

  return 0;
}


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

const int INF=123456;
string S;
bool f;

int main() {
	
    cin>>S;
    
    int n=S.size();
    
    int m=n;
    
    for(int i=0; i<n-1; i++){
    	int a=INF,b=INF;
	if(S[i]=='0'&&S[i+1]=='1'){
	  a=max(i+2,n-i); f=true;
	}
	if(S[i]=='1'&&S[i+1]=='0'){
	  b=max(i+2,n-i); f=true;	
	}
	int m1=min(a,b);
	
	m=min(m,m1);
    }
    
    
    if(f) cout<<m-1<<endl;
    else cout<<m<<endl;
    
    return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, W, ans=0, tmp=0;
vector<ll> Ws, Vs;
vector<vector<vector<ll>>> DP;

signed main(){
    cin >> N >> W;
    for(int i=0;i<N;i++) {
        ll w, v;
        cin >> w >> v;
        if(i==0) tmp = w;
        Ws.push_back(w-tmp);
        Vs.push_back(v);
    }
    DP.resize(N+1);
    for(int i=0;i<N+1;i++) {
        DP[i].resize(N+1);
        for(int j=0;j<N+1;j++) {
            DP[i][j].resize(4*N, -INF);
            DP[i][0][0] = 0;
        }
    }
    for(int i=1;i<N+1;i++) {
        for(int j=1;j<N+1;j++) {
            for(int k=0;k<4*N;k++) {
                DP[i][j][k] = max(DP[i][j][k], DP[i-1][j][k]);
                if(W-tmp*j-k-Ws[i-1]>=0) DP[i][j][k+Ws[i-1]] = max(DP[i][j][k+Ws[i-1]], DP[i-1][j-1][k]+Vs[i-1]);
            }
        }
    }
    for(int j=0;j<N+1;j++) {
        for(int k=0;k<4*N;k++) {
            ans = max(ans, DP[N][j][k]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35912
from itertools import permutations

def calc(x, y):
    return ((x[0] - y[0])**2 + (x[1] - y[1])**2)**0.5

def main():
    n = int(input())
    A = [list(map(int, input().split())) for i in range(n)]
    A = list(permutations(A))
    ls = []
    for c in A:
        l = calc(c[0], c[1])
        if len(c) > 2:
            prev_idx = 1
            for a in c[2:]:
                l += calc(c[prev_idx], a)
                prev_idx += 1
        ls.append(l)
    print(sum(ls) / len(ls))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9332
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
string s;
const int maxn = 2e5+100;
int a[maxn];
int main()
{
  int n, k;
  cin >> n >> k;
  int maxx = 0;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    if (a[i] > maxx) maxx = a[i];
  }
  int l = 1, r = maxx;
  while (l < r)
  {
    int mid = (l+r)>>1;
    int res = k;
    for (int i = 0; i < n; ++i)
    {
      if (a[i]%mid == 0) res -= a[i]/mid-1;
      else res -= a[i]/mid;
    }
    debug(l,r,mid,res);

    if (res < 0) l = mid+1;
    else r = mid;
  }
  cout << l << endl;
  return 0;
}

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

using namespace std;

int T[40][40];

int A[510][510];

int ch[40][3];

int main()
{
    int n,m;
    cin >> n >> m;
    for ( int c=1; c<=m; c++ )
    {
        for ( int d=1; d<=m; d++ )
        {
            cin >> T[c][d];
        }
    }

    for ( int c=1; c<=n; c++ )
    {
        for ( int d=1; d<=n; d++ )
        {
            cin >> A[c][d];
        }
    }

    for ( int c=1; c<=m; c++ )
    {
        for ( int d=1; d<=n; d++ )
        {
            for ( int e=1; e<=n; e++ )
            {
                ch[c][(d+e)%3] += T[A[d][e]][c];
            }
        }
    }
    int ans = 1000000000;
    for ( int c=1; c<=m; c++ )
    {
        for ( int d=1; d<=m; d++)
        {
            if ( c == d )
                continue;
            for ( int e=1; e<=m; e++ )
            {
                if ( c == e or d == e )
                    continue;
                ans = min ( ans, ch[c][0] + ch[d][1] + ch[e][2]);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 1280
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
double dp[3333][3333];
signed main(){
    int n;cin>>n;
    dp[0][0]=1;
    rep(i,1,n+1){
        double  p;cin>>p;
        rep(j,0,n+1){
            if(j!=0)dp[i][j]=p*dp[i-1][j-1]+(1-p)*dp[i-1][j];
            else dp[i][j]=(1-p)*dp[i-1][j];
            //cout<<dp[i][j]<<" ";
        }//cout<<endl;
    }
    double ans=0;
    rep(i,0,n+1){
        if(i>n/2)ans+=dp[n][i];
    }
    cout<<setprecision(15)<<ans<<endl;return 0;
}

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

int main(){
  
  int n, k, num = 1;
  cin >> n >> k;

  rep(i,n){
    num = min(num*2, num+k); 
  }

  cout << num << endl;

}

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

int main() {
    string S;
    int ans;
    cin >> S;
    if(S == "SUN") ans = 7;
    else if(S == "MON") ans = 6;
    else if(S == "TUE") ans = 5;
    else if(S == "WED") ans = 4;
    else if(S == "THU") ans = 3;
    else if(S == "FRI") ans = 2;
    else if(S == "SAT") ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try (Scanner sc = new Scanner  (System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i=0;i<length;i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    answer += Character.toUpperCase(ch);
                } else {
                    answer += Character.toLowerCase(ch);
                }
            }
            System.out.println(answer);
        }
    }
}



Measured memory_bytes: 31368
#include<stdio.h>

int main()
{
  int w_x,h_y;
  int n;
  int x[101]={},y[101]={},a[101]={};
  int i;
  int area;
  
  scanf("%d %d %d",&w_x,&h_y,&n);
  
   int left_x=0,below_y=0;
  int right_x=w_x,high_y=h_y;
  
  for(i=1;i<=n;i++)
  {
    scanf("%d %d %d",&x[i],&y[i],&a[i]);
  }
  
  for(i=1;i<=n;i++)
  { 
   if(a[i]==1)
   {
    if(left_x < x[i] )
    {
     left_x = x[i];
    }
   }
    else if(a[i]==2)
    {
      if(x[i] < right_x )
      {
        right_x = x[i];
      }
    }
    else if(a[i]==3)
    {
      if( below_y < y[i])
      {
        below_y = y[i];
      }
    }
    else if(a[i]==4)
    {
      if( y[i] < high_y  )
      {
        high_y = y[i];
      }
    }
  }
 
  if((left_x <= right_x)&&(below_y<=high_y))
  {
  area = (right_x - left_x) * (high_y - below_y);
  }
  else
  {
    area = 0;
  }
  printf("%d\n",area);
  
  return 0;
}

Measured memory_bytes: 128
n, k = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
ans = 0
v = []
for a in aaa:
  v.append((a * (a + 1)) / (2.0 * a))

current = 0
for i in range(n):
  current += v[i]
  if i >= k:
    current -= v[i-k]
  ans = max(ans, current)
print(ans)

Measured memory_bytes: 32208
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] A = new long[N+1];
		for( int i=1; i<=N; i++ ){
			A[i] = sc.nextLong();
		}
		Arrays.sort(A);
		int count = 1;
		long[] a = new long[2];
		int[] b = new int[2];
		int c = 0;
		for( int i=N; i>=2; i-- ){
			if( A[i]==A[i-1] ){
				count++;
			}
			if( A[i]==A[i-1] && A[i]!=A[i-2] ){
				a[c] = A[i];
				b[c] = count;
				count = 1;
				c++;
			}
			if( c==2 ){
				break;
			}
		}
		long ans = 0;      
		if( b[0]>=4 ){
			ans = a[0]*a[0];
		}else if( c==2 ){
			ans = a[0]*a[1];
		}else{
			ans = 0;
		}     
		System.out.println(ans);
	}
}


Measured memory_bytes: 52884
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int n,l;
               cin>>n>>l;
               string s[n];
               for(int i=0;i<n;++i)
                    cin>>s[i];
               sort(s,s+n);
               string ans;
               for(int i=0;i<n;++i)
                    ans += s[i];
               cout<<ans;
       }
}


Measured memory_bytes: 3692
//ツ本ツ禿コツづ個つケツつョツづ督つァツつ「
//defineツづ個値ツつェツ堕スツつキツつャツつス N 10000
//ツ本ツ禿コツづ個陛渉づ按エツδ可ー
//c++ツづ按づ個づ曳ccツづコツδ督パツイツδ仰つオツづつス

#include<cstdio>
#include<iostream>
#define N 1000
int W,Q,haba[N],koko=0,suei1[N],suei2[N];

using namespace std;



void habacalc(int,int);
void habacalc2(int);

int main(){
  int s[N][N],w[N],i,id[N],uei[N];
  char sw;
  
  for(i=0;i<N;i++){
    haba[i]=0;
  }
  while(1){
    
  cin >> W >> Q;
  if(W==0 && Q == 0)break;
  
  for(i=0;i<Q;i++){
    cin >> sw ;
    if(sw == 's'){
      cin >> id[i] >> uei[i];
      habacalc(id[i],uei[i]);
    }
    else if(sw == 'w'){
      cin >>  w[i];
      habacalc2(w[i]);
    }
    
    
  }
  cout << "END" <<endl;
  
 for(i=0;i<N;i++){
    haba[i]=0;
  }


  }
}


void habacalc(int id,int uei){
  int j,i,flag=1,count=0,fl[2],ok=0;
  
  fl[0]=-1;
  fl[1]=-1;
  for(j=0;j<W;j++){
    if(haba[j]==0){
      count+=1;
      if(fl[0]==-1){
	fl[0]=j; 
	suei1[id]=j;
	
      }
      if(count==uei){
	fl[1]=j;
	suei2[id]=j;
	
	ok=1;
	break;
      }
    }
    else{
      count=0;
      fl[0]=-1;
      fl[1]=-1;      
    }
  }
  if(ok==1){
    for(i=fl[0];i<=fl[1];i++){
      haba[i]=1;
     
    }
 cout << fl[0] << endl;
  }
  else{
    cout << "impossible" << endl;  
  }
  
}



void habacalc2(int w){
  int i;
  for(i=suei1[w];i<=suei2[w];i++){
    haba[i]=0;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

map<ll, ll> prime;

void prime_factorize(ll n)
{
    if (n <= 1)
        return;
    ll l = sqrt(n);
    for (ll i = 2; i <= l; i++)
    {
        if (n % i == 0)
        {
            prime_factorize(i);
            prime_factorize(ll(n / i));
            return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;
    return;
}

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

    prime_factorize(p);

    ll ans = 1;
    for (auto v : prime)
    {
        if(v.second>=N){
            ans=ans*(ll)pow(v.first,v.second/N);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    string S,T;cin>>S>>T;
    int ans=0;
    for(int i=0;i<3;i++){
        if(S[i]==T[i]) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
int N,K;
int A[200005],F[200005];
vector<int> ans;
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N)scanf("%lld",&A[i]);
    rep(i,N)scanf("%lld",&F[i]);
    sort(A,A+N,greater<int>());
    sort(F,F+N);
    int a=-1;
    int b=A[0]*F[N-1];
    while(a+1<b){
        int c=(a+b)/2;
        int left=K;
        rep(i,N){
            int useK=0;
            if(A[i]*F[i]>c)useK=A[i]-c/F[i];
            left-=useK;
        }
        if(left>=0){
            b=c;
        }else{
            a=c;
        }
    }
    printf("%lld\n",b);
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,a=0,b=0;
cin >> n;
b = n;
while(n>0){
	a = a + (n%10);
	n = n/10;
}
if(b%a==0){
	cout << "Yes" << endl;
}

else{
	cout << "No" << endl;
}

////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b == 15) {
	  cout << "+" << endl;
	} else if (a * b == 15) {
	  cout << "*" << endl;
	} else {
	  cout << "x" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

fn solve(n: usize, m: usize, arr: &mut Vec<usize>, req: &Vec<(usize, usize, usize, i64)>) -> i64 {
  if arr.len() == n {
    req
      .iter()
      .filter(|(a, b, c, _)| arr[*a] + c == arr[*b])
      .map(|&(_, _, _, d)| d)
      .sum()
  } else {
    let mut ret = 0;
    for tail in *arr.last().unwrap()..=m {
      arr.push(tail);
      ret = cmp::max(ret, solve(n, m, arr, req));
      arr.pop();
    }
    ret
  }
}

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
    q: usize,
    req: [(Usize1, Usize1, usize, i64); q],
  }

  println!("{}", solve(n, m, &mut vec![1], &req));
}


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

// Kevin Mathew T
// Birla Institute of Technology, Mesra
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

ll n, m, a[100010];

void solve(){
	cin >> n >> m;
	for(ll i=0;i<n;i++)
		cin >> a[i];

	priority_queue<ll> pq;
	for(ll i=0;i<n;i++)
		pq.push(a[i]);

	for(ll i=0;i<m;i++){
		ll x = pq.top();
		pq.pop();
		pq.push(x / 2);
	}

	ll tot = 0;
	for(ll i=0;i<n;i++){
		tot += pq.top();
		pq.pop();
	}

	cout << tot << "\n";
}

int main()
{
	// freopen("input.txt", "r", stdin);		//Comment
	// freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	solve();

	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using graph = vector<set<int>>;
using pii = pair<int, int>;

const int MAX = 1e5;

vector<int> G[MAX];

int c[MAX];
int res[MAX];

int it;

void dfs(int v, int prev) {
	res[v] = c[--it];
	for (auto to : G[v]) if (to != prev) {
		dfs(to, v);
	}
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}
	sort(c, c + N);
	it = N;
	dfs(0, -1);
	cout << accumulate(c, c + N - 1, 0LL) << endl;
	for (int i = 0; i < N; i++) {
		cout << res[i] << " \n"[i + 1 == N];
	}
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;cin>>N;
	int ng=((N%2)?N:N+1);
	vector<pair<int,int>> ans;
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;++j){
			if(j==ng-i)continue;
			ans.push_back(make_pair(i,j));
		}
	}
	cout<<ans.size()<<endl;
	for(auto x:ans){
		cout<<x.first<<' '<<x.second<<endl;
	}
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int n, m, ans;
vector<vector<int> > G;
vector<bool> visit;

void dfs(int now){
  visit[now] = true;
  bool check = true;
  for(auto next : G[now]){
    if(!visit[next]) dfs(next), check = false;
  }
  if(check){
    bool ok = true;
    for(int i = 0; i < visit.size(); i++) if(!visit[i]) ok = false;
    if(ok) ans++;
  }
  visit[now] = false;
}

signed main(){
  cin >> n >> m;
  G.resize(n);
  visit.resize(n, false);
  for(int i = 0; i < m; i++){
    int a, b; cin >> a >> b;
    G[a - 1].push_back(b - 1); G[b - 1].push_back(a - 1);
  }
  dfs(0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    scanf("%d", &N);
    string a;
    cin >> a;
    int cont = 0;
    char prev = ' ';
    for (int i=0; i<N; i++){
        if (a[i] == prev) continue;
        cont++;
        prev = a[i];
    }
    printf("%d\n", cont);
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	long long int num = 0;
	int q, p, n;
	char c;
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> p >> c >> n;
		if(c == '(') num += n;
		else num -= n;
		if(num == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  long ans = 0L;
  for (int i = 1; i <= N; ++i) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
    int N;
    scanf("%d", &N);
    bool a0 = true;
    int vals[3];
    int cnt[3];
    int distinct = 0;
    for(int i = 0; i < N; i++){
        int x;
        scanf("%d", &x);
        if(x != 0) a0 = false;
        bool match = false;
        for(int j = 0; j < distinct; j++){
            if(vals[j] == x){
                cnt[j]++;
                match = true;
            }
        }
        if(!match){
            if(distinct == 3){
                printf("No");
                return 0;
            }
            vals[distinct] = x;
            cnt[distinct] = 1;
            distinct++;
        }
    }
    if(a0){
        printf("Yes");
        return 0;
    }
    if(distinct == 1){
        printf("No");
        return 0;
    }
    if(distinct == 2){
        if(vals[0] == 0 && cnt[0]*2 == cnt[1]){
            printf("Yes");
            return 0;
        }else if(vals[1] == 0 && cnt[1]*2 == cnt[0]){
            printf("Yes");
            return 0;
        }else{
            printf("No");
            return 0;
        }
    }
    if(distinct == 3){
        if((vals[0]^vals[1])!=vals[2]){
            //printf("%d %d %d %d", vals[0], vals[1], vals[2], vals[0]^vals[1]);
            printf("No");
            return 0;
        }
        if(cnt[0] == cnt[1] && cnt[1] == cnt[2]){
            printf("Yes");
            return 0;
        }
            printf("No");
            return 0;
    }
}


Measured memory_bytes: 256