akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	cout << ( K == 1 ? 0 : N - K ) << endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    string s;
    long k;
    cin >> s >> k;
    char prev = '\0';
    long one=0, two=0, len=s.size();
    bool row2 = false, all = true;
    for (long i=0; i<2*len; i++) {
        char c = s[i % len];
        if (row2 || prev != c) {
            if (prev != '\0' && prev != c) all = false;
            prev = c;
            row2 = false;
            continue;
        }
        if (i < len) one++;
        else two++;
        row2 = true;
    }
    if (all) cout << one * (k - k / 2) + two * (k / 2) << '\n';
    else cout << one + two * (k - 1) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int i,count=0;
  for(i=100;i>0;i--){if(a%i==0&&b%i==0)count++;if(count==k)break;}
  cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a;
    ll b=0,c=0,d=0;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%4==0){
            b++;
        }else if(a%2==0){
            c++;
        }else{
            d++;
        }
    }
    if(c==0){
        if(b+1>=d)cout << "Yes"<<endl;
        else cout << "No" <<endl;
    }else{
        if(b>=d)cout << "Yes"<<endl;
        else cout <<"No" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
using namespace std;
template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ?
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ?
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ?
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}



int main() {
	while (1) {
		int w, d; cin >> w >> d;
		if (!w)break;
		vector<int>ws;
		vector<int>ds;
		if (w >= d) {
			for (int i = 0; i < w; ++i) {
				int a; cin >> a; ws.push_back(a);
			}
			for (int i = 0; i <d; ++i) {
				int a; cin >> a; ds.push_back(a);
			}
		}
		else {
			for (int i = 0; i < w; ++i) {
				int a; cin >> a; ds.push_back(a);
			}
			for (int i = 0; i <d; ++i) {
				int a; cin >> a; ws.push_back(a);
			}
		}
		assert(ws.size() >= ds.size());
		
		
		vector<int>perm;
		for (int i = 0; i < ws.size(); ++i) {
			perm.push_back(i);
		}
		int finans = 500;


		do {
			int nans = 0;
			for (int i = 0; i < ds.size(); ++i) {
				if (ds[i] == ws[perm[i]]) {
					nans += ds[i];
				}
				else {
					nans += ds[i] + ws[perm[i]];
				}
			}
			for (int i = ds.size(); i < ws.size(); ++i) {
				nans += ws[perm[i]];
			}
			finans = min(finans, nans);

		} while (next_permutation(perm.begin(), perm.end()));
		cout << finans << endl;

	}

	return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define pll pair<long long,long long>
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='?')s[i]='D';
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3728
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <unordered_set>
using namespace std;
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define long long long
long  pw(long  x, long  y){long  ans = 1;for(long  i = 0; i < y; i++){ans = ans * x;}return ans;}
long  factorial(long  x){long  ans = 1; for(int i = 1 ;i < x+1; i++){ans = ans *i;}return ans;}
long  combination(long  x,long  y){return factorial(x)/factorial(y)/factorial(x-y);}
long  permutation(long  x, long  y){return factorial(x)/factorial(x-y);}
#define TimeCount1    auto chrono_start = std::chrono::system_clock::now();
#define TimeCount2   auto chrono_end = std::chrono::system_clock::now();std::cout << "Elapsed time(C++):" << std::chrono::duration_cast<std::chrono::milliseconds>(chrono_end - chrono_start).count() << "[ms]" << std::endl;

//#include "./printer.hpp"

int main(){

	long n;
	cin >> n;
	long b,c;
	b = c = 0;
	for(long i = 0; i < n; i++){
		long a;
		cin >> a;
		b += a;
		c+= a * a;
	}
	long x = (b)/n;
	long y = b/n + 1;
	cout << min(n * x * x - 2 * b  * x + c,
		n*y*y - 2*b*y + c) << endl;
	return 0;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    ll x, y, a, b, c, res;
    res=0;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c), ans(x+y+c);
    rep(i,a) cin >> p.at(i);
    rep(i,b) cin >> q.at(i);
    rep(i,c) cin >> r.at(i);
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    rep(i,x)ans.at(i)=p.at(i);
    rep(i,y)ans.at(i+x)=q.at(i);
    rep(i,c)ans.at(i+x+y)=r.at(i);
    sort(ans.rbegin(), ans.rend());

    rep(i,x+y){
        res+=ans.at(i);
    }
    cout << res << endl;

}


