akhauriyash/Code-Regression huggingface dataset:
// 基本テンプレート
 
#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>
#include <numeric>
#include <fstream>
#include <functional>
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 debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, M;
    while(cin >> N, N) {
        vector< pair<int, int> > box;
        for(int i=0; i<N; i++) {
            int A, B; cin >> A >> B;
            box.emplace_back(A, B);
        }
        cin >> M;
        for(int i=0; i<M; i++) {
            int A, B; cin >> A >> B;
            box.emplace_back(A, B);
        }
        sort(box.begin(), box.end());

        N += M;
        vector<int> dp(N, 0);
        for(int i=0; i<N; i++) {
            dp[i] = 1;
            for(int j=0; j<i; j++) {
                bool ok = true;
                ok &= (box[j].first < box[i].first);
                ok &= (box[j].second < box[i].second);

                if(ok) {
                    chmax(dp[i], dp[j] + 1);
                }
            }
        }
        cout << *max_element(dp.begin(), dp.end()) << endl;
    }
    return 0;
}


Measured memory_bytes: 3028
a,b,h,m = gets.split.map(&:to_f)

pi = Math::PI
h_angle = (60 * h + m) / 720 * 360
m_angle = m / 60 * 360
angle = (h_angle - m_angle).abs
angle = [angle, 360 - angle].min
x = a**2 + b**2 - 2*a*b*Math.cos(angle/180 * pi)
puts Math.sqrt(x.to_f)

Measured memory_bytes: 14680
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());
#define mp make_pair
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int ans = 700;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] == 'o') ans += 100;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 3e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;

int A[MAXN];
char S[MAXN];
char T[MAXN];
int Sp[MAXN][5];//0 U,1 D,2 L,3 R
int Tp[MAXN][5];


int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;

    scanf("%d%d%d",&n,&m,&k);


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

    scanf("%s",&S);
    scanf("%s",&T);


    int mxh = a,mnh = a;
    int mxw = b,mnw = b;

    for(int i=1;i<=2*k;i++){
        if(i%2){
            if(S[i/2]=='U'){mnh--; if(!mnh){printf("NO"); return 0;}}
            if(S[i/2]=='D'){mxh++; if(mxh==n+1){printf("NO"); return 0;}}
            if(S[i/2]=='L'){mnw--; if(!mnw){printf("NO"); return 0;}}
            if(S[i/2]=='R'){mxw++; if(mxw==m+1){printf("NO"); return 0;}}
        }
        else {
            if(T[(i-1)/2]=='D'){mnh = min(mnh+1,n);}
            if(T[(i-1)/2]=='U'){mxh = max(1,mxh-1);}
            if(T[(i-1)/2]=='R'){mnw = min(mnw+1,m);}
            if(T[(i-1)/2]=='L'){mxw = max(1,mxw-1);}
        }
        //printf("%d %d %d %d\n",mnh,mxh,mnw,mxw);
    }

    printf("YES");


    return 0;
}


Measured memory_bytes: 2304
//g++ -std=c++11
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
typedef pair <ld, ld> pd;

typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ld> vd;
typedef vector <pi> vpi;
typedef vector <pl> vpl;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define ins insert

const int INF = 1000000000;
const int MAXN = 200000;
const int MOD = 1000000007;
const char nl = '\n';

int main() {

    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll a, b, d;
    char c;

    cin >> a >> b >> c >> d;

    cout << ((b*100) +d) * a / 100<< nl;
    
    return 0;
}

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

string han(string A){
	if(A == "H"){
		return "D";
	}
	else return "H";
}

