akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;


int main(void) {
    int n, k, i, j, d, de;
    const int mod = 1e9 + 7;
    ll pa[100003] = {}, r, ans;

    cin >> n >> k;
    
    for (i = k; i > 0; i--) {
        d = k / i;
        de = n;
        pa[i] = 1;
        r = d;
        while (de > 0) {
            if ((de & 1) == 1) pa[i] = pa[i] * r % mod;
            r = r * r % mod;
            de >>= 1;
        }
        j = i;
        while (j <= k) {
            if (j + i <= k) j += i;
            else break;
            pa[i] = (pa[i] + mod - pa[j]) % mod;
        }

    }

    ans = 0;
    for (i = 1; i <= k; i++) {
        ans = (ans + pa[i] * i % mod) % mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4408
N=int(input())
ans=[0]*(10**5)
L=list(i for i in range(1,100))

from itertools import*
P=list(product(L,repeat=3))
for x,y,z in P:
    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1

for a in ans[:N]:
    print(a)

Measured memory_bytes: 79080
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <algorithm>

#define rep(i, n) for(int i=0;i<n;i++)
#define IOS() ios_base::sync_with_stdio(false)

using namespace std;

char ch;

void input() {

    cin >> ch;

    switch(ch) {

        case 'A':
            cout << 'T';
            break;

        case 'C':
            cout << 'G';
            break;

        case 'G':
            cout << 'C';
            break;

        case 'T':
            cout << 'A';
            break;

    }

}

int main() {

    IOS();

    input();


    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>V(N);
  vector<int>C(N);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  for(int i =0;i<N;i++){
    cin >> C.at(i);
  }
  vector<int>A(N);
  for(int i=0;i<N;i++){
    A.at(i) = V.at(i) - C.at(i);
  }
  sort(A.begin(),A.end());
  int max=0;
  for(int i =0;i<N;i++){
   if(A.at(i)>0){
     max += A.at(i);
   }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
//ALL GLORY TO JESUS CHRIST 
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}
//const int NAX = (int)3e5+5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int n; cin >> n;
    vii v(n);
    forn(i, n) {
      cin >> v[i].first;
      v[i].second = i;
    }
    sort(all(v));
    forn(i, n)
      cout << v[i].second+1 << " ";
    cout << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

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

    bool flg=true;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a%2!=0) flg=false;
    }
    if(flg) cout << "second" << endl;
    else cout << "first" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	Scanner stdin = new Scanner(System.in);
	while ( stdin.hasNextLine() ) {
	    
	    final char[] in = stdin.nextLine().toCharArray();
	    
	    for ( int i = 0; i < 26; i++ ) {

		for ( int j = 0; j < in.length; j++ ) {
		    if ( isAlphabet( in[j] ) ) {
			in[j] = (char)( ( in[j] + 1 - 'a' ) % 26 + 'a' );
		    }
		}
		final String str = new String( in );
		if ( str.contains( "the" ) || str.contains( "this" ) || str.contains( "that" ) ) {
		    System.out.println( str );
		    break;
		}
		
	    }	    
	}
	
    }

    static boolean isAlphabet( char ch ) {
	return 'a' <= ch && ch <= 'z';
    }
    
}

Measured memory_bytes: 17964
#include <stdio.h>

int A[1000000];

int biNsearch(int,int);