Measured memory_bytes: 4736
N = int(input())
x = [0]*N
u = [0]*N
ans = 0
for i in range(N):
  x[i], u[i] = input().split()
  x[i] = float(x[i])
  if u[i] == "BTC":
    x[i] = x[i]*380000.0

print(sum(x))

Measured memory_bytes: 3060
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_055_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(3).
    01 tmpN   PIC 9(3).
    01 tmp    PIC 9(6).
    01 ans    PIC X(6).

    01 ZS     PIC Z(7).
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    DIVIDE 15 INTO N GIVING tmpN.

    COMPUTE tmp = 800 * N - tmpN * 200

    MOVE tmp TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<ll> v(n);
    REP(i,n)cin>>v[i];
    ll cnt=0;
    vector<ll> w(n);
    REP(i,n)if(v[i]==i+1)w[i]=1;
    REP(i,n-1){
        if(w[i]==1){
            w[i]=0;
            w[i+1]=0;
            cnt++;
        }
    }
    if(w[n-1]==1){
        w[n-1]=0;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A.begin(),A.end());
    int ans = 2e9;
    for(int i=0;i+K-1<N;i++) ans = min(ans,A[i+K-1]-A[i]);
    cout << ans << "\n";    
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
using namespace std;

int main(void){
    CIN(string, s);
    int ans = 0;
    FOR(i, s.size()-2){
        int a = stoi(s.substr(i, 3));
        if(abs(a - 753) < abs(ans - 753)) ans = a;
    }
    
    COUT(abs(ans - 753));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    string S;
    cin >> S;

    for (int i = 0; (i < 3); ++i) {
        if (S[i] == '1')
            S[i] = '9';
        else if (S[i] == '9')
            S[i] = '1';
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
module Main where

import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import qualified Data.ByteString.Char8         as BS

import Data.Bits

main :: IO ()
main = do
  n <- readLn :: IO Int
  x <- VU.reverse . VU.unfoldrN n BS.uncons <$> BS.getLine
  let x' = mkBit x
  let xs = [ complementBit x' i | i <- reverse [0..n-1] ]
  mapM_ (print . f) xs

f :: Integer -> Integer
f = g 0
  where
    g :: Integer -> Integer -> Integer
    g c 0 = c
    g c x = g (c+1) (x `mod` fromIntegral (popCount x))

mkBit :: VU.Vector Char -> Integer
mkBit = VU.ifoldl' (\bit i v -> if v == '1' then setBit bit i else bit) zeroBits


Measured memory_bytes: 25280
N = int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
s = num2alpha(N)
print(s.lower())

Measured memory_bytes: 9192
<?php
$n = (int)trim(fgets(STDIN));
fscanf(STDIN, "%d %d", $d, $x);

$total = 0;
for ($i = 0; $i < $n; $i++) {
    $a = (int)trim(fgets(STDIN));
    $total += 1;
    $total += (int)(($d - 1) / $a);
}

$total += $x;

echo $total . PHP_EOL;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*Sを反転させたものを、前から順にdream,dreamer,erase,eraserのいずれか
を反転させたもので切っていき、分割し切れたらok
*/
int main(){
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  vector<string> d = {"dream","dreamer","erase","eraser"};
  for(int i = 0;i<4;i++){
      reverse(d[i].begin(),d[i].end());
  }
  bool flag1 = true;//Sを分割し切れるか
  
  for(int i = 0;i<S.size();){//前から順に見ていって,dのいずれかで切れたらflag2をtrueに
      bool flag2 = false;//dのいずれかで切れるか
      for(int j = 0;j<4;j++){
          if(S.substr(i,d[j].size()) == d[j]){
              i += d[j].size();
              flag2 = true;
          }
        }
      if(!flag2){
          flag1 = false;
          break;
       }
     }
  if(flag1) cout << "YES" <<endl;
  else cout << "NO" << endl;
  }

Measured memory_bytes: 512
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	a, b := make([]int, N+1), make([]int, N+1)
	for i := 1; i < N+1; i++ {
		a[i], _ = strconv.Atoi(read())
	}

	for i := N; 0 < i; i-- {
		if N/2 < i {
			b[i] = a[i]
		} else {
			for j := i; j < N+1; j = j + i {
				cnt += b[j]
			}
			if cnt%2 == a[i] {
				b[i] = 0
			} else {
				b[i] = 1
			}
			cnt = 0
		}
	}
	var sum int
	for i := 1; i < N+1; i++ {
		sum += b[i]
	}
	if sum == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(sum)
		for i := 1; i < N+1; i++ {
			if b[i] == 1 {
				fmt.Printf("%d ", i)
			}
		}
		fmt.Printf("\n")
	}
}

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

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	
	printf("%d\n", (n - 2) * 180);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=3e5+5;
const ll mod=1e9+7;
ll ni[w],fac[w];
ll quick(ll x,ll y)
{
    ll ans=1;
    while(y)
    {
        if(y&1)
            ans=ans*x%mod;
        x=x*x%mod;
        y/=2;
    }
    return ans;
}
ll C(ll n,ll m)
{
    return fac[n]*ni[m]%mod*ni[n-m]%mod;
}
int main()
{
    int i,j;
    ll n,m;
    cin>>n>>m;
    fac[0]=1,fac[1]=1;
    for(i=2;i<=n;i++)
        fac[i]=fac[i-1]*i%mod;
    ni[n]=quick(fac[n],mod-2);
    for(i=n-1;i>=0;i--)
        ni[i]=ni[i+1]*(i+1)%mod;
    m=min(m,n-1);
    ll ans=0;
    for(i=0;i<=m;i++)
        ans+=C(n,i)*C(n-1,n-i-1)%mod,ans%=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,b,a[100005];
	while(~scanf("%d",&n))
	{for(i=0;i<n;i++)
	 scanf("%d",&a[i]);
	 sort(a,a+n);
	 printf("%d\n",a[n/2]-a[n/2-1]);
	}
}

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

using namespace std;


int main()
{
	int N,K;
	int h;
	vector<int> hs;

	cin >> N >> K;

	for (int n = 0; n < N; n++) {
		cin >> h;
		hs.push_back(h);
	}

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

	int ans = 1e9;
	int dif;
	for (int ti = 0; ti <= N - K; ti++) {
		dif = hs[ti + K - 1] - hs[ti];
		if (dif < ans) ans = dif;
	}


	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<string> s(N);
	vector<int> t(N);
	string X;
	for (int i = 0; i < N; ++i) {
		cin >> s[i] >> t[i];
	}
	cin >> X;

	int ans = 0;
	int i = find(s.begin(), s.end(), X) - s.begin();
	for (++i ; i < N; ++i) {
		ans += t[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N= 1e5+5;
int t, n,m,k;
string str;

int32_t main()
{
	IOS;
	cin>>str;
	if(str[0]=='7' ||str[1]=='7' ||str[2]=='7' ){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3640
import heapq
inf=float("inf")


def prim():
    color=["white" for _ in range(n+1)]
    D=[inf for _ in range(n+1)]
    M=[[] for _ in range(n+1)]

    for u,v,w in UVW:
        M[u].append([w,v])
        M[v].append([w,u])

    queue=[[0,1]]
    heapq.heapify(queue)
    color[1]="gray"
    D[1]=1

    while len(queue)>0:
        num=heapq.heappop(queue)[1]
        if color[num]=="black":continue
        color[num]="black"

        for i,j in M[num]:
            if D[j]>i and color[j]!="black":
                if i%2==0:D[j]=D[num]
                else:D[j]=-D[num]
                color[j]="gray"
                heapq.heappush(queue,[i,j])

    return D[1:]


n=int(input())
UVW=[list(map(int,input().split())) for _ in range(n-1)]
for i in prim():
    if i==1:print(i)
    else:print(0)

Measured memory_bytes: 122856
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	string s;
  	cin>>n>>s;
  	if(n%2)
      cout<<"No\n";
  	else
    {
    	string s1 = s.substr(0,n/2);
        string s2 = s.substr(n/2,n/2);
      	if(s1==s2)
          cout<<"Yes\n";
      	else
          cout<<"No\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

long long gcd(long long a,long long b);

int main(){
  
  long long n;

  scanf("%lld",&n);

  long long t[n];

  for(long long i=0;i<n;i++){
    scanf("%lld",&t[i]);
  }

  long long ka=1;

  for(long long i=0;i<n;i++){
    ka=(ka/gcd(ka,t[i]))*t[i];
  }

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

long long gcd(long long a,long long b){
  long long d,s;
  if(a>=b){
    d=a;
    s=b;
  }
  else{
    d=b;
    s=a;
  }

  if(s==1){
    return 1;
  }
  else if(d%s==0){
    return s;
  }
  else{
    return (gcd(s,d%s));
  }
}




Measured memory_bytes: 128
public class Main {
public static void main(String[] args){
	
	int input = new java.util.Scanner ( System.in ). nextInt();
	int h = input / (60 * 60);
	int m = (input / 60) - (h * 60);
	int s = input - (m * 60) - (h * 60 * 60);
	System.out.println(h + ":" + m + ":" + s);
	
}
}

Measured memory_bytes: 17352
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>


int main() {
	int n; std::cin >> n;
	std::vector<int> red(n), blue(n);
	for (auto& r : red) std::cin >> r;
	for (auto& b : blue) std::cin >> b;
	std::vector<std::pair<int, int>> for_odd, for_even;
	std::vector<int> indices(n);
	const auto comparator = [](std::pair<int, int> a, std::pair<int, int> b) {return a.second == b.second ? a.first < b.first : a.second < b.second; };
	int min_swap = INT_MAX;
	for (auto pattern = 0; pattern < (1 << n); ++pattern) {
		for_odd.clear(); for_even.clear();
		for (auto i = 0; i < n; ++i) {
			if ((pattern & (1 << i)) == 0) {//red
				if (i % 2 == 0) {
					for_even.emplace_back(i, red[i]);
				}
				else {
					for_odd.emplace_back(i, red[i]);
				}
			}
			else {//blue
				if (i % 2 == 0) {
					for_odd.emplace_back(i, blue[i]);
				}
				else {
					for_even.emplace_back(i, blue[i]);
				}
			}
		}
		if (for_even.size() == (n + 1) / 2 && for_odd.size() == n / 2) {
			std::sort(for_even.begin(), for_even.end(), comparator);
			std::sort(for_odd.begin(), for_odd.end(), comparator);
			int prev = 0;
			for (auto i = 0; i < n; ++i) {
				if (i % 2 == 0) {
					if (prev <= for_even[i / 2].second) prev = for_even[i / 2].second;
					else {
						prev = -1;
						break;
					}
				}
				else {
					if (prev <= for_odd[i / 2].second) prev = for_odd[i / 2].second;
					else {
						prev = -1;
						break;
					}
				}
			}
			if (prev < 0) continue;
			for (auto i = 0; i < n; ++i) {
				if ((i & 1) == 0) {
					indices[i] = for_even[i >> 1].first;
				}
				else {
					indices[i] = for_odd[i >> 1].first;
				}
			}
			int swap = 0;
			for (auto i = 0; i < n; ++i) {
				for (auto j = 0; j < i; ++j) {
					if (indices[i] < indices[j]) ++swap;
				}
			}
			min_swap = std::min(min_swap, swap);
		}
	}
	if (min_swap == INT_MAX) {
		std::cout << "-1\n";
	}
	else {
		std::cout << min_swap << '\n';
	}
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
//#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200, mod = 1e9 + 7;

char a[1001][1001];
int d[1001][1001];
int n,m;

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (a[i][j] == '#') d[i][j] = 0;
			else{
				(d[i][j] = d[i - 1][j] + d[i][j - 1]) %= mod;
			}
			if (i == 1 && j == 1){
				d[i][j] = 1;
			}
		}
	}
	cout << d[n][m];
	
	return 0;
}












Measured memory_bytes: 5120
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

//const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  long double l;
  std::cin>>l;

  l/=3;

  std::cout<<std::setprecision(10)<<std::fixed<<l*l*l<<"\n";

  return 0;
}


Measured memory_bytes: 256
import itertools 
n=int(input())
g=[[-1 for _ in range(15)] for _ in range(15)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        g[i][x-1]=y
ans=0

for i in range(2**n):
    honests = [0 for _ in range(n)]
    for j in range(n):
        if(i>>j)&1:
            honests[j]=1
    ok=True
    for j in range(n):
        if honests[j]:
            for k in range(n):
                if g[j][k]==-1: continue
                if g[j][k]!=honests[k]: ok=False
    if ok:
        ans=max(ans,honests.count(1))
print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int a[3];

int main(){
	cin.sync_with_stdio(false);
	rep(i,3)cin>>a[i];
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	return 0;
}

Measured memory_bytes: 3208
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}

signed main() {
    double a;cin >>a;
    cout <<2*a*acos(-1)<<endl;
}

















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

ll mod = 1'000'000'007;
ll dp[2001];
ll go(ll k) {
    ll &ret = dp[k];
    // cout << k << '\n';
    if (ret != -1) return ret;
    if (k < 3) return ret = 0;
    ret = 1;
    for (int i = 3; i <= (k-3); i++) {
        ret += go(k-i);
        ret %= mod;
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int S; cin >> S;
    memset(dp, -1, sizeof(dp));
    cout << go(S);
}

Measured memory_bytes: 3660
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Item {
  int i;
  string s;
  int p;
};

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

  int n;
  cin >> n;
  vector<Item> v(n);
  for (int i = 0; i < n; i++) {
    v[i].i = i + 1;
    cin >> v[i].s >> v[i].p;
  }
  sort(v.begin(), v.end(), [](const Item& x, const Item& y) {
    if (x.s == y.s) {
      return x.p > y.p;
    }
    return x.s < y.s;
  });
  for (const auto& e : v)
    cout << e.i << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;

long long calc(long long a, long long b) {
    if (b == 0)
        return 1;
    else if (b % 2 == 0) {
        long long d = calc(a, b / 2);
        return d * d % MOD;
    } else {
        return a * calc(a, b - 1) % MOD;
    }
}

int main() {
    long long N;
    cin >> N;
    vector<long long> D(N);
    bool check = false;
    int st = 0;
    for (int i = 0; i < N; i++) {
        cin >> D[i];
        if (i == 0) {
            st = D[i];
        } else if (st >= D[i]) {
            check = true;
        }
    }
    long long sum = 0;
    vector<long long> v(N, 0);
    long long maxv = 0;
    if (!check) {
        for (int i = 0; i < N; i++) {
            v[D[i] - D[0]]++;
            maxv = max(maxv, D[i] - D[0]);
        }
        for (int i = 0; i <= maxv; i++) {
            if (v[i] == 0) {
                sum = 0;
                break;
            }
            if (sum == 0) {
                sum = 1;
            } else {
                sum = sum * calc(v[i - 1], v[i]) % MOD;
            }
        }
    }
    cout << sum % MOD << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  int D,N;
  cin>>D>>N;
  int ans(1);
  for (int i(0);i<D;i++) ans*=100;
  if (N==100)
    cout << ans*101 << endl;
  else
    cout << ans*N << endl;
  return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

string s;

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

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    ll n=s.size();
    s="."+s;
    if(s[1]=='0' || s[n]=='1'){
        cout << -1;
        return 0;
    }
    for(ll i=1; i<n; i++){
        if(s[i]!=s[n-i]){
            cout << -1;
            return 0;
        }
    }
    ll p=n;
    for(ll i=n-1; i>=1; i--){
        cout << p << " " << i << "\n";
        if(s[i]=='1') p=i;
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 1664
using System;

namespace ABC168A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = n % 10;
            if (num == 3)
            {
                Console.WriteLine("bon");
            }
            else if (num == 0 || num == 1 || num == 6 || num == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }
        }
    }
}


Measured memory_bytes: 17652
#include <iostream>

using namespace std;

int main()
{
	
	int n,m;
	cin >> n >> m;
	
	int roads[n];		// roads[i] = number of roads from city i
	
	int city;
	
	for(int i=0; i<n; i++){
		roads[i] = 0;
	}
	
	for (int i = 0; i<m*2; i++ ){
		cin >> city;
		roads[city-1] = roads[city-1] + 1;
	}
	
	for(int i=0; i<n; i++){
		cout << roads[i] << "\n";
	}
}

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

#define int long long

int pow_mod (int a, int b, int p) {
	int res = 1, t = a;
	while (b) {
		if (b & 1)
			(res *= t) %= p;
		(t *= t) %= p;
		b >>= 1;
	}
	return res;
}

signed main () {
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;
	if (p == 2 || p == 5) {
		long long ans = 0;
		for (int i = 0; i < n; ++i) {
			if (((int)(s[i] - '0')) % p == 0LL)
				ans += i + 1;
		}
		cout << ans << '\n';
	}
	else {
		vector < int > pref(n + 1, 0);
		map < int, int > prefs;
		prefs[0] = 1;
		for (int i = 0; i < n; ++i) {
			pref[i + 1] = (pref[i] * 10LL + ((int)(s[i] - '0'))) % p;
			++prefs[((pref[i + 1]) * pow_mod(10, n - i - 1, p)) % p];
		}
		long long ans = 0LL;
		for (auto pr: prefs) 
			ans += (((long long) pr.second) * (((long long) pr.second) - 1LL)) / 2LL;
		cout << ans << '\n';
	}
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}


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

  int a = -1, c = -1;
  rep(i, s.length() - 1) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      p("Yes"); return 0;
    }
  }
  p("No");
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int n,A,B,C;
int bamboo[9];
int dfs(int l,int a,int b,int c)
{
	if(l==n)
	{
		if(a==0||b==0|c==0)
			return 8001;
		return abs(A-a)+abs(B-b)+abs(C-c);
	}
	int r1=dfs(l+1,a+bamboo[l+1],b,c)+10;
	int r2=dfs(l+1,a,b+bamboo[l+1],c)+10;
	int r3=dfs(l+1,a,b,c+bamboo[l+1])+10;
	int r4=dfs(l+1,a,b,c);
	return min(r1,min(r2,min(r3,r4)));
}
int main()
{
	scanf("%d%d%d%d",&n,&A,&B,&C);
	for(int i=1;i<=n;i++)
		scanf("%d",&bamboo[i]);
	printf("%d",dfs(0,0,0,0)-30);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y,z,cnt,i;
	cnt=0;
	scanf("%d %d",&x,&y);
	for(i=1;i<x;i++){
		if(i*y%x==0){
			cnt++;
		}
	}
	z=x+y-cnt;
	printf("%d\n",z);
	return 0;
}


Measured memory_bytes: 2104
N,K = map( int ,input().split())
N_list = [0]*N
for i in range(K):
    d = int(input())
    num_list = [int(i) for i in input().split()]
    for j in range(len(num_list)):
        N_list[num_list[j]-1] +=1
print(N_list.count(0))

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  string S;
  cin>>N>>S;
  int hidari[300000]={0},migi[300000]={0};
  hidari[0]=(S[0]=='W'? 1:0);
  for (int i(1);i<N;i++){
    hidari[i]=hidari[i-1]+(S[i]=='W'? 1:0);
  }
  migi[N-1]=(S[N-1]=='E'? 1:0);
  for (int i(N-2);i>=0;i--){
    migi[i]=migi[i+1]+(S[i]=='E'? 1:0);
  }
  int mini(1e9);
  for (int i(0);i<N;i++){
    mini=min(mini,migi[i]+hidari[i]-1);
  }
  cout << mini << endl;
  return 0;
}


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

int main()
{
  int n, m; cin >> n >> m;
  vector< list<int> > from(n);
  vector< pair<int, int> > side(m);
  for (int i = 0; i < m; ++i)
  {
    int a, b; cin >> a >> b; --a; --b;
    from[a].push_front(b);
    from[b].push_front(a);
    side[i] = make_pair(a, b);
  }
  
  int num_bridge = 0;
  for (auto cand_bridge = side.begin(); cand_bridge != side.end(); ++cand_bridge)
  {
    vector<bool> passed(n, false); passed[0] = true;
    int num_passed = 1;
    queue<int> next_v; next_v.push(0);
    while (!next_v.empty())
    {      
      int cur = next_v.front(); next_v.pop();       
      int off = -1;
      if (cur == (*cand_bridge).first) off = (*cand_bridge).second;
      else if (cur == (*cand_bridge).second) off = (*cand_bridge).first;
      
      for (auto to = from[cur].begin(); to != from[cur].end(); ++to)
      {
        if (!passed[*to] && *to != off)
        {
          passed[*to] = true;
          ++num_passed;
          next_v.push(*to);
        }
      }
    }
    
    if (num_passed < n) ++num_bridge;
  }
  
  cout << num_bridge << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var h, dp []int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scanf("%d", &tmp)
		h = append(h, tmp)
	}
	for i := 0; i < n; i++ {
		dp = append(dp, math.MaxInt64)
	}
	dp[0], dp[1] = 0, abs(h[1]-h[0])
	for i := 2; i < n; i++ {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
	}
	fmt.Println(dp[n-1])
}
func abs(in int) int {
	if in >= 0 {
		return in
	} else {
		return -in
	}
}
func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}


