akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n = inp1;
    vector<pair<ll, ll>> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    sort(allof(ab));

    ll ans = 0LL;
    // 重複部分家していい？
    if (n % 2 == 1) {
        vector<ll> mi, ma;
        rep(i, n) {
            mi.emplace_back(ab[i].first);
            ma.emplace_back(ab[i].second);
        }

        sort(allof(mi));
        sort(allof(ma));
        ans = ma[(n - 1) / 2] - mi[(n - 1) / 2] + 1;
    }
    else {
        vector<ll> mi, ma;
        rep(i, n) {
            mi.emplace_back(ab[i].first * 2);
            ma.emplace_back(ab[i].second * 2);
        }

        sort(allof(mi));
        sort(allof(ma));
        ll left = (mi[n / 2] + mi[n / 2 - 1]) / 2;
        ll right = (ma[n / 2] + ma[n / 2 - 1]) / 2;

        ans = right - left + 1;
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 9776
function Main(input) {
    var N = parseInt(input[0], 10);
    var D = input.slice(1).map(n => parseInt(n));

    var result = 0;

    for (var i = 0; i < N; i++) {
        for (var j = i + 1; j < N; j++) {
            result += D[i] * D[j];
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(void) {

  while (true) {
  string str;
  getline(cin,str);
  if (str[0] == '.') break;
  bool flag = true;
  stack<int> s;
  for (size_t i = 0; str[i] != '\0'; i++) {
    //cout << i << endl;
    int c = str[i];
    if (c == 40) {
      s.push(0);
      //cout << "push::0" << endl;
    }
    else if (c  == 91) {
      s.push(1);
      //cout << "push::1" << endl;
    }
    else if (c == 41) {
      if (s.empty()) {
	flag = false;
	break;
      }
      else {
      if (s.top() == 0) {
	s.pop();
	//cout << "pop::0" << endl;
      }
      else
	break;
      }
    }
    else if (c == 93) {
      if (s.empty()) {
	flag = false;
	break;
      }
      else {
	if (s.top() == 1) {
	  s.pop();
	//cout << "pop::1" <<endl;
	}
	else
	  break;
      }
    }
	
  }
  
  if (s.empty() && flag)
    cout << "yes" << endl;
  else
    cout << "no" << endl;

  //cout << str << endl;
  }
  return 0;

}

Measured memory_bytes: 2976
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int x;
  cin >> x;

  if (x == 0) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 3632
//             بسم الثالوث الاقدس
#include<iostream>	
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<iomanip>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<set>
#include<fstream>
using namespace std;
//********************************************************************************************
//******************************************************************************************** 
/*
jesus help me.......
*/
typedef long long lld;
typedef char c;



/*
jesus help me.......
jesus help me.......
jesus help me.......
*/



int binarySearch(int arr[], int l, int r, int x)
{
	while (l <= r)
	{
		int m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;

}





bool sortbysec(const pair<int, char> &a, const pair<int , char> &b)
{
	return (a.first > b.first);
}	
////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
long long sum1(int n,long long a)
{
	if (n == 0)
		return 1;
	return 	a*sum1(n - 1, a + 1);
	

}
////////////////////////////////////////////////////////////////////

vector<vector<int>>vis(100, vector<int>(100, 0));
void fun(int i, int j,int a, int n, int m, vector<vector<int>>v, vector<string>&v2)
{
	if (a< 0||i<0||j<0||i==n||j==m||v2[i][j]=='B'||vis[i][j]==1)
		return;

	vis[i][j] = 1;
	v2[i][j] = 'Y';
		fun(i - 1, j, a - 1, n, m, v, v2);
		fun(i , j-1, a - 1, n, m, v, v2);
		fun(i +1, j, a - 1, n, m, v, v2);
		fun(i , j+1, a - 1, n, m, v, v2);
		vis[i][j] = 0;

}
////////////////////////////////////////////////////////////////////

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


	//freopen("keys.in", "r", stdin);
	
	int x, a, b;
	cin >> x >> a >> b;
	x = x - a;
	cout << x%b << endl;
	

	/////system("pause");			


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long ;
int main()
{
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        ll point=i;
        double pro=1;
        while(point<k){
            point*=2;
            pro*=0.5;
        }
        ans+=pro/n;
    }
    printf("%.10f",ans);
}

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

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


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n, m;
    cin >> n >> m;
    vector<int> k(n);
    vector<vector<int>> a(n, vector<int> (30));
    vector<int> suki(30,0);
    REP(i,n){
        cin >> k.at(i);
        REP(j,k.at(i)){
            cin >> a.at(i).at(j);
            suki.at(a.at(i).at(j) - 1)++;
        }
    }
    int ans = 0;
    REP(i,30){
        if(suki.at(i) == n ) ans++; 
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int,int>;

int N;
vector<int> C(N);
vector<vector<Edge>> G(N);

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

int main() {
    cin >> N;
    G.assign(N,vector<Edge>());
    for (int i = 0;i < N - 1;i++){
        int u,v,w;cin >> u >> v >> w;u--;v--;
        G[u].push_back(Edge(v,w));
        G[v].push_back(Edge(u,w));
    }
    C.assign(N,0);
    dfs(0,-1,1);
    for (int i = 0;i < N;i++) cout << C[i] << endl;
}

Measured memory_bytes: 8192
from bisect import bisect_left
def check(x):
  cnt=0
  l=n
  r=n
  for i in range(n):
    while True:
      if l==0:
        break
      if a[l-1]<x-a[i]:
        break
      l-=1
    cnt+=(r-l)
  return cnt>=m

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ok=0
ng=2*10**5+10
# 幸福度が上位m個に入る最小のAx+Ayを二分探索する。
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if check(mid):
    ok=mid
  else:
    ng=mid

ru=[0]*(n+1)
for i in range(n):
  ru[i+1]=ru[i]+a[i]

ans=0
cnt=0
r=n
# 幸福度が上位m個に入るAx+Ayの最小値のみm個の個数制限から溢れてしまう場合があるので別に考える
ok=ok+1 # Ax+Ayの最小値より大きな値を先に処理するために最小値+1をする。
for i in range(n):
  # 最小値以外の処理
  l=bisect_left(a,ok-a[i])
  cnt+=r-l
  ans+=(r-l)*a[i]+(ru[r]-ru[l])
ans+=(ok-1)*(m-cnt) # 最小値の処理
print(ans)


Measured memory_bytes: 20880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[100100];
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int dp[100100];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i==1)
        dp[i]=abs(a[i]-a[i-1]);
        else
        {
            dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
        }
    }
    cout <<  dp[n-1] << endl;
    return 0;
}

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

#define MAX_N 1000
typedef long long int ll;

int main() {
  int n;
  ll u[MAX_N], v[MAX_N];

  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    ll x, y;
    std::cin >> x >> y;
    u[i] = x + y;
    v[i] = x - y;
  }

  bool flg;
  int mod;
  for(int i = 0; i < n; ++i) {
    if(i == 0) mod = std::abs(u[i]) % 2;
    flg = mod == std::abs(u[i]) % 2;
    if(!flg) break;
  }
  if(!flg) {
    std::cout << -1 << std::endl;
    return 0;
  }

  std::vector<ll> arms;
  int m = 31;
  for(int i = m - 1; i >= 0; --i) {
    arms.push_back(1LL << i);
  }
  if(mod == 0) {
    arms.push_back(1LL);
    ++m;
  }


  std::cout << m << std::endl;
  for(int i = 0; i < m; ++i) {
    std::cout << arms[i] << " ";
  }
  std::cout << std::endl;

  for(int i = 0; i < n; ++i) {
    std::string ans = "";
    for(int j = 0; j < m; ++j) {
      if(u[i] >= 0 && v[i] >= 0) {
        u[i] -= arms[j];
        v[i] -= arms[j];
        ans.push_back('R');
      } else if(u[i] >= 0 && v[i] < 0) {
        u[i] -= arms[j];
        v[i] += arms[j];
        ans.push_back('U');
      } else if(u[i] < 0 && v[i] >= 0) {
        u[i] += arms[j];
        v[i] -= arms[j];
        ans.push_back('D');
      } else if(u[i] < 0 && v[i] < 0) {
        u[i] += arms[j];
        v[i] += arms[j];
        ans.push_back('L');
      }
    }
    //std::cout << "(" << u[i] << ", " << v[i] << ")" << std::endl;
    std::cout << ans << std::endl;
  }
}


Measured memory_bytes: 256
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))