int main(){
  
  
  int i,q,n,key1;
  int count = 0;
  
  scanf("%d", &n);
  
  for(i = 0;i < n;i ++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  
  for(i = 0;i < q;i ++)
    {
      scanf("%d", &key1);
      if(biNsearch(key1,n))count ++;
    }

  printf("%d\n",count);

  return 0;
}

int biNsearch(int key2,int n){

  int left = 0,right = n;
  int mid;
  
  
  while(left < right) {
    
    mid = (left + right) / 2;
    
    if (key2 == A[mid]) {
      return 1;
    }
    
    if(key2 > A[mid]){
      left = mid + 1; 
    }
    else if(key2 < A[mid])
      {
      right = mid; 
      }
  }  
    return 0;
  
}

Measured memory_bytes: 988
e1,e2,e3,e4 = map(int, input().split())
if e1 == e2 and e3 == e4:
    print("yes")
elif e1 == e3 and e2 == e4:
    print("yes")
elif e1 == e4 and e2 == e3:
    print("yes")
else:
    print("no")


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

#define NMAX 3005
using namespace std;

int dp[NMAX][NMAX], val[NMAX], w[NMAX];
char s[3005], t[3005];

void build(int i, int j){
    if(dp[i][j] == 0)
        return;
    if(dp[i - 1][j - 1] == dp[i][j] - 1 && s[i] == t[j]){
        build(i - 1, j - 1);

        cout << s[i];
    }
    else if(dp[i - 1][j] == dp[i][j])
        build(i - 1, j);
    else if(dp[i][j - 1] == dp[i][j])
        build(i, j - 1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin.getline(s + 1, 3005);
    cin.getline(t + 1, 3005);

    int lg1 = strlen(s + 1);
    int lg2 = strlen(t + 1);
    for(int i = 1; i <= lg1; ++i)
        for(int j = 1; j <= lg2; ++j)
            if(s[i] == t[j])
                dp[i][j] = max(dp[i - 1][j - 1] + 1, max(dp[i - 1][j], dp[i][j - 1]));
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

    build(lg1, lg2);
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll n,a,b;cin >> n >> a >> b;
  ll res = b*(n-1)+a - (a*(n-1)+b) + 1;
  cout << (ll)max((ll)0 , res) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
struct TopologicalSort {
    vector<vector<int>> E; TopologicalSort(int N) { E.resize(N); }
    void add_edge(int a, int b) { E[a].push_back(b); }
    bool visit(int v, vector<int>& order, vector<int>& color) {
        color[v] = 1;
        for (int u : E[v]) {
            if (color[u] == 2) continue; if (color[u] == 1) return false;
            if (!visit(u, order, color)) return false;
        } order.push_back(v); color[v] = 2; return true;
    }
    bool sort(vector<int> &order) {
        int n = E.size(); vector<int> color(n);
        for (int u = 0; u < n; u++) if (!color[u] && !visit(u, order, color)) return false;
        reverse(order.begin(), order.end()); return true;
    }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, M;
vector<int> E[101010];
int dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    TopologicalSort ts(N);
    rep(i, 0, M) {
        int x, y; cin >> x >> y; x--; y--;
        ts.add_edge(x, y);
        E[x].push_back(y);
    }
    vector<int> ord;
    ts.sort(ord);

    fore(cu, ord) fore(to, E[cu]) chmax(dp[to], dp[cu] + 1);
    int ans = 0;
    rep(i, 0, N) chmax(ans, dp[i]);
    cout << ans << endl;
}


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

using namespace std;

int main(){
    char s[101];
    cin>>s;
    for(int i=1; i<=strlen(s); ++i){
        if(i%2==0&&s[i-1]=='R'){
            cout<<"No";
            return 0;
        }
        else if(i%2&&s[i-1]=='L'){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
readline = open(0).readline
writelines = open(1, 'w').writelines
N, Q = map(int, readline().split())
ans = []
A = [[] for i in range(N)]
def push(t, x):
    A[t].append(x)
def top(t):
    A[t] and ans.append("%d\n" % A[t][-1])
def pop(t):
    A[t] and A[t].pop()

C = [push, top, pop].__getitem__
for i in range(Q):
    t, *a=map(int, readline().split())
    C(t)(*a)
writelines(ans)


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

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

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

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

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

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

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

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

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

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

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

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

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),m=read(),ans=0;
	vi cnt(n,0),num(n,0);
	auto Add=[&](int x){
		int pos=max(x-(cnt[x]++),0LL);
		num[pos]++;
		if(num[pos]>1)ans++;
	};
	auto Del=[&](int x){
		int pos=max(x-(--cnt[x]),0LL);
		num[pos]--;
		if(num[pos]>0)ans--;
	};
	vi a(n);REP(i,n)a[i]=read()-1;
	for(auto x:a)Add(x);
	while(m--){
		int x=read()-1,y=read()-1;
		Del(a[x]);
		Add(a[x]=y);
		print(ans);
	}
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll g[4001][4001];
int r,c,k;
ll dp[4001][4001][4];
ll rec(ll i, ll j, ll taken)
{
	if(i>=r)return 0;
	if(j>=c)return 0;
	if(dp[i][j][taken]!=-1)return dp[i][j][taken];
	ll ans=0;
	if(taken<3 && i<r && j<c){
		ans=g[i][j];
	}
	else{ans=0;}
	
	ans=rec(i+1,j,0);
	if(taken<3){
	ans=max(ans,rec(i+1,j,0)+g[i][j]);
	}
	ans=max(ans,rec(i,j+1,taken));
	if(taken<3){
	ans=max(ans,rec(i,j+1,taken+1)+g[i][j]);
	}

	return dp[i][j][taken]=ans;



}
int main()
{
	 cin>>r>>c>>k;
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			g[i][j]=0;
		}
	}
	for(int i=0;i<k;i++)
	{
		int a,b,v; cin>>a>>b>>v;
		a--; b--;
		g[a][b]=v;
	}
	memset(dp,-1,sizeof(dp));
	cout<<rec(0,0,0);
	
	
}

Measured memory_bytes: 586568
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a, sum = 0, maxnum = 0;
  for(int i = 0; i < 5; i++){
    cin >> a;
    if(a % 10 == 0){
      sum += a;
      maxnum = max(maxnum, 0);
    } else {
      sum += (a / 10 + 1) * 10;
      maxnum = max(maxnum, 10 - a % 10);
    }
  }
  cout << sum - maxnum << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {	
		Scanner scanner = new Scanner(System.in);
		String string = scanner.next();
		string = string.substring(0, string.length() - 1);
		boolean same = false;
		while (!same) {
			if (string.length() % 2 != 0) {
				string = string.substring(0, string.length() - 1);
			}
			for (int i = 0; i < string.length() / 2; i++) {
				if (string.charAt(i) == string.charAt(i + string.length() / 2)) {
					same = true;
				} else {
					same = false;
					break;
				}
			}
			if (same) {
				break;
			}
			string = string.substring(0, string.length() - 1);
		}
		System.out.println(string.length());
		scanner.close();
	}
}


Measured memory_bytes: 21844
#include <iostream>

int main(){
  while(true){
    int a, b;
    std::cin >> a >> b;
    if(std::cin.eof()) return 0;
    int c=0, s=a+b;
    while(s!=0){
      s/=10;
      c++;
    }
    std::cout << c << std::endl;
  }
}


Measured memory_bytes: 2980
from collections import defaultdict

class UF():
    def __init__(self,n):
        self.l = [-1]*n
    def root(self, a):
        if self.l[a] < 0:
            return a
        else:
            self.l[a] = self.root(self.l[a])
        return self.l[a]
    def unite(self, a, b):
        a, b = self.root(a), self.root(b)
        if a == b:
            return
        if self.l[a] > self.l[b]:
            a, b = b, a
        self.l[a] += self.l[b]
        self.l[b] = a

n,k,l = map(int, input().split())
d = UF(n)
t = UF(n)
for i in range(k):
    r,s = map(int,input().split())
    d.unite(r-1, s-1)
for i in range(l):
    r,s = map(int,input().split())
    t.unite(r-1, s-1)
d_set = defaultdict(set)
t_set = defaultdict(set)
for i in range(n):
    d_set[d.root(i)].add(i)
    t_set[t.root(i)].add(i)

ans = []
cache = {}
for i in range(n):
    rd = d.root(i)
    rt = t.root(i)
    if (rd,rt) in cache:
        ans.append(cache[(rd,rt)])
    else:
        _ = len(d_set[rd] & t_set[rt])
        cache[(rd,rt)] = _
        ans.append(_)
print(*ans)

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

H = list(map(int, input().split()))
A = [0 for i in range(N)]

if H[0] >=2:
  A[0]=H[0]-1
else:
  A[0]=1
  
for i in range(1, N):
  if H[i] > A[i-1]:
    A[i] = H[i] - 1
  elif H[i] < A[i-1]:
    print('No')
    exit()
  else:
    A[i]=H[i]
print('Yes')

Measured memory_bytes: 14224
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

s = v()
if s[-1] == "s":
  print(s+"es")
else:
  print(s+"s")

Measured memory_bytes: 10372
#include<stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a+b<c+d){
        printf("Right");
    }else if(a+b>c+d){
        printf("Left");
    }else{
        printf("Balanced");
    }
    
    
    return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n;
int ans = 1;
int main() {
    scanf("%d",&n);
    vector<int>d(n);
    rep(i,0,n) cin >> d[i];

    sort(d.begin(),d.end());
    rep(i,0,n-1){
        if(d[i] != d[i+1]){
            ans++;
        }
    }
    pout(ans);
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum;
LL ans,a;
LL no;


int main() {
	cin >> N;
	ans = 0;
	no = 0;
	vector<LL> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		if (i > 0) {
			if (v[i] > v[i - 1]) {
				ans = max(ans, no);
				no = 0;
			}
			else {
				no++;
			}
		}
	}
	ans = max(ans, no);
	cout << ans << endl;

	return 0;
}



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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int N;
    lint x;
    cin >> N >> x;
    lint candy[100000];
    for(int i=0;i<N;i++) cin >> candy[i];
    lint cnt=0;

    for(int i=0;i<N;i++){
        if(i==0){
            if(candy[i]>x){
                cnt+=candy[i]-x;
                candy[i]=x;
            }
        }
        else if(candy[i]+candy[i-1]>x){
            cnt+=(candy[i]+candy[i-1])-x;
            candy[i]-=(candy[i]+candy[i-1])-x;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  int answer = 0;
  for(int i = 0;i < 2;i++) {
    if(A > B) {
      answer = answer + A;
      A = A - 1;
    }
    else {
      answer = answer + B;
      B = B - 1;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;

long P = 10^^9+7;
long[1001] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

long perm(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];
    auto n_k_b = RF[n-k];
    return (n_b * n_k_b) % P;
}

void main()
{
    init();
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    long r;
    foreach (k; 1..K+1) {
        long rr;
        foreach (e; 0..k) {
            (rr += comb(k, e) * pow(k-e, N) % P * (-1)^^e + P) %= P;
        }
        (r += rr * RF[k] % P) %= P;
    }
    writeln(r);
}


Measured memory_bytes: 2484
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    set<ll>s;
    vector<ll>len(n+1);
    ll ma=0;
    rep(i,n){
        ll p;cin>>p;
        s.insert(p);
        auto itr=s.find(p-1);
        if(itr==s.end()){
            len[p]=1;
        }else{
            len[p]=len[p-1]+1;
        }
        ma=max(len[p],ma);
    }
    cout<<n-ma<<endl;
}

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

typedef long long ll;

int main() {
	int N; cin >> N;
	vector<int> a(N+1);
	map<string, int> m;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (i < a[i]) {
			m[to_string(i)+to_string(a[i])]++;
		}
		else {
			m[to_string(a[i])+to_string(i)]++;
		}
	}

	int ans=0;
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if(itr->second>=2) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char s[110], ss[110];
bool check(int x){
	for(int i = 0; i < strlen(ss)-x-1; i ++){
		if(ss[i] != ss[i+1])return false;
	}
	return true;
}
int fun(int x){
	strcpy(ss,s);
	int cnt = 0;
	int len = strlen(ss);
	while(1){
		if(check(cnt))break;
		for(int i = 0; i <len-cnt-1; i ++){
			if(ss[i+1] == ('a'+x)){
				ss[i] = 'a'+x;
			}else ss[i] = ss[i];
		}
		cnt++;
	}
	return cnt;
}

int main(){
	cin >> s;
	int ans = strlen(s)/2;
	for(int i = 0; i < 26; i ++){
		//cout << i <<' ' << fun(i) << endl;
		ans = min(ans,fun(i));
	}
	cout << ans << endl;
	return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
int p[1000009];
ll v[1000009],iv[1000009];
const ll mod = 1e9+7;
ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
		if (b) { ll d = euclid(b, a % b, y, x);
					return y -= a/b * x, d; }
			return x = 1, y = 0, a;
}
ll modInverse(ll a,ll p){
		ll x,y;
			euclid(a,p,x,y);
				return ((x%p+p)%p);
}
ll f[1000009];
vi nodes[(1<<19)];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	int l = (1<<(n-1));
	v[1]=iv[1]=1;
	repA(i,2,2*l-1){
		v[i] = v[i/2]*i%mod;
		iv[i] = modInverse(v[i],mod);
	}
	rep(i,l) {
		cin>>p[i];
		p[i]--;
		nodes[i+l].pb(i+l);
	}
	ll ans = 0;

	repD(i,l-1,1){
		trav(j,nodes[2*i]){
			nodes[i].pb(j);
			int px = p[j-l]+l;
			int opx = px;
			while(px!=0){
				f[px]+=v[opx]*v[j]%mod;
				f[px]%=mod;
				px/=2;
			}
		}
		trav(j,nodes[2*i+1]){
			nodes[i].pb(j);
			ll cur = 0;
			ll lst = 0;
			int px = p[j-l]+l;
			int opx = px;
			while(px!=0){
				cur+=iv[px]*((f[px]-lst+mod)%mod)%mod*iv[px]%mod*px%mod;
				cur%=mod;
				lst = f[px];
				px/=2;
			}
			ans+=cur*v[j]%mod*v[opx]%mod*iv[i]%mod*iv[i]%mod*i%mod;
			ans%=mod;
		}
		trav(j,nodes[2*i]) {
			int px = p[j-l]+l;
			while(px!=0){
				f[px]=0;
				px/=2;
			}
		}
	}
	cout<<((ans%mod)+mod)%mod;
	return 0;
}



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


int main(void){
	string org;
	
	while(getline(cin,org)){

	for(int i=0; i<26; i++){
		for(int j=0; j<org.size(); j++){
			if( org[j] == '.' || org[j] == ' ' ) {}
			else {
				org[j]++;
				if( org[j] > 'z' )
					org[j] -= 26;
			}
		}
		string::size_type pos;
		pos = org.find("the");
		if( pos != string::npos ){
			cout << org << endl;
		}
		else{
			pos = org.find("this");
			if( pos != string::npos ){
				cout << org << endl;
			}
			else{
			pos = org.find("that");
			if( pos != string::npos ){
				cout << org << endl;
			}
			}
		}
	}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
using namespace std;

const int maxn=505;

int n,m;
char s[maxn][maxn];
bool bo[maxn][maxn];

int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}

int main() {
	n=read(),m=read();
	for(int i=1;i<=n;i++) {
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
			if(s[i][j]=='#')bo[i][j]=1;
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++)
			if(j!=m&&(bo[i][j]||j==1||(i&1)))printf("#");
			else printf(".");
		puts("");
	}
	puts("");
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++)
			if(j!=1&&(bo[i][j]||j==m||((i&1)==0)))printf("#");
			else printf(".");
		puts("");
	}
	return 0;
}


