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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<1000000007>;

void solve() {
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  repic(i, k, n + 1) {
    ans += (mint) i * (n - i + 1) + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    String s = sc.next();
    
    int ans = 0;
    for(int i = 1; i <= x ; i++){
      int count = 0;
      for(char c = 'a' ; c <= 'z'; c++){
        if(s.substring(0,i).contains(String.valueOf(c)) && s.substring(i).contains(String.valueOf(c))){
          count++;
        }
      }
      ans = Math.max(count,ans);
    }
    System.out.println(ans);
  }
}
        

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

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

using namespace std;

int main() {
  int h, w;
  std::cin >> h >> w;
  std::vector<string> s(h);
  rep(i, h) std::cin >> s[i];

  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '.') {
        s[i][j] = '0';
        for (int dx = -1; dx <= 1; ++dx) {
          for (int dy = -1; dy <= 1; ++dy) {
            int nx = i + dx, ny = j + dy;
            if (0 <= nx && nx < h && 0 <= ny && ny < w) {
              if (s[i + dx][j + dy] == '#') {
                s[i][j]++;
              }
            }
          }
        }
      }
    }
  }

  rep(i, h) { std::cout << s[i] << std::endl; }

  return 0;
}


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

int main()
{
  int N;
  cin>>N;
  int V[N],C[N];
  for(int i=0;i<N;i++) {
    cin>>V[i];
  }
  for(int i=0;i<N;i++) {
    cin>>C[i];
  }
  int cnt=0;
  for(int i=0;i<N;i++) {
    cnt+=(V[i]-C[i]>0) ? V[i]-C[i] : 0;
  }
  cout<<cnt;   
}

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

int main() {
  int X; cin >> X;
  int tmp = X;
  int ans =0;
  bool check = false;
  while (!check) {
    int count =0;
    for (int i =2; i<tmp; i++) {
      if (tmp % i != 0) count++;
    }
    if (count == tmp - 2) {
      ans = tmp;
      check = true;
    } else {
      tmp++;
    }
  }
  cout << ans << endl; 
}

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

int n , use[MAX] , good[MAX];
PII a[MAX] , b[MAX];
vector<int> v[MAX];
int DFS(int now){
	for(auto to : v[now]) if(use[to] == 0){
		use[to] = 1;
		if(good[to] == 0 || DFS(good[to]) == 1)
			return good[to] = now , 1;
	}
	return 0;
}
int32_t main(){
	IOS;
	cin >> n;
	REP(i , 1 , n + 1) cin >> a[i].A >> a[i].B;
	REP(i , 1 , n + 1) cin >> b[i].A >> b[i].B;
	REP(i , 1 , n + 1) REP(j , 1 , n + 1)
		if(a[i].A < b[j].A && a[i].B < b[j].B)
			v[i].pb(j);// , DB4("add edge = " , i , " = " , j);
	int ans = 0;
	REP(i , 1 , n + 1) MEM(use , 0) , ans += DFS(i);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long int> v;
vector<long long int> mem;
long long int k;
long long int dp(long long int n)
{
	if(mem[n]!=-1)
	{
		return mem[n];
	}
	if(n==1)
	{
		mem[n]=0;
		return 0;
	}
	else
	{
		long long int m=INT_MAX;
		for(long long int i=1;i<=min(k,n-1);i++)
			m=min(m,dp(n-i)+abs(v[n]-v[n-i]));
		mem[n]=m;
		return mem[n];
	}
}
int main()
{
	
	long long int n;
	cin>>n>>k;
	v.clear();
	v.assign(n+5,0);
	mem.assign(n+5,-1);
	for(long long int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	long long int ans=dp(n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

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

    bool res = false;
    if (n[0] == n[1] && n[1] == n[2]) {
        res = true;
    }
    else if (n[1] == n[2] && n[2] == n[3]) {
        res = true;
    }

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

    return 0;
}

Measured memory_bytes: 256
import random

X,N = input().split()
X,N = int(X),int(N)

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)    
else:
    L = list(range(max(0,X-N),min(102,X+N)))

    if X+N <= 101:
        L.append(X+N)

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(L)]

    if X in L:
        print(X)
    elif len(L) == 1:
        print(L[0])
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

Measured memory_bytes: 9512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void print_vector(vector<int> v, int n) {
  for(int i = 0; i < n - 1; i++) {
      cout << v[i] << " ";
  }
  cout << v[n - 1] << endl;
}

int main(void) {
  int n, m;
  cin >> n;
  vector<int> v;

  for(int i = 0; i < n; i++) {
    cin >> m;
    v.push_back(m);
  }

  vector<int> u(v);
  if(n == 1) {
    cout << v[0] << endl;
  }
  else {
    if(prev_permutation(v.begin(), v.end())) {
      print_vector(v, n);
    }
    
    print_vector(u, n);

    if(next_permutation(u.begin(), u.end())) {
      print_vector(u, n);
    }
  }

}


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

#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

bool check(string n)
{
    int len = n.length();
    int r = (n[0] - '0') % 9;
    REP(i, 1, len)
    {
        r = (r + (n[i] - '0')) % 9;
    }

    return (r == 0);
}

void solve()
{
    string n; cin >> n;

    cout << (check(n) ? "Yes" : "No") << "\n";
}

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

    int t = 1; // cin >> t;

    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	int iCount = 0;
	cin >> str;
	if (str[0] == '1') {
		iCount++;
	}
	if (str[1] == '1') {
		iCount++;
	}
	if (str[2] == '1') {
		iCount++;
	}

	cout <<  iCount;
	
	return 0;
}