n=II()
A=LI()
x=0
for i in range(n):
    x+=1/A[i]
x=1/x
print(x)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, ans=0;
	vector<int> a, b;

	cin>> n;
	a.resize(n);
	b.resize(n);

	rep(i, n) cin >> a[i] >> b[i];
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	if(n%2==1){
		ans=b[n/2]-a[n/2]+1;
	}else{
		ans=b[n/2-1]+b[n/2]-(a[n/2-1]+a[n/2])+1;
	}

	cout<< ans << endl;
 
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> p(N+M);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        p[i] = {a, 1};
    }
    for (int i = N; i < N+M; i++) {
        int b, c;
        cin >> b >> c;
        p[i] = {c, b};
    }
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    
    int cnt = 0;
    ll ans = 0;
    int pos = 0;
    while (cnt < N) {
        int t = min(p[pos].second, N - cnt);
        cnt += t;
        ans += (ll)t * p[pos].first;
        pos++;
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vi v(n);
    REP(i, n) cin >> v[i];
    ll sum = 0;
    ll sum_max = 0;
    int p;
    REP(i, n) {
        sum += v[i];
        if(i < k - 1) continue;
        if(i != k - 1) sum -= v[i-k];
        if(sum > sum_max) {
            sum = sum_max;
            p = i;
        }
    }
    double ans = 0;
    for(int i = p; i >= p - (k - 1); --i) {
        ans += 1.0 * (v[i] + 1) / 2;
    }
    cout << fixed << setprecision(3) << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s >> t;
    int n = (int)s.size();
    bool ans = true;
    map<char, vector<int>> cnta;
    map<char, vector<int>> cntb;
    rep(i, 0, n) {
        cnta[s[i]].pb(i);
        cntb[t[i]].pb(i);
    }
    for (auto itr = cnta.begin(); itr != cnta.end(); itr++) {
        vector<int> a = itr->second;
        if (a.size() >= 2) {
            bool flag = true;
            rep(j, 0, a.size()-1) {
                if (t[a[j]] != t[a[j+1]]) flag = false;
            }
            if (!flag) ans = false;
        }
    }
    for (auto itr = cntb.begin(); itr != cntb.end(); itr++) {
        vector<int> a = itr->second;
        if (a.size() >= 2) {
            bool flag = true;
            rep(j, 0, a.size()-1) {
                if (s[a[j]] != s[a[j+1]]) flag = false;
            }
            if (!flag) ans = false;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int a[3][3], n, b;
bool c[3][3], ok, t, u;
int main(){
	rep(i,3) rep(j,3) scanf("%d", &a[i][j]);
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &b);
		rep(j,3) rep(k,3) if(a[j][k] == b) c[j][k] = true;
	}
	rep(i,3){
		t = true; u = true;
		rep(j,3){
			if(!c[i][j]) t = false;
			if(!c[j][i]) u = false;
		}
		if(t || u) ok = true;
	}
	t = true; u = true;
	rep(i,3){
		if(!c[i][i]) t = false;
		if(!c[i][2-i]) u = false;
	}
	if(t || u) ok = true;
	puts(ok ? "Yes" : "No");
}

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

char grid[1005][1005];
int R, C;
int shortestpath[1005][1005];

int mr[4] = {0, -1, 0, 1};
int mc[4] = {1, 0 , -1, 0};

bool inside (int r, int c){
  if (r < 0 || r >= R || c < 0 || c >= C)
    return false;
  return true;
}

queue < pair <int, int>> w;

int bfs (queue<pair<int,int> > w){
  int ans = 0;
  while(!w.empty()){
    pair<int,int> now = w.front();
    w.pop();
    ans = max(ans, shortestpath[now.first][now.second]);
    for(int i=0; i<4; i++){
      int nxr = now.first + mr[i];
      int nxc = now.second + mc[i];
      if(!inside(nxr, nxc)) continue;
      if(shortestpath[nxr][nxc] != -1) continue;
      shortestpath[nxr][nxc] = shortestpath[now.first][now.second] + 1;
      w.push(make_pair(nxr, nxc));
    }
  }
  return ans;
}

int main() {
  cin >> R >> C;

  memset(shortestpath, -1, sizeof(shortestpath));
  for (int i = 0; i < R; i++){
    for (int j = 0; j < C; j++){
      cin >> grid[i][j];
      if (grid[i][j] == '#'){
        shortestpath[i][j] = 0;
        w.push(make_pair (i,j));
      }
    }
  }

  
  cout << bfs(w) << endl;

  return 0;
}


Measured memory_bytes: 24488
n,m=map(int,input().split())
l=[list(input().split()) for i in range(m)]
from collections import defaultdict
cnt_ac=defaultdict(lambda:0)
cnt_wa=defaultdict(lambda:0)

count_wa=0
count_ac=0
for i in range(m):
    if cnt_ac[l[i][0]]==0:
        
        if l[i][1]=='WA':
            cnt_wa[l[i][0]]+=1
        
        elif l[i][1]=='AC':
            cnt_ac[l[i][0]]=1
            count_ac+=1
            count_wa+=cnt_wa[l[i][0]]
print(count_ac,count_wa)


Measured memory_bytes: 41756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for (int i = 0; i < r; i++)
#define repeq(i,r) for (int i = 0; i <= r; i++)
#define isc(n) scanf("%d", &n)

int main() {
  int N, K;
  isc(N);
  isc(K);
  int p[N];
  rep(i,N) isc(p[i]);
  int E, e;
  rep(i,K) e += p[i];
  E = (e += K);
  rep(i,N - K) {
    e = e - p[i] + p[i + K];
    if (E < e) E = e;
  }
  printf("%f", (double) E / 2);
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        int N = NextInt();
        NX[] A = LineLong();
        NX[] X = A.ToArray();

        Dictionary<NX, NX> d = new Dictionary<NX, NX>();
        for (int i = 0; i < N; i++)
        {
            for (NX x = 2; x * x <= A[i]; x++)
            {
                int count = 0;
                if (A[i] % x != 0) continue; 
                while (A[i] % x == 0) { A[i] /= x; count++; }
                if (!d.ContainsKey(x)) d[x] = 0;
                d[x] = Math.Max(d[x], count);
            }
            if (A[i] != 1) {
                if (!d.ContainsKey(A[i])) d[A[i]] = 1;
                else d[A[i]] = Math.Max(d[A[i]], 1);
            }
        }

        NX LCM = 1;
        foreach (var e in d) { LCM *= RepPow(e.Key, e.Value);LCM %= MOD; }
        //foreach (var e in d) { Console.WriteLine(e.Key + " ^ " + e.Value); }
        //Console.WriteLine(LCM);

        NX ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += LCM * RepPow(X[i], MOD - 2);
            ans %= MOD;
        }
        Console.WriteLine(ans);
    }
}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }

    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

