akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int m;cin>>m;
  vector<int>res(n+1);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    res[a]++;
    res[b]++;
  }
  rep(i,n)cout<<res[i+1]<<endl;

  return 0;

}


Measured memory_bytes: 256
// Aizu Vol0 0045: Sum and Average
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int m, n;
	int total, sum, no, ave, r;

	total = sum = no = 0;
	while (scanf("%d,%d", &m, &n) == 2) {
		total += m * n;
		no++;
		sum += n;
	}
	if (no == 0) puts("0\n0");
	else {
		ave = sum / no;
		r = sum % no;
		if (no & 1) {
			if (r > (no/2)) ave++;
		} else {
			if (r >= (no/2)) ave++;
		}
		printf("%d\n%d\n", total, ave);
	}
	return 0;
}

Measured memory_bytes: 592
N, K = input().split()
D = set(map(int,input().split()))

C = list({0,1,2,3,4,5,6,7,8,9}-D)
C.sort()
num = len(N)

def minimum(x,ans):
    ans += str(min(C))*x
    return ans

ans = ''
if C[-1]<int(N[0]):
    C_0 = list(set(C)-{0})
    ans += str(min(C_0))
    ans = minimum(num,ans)
    print(ans)
    exit()

points = 0
for i in range(0,num):
    minus = 0
    for j in range(len(C)):
        if C[j]==int(N[i]):
            ans += str(C[j])
            points += 1
            break
        elif C[j]>=int(N[i]):
            ans += str(C[j])
            ans = minimum(num-i-1,ans)
            print(int(ans))
            exit()
            points = 0
        else:
            minus += 1
    if points == i and minus == len(C):
        ans = ''
        C_0 = list(set(C)-{0})
        ans += str(min(C_0))
        ans = minimum(num,ans)
        print(ans)
        exit()

print(ans)


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

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

	string S;
	cin >> S;

	vector<int> Nums;

	int now = 1;
	int cnt = 0;
	for (auto& c : S) {
		if (c == (char)('0' + now)) ++cnt;
		else
		{
			Nums.push_back(cnt);
			cnt = 1;
			now = 1 - now;
		}
	}
	if (cnt != 0) Nums.push_back(cnt);

	vector<int> Sums(Nums.size() + 1);
	for (int i = 0; i < Nums.size(); ++i) {
		Sums[i + 1] = Sums[i] + Nums[i];
	}

	int add = 2 * K + 1;
	int ans = 0;

	for (int i = 0; i < Nums.size(); i += 2) {
		int left = i;
		int right = min(i + add, (int)Sums.size() - 1);
		int tmp = Sums[right] - Sums[left];
		ans = max(ans, tmp);
	}

	cout << ans << endl;
}

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