Measured memory_bytes: 3148
n = int(input(""))
s1= []
s2 = []

for i in range(1,n+1):
    if i % 15 != 0:
        s1.append(i)

for j in s1 :
    if j % 3 == 0 and j % 5 != 0 :
        s2.append(j)
    elif j % 5 == 0 and j % 3 != 0:
        s2.append(j)

a1 = sum(s1)
a2 = sum(s2)
i = int(abs(a1-a2))
print(i)


Measured memory_bytes: 48868
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)

using namespace std;

typedef pair<ll,ll> pll;
const ll mod=(ll)(998244353);
typedef vector<ll> vll;
ll fact[(ll)(2e5+1)];

ll poww(ll a,ll b)
{
    ll res=1;
    a%=mod;

    while(b>0)
    {
        if(b&1) res=(res*a)%mod;

        a=(a*a)%mod;
        b>>=1;
    }

    return res;
}

ll C(ll n,ll r)
{
    if(n<r)
    {
        return 0;
    }

    return (((poww(fact[n-r],mod-2)*poww(fact[r],mod-2))%mod)*fact[n])%mod;
}



int main()
{
    //cout << "Hello world!" << endl;
    ll n,m,k;
    cin>>n>>m>>k;

    fact[0]=1;
    f(i,1,2e5+1){
        fact[i]=(fact[i-1]*i)%mod;
    }


    ll temp=0;
    f(i,0,k+1){
        temp=(temp+ (((C(n-1,i)*m)%mod)*poww(m-1,n-1-i))%mod)%mod;
    }
    cout<<temp<<endl;

    return 0;
}


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

