akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 10000000
int c[100005] = { 0 }, st[100005] = { 0 }, am[100005] = { 0 };
int n;
int main() {
	while (true) {
		cin >> n;
		if (n == 0) return 0;
		for (int i = 0; i < n; i++) {
			cin >> c[i];
			st[i] = am[i] = INF;
		}
		st[0] = c[0];
		am[0] = 1;
		int now = 0;
		for (int i = 1; i < n; i++) {
			if (i % 2) {
				if (st[now] == c[i]) {
					am[now]++;
				}
				else {
					if (now - 1 >= 0) {
						now--;
						am[now] += am[now + 1] + 1;
						st[now + 1] = am[now + 1] = INF;
					}
					else {
						if (st[now]) st[now] = 0;
						else st[now] = 1;
						am[now]++;
					}
				}
			}
			else {
				if (st[now] == c[i]) {
					am[now]++;
				}
				else {
					now++;
					st[now] = c[i];
					am[now] = 1;
				}
			}
		}
		int res = 0;
		for (int i = 0; i <= now; i++) {
			if (st[i] == 0) res += am[i];
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 4272
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    long long n,i,ans=0,c;
    cin>>n;
    long long a[n+2];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        c=1;
        while(a[i+1]==a[i])
        {
            c++;
            i++;
        }
        if((c%2)==1)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        n: usize,
        d: [u64; n],
    }
    let mut d = d;
    d.sort();
    println!("{}", d[n / 2] - d[n / 2 - 1]);
}

Measured memory_bytes: 6524
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	int N;
	set<int> D;
	cin >> N;
	int i, j;
	for (i = 0; i < N; i++){
		int d;
		cin >> d;
		D.insert(d);
	}
	cout << D.size() << endl;
	return 0;
}

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

int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	double ans = -1;
	int sugar = 0;
	int sw = 0;
	for (int i = 0; 100 * a*i <= f; i++) {
		for (int j = 0; 100 * b*j <= f - 100 * a*i; j++) {
			for (int t = 0; c*t <= f - 100 * a*i - 100 * b*j; t++) {
				for (int u = 0; d*u <= f - 100 * a*i - 100 * b*j - c*t; u++) {
					double wt = 100 * a*i + 100 * b*j + c*t + d*u;
					double sg = c*t + d*u;
					if ((100 * a*i + 100 * b*j)*e / 100 >= sg) {
						if (sg / wt > ans) {
							ans = sg / wt;
							sugar = c*t + d*u;
							sw = 100 * a*i + 100 * b*j + c*t + d*u;
						}
					}
				}
			}
		}
	}

	cout << sw << " " << sugar << endl;

	return 0;
}

Measured memory_bytes: 256
import re
n = int(input())
s = []
for i in range(n):
    s.append(input())
    
c = "abcdefghijklmnopqrstuvwxyz"
result = ""
for i in range(len(c)):
    thisC = c[i]
    clen = [s[j].count(c[i]) for j in range(len(s))]
    result += c[i]*min(clen)
    #print("hi",clen,result)
print(result)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;
double pi = 3.1415926535;

int main(){
    
    int r;
    cin >> r;
    
    double ans = 2 * pi * r;
    
    cout << ans << "\n";
    
    return 0;
}


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

