akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int A, B;
	cin >> A >> B;
	cout << A * B << endl;

	return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 200090
#define INF 0x3f3f3f3f

int n , a[MAX] , b[MAX] , c[MAX];
int32_t main(){
	IOS;
	cin >> n;
	REP(i , 0 , n) cin >> a[i] , a[i] <<= 1;
	REP(i , 0 , n) cin >> b[i] , b[i] <<= 1;
	int ans = 0 , pat = 1;
	REP(bit , 1 , 30){
		int cnt = 0 , zero = 0 , one = 0;
		REP(i , 0 , n) c[i] = b[i] & pat;
		sort(c , c + n);

		REP(i , 0 , n) if((b[i] & (1 << bit)) == 0) zero ++;
		REP(i , 0 , n) if((b[i] & (1 << bit)) != 0) one ++;
		REP(i , 0 , n) if((a[i] & (1 << bit)) == 0) cnt = (cnt + one) % 2;
		REP(i , 0 , n) if((a[i] & (1 << bit)) != 0) cnt = (cnt + zero) % 2;
		// if(bit == 2){ REP(i , 0 , n) cout << c[i] << " "; cout << endl; }
		REP(i , 0 , n){
			int val = a[i] & pat;
			int idx = n - (lower_bound(c , c + n , (1 << bit) - val) - c);
			// if(bit == 2) DBGG("idx = " , idx);
			cnt = (cnt + idx) % 2;
		}
		// DB4("i = " , bit , "cnt = " , cnt);
		if(cnt % 2) ans |= 1 << bit;
		pat = pat << 1 | 1;
	}
	cout << (ans >> 1) << endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	cout << count_if(A.begin(), A.end(), [](int& a) { return 0 == a % 2; }) << endl;
}


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