int main(){
	ll a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(a<b){
		if(v*t>=w*t+b-a)cout<<"YES";
		else cout<<"NO";
	}
	else{
		if(v*t>=w*t-b+a)cout<<"YES";
		else cout<<"NO";
	}
	return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  vector<ll> a(n); cin >> a;
  sort(whole(a)); UNIQUE(a);
  if(sz(a) == n)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"


  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
	int x = 0;
	for(int i = 0; i<5; i++){
		int a;
		cin >> a;
		if(a == 0){
			x = i + 1;
		}
	}
	
	
	cout << x;
	
	
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    fast;
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    sum = sum + min(k, a);
    k = k - min(k, a);
    if(k != 0){
        sum = sum;
        k -= min(k, b);
    }
    if(k != 0){
        sum = sum - min(k, c);
        k = k - min(k, c);
    }
    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 3652
function Main(input) {
    var N = parseInt(input, 10);
    
    var ans = 0;

    for (var i = 1; i <= N; i++){
        if (i.toString().length % 2 == 1) {
            ans++;
        }
    }

  	//出力
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10944
from sys import stdin
input = stdin.readline

ans = 10 ** 10

N, M, X = map(int, input().strip().split())

C = []
A = [[]] * N

for i in range(N):
    tmp = list(map(int, input().strip().split()))
    C.append(tmp[0])
    A[i] = tmp[1:]

for i in range(2 ** N):
    tans = 0
    tA = [0] * M
    for j in range(N):
        if i & (1 << j):
            tans += C[j]
            for k in range(M):
                tA[k] += A[j][k]

    flag = True
    for k in range(M):
        flag &= (tA[k] >= X)

    #print(i, tA, tans)

    if flag:
        ans = min(ans, tans)

if ans == 10 ** 10:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define ll  long long
int main ()
{
   	ll a,b;
   	cin>>a>>b;
   	if (a>0&&b>0)
   		cout<<"Positive"<<endl;
   	if (a==0||b==0)
   		cout<<"Zero"<<endl;
   	if (a<0&&b>0)
   		cout<<"Zero"<<endl;
   	if (a<0&&b<0)
   	{
   		
		ll t=b-a;
		if (t%2==0)
			cout<<"Negative";
		else
			cout<<"Positive";
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  int i, j, k, n, p[100000];
  for(i = 0; i < 100000; ++i) p[i] = 1;
  for(i = 2; i < 300; ++i) if(p[i]){
    for(j = 2; i * j < 90000; ++j) p[i * j] = 0;
  }
  scanf("%d", &n);
  n--;
  printf("2");
  for(i = 11; i < 55556; i += 30) {
    if(p[i]) {
      printf(" %d", i);
      n--;
    }
    if(!n) break;
  }
  return 0;
}

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

int main()
{
	int x,y;
	cin>>x>>y;
	int cnt1,cnt2;
	cnt1=(y-2*x)/2;
	cnt2=x-cnt1;
	if(cnt1>=0&&cnt2>=0&&cnt1*4+cnt2*2==y)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    // INPUT
    int N = 0;
    cin >> N;
    vector<string> title(N);
    vector<int> play_time(N);
    for(int i=0; i<N; i++) cin >> title[i] >> play_time[i];
    string X;
    cin >> X;

    // SOURCE
    int sleeping_time = 0;
    bool is_he_asleep = 0;
    for(int i=0; i<N; i++) {
        if( is_he_asleep ) sleeping_time += play_time[i];
        if( title[i] == X ) is_he_asleep = 1;
    }

    // OUTPUT
    cout << sleeping_time << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader();
		int n = in.nextInt();
		int x = in.nextInt();
		
		int d = 0, res = 0;
		for (int i=0; i<n; i++) {
			int l = in.nextInt();
			d += l;
			if (d <= x)
				++res;
		}
		System.out.println(res+1);
	}
	
	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 22612
# cf. 16315733
N, M = list(map(int, input().split()))
# upperは、根なら-その木の長さを、枝ならその木の根の要素のインデックスを指す。
upper = [-1] * N
# xの根を返す
def root(x):
  # xが根なら
  if upper[x] < 0:
    return x
  # xが枝なら
  else:
    # 根のインデックスをさかのぼる
    upper[x] = root(upper[x])
    # 根のインデックスを返す
    return upper[x]

# x,yが同じグループにあるかどうか判定する
def equiv(x, y):
  return root(x) == root(y)

def unite(x, y):
  x, y = root(x), root(y)
  if x != y:
    if upper[y] < upper[x]:
      #xとyの値をスワップ、必ずupper[y] >= upper[x]とするつまりxのほうが高い
      x,y = y,x
    # 要素の数を足す：結合後の要素の数を求める
    upper[x] += upper[y]
    # yの根をxにする（木が高い方を根にする）
    upper[y] = x
  return x == y

for i in range(M):
  a, b = list(map(int, input().split()))
  unite(a-1, b-1)
print(-min(upper))

Measured memory_bytes: 14332
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << ab * bc / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
q,h,s,d=map(int,input().split())
N=int(input())
D=[q*8,h*4,s*2,d]
D.sort()
a=D[0]
S=[q*4,h*2,s]
S.sort()
b=S[0]
print((N//2)*a+(N-(N//2)*2)*b)

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define array_length(array) (sizeof(array) / sizeof(array[0]))
#define pb push_back

int main() {
  double fst, sec;
  cin >> fst;
  cin >> sec;
  double w_ave = (fst+sec)/2.0;
  int i_ave = (int)w_ave;
  if (((w_ave-i_ave) >= 0.5)) cout << i_ave+1 << endl;
  else cout << i_ave << endl;
  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>m>>s;
      vector<ll> g[ohara];
      map<ll,ll> a;
      map<ll,ll> b;
      queue<ll> que;
      map<ll,ll> out;
      rep(i,m){
        cin>>c>>d;
        c--;d--;
        g[c].push_back(d);
        g[d].push_back(c);
      }
      rep(i,n){
        rep(j,Size(g[i])){
          pos=g[i][j];
          if(s[pos]=='A')a[i]++;
          else b[i]++;
      }
      }
      rep(i,n){
        if(a[i]==0||b[i]==0)que.push(i),out[i]=1;
      }
      while(!que.empty()){
        ll v=que.front();que.pop();
        rep(i,Size(g[v])){
          pos=g[v][i];
          if(out[pos]==1)continue;
          if(s[v]=='A')a[pos]--;
          else b[pos]--;
          if(a[pos]==0||b[pos]==0){
            que.push(pos);
            out[pos]=1;
          }
        }
      }
      rep(i,n)if(out[i])cnt++;
      if(cnt==n)Cout("No");
      else Cout("Yes");
    
       
return 0;
}


Measured memory_bytes: 64720
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
const ll MAX = 210000;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  if(n < k)
    return 0;
  if(n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  COMinit();
  ll cnt = m, ans = 0;
  for(int i = 0; i < n - k - 1; i++) {
    cnt *= (m - 1);
    cnt %= MOD;
  }

  for(int i = k; i >= 0; i--) {
    ans += cnt * COM(n - 1, i) % MOD;
    ans %= MOD;
    cnt *= (m - 1);
    cnt %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8556
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> v;

  char pre = '\0';
  int cnt = 0;
  for (char c : s) {
    if (pre != c) {
      if (pre)
        v.push_back(cnt);
      pre = c;
      cnt = 1;
    } else {
      ++cnt;
    }
  }
  v.push_back(cnt);

  int j = 2 * k + 1;
  if (j >= v.size()) {
    cout << accumulate(v.begin(), v.end(), -1) << "\n";
  } else {
    int ret = accumulate(v.begin(), v.begin() + j, -1);
    for (int i = j; i < v.size(); ++i)
      ret += v[i] - 1;
    cout << ret << "\n";
  }

  return 0;
}


Measured memory_bytes: 1020
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		bool[] P = new bool[N+1];
		for(int i=2;i<=N;i++) P[i] = true;
		for(int i=2;i<=N;i++){
			if(!P[i]) continue;
			for(int j=i+i;j<=N;j+=i) P[j] = false;
		}
		
		long mod = (long) 1e9 + 7;
		
		long ans = 1;
		for(int i=0;i<=N;i++){
			if(!P[i]) continue;
			long p = i;
			long b = 0;
			while(N / p > 0){
				b += (N / p);
				p *= i;
			}
			ans *= (1 + b);
			ans %= mod;
		}
		
		Console.WriteLine(ans);
		
		
		
	}
	int N;
	public Sol(){
		N = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  int L = A;
  int R = A + N - 1;
  
  int eat;
  if (R <= 0) eat = R;
  else if (L >= 0) eat = L;
  else eat = 0;
  
  int answer = (R+L)*(R-L+1)/2 - eat;
  
  cout << answer << endl;
 
  return 0; 
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        System.out.println(solve(n));
    }

    public static long solve(long n){
        if(n % 2 != 0 || n < 10){
            return 0;
        }
        long ret = 0;
        int i=0;
        while(10*Math.pow(5,i) <= n){
            long def = 10*(long)Math.pow(5,i);
            ret += n/def;
            i++;
        }
        return ret;
    }
}

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

using namespace std;
int v[200001],n;
int main()
{
    cin>>n;
    int tofind=1;
    int lg=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(v[i]==tofind)
        {
            tofind++;
            lg++;
        }
    }
    if(lg==0)
        cout<<-1;
    else
        cout<<n-lg;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const int MAX_M = (int)(1e5 + 5);

int n, m;
ll a[MAX_N];
vector<pair<ll, int>> cb;

unordered_map<ll, int> cnt;

set<ll> cand;

ll ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(a[i]));

    cnt[a[i]] += 1;

    cand.insert(a[i]);
  }

  for (int i = 1; i <= m; ++i) {
    int b;
    ll c;

    scanf("%d %lld", &b, &c);

    cb.push_back(make_pair(c, b));
    cand.insert(c);
  }

  sort(cb.begin(), cb.end());

  for (auto &e: cb) {
    cnt[e.first] += e.second;
  }

  vector<ll> cand_vec;

  for (auto e: cand) {
    cand_vec.push_back(e);
  }

  reverse(cand_vec.begin(), cand_vec.end());

  ll cnt_num = 0;

  int remain_card = n;
  for (auto fuck: cand_vec) {
    int num = min(remain_card, cnt[fuck]);

    // printf("%d %d %lld\n", remain_card, num, fuck);
    remain_card -= num;


    cnt_num += fuck * num;
    if (n == 0) break;
  }

  ans = cnt_num;

  printf("%lld\n", ans);

  return 0;
}


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

using namespace std;

int main(void){
    int x;
    cin >> x;
    int y = x;
    int s = 0;

    for(int a = 1; a < 11; a++){
        s += y % 10;
        y /= 10;
    }

    if(x % s == 0)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void Main()
{
	int n, r;
	cin >> n >> r;
	if (n < 10)
		r += 100 * (10 - n);
	cout << r << endl;
}
// END

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#define ll long long 
using namespace std;
void isN(int n){
	while(n){
		if(n%10==7)
		  {
		  	cout<<"Yes\n";
		  	return ;
		  }
		  n/=10;
	}
	cout<<"No\n";
	return ;
}
int main(){
	int T;
	cin>>T;
	isN(T);
	return 0;
}

Measured memory_bytes: 3600
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

string s;


int main () {
	cin >> s;
	string t = "hi";
	while(t.size() < s.size()) t += "hi";
	if(s == t) cout << "Yes";
	else cout << "No";

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ans;
	if (a == 0)ans = 1;
	if (b == 0)ans = 2;
	if (c== 0)ans = 3;
	if (d== 0)ans = 4;
	if (e == 0)ans = 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
import math


def using_sqrt(k):
    while True:
        factor = 0  # 割り切れた回数

        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            k += 1
            continue

        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1

        if factor == 0:
            return k

        k += 1


print(using_sqrt(int(input())))


Measured memory_bytes: 38384
import heapq, sys

n, m, s, t = map(int, input().split())

yen_edge = [[] for _ in range(n)]
snuke_edge = [[] for _ in range(n)]

for _ in range(m):
	u, v, a, b = map(int, input().split())
	yen_edge[u - 1].append([v - 1, a])
	yen_edge[v - 1].append([u - 1, a])
	snuke_edge[u - 1].append([v - 1, b])
	snuke_edge[v - 1].append([u - 1, b])

class DijkstraList():
    #隣接リスト版
    #同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ
    def __init__(self, adj, start):
        self.list = adj
        self.start = start
        self.size = len(adj)

    def solve(self):
        self.dist = [float("inf") for _ in range(self.size)]
        self.dist[self.start] = 0
        self.prev = [-1 for _ in range(self.size)]
        self.q = []
        self.cnt = 0

        heapq.heappush(self.q, (0, self.start))

        while self.q and self.cnt < self.size:
            u_dist, u = heapq.heappop(self.q)
            if self.dist[u] < u_dist:
                continue
            for v, w in self.list[u]:
                if self.dist[v] > u_dist + w:
                    self.dist[v] = u_dist + w
                    self.prev[v] = u
                    heapq.heappush(self.q, (self.dist[v], v))

            self.cnt += 1

        return

    def distance(self, goal):
        return self.dist[goal]

    def path(self, goal):
        self.path = [goal]
        while self.path[-1] != self.start:
            self.path.append(self.prev[self.path[-1]])
        return self.path[::-1]

yen = DijkstraList(yen_edge, s - 1)
snuke = DijkstraList(snuke_edge, t - 1)
yen.solve()
snuke.solve()
ans_list = []

for i in range(n):
	ans_list.append(yen.distance(i) + snuke.distance(i))

ans = []

ans.append(10 ** 15 - ans_list[n - 1])

for i in range(1, n):
	if ans_list[n - i - 1] > ans_list[n - i]:
		ans_list[n - i - 1] = ans_list[n - i]
	ans.append(10 ** 15 - ans_list[n - i - 1])

for i in range(n - 1, -1, -1):
	print(ans[i])

Measured memory_bytes: 126828
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define sort(i,t) qsort(i.data(),i.size(),sizeof(t),[](const void*a, const void*b)->int{if((*(t*)a)>(*(t*)b))return 1;if((*(t*)a)<(*(t*)b))return -1;return 0;})
void din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void din(T& head, Args& ... rest) { cin >> head; din(rest...); }
template <typename T, typename ... Args> inline void dout(T& head, Args& ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
int main()
{
	string s;
	din(s);
	repn(i, s.length())
		s[i] = s[i] == '1' ? '9' : (s[i] == '9'?'1' : s[i]);
	dout(s);
}

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

using namespace std;

char mcxi[5]="mcxi";
int digit[5]={1000, 100, 10, 1, 0};

int main(){
	int n; cin >> n;
	for(int i=0; i<n; i++) {
		string str;
		for(int j=0; j<2; j++){
			string tmp; cin >> tmp;
			str+=tmp;
		}

		int sum=0, tmp=1;
		for(int j=0; str[j]!='\0'; j++){
			if(isdigit(str[j])) tmp=str[j]-'0';
			else{
				for(int k=0; k<4; k++){
					if(str[j] == mcxi[k]) sum+= tmp*digit[k];
				}
				tmp=1;
			}
		}

		string out;
		for(int i=0; i<4; i++){
			int tmp = sum/digit[i] % 10;
			if(tmp>1) out += ('0'+tmp);
			if(tmp) out += mcxi[i];
		}
		cout << out <<endl;
	}
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}

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

    int N,H,W; cin >> N>>H>>W;
    int A, B;
    int ans = 0;
    rep(i, N) {
        cin >> A>>B;
        if (A>=H && B>=W) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
  int x,y;
  cin>>x>>y;
  int ans;
  if (x>=0 and y>=0){
    if(y>x) ans=(y-x);
    else ans=(x-y+2);
  }
  if (x<0 and y>=0) ans=abs(abs(x)-abs(y))+1;
  if (x<0 and y<=0) {
    if(y>x) ans=abs(x)-abs(y);
    else ans=abs(y)-abs(x)+2;
  }
  if(x>=0 and y<=0)ans=abs(abs(x)-abs(y))+1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var t string
	var s int
	if sc.Scan() {
		s, _= strconv.Atoi(sc.Text())
	}

	if sc.Scan() {
		t = sc.Text()
	}

	if s >= 3200 {
		fmt.Println(t)
	}else{
		fmt.Println("red")
	}
}

Measured memory_bytes: 640
use proconio::{fastout, input};

use proconio::marker::{Chars, Usize1};
use std::cmp::Reverse;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        h: usize, w: usize, k: usize,
        x1: Usize1, y1: Usize1, x2: Usize1, y2: Usize1,
        c: [Chars; h],
    }
    let mut d = vec![vec![None; w]; h];
    let mut q = BinaryHeap::new();
    q.push(Reverse((0, x1, y1)));
    while let Some(Reverse((z, x, y))) = q.pop() {
        for &(dx, dy) in [(!0, 0), (1, 0), (0, !0), (0, 1)].iter() {
            for t in 1..=k {
                let nx = t.wrapping_mul(dx).wrapping_add(x);
                let ny = t.wrapping_mul(dy).wrapping_add(y);
                if nx >= h || ny >= w {
                    break;
                }
                if c[nx][ny] == '@' {
                    break;
                }
                if let Some(dxy) = d[nx][ny] {
                    if z + 1 > dxy {
                        break;
                    }
                    if z + 1 == dxy {
                        continue;
                    }
                }
                d[nx][ny] = Some(z + 1);
                q.push(Reverse((z + 1, nx, ny)));
            }
        }
    }
    println!("{}", d[x2][y2].unwrap_or(-1));
}


Measured memory_bytes: 17500
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
double bmi(double h, double w){
	return w/((h/100)*(h/100));
}

int main(){
	int n, p;
	double h, w;
	const double c = 22;
	while(true){
		cin >> n;
		if(n == 0)
			return 0; 
		int num;
		double diff;
		for(int i = 0; i < n; i++){
			cin >> p >> h >> w;
			if(i == 0){
				num = p;
				diff = abs(bmi(h,w) - c);
			}else{
				double k = abs(bmi(h,w) - c);
				if(diff > k){
					diff = k;
					num = p;
				}else if(diff == k){
					if(num > p)
						num = p;
				}
			}
		}
		cout << num << endl;
	}

}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

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

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    vector<pair<string, int>> p;
    rep(i, n){
        string s;int t;
        cin>>s>>t;
        pair<string, int> pp(s,t*1000+i);
        p.push_back(pp);
    }
    sort(all(p));
    string now = "";
    vint ss;
    rep(i, p.size()){
        //cout << p[i].first << endl;
        debug("%s %d\n", p[i].first, p[i].second);
        if(p[i].first!=now){
            now = p[i].first;
            debug("%s\n", now);
            for(int j = ss.size()-1;j>=0;j--){
                cout << ss[j]%1000+1 << endl;
            }
            ss = vint();
            ss.push_back(p[i].second);
        }else{
            
            ss.push_back(p[i].second);
        }
    }
    for(int j = ss.size()-1;j>=0;j--){
        cout << ss[j]%1000+1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> cnt(n + 1);
  vector<int> a(n);
  long long tot = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    tot += cnt[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    cout << tot - cnt[a[i]] + 1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>

using namespace std;
int Max,Min,i,v[200],n;
int main()
{
    cin>>n;
    Min=1000000001;
    for(i=1;i<=n;++i) cin>>v[i];
    for(i=1;i<=n;++i)
    {
        if(v[i]>Max)Max=v[i];
        if(v[i]<Min)Min=v[i];
    }
    cout<<Max-Min<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
main(){
  int N;
  cin>>N;
  vector<int>good;
  if(N%2){
    good.push_back(0);
    for(int i=2;i<=N-1;i+=2){
      good.push_back(i);
      good.push_back(i);
    }
  }else{
    for(int i=1;i<=N-1;i+=2){
      good.push_back(i);
      good.push_back(i);
    }
  }
  vector<int>data(N);
  for(auto&x:data)cin>>x;
  sort(data.begin(),data.end());
  if(data!=good){
    cout<<0<<endl;
    return 0;
  }
  constexpr int MOD=1e9+7;
  int product=1;
  for(int i=0;i<N/2;++i)
    product=product*2%MOD;
  cout<<product<<endl;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 100010;
int r[limit], c[limit], a[limit];

// Description: 素集合を管理するデータ構造
// TimeComplexity: 初期化$\mathcal{O}(n)$ 更新$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

struct Union_find {
	Union_find(int n) {
		data.assign(n, -1);
		edge.assign(n, 0);
	}
	int find(int x) {return (data[x] < 0) ? x : data[x] = find(data[x]);}
	void unite(int a, int b) {
		a = find(a), b = find(b);
		if (a != b) {
			if (data[a] < data[b]) swap(a, b);
			data[a] += data[b], data[b] = a;
			edge[a] += edge[b], edge[b] = 0;
		}
		edge[a]++;
	}
	bool same(int a, int b) {return find(a) == find(b);}
	int v_size(int x) {return -data[find(x)];}
	int e_size(int x) {return edge[find(x)];}
	vector<int> data, edge;
};

bool used_edge[limit];
bool used_vertex[limit];

int main(void){
	int n, h, w;
	cin >> n >> h >> w;

	rep(i, n){
		cin >> r[i] >> c[i] >> a[i];
		r[i]--, c[i]--;
	}

	using edge = tuple<ll,int,int>;
	vector<edge> graph;

	rep(i, n) graph.push_back(edge(a[i], r[i], c[i] + h));
	sort(rbegin(graph), rend(graph));

	ll ans = 0LL;
	Union_find uf(h + w);

	rep(i, n) {
		ll cost;
		int u, v;
		tie(cost, u, v) = graph[i];

		int nv = uf.v_size(u);
		int ne = uf.e_size(u);

		if (uf.same(u, v) == false) {
			nv += uf.v_size(v);
			ne += uf.e_size(v);
		}

		if (nv <= ne) continue;
		ans += cost;
		uf.unite(u, v); 
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

const int N = 2e5 + 5;

int n;
int d[N];
ll c[N];

int main() {
	scanf("%d", &n);
	ll ans = -1, sum = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d%lld", d + i, c + i);
		ans += c[i];
		sum += d[i] * c[i];
	}
	ans += sum / 9;
	sum %= 9;
	while (sum + 9 < 10)
		ans--, sum += 9;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2560
using System;

public class hello
{
    public static void Main()
    {
        Console.ReadLine().Trim();
        var n = int.Parse(Console.ReadLine().Trim());
        var baL = 0;
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            baL += int.Parse(line[0]) * int.Parse(line[1]);
        }
        if (baL == 0) { Console.WriteLine(0); goto end; }
        Console.WriteLine(1);
        if (baL > 0) Console.WriteLine("-1 {0}", baL);
        else Console.WriteLine("1 {0}", -baL);
        end:;
    }
}

Measured memory_bytes: 9204
'''


39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB


'''

l=[]
q=[]
w=[]
n=int(input())
s=input().rstrip()
x=list(s)
for i in range(0,n):
    if x[i]=='R':
        l.append(i)
    elif x[i]=='G':
        q.append(i);
    else:
        w.append(i);
total = 0;
for i in range(0,len(l)):
    for j in range(0,len(q)):
        A=abs(l[i]-q[j]);
        H=[]
        H.append(l[i])
        H.append(q[j]);
        H.sort();
        B=H[0]-A;
        C=H[1]+A;
        D=-1;
        if A%2==0:
            D=H[0]+(A//2);
        I=0;
        J=len(w)-1;
        V=0;
        while(I<=J):
            m=I+(J-I)//2;
            if w[m]==B:
                V+=1;
                break;
            elif w[m]>B:
                J=m-1;
            else:
                I=m+1;
        B=C;
        I=0;
        J=len(w)-1
        while(I<=J):
            m=I+(J-I)//2;
            if w[m]==B:
                V+=1;
                break;
            elif w[m]>B:
                J=m-1;
            else:
                I=m+1;
        if D!=-1:
            B=D;
            I=0;
            J=len(w)-1
            while(I<=J):
                m=I+(J-I)//2;
                if w[m]==B:
                    V+=1;
                    break;
                elif w[m]>B:
                    J=m-1;
                else:
                    I=m+1;            
        total+=(len(w)-V);
print(total)

Measured memory_bytes: 69456
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    a, b, c = iim()
    n = 0
    for i in range(a, b+1):
        if c % i == 0:
            n += 1
    print(n)

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 5600
N  = int(input())
testimony = [[]for i in range(N)]
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1,state])#3次元配列の作り方
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if(i>>j)&1 == 1:
            for x,y in testimony[j]:#3次元リストからx,yを取り出す書きかた　覚える
                if (i>>x)&1 != y: #正直といっているがそうではない　と　嘘つきといっているがそうではない　の二つ同時
                    flag =1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))# bin()で二進数に変換　最初の二文字は0bで取り除く count('1')で数える
print(honest)


Measured memory_bytes: 3064
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def calc(a, b, c):
    if a==b or b==c or a==c:
        return False
    return a+b > c and b+c > a and a+c > b

_ = ni()
l = na()

cnt = 0
for a, b, c in itertools.combinations(l, 3):
    if calc(a, b, c):
        cnt += 1

print(cnt)


Measured memory_bytes: 69032
N = int(input())
s = [int(input()) for _ in range(N)]
t = [x for x in s if x%10 != 0]
total = sum(s)
if total%10 != 0:
    print(total)
else:
    if len(t) == 0:
        print(0)
    else:
        print(total-min(t))

Measured memory_bytes: 3060
#include <stdio.h>
#include <bitset>
using namespace std;
int main(){
    bitset<10000>a;
    int n,temp;
    a.reset();
    a[0]=true;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        a|=a<<temp;
    }
    scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        if(a[temp])printf("yes\n");
        else printf("no\n");
    }
}

Measured memory_bytes: 2580
#include <cstdio>

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    
    int a[n][m];
    for(int i = 0; i < n; i++) {
        for(int j = 0;j < m;j++){
            scanf("%d", &a[i][j]);
        }
    }
    int b[m];
    for(int j = 0;j < m;j++){
        scanf("%d",&b[j]);
    }
    int c[n];
    
    for(int i = 0;i < n;i++){
        c[i] = 0;
        for(int j = 0;j < m;j++){
           c[i] +=  a[i][j] * b[j];
        }
        printf("%d\n",c[i]);
    }
    return 0;
}


Measured memory_bytes: 2740
import numpy as np
N = int(input())
X = list(map(int, input().split()))
p1 = int(np.mean(X))
S1 = np.sum([(x-p1)**2 for x in X])
p2 = p1 + 1
S2 = np.sum([(x-p2)**2 for x in X])
print(min(S1, S2))

Measured memory_bytes: 19764
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define all(c) (c).begin(),(c).end()
#define ss second
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >
#define Inp(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define Out(a,n,ch) for(int i=0;i<n;i++)cout<<a[i]<<ch;cout<<endl;
 
int a[200005],pref[200005]={0};
int32_t main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	
	int n,sum=0,cursum=0,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=n-2;i>=0;i--)
	{
		pref[i] = pref[i+1] + a[i+1];
	}

	for(int i=0;i<n-1;i++)
	{
		ans = (ans+(pref[i]%MOD*a[i]%MOD))%MOD;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6752
def change(i, num)
  if $group[i]==nil
    $group[i] = num
  end
  for j in $pairs[i]
    if $group[j]==nil
      change(j, $group[i])
    end
  end
end

n,m = gets.split.map(&:to_i)

$pairs = Array.new(n){Array.new(0)}

for i in 0...m
  tmp = gets.split.map(&:to_i)
  $pairs[tmp[0]-1].push(tmp[1]-1)
  $pairs[tmp[1]-1].push(tmp[0]-1)
end

for i in 0...n
  $pairs[i] = $pairs[i].uniq.sort
end

$group = Array.new(n,nil)

for i in 0...n
  change(i, i)
end

ans = 0

$group = $group.sort

tmp = 1
for i in 1...$group.size
  if $group[i]==$group[i-1]
    tmp += 1
  else
    ans = [ans,tmp].max
    tmp = 1
  end
end

ans = [ans,tmp].max

puts ans

Measured memory_bytes: 268464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();

#define MAXN 10010

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

	string s;
	cin >> s;
	int one = (s[0] - '0') * 10 + (s[1] - '0'), two = (s[2] - '0') * 10 + (s[3] - '0');
	bool ym = false, my = false;

	if(1 <= two && two <= 12) ym = true;
	if(1 <= one && one <= 12) my = true;

	if(my && ym){
		cout << "AMBIGUOUS";
	}
	else if(ym){
		cout << "YYMM";
	}
	else if(my){
		cout << "MMYY";
	}
	else cout << "NA";
	return 0;
}

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

