akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const int MAXN = 52;
const int MAXS = 2502;
lint dp[MAXN][MAXN][MAXS];

VEC(int) A;
lint f(int i, int count, int sum)
{
    if (i == A.size())
        return count == 0 && sum == 0 ? 1 : 0;

    lint& ans = dp[i][count][sum];
    if (ans >= 0)
        return ans;

    ans = f(i + 1, count, sum);
    if (count >= 1 && sum >= A[i])
        ans += f(i + 1, count - 1, sum - A[i]);
    return ans;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, avg;
    cin >> N >> avg;
    A.resize(N);
    READVEC(A);

    memset(dp, -1, sizeof dp);
    lint ret = 0;
    FOR(i, 1, A.size() + 1)
        ret += f(0, i, avg * i);
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 53120
MOD = 10**9 + 7
L = input()
n = len(L)
dp1 = [0] * (n+1)   # == L の組み合わせ
dp2 = [0] * (n+1)   #  < L の組み合わせ
dp1[0] = 1

for i in range(n):
    if L[i] == '1':
        dp1[i+1] = (dp1[i] * 2) % MOD
        dp2[i+1] = (dp1[i] + dp2[i] * 3) % MOD
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i] * 3) % MOD
print((dp1[n] + dp2[n])%MOD)


Measured memory_bytes: 11124
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

const int maxN = 100005;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

class TaskC {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int n;
		cin >> n;
		set<string> all;
		for(int i = 0; i < n; i++){
			string s;
			cin >> s;
			all.insert(s);
		}
		cout << all.size() << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskC solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 19288
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    int m=max(max(a,b),c);
    if((3*m)%2!=(a+b+c)%2)m+=1;
    int ans=(3*m-(a+b+c))/2;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    	
    ll k, x;
    cin >> k >> x;
    if (k * 500 >= x) cout << "Yes\n";
    else cout << "No\n";
}



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