int main(){
	string A, B;
	cin >> A >> B;
	if (A == "H") cout << B << endl;
	else cout << han(B) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long int c1(long long int k)
{
	if (k <= 0)
		return 1;
	long long int res1[10], res2[10];
	res1[0] = res2[0] = 1;
	int i;
	for (i = 1; i < k; i++)
	{
		res1[i] = res2[i - 1];
		res2[i] = res2[i - 1] + res1[i - 1];
	}
	return res1[k - 1];
}
long long int c2(long long int k)
{
	if (k <= 0)
		return 1;
	long long int res1[10], res2[10];
	res1[0] = res2[0] = 1;
	int i;
	for (i = 1; i < k; i++)
	{
		res1[i] = res2[i - 1];
		res2[i] = res2[i - 1] + res1[i - 1];
	}
	return res2[k - 1];
}
int main()
{
	long long int h, w, k;
	scanf("%lld %lld %lld", &h, &w, &k);
	long long int p = 1000000007;
	long long int dp[102][10];
	k--;
	int i, j;
	for (i = 0; i <= h; i++)
		for (j = 0; j < w; j++)
			dp[i][j] = 0;
	dp[0][0] = 1;
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			dp[i + 1][j] += dp[i][j] * c2(j) * c2(w - j - 1);
			dp[i + 1][j] %= p;
			if (j > 0)
				dp[i + 1][j] += dp[i][j - 1] * c1(j) * c2(w - j - 1);
			dp[i + 1][j] %= p;
			if (j < w - 1)
				dp[i + 1][j] += dp[i][j + 1] * c2(j) * c1(w - j - 1);
			dp[i + 1][j] %= p;
		}
	}
	printf("%lld\n", dp[h][k]);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge> >;

Graph G;
vector<int> color;