int main(){
  int Bob,Alice;
  cin >> Alice>>Bob;
  if(Bob==1&&Alice==1) cout<<"Draw";
  else if(Bob==1||Alice == 1){if(Bob==1)cout<<"Bob";else cout<<"Alice";}
  else{
  if(Bob>Alice) cout<<"Bob";
  else if(Bob==Alice) cout<<"Draw";
  else cout << "Alice";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main(){
	int n,m,sum=0,k=0;scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",a+i),sum+=a[i];
	sort(a,a+n,greater<int>());
	for(int i=0;i<n;i++){
		if(a[i]*4*m<sum)break;
		k++;
	}
	if(k>=m)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    string s;
    cin >> s;
    for (int i=0; i<3; i++) {
        if (s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll n,W,ans=0,val=1e5;
	cin>>n>>W;
	vector<ll> w(n+1),v(n+1);
    vector<vector<ll>> dp(n+1,vector<ll>(val+1,1e10));
	/*
	State
	dp[i][j]: Denotes the minimum weight of items(from 1 to i) picked in the bag having total value == j
	Recurrence
	2 choices 1: we pick the ith element, 2: we dont pick the ith element 
	The 2 choices are checked for all weights
	dp[i][j]=minimum(weight of items picked from 1 to i-1 with value == j,weight of items picked from 1 to i-1 with value == (j-value[i]) + weight[i])
	*/
	for(ll i=1;i<=n;i++)
	cin>>w[i]>>v[i];
	for(ll i=0;i<=n;i++){
        dp[i][0] = 0;
    }
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=val;j++){
			if(v[i]>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
			if(dp[i][j]<=W)
				ans=max(ans,j);
		}
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 80256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;
using P = pair<int, int>;
int ans[100000];
vector<vector<P>> t;
int n;
void dfs(int node, int prev = -1, int color = 0) {
    // DDD(node, prev, color);
    for (P nextp : t[node]) {
        int next = nextp.first;
        int w = nextp.second;
        if (next == prev) continue;
        int nc = color;
        if (w % 2 != 0) nc = color == 0 ? 1 : 0;
        ans[next] = nc;
        dfs(next, node, nc);
    }
}

int main()
{
    cin >> n;
    t = vector<vector<P>>(n, vector<P>());
    for (int i = 0; i < n - 1; ++i) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;
        b--;
        t[a].push_back(make_pair(b, w));
        t[b].push_back(make_pair(a, w));
    }
    dfs(0);
    ans[0] = 0;
    REP(i, n) {
        cout << ans[i] << endl;
    }
}

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

typedef pair<int, int> ii;
map<ii, int> mp;

int n;
ii a[200001];
int pow_2[200001];

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

	pow_2[0] = 1;
	for (int i = 1; i <= 200000; i++)
		pow_2[i] = pow_2[i - 1] * 2 % mod;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i].first >> a[i].second;
		if (!a[i].first && !a[i].second)
			ans++;
		else if (!a[i].first)
			mp[ii(0, 1)]++;
		else if (!a[i].second)
			mp[ii(1, 0)]++;
		else
		{
			int g = __gcd(a[i].first, a[i].second);
			int x, y;
			x = a[i].first / g, y = a[i].second / g;
			if (y < 0)
			{
				x *= -1;
				y *= -1;
			}
			mp[ii(x, y)]++;
		}		
	}
	int cur = (pow_2[mp[ii(1, 0)]] + pow_2[mp[ii(0, 1)]] - 1)%mod;
	for (int i = 1; i <= n; i++)
		if (a[i].first && a[i].second)
		{
			int g = __gcd(a[i].first, a[i].second);
			int x, y;
			x = a[i].first / g, y = a[i].second / g;
			if (y < 0)
			{
				x *= -1;
				y *= -1;
			}
			int tmp = pow_2[mp[ii(x, y)]];
			mp[ii(x, y)] = 0;
			x = -a[i].second / g, y = a[i].first / g;
			if (y < 0)
			{
				x *= -1;
				y *= -1;
			}
			(tmp += pow_2[mp[ii(x, y)]]) %= mod;
			mp[ii(x, y)] = 0;
			tmp = (tmp - 1 + mod)%mod;
			(cur *= tmp) %= mod;
		}
	cout << ((ans + cur)%mod - 1 + mod)%mod;	
}

Measured memory_bytes: 33212
#include<bits/stdc++.h>
using namespace std;
int main(){
       int n; cin>>n;
       long int sum=0;
       for(int i=1; i<=n; i++){
           if(i%3!=0&&i%5!=0)
               sum+=i;
       }
       cout<<sum;
       return 0;
}

Measured memory_bytes: 3596
/*
by.YXH_XianYu
   2018.8.25
 */
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long
#define DBL double
#define CHR char
#define BOL bool
#define REG register
#define rep(i, j, k) for(int i = j, lim = k; i <= lim; i++)
#define req(i, j, k) for(int i = j, lim = k; i >= lim; i--)
#define MXN 100010

int n, k,
	a[MXN],
	ans;

int main() {
	//freopen("TEMPLATE.in", "r", stdin);
	//freopen("TEMPLATE.out", "w", stdout);
	REG int i; int lim; ans = 2000000000;

	scanf("%d %d", &n, &k);
	for(i = 1; i <= n; i ++)
		scanf("%d", &a[i]);
	lim = n - k + 1;
	for(i = 1; i <= lim; i ++)
		if(a[i+k-1] <= 0)
			ans = std::min(ans, abs(a[i]));
		else if(a[i] >= 0)
			ans = std::min(ans, a[i+k-1]);
		else
			ans = std::min(ans, std::min(abs(a[i]), a[i+k-1]) + abs(a[i]) + a[i+k-1]);
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 640
/*====================================
Auther:    Shyam Makwana
Problem:   abc179_b.cpp
====================================*/

#include <bits/stdc++.h>
using namespace std;

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define add(a,b) ((a%mod)+(b%mod))%mod
#define mul(a,b) ((a%mod)*(b%mod))%mod
#define __lcm(a,b) ((a*b)/__gcd(a,b))
#define endl "\n"
#define MAX 100005

int32_t main()
{
	int n,m,a,b,c,d,n1;	
	int max1=INT_MIN,min1=INT_MAX;
	bool flag=true,flag1=true;
	fastio;	
	string str;

	cin>>n;
	int count=0;	
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a==b)
			count++;
		else
			count=0;		
		if(count>=3)
			flag=false;
	}
	if(flag)
		cout<<"No";
	else
		cout<<"Yes";
}