Measured memory_bytes: 8468
use std::cmp;

fn main(){
    let mut sc = Scanner::new();
    while sc.read() {
        let n = sc.next();
        let m = sc.next();
        let mut es = [(0,0,0); 1000];
        let mut d:[[i32; 100]; 100] = [[i32::max_value() / 4; 100]; 100];
        for i in 0..m {
            let a = sc.next::<usize>() - 1;
            let b = sc.next::<usize>() - 1;
            let c:i32 = sc.next();
            d[a][b] = cmp::min(d[a][b], c);
            d[b][a] = cmp::min(d[b][a], c);
            es[i] = (a, b, c);
        }
        for k in 0..n {
            for i in 0..n {
                for j in 0..n {
                    d[i][j] = cmp::min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        println!("{}", es.iter().take(m).fold(0, |sum, &e| {
            sum + if d[e.0][e.1] < e.2 { 1 } else { 0 }
        }));
    }
}

#[allow(dead_code)]
struct Scanner {
    buf: Vec<u8>, i: usize, next: Option<String>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: vec![], i: 0, next: None, }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }

    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut res = Vec::<T>::with_capacity(n);
        for _ in 0..n { res.push(self.next()) }
        res
    }

    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.read();
        self.next.take().and_then(|s| s.parse::<T>().ok())
    }

    fn read(&mut self) -> bool {
        if self.next.is_some() { return true }
        let mut s = String::with_capacity(16);
        while let Some(c) = self.get_char() {
            if !c.is_whitespace() { s.push(c); }
            else if !s.is_empty() { break; }
        }
        self.next = if !s.is_empty() { Some(s) } else { None };
        self.next.is_some()
    }

    fn get_char(&mut self) -> Option<char> {
        if self.i >= self.buf.len() {
            use std::io::BufRead;
            let reader = std::io::stdin();
            let mut buffer = reader.lock();
            let len = match buffer.fill_buf() {
                Ok(bytes) => {
                    self.buf.resize(bytes.len(), b'\0');
                    // self.buf.copy_from_slice(bytes); // AtCoderのRustには未実装
                    for i in 0..bytes.len() { self.buf[i] = bytes[i]; }
                    Some(bytes.len())
                },
                Err(_) => None,
            };
            self.i = 0;
            if len.is_some() { buffer.consume(len.unwrap()); }
            if len.is_none() || len.unwrap() == 0 { return None }
        }
        self.i += 1;
        Some(self.buf[self.i - 1] as char)
    }
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y,ll m){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%m*res%m)%m;
    x=(x%m*x%m)%m;    
    y=y/2;
  }
  
  return res%m;
}
 
