akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int H, W, K;
	cin >> H >> W >> K;
	vector <vector <bool> > m( H, vector <bool>( W ));
	int sum_black = 0;
	rep( i, 0, H ){
		rep( j, 0, W ){
			char c; cin >> c;
			m[ i ][ j ] = ( c == '#' );
			sum_black += m[ i ][ j ];
		}
	}
	int lim = pow( 2, H + W );
	int cnt = 0;
	rep( pattern, 0, lim ){
		auto n = m;
		int sub = 0;
		rep( bit, 0, H ){
			if (pattern & ( 1 << bit )){
				rep( k, 0, W ){
					sub += n[ bit ][ k ];
					n[ bit ][ k ] = false;
				}
			}
		}
		rep( bit, 0, W ){
			if (pattern & ( 1 << bit + H )){
				rep( k, 0, H ){
					sub += n[ k ][ bit ];
					n[ k ][ bit ] = false;
				}
			}
		}
		if (sum_black - sub == K)
			cnt++;
	}
	cout << cnt << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 4092
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdio.h>
#include <functional>
#include <chrono>
#include <random>
#include <time.h>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MAX_INF = 9223372036854775807;
//constexpr ll MOD = (1e9 + 7);
constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init, ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T>& v) {
	T ans = -INF;
	rep(i, 0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C & c, std::ostream & os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}


ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

void warshall_floyd(ll v_num,vector<vector<long long>> &d) {
	for (long long k = 0; k < v_num; k++) {       // 経由する頂点
		for (long long i = 0; i < v_num; i++) {    // 始点
			for (long long j = 0; j < v_num; j++) {  // 終点
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

uniform_real_distribution<> dist(0.0, 1.0);

float judge(float p, mt19937& engine) {
	float f = dist(engine);
	return p >= f;
}

float prob(float delta, float tmp) {
	return exp(delta / tmp);
}


int cost(vector<vector<int>>& s, vector<int>& c, vector<int>& ls) {
	int result = 0;
	vector<int> prev(26,-1);
	rep(i, 0, ls.size()) {
		prev[ls[i]] = i;
		result += s[i][ls[i]];
		rep(j, 0, 26) {
			result -= c[j] * (i - prev[j]);
		}
	}
	return result;
}


int main() {
	// ↓この２行が追加部分
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	random_device seed_gen;
	mt19937 engine(seed_gen());

	int d;
	cin >> d;
	int con = 0;
	vector<int> c(26);
	vector<vector<int>> s(d, vector<int>(26));
	rep(i, 0, 26) {
		cin >> c[i];
	}
	rep(i, 0, d) {
		rep(j, 0, 26) {
			cin >> s[i][j];
		}
	}

	// 初期化
	vector<int> ls(d);
	rep(i, 0, d) {
		ls[i] = con;
		++con;
		con %= 26;
	}
	
	
	int now_cost = cost(s,c,ls);

	for (int tmp = 20000; tmp > 10; tmp -= 30) {
		rep(j, 0, d) {
			int ra = rand() % 24 + 1,val = ls[j];
			ls[j] = (ls[j] + ra) % 26;
			int cos = cost(s, c, ls);
			float p = prob(cos - now_cost, tmp);
			if (judge(p,engine)) {
				now_cost = cos;
			}
			else {
				ls[j] = val;
			}
		}
	}

	rep(i, 0, d) {
		printf("%d\n", ls[i] + 1);
	}
}

Measured memory_bytes: 4124
#include<stdio.h>

int main(void) {
   int n, m;
   int i;
   int sum = 0;
   int ans = 0;
   scanf("%d %d",&n, &m);
   int am[m];
   for(i = 0; i < m; i++) {
      scanf("%d", &am[i]);
   }

   for(i = 0; i < m; i++) {
      sum += am[i];
   }
   ans = n - sum;
   if(ans >= 0) {
      printf("%d\n",ans);
   } else {
      printf("-1");
   }

   return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll r, D, x;
    cin >> r >> D >> x;
    rep(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
	vector<P> v[100001];
	int n, m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int p, y;
		cin>>p>>y;
		v[p].push_back(P(y, i));
	}
	string s[100001];
	ll ans[100001];
	for(ll i=1; i<=n; i++){
		sort(v[i].begin(), v[i].end());
		for(ll j=0; j<v[i].size(); j++){
			int t=v[i][j].second;
			ans[t]=i*1000000+j+1;
			ll ans1=ans[t];
			int ct=0;
			while(ans1>0){
				ans1/=10;
				ct++;
			}
			for(int k=0; k<12-ct; k++) s[t]+='0';
		}
	}
	for(int i=0; i<m; i++){
		cout<<s[i]<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main()
{
    while (true) {
        string s;
        getline(cin, s);
        if (s[0] == '.') {
            break;
        }

        stack<char> st;
        bool ok = true;
        for (auto&& c : s) {
            if (!ok) {
                break;
            }
            switch (c) {
            case '(':
                st.push(c);
                break;
            case '[':
                st.push(c);
                break;
            case ')':
                if (!st.empty() && st.top() == '(') {
                    st.pop();
                }
                else {
                    ok = false;
                }
                break;
            case ']':
                if (!st.empty() && st.top() == '[') {
                    st.pop();
                }
                else {
                    ok = false;
                }
                break;
            }
        }
        if (ok && st.empty()) {
            printf("yes\n");
        }
        else {
            printf("no\n");
        }
    }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>	
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());

using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
 
pair <string, int> a[101];
map <pair <string, int>, int > d;

bool cmp(pair <string, int> a, pair <string, int> b)
{
	if(a.F == b.F) return a.S > b.S;
	return a.F < b.F;
}

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i].F >> a[i].S, d[mp(a[i].F, a[i].S)] = i;
	sort(a + 1, a + n + 1, &cmp);
	for(int i = 1; i <= n; i++) cout << d[mp(a[i].F, a[i].S)] << endl;
}                                

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, n - 2)
    {
        if (s.substr(i, 3) == "ABC")
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,a,b;cin>>h>>w>>a>>b;
  rep(i,b) {
    rep(j,a) printf("1");
    rep(j,w-a-1) printf("0");
    printf("0\n");
  }
  rep(i,h-b) {
    rep(j,a) printf("0");
    rep(j,w-a-1) printf("1");
    printf("1\n");
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
const int MOD=1000000007;
const int INF=1000000000;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

string rp(string str,string a,string b)
{
  string res=str;
  string::size_type pos=res.find(a);
  while(pos!=string::npos)
    {
      res.replace(pos,a.size(),b);
      pos=res.find(a,pos+b.size());
    }
  return res;
}

int main(int argc,char const* argv[])
{
  int n;
  while(cin >> n && n)
    {
      vector<string> a(n+5);
      vector<string> b(n+5);
      string s,g;
      for(int i=0;i<n;i++)
	{
	  cin >> a[i] >> b[i];
	}
      cin >> s >> g;
      queue<pair<string,int > > que;
      set<string> st;
      que.push(make_pair(s,0));
      st.insert(s);
      int res=-1;
      while(!que.empty())
	{
	  pair<string,int > p=que.front();
	  que.pop();
	  if(p.first==g)
	    {
	      res=p.second;
	      break;
	    }
	  for(int i=0;i<n;i++)
	    {
	      string tmp=rp(p.first,a[i],b[i]);
	      if(tmp.length()>g.length()) continue;
	      if(st.find(tmp)!=st.end()) continue;
	      que.push(make_pair(tmp,p.second+1));
	      st.insert(tmp);
	    }
	}
      cout << res << endl;
    }
  return 0;
}



Measured memory_bytes: 3444
from bisect import bisect_right
from random import randint
from copy import deepcopy


def calculate_score(c, L):
    global D, last, S
    rst = 0
    _last = L
    for d in range(1, D + 1):
        down = C[c] * (d - _last[d])
        up = S[d][c] if _last[d] == d else 0
        rst += up - down
    return rst


Z = 26
D = int(input())
C = list(map(int, input().split()))
S = [tuple([0] * Z)] + [tuple(map(int, input().split())) for _ in range(D)]

last = [-1] * Z
ans = 0
T = [0]
for d in range(D):
    maxScore = -float('inf')
    cand = 0
    for i in range(26):
        tmp = last[i]
        last[i] = d
        up = S[d][i]
        down = sum(C[j] * (d - last[j]) for j in range(Z))
        score = up - down
        if maxScore < score:
            cand = i
            maxScore = score
        last[i] = tmp
    last[cand] = d
    T.append(cand)


last = [[0] * (D + 1) for _ in range(Z)]
V = [0] * Z
for d in range(1, D + 1):
    t = T[d]
    for p in range(Z):
        last[p][d] = last[p][d - 1]
    last[t][d] = d
for p in range(Z):
    V[p] = calculate_score(p, last[p])

score = sum(V)
maxScore = score
maxT = deepcopy(T)
# print('Initial Score: ', score)

max_iter = 10 ** 4
for _ in range(max_iter):
    d = randint(1, D)
    q = randint(0, Z - 1)

    p = T[d]
    if p == q:
        continue

    e = bisect_right(last[p], d)
    _lastP = [0] * (D + 1)
    for j in range(d):
        _lastP[j] = last[p][j]
    for j in range(d, e):
        _lastP[j] = _lastP[j - 1]
    for j in range(e, D + 1):
        _lastP[j] = last[p][j]

    old = last[q][d]
    e = bisect_right(last[q], old)
    _lastQ = [0] * (D + 1)
    for j in range(d):
        _lastQ[j] = last[q][j]
    for j in range(d, e):
        _lastQ[j] = d
    for j in range(e, D + 1):
        _lastQ[j] = last[q][j]

    Vp = calculate_score(p, _lastP)
    Vq = calculate_score(q, _lastQ)
    if V[p] + V[q] < Vp + Vq:
        score -= V[p] + V[q]
        score += Vp + Vq
        V[p] = Vp
        V[q] = Vq
        T[d] = q
        last[p] = _lastP
        last[q] = _lastQ

if score > maxScore:
    for i in range(1, D + 1):
        print(T[i] + 1)
else:
    for i in range(1, D + 1):
        print(maxT[i] + 1)
# print(score)


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

#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long 
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define ss second
#define ff first
#define ll long long
#define pii pair<int,int>
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define vii vector<pii>
typedef long double ld;
const int N = 1e5+5;
const int INF = 1e9+7;

vi city[N];
map<int,int> number;

int calc(int x)
{
  int a=0;
  while(x)
  {
    x/=10;
    a++;
  }
  return a;
}

int32_t main()
{
  IOS;
  int n,m,p,y;
  cin >> n >> m;
  vector<string> ans(m+1);
  for(int i=1;i<=m;i++)
  {
    cin >> p >> y;
    number[y]=i;
    city[p].pb(y);
  }
  int j;
  for(int i=1;i<=n;i++)
  {
    sort(all(city[i]));
    if(city[i].size()==0)
      continue;
    string temp;
    j=6-calc(i);
    //cout << j << '\n';
    while(j)
    {
      temp+='0';
      j--;
    }
    temp+=to_string(i);
    int cnt=1;
    for(auto &x:city[i])
    {
      string temp1;
      j=6-calc(cnt);
      while(j)
      {
        temp1+='0';
        j--;
      }
      temp1+=to_string(cnt);
      cnt++;
      ans[number[x]]=temp+temp1;
    }
  }
  for(int i=1;i<=m;i++) cout << ans[i] << '\n';
  return 0;
}

Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int h, w, n;
  cin >> h >> w >> n;
   
  cout << (n + max(h, w) -1)/max(h, w) << "\n";

}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int N, A[200100];

int comp(const void* a, const void* b);
void solve();

int main() {
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &A[i]);
	solve();
	return 0;
}

void solve() {
	int i, median;
	long long int cnt = 0;
	for (i = 0; i < N; i++) A[i] -= i + 1;
	qsort(A, N, sizeof(int), comp);
	if (N % 2 == 0) {
		median = (A[N/2] + A[N/2 - 1])/2;
	}
	else {
		median = A[(N - 1) / 2];
	}
	for (i = 0; i < N; i++) cnt += abs(A[i] - median);
	printf("%lld", cnt);
}

int comp(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin >> a[i];
  cout << a[n-1];
  for(int i=1;i<n;i++)cout << " " << a[n-i-1];
  cout << endl;
  return 0;
}

Measured memory_bytes: 3060
str = input()
l = len(str)
for _ in range(int(input())):
    r = input().split()
    a = int(r[1])
    b = int(r[2])
    if r[0] == 'print':
        print(str[a:b+1])
    elif r[0] == 'reverse':
        str = str[:a] + str[b-l:a-l-1:-1] + str[b+1:]
    else:
        str = str[:a] + r[3] + str[b+1:]


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  ll N,K;
  cin>>N>>K;
  
  ll A[N+1];
  for(int i=1; i<=N; ++i) cin>>A[i];
  
  ll DP[300000];
  REP(i,300000) DP[i]=0;
  DP[0]=1;
  
  for(int i=1; i<=N; ++i){
    DP[i]=A[DP[i-1]];
  }
  
  if(K<=N) cout<<DP[K]<<endl;
  else{
    ll COUNT[300000],S,G;
    REP(i,300000) COUNT[i]=INF;
    COUNT[1]=0;
    
    for(int i=1; i<=N; ++i){
      if(COUNT[DP[i]]!=INF){
        S=COUNT[DP[i]];
        G=i;
        break;
      }
      else COUNT[DP[i]]=i;
    }
    
    cout<<DP[(K-S)%(G-S)+S]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 9888
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
 
     	if(a%2 == 0 || b%2 == 0)
        {
          Console.WriteLine("Even");
        }
     	else
      	{
          Console.WriteLine("Odd");
        }	
	}
}

Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;

	VI t(n);
	rep(i, n - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C')t[i] = 1;
	}
	VI ru(n + 1); ru[0] = 0;
	rep(i, n) {
		ru[i + 1] = ru[i] + t[i];
	}

	rep(i, q) {
		int l, r; cin >> l >> r;
		int ans = ru[r - 1] - ru[l - 1];
		Cout(ans);
	}
}

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

template<typename T1, typename T2> void cmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T1, typename T2> void cmin(T1 &a, T2 b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  long ans = 0, mx = LONG_MIN;
  for (auto a : A) {
    if (a < mx) ans += mx - a;
    cmax(mx, a);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3984
#include <stdio.h>
#include <string.h>
int main(void){
 char a[3][101];
 int b[3]={0};
 int i,j=0;
 for(i=0;i<3;i++) scanf("%s",a[i]);
 while(1){
  if(a[j][b[j]]=='\0') break;
  j=a[j][b[j]++]-'a';
 }
 printf("%c",'A'+j);
 return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n;
int a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n - 1) {
		if (a[i] < a[i + 1])ans++;
	}
	cout << ans << endl;
	ggr
}



Measured memory_bytes: 3888
#include<iostream>

using namespace std;

int bubbleSort(int A[],int N){
	for(int i=0; i<N; i++) cin >> A[i];
	int count = 0,x = 0,P;
	bool Y=1;
	for(int j=0; Y; j++){
		P++;
		Y=0;
		for(int i=N-1; i>j; i--){
			if(A[i]<A[i-1]){
				x=A[i];
				A[i]=A[i-1];
				A[i-1]=x;
				count++;
				Y=1;
			}
		}
	}	
	return count;
}
int main(void){
	int N,count,A[100];
	cin >> N;
	count=bubbleSort(A,N);
	for(int i=0; i<N; i++){
		if(i==N-1)cout << A[i];
		else cout << A[i] << " ";
	}
	cout << endl << count << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N,L;
  in(N,L);
  long sum=0;
  up(i,1,N)sum+=L+i-1;
  long diff=LONG_MAX,ans=0;
  up(i,1,N){
    long tmp=sum-(L+i-1);
    if(abs(sum-tmp)<diff){
      diff=abs(sum-tmp);
      ans=tmp;
    }
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long dp[100][21];

int main() {
  int N, a[100], r;
  cin >> N;
  for (int i = 0; i < N-1; i++)
    cin >> a[i];
  cin >> r;
  for (int i = 0; i < N-1; i++)
    for (int j = 0; j <= 20; j++)
      dp[i][j] = 0;
  dp[0][a[0]] = 1;
  for (int i = 1; i < N-1; i++)
    for (int j = 0; j <= 20; j++) {
      if (j + a[i] <= 20)
        dp[i][j] += dp[i-1][j+a[i]];
      if (j - a[i] >= 0)
        dp[i][j] += dp[i-1][j-a[i]];
    }
  cout << dp[N-2][r] << endl;
  return 0;
}

Measured memory_bytes: 0
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll MOD = 1e9 + 7;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n; cin >> n;
	vi c(n); rep(i,n) cin >> c[i];
	map <int, int> ma;
	vll dp(n); dp[0] = 1; ma[c[0]] = 1;
	repA(i,1,n-1){
		if(c[i] == c[i-1]){
			dp[i] = dp[i-1];
			continue;
		}
		dp[i] = (dp[i-1] + ma[c[i]])%MOD;
		ma[c[i]] = (ma[c[i]] + dp[i-1])%MOD;
	}
	cout << dp[n-1] << endl;
	return 0;
}



Measured memory_bytes: 12032
//2017-10-8
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (50+5)

char s[N];

int main(){
	scanf("%s", s+1);

	int len = strlen(s+1);
	For(i, 1, len-8) printf("%c", s[i]);
	puts("");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//using P = pair<ll, ll>;
const ll INF = 1LL<<60;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)

//この問題で特別に追加するもの
const int MAX = 2500;
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; }
using pll = pair<ll, ll>; // (money, time)
using Edge = pair<int, pll>;
using Graph = vector<vector<Edge>>;


int N, M;
long long S;
Graph G;
vector<long long> C, D; // money, time

void solve() {
    if (S >= MAX) S = MAX;
    vector<vector<long long>> dp(N, vector<long long>(MAX+1, INF));
    priority_queue<pair<long long, pll>, vector<pair<long long, pll> >, greater<pair<long long, pll> > > que;
    dp[0][S] = 0;
    que.push(make_pair(0, pll(0, S)));
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        long long time = p.first;
        int v = p.second.first;
        long long s = p.second.second;
        if (time > dp[v][s]) continue;

        // 補充
        if (s + C[v] <= MAX) {
            long long ns = s + C[v];
            long long ntime = time + D[v];
            if (chmin(dp[v][ns], ntime)) {
                que.push(make_pair(ntime, pll(v, ns)));
            }
        }
        // 辺を通る
        for (auto e : G[v]) {
            if (s < e.second.first) continue;
            int nv = e.first;
            long long ns = s - e.second.first;
            long long ntime = time + e.second.second;
            if (chmin(dp[nv][ns], ntime)) {
                que.push(make_pair(ntime, pll(nv, ns)));
            }
        }
    }
    for (int v = 1; v < N; ++v) {
        long long res = INF;
        for (int s = 0; s <= MAX; ++s) chmin(res, dp[v][s]);
        cout << res << endl;
    }
}

int main() {
    cin >> N >> M >> S;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < M; ++i) {
        long long u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        G[u].push_back(Edge(v, pll(a, b)));
        G[v].push_back(Edge(u, pll(a, b)));
    }
    C.resize(N); D.resize(N);
    for (int i = 0; i < N; ++i) cin >> C[i] >> D[i];
    solve();
}

Measured memory_bytes: 7420
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------



















































Measured memory_bytes: 3636
using System;

namespace A_Product {
    class Program {
        static void Main(string[] args) {
            var num = Console.ReadLine().Split(' ');

            int a = int.Parse(num[0]);
            int b = int.Parse(num[1]);

            int c = a * b;

            string answer = "Even";
            if(c%2 == 1) {
                answer = "Odd";
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
N,M,X = map(int,input().split())
r = [0]*M
A = []
ans = float('inf')
for _ in range(N):
    A_ = list(map(int,input().split()))
    A.append(A_)
    for i in range(M):
        r[i] += A_[i+1]
for i in range(len(r)):
    if r[i] < X:
        print(-1)
        exit()

for i in range(2**N):
    r = [0]*(M+1)
    p = 0
    for j in range(N):
        if ((i>>j)&1):
            c = A[j]
            for k in range(M+1):
                r[k] += c[k]
    for l in range(M):
        if r[l+1] <X:
            p = -1
            break
        else:
            continue
    if p == 0:
        ans = min(ans,r[0])
    else:
        continue
print(ans)

Measured memory_bytes: 9252
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    bool ok = true;
    rep(i, s.size()){
        if(i%2 == 0 && s[i] == 'L') ok = false;
        if(i%2 == 1 && s[i] == 'R') ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    string s,t;
    std::cin >> s;
    std::cin >> t;
    if(s==t.substr(0,s.length())){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


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

void findDivisors(ll int n)
{


	vector<ll int>div(n+1,0);ll int sum=0;;


	for (ll int i = 1; i <= n; i++) {

		for (ll int j = 1; j * i <= n; j++)
			div[i * j]++;
	}

	for (ll int i = 1; i <= n; i++)
		sum+=i*div[i];
    cout<<sum<<endl;
}
int main()
{
	ll int n ;
	cin>>n;
	findDivisors(n);

	return 0;
}


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

int N, W[100];

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

    vector<int> sum(N+1);
    sum[0] = 0;
    for(int i=0;i<N;i++)    sum[i+1] = sum[i] + W[i];

    int ans = 1000000000;
    for(int i=0;i<N;i++){
        ans = min(ans, abs( (sum[N] - sum[i]) - sum[i]) );
    }
    
    cout << ans << endl;
}

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

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

  while (N >= 4)
  {
    if (N % 4 == 0 || N % 7 == 0)
    {
      cout << "Yes";
      return 0;
    }
    N -= 4;
  }
  cout << "No";

  return 0;
}

Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n,k;
		cin>>n>>k;
		ll int dp[n+1],h[n+1];
		for(ll int i=1;i<=n;i++)
		{
			cin>>h[i];
		}
		dp[1]=0;
		dp[2]=abs(h[1]-h[2]);
		for(ll int i=3;i<=n;i++)
		{
			ll int mini=hell;
			for(ll int j=i-1;j>=i-k&&j>=1;j--)
			{
				mini=min(mini,dp[j]+abs(h[j]-h[i]));
			}
			dp[i]=mini;
		}
		cout<<dp[n];
	}
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))
m2 = 0
m4 = 0
other=0
for i, aa in enumerate(a):
    if aa % 4 == 0:
        m4 +=1
        continue
    if aa % 2 == 0:
        m2 += 1
        continue
    other += 1
if m4 >= other or (m4 + 1 == other and m2 == 0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = (n - 1 + k - 1 - 1) / (k - 1);
    cout << ans << endl;
}

Measured memory_bytes: 640
lst_c = [list(map(int, input().split())) for _ in range(3)]


lst_diff_i = []
for i in range(3):
    diff1 = lst_c[i][0] - lst_c[i][1]
    diff2 = lst_c[i][1] - lst_c[i][2]
    diff3 = lst_c[i][2] - lst_c[i][0]
    lst_diff_i.append([diff1, diff2, diff3])
if lst_diff_i[0] == lst_diff_i[1] == lst_diff_i[2]:
    ans = "Yes"
else:
    print("No")
    exit()


for i in range(3):
    diff1 = lst_c[0][i] - lst_c[1][i]
    diff2 = lst_c[1][i] - lst_c[2][i]
    diff3 = lst_c[2][i] - lst_c[0][i]
    lst_diff_i.append([diff1, diff2, diff3])
if lst_diff_i[0] == lst_diff_i[1] == lst_diff_i[2]:
    ans = "Yes"
else:
    print("No")
    exit()


print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

#define ll long long

using namespace std;

const int NMAX = 200000+ 3;
int c[NMAX], d[NMAX], a[NMAX];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> c[i] >> d[i];
        a[i] = i;
    }
    sort(a + 1, a + n + 1, [&] (int a, int b) {
                       return d[a] < d[b];
                   });
        cout << endl;
    // for (int i = 1; i <= n; ++i) {
    //     cout << d[a[i]] << " " << c[a[i]] << endl;
    // }
    ll time = 0;
    for (int i = 1; i <= n; ++i) {
        time += c[a[i]];
        if (time > d[a[i]]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 2560
#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 a, b, c;
  string s;
  cin >> a;
  const double PI=3.1415926535897932;
  cout <<setprecision(18) <<  2 * a * PI << endl;

  return 0;
}


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


int main(){
  int x,n;
  cin >> x >> n;
  map<int,int> mp;
  for(int i=0;i<n;++i){
    int p;
    cin >> p;
    mp[p]++;
  }
  int ans;
  int sa=300;
  for(int i=-100;i<=120;++i){
    if(mp[i]==0){
      int cal=abs(x-i);
      if(cal<sa){
        sa=cal;
        ans=i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int a,b,c,d;

	scanf("%d%d%d",&a,&b,&c);
	if(a!=b)d++;
	if(a!=c)d++;
	if(b!=c)d++;
	if(a==b&&a==c)d++;
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bitset<2000001>a;
int n,x,c;
int main()
{
	int i;
	cin>>n;
	a[0]=1;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		c+=x;
		a|=a<<x;
	}
	for(i=c/2+c%2;i<=c;i++)
	{
		if(a[i]>0)
		{
			cout<<i<<endl;
			return 0;
		} 
	}
	return 0;	
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

int main(){
    int P,Q,R; cin >> P >> Q >> R;
    int temp = P+Q;
    temp = min(temp,Q+R);
    temp = min(temp,P+R);
    cout << temp << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  double ans = 0;
  rep(i, n) {
    double x;
    string v;
    cin >> x >> v;

    if (v == "BTC") ans += x * 380000.0;
    else ans += x;
  }

  cout << fixed << setprecision(10) << ans << "\n";

  return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<bool> a(n+1);
    vector<bool> b(n+1); 
    vector<ll> out;
    for(ll i=1;i<=n;i++){
        ll x;
        cin >> x;
        if(x==0)    a[i] = false;
        else    a[i] = true;
    }
    ll num=n/2;

    for(ll i=num+1;i<=n;i++){
        b[i] = a[i];
    }
    for(ll i=num;i>=1;i--){
        ll cnt=0;
        ll t=3;
        for(ll j=2*i;j<=n;t++){
            if(b[j]==true)  cnt++;
            j=t*i;
        }
        if(cnt%2==0){
            if(a[i]) b[i] = true;
            else    b[i] = false;
        }
        else{
            if(a[i]) b[i] = false;
            else b[i] = true;
        }
    }
    for(int i=1;i<=n;i++){
        if(b[i])    out.push_back(i);
    }
    cout << out.size() << endl;
    if(out.size()>0){
        for(int i=0;i<out.size();i++){
        if(i!=0)cout << ' '<<out[i];
        else cout << out[i];
        }
        cout << endl;
    }
    return 0;
} 

Measured memory_bytes: 2296
n=int(input())
play=[]
for i in range(n):
    s,t=map(str,input().split())
    play.append([s,t])
x=input()
ans=0
flag=False
tmp=0
for i in range(n):
    if play[i][0]==x:
        flag=True
        tmp=int(play[i][1])
    if flag:
        ans+=int(play[i][1])

print(ans-tmp)

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	x, n := scanInt(), scanInt()
	xm := make(map[int]bool)
	for i := 0; i < n; i++ {
		p := scanInt()
		xm[p] = true
	}

	d := 100
	var ans int
	for i := 0; i <= 101; i++ {
		if xm[i] {
			continue
		}
		if abs(x-i) < d {
			d = abs(x - i)
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    string s;
    cin>>s;
    if(s[5]=='1'||s[6]>'4')cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;

    return 0;
}


Measured memory_bytes: 3592
n=int(input())
A=["3","5","7"]
A=set(A)
cnt=0

for _ in range(len(str(n))-1):
	for a in list(A):
		x=a+"3"
		y=a+"5"
		z=a+"7"
		if int(x)<=n:
			A.add(x)
		if int(y)<=n:
			A.add(y)
		if int(z)<=n:
			A.add(z)

res=0

for a in list(A):
	if "3" in a and "5" in a and "7" in a:
		res+=1		

print(res)

Measured memory_bytes: 7148
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; cin >> a;
    double b; cin >> b;
    cin >> a >> b;
    b += 1e-9;
    ll bb = b*100;
    cout << a*bb/100 << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>

using namespace std;

int N, ans;
int h[100];
int min(){
  	int M=101;
	for(int i=0; i<N; i++){
     	if(h[i]<M){
        	M=h[i];  
        }
    }
  	return M;
}
int sum(){
  	int s=0;
	for(int i=0; i<N; i++){
    	s+=h[i]; 
    }
	return s;
}

int main(){
	cin >> N;
  	for(int i=0; i<N; i++){
    	cin >> h[i];  
    }
	while(sum()){
      	int start=-1;
  		for(int i=0; i<N; i++){
    		if(h[i]>0){
        	 	start=i;
             	break;
       	 	}
    	}
      	if(start!=-1){
      		for(int i=start; i<N; i++){
         		if(h[i]>0&&i!=N-1){
            		h[i]-=1; 
            	}
              	else if(h[i]>0&&i==N-1){
                 	h[i]-=1;
                  	ans+=1;
                }
          		else{
              		ans+=1;
            		break; 
            	}
        	}
        }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256