Measured memory_bytes: 1152
S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
    if S[i]=="0":
        a.append(val)
        val=0
    else:
        val+=1

if val!=0:
    a.append(val)
m=len(a)
K=min(sum(a),K)

dp=[[0 for i in range(K+1)] for j in range(K+1)]

for j in range(K+1):
    dp[j][j]=1

b=[a[i] for i in range(m)]
c=[a[i] for i in range(m)]
for i in range(1,m):
    b[i]+=b[i-1]
b=[0]+b
for i in range(m-2,-1,-1):
    c[i]+=c[i+1]
for i in range(m-1,-1,-1):
    ndp=[[0 for j in range(K+1)] for k in range(K+1)]
    for k in range(min(b[i],K)+1):
        for j in range(min(K,k+c[i])+1):
            M=max(k-j,-a[i])
            ndp[j][k]=sum(dp[j+l][k] for l in range(max(0,M),K-j+1))+sum(dp[j][k+l] for l in range(1,min(K-k,-M)+1))
            ndp[j][k]%=mod
    dp=ndp

print(dp[0][0])


Measured memory_bytes: 107040
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N, K, L;
int par[2][200005], rankk[2][200005];

void init()
{
    for(int i = 0; i <= N; i++){
        par[0][i] = i;
        par[1][i] = i;
    }
}