int c[100][100];

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n, 0);
  for(int i=0; i<n; i++) cin>>a[i];
  queue<int> b;
  for(int i=0; i<n; i++) {
    for(int j=0; j<a[i]; j++) {
      b.push(i+1);
    }
  }
  for(int i=0; i<h; i++) {
    if(i%2==0) {
      for(int j=0; j<w; j++) {
	int t = b.front(); b.pop();
	c[i][j]=t;
      }
    } else {
      for(int j=w-1; j>=0; j--) {
	int t = b.front(); b.pop();
	c[i][j]=t;
      }
    }
  }
  for(int i=0; i<h; i++) {
    cout << c[i][0];
    for(int j=1; j<w; j++) {
      cout << " " << c[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (100006)
ll n,m,q,A[MAXN],B[MAXN],C[MAXN], p[MAXN], sz[MAXN];
int find(int x){return p[x]==x?x:p[x]=find(p[x]);}
void merge(int x,int y){p[find(x)]=find(y);}
void init() { FOR(i,0,MAXN-1)p[i]=i; }
int main(){
	FAST
	init();
	cin>>n>>m>>q;
	FOR(i,0,q-1){
		cin>>A[i]>>B[i]>>C[i];
	}
	if(m==n-1){
		bool ans=1;
		FOR(i,0,q-1)ans&=C[i]!=1;
		cout<<(ans?"Yes":"No")<<'\n';
		return 0;
	}
	FOR(i,0,q-1)if(C[i]==0){
		merge(A[i],B[i]);
	}
	FOR(i,0,q-1)if(C[i]&&find(A[i])==find(B[i])){cout<<"No\n";return 0;}
	ll cc=0; FOR(i,0,n-1)if(find(i)==i)++cc;
	if(m <= cc * (cc-1) / 2 + (n - cc)) cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 6748
use std::cmp::Reverse;
use std::collections::BinaryHeap;

const INF: usize = 1 << 50;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let k: usize = sc.read();
    let mut dp = vec![INF; k + 1];
    dp[0] = 0;
    let mut heap = BinaryHeap::new();
    heap.push((Reverse(0), 0));
    while let Some((_, cur_remain)) = heap.pop() {
        for i in 0..10 {
            let next_remain = (cur_remain * 10 + i) % k;
            let next_remain = if next_remain == 0 && cur_remain != 0 {
                k
            } else {
                next_remain
            };
            if dp[next_remain] > dp[cur_remain] + i {
                dp[next_remain] = dp[cur_remain] + i;
                heap.push((Reverse(dp[next_remain]), next_remain));
            }
        }
    }

    println!("{}", dp[k]);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5616
# https://atcoder.jp/contests/abc113/tasks/abc113_c
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N, M = read_ints()
data = []
for i in range(M):
    data.append(list(map(int, read().split())) + [i])

data.sort()
ans = []
cnt = [0] * (N + 1)  # それぞれの出現回数をカウントする →x番目を取得するため
for p, y, i in data:
    cnt[p] += 1
    x = cnt[p]
    ans.append((i, str(p).zfill(6) + str(x).zfill(6)))

ans.sort()
for _, a in ans:
    print(a)


Measured memory_bytes: 80220
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

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

const int maxn = 1e5 + 5;

int R, C;
int n;
vector<pii> vec[4];

bool in_border(pii p)
{
    return (p.fi == 0) || (p.fi == R) || (p.se == 0) || (p.se == C);
}

void push_in(int k, pii p)
{
    if(p.fi == 0) vec[0].push_back(pii(p.se, k));
    else if(p.se == C) vec[1].push_back(pii(p.fi, k));
    else if(p.fi == R) vec[2].push_back(pii(p.se, k));
    else if(p.se == 0) vec[3].push_back(pii(p.fi, k));
}

void read_input()
{
    cin >> R >> C;
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        pii p1, p2;
        cin >> p1.fi >> p1.se >> p2.fi >> p2.se;
        if(in_border(p1) && in_border(p2))
        {
            push_in(i, p1);
            push_in(i, p2);
        }
    }
}

void solve()
{
    sort(vec[0].begin(), vec[0].end());
    sort(vec[1].begin(), vec[1].end());
    sort(vec[2].rbegin(), vec[2].rend());
    sort(vec[3].rbegin(), vec[3].rend());

    stack<int> stk;
    for(int i = 0; i < 4; ++i)
        for(auto&to: vec[i])
        {
            int val = to.se;
            if(!stk.empty() && stk.top() == val)
                stk.pop();
            else stk.push(val);
        }
    if(stk.empty()) cout << "YES\n";
    else cout << "NO\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 2520
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll ans;
  ll x,y;
  ll A,B;
  cin >> A >> B;
  if(B%A==0){
    cout << A+B << endl;
  }else{
    cout << B-A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int K = cin.nextInt();

        int odd = K / 2;
        int even = K - odd;
        Write(even * odd);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#import numpy as np
N = int(input())
#x1,y1,x2,y2= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
S= str(input())
x=0
max=0
for i in S:
    if i == 'I':
        x+=1
        if x>=max:
            max=x
    elif i== 'D':
        x-=1

print(max)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<bool> sieve;
vector<int> primes;

void eratosthenes(int maximum){
	sieve = vector<bool>(maximum+1);
	sieve[0]=sieve[1]=false;
	for(int i=2; i<sieve.size(); i++) sieve[i]=true;
	for(int j=4; j<sieve.size(); j+=2) sieve[j]=false;
	for(int i=3; 2*i<sieve.size(); i++){
		if(!sieve[i]) continue;
		for(int j=2*i; j<sieve.size(); j+=i) sieve[j] = false;
	}
}

void get_primes(int maximum){
	if(sieve.size() < maximum) eratosthenes(maximum);
	for(int i=2; i<sieve.size(); i++){
		if(sieve[i]) primes.push_back(i);
	}
}

map<int, int> get_factors(int x){
	map<int, int> factors;
	for(int p: primes){
		if(p*p>x) break;
		while(x%p==0){
			factors[p]++;
			x /= p;
		}
	}
	if(x>1) factors[x]++;
	return factors;
}

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

	get_primes(55555);

	vector<int> ans;
	for(int i=0; i<primes.size(); i++){
		if(primes[i]%5==1) ans.push_back(primes[i]);
	}

	for(int i=0; i<N; i++){
		cout << ans[i] << (i==N-1?'\n':' ');
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <random>
#include <map>
#include <string>

using namespace std;

typedef long long ll;
typedef long double ld;

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

const ll SIZE = 3e5 + 10, INF = 1e9 - 1, K = 400;


int main()
{
    fastInp;

    ll n, m, h, w;
    cin >> n >> m >> h >> w;
    ll s = (h * w);
    if (h * w == 1) {
        cout << "No";
        return 0;
    }
    ll vl = INF / (h * w - 1);
    ll c = vl * (h * w - 1) + 1;

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i % h == (h - 1) && j % w == (w - 1)) {
                cnt -= c;
            }
            else {
                cnt += vl;
            }
        }
    }

    if (cnt <= 0) {
        cout << "No";
    }
    else {
        cout << "Yes\n";
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i % h == (h - 1) && j % w == (w - 1)) {
                    cout << -c << " ";
                }
                else {
                    cout << vl << " ";
                }
            }
            cout << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3612
#https://atcoder.jp/contests/abc119/tasks/abc119_c
#2019-02-24
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]


ans = float("inf")
# 00 なら使わない、 01 ならAをつくる、10 ならBをつくる、11ならCをつくる　
for i in range(1 << 2*N):
    cost = float("inf")
    A_hon = 0
    B_hon = 0
    C_hon = 0
    A_zai = 0
    B_zai = 0
    C_zai = 0
    for k in range(N):
        if i & (1<<(2*k)) and i & (1<< (2*k)+1):
            C_hon += 1
            C_zai += l[k]
        elif i & (1<<(2*k)+1):
            B_hon += 1
            B_zai += l[k]
        elif i & (1<<(2*k)):
            A_hon += 1
            A_zai += l[k]
    if A_hon * B_hon * C_hon >0:
       cost = 10*(A_hon - 1)+ abs(A_zai - A)+10*(B_hon - 1)+ abs(B_zai - B)+ 10*(C_hon - 1)+ abs(C_zai - C)
    ans = min(cost, ans)
print(ans)

Measured memory_bytes: 3064
import           Control.Monad
import           Data.List
import Prelude


main = do
  n  <- read <$> getLine
  rs <- replicateM n getPair
  print $ solve rs

getPair = (\(x : y : _) -> (x, y)) . fmap read . words <$> getLine

solve :: [(Int, Int)] -> Int
solve xs = sumPair (foldl' getNextVotes (1, 1) xs)

sumPair :: (Int, Int) -> Int
sumPair = uncurry (+)
-- 現在の投票数と次の投票数の比から、次の投票数を返却する
getNextVotes ::  (Int, Int) -> (Int, Int) -> (Int, Int)
getNextVotes (a, b) (x, y) =  (n * x,  n * y) where
  n = max (a `ceilDiv` x) (b `ceilDiv` y)

ceilDiv :: Int -> Int -> Int
ceilDiv x y = x `div` y + (if x `mod` y == 0 then 0 else 1)


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#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--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
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;}
//head

int main(void){
    int n;
    cin>>n;
    VI cnt(n+1),a(n);
    rep(i,0,n){
        cin>>a[i];
        ++cnt[a[i]];
    }
    ll ans=0;
    rep(i,1,n+1){
        ans+=1ll*cnt[i]*(cnt[i]-1)/2;
    }
    rep(i,0,n){
        cout<<ans-(cnt[a[i]]-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 4096
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}
int main()
{
    ll n;
    cin>>n;
    multiset< pair<ll,ll> > s;
    while(n--)
    {
        ll a,b;
        cin>>a>>b;
        s.insert(mp(b,a));
    }
    ll sum=0;
    pair<ll,ll> p;
    multiset< pair<ll,ll> >::iterator itr;
    for(itr=s.begin();itr!=s.end();++itr)
    {
        //cout<<itr->first<<" "<<itr->second<<endl;
        if(sum+(itr->second)>itr->first)
        {
            //cout<<itr->first<<" "<<itr->second<<endl;
            //cout<<sum<<endl;
            cout<<"No"<<endl;
            return 0;
        }
        sum+=itr->second;
    }
    cout<<"Yes"<<endl;
    return 0;
    
}


Measured memory_bytes: 12800
#include <iostream>
using namespace std;
int main()
{
    int a,b,sum,sub,mult;
    cin>>a>>b;
    sum=a+b;
    sub=a-b;
    mult=a*b;
    if (mult>sum && mult>sub)
        cout<<mult<<endl;
    else if (sum>mult && sum>sub)
        cout<<sum<<endl;
    else cout<<sub<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
	int x,y,z,i,j,k,m;
	char a[1001],b[1001],c[1001];
	char rep[]="replace";
	char rev[]="reverse";
	char pri[]="print";
	scanf("%s",a );
	scanf("%d",&m );
	for(i=0;i<m;i++){
		scanf("%s %d %d",b,&x,&y );
		z=y+1;
		if(strstr(b,rep)!=NULL){
			scanf("%s",c);
			strncpy(a+x,c,y+1-x);
		}
		else if(strstr(b,rev)!=NULL){
			for(j=0;y>=x;y--,j++){
				c[j]=a[y];
				if(y==x)c[j+1]='\0';
			}strncpy(a+x,c,z-x);
		}
		else if(strstr(b,pri)!=NULL){
			strncpy(c,a+x,z-x);
			c[z-x]='\0';
			printf("%s\n",c );
		}
	}

	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

void trace(int A[], int N){
    int i;
    for (i = 0; i < N; i++){
        if(i > 0)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

int main(){
    int N, i, j;
    int A[100];

    cin >> N;
    for (int i = 0; i < N; i++) //i = 0
        cin >> A[i];

    trace(A, N);
    insertionSort(A, N);
    
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vi a;

int main(){
	cin>>n>>m;
	a=vi(m);
	for(auto &i:a) cin>>i;
	sort(a.begin(),a.end());
	vi b(m-1);
	for(int i=0;i<m-1;i++) b[i]=a[i+1]-a[i];
	sort(b.rbegin(),b.rend());
	int res=a[m-1]-a[0];
	for(int i=0;i<min(m,n)-1;i++) res-=b[i];
	cout<<res<<endl;
}

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

int main() {
 int N, X, T;
 cin >> N >> X >> T;
  
  int n = N/X;
  double c = N%X;
  if(c==0.0){
    cout << T*n << endl;
  }
  else{
    cout << (T*n)+T << endl;
  }
}  
 


Measured memory_bytes: 3632
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(min(A, X//500) + 1):
  for j in range(min(B, (X - i*500)//100) + 1):
    if C*50 >= X - i*500 - j*100:
      count = count + 1
      
print(count)

Measured memory_bytes: 3064
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();

        System.out.println(solve(K));

        sc.close();
    }

    static int solve(int K) {
        int[] distances = new int[K];
        Arrays.fill(distances, -1);

        Deque<Element> deque = new ArrayDeque<>();
        deque.offerLast(new Element(1, 0));

        while (true) {
            Element head = deque.pollFirst();
            if (distances[head.index] != -1) {
                continue;
            }

            distances[head.index] = head.distance;
            if (head.index == 0) {
                return distances[head.index] + 1;
            }

            int nextInc = (head.index + 1) % K;
            if (distances[nextInc] == -1) {
                deque.offerLast(new Element(nextInc, head.distance + 1));
            }

            int nextMul = head.index * 10 % K;
            if (distances[nextMul] == -1) {
                deque.offerFirst(new Element(nextMul, head.distance));
            }
        }
    }
}

class Element {
    int index;
    int distance;

    Element(int index, int distance) {
        this.index = index;
        this.distance = distance;
    }
}

Measured memory_bytes: 27348
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        boolean band = false;
        n = sc.nextInt();
        for (int i=1; i<10; i++){
            for (int j=1; j<10; j++){
                if (i*j == n){
                    band = true;
                    i = 10;
                    j = 10;
                }
            }
        }
        if (band == true){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22100
n = int(raw_input())
lst = []
#store all the cards
for i in ["S","H","C","D"]:
	for j in xrange(1,14):
		lst.append("{0} {1}".format(i,j))
#discard the given cards
for i in range(n):
	a = raw_input()
	lst.remove(a)
#print the result
for i in range(len(lst)):
	print lst[i]

Measured memory_bytes: 6424
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main(void) {
    int N;cin>>N;
    vector<int> score(N);
    int result = 0;
    for (int i = 0; i < N; i++) {
        cin>>score[i];
        result += score[i];
    }
    if (result % 10 > 0) {
        cout << result << endl;
        return 0;
    }
    sort(all(score));

    // 一桁目がresultとは異なる整数を集める
    vector<int> candidate;
    // 一桁目がresultと同じ整数を集める
    vector<int> same;
    int target_index = result % 10;
    for (int i = 0; i < N; i++) {
        if (score[i] % 10 == target_index) same.push_back(score[i]);
        else candidate.push_back(score[i]);
    }
    sort(all(candidate));
    sort(all(same));
    if (candidate.size() > 0) cout << result - candidate.at(0) << endl;
    else {
        if (result % 10 == 0) cout << 0 << endl;
        else cout << result - same.at(0) - same.at(0) << endl;
    }


    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = [0]*N
for _ in range(N):
    A[_] = int(input())

c = Counter(A)

hoge = sorted(A,reverse=True)
if c[hoge[0]] == 1:
    for _ in range(N):
        if A[_] == hoge[0]:
            print(hoge[1])
        else:
            print(hoge[0])
else:
    for _ in range(N):
        print(hoge[0])

Measured memory_bytes: 21092
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

K = int(read())

l = [
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2,
    2, 5, 4, 1, 4, 1, 51
]
print(l[K - 1])


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

using namespace std;

int main()
{
    int a,b,c;
    int flag=0;
    cin>>a>>b>>c;
    if(a==b)
    {
        if(a!=c) flag=1;
    }
    else
    {
        if((a==c) || (b==c)) flag=1;
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
j,p[1<<20],n;main(i){for(;++i<999;)for(j=i;!p[i]&(j+=i)<1<<20;)p[j]=1;for(;scanf("%d",&n),j=0,n;printf("%d\n",j))for(i=1;++i<=n/2;)j+=!p[i]&!p[n-i];exit(0);}

Measured memory_bytes: 0
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
pii A[200];//firstは行secondを列とする
int dp[200][200];//dp[i][j]:=Ai...Ajの最小スカラー積とする
int n;
int f[200][200];//最適な括弧を挿入する位置
void solve(){
	for(int i =0;i < n;i++){
		for(int j =0;j < n;j++){
			if(i==j)dp[i][j]=0;
			else dp[i][j]=INF;
		}
	}
	
	for(int k =1;k <n;k++){//鎖の数
		for(int i =0;i <n-k;i++){//どこから始めるか
			for(int j =i;j <i+k;j++){//どこに括弧を挟むか
				int tmp =A[i].first*A[j].second*A[i+k].second;
				if(dp[i][i+k] >dp[i][j]+dp[j+1][i+k]+tmp){
					dp[i][i+k]=dp[i][j]+dp[j+1][i+k]+tmp;
					f[i][i+k] =j;
				}
			}
		}
	}
}

void print(int i,int j){//解を表示する
	if(i==j){
		cout <<"A"<<i;
	}else{
		cout <<"(";
		print(i,f[i][j]);
		print(f[i][j]+1,j);
		cout <<")";
	}
}


int main(){
	cin>>n;
	for(int i =0;i < n;i++){
		cin>>A[i].first>>A[i].second;
	}
	solve();
	cout <<dp[0][n-1]<<endl;
	//print(0,n-1);
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  string S;
  cin >> N >> S;
  int ans = -1;
  REPS(i, N - 1) {
    int curAns = 0;
    vec< vec< bool > > flg(2, vec< bool >(26, false));
    REP(j, i) { flg[0][S[j] - 'a'] = true; }
    FOR(j, i, N) { flg[1][S[j] - 'a'] = true; }
    REP(j, 26) {
      if (flg[0][j] && flg[1][j])
        curAns++;
    }
    chmax(ans, curAns);
  }
  print(ans);
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n, m;
	cin >> n >> m;
	v1 a(n+1, 0);
	v1 b(n+1, 0);
	rep(i, m){
		int p;
		string s;
		cin >> p >> s;
		if(s == "AC"){
			a[p]++;
		}else if(s == "WA" && a[p] == 0){
			b[p]++;
		}
	}
	int ac = 0;
	int wa = 0;
	rep(i, n){
		if(a[i+1] != 0){
			ac++;
			wa += b[i+1];
		}
	}
	cout << ac << " " << wa << endl;
}


Measured memory_bytes: 4016
Module Module1

    Sub main()
        Dim user1 = Split(Console.ReadLine(), " ")
        Dim user2 = Console.ReadLine().Split(" ")
        Dim typeF As Long = user1(0)
        Dim buyNum As Long = user1(1)
        Dim fruits As Long()
        Dim total As Long = 0

        fruits = Array.ConvertAll(user2, Function(i As String) CLng(i))
        Array.Sort(fruits)

        For i = 0 To buyNum - 1
            total = total + fruits(i)
        Next

        Console.WriteLine(total)
    End Sub
end module

Measured memory_bytes: 28592
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

mod=10**9+7
n=int(input())
a=lmp()
l=[[0,0] for i in range(60)]
for i in range(n):
    b=format(a[i],"060b")
    for j in range(60):
        if b[j]=="0":
            l[j][0]+=1
        else:
            l[j][1]+=1
ans=0
for i in range(60):
    ans+=(l[i][0]*l[i][1]*(2**(59-i)))%mod
print(ans%mod)

Measured memory_bytes: 129332
N,M=map(int,input().split())
a=[0]*M
for i in range(M):
  a[i]=int(input())
dp=[1]*(N+1)
mod=10**9+7
if M >=2:
  j=0
  if a[j]==1:
    j=j+1
    dp[1]=0
  for i in range(2,N+1):
    if j==0:
      if i==a[j]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
    else:
      if i==a[j] and i-1 !=a[j-1]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      elif i==a[j] and i-1 ==a[j-1]:
        dp[N]=0
        break
      elif i-2 ==a[j-1]:
        dp[i]=dp[i-1]
      elif i-1 ==a[j-1]:
        dp[i]=dp[i-2]
      elif i-1 !=a[j-1] and i-2 !=a[j-1]:
        dp[i]=(dp[i-1]+dp[i-2])%mod
elif M==0:
  for i in range(2,N+1):
    dp[i]=(dp[i-1]+dp[i-2])%mod
else:
  for i in range(2,N+1):
    if i==a[0]:
      dp[i]=0
    elif i-2==a[0]:
      dp[i]=dp[i-1]
    elif i-1==a[0]:
      dp[i]=dp[i-2]
    else:
      dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)

Measured memory_bytes: 45272
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const M = Number(input[0][0]);

  return 24 - M + 24;
};

console.log(main(read()));


Measured memory_bytes: 29620
# https://atcoder.jp/contests/abc126/tasks/abc126_c
# C - Dice and Coin

import math

n, k = list(map(int, input().split()))

# 全パターン
step_1_p_list = [1 / n for x in range(1, n+1)]

# サイコロを降る回数
step_2_p_list = []

for saikoro in range(1, n+1):
    if saikoro >= k:
        step_2_p_list.append(1)
        continue

    a, b = math.modf(math.log2(k/saikoro))
    if a == 0:
        must_win_n = b
    else:
        must_win_n = b + 1
    must_win_n = int(must_win_n)
    # sprint('saikoro = {}: ({}, {}) -> {}'.format(saikoro, a, b, must_win_n))
    # print('{}: must_win_n = {}'.format(saikoro, must_win_n))
    step_2_p_list.append((1/2) ** must_win_n)

# print('step_1: {}'.format(step_1_p_list))
# print('step_2: {}'.format(step_2_p_list))

p_list = []

for step_1_p, step_2_p in zip(step_1_p_list, step_2_p_list):
    p_list.append(step_1_p * step_2_p)

# print('p_list: {}'.format(p_list))
ans = sum(p_list)
print(ans)


Measured memory_bytes: 10264
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l,r=LI()

  ans=[]
  for i in range(l,min(l+2020,r+1)):
    for j in range(i+1,min(l+2020,r+1)):
      ans.append((i*j)%2019)

  ans.sort()

  return ans[0]

print(main())


Measured memory_bytes: 85992
#include<stdio.h>

int main(){
    long long a,b,c,k;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);

    if(k <= a)printf("%lld\n",k);
    else if(k <= (a + b))printf("%lld\n",a);
    else if((k - (a + b)) <= c)printf("%lld\n",a - (k - (a + b)));
    else printf("%lld\n",a - c);


    return 0;
}

Measured memory_bytes: 1736
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int forc = 0;
  int twoc = 0;
  
  rep(i,n){
    if(!(a[i]%4))forc++;
    else if(!(a[i]%2))twoc++;
  }
  int kisu = n - forc - twoc;
  //cout << twoc << " " << forc << " " << kisu << endl;
  if(min(1,twoc)+kisu<=forc+1) cout << "Yes" << endl;
  else cout << "No" << endl;
}




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

int main(){
    ll n;
    cin >> n;
    P a[n];
    rep(i,n) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a,a+n);
    ll ans = 0;
    set<ll> s;
    s.insert(n); s.insert((ll)-1);
    for(ll i = 0; i < n; i++){
        s.insert(a[i].second);
        auto itr = s.find(a[i].second);
        auto jtr = s.find(a[i].second); 
        itr++; jtr--;
        ans += (*itr-a[i].second)*(a[i].second-*jtr)*(i+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
def knapsack(val,wt,n,k):
    b = [[0 for _ in range(k+1)]for _ in range(n+1)]
    for i in range(n+1):
        for j in range(k+1):
            if j==0 or i==0:
                b[i][j] = 0
            elif wt[i-1]<=j:
                b[i][j] = max(val[i-1]+b[i-1][j-wt[i-1]],b[i-1][j])
            else:
                b[i][j] = b[i-1][j]
    return b[n][k]
from sys import stdin
input = stdin.readline
n,k = list(map(int,input().split()))
val,wt = [],[]
for _ in range(n):
    x,y = list(map(int,input().split()))
    val.append(y)
    wt.append(x)
p = knapsack(val,wt,n,k)
print(p)

Measured memory_bytes: 171912
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int n;
    cin>>n;
    map<int,int> bou;
    rep(i,n){
        int a;
        cin>>a;
        bou[-1*a]++;//大きい順に取り出すため
    }
    long long ans=1;
    int count=0;
    for(auto a:bou){
        int l=-1*a.first,k=a.second;
        while(k>=2 && count<2){
            ans*=l;
            k-=2;
            count++;
        }
        if(count==2) break;
    }
    if(count==2) cout<<ans<<endl;
    else cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int k, x;
	cin >> k >> x;

	bool ok = 500 * k >= x;
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

typedef vector<vector<ll>> Mat;
ll n;

Mat & mul(Mat &ret,Mat A){
    for(auto &i:ret){
        for(auto &t:i){t=0;}
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                ret[i][k]+=A[i][j]*A[j][k]%MOD;
            }
        }
    }
    for(auto &i:ret){
        for(auto &t:i){t%=MOD;}
    }
    return ret;
}

Mat & mul(Mat &ret,Mat A,Mat &B){
    for(auto &i:ret){
        for(auto &t:i){t=0;}
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                ret[i][k]+=A[i][j]*B[j][k]%MOD;
            }
        }
    }
    for(auto &i:ret){
        for(auto &t:i){t%=MOD;}
    }
    return ret;
}


int main(){
    ll k;
    cin>>n>>k;
    Mat edge(n,vector<ll>(n));
    Mat ans(n,vector<ll>(n,0));
    for(int i=0;i<n;i++){ans[i][i]=1;}
    for(auto &i:edge){
        for(auto &t:i){cin>>t;}
    }
    while(k>0){
        if(k&1){mul(ans,ans,edge);}
        mul(edge,edge);
        k>>=1;
    }
    ll ret=0;
    for(auto &i:ans){
        for(auto &t:i){ret+=t; ret%=MOD;}
    }
    cout<<ret%MOD<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
nandm = input().split()
numlist = input().split()
N = int(nandm[0])
M = int(nandm[1])
if N >= M:
    print(0)
else:
    intlist = [int(num) for num in numlist]
    intlist.sort()
    subtract = [intlist[i + 1] - intlist[i] for i in range(len(intlist) - 1)]
    subtract.sort()
    print(sum(subtract[:(M - N)]))

Measured memory_bytes: 14736
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int mod = 1000000007;

int main(){
    ll N,C;cin>>N>>C;
    ll D[C][C];
    for(ll i=0;i<C;i++){
        for(ll j=0;j<C;j++){
            cin>>D[i][j];
        }
    }
    ll c[N][N];
    for(ll i=0;i<N;i++){
        for(ll j=0;j<N;j++){
            cin>>c[i][j];
        }
    }
    vector<vector<ll>> color(C,vector<ll>(3,0));
    for(ll i=0;i<C;i++){
        for(ll x=0;x<N;x++){
            for(ll y=0;y<N;y++){
                if((x+y)%3==0){
                    color[i][0]+=D[c[x][y]-1][i];
                }else if((x+y)%3==1){
                    color[i][1]+=D[c[x][y]-1][i];
                }else{
                    color[i][2]+=D[c[x][y]-1][i];
                }
            }
        }
    }    
    // for(ll i=0;i<C;i++){
    //     for(ll j=0;j<3;j++){
    //         cout<<", color:"<<i<<", mod:"<<j<<", cost:"<<color[i][j];
    //     }
    //     cout<<endl;
    // }
    ll res=999999999999;
    for(ll i=0;i<C;i++){
        for(ll j=i+1;j<C;j++){
            for(ll k=j+1;k<C;k++){
                for(ll o=0;o<6;o++){
                    ll zero,one,two;
                    switch (o)
                    {
                    case 0:
                        zero = i;one = j;two = k;
                        break;
                    case 1:
                        zero = i;one = k;two = j;
                        break;
                    case 2:
                        zero = j;one = i;two = k;
                        break;
                    case 3:
                        zero = j;one = k;two = i;
                        break;
                    case 4:
                        zero = k;one = j;two = i;
                        break;
                    case 5:
                        zero = k;one = i;two = j;
                        break;
                    default:
                        break;
                    }
                    ll tmp=color[zero][0]+color[one][1]+color[two][2];
                    res = min(res,tmp);
                    // cout<<tmp<<endl;
                }
            }
        }
    }
    cout<<res<<endl;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  
  rep(i, 0, n-2){
    if(s[i] == 'A')
      if(s[i+1] == 'B' && s[i+2] == 'C')
        cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
  
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s;
    ll k;
    cin >> s >> k;

    for (int i = 0; i < min((ll)s.size(), k); i++)
    {
        if (s[i] != '1')
        {
            cout << s[i] << endl;
            return 0;
        }
    }

    cout << '1' << endl;
}


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

int main(int argc, char const *argv[])
{
	int v[3], ans1=0, ans2=0, ans3=0, ans4=0;
	while (1)
	{
		cin >> v[0] >> v[1] >> v[2];
		sort(v, v+3);
		if(v[2] >= v[0] + v[1]) break;
		++ans1;
		if(v[2]*v[2] == v[0]*v[0] + v[1]*v[1])  ++ans2;
		else if(v[2]*v[2] < v[0]*v[0] + v[1]*v[1])  ++ans3;
		else ++ans4;
	}
	cout << ans1 << " " << ans2 << " " << ans3 << " " << ans4 << endl;
	return 0;
}


Measured memory_bytes: 3108
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s1,s2;
	cin>>s1>>s2;
	cout<<s2<<s1;
    return 0;
}
//.........

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

using namespace std;

int main(){
  char s[50];
  int n;
  cin >> n >> s;
  int ans = 0;
  for(int i=0;i<n-2;i++){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      ans ++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256