Measured memory_bytes: 3636
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	vector<ll> a(n+1);
	ll res = 0;
	for (ll i = 1; i < n + 1; i++) {
		cin >> a[i];
	}
	for (ll i = 1; i < n + 1; i++) {
		if (a[a[i]]==i) {
			res++;
		}
	}
	cout << res/2 << endl;
}

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

int main(int argc, char *argv[]) {
	uint32_t alice_card;
	uint32_t bob_card;

	std::cin >> alice_card;
	std::cin >> bob_card;

	std::string result;
	if (alice_card == bob_card) {
		result = "Draw";
	} else {
		if (alice_card == 1) {
			result = "Alice";
		}
		if (bob_card == 1) {
			result = "Bob";
		}
		if (alice_card != 1 && bob_card != 1) {
			result = (alice_card > bob_card) ? "Alice" : "Bob";
		}
	}
	std::cout << result << std::endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    input = sys.stdin.readline
    try:
        n = int(input())
        H = list(map(int, input().split()))
        
        cnt = 0
        now = 0
        for h in H:
            if h >= now:
                cnt += 1
            now = max(now,h)
            
        print(cnt)
        
    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;

int main(void){

  int a,b;
  cin>>a>>b;
  if(a*b%2==0)cout<<"Even"<<endl;
  else cout<<"Odd"<<endl;
}

Measured memory_bytes: 256
import sys
import math
import bisect

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
bs = [b[0]]
am = max(a)
bs_append = bs.append
for i in range(1,n) :
  if b[i] < am :
    break
  bs_append(bs[i-1]+b[i])
  
if b[0] < am :
  print(math.ceil(h/am))
  sys.exit()

if bs[-1] <= h :
  print(len(bs) + math.ceil((h-bs[-1])/am))
else :
  print(bisect.bisect_left(bs,h)+1)

Measured memory_bytes: 15792
using System;
using System.Collections.Generic;
using System.Linq;

namespace _154D
{
    internal class Program
    {
        //とりあえずごり押しで
        private static void Main(string[] args)
        {
            var inputNK = Console.ReadLine().Split(' ');
            var N = int.Parse(inputNK[0]);
            var K = int.Parse(inputNK[1]);
            var P = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            var sum = new List<int>();
            sum.Add(P[0]);
            for (int i = 1; i < K; ++i)
                sum[0] += P[i];

            for (int i = 0; i < N - K; ++i)
            {
                sum.Add(sum[i] - P[i] + P[i + K]);
            }

            Console.WriteLine((sum.Max() + K) / 2.0);
        }
    }
}

Measured memory_bytes: 30044
-- A Harmony

main :: IO()
main = do
  l <- getLine
  let a: b: _ = take 2 (map read (words l) :: [Int])
  let ans = solve a b
  if ans < 0
    then
    putStrLn("IMPOSSIBLE")
    else
    putStrLn(show ans)

solve :: Int -> Int -> Int
solve a b =
  if even diff
  then
    diff_div + smaller_one
  else
    -1
  where
    smaller_one = min a b
    diff = abs (a - b)
    diff_div = diff `div` 2



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

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

	vector<int> k(m);
	vector<vector<int>> s(m);
	for (int i = 0; i < m; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			int x; cin >> x;
			s[i].emplace_back(x);
		}
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	int ans = 0;

	for (int i = 0; i < (1 << n); i++) {//全列挙ポーズ
		vector<bool> x(n, false);
		for (int j = 0; j < n; j++) {//その時点でのbit状態
			if (i&(1 << j)) {
				x[j] = true;
			}
		}
		vector<bool> y(m, false);
		for (int a = 0; a < m; a++) {
			int tmp = 0;
			for (int b = 0; b < k[a]; b++) {
				if (x[s[a][b] - 1]) {
					tmp++;
				}
			}
			if (tmp % 2 == p[a]) {
				y[a] = true;
			}
		}

		for (int f = 0; f < m; f++) {
			if (y[f]) {

			}
			else {
				goto ggg;
			}
		}

		ans++;


		ggg:;
	}

	cout << ans << endl;

	return 0;
}

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

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

