akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	string S[200000];
	int c;
	int max_c;

	cin >> N;
	for(int i=0; i<N; i++){
		cin >> S[i];
	}
	sort(S,S+N);

	c=1; max_c=0;
	for(int i=1; i<N; i++){
		if(S[i]!=S[i-1]){
		  if(max_c<c){ max_c=c; }
		  c=0;
		}
		c++;
	}
	if(max_c<c){ max_c=c; }

	c=0;
	for(int i=1; i<N; i++){
		c++;
		if(S[i]!=S[i-1]){
		  if(max_c==c){ cout << S[i-1] << endl; }
		  c=0;
		}
	}
	c++;
	if(max_c==c){ cout << S[N-1] << endl; }


	
}

Measured memory_bytes: 14208
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int a, b;
  cin >> a >> b;
  vector<int> n(4, true);
  n[a] = n[b] = false;

  for (int i = 1; i <= 3; i++) {
    if (n[i]) {
      cout << i << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
#define R(i,n) for(int i = 1; i<=n; i++)
typedef long long ll;
using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  vector<int> a(h,0),b(w,0);
  vector<vector<char>> v(h,vector<char>(w,0));
  r(i,h){
    r(j,w){
      cin >> v.at(i).at(j);
      if(v.at(i).at(j)=='#'){
        a.at(i)++; b.at(j)++;
      }
    }
  }
  r(i,h){
    if(a.at(i)>0){
    r(j,w){
      if(b.at(j)>0)cout << v.at(i).at(j);
    }
    cout << endl;
  }
  }
}

Measured memory_bytes: 256
n = int(input())
A = [0]*n
B = list(map(int,input().split()))
for i in range(n):
  if i==0:
    A[i] = B[i]
  else:
    if i==n-1:
      A[i] = B[i-1]
      break
    A[i] = min(B[i-1], B[i])
print(sum(A))

Measured memory_bytes: 3060
x,y=map(int,input().split())
while not (x==0 and y==0):
    if (x>y):
        print(str(y)+" "+str(x))
    elif (x<y):
        print(str(x)+" "+str(y))
    else:
        print(str(x)+" "+str(y))
    x,y=map(int,input().split())


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

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

	// 鶴の数を全探索
	rep(i,101){
		int kame = x - i;
		if(kame < 0) continue;
		if(2*i + 4*kame == y){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>

int main(int argc, const char * argv[])
{
    int a, b;
    
    while (scanf("%d %d", &a, &b) != -1) {
        printf("%d\n", (int)log10(a+b) + 1);
    }

    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string s;
  cin >> N >> s;

  int R = 0;
  int B = 0;
  for (int i = 0; i < N; i++) {
    char c = s.at(i);
    if (c == 'R') {
      R++;
    } else {
      B++;
    }
  }

  string ret = "No";
  if (R > B) {
    ret = "Yes";
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll K;
    cin >> K;
    
    auto check = [&](ll X){
        // Xを桁ごとのvectorに変換
        vector<int> vx;
        ll tmp = X;
        while(tmp > 0){
            vx.push_back(tmp%10);
            tmp/=10;
        }
        reverse(all(vx));
        //桁数
        int N = vx.size();
        // dp[i][smaller][0以外を一度でも取ったか][最後の数字]
        ll dp[N+1][2][2][10];
        rep(i,N+1)rep(j,2)rep(k,2)rep(l,10)
            dp[i][j][k][l] = 0;

        dp[0][0][0][0] = 1;
        //dpの遷移
        for(int i = 0; i < N; i++)rep(j,2)rep(k,2)rep(l,10){
            int minl = max(0, l-1);
            int maxl = min(l+1, (j ? 9:vx[i]));
            if(k == 0 && j == 1)maxl = 9;
            if(k == 0 && j == 0)maxl = vx[i];
            for(int nxt = minl; nxt <= maxl; nxt++){
                dp[i+1][j || nxt < vx[i]][k || nxt > 0][nxt] +=  dp[i][j][k][l];
            }
        }
        ll cnt = 0;
        rep(j,2)rep(l,10)cnt += dp[N][j][1][l];
        return cnt >= K;
    };
    ll ng = 0;
    ll ok = 1e18;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

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

using namespace std;


#define MAXN 100001
const int INF = 1e9+1;
int pos[MAXN];
bool ans = true;
vector<pair<int, int>> g[MAXN];
pair<int, int> dif;

void dfs(int u, int p) {
  if (pos[u]!=INF) {
    ans &= pos[u]==p;
    return;
  }
  pos[u] = p;
  dif = {min(dif.first, p), max(dif.second, p)};
  for (auto &vv : g[u]) {
    int v, d;
    tie(v, d) = vv;
    dfs(v, p+d);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int u = 1; u <= n; ++u) {
    pos[u] = INF;
  }
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    g[r].push_back({l, -d});
    g[l].push_back({r, d});
  }
  for (int u = 1; u <= n; ++u) {
    dif = {0, 0};
    if (pos[u]==INF) dfs(u, 0);
    ans &= dif.second - dif.first <= (int)1e9;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 11008
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, int s>using va = vector<array<T, s>>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define rrep(i,a) for(int i=a-1;i>=0;i--)
#define rrep1(i,a) for(int i=a;i;i--)
const ll mod = 1000000007;
#define REP rep
template<class T>using heap = priority_queue<T, vector<T>, greater<T>>;
template<class T>using pque = priority_queue<T, vector<T>, function<T(T, T)>>;
template <class T>
inline void hash_combine(size_t & seed, const T & v) {
	hash<T> hasher;
	seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std {
	template<typename S, typename T> struct hash<pair<S, T>> {
		inline size_t operator()(const pair<S, T> & v) const {
			size_t seed = 0;
			hash_combine(seed, v.first);
			hash_combine(seed, v.second);
			return seed;
		}
	};
	// Recursive template code derived from Matthieu M.
	template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
	struct HashValueImpl{
		static void apply(size_t& seed, Tuple const& tuple){
			HashValueImpl<Tuple, Index - 1>::apply(seed, tuple);
			hash_combine(seed, std::get<Index>(tuple));
		}
	};
	template <class Tuple>
	struct HashValueImpl<Tuple, 0>{
		static void apply(size_t& seed, Tuple const& tuple){
			hash_combine(seed, std::get<0>(tuple));
		}
	};
	template <typename ... TT>
	struct hash<std::tuple<TT...>>{
		size_t operator()(std::tuple<TT...> const& tt) const{
			size_t seed = 0;
			HashValueImpl<std::tuple<TT...> >::apply(seed, tt);
			return seed;
		}
	};
}
template<class T>int id(vector<T> &a, T b) {
	return lower_bound(ALL(a), b) - a.begin();
}
//end of lib
int main() {
	int s;
	cin >> s;
	while (s--) {
		vll in(9);
		rep(i, 9)cin >> hex >> in[i];
		ll key = 0;
		int c = 0;
		rep(i, 32) {
			ll a = c;
			rep(j, 8)a += in[j] >> i;
			if ((a^in[8] >> i) & 1) {
				key |= 1ll << i;
				rep(j, 9)in[j] ^= 1ll << i;
			}
			c = 0;
			rep(j, 8)c += in[j] & (2 << i) - 1;
			c = c >> i + 1;
		}
		cout << hex << key << endl;
	}
}

Measured memory_bytes: 3052
#include <algorithm>
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
const int MOD = (int)1e9 + 7;

template<class T> struct Parser {
    typedef string::const_iterator State;
    State end;

    T solve(const string &S) {
        State begin = S.begin();
        end = S.end();
        return expr(begin);
    }

    // expr ::= term | expr ">>" term
    // expr ::= term { ">>" term }
    T expr(State &begin) {
        T ret = term(begin);
        while (end - begin >= 2) {
            if (*begin == '>' && *(begin + 1) == '>' && *(begin + 2) != '>') {
                begin += 2;
                ret = ret >> min(term(begin), 31);
            } else {
                break;
            }
        }
        return ret;
    }

    // term ::= number | "S" "<" expr ">"
    T term(State &begin) {
        if (*begin == 'S') {
            begin += 2;
            T ret = expr(begin);
            begin++;
            return 1LL * ret * ret % MOD;
        } else {
            return number(begin);
        }
    }

    // number ::= digit | number digit
    // digit  ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
    T number(State &begin) {
        T ret = 0;
        while (isdigit(*begin)) {
            ret *= 10;
            ret += *begin - '0';
            begin++;
        }
        return ret;
    }
};

int main() {
    Parser<int> ps;
    string tmp;
    while (getline(cin, tmp) , tmp != "#") {
        string S = "";
        for (auto &it : tmp) if (it != ' ') S += it;
        cout << ps.solve(S) << endl;
    }
    return 0;
}


Measured memory_bytes: 5904
import java.util.*;

public class Main {
    void solve(){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt() % 2;
        int b = scan.nextInt() % 2;
        System.out.println(a * b == 0 ? "Even" : "Odd");
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35444
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s >> t;
    int ls = s.length(), lt = t.length();
    for(int i = ls - 1; i >= 0; --i) {
        for(int j = 0; j < lt; ++j) {
            if(s[i - j] != t[lt - j - 1] && s[i - j] != '?') break;
            if(j + 1 == lt) {
                s.replace(i - j, lt, t);
                for(int k = 0; k < ls; ++k)
                    if(s[k] == '?') s[k] = 'a';
                cout << s << endl;
                return 0;
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
}

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

int main(){

   int x,y,ans = 0;

   cin >> x >> y;
   if(x==1) ans+=300000;
   if(x==2) ans+=200000;
   if(x==3) ans+=100000;

   if(y==1) ans+=300000;
   if(y==2) ans+=200000;
   if(y==3) ans+=100000;

   if(x==1&&y==1) ans+=400000;
   cout << ans;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = p[0] == 1 ? 1 : 0;
        boolean isContinuous = false;
        for (int i = 1; i < p.length; i++) {
            if (i + 1 == p[i]) {
                isContinuous = i == p[i - 1] && !isContinuous;
                if (!isContinuous) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 48852
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String,Integer> map = new HashMap<String,Integer>();
        String temp = sc.nextLine();

        int N = Integer.parseInt(temp);

        temp = sc.nextLine();
        String[] tempArr = temp.split(" ");
        int[] intArr = new int[N];

        for (int i = 0; i < N; i++) {
            intArr[i] = Integer.parseInt(tempArr[i]);
        }

        int previousGCD = 0;
        for (int j = 0; j < N; j++) {
            previousGCD = gcd(previousGCD,intArr[j]);

        }

        System.out.println(previousGCD);


    }

    static int gcd(int a, int b) {
        if (b > 0) {
            return gcd(b, a % b);
        } else {
            return a;
        }
    }

}


Measured memory_bytes: 48744
/*隣接しているところに絶対行く。
間の距離を計算。
*/

#include<stdio.h>

int main(){
	int K, N, i, dist;
	scanf("%d %d", &K, &N);
	int A[N], d[N];
	for(i = 0; i < N; i++){
		scanf("%d", &(A[i]));
	};
	for(i = 0; i < N - 1; i++){
		d[i] = A[i+1] - A[i];
	}
	d[N-1] = (K - A[N-1]) + A[0];
	/*d[i] は i と i+1の間の距離*/
	dist = K;
	for(i = 0; i < N; i++){
		if(K - d[i] < dist){
			dist = K - d[i];
		}
	}
	printf("%d\n", dist);
	/*printf("%d %d\n", K, N);
	for(i = 0; i < N; i++){	
		printf("%d ", A[i]);
	}*/
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N,M;
    cin >> N >> M;
    vector<pair<long,long>> valAmount(N);
    for(int i = 0; i < N; i++)
    {
        cin >> valAmount[i].first;
        cin >> valAmount[i].second;
    }
    sort(valAmount.begin(),valAmount.end());
        for(int i = 0; i < N; i++)
    {
        //cout << valAmount[i].first;
        //cout << valAmount[i].second;
    }
    long currentCost = 0;
    long currentAmount = 0;
    long currentIndex = 0;
    while(true){
        if(M - currentAmount <= valAmount[currentIndex].second){
            currentCost += valAmount[currentIndex].first * (M - currentAmount);
            break;
        }else{
            currentAmount += valAmount[currentIndex].second;
            currentCost += valAmount[currentIndex].first * valAmount[currentIndex].second;
            
        }
        currentIndex++;
        //cout << endl << currentCost << "," << currentAmount << endl;
        
    }
    cout << currentCost << endl;
}

Measured memory_bytes: 1792
H, W, K = map(int, input().split())
C = [[i for i in input()] for j in range(H)]

ans = 0
for h_bit in range(1 << H):
	for w_bit in range(1 << W):
		black = 0
		for i in range(H):
			for j in range(W):
				if h_bit & (1 << i) and w_bit & (1 << j):
					if C[i][j] == '#':
						black += 1
		if black == K:
			ans += 1
			
print(ans)

Measured memory_bytes: 9100
def main():
    s = input()

    if s == "SUN":
        print(7)
    elif s == "MON":
        print(6)
    elif s == "TUE":
        print(5)
    elif s == "WED":
        print(4)
    elif s == "THU":
        print(3)
    elif s == "FRI":
        print(2)
    else:
        print(1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var r = o.a();
  return 3*r*r;
}

Measured memory_bytes: 22964
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long[] data = new long[3];

    for (int i = 0 ; i < 3; i++) {
      data[i] = sc.nextInt();
    }

    int k = sc.nextInt();
    long sum = 0;

    if (data[0] == 0 && data[1] == 0) {
      System.out.println((-1)*k);
      return;
    } else {
      long count = 0;
      for (int i = 0; i < 3; i++) {
        if (i == 0) {
          if (data[i] <= k) {
            sum += 1*data[i];
          } else {
            sum += 1*k;
          }
        }
        if (i == 1) {
          if (data[i]+count <= k) {
            sum += 0*data[i];
          } else {
            sum += 0*k;
          }
        }
        if (i == 2) {
          if (data[i]+count < k) {
            sum += (-1)*data[i];
          } else {
            sum += (-1)*(k-count);
          }
        }
        count += data[i];
        if (k <= count) break;
      }
    }
    System.out.println(sum);
  }

}


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

int main(){
  int N,A,B; cin >> N >> A >> B;
  string S; cin >> S;
  int dome=0, over=0;
  for(int i=0; i<N; i++){
    if(S[i]=='a'){
      if(dome+over<A+B){
        cout << "Yes" << endl;
        dome++;
      }else{
        cout << "No" << endl;
      }
    }else if(S[i]=='b'){
      if(dome+over<A+B&&over<B){
        cout << "Yes" << endl;
        over++;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 896
// E - Divisible Substring
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define modadd(x,y,m) x=(x+(y))%(m)
#define modmul(x,y,m) x=(x*(y))%(m)
#define c2d(c) ((c)-'0') // char to digit

int main(){
	int N,P; string S; cin>>N>>P>>S;
	ll ans = 0;
	if(P==2 || P==5){
		rep(i, N) if(c2d(S[N-1-i]) % P == 0) ans += N - i;
	}
	else{
		reverse(S.begin(), S.end());
		vector<ll> cnt(P, 0);
		int r = 0, ten = 1;
		cnt[r]++;
		rep(left, N){
			modadd(r, c2d(S[left])*ten, P);
			modmul(ten, 10, P);
			cnt[r]++;
		}
		rep(r, P) ans += cnt[r] * (cnt[r]-1) / 2;
	}
	cout<< ans <<endl;
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

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

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7


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

  vector<bool> prim(N+1, true);

  prim[0] = false;
  prim[1] = false;
  for( int i=4; i<=N; i+=2 ) prim[i] = false;
  for( int i=3; i<=N; i+=2 ){
    for( int j=2; i*j <= N; j++ ){
      prim[i*j] = false;
    }
  }

  vi counter(N+1, 0);
  for( int i=2; i<=N; i++ ){
    int n = i;
    for( int j=2; j<=N+1; j++ ){
      if( !prim[j] ) continue;
      int cnt = 0;
      while( n%j == 0 ){
        cnt++;
        n /= j;
      }
      counter[j] += cnt;
      if( n == 1 ) break;
    }
  }

  vi counter2(5,0);
  for( auto &val : counter ){
    if( val >= 74 ) counter2[0]++;
    if( val >= 24 ) counter2[1]++;
    if( val >= 14 ) counter2[2]++;
    if( val >= 4  ) counter2[3]++;
    if( val >= 2  ) counter2[4]++;
  }
  int ret = 0;
  ret += counter2[0];
  if( counter2[1] >= 1 )
    ret += counter2[1] * (counter2[4]-1);
  if( counter2[2] >= 1 )
    ret += counter2[2] * (counter2[3]-1);
  if( counter2[3] >= 1 )
    ret += (counter2[3] * (counter2[3]-1) * (counter2[4]-2)) / 2;

  cout << ret << endl;

  return 0;
}



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

int main(){
	int N , M , a , b;
  	cin >> N >> M;
  	vector <int> count(N , 0);
  	for (int i = 0 ; i < M ; i ++){
    	cin >> a >> b;
      	count.at(a-1) += 1;
      	count.at(b-1) += 1;
    }
  	for(int i = 0 ; i < N ; i ++){
    	cout << count.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	long long int n,i,c,w[10],h;
	c=0;
	while(1){
		scanf("%lld",&h);
		if(h==0) break;
		for(i=0;i<10;i++){
			w[i]=0;
		}	
		for(i=0;i<h;i++){
			scanf("%lld",&n);
			if(n>=0&&n<=9){
				w[0]+=1;
			}
			if(n>=10&&n<=19){
				w[1]+=1;
			}
			if(n>=20&&n<=29){
				w[2]+=1;
			}
			if(n>=30&&n<=39){
				w[3]+=1;
			}
			if(n>=40&&n<=49){
				w[4]+=1;
			}
			if(n>=50&&n<=59){
				w[5]+=1;
			}
			if(n>=60){
				w[6]+=1;
			}	
		}
		for(i=0;i<7;i++){
			printf("%lld\n",w[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define akumanosuuji = 666;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    char c[3];
    cin >> c[0] >> c[1] >> c[2];
    sort(c,c+3);
    cout << (c[0]=='a'&&c[1]=='b'&&c[2]=='c' ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
c,r=map(int,input().split())
a=[]
for i in range (c):
    a.append(list(map(int,input().split())))
    a[i]+=[sum(a[i])]
    print(*a[i])
    
a=list(zip(*a[::-1]))
for i in range(r):print(sum(a[i]),end=' ')
print(sum(a[r]))


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

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a = a * a;
        b = b * b;
        c = c * c;
        if ((a == b + c) || (b == a + c) || (c == a + b)) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int main()
{
    int n;
    int a[1000];
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = n - 1; i > 0; --i)
    {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3096
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N=sc.nextInt();
	        ArrayList<Long> a = new ArrayList<>();
	        for (int i=0 ; i<N; i++) {
	            a.add(sc.nextLong());
	        }
	        long[] m= new long[N];
	        for(int i=0;i<N;i++) {
	        	for(int j=a.size()-1;j>=0;j--) {
	        		if(a.get(j)==j+1) {
	        			m[i]=a.get(j);
	        			a.remove(j);
	        			break;
	        		}
	        		if(j==0) {
	        			System.out.println(-1);
	        			return;
	        		}
	        	}
	        }
	        for(int i=N-1;i>=0;i--) {
	        	System.out.println(m[i]);
	        }
	        
	 }

}

Measured memory_bytes: 23252
n = int(input())
A = list(map(int, input().split()))
SWAP = 0

def conquer(A, left, mid, right):
  L, R = A[left:mid], A[mid:right]
  # L, Rの末尾にINFTYを入れないと、L[-1] or R[-1]が評価されない
  INFTY = 2 ** 30
  L.append(INFTY)
  R.append(INFTY)
  # i : position in L, j : position in R
  i, j = 0, 0

  swap_times =  0

  # 元のArrayを変えたいため、kを生成
  for k in range(left, right):
    # print(i, j, L, R, A)
    if L[i] <= R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1
    swap_times += 1

  return swap_times

def divide(A, left, right):
  # print(left, right)

  # A[right-left]が2つ以上の場合に
  if left+1 < right:
    mid = (left+right)//2

    countL = divide(A, left, mid)
    countR = divide(A, mid, right)

    return conquer(A, left, mid, right) + countL + countR

  return 0

def mergeSort(A):
  return divide(A, 0, len(A))

swap = mergeSort(A)

print(" ".join([ str(i) for i in A]))
print(swap)


Measured memory_bytes: 66992
#include <iostream>
#include <vector>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
using namespace std;


int main() {
    string s;
    cin >> s;
    int size = s.size();
    long long ans = 0;
    rep(i, (1 << (size - 1))){
        int l = 0;
        string tmp;
        rep(j, size - 1){
            if((1 << j & i) == (1 << j)){
                int r = j;
                tmp = s.substr(l, (r - l) + 1);
                //cout << tmp << " ";
                int val = stoll(tmp);
                ans += val;
                l = r + 1;
            }
        }
        tmp = s.substr(l, size - l);
        ans += stoll(tmp);
        //cout << tmp << endl;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    int num = 1;
    
    for(int i=0;i<N;i++){
        if(num < K){
            num *= 2;
        }
        else{
            num += K;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 400010;
const int inf  = 0x3f3f3f3f;

int n,m,tol,head[maxn];
struct edge
{
    int to,cost,next;
}es[maxn<<1];

void addedge( int u , int v , int w )
{
    es[tol].to = v;
    es[tol].cost = w;
    es[tol].next = head[u];
    head[u] = tol++;
}

struct node
{
    int from,to,cost;
    friend bool operator<( const node&a , const node&b )
    {
        return a.cost<b.cost;
    }
}data[maxn];

int dis[maxn],vis[maxn],used[maxn],pre[maxn],id[maxn],sizes;

int Find( int x )
{
    if ( x!=pre[x] )
        pre[x] = Find( pre[x] );
    return pre[x];
}

void Build( int l , int r )
{
    for ( int i=l ; i<=r ; i++ )
    {
        pre[data[i].to] = data[i].to;
        pre[data[i].from] = data[i].from;
        id[data[i].to] = -1;
        id[data[i].from] = -1;
        used[data[i].to] = 0;
        used[data[i].from] = 0;
    }
    for ( int i=l ; i<=r ; i++ )
    {
        int fx = Find( data[i].from );
        int fy = Find( data[i].to );
        if ( fx!=fy )
            pre[fy] = fx;
    }
    for ( int i=l ; i<=r ; i++ )
    {
        int fx = Find( data[i].from );
        int fy = Find( data[i].to );
        if ( !used[data[i].from] )
        {
            if ( id[fx]==-1 )
                id[fx] = ++sizes;
            addedge( data[i].from , id[fx] , 1 );
            addedge( id[fx] , data[i].from , 1 );
        }
        if ( !used[data[i].to] )
        {
            if ( id[fy]==-1 )
                id[fy] = ++sizes;
            addedge( data[i].to , id[fy] , 1 );
            addedge( id[fy] , data[i].to , 1 );
        }
    }
}

struct point
{
    int pos,dis;
    friend bool operator<( const point&a , const point&b )
    {
        return a.dis>b.dis;
    }
};

void dijkstra()
{
    priority_queue<point>Q;
    for ( int i=1 ; i<=sizes ; i++ )
        dis[i] = inf,vis[i] = 0;
    dis[1] = 0;
    point p,q;
    p.pos = 1;
    p.dis = 0;
    Q.push(p);
    while ( !Q.empty() )
    {
        p = Q.top();
        Q.pop();
        int u = p.pos;
        if ( vis[u] )
            continue;
        vis[u] = 1;
        for ( int i=head[u] ; i!=-1 ; i=es[i].next )
        {
            int v = es[i].to,w = es[i].cost;
            if ( dis[v]>dis[u]+w )
            {
                dis[v] = dis[u]+w;
                p.pos = v;
                p.dis = dis[v];
                Q.push(p);
            }
        }
    }
}

int main()
{
    for ( ; scanf ( "%d%d" , &n , &m )==2 ; )
    {
        for ( int i=1 ; i<=m ; i++ )
            scanf ( "%d%d%d" , &data[i].from , &data[i].to , &data[i].cost );
        sort ( data+1 , data+m+1 );
        tol = 0;
        sizes = n;
        memset ( head , -1 , sizeof(head) );
        for ( int i=1 ; i<=m ; i++ )
        {
            int l=i,r=i;
            while ( r+1<=m&&data[r+1].cost==data[i].cost )
                r++;
            Build( l , r );
            i = r;
        }
        dijkstra();
        if ( dis[n]==inf )
            dis[n] = -2;
        printf ( "%d\n" , dis[n]>>1 );
    }
    return 0;
}


Measured memory_bytes: 21496
n,m,q = list(map(int, input().split()))
abcd = [list(map(int,input().split())) for _ in range(q)]
ans = 0

def dfs(v,pre):
    global ans
    if len(v) >= n:
        cnt = 0
        for a,b,c,d in abcd:
            if (v[b-1] - v[a-1] == c):
                cnt += d
        ans = max(ans, cnt)
        return 

    for i in range(pre, m+1):
        v.append(i);
        dfs(v, i)
        v.pop(-1)


v = [1]
dfs(v,1)
print(ans)


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

int divisor(long long n){
    std::vector<long long > res;
    for(long long i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            long long j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    std::sort(res.begin(),res.end());
    return res.size();
}

int main()
{
    int n; std::cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i+=2){
        if(divisor(i) == 8)cnt++;
    }
    std::cout << cnt << std::endl;
}

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

int main(){
	int n,k,a,b,t[102]={0},dp[102][5][5]={0};
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++){
		scanf("%d%d",&a,&b);
		t[a]=b;
	}
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			if((t[1]==0||t[1]==i)&&(t[2]==0||t[2]==j))dp[2][j][i]++;
		}
	}
	for(int m=3;m<=n;m++){
		int sum=0;
		for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)sum+=dp[m-1][i][j];
		for(int i=1;i<=3;i++){
			for(int j=1;j<=3;j++){
				if(t[m]==0||t[m]==i){
					dp[m][i][j]=dp[m-1][j][1]+dp[m-1][j][2]+dp[m-1][j][3];
					if(i==j)dp[m][i][j]-=dp[m-1][i][i];
				}
				dp[m][i][j]%=10000;
			}
		}
	}

				
	int sum=0;
	for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)sum+=dp[n][i][j];
	printf("%d\n",sum%10000);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

ll big = 1e16;

ll solve() {
  ll N; cin >> N;
  vector<ll> A(N+1);
  for (ll i = 0; i <= N; i++) cin >> A.at(i);

  if (N == 0) {
    if (A.at(0) == 1) return 1;
    else return -1;
  }

  if (A.at(0) != 0) return -1;
  vector<ll> p(N+1);
  p.at(0) = 1;
  for (ll i = 1; i < N; i++) {
    if (p.at(i-1) >= big) p.at(i) = big;
    else {
      ll x = p.at(i-1) * 2 - A.at(i);
      if (x <= 0) return -1;
      p.at(i) = x;
    }
  }
  if (p.at(N-1) * 2 < A.at(N)) return -1;
  vector<ll> r(N+1);
  r.at(N) = 0;
  for (ll i = N-1; i >= 0; i--) {
    ll t = r.at(i+1) + A.at(i+1);
    if (t <= p.at(i)) r.at(i) = t;
    else              r.at(i) = p.at(i);
  }
  ll ans = 0;
  for (ll i = 0; i <= N; i++) {
    ans += A.at(i) + r.at(i);
  }
  return ans;
  
}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << solve() << endl;

  return 0;
}



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

int n,ans,d[210][210],a;
string s;

int main(){
    cin>>n;
    vector<vector<int>> p(n);
    for(int i=0;i<n;i++){
        cin>>s;
        for(int j=0;j<n;j++){
            if(s[j]=='1'){
                if(i<j){
                    p[i].push_back(j);
                    p[j].push_back(i);
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        queue<int> q;
        q.push(i);
        while(q.size()){
            a=q.front();
            q.pop();
            for(int j=0;j<p[a].size();j++){
                if(!d[i][p[a][j]] && p[a][j]!=i){
                    q.push(p[a][j]);
                    d[i][p[a][j]]=d[i][a]+1;
                    ans=max(ans,d[i][p[a][j]]);
                }
                else{
                    if((d[i][p[a][j]]+d[i][a]+1)%2==1){
                        cout<<-1<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
void over_b(int i,int *p,int *q);
int main(void)
{
    int n,i;
    scanf("%d",&n);
    int b[n],a[n];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    over_b(n-1,b,a);
    for(i=0;i<n;i++)
    printf(" %d",b[i]);
}
void over_b(int i,int *p,int *q)
{
    int j=0,z=i;
    if(i%2==0)
while(i>=0){
    if(i%2==0) p[j]=q[i];
    else {p[z]=q[i]; z--; j--; }
    i--;
    j++;
    }
  else
while(i>=0){
    if(i%2!=0) p[j]=q[i];
    else {p[z]=q[i]; z--; j--;}
    i--;
    j++;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  ll n;
  cin >> n;
  map<ll, int> pf = prime_factor(n);

  int minus = 1, ans = 0;
  while (true) {
    bool flg = false;
    for (auto p : pf) {
      if (p.second - minus >= 0) {
        ans++;
        flg = true;
      }
      pf[p.first] -= minus;
    }
    if (!flg)
      break;
    minus++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define f first
#define s second
#define pb push_back

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<pair<int, int>>l;
		vector<pair<int, int>>r;
		int ans=0;
		for(int i=0; i<n; i++){
			int k, l1, r1;
			cin>>k>>l1>>r1;
			ans=ans+min(l1, r1);
			if(l1>r1){
				l.pb({l1-r1, k});
			}
			else{
				r.pb({r1-l1, k});
			}
		}
		int pre[n+1];
		for(int i=0; i<=n; i++){
			pre[i]=0;
		}
		for(auto u:l){
			pre[u.s]+=1;
		}
		for(int i=n-1; i>=1; i--){
			pre[i]=pre[i]+pre[i+1];
		}
		int mini=1e9;
		for(int i=1; i<=n; i++){
			mini=min(mini, i+pre[i]-1);
		}
		vector<vector<int>>v;
		v.resize(n+1);
		for(auto u:l){
			if(u.s>=mini){
				v[mini].pb(u.f);
			}
			else{
				v[u.s].pb(u.f);
			}
		}
		multiset<int>se;
		for(int i=mini; i>=1; i--){
			for(auto u:v[i]){
				se.insert(u);
			}
			auto it=se.end();
			it--;
			ans+=((*it));
			se.erase((se.find((*it))));
		}
		for(int i=0; i<=n; i++){
			pre[i]=0;
		}
		for(auto u:r){
			if(u.s==n){
				continue;
			}
			pre[u.s+1]+=1;
		}
		for(int i=1; i<=n; i++){
			pre[i]=pre[i]+pre[i-1];
		}
		int maxi=-1;
		for(int i=n; i>=1; i--){
			maxi=max(maxi, i-pre[i]+1);
		}
		v.clear();
		v.resize(n+1);
		for(auto u:r){
			if(u.s==n){
				continue;
			}
			int pos=u.s+1;
			if(pos<=maxi){
				v[maxi].pb(u.f);
			}
			else{
				v[pos].pb(u.f);
			}
		}
		se.clear();
		for(int i=maxi; i<=n; i++){
			for(auto u:v[i]){
				se.insert(u);
			}
			auto it=se.end();
			it--;
			ans+=((*it));
			se.erase(se.find((*it)));
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 18020
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b || b == c || a == c) {
        if (a == b && b == c && a == c){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    q = int(input())
    mod = 1000003
    fact = [1, 1]
    for i in range(2, mod+1):
        fact.append(fact[-1]*i % mod)

    for i in range(q):
        x, d, n = map(int, input().split())
        if d == 0:
            print(pow(x, n, mod))
            continue
        elif n >= mod:
            print(0)
            continue
        b = -x*pow(d, mod-2, mod) % mod
        if b >= n:
            print(pow(fact[b-n], mod-2, mod)*fact[b]*pow(-d, n, mod) % mod)
        else:
            print(0)


main()


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read(),X=read();
	vi x(n+1,0);
	FOR(i,1,n+1)
		x[i]=x[i-1]+read();
	int ans=inf;
	FOR(i,1,n+1){
		int cost=(n+i)*X;
		int p=n;
		REP(j,n){
			if(p==0)break;
			int q=max(p-i,int(0));
			int w=j==0?5:j*2+3;
			cost+=(x[p]-x[q])*w;
			chmin(cost,inf);
			p=q;
		}
		chmin(ans,cost);
	}
	print(ans);
}


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

void call(int n)
{
    int i = 0;

    while(++i <= n) {

        if(i%3 == 0)
            cout << ' ' << i;
        else {
            int x = i;
            while(x) {
                if(x%10 == 3) {
                    cout << ' ' << i;
                    break;
                } else 
                    x /= 10;
            }
        }
    }
    cout << endl;
}

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

    call(n);

    return 0;
}



Measured memory_bytes: 3076
<?php
$n = intval(fgets(STDIN));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$low = 10**10;
$count = 0;
foreach($A as $a){
  if($a < $low){
    $count++;
    $low = $a;
  }
}
echo $count;

Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W,K; cin>>H>>W>>K;
  vector<string> S(H);
  rep(i,0,H) cin>>S[i];
  vii A(H,vi(W));
  int memo=1;
  vector<bool> F(H,1);
  rep(i,0,H){
    int count=0;
    rep(j,0,W){
      A[i][j]=memo;
      if(S[i][j]=='#'){
        memo++;
        F[i]=0;
      }
    }
    rep(j,1,W){
      if(A[i][j]==memo&&S[i][W-1]=='.') A[i][j]=A[i][j-1];
    }
  }
  rep(_,0,H){
    rep(i,0,H){
      if(F[i]){
        if(i>0&&!F[i-1]){
          rep(j,0,W) A[i][j]=A[i-1][j];
          F[i]=0;
        }
        else if(i<H-1&&!F[i+1]){
          rep(j,0,W) A[i][j]=A[i+1][j];
          F[i]=0;
        }
      }
    }
  }
  rep(i,0,H){
    rep(j,0,W) cout<<A[i][j]<<" ";
    cout<<endl;
  }
  }





Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	vector<int>v1,v2;
	for(int i=0;i<m;i++){
		int z;
		cin>>z;
		v1.push_back(z);
	}
	sort(v1.begin(),v1.end());
	for(int i=1;i<m;i++){
		v2.push_back(v1[i]-v1[i-1]);
	}
	sort(v2.begin(),v2.end());
	int ans=0;
	for(int i=0;i<m-n;i++){
		ans+=v2[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
S = input()
T = input()
def same(U):
    k = 0
    for i in range(len(U)):
        if U[i] == T[i]:
            k += 1
    return k
ans = 0
for i in range(len(S)-len(T)+1):
    ans = max(ans,same(S[i:i+len(T)]))
print(len(T)-ans)

Measured memory_bytes: 67232
p = 'ACGT'
s = input()
l = len(s)
r = 0
i = -1
while i < l:
 j = next((i for i in range(i + 1, l) if s[i] in p), l)
 i = next((i for i in range(j + 1, l) if s[i] not in p), l)
 r = max(r, i - j)
print(r)


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

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	string ans;
	ans = s1.substr(0, 1);
	char* c1 = new char[ans.size() + 1];
	strcpy(c1, ans.c_str());
	cout << (char)(*c1 - 0x20);
	ans = s2.substr(0, 1);
	char* c2 = new char[ans.size() + 1];
	strcpy(c2, ans.c_str());
	cout << (char)(*c2 - 0x20);
	ans = s3.substr(0, 1);
	char* c3 = new char[ans.size() + 1];
	strcpy(c3, ans.c_str());
	cout << (char)(*c3 - 0x20) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
ll a[105];
int main(void){
	int n,m;
	cin>>n>>m;
	ll cnt=0;
	REP(i,n){
		cin>>a[i];
		a[i]*=4*m;
		cnt+=a[i];
	}
	ll comp=cnt/(4*m);
	ll num=n;
	REP(i,n){
		if(a[i]<comp)num--;
	}
	if(num>=m)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	string S;
	
	cin >> S;

	VP RL;
	RL.push_back(make_pair(-1, 0)); // first:インデックス，　second:R,Lの個数

	int i = 0, j = 0;
	char s0 = S[0];
	for (auto& s : S) {
		if (s == s0) {
			if (s == 'R') {
				RL[j].first++;
				RL[j].second++;
			}
			else if (s == 'L') {
				RL[j].second++;
			}
		}
		else {
			RL.push_back(make_pair(i, 1));
			j++;
		}
		s0 = s;
		i++;
	}

	int ff = 1;
	const auto RL2 = RL;
	for (i = 0; i < RL.size(); i += 2) {
		RL[i].second = (RL2[i].second + 1) / 2 + RL2[i+1].second / 2;
		RL[i+1].second = (RL2[i+1].second + 1) / 2 + RL2[i].second / 2;
	}

	VI ans(S.size(), 0);
	for (auto& rl : RL) {
		ans[rl.first] = rl.second;
	}

	for (auto& a : ans) {
		cout << a << ' ';
	}
	cout << endl;
	

	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m; cin>>n>>m;
    bool g[10][10]={};
    rep(i,m){
        ll a,b; cin>>a>>b;
        --a; --b;
        g[a][b]=g[b][a]=true;
    }
    ll ans=0;
    vector<ll> p(n);
    rep(i,n) p[i]=i;
    do{
        if(p[0]!=0) break;
        bool ok=true;
        rep(i,n-1){
            if(!g[p[i]][p[i+1]]) ok=false;
        }
        if(ok) ans++;
    }while(next_permutation(all(p)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608