int main(){

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int com, b, e;
		cin >> com >> b >> e;
		vector<int>::iterator itr;
		if (com == 0) {
			itr = min_element(a.begin() + b, a.begin() + e);
		}
		else {
			itr = max_element(a.begin() + b, a.begin() + e);
		}
		cout << (*itr) << endl;
	}
	return 0;
}


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

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

    int n;
    cin >> n;

    bool represent = false;

    for(int i = 1; i <= 9; i++){
        if (n%i == 0){
            if (n/i <= 9 && n/i >=1) {
                represent = true;
            }
        }
    }

    if (represent){
        cout << "Yes";
    } else {
        cout << "No";
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    int n;
    string ans = "YES";
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n - 1; i++) {
        if (a.at(i) == a.at(i + 1)) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
}


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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n>> m;
    set<int> s1, s2;
    rep(i,m){
        int x, y;
        cin >> x >> y;
        if(x==1){
            s1.insert(y);
        }
        else if(y == 1){
            s1.insert(x);
        }
        else if(x == n){
            s2.insert(y);
        }
        else if(y == n){
            s2.insert(x);
        }
    }
    for(auto it : s1){
        if(s2.count(it)){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
    
    return 0;
}


Measured memory_bytes: 13040
#include<stdio.h>
#include<string.h>
char key[10][5]={{},{'.',',','!','?',' '},{'a','b','c'},{'d','e','f'},{'g','h','i'},
    {'j','k','l'},{'m','n','o'},{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
int num[10]={1,5,3,3,3,3,3,4,3,4};
int main(void){
    int n; scanf("%d",&n);
    getchar();
    for(int i=0;i<n;i++){
        char c[1030]; char output[80]={0};
        scanf("%s",c); int len=strlen(c);
        int prev=c[0]-'0';
        int cnt=0; int idx=0;
        for(int i=1;i<len;i++){
            int cur=c[i]-'0';
            if(prev==cur) cnt=(cnt+1)%num[cur];
            if(prev!=0&&cur==0) output[idx++]=key[prev][cnt],cnt=0;
            prev=cur;
        }
        printf("%s\n",output);
    }
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b;
    string p,q,r;
    cin>>p>>q;
    a=p.size();
    r=q.substr(0,a);
    if(r==p) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head
int q,m,n,k,res,tmp,tmp2,tmp3,h,w;
//int a[100001] = {};
//int b[100010] = {};
int a,b,c,d;
deque<PII> que;
string s;
VPII kabe;
int dp[3003][3];

const int CMAX = 10000000;
long long fact[CMAX] = {};
long long revFact[CMAX] = {};
void setFact(int N)
{
  fact[0] = 1;
  for (int i = 1; i<N; i++)
  {
    fact[i] = fact[i-1]*i;
    fact[i] %= mod;
  }
  revFact[N-1] = powmod(fact[N-1],mod-2);
  for (int i=N-2;i>=0;i--)
  {
    revFact[i] = revFact[i+1]*(i+1);
    revFact[i] %= mod;
  }
}

long long getC(int a, int b)
{
  return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
}


signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	std::cin >>h>>w>>n;
    dp[0][0] = 1;
    kabe.pb({0,0});
    rep(i,0,n){
        cin>>tmp>>tmp2;
        kabe.pb({tmp-1,tmp2-1});
    }
    sort(all(kabe));
    setFact(h+w+10);
    rep(i,1,n+1){
        rep(j,0,i){
            int dx = kabe[i].fi - kabe[j].fi;
            int dy = kabe[i].se - kabe[j].se;
            if(dx >= 0 && dy >= 0){
                dp[i][0] += dp[j][1]*getC(dx+dy,dx);
                dp[i][1] += dp[j][0]*getC(dx+dy,dx);
                dp[i][0] %=mod;
                dp[i][1] %=mod;                
            }
        }
    }
    rep(i,1,n+1){
        int dx = h-1 - kabe[i].fi;
        int dy = w-1 - kabe[i].se;
        dp[n+1][0] += dp[i][0] * getC(dx+dy,dy);
        dp[n+1][1] += dp[i][1] * getC(dx+dy,dy);
        dp[n+1][0] %=mod;
        dp[n+1][1] %=mod;  
    }
//    cout<<dp[n+1][0]<<" "<<dp[n+1][1]<<endl;
    cout << (getC(h+w-2,h-1) +mod - dp[n+1][1] + dp[n+1][0])%mod<<endl;
}

Measured memory_bytes: 4096
#include<iostream>

using namespace std;

int main() {
	long long x;
	cin >> x;

	long long y = 100;

	long long ans = 0;
	while (1) {

		y = y + (y / 100);
		ans++;
		if (y >= x) {
			break;
		}
		
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
era = [True]*1000001

for i in range(2, 1000001):
  if era[i-2]:
    for j in range(i*2, 1000001, i):
      era[j-2] = False

while True:
  try:
    n = int(raw_input())
    print era[:n-1].count(True)

  except EOFError:
    break

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

using namespace std;

int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int res = 0;

  if (a + b < 2 * c)
  {
    res = a * x + b * y;
  }
  else
  {
    if (x > y)
    {
      x = x - y;
      res += 2 * c * y;
      if (a > 2 * c)
      {
        res += 2 * c * x;
      }
      else
      {
        res += a * x;
      }
    }
    else
    {
      y = y - x;
      res += 2 * c * x;
      if (b > 2 * c)
      {
        res += 2 * c * y;
      }
      else
      {
        res += b * y;
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long long ans = 0;
  int X = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (X > A) {
      ans += X-A;
    }
    else {
      X = A;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
// Copyright 2019 yaito3014
#include <bits/stdc++.h>
using namespace std;
using namespace literals;

int main(){
	long long int N, A, B;
	cin >> N >> A >> B;
	long long int ans;
	if(abs(A-B)%2)
		ans = min((A+B-1)/2,(N-A+1+N-B+1-1)/2);
	else
		ans = abs(A-B)/2;
	cout << ans << endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

map<string, int> z;

void solve() {
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        ++z[s];
    }
    int m; cin >> m;
    for (int i = 0; i < m; ++i) {
        string s; cin >> s;
        --z[s];
    }
    int ans = 0;
    for (const auto &e: z) {
        ans = max(ans, e.second);
    }
    cout << ans;
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#define llint long long

using namespace std;

llint n;
llint a[3][3];
bool used[3][3];
set<int> S;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}
	cin>> n;
	llint b;
	for(int i = 0; i < n; i++){
		cin >> b;
		S.insert(b);
	}
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			if(S.count(a[i][j])) used[i][j] = true;
		}
	}
	for(int i = 0; i < 3; i++){
		bool flag = true;
		for(int j = 0; j < 3; j++){
			if(used[i][j] == false) flag = false;
		}
		if(flag){
			cout << "Yes" << endl;
			return 0;
		}
	}
	for(int i = 0; i < 3; i++){
		bool flag = true;
		for(int j = 0; j < 3; j++){
			if(used[j][i] == false) flag = false;
		}
		if(flag){
			cout << "Yes" << endl;
			return 0;
		}
	}
	if(used[0][0] && used[1][1] && used[2][2]){
		cout << "Yes" << endl;
		return 0;
	}
	if(used[2][0] && used[1][1] && used[0][2]){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	
	int r;
	cin >> r;

	if (r < 1200){ cout << "ABC" << endl; }
	else if (r < 2800){ cout << "ARC" << endl; }
	else{ cout << "AGC" << endl; }

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long inf = 1LL<<60;

int main(){
    int n,k;
    cin >> n >> k;
    int h[100010];

    rep(i,n) cin >> h[i];

    long long dp[100010];
    rep(i,100010) dp[i] = inf;

    dp[0] = 0;

    rep(i,n){
        for(int j=1;j<k+1;j++){
            if(i+j>=n) break;
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }

    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            Println(Pow(ReadInt(), 3));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



Measured memory_bytes: 11092
N = int(input())
S = [''.join(list(sorted(list(input())))) for _ in range(N)]
ans = 0


def nC2(num):
    return int(num * (num - 1) / 2)


count_dict = {}

for s in S:
    if s in count_dict:
        count_dict[s] += 1
    else:
        count_dict[s] = 1

L = list(count_dict.values())

for l in L:
    ans += nC2(l)
print(ans)


Measured memory_bytes: 67416
import numba
from numba import njit, b1, i4, i8, f8
import numpy as np  # noqa

N = int(input())
A = [int(x) for x in input().split()]


def main(A):
    ans = 0
    s = 0
    for i in range(N - 2, -1, -1):
        s += A[i + 1]
        s %= 10**9 + 7
        ans = (ans + A[i] * s) % (10**9 + 7)
    return ans


print(main(A))


Measured memory_bytes: 113648
#include<iostream>

using namespace std;

int main(void)

{
    int n, i, ac = 0, wa = 0, tle = 0, re = 0;
    cin>>n;
    string s;
    for(i = 0; i < n; i++){
        cin>>s;
        if(s == "AC")ac++;
        else if(s == "WA")wa++;
        else if(s == "TLE")tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
    return 0;
}

Measured memory_bytes: 3228
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
import std.typecons : Tuple;

alias Edge = Tuple!(int, "to", int, "cost");

void main() {
    int n,m;
    scan(n,m);

    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int a, b, c;
        scan(a, b, c);
        a--, b--;
        adj[a] ~= Edge(b, c);
    }

    auto mark = new int[](n);
    auto top = new int[](0);
    bool heiro = 0;

    void visit(int i) {
        if (mark[i] == 2) {
            return;
        }
        else if (mark[i] == 1) {
            heiro = 1;
            return;
        }
        else {
            mark[i] = 1;

            foreach (e ; adj[i]) {
                visit(e.to);
            }

            mark[i] = 2;
            top ~= i;

            return;
        }
    }

    foreach (i ; 0 .. n) {
        if (!mark[i]) {
            visit(i);
        }
    }

    if (heiro) {
        writeln("No");
        return;
    }

    top.reverse();

    debug {
        writeln(top);
    }

    immutable inf = 10L^^17;

    auto d = new long[](n);
    d[] = inf;
    d[top.front] = 0;

    foreach (i ; top) {
        foreach (e ; adj[i]) {
            if (d[e.to] == inf) {
                d[e.to] = d[i] + e.cost;
            }
            else {
                if (d[e.to] != d[i] + e.cost) {
                    writeln("No");
                    return;
                }
            }
        }
    }

    writeln("Yes");
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 15740
//shara's here
//私は私は大きい男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
//fold
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	speed;
	ll n,r;
	cin>>n>>r;
	if(n>=10)cout<<r<<endl;
	else cout<<(r+(100*(10-n)))<<endl;
	
	
	
	
	
	
	






return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


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

#define SIZE 100005
#define PI acosl(-1) //3.14159265358979323846264338327950L 
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?

typedef long long ll; typedef long double ld;
typedef struct node { int data; struct node *next; } Node;

Node *list[SIZE];
int queue[SIZE]; int q_head = 0, q_tail = 0;

void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)
void printl_int(int size); //リンクリストを出力(for debug)
Node* add_node(int i, int data); void free_list(Node* head);
int queue_empty(); int queue_full();
void enqueue(int data); int dequeue();

int main() {
    int i, N;
    scanf("%d", &N);
    ll *A = array(N, ll);
    rep(i, N) {
        scanf("%lld", A + i);
        if (!A[i]) {
            printf("0\n");
            return 0;
        }
    }
    ll ans = 1, temp = 1;
    rep(i, N) {
        if (ans > 1000000000000000000LL / A[i]) {
            printf("-1\n");
            return 0;
        }
        ans *= A[i];
        temp = ans;
    }
    printf("%lld\n", ans);
    return 0;
}

void print_log() {
    printf("=== print log ===\n");
}
void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}
void printl_int(int size) {
    int i;
    Node *t;
    rep(i, size) {
        printf("[%d] ", i);
        for (t = list[i]; t; t = t->next) printf("%d, ", t->data);
        printf("\n");
    }
}
Node* add_node(int i, int data) {
    if (!list[i]) {
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
    } else {
        Node *t;
        t = list[i];
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
        list[i]->next = t;
    }
    return list[i];
}
void free_list(Node* head) {
    Node *prev = NULL, *t = head;
    while (t) {
        prev = t;
        t = t->next;
        free(prev);
    }
}
int queue_empty() {
    return q_head == q_tail;
}
int queue_full() {
    return (q_head - 1) % SIZE == q_tail % SIZE;
}
void enqueue(int data) {
    if (queue_full()) {
        printf("full!\n");
        return;
    }
    queue[q_tail++] = data;
    q_tail %= SIZE;
}
int dequeue() {
    if (queue_empty()) {
        printf("empty!\n");
        return -444444;
    }
    int data = queue[q_head++];
    q_head %= SIZE;
    return data;
}

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

int main() {
    int n,count=0;
    string s;
    cin>>n>>s;

    rep(i,n-2) {
        if (s.at(i)=='A' && s.at(i+1)=='B' && s.at(i+2)=='C') {
            count++;
        }
    }

    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)

vector<int> makePrimeLst(int N)
{
    if (N < 2) return vector<int>();
    if (N == 2) return vector<int>{2};
    vector<int> ans;
    vector<int> alive(N+1, 1);
    for (int i=2; (long long)i*i<=(long long)N; i++)
    {
        if (alive[i]) ans.push_back(i);
        for (int t = i; t<=N; t += i) alive[t] = 0;
    }
    for (int i=ans.back()+1; i<=N; i++) if (alive[i]) ans.push_back(i);
    return ans;
}

constexpr int Nmax = 501;
lint ans[Nmax][Nmax];

int main()
{
    vector<int> info = makePrimeLst(10000);

    vector<lint> p, q;
    int now = 2;
    while (p.size() < Nmax + 1)
    {
        p.insert(p.begin(), info[now++]);
        q.insert(q.begin(), info[now++]);
        p.push_back(info[now++]);
        q.push_back(info[now++]);
    }

    int N;
    cin >> N;
    REP(i, N) REP(j, N)
    {
        int u = (i + j) / 2, v = (i + (Nmax - 1 - j)) / 2;
        cout << (((i + j) & 1) ? p[u + 1] * q[v + 1] : p[u] * p[u + 1] * q[v] * q[v + 1] + 3) << (j == N - 1 ? "\n" : " ");
    }
}


Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int flag = 1;
	int count = 0;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j > 0; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				count++;
				flag = 1;
			}

		}
	}
	for (int i = 0; i < n; i++) {
		cout<< a[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	cout << count << endl;
	
}




Measured memory_bytes: 3092
N, K = gets.split.map &:to_i
P = gets.split.map &:to_i
exp = []
for i in 0..N-1
    exp << (P[i] + 1.0) / 2
end
current = exp[0..K-1].inject(:+)
ans = current
for i in 0..N-K-1
    current = current - exp[i] + exp[i + K]
    ans = current if ans < current
end
p ans

Measured memory_bytes: 17284
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int mulu=55555;
int pr[mulu|10],p[mulu|10]={1,1},pnum;
 
void pre(){
int i,j;
for (i=2;i<=mulu;++i) if (!p[i]){
  pr[++pnum]=i;
  for (j=i<<1;j<=mulu;j+=i) p[j]=1;
  }
}
 
int main(){
int i,j,cnt=0,ans[59];pre();
for (i=1;i<=pnum&&cnt<=55;++i){
  if (pr[i]%5==1) ans[++cnt]=pr[i];
  }
int n=read();
for (i=1;i<=n;++i) write(ans[i]),p32;
}

Measured memory_bytes: 512