akhauriyash/Code-Regression huggingface dataset:
/*
Abdullah All Rawaha Anik
American International University - Bangladesh
18-*****-1
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define mp make_pair
#define  pb push_back
#define pf push_front
#define ll long long
const ll MAXN = 1e5+7;
ll arr[MAXN];
pii A[MAXN];
ll power(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}
ll bigmod(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,number;
    set<ll>x;
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>number,x.insert(number);
    if(x.size()==n)
        printf("YES\n");
    else
        printf("NO\n");
}





Measured memory_bytes: 9600
in_all = list(map(int, input().split()))

total = 0
for n in range(1, in_all[0]+1):
    all = 0
    tmp = n
    while tmp!=0:
        all += tmp%10
        tmp = tmp//10
    if all>=in_all[1] and all<=in_all[2]:
        total += n

print(total)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pii pair<int,int>
int n,a[1000005],ans;
pii Max[1000005];
void fun(int x,pii &y){
	if(x==y.F||x==y.S)return;
    if(a[x]>a[y.F])y.S=y.F,y.F=x;
    else if(a[x]>a[y.S])y.S=x;
}
int main(){
	scanf("%d",&n);
	int sta=1<<n;
	for(int i=0;i<sta;i++){
		scanf("%d",&a[i]);
		Max[i].F=i;
		Max[i].S=sta;
	}
	for(int i=1;i<sta;i++)
		for(int j=0;j<n;j++)
			if(i&(1<<j)){
				int k=i^(1<<j);
				fun(Max[k].F,Max[i]);
				fun(Max[k].S,Max[i]);
			}
	for(int i=1;i<sta;i++){
		ans=max(ans,a[Max[i].F]+a[Max[i].S]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 6916
#include<stdio.h>
int main(void)
{
	long int a,b,s;
	
	scanf("%ld %ld",&a,&b);
	
	if(a<b)
	{
		s=a;
		a=b;
		b=s;
	}
	
	if((a-b)%2==0)
	{
		printf("%ld\n",(a-b)/2+b);
	}
	else
	{
		printf("IMPOSSIBLE\n");
	}
	
	return 0;
}

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

int main(int argc, char *argv[]) {
  int N, K;
  cin >> N >> K;
  if(K % 2 == 1) {
    int count = 0;
    for(int i = K; i <= N; i++) {
      if(i % K == 0) {
        count++;
      }
    }
    long long ans = pow(count, 3);
    cout << ans << endl;
  } else {
    int count = 0;
    for(int i = K / 2; i <= N; i++) {
      if(i % (K / 2) == 0 && i % K != 0) {
        count++;
      }
    }
    int count2 = 0;
    for(int i = K; i <= N; i++) {
      if(i % K == 0) {
        count2++;
      }
    }
    long long ans = pow(count, 3) + pow(count2, 3);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {  
  cout << setprecision(20);
    double A,B,X;
    cin >> A >> B >> X;
    double E = A*A*B - X;
    if(E <= X){
        double C = (2*E)/(A*A);
        double D = atan2(A,C);
        cout << 90.0 - D * 180.0 / (atan(1.0) * 4.0) << endl;
    }
    else {
        double C = (2*X)/(B*A);
        double D = atan2(B,C);
        cout << D * 180.0 / (atan(1.0) * 4.0) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
	V<int>a(n);
	REP(i,0,n){
		cin>>a[i];
		a[i]-=(i+1);
	}
	SO(a);
	int b=a[n/2],ans=0;
	REP(i,0,n){
	ans+=labs(a[i]-b);	
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4648
def main():
    n, a, b = list(map(int, input().split()))
    if (b-a) % 2 == 0:
        print((b-a)//2)
    else:
        ans = min(n-a, b-1)
        ans = min(ans, n-b+1+(n-(a+n-b+1))//2)
        ans = min(ans, a-1+1+(b-(a-1+1)-1)//2)
        print(ans)


main()


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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)
const ll INF = 1LL << 60;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;


int main()
{
    int n;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];

    int flag=0;
    rep(i,0,n) {
        if(a[i]%2==0) {
            if(a[i]%3==0 || a[i]%5==0) {
                flag=1;
            } else {
                flag=0;
                break;
            }
        } else {
            flag=1;
        }
    }

    if(flag==1) {
        cout<<"APPROVED"<<endl;
    }
    else cout<<"DENIED"<<endl;

    return 0; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int mp[51][51];
int cnt;
int w,h;

void dfs(int x,int y){
    mp[x][y]=0;
    for(int i=-1;i<=1;i++){
        for(int j=-1;j<=1;j++){
            if(x+i<0||h<=x+i||y+j<0||w<=y+j) continue;
            if(mp[x+i][y+j]) dfs(x+i,y+j);
        }
    }
}

int main(){
    while(1){
        cin >> w >> h;
        if(w==0&&h==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> mp[i][j];
            }
        }
        cnt=0;
        rep(i,h)rep(j,w){
            if(mp[i][j]){
                cnt++;
                dfs(i,j);
            }
        }
        cout << cnt << endl;
    }
    
    return 0;
}














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

int main(){
  int a,b,d=0;
  cin>>a>>b;
  vector<vector<char>> c(a+2,vector<char>(b+2,'.'));
  for(int i=1;i<a+1;i++){
    for(int j=1;j<b+1;j++)
      cin>>c.at(i).at(j);
  }
  for(int i=1;i<a+1;i++){
    for(int j=1;j<b+1;j++){
      if(c.at(i).at(j)=='#'){
        if(c.at(i-1).at(j)=='.'&&c.at(i).at(j+1)=='.'&&c.at(i).at(j-1)=='.'&&c.at(i+1).at(j)=='.'){
          d=1;
          cout<<"No"<<endl;
          break;
        }
      }
    }
    if(d==1)
      break;
  }
  if(d==0){
    cout<<"Yes"<<endl;
  }
}


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

using namespace std;

int main()
{
    double a, b, c, d;
    const double r = 6378.1; // 地球の半径

    while (cin >> a >> b >> c >> d) {
        if (a == -1 && b == -1 && c == -1 && d == -1)
            break;
        double x[2], y[2], z[2];
        double theta[2], phi[2];

        phi[0] = b * M_PI / 180.0;
        phi[1] = d * M_PI / 180.0;
        theta[0] = (90.0 - a) * M_PI / 180.0;
        theta[1] = (90.0 - c) * M_PI / 180.0;

        for (int i = 0; i < 2; i++) {
            z[i] = r * cos(theta[i]);
            x[i] = r * sin(theta[i]) * cos(phi[i]);
            y[i] = r * sin(theta[i]) * sin(phi[i]);
        }

        double d[2], inner;

        inner = x[0] * x[1] + y[0] * y[1] + z[0] * z[1];
        for (int i = 0; i < 2; i++) 
            d[i] = sqrt(x[i] * x[i] + y[i] * y[i] + z[i] * z[i]);
        
        cout << (int)(r * acos(inner / d[0] / d[1]) + 0.5) << endl;
    }

    return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

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

const double pi = 3.1415926535;

int main(){
    int n;
    cin >> n;
    cout <<fixed<<setprecision(10)<< 2 * n * pi << endl;
}

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

int main() {
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  
  if(a1+a2+a3>=22){
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}
  

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

const int N = 3010;

char s[N], t[N], st[N];
int f[N][N];

int main() {
	scanf("%s%s", s + 1, t + 1);
	int n = strlen(s + 1), m = strlen(t + 1);
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			f[i][j] = max(f[i - 1][j], f[i][j - 1]);
			if(s[i] == t[j]) f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
		}
	}
	int now = f[n][m] + 1;
	int top = 0;
	for(int i = n; i; --i) {
		for(int j = m; j; --j) {
			if(s[i] == t[j] && f[i][j] == now - 1) {
				--now;
				st[++top] = s[i];
				break;
			}
		}
	}
	while(top) putchar(st[top--]);
}

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

int main() {
    string s, t, u;
    cin >> s;
    cin.ignore();
    cin >> t;
    int a, b;
    cin >> a >> b;
    cin.ignore();
    cin >> u;
    if(s == u) {
        cout << --a << " " << b <<endl;
    } else {
        cout<< a << " " << --b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, raw_input().split())
maze = [list(raw_input()) for i in xrange(h)]

INF = 10 ** 10
my = [-1, 0, 1, 0]
mx = [0, -1, 0, 1]
def bfs(sy, sx):
    q = [(sy, sx)]
    dp = [ [INF for j in xrange(w)] for i in xrange(h) ]
    dp[sy][sx] = 0
    while q:
        (y, x) = q.pop(0)
        for (dy, dx) in zip(my, mx):
            ny = y + dy
            nx = x + dx
            if ny < 0 or nx < 0 or ny >= h or nx >= w:
                continue
            if maze[ny][nx] == '#':
                continue
            if dp[ny][nx] != INF:
                continue
            dp[ny][nx] = dp[y][x] + 1
            q.append((ny, nx))
    res = 0
    for i in xrange(h):
        for j in xrange(w):
            if maze[i][j] != '#':
                res = max(res, dp[i][j])
    return res

res = 0
for sy in xrange(h):
    for sx in xrange(w):
        if maze[sy][sx] == '#':
            continue
        res = max(res, bfs(sy, sx))
print res


Measured memory_bytes: 40296
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int X, A, B;
	cin >> X >> A >> B;

	if (A >= B) cout << "delicious" << "\n";
	else if (B - A <= X) cout << "safe" << "\n";
	else cout << "dangerous" << "\n";

	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, M;
vector<pii> G[100010];
int D[100010];

bool dfs(int v, int c, int pre)
{
	if (D[v] != INF)
	{
		if (D[v] == c)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	D[v] = c;

	bool ok = true;

	for (auto e : G[v])
	{
		if (e.first == pre)continue;
		ok = dfs(e.first, c + e.second, v) && ok;
	}
	
	return ok;
}

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

	cin >> N >> M;
	int s, t, d;
	rep(i, 0, M)
	{
		cin >> s >> t >> d;
		s--, t--;
		G[s].push_back(mp(t, d));
		G[t].push_back(mp(s, -d));
	}

	fill(D, D + N, INF);

	rep(i, 0, N)
	{
		if (D[i] != INF)continue;
		if (!dfs(i, 0, -1))
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 17408
N,K=list(map(int,input().split()))
P=list(map(int,input().split()))

E_P=[(1+p)/2 for p in P] 

E_P_sum=[0]
E_P_sum_=0
for n in range(N):
    E_P_sum_=E_P_sum_+E_P[n]
    E_P_sum.append(E_P_sum_)

max_ = 0
for k_ in range(len(P)-K+1):
    sum_=E_P_sum[k_+K]-E_P_sum[k_]
#     print(E_P_sum[k_+K],E_P_sum[k_],sum_)
    if max_ < sum_:
        max_=sum_
        
print(max_)

Measured memory_bytes: 78984
while True:
    a,b,c = input().split()
    a = int(a)
    c = int(c)
    if b == "?":
        break
    elif b == "+":
        print("%d"%(a + c))
    elif b == "-":
        print("%d"%(a - c))
    elif b == "*":
        print("%d"%(a * c))
    else:
        print("%d"%(a / c))


Measured memory_bytes: 5596
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int, input().split()))
if n == 1:
    print(h[0])
else:
    ans = h[0]
    for i in range(1, n):
        if h[i] > h[i-1]:
            ans += h[i] - h[i-1]
    print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
const int mod = 998244353;
const int N = 3e5 + 5;



int main() {
    io();
    string s, t;
    cin >> s >> t;
    if(t.substr(0, s.size()) == s)
        cout << "Yes";
    else
    cout << "No";    

}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
ll n, m, a, b;
string x, y;
int main()
{
	FAST
	cin>>n>>m>>a>>b;
	FOR(i,1,a) x+='0', y+='1';
	FOR(i,a+1,m) x+='1', y+='0';
	FOR(i,1,b) cout<<x<<'\n';
	FOR(i,1,n-b) cout<<y<<'\n';
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int X, Y;
	scanf("%lld%lld", &X, &Y);
	if(X % Y == 0){
		printf("-1\n");
	}
	else{
		printf("%lld\n", X);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<string>s(h);
  for(int i = 0; i < h; i++){
    cin >> s[i];
  }
  vector< vector<int> > tate(h);
  vector<int> isnull(h, 0);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#') tate[i].push_back(j);
    }
    if(!tate[i].size()){
      isnull[i] = 1;
    }
  }

  vector< vector<int> > ans(h, vector<int>(w));
  int now = 1;
  int pd = 0;
  for(int i = 0; i < h; i++){
    if(isnull[i]) continue;
    for(int j = 0; j < tate[i].size(); j++){
      int l,u;
      if(j == 0) l = 0;
      else l = tate[i][j-1]+1;
      if(j == tate[i].size()-1) u = w;
      else u = tate[i][j+1];
      for(int k = l; k < u; k++) ans[i][k] = now;
      if(!pd){
        for(int t = 0 ; isnull[t] && t < i ; t++){
          for(int k = l; k < u; k++){
            ans[t][k] = now;
          }
        }
      }
      for(int t = i+1 ; isnull[t] && t < h ; t++){
        for(int k = l; k < u; k++){
          ans[t][k] = now;
        }
      }
      now++;
    }
    pd = 1;
  }
  for(int i = 0; i < h ; i++){
    for(int j = 0; j < w; j++){
      cout << ans[i][j] << ' ';
    }
    cout << endl;
  }
}


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

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

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

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

int main(void) {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 0;
    REP(i,N) {
        int n;
        cin >> n;
        ans = gcd(n, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

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

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

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

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

const ll M = 1e9 + 7;

vector<ll> fac(1e6+1); //n!(mod M)
vector<ll> ifac(1e6+1); //k!^{M-2} (mod 
ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

ll comb(ll a, ll b) { //aCbをmod計算
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}

ll dp[3001][3001][2];
int main() {
	ll N, T;
	cin >> N >> T;

	vector<pll> AB(N);

	rep(i, N) {
		cin >> AB[i].first >> AB[i].second;
	}
	sort(all(AB), std::greater<pll>());

	// cout << AB << endl;

	rep(i, T+1) {
		dp[0][i][0] = 0;
		dp[0][i][1] = 0;
	}

	rep(i, N) {
		ll a = AB[i].first;
		ll b = AB[i].second;

		rep(w, T + 1) {
			if (w > a) {
				dp[i + 1][w][0] = max(dp[i][w - a][0] + b, dp[i][w][0]);
				dp[i + 1][w][1] = max(dp[i][w - a][1] + b, dp[i][w][1]);
			}
			else {
				dp[i + 1][w][0] = dp[i][w][0];
				dp[i + 1][w][1] = max(dp[i][w][0] + b, dp[i][w][1]);
			}
		}
	}

	/*
	rep(i, N+1) {
		rep(w, T + 1) {
			cout << i << ":" << w << " " << dp[i][w][0] << ", " << dp[i][w][1] << endl;
		}
	}
	*/
	cout << max(dp[N][T][0], dp[N][T][1]) << endl;

	return 0;
}