int main(){
  int N,D,X,cnt=0;
  cin >> N >> D >> X;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    int s = 1;
    while(s < D+1){
      s += A[i];
      cnt++;
    }
  }
  cout << cnt + X << endl;
}	

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

using namespace std;
// bool isCircular(node *head);

struct node{
    int val;
    node* next;
};

bool isCircular(node *head) 
{ 
    // An empty linked list is circular 
    if (head == NULL) 
       return true; 
  
    // Next of head 
    node *node = head->next; 
  
    // This loop would stope in both cases (1) If 
    // Circular (2) Not circular 
    while (node != NULL && node != head) 
       node = node->next; 
  
    // If loop stopped because of circular 
    // condition 
    return (node == head); 
} 

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

    long long n, k;
    cin >> n >> k;
    long long a[n];
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        a[i]--;
    }
    // long long t = a[0];
    // for(int i = 0; i < k - 1; ++i){
    //     t = a[t-1];
    // }

    long long now;
    vector<int> loop;
    vector<bool>seen(n, false);
    now = 0;
    seen[now] = true;
    loop.push_back(0);
    int num;
    while(1){
        int next = a[now];
        if(seen[next] == true){
            num = next;
            break;
        }
        loop.push_back(next);
        seen[next] = true;
        now = next;
    }

	if (loop.size() == 1) {
		cout << 1;
		return 0;
	}

    vector<int> v;
    for(int i = 0; i < loop.size(); ++i){
        if(loop[i] == num){
            while(i < loop.size()){
                v.push_back(loop[i]);
                ++i;
            }
        }
    }
    for(int i = 0; i < loop.size() - 1; ++i){
        if(loop[i] == num) break;
        if(k == 1){
            if(i + 1 < loop.size()){
                cout << loop[i + 1] + 1;
                return 0;
            }
        }
        k--;
    }

    int len = v.size();
    long long ans = k%len;
    cout << v[ans] + 1 << endl;

    // node *head = new node(), *curr;
    // head->val = a[0];
    // t[0] = a[0];
    // curr = head;
    // int count = 0;
    // node *tmp = new node();
    // for(int i = 1; i < n; ++i){
    //     t[i] = a[t[i - 1] - 1];
    //     tmp->val = t[i];
    //     curr->next = tmp;
    //     curr = tmp;
    // }   
    // if(isCircular(head)){
    //     cout << "cir" << endl;
    // }

    // cout << t << endl;;
    // 1-6-2-5-3-2-5-3-2-5-
}

Measured memory_bytes: 7148
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];

	int ans = 0;
	for (int i = 0; i <= n && i <= k; ++i) 
		for (int j = 0; i+j <= n && i+j <= k; ++j) {
			priority_queue<int> pq;
			int sum = 0;

			for (int t = 0; t < i; ++t) {
				sum += v[t];
				pq.push(-v[t]);
			}

			for (int t = n-j; t < n; ++t) {
				sum += v[t];
				pq.push(-v[t]);
			}

			// printf("%d %d %d\n", i, j, sum);

			int rem = k - i - j;
			while (rem > 0 && !pq.empty() && pq.top() > 0) {
				--rem;
				sum += pq.top();
				pq.pop();
			}

			// printf("%d %d %d\n", i, j, sum);
			ans = max(ans, sum);
		}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256