void dfs(int v, int p, int c){
    color[v] = c;
    for(auto e : G[v]){
        if(e.first == p) continue;
        if(e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    G.assign(n, vector<Edge>());
    for(int i = 0; i < n-1; i++){
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        u--, v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    color.assign(n, -1);
    dfs(0, -1, 1);
    for(auto c : color) printf("%d\n", c);
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a;cin>>a;
    if(a==tolower(a))cout<<'a';
    else cout<<'A';
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
#define _ << " " <<
#define pb push_back

using namespace std;

const int mod = 1e9 + 7;
int add(int x, int y) {
  x += y;
  if(x >= mod) return x - mod;
  return x;
}
int mul(int x, int y) {
  return (ll) x * y % mod;
}
int sub(int x, int y) {
  x -= y;
  if(x < 0) return x + mod;
  return x;
};

#define int ll

typedef pair<int, int> pii;

const int off = 1 << 18, MAXN = 2e5 + 5;

ll mx[2 * off], p[2 * off];
/*
void prop(int x) {
  if(p[x]) {
    mx[x] += x;
    if(x < off) {
      p[x * 2] += p[x];
      p[x * 2 + 1] += p[x];
    }
    p[x] = 0;
  }
}*/
void upd(int x, int lo, int hi, int a, int b, int v) {
  if(lo >= a && hi <= b) {
    p[x] += v;
    mx[x] += v;
    //prop(x);
    return;
  }
  //prop(x);
  if(lo >= b || hi <= a) {
    return;
  }

  int mi = (lo + hi) >> 1;
  upd(x * 2 + 0, lo, mi, a, b, v);
  upd(x * 2 + 1, mi, hi, a, b, v);
  mx[x] = max(mx[x * 2], mx[x * 2 + 1]) + p[x];
}
void upd2(int x, int lo, int hi, int a, int b, int v) {
  if(lo >= a && hi <= b) {
    p[x] = v;
    mx[x] = v;
    //prop(x);
    return;
  }
  //prop(x);
  if(lo >= b || hi <= a) {
    return;
  }

  int mi = (lo + hi) >> 1;
  upd(x * 2 + 0, lo, mi, a, b, v);
  upd(x * 2 + 1, mi, hi, a, b, v);
  mx[x] = max(mx[x * 2], mx[x * 2 + 1]) + p[x];
}/*
ll get(int x, int lo, int hi, int a, int b) {
  if(hi <= lo) return 0;
  prop(x);
  if(lo >= a && hi <= b) {
    return mx[x];
  }
  if(lo >= b || hi <= a) {
    return 0;
  }

  int mi = (lo + hi) >> 1;
  return max(get(x * 2 + 0, lo, mi, a, b),
             get(x * 2 + 1, mi, hi, a, b));
}*/
ll sol;

vector<pii> e[MAXN];
ll dp[MAXN];

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

  REP(i, m) {
    int l, r, a; cin >> l >> r >> a;
    e[r].pb({l, -a});
  }

  FOR(i, 1, n + 1) {
    ll tmp = mx[1], best = 0;
//    sort(e[i].begin(), e[i].end());
//    reverse(e[i].begin(), e[i].end());

    ll tmp_add = 0;

    int lst = i;

    for(auto p: e[i]) {
      int ii = p.first;
      int cost = -p.second;

      tmp += cost;

      if(ii < i) upd(1, 0, off, ii, i, cost);
    }

    if(i == n) sol = tmp;
    upd2(1, 0, off, i, i + 1, tmp);
  }

  sol = max(sol, mx[1]);

  cout << sol << endl;
}


Measured memory_bytes: 20224
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');

var input = stdin.toString().trim().split('\n');
var S = parseInt(input[0],10);

var h = Math.floor(S / (60 * 60));
var m = Math.floor(S % (60 * 60) /60);
var s = Math.floor(S % 60) ;
console.log([h,m,s].join(':'));

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

int main(){
    ll N, M;
    cin >> N >> M;
    priority_queue<pair<ll,ll>> que;
    pair<ll,ll> p;
    p.second = 1;
    rep(i,N){
        cin >> p.first;
        que.push(p);
    }
    rep(i,M){
        cin >> p.second >> p.first;
        que.push(p);
    }
    ll sum = 0;
    rep(i,N){
        sum += que.top().first;
        if(que.top().second > 1){
            pair<ll,ll> tmp = que.top();
            que.pop();
            tmp.second--;
            que.push(tmp);
        }else{
            que.pop();
        }
    }
    cout << sum << endl;
    /*
    vector<ll> A(N,0), B(M,0), C(M,0),S(N+1,0);
    vector<pair<ll,ll>> D(M);
    rep(i,N){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    rep(i,N){
        S[i+1] = S[i] + A[i];
    }
    rep(i,M){
        cin >> D[i].second >> D[i].first;
    }
    sort(D.begin(), D.end(), greater<pair<ll,ll>>());    
    ll plus = 0;
    rep(i,M){
        ll id = lower_bound(A.begin(), A.end(), D[i].first) - A.begin();
        ll num = min(id,D[i].second);
         = max(S[num], num*D[i].first) - S[num];
        /*rep(j,num){
            A[j] = C[i];
        }
        sort(A.begin(), A.end());
        */
    //}
    /*ll sum = 0;
    rep(i,N){
        sum += A[i];
    }*/
    //cout << S[N] << endl;
    
}

Measured memory_bytes: 6384
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int k,t;
  cin >> k >> t;
  vi a(t);
  int maxnum = 0, pos;
  rep(i, t){
    cin >> a[i];
    if(a[i] > maxnum){
      maxnum = a[i];
      pos = t;
    }
  }
  int ans = maxnum - 1;
  ans = max(ans - k + maxnum, 0);
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

// gcd ...
func gcd(n, m int) int {
	if m == 0 {
		return n
	}
	return gcd(m, n%m)
}

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	m := sc.NextInt()
	s := sc.NextLine()
	t := sc.NextLine()

	g := gcd(n, m)
	ans := n / g * m

	n /= g
	m /= g
	for i := 0; i < g; i++ {
		if string(s[i*n]) != string(t[i*m]) {
			fmt.Printf("-1\n") // output for debug
			return
		}
	}
	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for (int i=0;i<n;i++){
    for (int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  vector<int> d(n);
  int count=0;
  for (int i=0;i<n;i++){
    for (int j=0;j<m;j++){
      d[i]+=a[i][j]*b[j];
    }
    if(d[i]+c>0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n,m,p;
    while(1){
    cin>>n>>m>>p;
    if(n==0&&m==0&&p==0)break;
    m--;
    vector<int> v(n,0);
    int sum=0;
    rep(i,0,n){
        cin>>v[i];
        sum+=v[i]*100;
    }
    sum-=(sum*p)/100;
    cout<<((v[m]==0)?0:sum/v[m])<<endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int a,b,c;
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	int ans = c - a + b;
	if(ans < 0)
	{
		ans = 0;
	}
	cout <<ans << endl; 
	return 0;
}

Measured memory_bytes: 256
import operator
N =int(input())
exist_cards = [input() for _ in range(N)]

SUITS = 'S H C D'.split()
suits_prior =dict(zip(SUITS,range(4)))
prior_suits = {v:k for k,v in suits_prior.items()}

def multisort(xs, specs):
    getter = operator.itemgetter if isinstance(specs,list) or isinstance(specs,tuple) else operator.attrgetter
    for key, reverse in reversed(specs):
        xs.sort(key=getter(key), reverse=reverse)
    return xs
cards =[]
for suit in SUITS:
    for i in range(1,14):
        cards.append(suit+" "+str(i))
missings = map(lambda s:s.split(),set(cards).difference(exist_cards))
missings2 = [[suits_prior[suit],int(val)] for suit,val in missings]
ms =  multisort(missings2, ((0, False), (1, False)))
ans = [[prior_suits[k],v] for k,v in ms]
for x in ans:
    print(" ".join([str(e) for e in x]))


Measured memory_bytes: 5696
#include<cstring>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
string s;
int main(){
	getline(cin,s);
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='p'&&s[n-i-1]=='q') continue;
		if(s[i]=='q'&&s[n-i-1]=='p') continue;
		if(s[i]=='b'&&s[n-i-1]=='d') continue;
		if(s[i]=='d'&&s[n-i-1]=='b') continue;
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 512
#!/usr/bin/env python3
s = input()
l = 0
r = len(s) - 1
cnt = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        cnt += 1
        l += 1
    elif s[r] == 'x':
        cnt += 1
        r -= 1
    else:
        cnt = -1
        break
print(cnt)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
const int INF=987654321;

int main()
{
    int N,M,X,arr[13][13],ans=INF;
    cin>>N>>M>>X;
    vector<int>cost(N);
    for(int i=0;i<N;i++)
    {
        cin>>cost[i];
        for(int j=0;j<M;j++)cin>>arr[i][j];
    }
    for(int bits=0;bits<(1<<N);bits++)
    {
        vector<int>sum(M);
        int costSum=0;
        for(int i=0;i<N;i++)
        {
            if(!(bits&(1<<i)))continue;
            costSum+=cost[i];
            for(int j=0;j<M;j++) sum[j]+=arr[i][j];
        }
        bool flag=true;
        for(auto i:sum)if(i<X)flag=false;
        if(flag)ans=min(ans,costSum);
    }
    cout<<(ans==INF?-1:ans);
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,k,r,s,p,f[200010],ans;
string t;
int main(){
	cin>>n>>k>>r>>s>>p>>t;
	for (int i=0;i<n;i++)
		if (t[i]=='r'){
			if (f[i]==3)
				continue;
			else{
				f[i+k]=3;
				ans+=p;
			}
		}
		else if (t[i]=='s'){
			if (f[i]==1)
				continue;
			else{
				f[i+k]=1;
				ans+=r;
			}
		}
		else if (t[i]=='p'){
			if (f[i]==2)
				continue;
			else{
				f[i+k]=2;
				ans+=s;
			}
		}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

template <class T> int getbit(T s, int i) { return (s >> i) & 1; }
template <class T> T onbit(T s, int i) { return s | (T(1) << i); }
template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template <class T> ll cntbit(T s) { return __builtin_popcntll(s); }

#define all(a) (a).begin(), (a).end()
#define ms(a, x) memset(a, x, sizeof(a))
#define forv(v, it) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); it++)
#define print(x) cout << "L" << __LINE__ << " -- " << #x << " = " << x << endl
#define clear(x) v.clear(); vector<T>(v).swap(v)

#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define eps 1e-12

#define div ___div
#define next ___next
#define prev ___prev
#define left ___left
#define right ___right
#define y0 ___y0
#define y1 ___y1

vector< vector<int> > arr(10);
vector< vector<int> > shortest(10);

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

  int h, w;
  cin >> h >> w;

  for(int i = 0; i < 10; i++) {
    arr[i].resize(10);
    shortest[i].resize(10);
    fill(all(shortest[i]), 0);
    for(int j = 0; j < 10; j++) {
      cin >> arr[i][j];
      shortest[i][j] = arr[i][j];
    }
  }

  for(int k = 0; k < 10; k++) {
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        if(shortest[i][k] + shortest[k][j] < shortest[i][j]) {
          shortest[i][j] = shortest[i][k] + shortest[k][j];
        }
      }
    }
  }

  int answer = 0;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      int temp;
      cin >> temp;

      if (temp != -1) {
        answer += shortest[temp][1];
      }
    }
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n,m;
    cin>>n>>m;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    vector<vector<int>>r(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    int ans=0;
    rep(i,n){
        bool ok=true;
        for(int x:r[i]){
            if(h[i]<=h[x])ok=false;
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

#define _11day ""

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void add(ll &x, ll y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
int sum(ll x, ll y) {
  add(x, y);
  return x;
}
int mult(ll x, ll y) {
  return (x * 1ll * y) % mod;
}

int n, m;
int x[N], y[N];
int main() {
  #ifndef _11day
    freopen (_11day".in", "r", stdin);
    freopen (_11day".out", "w", stdout);
  #endif

  scanf ("%d%d", &n, &m);
  rep(i, 1, n)
    scanf ("%d", &x[i]);
  rep(i, 1, m)
    scanf ("%d", &y[i]);

  ll f = 0;
  {
    ll s = 0;
    rep(i, 1, m) {
      if (i > 1) {
        ll cur = sum(mult(i - 1, y[i]), -s);
        add(f, cur);
      }
      add(s, y[i]);
    }
  }

  ll s = 0, ans = 0;
  rep(i, 1, n) {
    if (i > 1) {
      ll cur = sum(mult(i - 1, x[i]), -s);
      add(ans, mult(cur, f));
    }
    add(s, x[i]);
  }

  cout << ans;
  ioi
}


Measured memory_bytes: 1024
# UnionTreeクラス：グループ分けを木構造で管理する
class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1] * N
        self.N = N

    # xのrootを返す
    def root(self, x):
        if self.par[x] == x:
            return x
        else: 
            self.par[x] = self.root(self.par[x])
            return self.root(self.par[x])

    # x, yが同じrootの場合true
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    # x,yのrootが違った場合、併合
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if self.size[rx] < self.size[ry]:
            self.par[rx] = ry
            self.size[ry] += self.size[rx]
        else:
            self.par[ry] = rx
            self.size[rx] += self.size[ry]
            

n, m = (int(i) for i in input().split())
a = [int(i)-1 for i in input().split()]
xy = [[int(i)-1 for i in input().split()] for i in range(m)]

uf = UnionFind(n)

for x,y in xy: 
    uf.unite(x, y)

cnt = 0
for idx, a_ in enumerate(a):
    if uf.same(idx, a_):
        cnt += 1

print(cnt)



Measured memory_bytes: 110828
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll x;
    cin >> x;
    ll now = 100;
    for(int i = 0; ++i;) {
        now += now / 100;
        if(now >= x) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3640
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

#ifndef __GNUG__
int __builtin_popcount(int n) {
	int x = 0;
	while (n)n -= n&(-n), x++;
	return x;
}
#endif

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 1000000007;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

int main() {

	//freopen("input.txt", "r", stdin);

	int n; ni(n);
	if (n == 1 || n == 10 || n == 100 || n == 1000 || n == 10000 || n == 100000)puts("10");
	else {
		int ans = 0;
		while (n) {
			ans += n % 10; n /= 10;
		}
		printf("%d\n", ans);
	}
	
}

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

int main(){
	string s;
	ll k,c=0,ans;

	cin>>s>>k;

	for(int i=0;i<s.size();i++){
		if(s[i]=='1')c++;
		else c+=k+1;
		if(c>=k){
			cout<<s[i];
			return 0;
		}
	}
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os
import re

t0 = {}
for s in sys.stdin:
    s = s.strip()
    if s == '':
        break
    c, d = map(int, s.split(','))
    if c in t0:
        t0[c] += 1
    else:
        t0[c] = 1

t1 = {}
for s in sys.stdin:
    s = s.strip()
    if s == '':
        break
    c, d = map(int, s.split(','))
    if c in t1:
        t1[c] += 1
    else:
        t1[c] = 1

set0 = set(t0)
set1 = set(t1)
intersection = list(set0 & set1)
intersection.sort()

for key in intersection:
    print(key, t0[key] + t1[key])

Measured memory_bytes: 7712
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}
const int MOD = 1e9 + 7;


int power(int n, int p)
{
    if (p == 0)
        return 1;
    long long res = 1;
    long long add = n;
    while (p > 0)
    {
        if (p & 1)
            res = (res * add) % MOD;
        p >>= 1;
        add = add*add%MOD;
    }
    return res;
}

      

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
        cin >> a[i];
    ll ans = 1;

    vector<ll> fc(n+1, 1);
    vector<ll> inv(n+1, 1);
    IFOR(i, 1, n){
        fc[i] = (fc[i-1] * i) % MOD;
        inv[i] = power(fc[i], MOD-2);
    }

    vector<int> cnt(n+1, 0);
    int c0 = 0;
    REP(i, n){
        int x = a[i];
        cnt[x]++;
        if(x != 0){
            ans = (ans * cnt[x-1]) % MOD;
            cnt[x-1]--;
        }
        else
            c0++;
    }
    REP(i, c0)
        ans = (ans * (3-i)) % MOD;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 2560
main :: IO ()
main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  lines <- sequenceA (replicate h getLine)  :: IO [String]
  put lines
  
put :: [String] -> IO ()
put [] = return ()
put (b:bs) = do 
  sequenceA (replicate 2 (putStrLn b))  
  put bs


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll A,B,N;
  cin>>N;
  vector<ll> ans(0);
  ll count=0;
  for(ll i=9;i>=2;i--){
    if(N%i==0){
      ans.push_back(i);
      N/=i;
      count++;
      if(N%i==0){
        ans.push_back(i);
        N/=i;
        count++;
      }
    }
    if(count==2){break;}
  }
  if(N!=1){cout<<"No"<<endl;}
  if(N==1){cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
lmin = 1
rmax = n
for i in 1..m do
  l, r = gets.split.map(&:to_i)
  lmin = l if lmin < l
  rmax = r if rmax > r
end
if lmin > rmax
  res = 0
else
  res = rmax - lmin + 1
end
puts res


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

int main(){

    int n;
    cin >> n;

    set<string> s;

    string t;
    rep(i, n) {
        cin >> t;
        s.insert(t);
    }

    cout << s.size() << endl;

    return 0;
} 


Measured memory_bytes: 19264
#include <stdio.h>
int main(){

  int num1,num2;
  int amari,tmp;

  scanf("%d%d",&num1,&num2);
  if(num1<num2){
    tmp = num1;
    num1 = num2;
    num2 = tmp;
  }
  

 
  amari = num1 % num2;
  while(amari!=0){
    num1 = num2;
    num2 = amari;
    amari = num1 % num2;
  }
  printf("%d\n",num2);
  

  
  return 0;
}
  



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[2][n+5],sum=0;

    for(int i=0;i<2;i++)
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
            if(i) sum+=arr[i][j];
        }
    sum+=arr[0][0];
    int ans=sum;
    for(int i=1;i<n;i++){
        sum+=arr[0][i];
        sum-=arr[1][i-1];
        ans=max(ans,sum);
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	//*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	int A = 0;
	int B = 0;
	char[] S = null;
	boolean ans = true;

	public void input() throws IOException {
		//*
		String[] tmp = br.readLine().split(" ");
		A = Integer.parseInt(tmp[0]);
		B = Integer.parseInt(tmp[1]);
		S = br.readLine().toCharArray();
		/*/
		X = in.nextInt();
		Y = in.nextInt(new int[N]);
		//*/
	}
	
	public void solve() throws IOException {
		for(int i=0; i<A+B+1; i++){
			if (i==A) {
				if(S[i]!='-') {
					ans = false;
					return;
				}
			}else{
				if(!('0' <= S[i] && S[i] <= '9')){
					ans = false;
					return;
				}
			}
		}
	}
	
	
	public void output() {
		out.println(ans?"Yes":"No");
		out.flush();
	}
}

//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  ll T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  if (T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
    cout << "infinity" << endl;
    return 0;
  }
  if (A1 > B1) {
    swap(A1, B1);
    swap(A2, B2);
  }
  ll one_time = A1 * T1 + A2 * T2 - B1 * T1 - B2 * T2;
  if (one_time < 0) {
    cout << 0 << endl;
    return 0;
  }
  ll t1_diff = B1 * T1 - A1 * T1;
  ll res = 2 * (t1_diff / one_time);
  if (t1_diff % one_time != 0) {
    res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
a = list(map(int,readline().split()))
for i in range(n-k):
  chk = a[k+i]
  c = a[i]
  if chk > c:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 92984
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int n,c=0;
    cin >> n;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end(),greater<int>());
    for(int i=0;i<n-1;i++){
        if(d[i]>d[i+1]){
            c++;
        }
    }
    cout << c+1;
}

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

using namespace std;

#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define vi vector<int>

using lll = __int128_t;

pair<lll, lll> crt(lll a1, lll m1, lll a2, lll m2)
{
    auto normal = [](lll x, lll m) { return x >= -x ? x % m : m - (-x) % m; };
    auto modmul = [&normal](lll a, lll b, lll m) { return normal(a, m) * normal(b, m) % m; };
    auto extgcd = [](lll a, lll b, lll &x, lll &y) {
        for (lll u = y = 1, v = x = 0; a;) {
            lll q = b / a;
            swap(x -= q * u, u);
            swap(y -= q * v, v);
            swap(b -= q * a, a);
        }
        return b;
    };
    lll k1, k2;
    lll g = extgcd(m1, m2, k1, k2);
    if (normal(a1, g) != normal(a2, g))
        return {-1, -1};
    else {
        lll l = m1 / g * m2;
        lll x = a1 + modmul(modmul((a2 - a1) / g, k1, l), m1, l);
        return {x, l};
    }
}

pair<lll, lll> crt(vector<lll> a, vector<lll> m)
{
    lll mod = 1, ans = 0;
    lll n = a.size();
    rep(i, n) {
        tie(ans, mod) = crt(ans, mod, a[i], m[i]);
        if (ans == -1) return {-1, -1};
    }
    return {ans, mod};
}

pair<int, int> get(int pos, int num, vi &b)
{
    int step = 0, first = -1, second = -1;
    int n = b.size();
    for (int i = 0; i <= n + n; i++) {
        if (num == pos) {
            first = i;
            break;
        }
        num = b[num-1];
    }
    if (first == -1) return {-1, -1};
    for (int i = first+1; i <= n + n + n + n; i++) {
        num = b[num-1];
        if (num == pos) {
            second = i;
            break;
        }
    }
    return {second - first, first};
}

signed main()
{
    int n;
    cin >> n;
    vi target(n), base(n);
    rep(i, n) {
        cin >> target[i];
    }
    rep(i, n) {
        cin >> base[i];
    }
    vector<lll> a(n), m(n);
    rep(i, n) {
        auto t = get(i+1, target[i], base);
        if (t.first == -1) {
            cout << -1 << endl;
            return 0;
        }
        a[i] = (lll)t.second;
        m[i] = (lll)t.first;
    }
    //rep(i, n) cout << a[i] << " "; cout << endl;
    //rep(i, n) cout << m[i] << " "; cout << endl;

    auto t = crt(a, m);
    if (t.first == -1) {
        cout << -1 << endl;
    } else {
        cout << (int)t.first << endl;
    }

    return 0;
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[110];
int main() {
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                int ta = a[i], tb = a[j], tc = a[k];
                if (ta == tb || ta == tc || tb == tc) continue;
                if (ta + tb <= tc || ta + tc <= tb || tb + tc <= ta) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

    int Q;cin>>Q;
    ll b=0,leftsum=0,rightsum=0;
    ll cnt=0;
    priority_queue<ll> left;
    priority_queue<ll,vector<ll>,greater<ll>> right;//rightを多めに
    for(int i=0;i<Q;i++){
        int n;cin>>n;
        if(n==1){
            ll x,y;cin>>x>>y;
            b+=y;
            if(cnt==0){
                right.push(x);
                rightsum+=x;
                cnt++;
            }else if(cnt==1){
                ll r=right.top();
                if(x<r){
                    leftsum+=x;
                    left.push(x);
                }else{
                    rightsum=0;
                    right.pop();
                    
                    leftsum=r;
                    left.push(r);
                    
                    rightsum=x;
                    right.push(x);
                }
                cnt++;
            }else if(cnt%2==0){
                ll l=left.top(),r=right.top();
                if(l<=x&&x<=r){
                    rightsum+=x;
                    right.push(x);
                }else if(x<l){
                    leftsum-=l;
                    left.pop();
                    
                    rightsum+=l;
                    right.push(l);
                    
                    leftsum+=x;
                    left.push(x);
                }else{
                    rightsum+=x;
                    right.push(x);
                }
                cnt++;
            }else{
                ll l=left.top(),r=right.top();
                if(l<=x&&x<=r){
                    leftsum+=x;
                    left.push(x);
                }else if(x<l){
                    leftsum+=x;
                    left.push(x);
                }else{
                    rightsum-=r;
                    right.pop();
                    
                    leftsum+=r;
                    left.push(r);
                    
                    rightsum+=x;
                    right.push(x);
                }
                cnt++;
            }
        }else{
            ll mid,ans=0;
            if(cnt%2==0){
                mid=left.top();
                ans+=(mid)*(cnt/2)-leftsum;
                ans+=rightsum-(mid)*(cnt/2);
            }else{
                mid=right.top();
                ans+=(mid)*(cnt/2)-leftsum;
                ans+=rightsum-(mid)*(cnt/2+1);
            }
            cout<<mid<<" "<<ans+b<<endl;
        }
    }
    
}


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

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

#define MAX 100000

int a[MAX];

int main(){
  int n;
  int tmp;
  int ans;
  
  REP( i, MAX){
    a[i] = 0;
  }

  cin >> n;
  REP( i, n){
    cin >> tmp;
    ++a[tmp];
  }

  ans = 0;
  FOR( i, 0, MAX-2){
    tmp = a[i] + a[i+1] + a[i+2];
    if( tmp > ans){
      ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(100000)
import numpy as np

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])


def acinput():
    return list(map(int,input().split(" ")))




import sys
sys.setrecursionlimit(100000)

import numpy as np

directions = [[1, 0], [0, 1], [-1, 0], [0, -1]]
directions = list(map(np.array, directions))

def acinput():
    return list(map(int, input().split(" ")))

N=int(input())

if N%2==0:
    print(0.5)
else:
    print(np.ceil(N/2)/N)

    

Measured memory_bytes: 12452
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

ll n, m, d;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> d;
    cout << fixed << setprecision(15);
    if (d == 0){
        cout << 1.0 * (m - 1) / n << endl;
    }else{
        cout << 2.0 * (m - 1) * (n - d) / n / n << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int W,H,x,y,r;
        scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
        if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
                puts("Yes");
        else
                puts("No");
        return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
using namespace atcoder;
using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S{
  mint val;
  mint power;
  S(mint v = 0, mint p = 1) : val(v), power(p) {}
};

using F = int;

S op(S l, S r){
  S res;
  res.power = l.power * r.power;
  res.val = l.val*r.power + r.val;
  return res;
}

S e(){
  return S();
}

S mapping(F f, S s){
  if(f == 0) return s;
  return S((s.power-1)*inv9 * f, s.power);
}

F composition(F l, F r){
  if(l == 0) return r;
  return l;
}

F id(){
  return 0;
}


int main(){
  int n, q;
  cin >> n >> q;
  lazy_segtree<S, op, e, F, mapping, composition, id> lsg(n);
  rep(i, n){
    lsg.set(i, S(1, 10));
  }

  rep(_q, q){
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    lsg.apply(l, r, d);
    S ans = lsg.all_prod();
    cout << ans.val.val() << endl;
  }
  return 0;
}

Measured memory_bytes: 9856
import collections

def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:  f += 2
    if n != 1:  a.append(n)
    return a

A, B = cin()
A, B = min(A, B), max(A, B)
res = collections.Counter(prime_factorize(A))
keys = list(res.keys())
keys.append(1)
ans = 0
for i in keys:
    if B % i == 0:
        ans += 1
print(ans)

Measured memory_bytes: 65868