ll modinv(ll x){
  return power(x,hell-2,1);
}

ll gcd(ll a,ll b){
    while(b!=0){
		ll t=b;
		b=a%t;
		a=t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
} 

void solve(){
    int n;
    cin>>n;
    ll a[n];
    forn(i,0,n)
    cin>>a[i];
    
    sort(a,a+n);
    
    ll ans=0;
    
    ans+=a[n-1];
    int rem=n-2;
    
    for(int i=n-2;i>=0;i--){
        if(rem==0)
        break;
        
        if(rem==1){
            ans+=a[i];
            break;
        }else{
            rem-=2;
            ans+=2*a[i];
        }
    }
    cout<<ans;
}    
    
int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
   
   while(test--)
   solve();
}

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

const int MAX_N = 1e5+2, MOD=1e9+7;
int N, K;
int a[MAX_N],b[MAX_N];
vector<int> G[MAX_N];

void add_edge(int from, int to)
{
	G[from].push_back(to);
	G[to].push_back(from);
}

ll dfs(int x, int par)
{
	int cnt = 0;
	ll res = 1LL;
	for(int i=0;i<G[x].size();++i){
	    int y = G[x][i];
	    if(y != par){
	        (res *= 1LL*(K-1-cnt-((x==1)?0:1))*dfs(y,x)%MOD)%=MOD;
	        cnt++;
	    }
	}
	return res;
}
 
void solve()
{
	for(int i=1;i<=N;++i)if((int)G[i].size()+1>K){
		cout << 0 << '\n';
		return;
	}
	ll ans = 1LL*K*dfs(1,0)%MOD;
	cout << ans << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N-1;++i){
		cin >> a[i] >> b[i];
		add_edge(a[i],b[i]);
	}
	solve();
	return 0;
}


Measured memory_bytes: 15548