struct Node * find(struct Node *u,int k){
  while(u != NIL && k != u->key){
    if(k<u->key)u=u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  struct Node *x=root;
  struct Node *y=NIL;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  int a=0,b=0;
  char com[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    
    a = strcmp(com,"insert");
      if(a==0){
	scanf("%d",&x);
	insert(x);
      }

      b = strcmp(com,"print");
      if(b==0){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
  }

  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<(2*b>a?0:a-2*b)<<endl;
    return 0;
}

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

using namespace std;

int main(){
	while(1){
		int d, w; cin >>d>>w;
		if(!d && !w) break;
		int e[10][10];
		for(int y=0; y<d; y++){
			for(int x=0; x<w; x++){
				cin >> e[y][x];
			}
		}

		int ans=0;
		for(int i=0; i<d; i++){
			for(int j=0; j<w; j++){
				for(int k=0; k<d; k++){
					for(int l=0; l<w; l++){
						int low=10, high=0, tmp=0;
						
						for(int m=i; m<=k; m++){
							for(int n=j; n<=l; n++){
								if(m==i || m==k || n==j || n==l){
									if(e[m][n] < low) low = e[m][n];
								}
							}
						}
						
						for(int m=i+1; m<k; m++){
							for(int n=j+1; n<l; n++){
								high = max(e[m][n], high);
								tmp += low - e[m][n];
							}
						}
						if(low > high) ans = max(ans, tmp);
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
module Main (main) where

import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main =
  readInts >>= print . showAnswer . solve

type Input  = [Int]
type Output = Int

solve :: Input -> Output
solve [a,b]
  | a <= 5  = 0
  | a <= 12 = b `div` 2
  | otherwise = b

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | ByteString ByteString
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)       = bool "No" "Yes"  b
  show (YESNO b)       = bool "NO" "YES"  b
  show (AB b)          = bool "B"  "A"    b
  show (Number i)      = show i
  show (String s)      = s
  show (ByteString bs) = C8.unpack bs
  show (Compare o)     = ordering "<" "=" ">" o
  show (Compare2 o)    = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

indexMapBS :: Int -> (Char -> Char) -> ByteString -> ByteString
indexMapBS k f s = C8.concat [s1, C8.singleton (f c), s3]
  where
    (s1, s2) = C8.splitAt (k-1) s
    c = C8.head s2
    s3 = C8.tail s2

Measured memory_bytes: 380
from collections import deque
dirc = ((-1, 0), (0, 1), (1, 0), (0, -1))
while 1:
    w, h = map(int, input().split())
    if w==0:
        break
    maze = [[[0]*4 for i in range(w)] for _ in range(h)]
    for idx in range(2*h-1):
        if idx%2==0:
            horizon = list(map(int, input().split()))
            for i, j in enumerate(horizon):
                if j==1:
                    maze[idx//2][i][1] = -1
                    maze[idx//2][i+1][3] = -1
        else:
            vertical = list(map(int, input().split()))
            for i, j in enumerate(vertical):
                if j==1:
                    maze[idx//2][i][2] = -1
                    maze[idx//2+1][i][0] = -1
    queue = deque()
    queue.appendleft((0, (0, 0)))
    checked = [[0]*w for _ in range(h)]
    ans = 0
    while queue:
        c, (y, x) = queue.pop()
        c += 1
        if checked[y][x]:
            continue
        checked[y][x] = 1
        if (y, x)==(h-1, w-1):
            ans = c
            break
        for i, (dy, dx) in enumerate(dirc):
            if maze[y][x][i]==-1:
                continue
            ny, nx = y+dy, x+dx
            if nx<0 or nx>=w or ny<0 or ny>=h:
                continue
            if not checked[ny][nx]:
                queue.appendleft((c, (ny, nx)))
    print(ans)
            
        



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

int main(void){
    int N;
    cin>>N;
    vector<int> t(N);
    vector<double> v(N);
    int T=0;
    rep(i,N) {
        cin>>t[i];
        T += t[i]*2;
    }
    rep(i,N) cin>>v[i];
    vector<double> s(T+1);
    rep(x,T){
        if(x<=T/2) s[x] = x/2.0;
        else s[x] = (T-x)/2.0;
    }
    // rep(x,T) cout<<s[x]<<endl;
    int l=0,r=0;
    rep(i,N){
        r += 2*t[i];
        rep(x,T){
            if(x<=l) s[x] = min(s[x],v[i]+(l-x)/2.0);
            else if(x<=r) s[x] = min(s[x],v[i]);
            else s[x] = min(s[x],v[i]+(x-r)/2.0);
        }
        l = r;
    }

    double sum = 0;
    rep(x,T){
        sum += 0.25*(s[x]+s[x+1]);
    }
    printf("%.6f\n",sum);

    return 0;
}


Measured memory_bytes: 512
from sys import stdin

while True:
    H,W = map(int, stdin.readline().split())
    str = ''
    
    if W == 0 and H == 0:
        break
    
    for i in range(H):
        if i == 0 or i == H-1:
            str += '#'*W + '\n'
        else:
            str += '#' + '.'*(W-2) + '#\n'
    print(str)


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

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

typedef long long ll;
typedef pair<int, int> pr;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true){
        int n, a, b, c, x;
        int y[100];
        cin >> n >> a >> b >> c >> x;
        if((n|a|b|c|x) == 0) break;
        for(int i = 0; i < n; i++){
            cin >> y[i];
        }
        int nx = x;
        int cnt = 0;
        int ind = 0;
        for(cnt = 0; cnt <= 10000; cnt++){
            if(y[ind] == nx){ ++ind; }
            if(ind == n) break;
            nx = (a * nx + b) % c;
        }
        if(cnt > 10000){
            cout << -1 << endl;
        }else{
            cout << cnt << endl;
        }
    }

    return 0;
}

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

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

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }

// 0 = all front chars
// 1 = all back chars
vector<char> qu[2];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s; int Q;
  cin >> s >> Q;
  bool rev = false;
  while(Q--) {
    int q;
    cin >> q;
    // rev string
    if (q == 1) {
      rev = !rev;
    }
    else {
      int f; char c;
      cin >> f >> c;
      f--; // f == 0 or 1, front or back resp.
      qu[f ^ rev].push_back(c);
    }
  }
  string res;
  for (int i = qu[0].size() - 1; i >= 0; i--)
    res += qu[0][i];
  res += s;
  for (auto c : qu[1]) res += c;
  if (rev) {
    reverse(res.begin(), res.end());
  }
  cout << res << endl;
}


Measured memory_bytes: 1448
# input
N = int(input())
A = list(map(int, input().split()))

# process
ans = 0
check = {}
for i, a in enumerate(A):
    x = i-a
    y = i+a
    ans += check.get(x, 0)
    check.setdefault(y, 0)
    check[y] += 1
    
# output
print(ans)


Measured memory_bytes: 40316
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		if(s.length()>n)System.out.println(s.substring(0,n)+"...");
		else System.out.println(s);
		
	}

}


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

int main()
{
    int n;
    cin >> n;
    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon" << endl;
    else
        cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mn(a,b) (a < b ? a : b)
#define mx(a,b) (a > b ? a : b)
#define f first
#define s second
#define mp make_pair
#define all(v) (v).begin(),(v).end()

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int tam = s.size();
    string t;
    s = " " + s;
    for(int i = 1; i <= tam; i += 2)
        t.push_back(s[i]);
    cout<<t;
    return 0;
}


Measured memory_bytes: 512
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        int[] abc = r.ii();
        java.util.Arrays.sort(abc);
        print(abc[0]+abc[1]+abc[2]*10);        
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b; cin >> a >> b;
  if (a < 10 && b < 10) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, x;
  cin >> N >> K;
  int total = 0; // 総移動距離
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (abs(x) < abs(K - x)) total += x * 2; // type B ロボの方が遠い時
    else total += (K - x) * 2;
  }
  cout << total << endl;
}

Measured memory_bytes: 3648
using System;
class Program
{
	static void Main(string[] args)
	{
        int n = int.Parse(Console.ReadLine());
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        Array.Sort(input);
        Array.Reverse(input);
        int alice = 0;
        int bob = 0;
        for(int i = 0;i < input.Length;i++){
            if (i%2 == 0) {
                alice += input[i];
            } else {
                bob += input[i];
            }
        }
        Console.WriteLine(alice - bob);
	}
}

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

int main() {
  int n; cin >> n;
  vector<int> A(n);
  map<int, int> cnt;
  rep(i,n) {
    cin >> A[i];
    if (A[i] >= 3200) {
      cnt[3200]++;
    } else {
      cnt[A[i]/400]++;
    }
  }
  int minv,maxv;
  minv = cnt.size();
  maxv = minv;
  if (cnt.count(3200)) {
    if (minv != 1) {
      minv--;
    }
    maxv--;
    maxv += cnt[3200];
  }
  cout << minv << " ";
  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 3592
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

VecVec tree;
Vec dist1, dist2;

void dijkstra(ll node, Vec &dist){
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(mp(0, node));
	while(!que.empty()){
		P o = que.top(); que.pop();
		if(o.fs >= dist[o.sc]) continue;
		dist[o.sc] = o.fs;
		for(ll i : tree[o.sc]) que.push(mp(o.fs+1, i));
	}
}

int main(void){
	ll n, u, v;
	cin >> n >> u >> v;
	u--, v--;
	tree.resize(n);
	dist1.assign(n, LINF);
	dist2.assign(n, LINF);
	ll a, b;
	rep(i, n-1){
		cin >> a >> b;
		a--; b--;
		tree[a].pb(b);
		tree[b].pb(a);
	}
	dijkstra(u, dist1);
	dijkstra(v, dist2);

	ll ans = 0;
	rep(i, n) if(dist1[i] < dist2[i]) chmax(ans, dist2[i]-1);
	co(ans);

	return 0;
}


Measured memory_bytes: 9632
n=int(input())
a=list(map(int,input().split()))
c=[1]*(10**3+1)
p={}
q=[]
m=10**9+7
for i in range(2,10**3+1):
    if c[i]:
        p[i]=0
        q.append(i)
        for j in range(i*2,10**3+1,i):
            c[j]=0
for j in a:
    i=0
    while j!=1:
        if j%q[i]==0:
            d=0
            while j%q[i]==0:
                j//=q[i]
                d+=1
            p[q[i]]=max(p[q[i]],d)
        i+=1
        if i==168:
            break
    p[j]=1
e=1
for i in p.keys():
    e=(e*pow(i,p[i],m))%m
c=0
for i in a:
    c=(c+e*pow(i,m-2,m))%m
print(c)
            

Measured memory_bytes: 4596
/* Coached by Dukkha */
#include <stdio.h>
#include <string.h>

#define N 100000

int main() {
	static char s[N + 1];
	static int kk[2];
	int n, i, r;

	scanf("%s", s);
	n = strlen(s);
	for (r = 0; r < 2; r++)
		for (i = 0; i < n; i++)
			if ((i % 2 == r) != (s[i] == '0'))
				kk[r]++;
	printf("%d\n", kk[0] < kk[1] ? kk[0] : kk[1]);
	return 0;
}


Measured memory_bytes: 256
a = [0] * 20
v = [0] * 20
a_v = []
for i in range(int(raw_input())):
	a[i],v[i] = map(int, raw_input().split())
	a_v.append([a[i], v[i]])
a_v.sort()
ans2 = max(v)
for i in a_v:
	if i[1] == ans2:
		ans1 = i[0]
		break
print "{} {}".format(ans1, ans2)

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    set<int> s;
    for(int i=0;i<3;i++) {
        int x;
        cin >> x;
        s.insert(x);
    }
    cout << ((s.size() == 2) ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mo=1e9+7;
int calc(int l,int r){
	return 1ll*(r+l)*(r-l+1)/2%mo;
}
int main(){
	int n,k,ans=0;scanf("%d%d",&n,&k);
	for(int i=k;i<=n+1;i++)
		(ans+=(calc(n-i+1,n)-calc(0,i-1)+1)%mo)%=mo;
	printf("%d",(ans+mo)%mo);
	return 0;
}

Measured memory_bytes: 3836
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.stream.IntStream;

public class Main {

	static long countEvenPlus(int[] a) {
		long count = 0;
		int sum = 0;
		for (int i = 0; i < a.length; i += 1) {
			sum += a[i];
			if (i % 2 == 0 && sum <= 0) {
				count += Math.abs(sum) + 1;
				sum = 1;
			} else if (i % 2 == 1 && sum >= 0) {
				count += Math.abs(sum) + 1;
				sum = -1;
			}
		}
		return count;
	}

	static long countEvenMinus(int[] a) {
		long count = 0;
		int sum = 0;
		for (int i = 0; i < a.length; i += 1) {
			sum += a[i];
			if (i % 2 == 0 && sum >= 0) {
				count += Math.abs(sum) + 1;
				sum = -1;
			} else if (i % 2 == 1 && sum <= 0) {
				count += Math.abs(sum) + 1;
				sum = 1;
			}
		}
		return count;
	}

	static void exec(MyScanner in, PrintWriter out) {
		int N = in.nextInt();
		int[] a = IntStream.range(0, N).map(i -> in.nextInt()).toArray();
		out.println(Math.min(countEvenPlus(a), countEvenMinus(a)));
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int readByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


Measured memory_bytes: 27628
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    ll x,y;
    cin>> x >> y;
    ll m =x;
    ll cnt =1;

    while(m*2<=y){
        cnt +=1;
        m*=2;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define int long long
using namespace std;
const int mod=998244353;
const int N=3e6+2;
int fact[N],inv[N];
int binpow(int x,int y){
	int tich=1;
	while(y){
		if((y&1)){
			tich*=x;
			tich%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return tich;
}
int C(int x,int y){
	return ((fact[y]*inv[x])%mod*inv[y-x])%mod;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,i,j,k,l,ans=0;
	cin>>n>>m;
	fact[0]=1;
	for(i=1;i<=2*(n+m);i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
	inv[2*(m+n)]=binpow(fact[2*(m+n)],mod-2);
	for(i=2*(m+n);i>=1;i--){
		inv[i-1]=(inv[i]*i)%mod;
	}
	for(i=m%2;i<=min(n,m);i+=2){
		if(i>3*m){
			break;
		}
		ans+=C(i,n)*C(n-1,(3*m-i)/2+n-1);
		if(i<=m){
			ans-=(n*C(i,n))%mod*C(n-1,n-1+(m-i)/2);
			if(i<n){
				ans+=(n*C(i,n-1))%mod*C(n-2,n-2+(m-i)/2);
			}
		}
		ans%=mod;
		if(ans<0){
			ans+=mod;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 47104
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
 
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;



 
int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll ds = abs(b - a);
    ll sp = v - w;
    if(sp*t >= ds || ds == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

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

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    LL ans = 0;
    LL n,a;
    bool next = false;
    cin >> n;
    REP(i, n){
        cin >> a;
        a += next;
        ans += a / 2;
        if(a % 2 == 1 && a != 1){
            next = true;
        }else{
            next = false;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256