int main() {
  	std::ios::sync_with_stdio(false);
  
    int N, Q;
    std::string S;
    std::cin >> N >> Q >> S;

    std::vector<int> cnt(N + 1, 0);
    for (int i = 2; i <= N; ++i) {
        cnt[i] = cnt[i - 1];
        if (S.substr(i - 2, 2) == "AC") ++cnt[i];
    }

    for (int q = 0; q < Q; ++q) {
        int l, r;
        std::cin >> l >> r;
        std::cout << cnt[r] - cnt[l] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 1488
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

char judge(char C, int c){

	  if(C == '1'){
	     if(c % 5 == 1){
	       return '.';
	   } else if(c % 5 == 2){
	     return ',';
	     } else if(c % 5 == 3){
	       return '!';
	   } else if(c % 5 == 4){
	     return '?';
	      } else if(c % 5 == 0){
	       return ' ';
	    }
	 } else if(C == '2'){
	   if(c % 3 == 1){
	    return 'a';
	     } else if(c % 3 == 2){
		   return 'b';
		    } else if(c % 3 == 0){
		    return 'c';
	   }
	  } else if(C == '3'){
      if(c % 3 == 1){
       return 'd';
    } else if(c % 3 == 2){
      return 'e';
      } else if(c % 3 == 0){
       return 'f';
    }
    } else if(C == '4'){
    if(c % 3 == 1){
     return 'g';
     } else if(c % 3 == 2){
       return 'h';
    } else if(c % 3 == 0){
     return 'i';
      }
  } else if(C == '5'){
      if(c % 3 == 1){
      return 'j';
   } else if(c % 3 == 2){
      return 'k';
      } else if(c % 3 == 0){
      return 'l';
    }
    } else if(C == '6'){
    if(c % 3 == 1){
      return 'm';
     } else if(c % 3 == 2){
        return 'n';
    } else if(c % 3 == 0){
      return 'o';
      }
	  } else if(C == '7'){
      if(c % 4 == 1){
        return 'p';
    } else if(c % 4 == 2){
		return 'q';
      } else if(c % 4 == 3){
       return 'r';
    } else if(c % 4 == 0){
      return 's';
      }
    } else if(C == '8'){
	 if(c % 3 == 1){
	     return 't';
	     } else if(c % 3 == 2){
	      return 'u';
	    } else if(c % 3 == 0){
	      return 'v';
	      }
	  } else if(C == '9'){
	    if(c % 4 == 1){
	        return 'w';
	    } else if(c % 4 == 2){
	      return 'x';
	      } else if(c % 4 == 3){
	       return 'y';
	    } else if(c % 4 == 0){
	      return 'z';
				      }
	  }

}


int main(void) {
	int n, c, count = 0, i = 0;
	char st[2], str[77], nowc;

	cin.tie(0);

	cin >> n;
	fgets(st, 2, stdin);

	for (int k = 0; k < n; k++) {
		while ((c = getchar()) != '\n') {

			if (count == 0 && c == '0') {
				continue;
			} else if (count == 0 && c != '0') {
				nowc = (char)c;
				count++;
			} else if (count != 0 && c == '0') {
				str[i++] = judge(nowc, count);
				count = 0;
			} else if (count != 0 && c != 0) {
				count++;
			}
		}
		str[i] = '\0';
		if (i != 0) cout << str << "\n";
		strcpy(str, "");
		count = 0;
		i = 0;
	}

	return 0;
}

Measured memory_bytes: 1132
// 2011/07/24 Tazoe

#include <iostream>
using namespace std;

void trn(int n)
{
	if(n==0)
		return;

	int a = n%(-10);
	if(a<0)
		a = 10+a;

	trn((n-a)/(-10));

	cout << a;
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		trn(n);
		cout << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

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

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

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

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

  ll N, M;
  IN(N,M);
  vll H(N);
  REP(i,N) IN(H[i]);
  vvll Graph(N);
  REP(i,M){
    ll A, B;
    IN(A,B);
    A--; B--;
    Graph[A].pb(B);
    Graph[B].pb(A);
  }

  ll ans = 0;
  REP(i,N){
    bool flag = true;
    REP(j,Graph[i].size()){
      if(H[i]<=H[Graph[i][j]]){
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 9800
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define frd(x) freopen("x","r",stdin)
#define fwt(x) freopen("x","w",stdout)
#define fo(i,a) for(int i=1;i<=(a.n);i++)
#define fup(i,x,y) for(int i=(x);i<=(y);i++)
#define fdn(i,x,y) for(int i=(x);i>=(y);i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
    char a[20];
    scanf("%s",a+1);
    a[4]='8';
    printf("%s\n",a+1);
    return 0;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

lli parent[100001]; // parent[i]: i が含まれる木の根の番号
lli depth[100001];  // depth[i] : i は自身が含まれる木のどれくらいの深さにいるか(最低1) ただし、根の depth のみが参照される
lli counts[100001];

void init(lli n) {
    REPE(i, 1, n) {
        parent[i] = i;
        depth[i] = 1;
        counts[i] = 1;
    }
}

lli find(lli x) {
    if (parent[x] == x)
        return x;
    else
        return parent[x] = find(parent[x]);
}

void unite(lli x, lli y) {
    lli x_root = find(x);
    lli y_root = find(y);
    if (x_root == y_root)
        return;

    if (depth[x_root] < depth[y_root]) {
        parent[x_root] = y_root;
        counts[y_root] += counts[x_root];
        counts[x_root] = 0;
    }
    else {
        parent[y_root] = x_root;
        counts[x_root] += counts[y_root];
        counts[y_root] = 0;
        if (depth[x_root] == depth[y_root])
            depth[x_root]++;
    }
}

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


int main() {
    lli n, m;
    cin2(n, m);
    lli a[m];
    lli b[m];
    ncin2(m, a, b);

    init(n);
    lli ans[m] = {0};
    for (lli i = m-1; i >= 0; i--) {
        lli a_root = find(a[i]);
        lli b_root = find(b[i]);
        if (a_root == b_root) {
            ans[i] = 0;
            continue;
        }
        ans[i] = counts[a_root] * counts[b_root];
        unite(a[i], b[i]);
    }
    lli x = 0;
    REP(i, 0, m) {
        x += ans[i];
        cout << x << endl;
    }
}


Measured memory_bytes: 7040
public class Main {

	public void doIt(){
		for(int i=1; i <= 9; i++){
			for(int j=1; j <= 9; j++){
				System.out.println(i + "x" + j + "=" + i*j);
			}
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

main(){

int count=0;
    int n,k,s;//long,total,sum
    cin >> n>>k>>s;
    for(int i=0;i<n;i++){
        //output
        if(count >=k){
            if(s==1000000000){
                cout<<s-2;
            }else{
            cout<<s+1;
            }
        }else if(s!=1){
           
   
                count++;
                cout<<s;
            }
        else{
            if (count >= k){
                
                cout << 6;
                
            }else{
                cout << 1;
                count++;
            }
        }

        if(i <n-1){
            cout<<" ";
        }
    }

    
}


Measured memory_bytes: 1280
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int[] T = new int[n];
        int[] A = new int[n];
        for (int i = 0; i < n; i++) {
            T[i] = sc.nextInt();
            A[i] = sc.nextInt();
        }
        long t=1,a=1;
        for (int i = 0; i < n; i++) {
            long k = max(ceil(a, A[i]), ceil(t, T[i]));
            t = k*T[i];
            a = k*A[i];
           // out.println(k+" "+t+" "+a);
        }
        out.println(a+t);
    }
    static long ceil(long a,long b){
        return a%b==0?a/b:a/b+1;
    }
}

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

long long N, M, K;
long long A[200005];
long long B[200005];

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

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

	for(long long i = 0; i < M; i++) {
		cin >> B[i];
	}


	long long ans = 0;
	long long aidx = 0;
	long long bidx = 0;
	long long cursum = 0;

	while(aidx < N && cursum + A[aidx] <= K){
		cursum += A[aidx];
		aidx++;
	}

	while(bidx < M && cursum + B[bidx] <= K) {
		cursum += B[bidx];
		bidx++;
	}

	ans = aidx + bidx;


	while(aidx > 0 && bidx < M) {
		aidx--;
		cursum -= A[aidx];

		while(bidx < M && cursum + B[bidx] <= K) {
			cursum += B[bidx];
			bidx++;
		}
		//cout << "aidx = " << aidx << " bidx = " << bidx << " cursum = " << cursum << endl;
		ans = max(ans, aidx + bidx);
	}
	cout << ans << endl;






}

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn = 100000;
int a[maxn + 1];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;
    for(int i = 1; i <= N; i += 1) cin >> a[i];
    sort(a + 1, a + N + 1, greater<int>());
    for(int i = 1; i <= N; i += 1) if(i == N or i >= a[i + 1]){
        int k = i;
        while(k + 1 <= N and a[k + 1] == i) k += 1;
        cout << ((k - i) % 2 == 0 and (a[i] - i) % 2 == 0 ? "Second" : "First");
        return 0;
    }
    return 0;
}

Measured memory_bytes: 640
with Ada.Text_IO, Ada.Integer_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO;

procedure main is
   S: Integer;
   W: Integer;
begin
   get(S);
   get(W);
   if (W >= S) then put_line("unsafe");
   else put_line("safe");
   end if;
end main;

Measured memory_bytes: 3644
import itertools

N, M, K = map(int, input().split())
a = list(input().split())
b = list(input().split())
A = list(itertools.accumulate([int(a[i]) for i in range(N)]))
B = list(itertools.accumulate([int(b[i]) for i in range(M)]))

count = 0
tmp = K

for i in range(N+1):
    low = 0
    high = M - 1
    while low <= high:
        mid = int((low + high) // 2)
        guess = B[mid]
        if low == high or guess == tmp:
            break
        elif guess > tmp:
            high = mid - 1
        else:
            low = mid + 1
    count = max(count, (i+mid+1 if B[mid] <= tmp else i+mid))
    if i == N:
        break
    else:
        tmp = K - A[i]
        if tmp < 0:
            break

print(count)

Measured memory_bytes: 68328
N, K = map(int, input().split())
x = list(map(int, input().split()))
m = 10000000000000
for i in range(N-K+1):
  x1 = x[i]
  xk = x[i+K-1]
  if x1*xk <= 0: # 区間に0を含む時
    m = min(m, 2*abs(x1)+xk, abs(x1)+2*xk)
  elif x1>0:
    m = min(m, xk)
  else:
    m = min(m, abs(x1))
print(m)

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

int main(){

  long long N, i, md=1000000007;
  cin>>N;
  vector<long long> A(N);
  A[0]=0; A[1]=0; A[2]=1;
  for(i=3; i<N; i++){
    A[i]=(A[i-3]+A[i-1])%md;
    }
  cout<<A[N-1]%md<<endl;
  return 0;
}

Measured memory_bytes: 3600
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,res=0,i=1; 
    cin>>n;
    while (i<=n){
        res=i;
        i*=2;
    }
    cout << res << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3584
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[][] ques = new int[q][2];
		for (int i = 0; i < q; i++) {
			ques[i] = new int[] { sc.nextInt(), sc.nextInt() };
		}
		sc.close();

		// 累積和
		int[] ruiseki = new int[n];
		String flag = "C";
		for (int i = 0; i < n; i++) {
			switch (flag) {
			case "A":
				if (String.valueOf(s.charAt(i)).equals("C")) {
					ruiseki[i] = ruiseki[i - 1] + 1;
					flag = "C";
				} else if (String.valueOf(s.charAt(i)).equals("A")) {
					flag = "A";
					ruiseki[i] = ruiseki[i - 1];
				} else {
					ruiseki[i] = ruiseki[i - 1];
					flag = "C";
				}
				break;
			case "C":
				if (String.valueOf(s.charAt(i)).equals("A")) {
					flag = "A";
				}
				if (i != 0)
					ruiseki[i] = ruiseki[i - 1];
				break;
			}
			// デバッグ
			// System.out.println(ruiseki[i]);
			// replaceのオーダーがO(|S|)なので死
			// ruiseki[i - 1] = (tmp.length() - tmp.replaceAll("AC", "").length()) / 2;
		}

		for (int i = 0; i < q; i++) {
			System.out.println(ruiseki[ques[i][1] - 1] - ruiseki[ques[i][0] - 1]);
		}
	}
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int r;
    in(r);
    out(3 * r * r);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int vis[1000010],a[200010],in[1000010];
int main(){
	int n,i,j,cnt,mn=1000010,mx=0,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),vis[a[i]]++,in[a[i]]=1,mn=min(mn,a[i]),mx=max(mx,a[i]);
	for(i=1;i<=n;i++){
		cnt=1;
		while(1){
			cnt++;
			if(a[i]*cnt>mx)break;
			vis[a[i]*cnt]++;
		}
	}
	for(i=mn;i<=mx;i++)
		if(in[i]==1&&vis[i]==1)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11644
#include <stdio.h>

int main(){
	int N, x, preva = 0, nexta, i;
	long long int ans = 0;
	scanf("%d%d", &N, &x);
	for(i = 0; i < N; i++){
		scanf("%d", &nexta);
		if(x < preva + nexta){
			ans += preva + nexta - x;
			nexta = x - preva;
		}
		preva = nexta;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

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

using namespace std;

typedef long long ll;

ll n, m;
bool a[100001];
ll dp[100001];

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

    fill(dp, dp + 100001, 0);
    fill(a, a + 100001, true);
    
    cin >> n >> m;
    
    ll tmp = 0;
    REP(i, m) {
        cin >> tmp;
        a[tmp] = false;
    }
    
    if (a[1] && a[2]) {
        dp[1] = 1;
        dp[2] = 2;
    } else if (a[1] && !a[2]) {
        dp[1] = 1;
        dp[2] = 0;
    } else if (!a[1] && a[2]) {
        dp[1] = 0;
        dp[2] = 1;
    } else {
        cout << 0 << endl;
        return 0;
    }
    
    FOR(i, 3, n + 1) {
        if (a[i - 1] && a[i - 2]) {
            dp[i] = dp[i - 1] + dp[i - 2];
        } else if (a[i - 1] && !a[i - 2]) {
            dp[i] = dp[i - 1];
        } else if (!a[i - 1] && a[i - 2]) {
            dp[i] = dp[i - 2];
        } else {
            cout << 0 << endl;
            return 0;
        }
        dp[i] %= 1000000007;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1152
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int n=s.size(),l=-1,r=-1;

        for(int i=0; i<n; i++)
        {
            int idx=i+1;
            if(i<n-1 && s[i]==s[i+1])
            {
                l=idx;
                r=idx+1;
                break;
            }
            if(i<n-2 && s[i]==s[i+2])
            {
                l=idx;
                r=idx+2;
                break;
            }
        }
        cout<<l<<" "<<r<<endl;
    }
    return 0;
}



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

int main() {
  int H,W;
  cin>>H>>W;
  char data[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>data[i][j];
    }
  }

  for(int i=0;i<H;i++){
    for(int k=0;k<2;k++){
      for(int j=0;j<W;j++){
        cout<<data[i][j];
      }
    cout<<endl;
    }
  }



}


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

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct edge
{
	int s, t, w;
	edge(int s, int t, int w) :s(s), w(w), t(t) {}
	edge() { s = -1, w = -1, t = -1; }
};

int land[203][203], sea[203][203];
int order[1003];
int dp[1003][203];

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

	int N, M,R, x, y, t,z;
	char s;
	while (true)
	{
		cin >> N >> M;
		if (N + M == 0)
		{
			break;
		}
		rep(i, 0, N)rep(j, 0, N)if (i != j)land[i][j] = INF, sea[i][j] = INF;
		rep(i, 0, M)
		{
			cin >> x >> y >> t >> s;
			x--, y--;
			if (s == 'L')
			{
				chmin(land[x][y], t);
				land[y][x] = land[x][y];
			}
			else
			{
				chmin(sea[x][y], t);
				sea[y][x] = sea[x][y];
			}
		}

		cin >> R;
		rep(i, 0, R)
		{
			cin >> z;
			order[i] = z - 1;
		}

		rep(k, 0, N)rep(i, 0, N)rep(j, 0, N)
		{
			if (land[i][k] != INF&&land[k][j] != INF)chmin(land[i][j], land[i][k] + land[k][j]);
			if (sea[i][k] != INF&&sea[k][j] != INF)chmin(sea[i][j], sea[i][k] + sea[k][j]);
		}

		rep(i, 0, R)rep(j, 0, N)dp[i][j] = INF;
		dp[0][order[0]] = 0;

		rep(i, 0, R - 1)
		{
			rep(j, 0, N)
			{
				if (dp[i][j] == INF)
				{
					continue;
				}
				chmin(dp[i + 1][j], dp[i][j] + land[order[i]][order[i + 1]]);
				rep(k, 0, N)
				{
					chmin(dp[i + 1][k], dp[i][j] + land[order[i]][j] + sea[j][k] + land[k][order[i + 1]]);
				}
			}
		}

		int ans = INF;
		rep(i, 0, N)
		{
			chmin(ans, dp[R - 1][i]);
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 5436
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <stack>

using namespace std;


//エラトステネスの篩
int main(){
  int n;

  while(1){
    cin >> n;
    if(n==0) break;

    int count = 0;
    bool s[2*n+1];
    int era;

    for(int i=2; i<2*n+1 ; i++){
      s[i] = true;
    }

    for(int i=2 ; i*i<=(2*n+1) ; i++){
      if(s[i] != false){
        era = i;
        for(int j=2 ; (j*era)<(2*n+1) ; j++){
          s[j*era] = false;
        }
      }
    }

    for(int i=n+1 ; i<2*n+1 ; i++){
      if(s[i] == true) count++;
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 1396
from collections import deque
from itertools import count

X, Y, A, B, C = map(int, input().split())
P = [int(n) for n in input().split()]
Q = [int(n) for n in input().split()]
R = [int(n) for n in input().split()]


P.sort()
Q.sort()
R.sort(reverse=True)

P = deque(P[-X:])
Q = deque(Q[-Y:])
R = deque(R)

for i in count():
    if not R or P[0] >= R[0] <= Q[0]:
        break
    if R[0] >= P[0] <= Q[0]:
        P.append(R.popleft())
        P.popleft()
    elif R[0] >= Q[0] <= P[0]:
        Q.append(R.popleft())
        Q.popleft()

print(sum(P) + sum(Q))

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

typedef long long ll;

int main(void) {
	int N, D;
	cin >> N >> D;
	ll d2 = (ll)D * D;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int X, Y;
		cin >> X >> Y;
		ll L2 = (ll)X * X + (ll)Y * Y;
		if (L2 <= d2)
			++ans;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    int n,k;
    cin>>n>>k;
    vi v(n);
    Forr(i,v)cin>>i;
    sort(all(v));
    ll ans=0;
    for (int i = 0; i < k; ++i) {
        ans+=v[i];
    }
    cout<<ans;

}

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

int main(){
    int n;
    cin >> n;
    int l[n];
    for(int i = 0; i < n; i++) cin >> l[i];
    std::sort(l, l+n, std::greater<int>());
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] >= l[j] + l[k]) break;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>

using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int N, M;
int A[1010];
int C[1010];

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    cin >> N >> M;
    rep(i,M){
        int b; cin >> A[i] >> b;
        int c,k; k = 0;
        rep(j,b){
            cin >> c;
            k |= (1 << (c-1));
        }
        C[i] = k;
    }

    vi dp(1<<N, INF);
    dp[0] = 0;
    rep(i,M) rep(j,1<<N){
        int k = j | C[i];
        dp[k] = min(dp[k], dp[j] + A[i]);
    }

    if(dp[(1<<N)-1] == INF) cout << -1 << endl;
    else cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>

int main(void){
  int input;

  std::stack<int> st;

  while(std::cin >> input ){
    if(input != 0){
      st.push(input);
    }
    else{
      std::cout << st.top()<<std::endl;
      st.pop();
    }
  }

  return 0;
}



Measured memory_bytes: 3020
#include <stdio.h>

void shellSort(int *A, int n);
int insertionSort(int *A, int n, int g);

int main() {
    int n;
    scanf("%d", &n);
    int A[n];
    for (int i=0; i<n; i++) {
        scanf("%d", &A[i]);
    }
    
    shellSort(A, n);
    
    for (int j=0; j<n; j++) {
        printf("%d\n", A[j]);
    }
    
    return 0;
}

void shellSort(int *A, int n) {
    int cnt = 0;
    int m = 1;
    int temp = 1;       // interval (1, 4, 13, 40, 121, …)
    while (temp * 3 + 1 < n) {
        temp = temp * 3 + 1;
        m++;
    }
    int G[m];
    for (int i=0; i<m; i++) {
        G[i] = temp;
        temp = (temp - 1) / 3;
    }
    
    for (int j=0; j<m; j++) {
        cnt += insertionSort(A, n, G[j]);
    }
    
    printf("%d\n", m);
    for (int k=0; k<m; k++) {
        printf("%d", G[k]);
        if (k == m - 1) {
            putchar('\n');
        } else {
            putchar(' ');
        }
    }
    printf("%d\n", cnt);
    return;
}

int insertionSort(int *A, int n, int g) {
    int cnt = 0;
    for (int i=g; i<n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
    
    return cnt;
}




Measured memory_bytes: 5708
figs = []

8.times.each do
  figs.push gets.strip.split('')
end

deg = 90

3.times.each do
  figs1 = 8.times.map{[]}

  for y in (0..7)
    for x in (0..7)
      figs1[y][x] = figs[7 - x][y]
    end
  end

  puts deg
  figs1.each{|hl| puts hl.join('')}

  deg += 90
  figs = figs1
end

Measured memory_bytes: 6128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<string> v(N);
		for(string& s : v) cin >> s;
		int res = -1;
		int allB = 0;
		for(int i=0;i<N;i++){
			bool ok = true;
			for(int j=0;j<N;j++){
				if(v[j][i] == '.') ok = false;
			}
			if(ok) ++allB;
		}
		if(allB == N){
			cout << 0 << endl;
			continue;
		}
		for(int i=0;i<N;i++){
			int w = 0;
			for(int j=0;j<N;j++) if(v[i][j] == '.') ++w;
			int cur = -1;
			if(v[i][i] == '#'){
				cur = w+N-allB;
			} else {
				bool find = false;
				for(int j=0;j<N;j++){
					if(v[j][i] == '#') find = true;
				}
				cur = w+N-allB+(find?0:1);
			}
			if(res==-1 || cur < res) res = cur;
		}
		if(res > 2*N) res = -1;
		cout << res << endl;
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

int n, k, i, x;

void solve() {
    int ans = n;
    int i, aux;

    for (i = max(1, x - k + 1); i <= min(n - k + 1, x); i++) {
        aux = (i - 1 + k - 2) / (k - 1);
        aux += (n - i - k + 1 + k - 2) / (k - 1);
        ans = min(ans, aux + 1);
    }

    printf("%d", ans);
}

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d%d", &n, &k);
    for (i = 1; i <= n; i++) {
        scanf("%d", &x);
        if (x != 1) continue;
        x = i;
        solve();
        return 0;
    }


    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
absa = list(map(abs, a))

minus = sum(x < -1 for x in a) % 2
plus = sum(abs(x) for x in a)
mina = min(absa)

if minus == 0:
  print(plus)
else:
  print(plus - mina * 2)


Measured memory_bytes: 14412
X_hiki, Y_hon = map(int, input().split())
 
ans = 'No'
 
for i in range(X_hiki + 1):
    hon = 2 * i + 4 * (X_hiki - i)
    
    if (hon == Y_hon):
        ans = 'Yes'
        break
 
print(ans)

Measured memory_bytes: 9176
N, M =map(int, input().split())
list1 = []
cost = 0
for i in range(N):
  A, B = map(int, input().split())
  list1.append((A, B))
list2 = sorted(list1, key= lambda x:x[0])
for i in range(N):
  if M >= list2[i][1]:
    M -= list2[i][1]
    cost += list2[i][0] * list2[i][1]
  else:
    break
cost += list2[i][0] * M
print(cost)

Measured memory_bytes: 24564
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int a, b; cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int i;
  int n;
  int m;
  int a;
  scanf("%d%d",&n, &m);
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    n -= a;
  }
  if (n < -1)
    n=-1;
  printf("%d",n);
}

Measured memory_bytes: 1724
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
	IOS;
	int64 T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i;
		cin>>n;
		int64 arr[n+1];
		int64 a[n];
		for(i=1;i<n;i++)
			cin>>a[i];
		arr[0]=arr[1]=a[1];
		for(i=2;i<n;i++)
		{
			arr[i]=a[i];
			arr[i-1]=min(arr[i-1],a[i]);
		}
		int64 ans=0;
		for(i=0;i<n;i++)
			ans+=arr[i];
		cout<<ans;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int k, t;
ll a[105], maxi=0;
int main()
{
    int i;
    cin>>k>>t;
    for(i=1; i<=t; i++)cin>>a[i];
    maxi=a[1];
    for(i=2; i<=t; i++)
        maxi=max(maxi, a[i]);
    if(maxi> (k+1)/2){
        cout<<(k- (2*(k-maxi)+1));
    }
    else
        cout<<0;
    return 0;
}



Measured memory_bytes: 256
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
from heapq import heappush,heappop
ans=[]
data=[(-A[-1]-B[-1]-C[-1],X-1,Y-1,Z-1)]
visited={(X-1,Y-1,Z-1)}
while len(ans)<K:
    now=heappop(data)
    ans.append(-1*now[0])
    if now[1]>0 and (now[1]-1,now[2],now[3]) not in visited:
        nex=now[0]+A[now[1]]-A[now[1]-1]
        heappush(data,(nex,now[1]-1,now[2],now[3]))
        visited|={(now[1]-1,now[2],now[3])}
    if now[2]>0 and (now[1],now[2]-1,now[3]) not in visited:
        nex=now[0]+B[now[2]]-B[now[2]-1]
        heappush(data,(nex,now[1],now[2]-1,now[3]))
        visited|={(now[1],now[2]-1,now[3])}
    if now[3]>0 and (now[1],now[2],now[3]-1) not in visited:
        nex=now[0]+C[now[3]]-C[now[3]-1]
        heappush(data,(nex,now[1],now[2],now[3]-1))
        visited|={(now[1],now[2],now[3]-1)}
for i in range(K):
    print(ans[i])

Measured memory_bytes: 5228
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
#include <typeinfo>
#include <cstdlib>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()



int main() {
    ll N; scanf("%lld",&N);
    ll A,B,C; scanf("%lld%lld%lld",&A,&B,&C);
    ll L[N]; rep(i,N) scanf("%lld",&L[i]);
    ll ctr[3];
    ll score=1000000000000;
    for (ctr[0] = 1; ctr[0] < (1<<N); ctr[0]++){
        for (ctr[1] = 1; ctr[1] < (1<<N); ctr[1]++){
            if (ctr[0] & ctr[1]) continue;
            for (ctr[2] = 1; ctr[2] < (1<<N); ctr[2]++){
                if (ctr[2] & ctr[0]) continue;
                if (ctr[2] & ctr[1]) continue;
                ll preA=0,preB=0,preC=0;
                ll numA=0,numB=0,numC=0;
                rep(i,N){
                    if(ctr[0] & (1<<i)) {
                        preA += L[i];
                        numA ++;
                    }
                }
                rep(i,N){
                    if(ctr[1] & (1<<i)) {
                        preB += L[i];
                        numB ++;
                    }
                }
                rep(i,N){
                    if(ctr[2] & (1<<i)) {
                        preC += L[i];
                        numC ++;
                    }
                }
               
                score = min(score,(abs(A-preA)+abs(B-preB)+abs(C-preC)+10*(numA+numB+numC-3)));
            }
        }
    }
    cout << score << endl;
    return 0;
}
    
   



Measured memory_bytes: 256
#include <stdio.h>
void maxHeapify(int);
int A[2000001], H;

int main(){
        int i;
        scanf("%d", &H);
        for(i = 1; i<=H; i++) {
                scanf("%d", &A[i]);
        }

        for(i = H/2; i>=1; i--) {
                maxHeapify(i);
        }
        for(i = 1; i<=H; i++) {
                printf(" %d", A[i]);
        }
        printf("\n");
        return 0;
}

void maxHeapify(i){
        int l, r, largest, tmp = 0;
        l = 2 * i;
        r = 2 * i + 1;
        if(l <= H && A[l]>A[i]) {
                largest = l;
        }
        else {largest = i;}
        if(r <= H && A[r] > A[largest]) {
                largest = r;
        }

        if(largest != i) {
                tmp = A[largest];
                A[largest] = A[i];
                A[i] = tmp;
                maxHeapify(largest);
        }
}

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

using namespace std;

main(){
  int n;
  cin>>n;
  unordered_map<int,int> value;
  for(int i=0;i<n;i++){
    int z;
    cin>>z;
    value[z]++;
  }
  int remove=0;
  for(auto z=value.begin();z!=value.end();z++){
    if(z->first!=z->second){
    	if(z->first<z->second){
    		remove=remove+(z->second-z->first);
    	}else{
    		remove=remove+(z->second);
    	}
    }
  }
  cout<<remove;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> s;
    t = "CODEFESTIVAL2016";
    x = 0;
    for(int i = 0; i < 16; ++i){
        x += (s[i] != t[i]);
    }
    cout << x << endl;
}


Measured memory_bytes: 256