akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 10000
using namespace std;

int main () {
  std::cin.tie(0); // tie
  std::ios::sync_with_stdio(false); // sync
  int n, q, val;
  int count = 0, m, i;
  set<int> S;

  cin >> n;
  rep(i,n) {
    cin >> val;
    S.insert(val);
  }

  cin >> q;
  rep(i,q) {
    cin >> m;
    if (S.find(m) != S.end())  count++;
  }
  cout << count << endl;
  return 0;
}
  

Measured memory_bytes: 3224
s = gets.chomp
f = s[0, 2].to_i
b = s[2, 2].to_i

def y(x)
  0 <= x && x <= 99
end

def m(x)
  1 <= x && x <= 12
end

ans = []
ans << 'YYMM' if y(f) && m(b)
ans << 'MMYY' if m(f) && y(b)

case ans.size
when 0
  puts 'NA'
when 1
  puts ans[0]
when 2
  puts 'AMBIGUOUS'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));

int main() {
  cin >> n;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    if (a == 1) {
      cout << b << endl;
    }
    else cout << (a-1) * 127 + (a%2?b:b^127) << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    string s;
    cin >> s;

    replace(ALL(s), ',', ' ');
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 

int main(void)
{
	int a, b;

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

	if(a < b)
	{
		printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

bool in(int x, int y) {
  return 0<=x&&x<15&&0<=y&&y<19;
}

string S[20];
int sx, sy;
map<pint, int> mp;
int dp[1<<20];

int solve(int x, int y, int bit) {
  if(y >= 19 || y == 18 && 0 <= x && x < 15) return 0;
  if(y < 0 || x < 0 || 15 <= x) return inf;
  int &res = dp[bit];
  if(~res) return res;
  res = inf;
  for(int dx = -1; dx < 2; dx++) {
    for(int dy = -1; dy < 2; dy++) {
      if(dx == 0 && dy == 0) continue;
      int nx = x + dx, ny = y + dy, nbit = bit;
      if(!in(nx, ny) || S[ny][nx] != 'X') continue;
      if((bit>>mp[pint(nx, ny)])&1) continue;
      while(in(nx, ny) && S[ny][nx] == 'X' && !(bit>>mp[pint(nx, ny)]&1)) {
	nbit |= 1<<mp[pint(nx, ny)];
	nx += dx, ny += dy;
      }
      res = min(res, solve(nx, ny, nbit) + 1);
    }
  }
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int cnt = 0;
  rep(i, 19) {
    cin >> S[i];
    rep(j, 15) {
      if(S[i][j] == 'O') sx = j, sy = i;
      if(S[i][j] == 'X') mp[pint(j, i)] = cnt++;
    }
  }
  memset(dp, -1, sizeof(dp));
  int ans = solve(sx, sy, 0);
  cout << (ans == inf ? -1 : ans) << endl;

  return 0;
}

Measured memory_bytes: 11408
#include <stdio.h>
#include <stdlib.h>

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

int main(void){
  /*
  串が長い奴を多く使いたい？
  ケース
  (100,50,50,10)→10+50=6
  (100,50,50,50,20,10)→10+50+50
  短い奴は短い奴と組み合わせたい
  短い順に並べて、奇数番目を足せばおk
  */

  int N;
  scanf("%d",&N);
  int L[2*N+1];
  int i;
  int sum = 0;
  L[0] = 101;
  for(i=1;i<=2*N;i++){
      scanf("%d",L+i);
  }

  qsort(L,2*N+1,sizeof(int),compare_int);

  for(i=0;i<=N-1;i++){
    sum = sum + L[i*2];
  }

  printf("%d",sum);

}

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

const int N = 200005;

int n;
int a[N];

map<int, int> cnt;

int solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += cnt[i - a[i]];
    ++cnt[a[i] + i];
  }

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

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    solve();
  }
  return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll dp[MAXN][2];
vector<ll> G[MAXN];

void DFS(ll u, ll p){
	dp[u][0] = 1;
	dp[u][1] = 1;
	for(auto adj : G[u]){
		if(adj == p) continue;
		DFS(adj, u);
		dp[u][0] *= (dp[adj][0] + dp[adj][1]);
		dp[u][1] *= (dp[adj][0]);
		dp[u][0] %= MOD; 
		dp[u][1] %= MOD;
	}
	return ;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll u, v;
	for(int i = 1; i < n; i++){
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	
	DFS(1, -1);
	cout << (dp[1][0] + dp[1][1]) % MOD;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 14208
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    keta=1
    for i in A:
        keta*=i
        if keta>1000000000000000000:
            break
        
    if keta>1000000000000000000:
        print(-1)
    else:  
        print(keta)

Measured memory_bytes: 21648
"use strict"
 
const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args_lines = arg_str.split('\n')
const N = args_lines[0]
const a = args_lines[1]
const a_s = a.split(' ')
const b = args_lines[2]
const b_s = b.split(' ')
const c = args_lines[3]
const c_s = c.split(' ')
 
let sum = 0
let last_val = -1
 
a_s.map(x=>{
    if(b_s[x-1]){
        sum += parseInt(b_s[x-1])
    }
    if(x - 1 == last_val + 1){
        if(c_s.length > 0 && c_s[last_val]){
            sum += parseInt(c_s[last_val])
        }else{
          if(last_val == 0){
            sum += parseInt(c_s)
          }
        }
    }
    last_val = x - 1
})

console.log(sum)

Measured memory_bytes: 7372
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
ll ans=0;
ans+=(n/500)*1000;
n%=500;
ans+=(n/5)*5;
cout<<ans;









return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
def warshall_floyd(graph):
    num_v = len(graph)

    for k in range(num_v):
        for i in range(num_v):
            for j in range(num_v):
                if graph[i][j] > graph[i][k] + graph[k][j]:
                    graph[i][j] = graph[i][k] + graph[k][j]
    return graph

N = int(input())
graph = [[float("inf") for _ in range(N)] for _ in range(N)]
for i in range(N):
    a_list = list(map(int, input().split()))
    for j in range(N):
        if i == j:
            continue
        graph[i][j] = a_list[j]
# import copy
# a_list = copy.deepcopy(graph)
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
w_graph = floyd_warshall(graph, directed=False)
result = 0
for i in range(N):
     w_graph[i][i] = float("inf")
for i in range(N):
    for j in range(i):
        if i == j:
            continue
        if w_graph[i][j] != graph[i][j]:
            print(-1)
            exit()
        if w_graph[i][j] < np.min(w_graph[i] + w_graph[j]):
            result += w_graph[i][j]
print(int(result))


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

using namespace std;

void insertionSort(int target[], int n) {
  for (int i = i; i < n; i++) {
    int v = target[i];
    int j = i - 1;
    while (j >= 0 && target[j] > v) {
      target[j + 1] = target[j];
      j--;
    }
    target[j + 1] = v;

    for (int k = 0; k < n; k++) {
      cout << target[k];

      if (k == n - 1) {
        cout << endl;
      } else {
        cout << " ";
      }
    }
  }
};

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

  insertionSort(R, num);
  return 0;
}



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

int main()
{
    long long int n;
    cin >> n;
    for(long long int i = sqrt(n);i > 0;i--) {
        if(n % i == 0) {
            cout << n / i + i - 2 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

    int A,B,M; cin>>A>>B>>M;
    vi a = READ<int>(A);
    vi b = READ<int>(B);
    int ans = *min_element(ALL(a)) + *min_element(ALL(b));
    FOR(i,M){
        int x,y,c; cin>>x>>y>>c;
        ans |= MIN(a[x-1]+b[y-1]-c);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <cctype>
#include <utility>
#include <string>
#include <functional>
#include <array>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using A = array<int, 3>;

function<int(A &)> f(string::iterator &i) {
	switch (*i) {
	case '0': case '1': case '2':
		{
			char c = *i++ - '0';
			return [c](...) { return c; };
		}
	case 'P': case 'Q': case 'R':
		{
			int j = *i == 'P' ? 0 : *i == 'Q' ? 1 : 2;
			i++;
			return [j](A &e) { return e[j]; };
		}
	case '-':
		{
			auto a = f(++i);
			return [a](A &e) { return 2 - a(e); };
		}
	default:
		{
			auto a = f(++i);
			char op = *i;
			auto b = f(++i);
			i++;
			if (op == '*')
				return [a, b](A &e) { return min(a(e), b(e)); };
			else
				return [a, b](A &e) { return max(a(e), b(e)); };
		}
	}
}

int main() {
	for (string s; scan(s), s[0] != '.';) {
		auto i = s.begin();
		auto e = f(i);
		A t;
		function<int(int)> loop = [&](int i) {
			if (i--) {
				int a = 0;
				for (t[i] = 0; t[i] < 3; t[i]++)
					a += loop(i);
				return a;
			} else
				return (int) (e(t) == 2);
		};
		outl(loop(3));
	}
}


Measured memory_bytes: 2536
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int modpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

//周期がiの約数の回文数
int calcnum(int i, int K, int mod){
    return modpow(K, (i + 1) / 2, mod);
}

int mebius(int d){
    int m = 1;
    int d0 = d;
    for(int i = 2; i * i <= d; i++){
        int k = 0;
        while(d0 % i == 0){
            k++;
            d0 /= i;
        }
        if(k >= 2) return 0;
        else if(k == 1) m *= -1;
    }
    if(d0 > 1) return -m;
    else return m;
}

signed main(){

    int N, K; cin >> N >> K;
    int mod = 1000000007;

    map<int, int> f, mu;
    for(int i = 1; i * i <= N; i++){
        if(N % i == 0){
            f[i] = calcnum(i, K, mod);
            f[N / i] = calcnum(N / i, K, mod);
            mu[i] = mebius(i);
            mu[N / i] = mebius(N / i);
        }
    }
    int ans = 0;
    for(auto p: f){
        int n = p.first;
        int val = 0;
        for(auto q: f){
            int d = q.first;
            if(n % d == 0){
                val += mu[n / d] * q.second;
                val = (val % mod + mod) % mod;
            }
        }
        //g[n] = val;
        //cout << n << " " << val << endl;
        if(n % 2 == 0) ans += val * (n / 2);
        else ans += val * n;
        ans %= mod;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <bitset>

#pragma comment(linker, "/STACK:256000000")

using namespace std;

typedef long long int ll;
typedef long double ld;

const int INF = 1000 * 1000 * 1000 + 21;
const ll LLINF = (1ll << 60) + 5;
const int MOD = 1000 * 1000 * 1000 + 7;

const int MAX_N = 505;

int n;
ll c[MAX_N];
ll s[MAX_N];
ll f[MAX_N];

int main()
{
#ifdef CH_EGOR
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
#endif

	cin >> n;

	for (int i = 0; i < n - 1; ++i)
		cin >> c[i] >> s[i] >> f[i];

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

		for (int j = i; j < n - 1; ++j)
		{
			if (time_now < s[j]) time_now = s[j];
			
			if (time_now % f[j] != 0)
			{
				time_now += f[j] - time_now % f[j];
			}

			time_now += c[j];
		}

		cout << time_now << "\n";
	}
	
	cout << 0 << "\n";

	return 0;
}



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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL a, b;
	cin >> a >> b;

	int negative=0, positive=0, zero=0;
	for(int i=a; i<=b; i++){
		if(i < 0){
			negative++;
		}
		else if(i == 0){
			zero++;
		}
		else{
			positive++;
		}
	}

	if(zero > 0){
		printf("Zero\n");
	}
	else if((negative % 2) == 1){
		printf("Negative\n");
	}
	else{
		printf("Positive\n");
	}
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include<stdlib.h>
#define min(a,b) (a)<(b)?(a):(b)
#define inf (1<<30)

int h[100100];
int dp[100100];
int main(void){
    int i,n;
    for(i=0;i<100100;i++){
        h[i] = dp[i] = inf;
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    dp[0]=0;
    for(i=0;i<n;i++){
        int a=abs(h[i]-h[i+1]);
        int b=abs(h[i]-h[i+2]);
        dp[i+1]=min(dp[i]+a,dp[i+1]);
        dp[i+2]=min(dp[i]+b,dp[i+2]);
    }
    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define mm(x,n) memset(x,n,sizeof(x))
#define IOS cin.tie(0); ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int maxn = 2e5+5;

int main(){IOS
	int n,a,b;	
	cin >> n >> a >> b;
	ll ans = 0;
	rep(i,1,n){
		int sum = 0;
		int j = i;
		while(j){
			sum += j%10;
			j /= 10;
		}
		if(sum>=a && sum<=b)
			ans += i;
	} 
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;

cc N, K, Ans, i, j, k, a[5000000], sub = 0;
cc kai[35], A[5000000];

string S;


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

	for (i = 0; i < N; i++) {
		if (A[0] < a[i])
			A[0] = a[i];
		else if (A[1] < a[i])
			A[1] = a[i];
	}
	
	for (i = 0; i < N; i++) {
		if (a[i] != A[0])
			cout << A[0] << endl;
		else
			cout << A[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)998244353, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i, a[200003], ans[200003] = {}, bit, on;
    bool con;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    bit = 1;
    con = true;
    while (con) {
        con = false;
        on = 0;
        for (i = 0; i < n; i++) {
            if (a[i] % 2 == 1) {
                on++;
            }
        }
        for (i = 0; i < n; i++) {
            if ((on + a[i] % 2) % 2 == 1) {
                ans[i] += bit;
            }
            a[i] /= 2;
            if (a[i] > 0) con = true;
        }
        bit *= 2;
    }

    for (i = 0; i < n; i++) {
        printf("%d ", ans[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 5376
N=int(input())
lenN=len(str(N))
lst=[]
lst2=[[0 for m in range(10)] for i in range(10)]

for i in range(11,100):
    if "0" not in str(i):
        lst.append(str(i))
for i in range(1,N+1):
    if "0" not in [int(str(i)[0]),int(str(i)[-1])]:
        lst2[int(str(i)[0])][int(str(i)[-1])]+=1
#print(lst)
count=0
for a in lst:
    for b in lst:
        if a[0]==b[-1] and b[0]==a[-1]:
            b=lst2[int(a[0])][int(a[-1])]*lst2[int(b[0])][int(b[-1])]
            count+=(b) if b>1 else b
print(count)


Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n; cin>>n;
    string ans;
    if(n==0) ans="0";
    while(n!=0){
        if(n%(-2)!=0){
            ans="1"+ans;
            n--;
        }else{
            ans="0"+ans;
        }
        n/=-2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

a, b, c = nil()

if(b-a == c-b):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		scan.close();
		int cnt[]= {0,0,0};
		int next=0;
		char fin='f';
		while(true){
			switch(next) {
				case 0:
					if(a.length()==cnt[0])fin='A';
					else if(a.charAt(cnt[next])=='b')next=1;
					else if(a.charAt(cnt[next])=='c')next=2;
					cnt[0]++;
					break;
				case 1:
					if(b.length()==cnt[1])fin='B';
					else if(b.charAt(cnt[next])=='a')next=0;
					else if(b.charAt(cnt[next])=='c')next=2;
					cnt[1]++;
					break;
				case 2:
					if(c.length()==cnt[2])fin='C';
					else if(c.charAt(cnt[next])=='b')next=1;
					else if(c.charAt(cnt[next])=='a')next=0;
					cnt[2]++;
					break;
			}
			if(fin!='f')break;
		}
		System.out.println(fin);
	}
}

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



int main(){
	int A[3][10];
	int B[3][10];
	int C[3][10];
	int D[3][10];
	for (int j = 0; j < 10; j++){
		for (int i = 0; i < 3; i++){
			A[i][j] = 0;
			B[i][j] = 0;
			C[i][j] = 0;
			D[i][j] = 0;
		}
	}

	int n;
	int b, f, r, v;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		switch (b)
		{
		case 1:
			A[f - 1][r - 1] += v;
			break;
		case 2:
			B[f - 1][r - 1] += v;
			break;
		case 3:
			C[f - 1][r - 1] += v;
			break;
		case 4:
			D[f - 1][r - 1] += v;
			break;
		default:
			break;
		}
	}

	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 10; j++){
			cout << " " << A[i][j];
		}
		cout << endl;
	}
	for (int k = 0; k < 20; k++){
		cout << "#";
	}
	cout << endl;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 10; j++){
			cout << " " << B[i][j];
		}
		cout << endl;
	}
	for (int k = 0; k < 20; k++){
		cout << "#";
	}
	cout << endl;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 10; j++){
			cout << " " << C[i][j];
		}
		cout << endl;
	}
	for (int k = 0; k < 20; k++){
		cout << "#";
	}
	cout << endl;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 10; j++){
			cout << " " << D[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
N, A, B = map(int, input().split())

sum = 0
for n in range(1, N+1):
    _num = 0
    digits = list(str(n))
    for _n in list(str(n)):
        _num += int(_n)

    if _num >= A and _num <= B:
        sum += n

print(sum)


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

int main(){
    int n,d;cin>>n>>d;vector<vector<int>> x(n,vector<int>(d));
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x.at(i).at(j);
        }
    }
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int l=0;
            for(int k=0;k<d;k++){
                l+=pow(x.at(i).at(k)-x.at(j).at(k),2);
            }
            for(int k=1;k*k<=l;k++){
                if(k*k==l) count++;
            }
        }
    }
    cout<<count<<endl;
}

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

int main(void){
  string s, t; ll ans = 0, cur = 0, n, m, x; bool ok = true;
  cin >> s >> t;
  n = s.length(), m = t.length();
  vector<set<int>> vs(26);
  rep(i, 26) vs[i].insert(M);
  rep(i, n) vs[s[i] - 'a'].insert(i + 1);
  rep(i, m){
    x = t[i] - 'a';
    cur = *vs[x].upper_bound(cur);
    if (cur == M) ++ans, cur = *vs[x].begin();
    if (cur == M) ok = false;
  }

  (ans *= n) += cur;
  printf("%lld\n", ok ? ans : -1);

  return 0;
}


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

int N;
int main(void){
    // Your code here!
    cin >> N;
    double P[N];
    double dp[N+10][N+10];
    
    for(int i = 0; i < N; i++) cin >> P[i];
    
    for(int i = 0; i <= N; i++) for(int j = 0; j <= N; j++) dp[i][j] = 0;
    dp[0][0] = 1.0;
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= i; j++){
            dp[i+1][j+1] = P[i] * dp[i][j];
            dp[i+1][j] += (1.0-P[i]) * dp[i][j];
        }
    }
    
    double ans = 0.0;
    if(N % 2 == 0){
        for(int j = N / 2 + 1; j <= N; j++){
            ans += dp[N][j+1];
        }
    } else {
        for(int j = (N + 1)/2; j <= N; j++){
            ans += dp[N][j];
        }
    }
    
    printf("%.10f\n", ans);
}


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

int main() {
  int N;
  cin >> N;
  int cnt=0;
  
  if(N / 100000 == 1){
    cnt = 90909;
  }
  else if (N / 10000 > 0){
    cnt = N - 9090;
  }
  else if (N / 1000 > 0){
    cnt = 909;
  }
  else if (N / 100 > 0){
    cnt = N - 90;
  }
  else if (N / 10 > 0){
    cnt = 9;
  }
  else{
    cnt = N;
  }
  cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
 #include <vector>
 #include <algorithm>
 #include <map>
 #include <set>
 #include <cmath>
 #include <cstring>
 #include <iomanip>
 #include <random>
 #include <chrono>
 #include <queue>
 #include <math.h>
 using namespace std;

int main(){
  int a[5];
  cin >>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
  bool ans=0;
  
  for (int i=1;i<5;i++){
    if(a[5]<a[i]-a[0]) ans=1;
  }
  for (int i=2;i<5;i++){
    if(a[5]<a[i]-a[1]) ans=1;
  }
  for (int i=3;i<5;i++){
    if(a[5]<a[i]-a[2]) ans=1;
  }
  for (int i=4;i<5;i++){
    if(a[5]<a[i]-a[3]) ans=1;
  }
  
  if(ans) cout <<":("<<endl;
  else cout <<"Yay!"<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;

int main () {
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  
  int sum;
  for (int i = 0; i < 2; i++) {
    if (x > y) {
      sum += x;
      x--;
    } else {
      sum += y;
      y--;
    }
  }
  cout << sum << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,c,i,count=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if (c%i==0){
            count+=1;
        }
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S;
        int x = 0;
            cin >> S;
                for(int i = 0; i < 4; i++){
                    if(S.at(i) == '+'){
                        x += 1;
                    }else if(S.at(i) == '-'){
                        x -= 1;
                    }else{}
                }
                    cout << x << endl;
    return 0;}

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

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


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

#define ll long long int 
#define ull unsigned long long
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



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

int main()
{
	_fastio
	vector<ll>v[200005];
	ll n,m,a,b,ans=0;
	si(n);
	si(m);
	ll h[n+10];
	for1(i,n)
		si(h[i]);

	for1(i,m)
	{
		si(a);
		si(b);
		pb(v[a],b);
		pb(v[b],a);
	}
	for1(i,n)
	{
		ll fl=0;
		ll k=v[i].size();
		for0(j,k)
		{
			if(h[v[i][j]]>=h[i])
			{
				fl=1;
				break;
			}
		}
		if(!fl) ans=ans+1;
	}
	printf("%lld\n",ans);
}

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

using namespace std;

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

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

int a,b;
int main() {
	scanf("%d %d", &a, &b);
	if (a <= 0 && b >= 0) printf("Zero\n");
	else if (a > 0) printf("Positive\n");
	else {
		if ( (b-a+1)%2 == 0 ) printf("Positive\n");
		else printf("Negative\n");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <string.h>
#include <vector>
#include <map>
#include <stack>

// TODO テンプレート化したい
// std::vector<int>::iterator binarySearch(std::vector<int> sorted_array, int value)
// {
//     int left  = 0;
//     int right = sorted_array.size();

//     while (left < right - 1) {
//         int current = (left + right) / 2;
//         if(value == sorted_array.at(current)){
//             return sorted_array.begin() + current;
//         }else if(value < sorted_array.at(current)){
//             right = current;
//         }else{
//             left = current;
//         }
//     }

//     return sorted_array.end();
// }

int binarySearch(std::vector<int> sorted_array, int value)
{
    int left  = 0;
    int right = sorted_array.size();

    while (left < right) {
        int current = (left + right) / 2;
        if(value == sorted_array.at(current)){
            return current;
        }else if(value < sorted_array.at(current)){
            right = current;
        }else{
            left = current;
            if (current + 1 == right)
                break;
        }
    }

    return sorted_array.size();
}

std::vector<int> createVectorFronCin(int cnt)
{
    std::vector<int> ret;
    ret.reserve(cnt);

    int cur = 0;
    for (int i = 0; i < cnt; ++i) {
        std::cin >> cur;
        ret.push_back(cur);
    }

    return ret;
}

int main()
{
    int n = 0;
    int q = 0;

    std::cin >> n;
    std::vector<int> sorted_array = createVectorFronCin(n);

    std::cin >> q;
    std::vector<int> values = createVectorFronCin(q);

    int counter = 0;
    for (std::vector<int>::iterator it = values.begin(); it < values.end(); ++it) {
        int pos = binarySearch(sorted_array, *it);
        if (pos < sorted_array.size())
           counter++;

        //std::vector<int>::iterator pos = binarySearch(sorted_array, *it);
        //if (pos != sorted_array.end())
        //    counter++;


        // if (binarySearch(sorted_array, *it) != sorted_array.end())
        //     counter++;
    }

    std::cout << counter << std::endl;
}




Measured memory_bytes: 3848
program ABC163D
    implicit none
    integer(8)::N,K,ans,m,i
    read*,N,K
    m=10**9+7
    ans=0
    do i=K,N+1
        ans=ans+-1*i**2+(N+1)*i+1
        ans=mod(ans,m)
    end do

    print'(i0)',ans
end program ABC163D

Measured memory_bytes: 2876
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n, a[128][128], b[128];

void readA(int *a) {
    rep (i, n) a[i] = 0;
    int m;
    scanf("%d", &m);
    rep (i, m) {
        int x;
        scanf("%d", &x);
        a[x-1] = 1;
    }
}

bool can(int k) {
    rep (i, n) if (b[i] && !a[k][i]) return false;
    return true;
}

int main() {
    for (;;) {
        scanf("%d", &n);
        if (n == 0) return 0;
        rep (i, n) readA(a[i]);
        readA(b);
        int c = 0;
        rep (i, n) if (can(i)) c++;
        if (c != 1) printf("%d\n", -1);
        else rep (i, n) if (can(i)) printf("%d\n", i+1);
    }
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}
// nのk乗を計算する
ll modpow(ll n, ll k){
    ll ret = 1;
    ll t = n;
    while(k > 0){
        if(k & 1) ret = ret * t % MOD;
        t = t * t % MOD;
        k = k>>1;
    }
    return ret;
}

int main(){
    ll N;
    cin >> N;
    ll ans = modpow(10, N);
    ans = (ans + modpow(8, N)) % MOD;
    ans = (ans - 2 * modpow(9, N) + 2 * MOD) % MOD;
    printf("%lld\n", ans);

}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int limit;
double deepest = 0;
int sgans=0, sans=0;
double a,b,c,d,e,f;
vector <vector<bool>> SW(3010 ,vector <bool>(3010 )); //water| sugar
void dfs(int water, int sugar){
    if(water>3000||sugar>3000) return ;
    if(SW[water][sugar]==true) return ;
    else {
        SW[water][sugar] = true;
        dfs(water+(100*a), sugar);
        dfs(water+(100*b), sugar);
        dfs(water, sugar +c);
        dfs(water, sugar +d);
    }
    return ;
}
int main(void){
    cin>>a>>b>>c>>d>>e>>limit;
    dfs(0,0);
    for(double i=0;i<=limit;i++){
        for(double j=0;j<=limit;j++){
            if(SW[i][j]&&(i+j)<=limit&& !(i==0&&j==0)){
                if(j<= i*e/100){
                    double noudo = 100*j/(i+j);
                    if(noudo>deepest){
                        deepest = noudo;
                        sgans = i+j;
                        sans = j;
                    }
                }
            }
        }
    }
    if(sgans==0&&sans==0){
        cout<<a*100<<' '<<0<<endl;
        return 0;
    }
    cout<<sgans<<' '<<sans<<endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

void rec(vector<pair<int, vector<int>>> &v, int idx, int cost, vector<int> knowledge, int &minCost) {
    if (idx == v.size()) {
        for (int i : knowledge)
            if (i > 0) return;

        minCost = min(minCost, cost);
        return;
    }

    rec(v, idx + 1, cost, knowledge, minCost);

    for (int i = 0; i < v[idx].second.size(); ++i) {
        knowledge[i] -= v[idx].second[i];
    }
    rec(v, idx + 1, cost + v[idx].first, knowledge, minCost);
}

int solve()
{
    int N, M, X;

    std::cin >> N >> M >> X;

    vector<pair<int, vector<int>>> v;

    for (int i = 0; i < N; ++i) {
        int c;
        cin >> c;

        vector<int> learn = fetch_vec<int>(M);
        v.push_back({c, learn});
    }


    vector<int> knowledge(M, X);
    int minCost = std::numeric_limits<int>::max();
    rec(v, 0, 0, knowledge, minCost);

    if (minCost != std::numeric_limits<int>::max())
        return minCost;

    return -1;
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 3632
import heapq
INFTY = 10**6
N,M = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
Arc = {}
for _ in range(M):
    a,b,c = map(int,input().split())
    G[a].append((b,c))
    G[b].append((a,c))
    Arc[(a,b)]=0
    Arc[(b,a)]=0
for s in range(1,N+1):
    dist = [INFTY for _ in range(N+1)]
    dist[s] = 0
    hist = [0 for _ in range(N+1)]
    heap = [(0,s)]
    pre = {}
    while heap:
        d,x = heapq.heappop(heap)
        if dist[x]<d:continue
        hist[x] = 1
        for y,e in G[x]:
            if hist[y]==0 and dist[y]>d+e:
                dist[y] = d+e
                pre[y] = x
                heapq.heappush(heap,(d+e,y))
    for j in pre:
        a = j
        while pre[a]!=s:
            b = pre[a]
            Arc[(a,b)] = 1
            Arc[(b,a)] = 1
            a = b
        Arc[(a,s)] = 1
        Arc[(s,a)] = 1
cnt = 0
for x in Arc:
    if Arc[x]==0:
        cnt += 1
print(cnt//2)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n-8) cout << s[i];
    cout << endl;
    

    return 0;
}



Measured memory_bytes: 256
def call(n):
    print "",
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print str(i),
            i += 1
            continue

        while x:
            if x % 10 == 3:
                print str(i),
                break
            x /= 10
            
        i += 1
        
    print

n = int(raw_input())
call(n)

Measured memory_bytes: 4208
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dp[5001];
bool able[5001];

void init(){
	vector<int> item;
	item.push_back(200);
	item.push_back(300);
	item.push_back(500);
	item.push_back(1000);
	item.push_back(1200);
	item.push_back(1500);
	vector<int> price;
	price.push_back(380);
	price.push_back(550);
	price.push_back(850);
	price.push_back( 1520 );
	price.push_back( 1870 );
	price.push_back( 2244 );
	rep(i,5001)dp[i]=(1<<20);
	able[0]=true;
	dp[0]=0;
	for(int k=0;k<item.size();k++){	
		for(int i=0;i+item[k]<=5000;i++){
			able[i+item[k]] = able[i+item[k]] | able[i];
			if(able[i+item[k]]){
				dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
			}
		}
	}
	return;
}

int main(){
	init();
	int n;
	int mi;
	while(cin >> n && n){
		/*mi = 1<<21;
		for(int i=n;i<=5000;i++){
			mi = min(dp[i],mi);
		}*/	
		cout << dp[n] << endl;
	}
}	

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A,B,K; cin>>A>>B>>K;
    int count=0;
    int N=min(A,B);
    for(int i=N;i>=0;i--){
        if(A%i==0&&B%i==0){
            count++;
            if(count==K){
                cout<<i;
                return 0;
            }
        }
    }

    return 0;
}

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

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    ll i;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    ll dp[n];
    dp[0]=0;
    for(i=1;i<n;i++){
        if(i-1>=0){
            dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        }
        if(i-2>=0){
            dp[i]=min(dp[i], dp[i-2]+abs(a[i-2]-a[i]));

        }
    }
    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  REP(i, k+1)
  {
    REP(j, k+1)
    {
      int z = s - i - j;
      if (z >= 0 && z <= k)
        count++;
    }
  }

  cout << count << "\n";

  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,i;cin>>n>>i;
  P(n-i+1);
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(void){
    // Your code here!
    int N, a[100],j,magic=0;
    scanf("%d",&N);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&a[i]);
    }
    
    for(int i = 0; i < N-1; i++)
    {
        if(a[i] == a[i+1])
        {
            j = 0;
            while(a[i+j]==a[i+j+1]) j++;
            magic += (j+1)/2;
            i += j;
        }
    }
    
    printf("%d\n",magic);
}

Measured memory_bytes: 128
alp = list("abcdefghijklmnopqrstuvwxyz")
s=input()
n=len(s)
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif n<26:
    for i in alp:
        if i not in s:
            print(s+i)
            break
else:
    for i in range(len(s)-1,-1,-1):
        for j in range(ord(s[i])+1,ord('z')+1):
            if chr(j) not in s[:i]:
                print(s[:i]+chr(j))
                exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n);++i)
#define rep2(i,n,m) for(int i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 string s ;
 cin>> s ;
 if(s=="ABC")
 cout << "ARC" <<endl; 
 
else
  cout <<"ABC"<<endl ; 
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    ll x, y;
    cin >> x >> y;

    if (abs(x-y) <= 1LL) {
        cout << "Brown\n";
    } else {
        cout << "Alice\n";
    }

    return 0;
}

Measured memory_bytes: 256