int main() {
    int n;
    cin >> n;
    int fib[50];
    fib[0] = fib[1] = 1;
    for (int i = 2; i <= n; i++) {
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[n] << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/
bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

// Prime factor
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> ret;
    ret[1] = 1;
    for (ll i = 2; i*i <= n; ++i) {
        while (n % i == 0) {
            ++(ret[i]);
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

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

    cin >> n;
    vi a(n); veccin(a);
	int b[1000001] = {};
	sort(ALL(a));
    REP(i,n){
      //if(a[i-1]==a[i]||a[i]==a[i+1])continue;
      if(!b[a[i]]){
      	/*auto div = divisor(a[i]);
        for(auto&&e:div){
        	b[e]=1;
        	dbg(e);
        }*/
        for(ll j=a[i];j<=1000000;j+=a[i]){b[j]=1;}
        if(a[i]!=a[i+1])ans++;
      }
    }
    //ans = lis.size();
    cout << ans << endl;
}


Measured memory_bytes: 8752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define reps(i,s,n) for(int i=s; i<n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

int field[140][140];
void setf(int x, int y, int val) {
	field[x+70][y+70] = val;
}
int getf(int x, int y) {
	return field[x+70][y+70];
}

struct t_node {
	int x, y, t;
	t_node( int tx, int ty, int tt ) {
		x = tx;
		y = ty;
		t = tt;
	}
};
bool operator<( const t_node &lhs, const t_node &rhs ) {
	return lhs.t < rhs.t;
}

const int INF = 1<<30;

int main() {
	int t, n;
	while( cin >> t >> n, t||n ) {
		memset( field, -1, sizeof(field) );
		rep(i, n) {
			int x, y;
			cin >> x >> y;
			setf(x, y, INF);
		}
		int sx, sy;
		cin >> sx >> sy;
		priority_queue<t_node> que;
		que.push( t_node(sx, sy, t) );
		while( !que.empty() ) {
			t_node tn = que.top();
			que.pop();
			if( getf(tn.x, tn.y) > 0 ) continue;
			setf( tn.x, tn.y, tn.t );
			if( tn.t == 0 ) continue;
			int dx[6] = {0, 1, 1,  0, -1, -1};
			int dy[6] = {1, 1, 0, -1, -1,  0};
			rep(i, 6) {
				int nx = tn.x + dx[i];
				int ny = tn.y + dy[i];
				if( getf(nx, ny) < tn.t-1 ) {
					que.push( t_node(nx, ny, tn.t-1) );
				}
			}
		}
		int cnt = 0;
		for(int y=0; y<140; y++) {
			for(int x=0; x<140; x++) {
				if( 0<=field[x][y] && field[x][y]<INF ) {
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, M; cin >> N >> M;
	vector<int> res(N, 0);
	for (int i = 0; i < M; i++)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		res[a]++; res[b]++;
	}
	for (int i = 0; i < N; i++)
	{
		cout << res[i] << endl;
	}

	return 0;
}


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

int main(){
        char s[4];
        scanf("%s", s);
        if(!strcmp(s,"SUN"))puts("7");
        if(!strcmp(s,"MON"))puts("6");
        if(!strcmp(s,"TUE"))puts("5");
        if(!strcmp(s,"WED"))puts("4");
        if(!strcmp(s,"THU"))puts("3");
        if(!strcmp(s,"FRI"))puts("2");
        if(!strcmp(s,"SAT"))puts("1");
        return 0;
}

Measured memory_bytes: 128
while data = gets
  data2 = data.split(" ")
  data2.map! {|x| x.to_f}
  x = (data2[5]*data2[1]-data2[2]*data2[4])/(data2[1]*data2[3]-data2[0]*data2[4])

  y = (data2[2]-data2[0]*x)/data2[1]
  puts "#{sprintf("%.03f",x+0.0)} #{sprintf("%.03f",y+0.0)}"
end

Measured memory_bytes: 6136
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int ans=0;
    REP(i,3){
        ans+=s%10;
        s/=10;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<pair<int, int>> ans;
    int M = (N % 2 == 0) ? N + 1 : N;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) {
            if(i + j != M) ans.pb(mp(i, j));
        }
    }
    output(ans.size());
    for(auto a: ans) {
        cout << a.first << " " << a.second << endl;
    }
    
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
vector<int> g[maxn];
int color[maxn];


void dfs(int at, int p=-1) {
    for (int to: g[at]) {
	if (to == p) continue;
	if (color[to]==-1) {
	    color[to] = 1^color[at];
	    dfs(to, at);
	} else {
	    assert(color[to] == (1^color[at]));
	}
    }
}

int ans[maxn];

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

    cin>>n;
    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    memset(color,-1,sizeof(color));

    color[1] = 0;
    dfs(1);

    vector<int> v(2);
    for (int i=1; i<=n; i++) {
	v[color[i]]++;
    }
    int c = 0;
    if (v[1] < v[0]) c = 1;

    set<int> st;
    for (int i=1; i<=n; i++) {
	st.insert(i);
    }

    // enough of 0mod3 to cover all white nodes
    if (v[c] <= n/3) {
	int f3=3;
	for (int i=1; i<=n; i++) {
	    if (color[i] == c) {
		assert(f3 <= n);
		ans[i] = f3;
		assert(st.count(f3));
		st.erase(f3);
		f3+=3;
	    }
	}
	for (int i=1; i<=n; i++) {
	    if (color[i] != c) {
		assert(st.size());
		ans[i] = *st.begin();
		st.erase(st.begin());
	    }
	}
    } else {
	// use all of 1mod3 on white nodes, and 0mod3 on the rest of the white nodes
	int at=1;
	for (int i=1; i<=n; i++) {
	    if (color[i] == c) {
		assert(at <= n);
		ans[i] = at;
		st.erase(at);
		at += 3;
		if (at > n) {
		    at = 3;
		}
	    }
	}

	for (int i=1; i<=n; i++) {
	    if (color[i] != c) {
		assert(st.size());
		ans[i] = *st.begin();
		st.erase(st.begin());
	    }
	}
    }


    for (int i=1; i<=n; i++) {
	cout<<ans[i]<<" ";
    }
    cout<<endl;    
    return 0;
}


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

int n , m , k;

int main()
{
	cin >> n >> m >> k;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			int ans = 0;
			ans += (i * m);
			ans += (n - i) * j;
			ans -= (i * j);
			if(ans == k) 
			{
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = 2e5 + 10;
char s[N];
int dp[N][2], n;

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    memset(dp, -1, sizeof dp);
    dp[1][0] = dp[2][1] = 1;
    for (int i = 1; i <= n; i++) {
        if (dp[i][0] != -1) {
            dp[i + 2][1] = std::max(dp[i + 2][1], dp[i][0] + 1);
            if (s[i + 1] != s[i]) dp[i + 1][0] = std::max(dp[i + 1][0], dp[i][0] + 1);
        }
        if (dp[i][1] != -1) {
            dp[i + 1][0] = std::max(dp[i + 1][0], dp[i][1] + 1);
            if (s[i + 2] != s[i] || s[i + 1] != s[i - 1]) dp[i + 2][1] = std::max(dp[i + 2][1], dp[i][1] + 1);
        }
    }
    printf("%d\n", std::max(dp[n][0], dp[n][1]));
    return 0;
}


Measured memory_bytes: 1920
def main():
  n = input()
  a = tuple(map(int, input().split()))

  if 0 in a:
    print(0)
    return
  
  ans = a[0]
  a2 = a[1:]
  for i in a2:
    ans = ans * i
    if ans > 1000000000000000000:
      print(-1)
      return

  print(ans)

main()

Measured memory_bytes: 21864
#include <bits/stdc++.h>
#include <tuple>
#include <complex>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

using namespace std;

const int INF = 1e9;

typedef complex<double> Point;



vector<Point> koch(vector<Point> pairs, int n){
    vector<Point> temp;
    if(n == 0)
        return pairs;
    temp.push_back(pairs[0]);
    REP(i, pairs.size()-1){
        Point start = pairs[i];
        Point end = pairs[i+1];
        Point mid1 = start + polar(abs(end-start) / 3, arg(end-start));
        Point mid2 = end - polar(abs(end-start) / 3, arg(end-start));
        Point top = mid1 + polar(abs(mid1-start), M_PI / 3 + arg(mid1-start));
        temp.push_back(mid1);
        temp.push_back(top);
        temp.push_back(mid2);
        temp.push_back(end);
    }
    return koch(temp, n-1);
}

int main() {
    int n;
    cin >> n;
    vector<Point> res;
    res.push_back(Point(0, 0));
    res.push_back(Point(100, 0));
    res = koch(res, n);
    cout << setprecision(10);
    REP(k, res.size()){
        cout << res[k].real() << " " << res[k].imag() << endl;
    }
}

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

int main(){
    vector<int> v(101);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for(int i=a; i<b; i++) v[i]++;
    for(int i=c; i<d; i++) v[i]++;
    int ans = 0;
    for(int i=0; i<v.size(); i++) ans += (v[i] == 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

N=int(input())
A=list(map(int,input().split()))

A.sort()

ansi=A[-1]

def bin_isOK(index,key):
    if A[index] >= key:
        return True
    else:
        return False


def binary_search(key):
    ng = -1
    ok = len(A)

    while abs(ok - ng) >1:
        mid = (ok + ng)//2

        if bin_isOK(mid,key):
            ok = mid
        else:
            ng = mid
    
    return ok

Index=binary_search(ansi/2)

if abs(A[Index]-(ansi/2))<abs(A[Index-1]-(ansi/2)):
    ansj=A[Index]
else:
    ansj=A[Index-1]

print(ansi,ansj)



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

long long int C[100045][41];

int check[100005];

void ER(void) {
	check[1] = 1;
	for (int i = 2; i <= 100000; i++) {
		if (check[i] == 0) {
			for (int j = 2;i*j<=100000; j++) {
				check[i*j] = 1;
			}
		}
	}
}

int N;
long long int M;

long long int MOD = 1000000007;

vector<int> V;
int NUM[100040];

long long int INV(long long int m, long long int p) {
	vector<int> bit; // 2^0, 2^1, 2^2, 2^3, 
	long long int u = p - 2;
	while (u > 0) {
		bit.push_back(u % 2); u /= 2;
	}

	vector<long long int> W;
	long long int TMP = m;
	for (int i = 0; i < (int)bit.size(); i++) {
		TMP %= p;
		W.push_back(TMP);
		TMP *= TMP;
	}

	long long int ret = 1;

	for (int i = 0; i<(int)bit.size(); i++) {
		if (bit[i] == 1) { ret *= W[i];  ret %= p; }
	}

	return ret;
};

long long int p[100045], inv_p[100045];

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

	ER();

	for (int i = 1; i <=100000; i++) {
		if (check[i] == 0) { V.push_back(i); }
	}
	
	for (int i = 0; i < (int)V.size(); i++) {
		int count = 0;
		while (M%V[i] == 0) { count++; M /= V[i]; }
		NUM[i] = count;
	}
	
	

	//====================

	p[0] = 1; inv_p[0] = 1;
	for (int i = 1; i <= 100040; i++) {
		p[i] = (p[i - 1] * i) % MOD;
	}
	for (int i = 1; i <= 100040; i++) {
		inv_p[i] = INV(p[i], MOD)%MOD;
	}

	

	for (int i = 0; i <= N+40; i++) {
		C[i][0] = 1;
		for (int m = 1; m <= min(40,i); m++) {
			C[i][m] = (p[i] * inv_p[m]) % MOD;
			C[i][m] *= inv_p[i - m];
			C[i][m] = C[i][m] % MOD;
		}
	}
	
	//===================

	long long int ans = 1;

	for (int i = 0; i < (int)V.size(); i++) {
		ans *= C[N+NUM[i]-1][NUM[i]]; ans %= MOD;
		
	}

	/*for (int j = 0; j <= 5; j++) {
		for (int i = 0; i <= 3; i++) {
			cout << "C["<<j<<" ][" <<i<<"]= " << C[j][i] % MOD << endl;
		}
	}*/

	if (M > 1) {
		ans *= N; ans %= MOD;
	}

	cout << ans << endl;

	
	//system("pause");
	return 0;
}

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

string A(string s){
  reverse(s.begin(), s.end());
  return s;
}
string C(string s){
  return s.substr(1, s.length() - 1) + s[0];
}
string J(string s){
  return s.back() + s.substr(0, s.length() - 1);
}
string E(string s){
  string res = s.substr((s.length() + 1)/2);
  if(s.length()%2 != 0)res += s[s.length()/2];
  res += s.substr(0, s.length()/2);
  return res;
}

string M(string s){
  string res = s;
  for (int i = 0; i < s.length(); i++) {
    if('0' <= res[i] and res[i] < '9'){
      res[i]++;
    }else if(res[i] == '9'){
      res[i] = '0';
    }
  }
  return res;
}

string P(string s){
  string res = s;
  for (int i = 0; i < s.length(); i++) {
    if('0' < res[i] and res[i] <= '9'){
      res[i]--;
    }else if(res[i] == '0'){
      res[i] = '9';
    }
  }
  return res;
}

int main(){
  int n;
  std::cin >> n;
  for (int roop = 0; roop < n; roop++) {
    string ope, s;
    std::cin >> ope >> s;
    reverse(ope.begin(), ope.end());
    for (int i = 0; i < ope.length(); i++) {
      if(ope[i] == 'A'){
        s = A(s);
      }else if(ope[i] == 'E'){
        s = E(s);
      }else if(ope[i] == 'C'){
        s = C(s);
      }else if(ope[i] == 'J'){
        s = J(s);
      }else if(ope[i] == 'M'){
        s = M(s);
      }else if(ope[i] == 'P'){
        s = P(s);
      }else{
        std::cerr << "hoge" << std::endl;
      }
    }
    std::cout << s << std::endl;

  }
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	int dat[N];
	int sum = 0;
	for (int i = 0; i < N; ++i) cin >> dat[i], sum += dat[i];
	long long MIN = -1;
	int idx = -1;
	for (int i = 0; i < N; ++i) {
		if (idx == -1) {
			idx = i+1;
			MIN = abs(sum - N * dat[i]);
		} else {
			if (MIN > abs(sum - N * dat[i])) {
				MIN = abs(sum - N * dat[i]);
				idx = i + 1;
			}
		}
	}
	cout << idx-1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char m[111][111];
bool used[111][111];
char c[] = "v^<>";
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
int main(void){
  while(1){
    int w,h;
    cin >> w >> h;
    if(!w && !h)break; 
    memset(m,0,sizeof(m));
    memset(used,false,sizeof(used));
    for(int i = 0; i < w; i++){
      cin >> m[i];
    }
    int x = 0,y = 0;
    bool f = true;
    while(m[x][y] != '.'){
      used[x][y] = true;
      for(int i = 0;i < 4; i++){
	if(m[x][y] == c[i]){
	  x += dx[i];
	  y += dy[i];
	  break;
	}
      }
      if(used[x][y]){
	cout << "LOOP" << endl;
	f = false;
	break;
      }
    }
    if(f){
      cout << y << " " << x << endl;
    }
  }
}

Measured memory_bytes: 1196
import java.util.Scanner;

class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    //反対の大きい数字を入れて初期化する
    //0を初期化したなら０が最小になるため、－の値を入れる必要がある
    //maxの場合上記の逆
    int min = 1000000;
    int max = -1000000;
    long  sum = 0L;

      for (int i=0; i<n; i++){
        int nn = sc.nextInt();
        min = Math.min(min,nn);
        max = Math.max(max,nn);
        sum += nn;
      }
      System.out.println(min + " " + max + " " + sum);
  }
}



Measured memory_bytes: 40920
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define ull unsigned long long
using namespace std;
string s;
int cnt[100];
void work() {
  cin >> s;
  int tot = 1, len = s.length();
  for(reg int i = 0; i < len; ++i) {
    if(s[i] == 'R') ++cnt[tot];
    if(s[i] != 'R') ++tot;
  }
  int ans = 0;
  for(reg int i = 0; i <= tot; ++i) ans = max(ans, cnt[i]);
  printf("%d\n", ans);
}
signed main() {
  int _ = 1;
  // scanf("%d", &_);
  while(_--) {
    work();
  }
  return 0;
}


Measured memory_bytes: 3748
#include <iostream>

using namespace std;

const int MAX = 246913;
const int SIZE = 123457;

int main()
{
	int n;
	bool prime[SIZE];
	for(int i=0; i < SIZE; i++) prime[i] = true;
	for(int i=3; i < MAX; i+=2) {
		if(prime[((i-1)>>1)]) {
			for(int j=i+i+i; j < MAX; j+=i) {
				if(j&1) prime[((j-1)>>1)] = false;
			}
		}
	}
	while(cin >> n, n)
	{
		int cnt = 0;
		int m = (n << 1) + 1;
		for(int i=n+1; i < m; i++) {
			if((i&1) && (prime[((i-1)>>1)])) cnt++;
		}
		if(n == 1) cnt++;
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 0
(defmacro defsolver (name vars &body body)
  `(defun ,name ()
     (let (,@(mapcar #'list
            vars
            (mapcar (constantly '(read))
                vars)))
       ,@body)))

(defsolver solution-a (n m)
  (princ (floor (+ (* 3 n) m) 2)))

(solution-a)

Measured memory_bytes: 15976
use std::collections::LinkedList;


#[derive(Debug, Clone)]
struct Node {
    value: i64,
    child: LinkedList<usize>,
    visited: bool,
}

impl Node {
    fn new() -> Node {
        Node { value: 0, child: LinkedList::new(), visited: false, }
    }
    fn add(&mut self, value: i64) {
        self.value += value;
    }
    fn append(&mut self, child_id: usize) {
        self.child.push_back(child_id);
    }
}


fn dfs(tree: &mut Vec<Node>, id: usize, tmp_value: i64) {
    if !tree[id].visited {
        tree[id].visited = true;
        tree[id].add(tmp_value);

        let Node { value: v, child: child_nodes, ..} = tree[id].clone();

        for child in child_nodes.iter() {
            dfs(tree, *child, v);
        }
    }
}

fn main() {
    let (n, q) = read_tuple();

    let mut tree: Vec<Node> = (0..(n+1)).map(|_| Node::new()).collect();

    for _ in 0..(n-1) {
        let (a, b) = read_tuple::<usize>();
        tree[a].append(b);
        tree[b].append(a);
    }

    for _ in 0..q {
        let (p, x) = read_tuple::<i64>();
        tree[p as usize].add(x);
    }

    dfs(&mut tree, 1, 0);

    for n in tree.iter().skip(1) {
        print!("{} ", n.value);
    }
    println!("");
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



Measured memory_bytes: 52732
#include<iostream>
#include<string>
using namespace std;
string search(int n[]) {
	if (n[0]) {
		if (n[0]%5 == 1) {
			n[0] = 0;
			return ".";
		}
		else if (n[0]%5 == 2) {
			n[0] = 0;
			return ",";
		}
		else if (n[0]%5 == 3) {
			n[0] = 0;
			return "!";
		}
		else if(n[0]%5==4) {
			n[0] = 0;
			return "?";
		}
		else {
			n[0] = 0;
			return " ";
		}
	}
	else if (n[1]) {
		if (n[1] % 3 == 1) {
			n[1] = 0;
			return "a";
		}
		else if (n[1] % 3 == 2) {
			n[1] = 0;
			return "b";
		}
		else {
			n[1] = 0;
			return "c";
		}
	}
	else if (n[2]) {
		if (n[2] % 3 == 1) {
			n[2] = 0;
			return "d";
		}
		else if (n[2] % 3 == 2) {
			n[2] = 0;
			return "e";
		}
		else {
			n[2] = 0;
			return "f";
		}
	}
	else if (n[3]) {
		if (n[3] % 3 == 1) {
			n[3] = 0;
			return "g";
		}
		else if (n[3] % 3 == 2) {
			n[3] = 0;
			return "h";
		}
		else {
			n[3] = 0;
			return "i";
		}
	}
	else if (n[4]) {
		if (n[4] % 3 == 1) {
			n[4] = 0;
			return "j";
		}
		else if (n[4] % 3 == 2) {
			n[4] = 0;
			return "k";
		}
		else {
			n[4] = 0;
			return "l";
		}
	}
	else if (n[5]) {
		if (n[5] % 3 == 1) {
			n[5] = 0;
			return "m";
		}
		else if (n[5] % 3 == 2) {
			n[5] = 0;
			return "n";
		}
		else {
			n[5] = 0;
			return "o";
		}
	}
	else if (n[6]) {
		if (n[6] % 4 == 1) {
			n[6] = 0;
			return "p";
		}
		else if (n[6] % 4 == 2) {
			n[6] = 0;
			return "q";
		}
		else if (n[6] % 4 == 3) {
			n[6] = 0;
			return "r";
		}
		else {
			n[6] = 0;
			return "s";
		}
	}
	else if (n[7]) {
		if (n[7] % 3 == 1) {
			n[7] = 0;
			return "t";
		}
		else if (n[7] % 3 == 2) {
			n[7] = 0;
			return "u";
		}
		else {
			n[7] = 0;
			return "v";
		}
	}
	else if (n[8]) {
		if (n[8] % 4 == 1) {
			n[8] = 0;
			return "w";
		}
		else if (n[8] % 4 == 2) {
			n[8] = 0;
			return "x";
		}
		else if (n[8] % 4 == 3) {
			n[8] = 0;
			return "y";
		}
		else {
			n[8] = 0;
			return "z";
		}
	}
	return "";
}


int main() {
	int i;
	cin >> i;
	string num;
	string s;
	int n[9] = {};
	for (int j = 0; j<i; j++) {
		cin >> num;
		for (int j = 0; j < num.size() ; j++) {
			switch (num[j]) {
			case '1':
				n[0]++;
				break;
			case '2':
				n[1]++;
				break;
			case '3':
				n[2]++;
				break;
			case '4':
				n[3]++;
				break;
			case '5':
				n[4]++;
				break;
			case '6':
				n[5]++;
				break;
			case '7':
				n[6]++;
				break;
			case '8':
				n[7]++;
				break;
			case '9':
				n[8]++;
				break;
			default:
					s += search(n);
			}
		}
		cout << s << endl;
		s = "";
	}
}



Measured memory_bytes: 3200
N, K = map(int, input().split())
A = list(map(int, input().split()))

dic = dict()
for a in A:
    if dic.get(a) is not None:
        dic[a] += 1
    else:
        dic[a] = 1
sorted_dic = sorted(dic.items(), key=lambda x:x[1], reverse=True)

ans = 0
for ind, (k, v) in enumerate(sorted_dic):
    if ind < K:
        continue
    else:
        ans += v
print(ans)

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

const string YES = "YES";
const string NO = "NO";

int main(){
  int x,ans=0;
  for (int i = 0; i < 3; i++) {
    scanf("%d",&x);
    if (x == 7) ans+=10;
    if (x == 5) ans++;
  }
  printf("%s\n",ans == 12 ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;

typedef long long ll;

ll arr[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int n, cnt = 0;;

    cin>>n;
    for(int i = 0; i < n; i++){
    	cin>>arr[i];
    }

    for(int i = 0; i < n; i++){
    	while(!(arr[i] & 1)){
	    	arr[i] >>= 1;
	    	cnt++;
	    }
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 384
n,k=map(int, input().split())
l=list(range(1,n+1))
for i in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for k in range(len(a)):
        if a[k] in l:
            l.remove(a[k])
            
print(len(l))

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

int main(){
	string s;
	cin>>s;
	if(s =="SUN") cout<<"7\n";
	else if(s =="MON") cout<<"6\n";
	else if(s =="TUE") cout<<"5\n";
	else if(s =="WED") cout<<"4\n";
	else if(s =="THU") cout<<"3\n";
	else if(s =="FRI") cout<<"2\n";
	else if(s =="SAT") cout<<"1\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int main(void){
    char S[110];
    ll K, ans=0;
    scanf("%s %lld", S, &K);
    ll N=strlen(S);
    if(N==1) {
        printf("%lld\n", K/2);
        return 0;
    }
    ll f=1, idx=0;
    while(f && S[++idx]!='\0') f &= (S[idx]==S[idx-1]);
    if(f){
        printf("%lld\n", N*K/2);
        return 0;
    }
    for(ll i=0; i<N-1; ) {
        if(S[i]==S[i+1]) {
            ll t=i, a=1;
            while(t<N-1 && S[t]==S[t+1]) {
            t++;
            a++;
            }
            i=t;
            ans += a/2;
        }
        else i++;
    }
    if(N>2 && S[0]==S[N-1]){
        ll l=1, r=1;
        while(l<N && S[l-1]==S[l]) l++;
        while(r<N && S[N-r-1]==S[N-r]) r++;
        if(l==r && l%2) {
            printf("%lld\n", ans*K + K-1);
            return 0;
        }
    }
    printf("%lld\n", ans*K);
    return 0;
}


Measured memory_bytes: 128
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, K = rl()
A = rl()

s = sum(A)
m = math.ceil(math.sqrt(s))

divs = []
divs2 = []
i = 1
while i <= m:
	if s % i == 0:
		divs.append(i)
		divs2.append(s//i)
	i += 1
divs.reverse()
divs2 += divs

ans = 1
for n in divs2:
	B = [a % n for a in A]
	s = sum(B)
	if s % n != 0: continue
	B.sort()
	B = [b for b in B if b != 0]
	if len(B) == 0:
		ans = max(ans, n)
		break
	bsum = [0]*len(B)
	rbsum = [0]*len(B)
	bs = 0
	for i, b in enumerate(B):
		bs += b
		bsum[i] = bs
	bs = 0
	for i in range(len(B)-1, -1, -1):
		bs += n - B[i]
		rbsum[i] = bs
	need = float('inf')
	for i in range(len(B)-1):
		if bsum[i] == rbsum[i+1]:
			need = bsum[i]
			break
	if need <= K:
		ans = max(ans, n)
		break
print(ans)



Measured memory_bytes: 74832
#include <bits/stdc++.h>
using namespace std;
int maxn=INT_MIN;
int main()
{
	int kel=0;
	string s;
	cin>>s>>s;
	for(int i=0;i<s.size();i++){
		maxn=max(maxn,kel);
		if(s[i]=='I')kel++;
		if(s[i]=='D')kel--;
		maxn=max(maxn,kel);
	}cout<<maxn<<endl;
}



Measured memory_bytes: 256
N = int(input())

countXA = 0
countBX = 0
countBXA = 0
countAB = 0

for i in range(N):
  line = input()
  if line[0] == 'B' and line[-1] == 'A':
    countBXA += 1
  elif line[0] == 'B':
    countBX += 1
  elif line[-1] == 'A':
    countXA += 1
  countAB += line.count('AB')

if countBXA > 0 and countBX == 0 and countXA == 0:
  countAB += countBXA - 1
else:
  countAB += min(countBX, countXA) + countBXA

print(countAB)


Measured memory_bytes: 3064
n = int(input())
p = input().split()
p_list = [int(p[i]) for i in range (len(p))]

n_error = 0

for i in range(n):
  if p_list[i]!=i+1:
    n_error += 1

if n_error==0 or n_error==2:
  print("YES")
else:
  print("NO")

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

int main()
{
    map<char, char> mp;
    
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['C'] = 'G';
    mp['G'] = 'C';
    
    char ch;
    
    cin >> ch;
    
    cout << mp[ch] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  int m = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] < 0){
      m++;
      a[i] *= -1;
    }
  }
  if(m % 2 == 0){
    ll sum = 0;
    for(int i = 0; i < n; i++){
      sum += a[i];
    }
    cout << sum << endl;
  }else{
    ll sum = 0;
    ll mini = 1001001001;
    for(int i = 0; i < n; i++){
      mini = min(mini, a[i]);
      sum += a[i];
    }
    cout << sum - mini * 2<< endl;
  }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;


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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
int up(int a, int b) {
    return (a + a % b) / b;
}

void swap(string s) {
    int low = 0;
    int high = s.length()-1;
    while (low < high) {
        char tmp = s[low];
        s[low] = s[high];
        s[high] = tmp;
        low++;
        high--;
    }
}




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

    string s = to_string(n);
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3672
n = int(input())

A = list(map(int,input().split()))	

#print(A)

flag = 0
b = 1

for a in A:
  if a == 0:
    flag = 2

if flag == 0:
  for a in A:
    b = b * a
    if(b > 10**18):
      flag = 1
      break

#if(b > 10**18):
#  flag = 1
  
  
if flag == 1:
  print(-1)
elif flag == 0:
  print(b)
else:
  print(0)


Measured memory_bytes: 87824
/*GRATITUDE*/
/*1916057*/
//Arise Awake and Stop Not Till the Goal is reached. 
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

/*************************************************************************************************/
//Write your functions here..............................


/***************************************************************************************************/

void solve() {
/*Write your code here*/
   int n; cin>>n;
   int a[n+1];
   for_f (1,n,1) cin>>a[i];
   int pre[n+1]={0}; int res=0;
   pre[1]=a[1];
   for_f (2,n,1) pre[i]=pre[i-1]+a[i];
   for_f (1,n-1,1) {
    res+=((a[i]%mod)*((pre[n]-pre[i])%mod)%mod);
    res%=mod;

   }
   cout<<res;
 
  
}
int32_t main()
{

ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 

Measured memory_bytes: 6724
#include <iostream>
using namespace std;
int main(void)
{
    // Your code here!
    unsigned long n;
    cin >> n;
    bool flg=false;
    if( n<4 ){
        cout << "No" << endl;
    }else{
        for( int i=0; i<=(n/4); i++)
        {
            for( int j=0; j<=(n/7); j++ )
            {
                if( (i*4+j*7)==n )
                {
                    flg=true;
                    break;
                }
            }
            if(flg) break;
        }
        if(flg)
        {
            cout << "Yes" << endl;
        }else{    
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	nInt := readLineToInt(sc)
	hInts := explodeInt(" ", readLine(sc))

	var outputValue, maxHeight int

	for index := 0; index < nInt; index++ {
		if index == 0 {
			outputValue++
			maxHeight = hInts[index]
		} else {
			if hInts[index] >= maxHeight {
				outputValue++
				maxHeight = hInts[index]
			}
		}
	}

	fmt.Println(outputValue)
}

// helper

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return strings.TrimSpace(sc.Text())
}

func readLineToInt(sc *bufio.Scanner) int {
	intValue, err := strconv.Atoi(readLine(sc))
	if err != nil {
		panic(err)
	}

	return intValue
}

func explodeString(delimiter string, inputValue string) []string {
	splittedValue := strings.Split(inputValue, delimiter)

	var trimmedValues []string

	for _, value := range splittedValue {
		if value != "" {
			trimmedValues = append(trimmedValues, value)
		}
	}

	return trimmedValues
}

func explodeInt(delimiter string, inputValue string) []int {
	inputStrings := explodeString(" ", inputValue)

	var splittedInts []int

	for _, inputString := range inputStrings {
		var (
			intValue int
			err      error
		)
		intValue, err = strconv.Atoi(inputString)

		if err != nil {
			panic(err)
		}
		splittedInts = append(splittedInts, intValue)
	}

	return splittedInts
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val pfMap = mutableMapOf<Int, Map<Int, Int>>()
    (2..100).forEach { pfMap[it] = calcFactors(it) }

    val pfCountMap = mutableMapOf<Int, Int>()
    pfMap.filter { it.key <= n }.forEach {
        it.value.forEach { vit ->
            pfCountMap[vit.key] = vit.value + if (pfCountMap.containsKey(vit.key)) pfCountMap[vit.key]!! else 0
        }
    }

    val count2 = pfCountMap.count { it.value >= 2 }
    val count4 = pfCountMap.count { it.value >= 4 }
    val count14 = pfCountMap.count { it.value >= 14 }
    val count24 = pfCountMap.count { it.value >= 24 }
    val count74 = pfCountMap.count { it.value >= 74 }

    print(count74
            + count24 * count2 - count24
            + count14 * count4 - count14
            + count4 * (count4 - 1) * (count2 - 2) / 2)

}


fun calcFactors(n: Int): Map<Int, Int> {//素因数分解
    val factors = mutableMapOf<Int, Int>()
    var tmp = n
    var i = 2
    while (i * i <= tmp) {
        while (tmp % i == 0) {
            factors[i] = factors.getOrElse(i) { 0 } + 1
            tmp /= i
        }
        i++
    }
    if (tmp > 1) factors[tmp] = 1
    return factors
}

Measured memory_bytes: 33696
if __name__ == '__main__':
    while 1:
        n,a,b,c,x = list(map(int,input().strip().split()))
        if n ==0 and a == 0 and b ==0 and c ==0 and x ==0:break
        dataline = list(map(int,input().strip().split()))
        f =0
        count = 0
        while 1:
            if x == dataline[count]:count +=1
            if count == n: break
            f +=1
            x = (a * x + b) % c
            if f > 10000:
                f = -1
                break

        print(f)

Measured memory_bytes: 7664
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	int n,i,k,s=0;
	cin>>n>>k;
	int a[n];
	rep(i,0,n) cin>>a[i];
	sort(a,a+n);
	rep(i,0,k) s+=a[i];
	 cout<<s;
	
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 3664
n, k = map(int, input().split())
a = list(map(int, input().split()))

num = 1
li = [1]
flag = [True]*n
flag[0] = False

for i in range(k):
    num = a[num-1]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d

print(li[ans])

Measured memory_bytes: 32348
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
 var L = parseInt(lines[0].split(' ')[0],10);
 var H = parseInt(lines[0].split(' ')[1],10);
 var b = parseInt(lines[0].split(' ')[2],10);
var count = 0;
  
  for(var i=L;i<=H;i++){
  	if(i%b === 0){
    	count++;
    }
  }
console.log(count);
  
});

Measured memory_bytes: 30008
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
ll modpow(ll n, ll x, ll MOD){
	ll ret = 1;
	while(x){
		if(x&1){
			(ret*=n)%=MOD;
		}
		x >>= 1;
		(n*=n)%=MOD;
	}
	return ret;
}
int solve(int k, int MOD){
	if(__gcd(10, MOD) != 1){
		return -1;
	}
	for(int i = 1; i < MOD; ++i){
		if(modpow(10, i, MOD) == 1){
			return i;
		}
	}
}
int main(){
	int k;
	cin >> k;
	if(k%7 == 0){
		cout << solve(k, 9*(k/7));
	}
	else{
		cout << solve(k, 9*k);
	}
}


Measured memory_bytes: 3636
#include <stdio.h>
void PrintRectangle (int H, int W){
	int i, j;
	if(i=1){
		for(j=1; j<=W; j++)
			putchar('#');
		putchar('\n');
	}
	for(i=2; i<=H-1; i++){
		if(j=1)
			putchar('#');
		for(j=2; j<=W-1; j++)
			putchar('.');
		if(j=W)
			putchar('#');
		putchar('\n');
	}
	if(i=H){
		for(j=1; j<=W; j++)
			putchar('#');
		putchar('\n');
	}
}
int main(void)
{
	int H,W;
	while (1){
		scanf("%d %d", &H, &W);
		if (H==0 && W==0)
			break;
		PrintRectangle(H,W);
	putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 572
N=gets.to_i
a = gets.split.map(&:to_i)

h = Hash.new(0)

a.each{|t|
  h[t] += 1
}

w = [h[0], h[0]+h[1]]
(100000-1).times{|i|
  w << w[i+1] + h[i+2] 
}

q = [w[2]]
(100000-2).times{|i|
  q << w[i+3] - w[i]
}

puts q.max

Measured memory_bytes: 13828
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

using ld = double;
using Point =  complex<ld>;
const ld eps = 1e-10;
const ld pi = acos(-1.0);

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}
//内積
ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
//外積
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}

bool cmp(Point x,Point y){
	if(eq(x.real(),y.real()))return x.imag()<y.imag();
	return x.real()<y.real();
}

//線分
//直線にするなら十分通い２点を端点とすればよい
class Line {
public:
	Point a, b;
};
//円

//点が線分上に存在するか
bool isis_sp(Line s, Point p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
//線分と線分の交差判定
bool isis_ss(Line s, Line t) {
	if (isis_sp(s, t.a) || isis_sp(s, t.b) || isis_sp(t, s.a) || isis_sp(t, s.b))return true;
	return(cross(s.b - s.a, t.a - s.a)*cross(s.b - s.a, t.b - s.a) < -eps && cross(t.b - t.a, s.a - t.a)*cross(t.b - t.a, s.b - t.a) < -eps);
}

ld dp[1111][1111];
ld dq[1111][1111];
int main(){
    int n,m;
    cin>>n>>m;
    vector<Point> p(n),q(m);
    rep(i,n){
        int x,y;
        cin>>x>>y;
        p[i]=Point(x,y);
    }
    rep(i,m){
        int x,y;
        cin>>x>>y;
        q[i]=Point(x,y);
    }
    rep(i,n)rep(j,n)dp[i][j]=abs(p[i]-p[j]);
    rep(i,m)rep(j,m)dq[i][j]=abs(q[i]-q[j]);
    ld ans=1e9;
    vector<ld> distp(n,inf);
    distp[0]=0;
    priority_queue<pair<ld,int>,vector<pair<ld,int>>,greater<pair<ld,int> > > que;
    que.push({0,0});
    while(que.size()){
        ld d=que.top().first;
        int cur=que.top().second;
        que.pop();
        if(d>distp[cur])continue;
        rep(i,n){
            if(cur==i)continue;
            if(isis_ss(Line{p[cur],p[i]},Line{q[0],q[1]}))continue;
            if(distp[i]>distp[cur]+dp[i][cur]){
                distp[i]=distp[cur]+dp[i][cur];
                que.emplace(distp[i],i);
            }
        }
    }

    vector<ld> distq(m,inf);
    distq[0]=0;
    que.push({0,0});
    while(que.size()){
        ld d=que.top().first;
        int cur=que.top().second;
        que.pop();
        if(d>distq[cur])continue;
        rep(i,m){
            if(cur==i)continue;
            if(isis_ss(Line{q[cur],q[i]},Line{p[0],p[1]}))continue;
            if(distq[i]>distq[cur]+dq[i][cur]){
                distq[i]=distq[cur]+dq[i][cur];
                que.emplace(distq[i],i);
            }
        }
    }
    ans = min(ans,dq[0][1]+distp[1]);
    ans = min(ans,dp[0][1]+distq[1]);
    if(ans>=1e9){
        cout<<-1<<endl;
    }
    else cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}


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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    int A, B;
    cin >> A >> B;

    print(max(0, A-2*B));
}

signed main() {
    solve();
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> D(N);
    rep(i, N) cin >> D[i];
    sort(D.begin(), D.end());
    D.erase(unique(D.begin(), D.end()), D.end());
    cout << D.size() << endl;
    return 0;
}


Measured memory_bytes: 3508