Measured memory_bytes: 156672
i=3;main(n,j){scanf("%d",&n);if(n==3)return!printf("2 3 25");for(;j=n-i,j+=j&1,1>j||j>5000||i>15000;i+=3);for(i=n-j;i--;printf("%d ",2*i+2));for(;j--;printf("%d ",6*j+3));}

Measured memory_bytes: 256
a,b = map(int, input().split())
 
p = [1]*a
ph = list(map(int, input().split()))

 
for i in range(b):
  at,bt = map(int, input().split())
  at-=1
  bt-=1
  if ph[at]>ph[bt]:
    p[bt]=0
  elif ph[at]<ph[bt]:
    p[at]=0
  elif ph[at]==ph[bt]:
    p[at]=0
    p[bt]=0 
 
print(sum(p))

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rreps(i, n) for (int (i) = (n); (i) > 0; (i)--)
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} init;

int N, K;
int mod = 924844033;
int fact[2200];
int dp[4400][2200][2];
vector<bool> G;
signed main() {
    cin >> N >> K;

    rep(i, 2) {
        rep(j, K) {
            int cur = N / K - 1 + (N % K > j);
            if (cur == 0) { continue; }
            G.push_back(1);
            rep(k, cur - 1) { G.push_back(0); }
        }
    }

    for (int i = 0; i <= G.size(); i++) { dp[i][0][0] = 1; }
    reps(i, G.size()) {
        for (int j = 1; j <= N; j++) {
            dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
            dp[i][j][1] = dp[i - 1][j - 1][0];
            if (G[i - 1]) { (dp[i][j][1] += dp[i - 1][j - 1][1]) %= mod; }
        }
    }

    fact[0] = 1;
    reps(i, N) { fact[i] = fact[i - 1] * i % mod; }
    int ans = 0;
    int co = 1;
    for (int i = 0; i <= N; i++) {
        (ans += (dp[G.size()][i][0] + dp[G.size()][i][1]) % mod * fact[N - i] % mod * co + mod) %= mod;
        co *= -1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 139520
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i <= (int)n; ++i)
#define REPT(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)
const char alphabet[26] = {'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'};
const ll MOD = 1e9 + 7;
typedef pair<int, int> Pi;

int main() {

    int N, M, sx, sy, gx, gy;
    cin >> N >> M;
    sx = 0;
    sy = 0;
    gx = N-1;
    gy = M-1;
    int map[51][51] = {0};
    int vim[51][51] = {1};
    int cnt = 0;
    REP(i, N) {
        string s;
        cin >> s;
        REP(j, M) {
            if (s[j] == '#'){
                map[i][j] = 0;
                cnt++;
            }
            else map[i][j] = 1;
        }
    };

    queue<pair<int, int>> Q;
    Q.push(make_pair(sx, sy));
    vim[sx][sy] = 1;
    while (!Q.empty()) {
        pair<int, int> t = Q.front();
        Q.pop();
        int x = t.first;
        int y = t.second;
        if (x == gx && y == gy) {
            cout << N*M-vim[gx][gy]-cnt << endl;
            return 0;
        }
        if (map[x + 1][y])
            if (0 <= x && x <= 50 && 0 <= y && y <= 50 && vim[x + 1][y] == 0) {
                Q.push(make_pair(x + 1, y));
                vim[x + 1][y] = vim[x][y] + 1;
            }
        if (map[x - 1][y])
            if (0 <= x && x <= 50 && 0 <= y && y <= 50 && vim[x - 1][y] == 0) {
                Q.push(make_pair(x - 1, y));
                vim[x - 1][y] = vim[x][y] + 1;
            }
        if (map[x][y + 1])
            if (0 <= x && x <= 50 && 0 <= y && y <= 50 && vim[x][y + 1] == 0) {
                Q.push(make_pair(x, y + 1));
                vim[x][y + 1] = vim[x][y] + 1;
            }
        if (map[x][y - 1])
            if (0 <= x && x <= 50 && 0 <= y && y <= 50 && vim[x][y - 1] == 0) {
                Q.push(make_pair(x, y - 1));
                vim[x][y - 1] = vim[x][y] + 1;
            }
    }
    cout << -1 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}





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

int main(void) {
    int a, b, c;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    cout << ((a == b && b == c) || (a != b && b != c && c != a)? "No" : "Yes") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int h,w,i,j,a,b;
while(1){
a=0;
scanf("%d %d",&h,&w);
if(w%2==0)b=1;else b=0;
if((h==0)&&(w==0))break;
for(i=0;i<h;i++){
for(j=0;j<w;j++){

if(a==0){
printf("#"); 
a=1;
}else{
printf(".");
a=0;
}

}
printf("\n");
if(b==1){
if(a==0)a=1;else a=0;
}
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

#define fori(x) for(int i=0;i<x;++i)

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<((a==b)?"Yes":"No");
  return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n, k;
    cin >> n >> k;

    vector< int > as(n);
    cin >> as;

    as.push_back(0);

    range(cnt, 0, k) {
        vector< int > bs(n + 1);
        range(i, 0, n) {
            bs[max(i - as[i], 0)]++;
            bs[min(i + as[i] + 1, n)]--;
        }

        int m = bs[0];
        range(i, 1, n) {
            bs[i] += bs[i - 1];
            chmin(m, bs[i]);
        }

        as = bs;
        if (m == n) {
            as.pop_back();
            cout << as << endl;
            return;
        }
    }

    as.pop_back();
    cout << as << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 4996
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str = sc.nextLine();
      String[] arr = str.split(" ");
      int[] list = new int[arr.length];
      
      for(int i = 0; i < arr.length; i ++){
         list[i] = Integer.parseInt(arr[i]);
      }
      
      Arrays.sort(list);
      
      for(int i = list.length - 1; i >= 0; i --){
         System.out.print(list[i]);
         if(i != 0){
            System.out.print(" ");
         }
      }
      System.out.println();
   }//main   
}//class

Measured memory_bytes: 26296
#cited from c-yan
N, M, X = map(int, input().split())

C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

result = -1
for i in range(1 << N):
    t = [0] * M
    c = 0
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)

Measured memory_bytes: 8984
#include "bits/stdc++.h"

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<int> as(n), bs(n), cs(n);
    long ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> bs[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        cin >> cs[i];
    }
    for (int i = 0; i < n; i++)
    {
        ans += bs[as[i] - 1];
        if (i && (as[i - 1] + 1 == as[i]))
        {
            ans += cs[as[i] - 2];
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
int a[100001];
int b[100001];

int seg[600000];

void update(int i) {
    i += 200000;
    while (i < 600000) {
        ++seg[i];
        i += i & -i;
    }
}

int query(int i) {
    i += 200000;
    int ret = 0;
    while (i) {
        ret += seg[i];
        i -= i & -i;
    }
    return ret;
}

int check() {
    for (int i = 0; i < 600000; ++i) seg[i] = 0;
    for (int i = 2; i <= n; ++i) b[i] += b[i - 1];
    update(0);
    llong ret = 0;
    for (int i = 1; i <= n; ++i) {
        ret += query((b[i] << 1) - i);
        update((b[i] << 1) - i);
    }
    return (n + 1ll) * n <= (ret << 2);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	int s = 1, e = 1e9;
	while (s < e) {
        int m = (s + e + 1) / 2;
        for (int i = 1; i <= n; ++i) b[i] = (m <= a[i]);
        if (check()) s = m;
        else e = m - 1;
	}
	printf("%d\n", s);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

graph grafo;

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

	vi empty;
	grafo.assign(5, empty);
	int in1, in2;
	for (int i = 0; i < 3; ++i)
	{
		cin >> in1 >> in2;
		grafo[in1].push_back(in2);
		grafo[in2].push_back(in1);
	}
	for (int i = 1; i < 5; ++i)
	{
		if (grafo[i].size() > 2) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<Vec<i64>> = (0..2).map(|_| (0..n).map(|_| input()).collect()).collect();

    let mut dp = vec![vec![0; n + 1]; 3];
    for i in 1..3 {
        for j in 1..n + 1 {
            dp[i][j] = std::cmp::max(dp[i][j - 1], dp[i - 1][j]) + a[i - 1][j - 1];
        }
    }
    println!("{}", dp[2][n]);
}


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

int main(){
  double T, X;
  cin >> T >> X;

  cout << setprecision(9) << fixed << T / X << endl;
}

Measured memory_bytes: 3736
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n = gets.to_s.to_i
    @a = Array.new(n){ gets.to_s.split.map { |v| v.to_i } }
  end

  def solve
    cnt = 0
    n.times do |i|
      if a[i][0] == a[i][1]
        cnt += 1 
      else
        cnt = 0
      end
      return "Yes" if cnt >= 3
    end
    "No"
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14352
#pragma comment(linker, "/stack:200000000")

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

#include <stdio.h>
#include <bits/stdc++.h>

#define uint unsigned int
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
string s;
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	ld  a , p , b;
	cin >> a >> b;
	cout << a + b / 2;
	
}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i=0; i<n; i++){
    cin >> a.at(i);
  }
  
  int cnt = 1, flag = 0;
  
  for (int i=0; i<n-1; i++){
    if (i == 0 || flag == 2){
      if (a[i] < a[i+1]){
        flag = 0;
      }
      else if (a[i] > a[i+1]){
        flag = 1;
      }
      else{
        flag = 2;
      }
    }else if (flag == 0){
      if (a[i] > a[i+1]){
        cnt++;
        flag = 2;
      }
    }else{
      if (a[i] < a[i+1]){
        cnt++;
        flag = 2;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int prime[1000001];

void to_prime(int x){
	int copy = x;
	for (int i = 2; i <= sqrt(x); i++){
		int coun = 0;
		while (x%i == 0){
			x /= i;
			coun++;
		}
		prime[i] = max(coun, prime[i]);
	}
	if (copy = x){
		prime[x] = max(1, prime[x]);
	}
}

ll modpow(ll x, ll n){
	ll res = 1;
	while(n > 0){
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}


ll modinv(ll x){
	return modpow(x, MOD-2);
}


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

	for (int i = 0; i < n; i++){
		to_prime(a[i]);
	}

	ll modsum = 0, ans = 1;

	for (int i = 0; i < n; i++){
		modsum += modinv(a[i]);
		modsum %= MOD;
	}

	for (int i = 0; i <= 1000000; i++){
		if (prime[i] != 0){
			ans *= modpow(i, prime[i]);
			ans %= MOD;
		}
	}
	cout << (ans*modsum)%MOD << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	char S[26]; cin >> S;
	ll T[26] = {};
	int i = 0;
	while (S[i]) {
		T[S[i] - 'a']++;
		if (T[S[i] - 'a'] > 1) {
			cout << "no" << endl;
			return 0;
		}
		i++;
	}
	cout << "yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){

	int n;
	cin >> n;

	int box[n];
	for(int k=0 ;k<n;k++){
			cin >>box[k];
			if(k==n-1)
				cout << box[k];
			else
				cout << box[k] << " ";
	}// 入力終わり
	cout << endl;

	int k;
	for(int i=1 ; i < n;i++){

		int v = box[i];
		int j = i-1;
		while(j >=0 && box[j] >v){
			box[j+1] = box[j];
			j--;
		}
		box[j+1] = v;
		for(k = 0; k< n;k++){
			if(k==n-1)
				cout << box[k];
			else
				cout << box[k] << " ";
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <set>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string str;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	std::getline(ifs, str);
#else
	std::getline(std::cin, str);
#endif
	
	std::istringstream stream(str);
	int max_length = 0;
	int max_count = 0;
	std::string longest_str;
	std::string most_frequent_str;
	std::multiset<std::string> mset;

	while(std::getline(stream, str, ' ')){
		if(max_length < str.size()){
			max_length = str.size();
			longest_str = str;
		}
		mset.insert(str);
	}

	for(std::multiset<std::string>::const_iterator it = mset.begin();
		it != mset.end(); it++){
		std::string s = *it;
		int c = mset.count(s);
		if(max_count < c){
			max_count = c;
			most_frequent_str = s;
		}
	}

	std::cout << most_frequent_str << " " << longest_str << std::endl;
	return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  int n,k,i,j,s,t,v[50];

  cin>>n>>k;
  for(i=0;i<n;i++){
    cin>>v[i];
  }
  int r=min(n,k);

  int suma[51],sumb[51],sum,max=0;
  suma[0]=sumb[0]=0;
  for(i=0;i<n;i++){
    suma[i+1]=
    suma[i]+v[i];
    sumb[i+1]=sumb[i]+v[n-1-i];
  }

  int m[51],mn;
  for(i=0;i<=r;i++){
    for(j=0;j<=r;j++){
      t=k-(i+j);
      if(t<0||(i+j)>n){
        break;
      }
      mn=0;
      sum=suma[i]+sumb[j];

      for(s=0;s<i;s++){
        if(v[s]<0){
          m[mn]=v[s];
          mn++;
        }
      }
      for(s=0;s<j;s++){
        if(v[n-1-s]<0){
          m[mn]=v[n-1-s];
          mn++;
        }
      }
      sort(m,m+mn);
      for(s=0;s<t&&s<mn;s++){
        sum-=m[s];
      }

      if(sum>max)max=sum;
    }
  }

  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 256
//Largest Empty Square Algorithm by udchen
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
const int maxn = 2000 + 10;
int mp[maxn][maxn], dp[maxn][maxn], h, w;

int largest_empty_square(int n, int m) {
	memset(dp, 0, sizeof(dp));
	int ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (mp[i][j] == 1)
				dp[i][j] = 0;
			else
				ans = max(ans, (dp[i][j] = min(dp[i - 1][j - 1], min(dp[i][j - 1], dp[i - 1][j])) + 1));
	return ans * ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			cin >> mp[i][j];
	cout << largest_empty_square(h, w) << '\n';
	return 0;
}



Measured memory_bytes: 29936
#include<bits/stdc++.h>
using namespace std;
string str;
int main(){
	cin>>str;
	for(int i=0;i<str.size();i++){
		if(str[i]=='C'){
			for(int j=i+1;j<str.size();j++){
				if(str[j]=='F'){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <set>
#include <queue>

using namespace std;


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

	int n;
	long long to_add = 0;
	cin >> n;

	vector<long long> a(n);
	vector<long long> b(n);

	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = n - 1; i >= 0; --i) {
		a[i] += to_add;
		if (a[i] % b[i] != 0) {
			to_add += b[i] - a[i] % b[i];
		}
	}
	cout << to_add << endl;

	return 0;
}

Measured memory_bytes: 1792
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; long a, b; rd(n, a, b);
  auto h=new long[](n);
  foreach(i; 0..n) rd(h[i]);

  bool c(long k){
    long num=0;
    foreach(e; h) num+=max(0, (e-b*k+a-b-1)/(a-b));
    return num<=k;
  }

  long ng=0, ok=10000000000;
  while(ok-ng>1){
    auto m=(ng+ok)/2;
    (c(m) ? ok : ng = m);
  }

  writeln(ok);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 3708
def max_cookie(a, b, c):
    if a + b + 1 >= c:
        return b + c
    else:
        return a + 2 * b + 1

def main():
    a, b, c = map(int, input().split())
    print(max_cookie(a, b, c))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
			//?????????????????????

	    Scanner scan = new Scanner(System.in);
	    String gyosu = scan.next();
	 	int intgyosu = Integer.parseInt(gyosu);
	 	String[] yesno;
	 	yesno = new String[intgyosu];

	  for(int i = 1; i<=intgyosu; i++){

	    String num1 = scan.next();
	 	int int1 = Integer.parseInt(num1);

	    String num2 = scan.next();
	    int int2 = Integer.parseInt(num2);

	    String num3 = scan.next();
	    int int3= Integer.parseInt(num3);

	    int maxnum = Math.max(int1, int2);
	    int max_num = Math.max(maxnum, int3);

	    boolean hantei = false;

		if(max_num==int1){
	    	hantei =  (int2 * int2) + (int3 * int3) == (int1*int1);
	    }else if(max_num==int2) {
	    	hantei =  (int1 * int1) + (int3 * int3) == (int2*int2);
	    }else if (max_num==int3){
	    	hantei =  (int2 * int2) + (int1 * int1) == (int3*int3);
	    }

		if(hantei){
			 yesno[i-1] = "YES";
		}else{
			yesno[i-1] = "NO";
		}
	  }

	  //????????????
	    scan.close();

	    for(int j =0; j<intgyosu; j++){
	    		System.out.println(yesno[j]);

	}

	}
}

Measured memory_bytes: 34972
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, 4) if(s[i] == '2') ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g;

	scanf("%d%d%d%d",&a,&b,&c,&d);

	e = a+b+c+d ;

	f = e / 60 ;

	g = e % 60 ;

	printf	("%d\n%d\n",f,g);

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define pb push_back
 
using namespace std;

const int N=3005;
int n,a[N];
vector<int> e[N];

bool dfs(int x,int fa){
	for(int v:e[x])if(v!=fa&&a[x]>a[v]&&!dfs(v,x))return true;
	return false;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),e[u].pb(v),e[v].pb(u);
	for(int i=1;i<=n;i++)if(dfs(i,0))printf("%d ",i);
	return 0;
}

Measured memory_bytes: 384