int root(int x, int e)
{
    if(par[e][x] == x){
        return x;
    }
    else{
        return par[e][x] = root(par[e][x], e);
    }
}

void unite(int x, int y, int e)
{
    x = root(x, e), y = root(y, e);
    if(x == y)return;

    if(rankk[e][x] < rankk[e][y]){
        par[e][x] = y;
    }
    else {
        par[e][y] = x;
        if(rankk[e][x] == rankk[e][y]){
            rankk[e][x]++;
        }
    }
}

bool same(int x, int y, int e)
{
    return root(x, e) == root(y, e);
}

map<PA, int> mp;

signed main()
{
    cin >> N >> K >> L;
    init();
    for(int i = 0; i < K; i++){
        int a, b;
        cin >> a >> b;
        unite(a, b, 0);
    }
    for(int i = 0; i < L; i++){
        int a, b;
        cin >> a >> b;
        unite(a, b, 1);
    }
    for(int i = 1; i <= N; i++){
        int x = root(i, 0), y = root(i, 1);
        mp[mk(x, y)]++;
        //printf("PA %lld %lld\n", x, y);
    }
    for(int i = 1; i <= N; i++){
        int x = root(i, 0), y = root(i, 1);
        printf("%lld", mp[mk(x, y)]);
        if(i < N) printf(" ");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 16384
/**
*    created: 03.07.2020 01:59:45
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    int s = a + b;
    if (s % 2 == 0) cout << s/2 << endl;
    else cout << (s+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
  int N;
  cin >> N;
  map<string, int> m;
  string tmp;
  int max_count = 0;
  rep(i, N) {
      cin >> tmp;
      m[tmp]++;
      max_count = max(m[tmp], max_count);
  }

  vector<string> ret;
  for(auto& itr: m) {
      if (itr.second == max_count)
        ret.push_back(itr.first);
  }
  sort(ret.begin(), ret.end());
  for(auto&s: ret) {
      std::cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 26868
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;

class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(a.Max() - a.Min());
    }
}



Measured memory_bytes: 13780
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    const int64_t MOD = 1e9 + 7;
    int64_t N;
    cin >> N;
    vector<int64_t> p, x;
    for(int n = 2; n <= N; n++) {
		bool isPrime = true;
        int c = n;
		for (int i = 0; i < p.size(); i++) {
            while (c % p[i] == 0) {
                isPrime = false;
                c /= p[i];
                x[i]++;
            }
		}
		if (isPrime) {
			p.push_back(n);
            x.push_back(1);
        }
    }
    int64_t ans = 1;
    for(auto i : x) {
        ans *= i + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
l,r=map(int,input().split())

min=100000000000000000000000
for i in range(l,r+1):
    for j in range(i+1,r+1):
        mod = (i*j)%2019
        if mod == 0:
            print(0)
            exit()
        elif mod<min:
            min = mod
print(min)


Measured memory_bytes: 2940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1e9+10;

int dp[5010][5010];
int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  vector<PII> ps(N);
  VI xs(N), ys(N);
  // x??§?¨???¨y??§?¨??????\??????????????????
  REP(i,N){
	scanf("%d %d", &ps[i].first, &ps[i].second);
	xs[i] = ps[i].first, ys[i] = ps[i].second;
  }
  xs.PB(-INF), xs.PB(INF);
  ys.PB(-INF), ys.PB(INF);
  SORT(xs); SORT(ys);

  // x -> x', 0 <= x' < N+2
  map<int,int> compX, compY;
  int MX = 0;
  REP(i,N+2)
	if(!compX.count(xs[i])){
	  compX[xs[i]] = MX++;
	}
  int MY = 0;
  REP(i,N+2)
	if(!compY.count(ys[i])){
	  compY[ys[i]] = MY++;
	}

  REP(i,N)
	dp[compY[ps[i].second]][compX[ps[i].first]]++;

  for(int y=0;y<MY;++y)
	for(int x=0;x<MX;++x)
	  dp[y][x] += (y>0? dp[y-1][x]:0) + (x>0?dp[y][x-1]:0) - (y>0&&x>0? dp[y-1][x-1]:0);

  while(M--){
	int sx, sy, ex, ey;
	scanf("%d %d %d %d", &sx, &sy, &ex, &ey);
	int sxi = compX.lower_bound(sx)->second;
	int syi = compY.lower_bound(sy)->second;
	auto it = compX.upper_bound(ex); --it;
	int exi = it->second;
	it = compY.upper_bound(ey); --it;
	int eyi = it->second;

	int ans = dp[eyi][exi] - (sxi>0?dp[eyi][sxi-1]:0) - (syi>0?dp[syi-1][exi]:0) + (syi>0&&sxi>0? dp[syi-1][sxi-1]:0);
	printf("%d\n", ans);
  }
  
  return 0;
}

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

int main(void){
	int n;
	int h[3],dp[3]={0};
	cin>>n;
	cin>>h[1]>>h[2];
	dp[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;i++){
		cin>>h[i%3];
		dp[i%3]=min(dp[(i-2)%3]+abs(h[(i-2)%3]-h[i%3]),dp[(i-1)%3]+abs(h[(i-1)%3]-h[i%3]));
	}
	cout<<dp[n%3]<<endl;

	return 0;
}


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

using namespace std;

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

    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r[n+1]={0},g[n+1]={0},b[n+1]={0};
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R'){
            r[i] = r[i+1]+1;
            g[i] = g[i+1];
            b[i] = b[i+1];
        }
        else if(s[i]=='G'){
            g[i] = g[i+1]+1;
            r[i] = r[i+1];
            b[i] = b[i+1];
        }
        else{
            b[i] = b[i+1]+1;
            r[i] = r[i+1];
            g[i] = g[i+1];
        }
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        char c = s[i];
        for(int j=i+1;j<n;j++){
            if(s[j]!=c){
                int diff = j-i;
                int rr=0,bb=0,gg=0;
                if(c=='R' || s[j]=='R')
                    rr=1;
                if(c=='G' || s[j]=='G')
                    gg=1;
                if(c=='B' || s[j]=='B')
                    bb=1;
                if(rr==0){
                    ans += r[j+1];
                    if(j+diff<n && s[j+diff]=='R')
                        ans--;
                }
                else if(bb==0){
                    ans += b[j+1];
                    if(j+diff<n && s[j+diff]=='B')
                        ans--;
                }
                else{
                    ans += g[j+1];
                    if(j+diff<n && s[j+diff]=='G')
                        ans--;
                }
            }
        }
    }
    cout<<ans;
	return 0;
}


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



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


    long long h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) cout << 1 << endl;
    else cout << (h*w+1) / 2 << endl;


    return 0;
}



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

  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  int B[N];
  for (int i = 0; i < N; i++) cin >> B[i];

  int C[N - 1];
  for (int i = 0; i < N - 1; i++) cin >> C[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += B[A[i]-1];
    if (i > 0 && A[i] == A[i-1] + 1 )  {
      ans += C[A[i-1]-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n,k; cin >> n >> k;
    vector<ll> v(n);
    REP(i,n) cin >> v[i];
    ll ans = 1LL << 60;
    REP(i,n-k+1) {
        int e = i+k-1;
        ans = min(ans,abs(v[e]- v[i]) + min(abs(v[i]),abs(v[e])));
    }

    cout << ans << '\n'; 

    return 0;
}

Measured memory_bytes: 1024
#! /usr/bin/env python3

def main():
    N, L = map(int, input().split())
    A = list(map(int, input().split()))
    la = N
    for i in range(N-1):
        if A[i] + A[i+1] >= L:
            la = i
            break
    if la == N:
        print('Impossible')
        return
    print('Possible')
    for i in range(la) : print(i+1)
    for i in range(N-la-2) : print(N-i-1)
    print(la+1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 14388
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n = int(input())
  A = list(map(int,input().split()))
  
  ans = 0
  for i in range(n):
    ans += 1/A[i]
  inv = 1/ans
  print(inv)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt();
            var x1 = line[0];
            var y1 = line[1];
            var x2 = line[2];
            var y2 = line[3];

            var xd = x2 - x1;
            var yd = y2 - y1;

            return $"{x2 - yd} {y2 + xd} {x1 - yd} {y1 + xd}";
        }

        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    #region Console
    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
    #endregion
}

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

int main() {
    string S; cin >> S;
    int cnt = 0, ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S.at(i) == 'R') {
            cnt++;
            ans = max(ans, cnt);
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	static double[] X, Y;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			X = new double[N];
			Y = new double[N];
			for (int i = 0; i < N; ++i) {
				X[i] = sc.nextDouble();
				Y[i] = sc.nextDouble();
			}
			System.out.println(solve());
		}
	}

	static int solve() {
		if (N == 1) return 1;
		if (N == 2) {
			return dist(0, 1) <= 2 ? 2 : 1;
		}
		int ans = 1;
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				double d = dist(i, j);
				if (d > 2) continue;
				double dx = (X[j] - X[i]) / 2;
				double dy = (Y[j] - Y[i]) / 2;
				double len = sq(dx, dy);
				double ex = dx / len;
				double ey = dy / len;
				double lenC = Math.sqrt(1 - len * len);
				{
					double cx = X[i] + dx - ey * lenC;
					double cy = Y[i] + dy + ex * lenC;
					ans = Math.max(ans, count(cx, cy));
				}
				{
					double cx = X[i] + dx + ey * lenC;
					double cy = Y[i] + dy - ex * lenC;
					ans = Math.max(ans, count(cx, cy));
				}
			}
		}
		return ans;
	}

	static int count(double cx, double cy) {
		int c = 0;
		for (int i = 0; i < N; ++i) {
			double d = sq(X[i] - cx, Y[i] - cy);
			if (d <= 1 + 1e-9) ++c;
		}
		return c;
	}

	static double dist(int i, int j) {
		return sq(X[i] - X[j], Y[i] - Y[j]);
	}

	static double sq(double x, double y) {
		return Math.sqrt(x * x + y * y);
	}

}

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

constexpr int mod = 998244353;
struct mint {
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint &operator+=(const mint &a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator-=(const mint &a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint &a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint &a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint &a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint &a) const {
    mint res(*this);
    return res /= a;
  }
};
ostream &operator<<(ostream &os, const mint &m) {
  os << m.x;
  return os;
}

int d[100001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  int maxv = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (i == 0 && a != 0) {
      cout << 0 << endl;
      return 0;
    }
    d[a]++;
    chmax(maxv, a);
  }

  if (d[0] > 1) {
    cout << 0 << endl;
    return 0;
  }

  mint ans = 1;
  rep(i, 1, maxv + 1) {
    mint a1 = d[i - 1];
    ans *= a1.pow(d[i]);
  }

  cout << ans.x << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double v,y;
	while(cin>>v){
	y=4.9*v/9.8*v/9.8;
	for(int i=1;i!=1000000;i++){
		if((i*5-5)>y){
			cout<<i<<endl;
		break;
		}
	}	
	}
}

Measured memory_bytes: 1224
import numpy as np
H,W=map(int,input().split())
c=[list(input()) for _ in range(H)]
wide=np.zeros((H*2,W)).tolist()

#print(c,wide)
for i in range(H):
    for j in range(W):
        wide[2*i][j]=c[i][j]
        wide[2 * i+1][j] = c[i][j]

for i in wide:print(*i, sep='')


Measured memory_bytes: 14164
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main() {
	/*
	int a = 0;//整数変数aを作る
	int b = 0;//整数変数bを作る

	cin >> a >> b;//2つの数字を受け取り、a,bに代入

	cout << a * b << endl;//a*bを出力
	*/
	/*
	string S;
	cin >> S;
	if (S[0]=='7'||S[1]=='7'||S[2]=='7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	int a = 0;
	int b = 0;
	int ans = 0;

	cin >> a >> b;

	int apb = a + b;
	int akb = a * b;
	int amb = a - b;
	ans = apb;
	if (ans < a - b) {
		ans = a - b;
	}


	if (ans < a * b) {
		ans = a * b;
	}
	cout << ans << endl;
	*/
	int N = 0;
	int R = 0;
	int Ans = 0;
	cin >> N >> R;
	if (N >=10) {
		Ans = R;
	}
	else
	{
		Ans = R + (100 * (10 - N));
	}

	cout << Ans << endl;
	return 0;
}



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

int main()
{

	int N, M;
	cin >> N >> M;

	int a=0, b=0;

	if (N >= 2) { a = N * (N - 1) / 2; }
	if (M >= 2) { b = M * (M - 1) / 2; }

	cout << a+b << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

  int n, a, b, c, d;
  cin >> a >> b >> c >> d;
  if(c / b  + (c % b != 0) <= a / d +  (a % d != 0)){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


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

int main(){
	int a,b,ans;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?') break;
		else if(op=='+') ans=a+b;
		else if(op=='-') ans=a-b;
		else if(op=='*') ans=a*b;
		else if(op=='/') ans=a/b;
		printf("%d\n",ans); 
	}
	return 0;
}

Measured memory_bytes: 1028