akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		for(int i = 0; i < 5; i++){sum += Math.max(40, sc.nextInt());}
		System.out.println(sum/5);
	}
}


Measured memory_bytes: 26448
N = int(input())
A = list(map(int, input().split()))
d = dict()
for a in A:
    v = d.get(a, 0)
    d[a] = v+1
S = sum(A)
Q = int(input())
B = []
C = []
for q in range(Q):
    b, c = map(int,input().split())
    v = d.get(b, 0)
    S += v*(c-b)
    d[b] = 0
    d[c] = d.get(c,0) + v
    print (S)

Measured memory_bytes: 23816
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto i:x) cout << i << " "; cout << "\n";}
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b

const ll INF64=LLONG_MAX;
const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;
template <typename T>
struct segment_tree{

    vector<T>tree;
    int size;
    T DEF;
    void init(int n){
        size=1;
        DEF=INF;
        while(size<n)size*=2;
        tree=vector<T>(2*size,0);
    }

    T merge(T a,T b){return a+b;}

    void set(int i,int x,T v,int lx, int rx){
        if(rx-lx==1){
            tree[x]=v;
            return;
        }
        int m=(rx+lx)/2;
        if(i<m){
            set(i,2*x+1,v,lx,m);
        }
        else{
            set(i,2*x+2,v,m,rx);
        }
        tree[x]=merge(tree[2*x+1],tree[2*x+2]);
    }
    void set(int i,T v){
        set(i,0,v,0,size);
    }
    T sum(int l,int r,int x,int lx,int rx){
        if(r<=lx || rx<=l) return 0;//change
        else if(l<=lx && rx<=r)return tree[x];
        int m=(lx+rx)/2;
        return merge(sum(l,r,2*x+1,lx,m),sum(l,r,2*x+2,m,rx));
    }
    T sum(int l,int r){
        return sum(l,r+1,0,0,size);
    }
    void print_tree(){
        for(int i=0; i<tree.size(); i++)
            cout << to_string(tree[i]) << " ";
        cout << "\n";
    }
};
vi bfs(vector<vi>adj, int src){
    queue<int>q;
    vi d(adj.size(),INF);
    q.push(src);
    d[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(d[nbr]==INF)
                q.push(nbr);
            d[nbr]=min(d[nbr],d[c]+1);
        }
    }
    return d;
}
void read(vi& v){
    int n=v.size();
    for(int i=0; i<n; i++)
        cin >> v[i];
}
ld log (ld a,ld b){return log(b)/log(a);}
ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}

void solve();

int main() {
    FAST;
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
}
void solve(){
    int n;
    cin >> n;
    ll mx=-1;
    ll ans=0;
    while(n--){
        ll x;
        cin >> x;
        if(x<mx)
            ans+=mx-x;
        mx=max(x,mx);
    }
    out(ans)
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<char> S(N);
    for (int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    set<char> st_x, st_y;
    int count = 0, count_f = 0;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < i; j++){
            st_x.insert(S.at(j));
        }
        for (int j = i; j < N; j++){
            st_y.insert(S.at(j));
        }
        while (!st_x.empty()){
            char k = *begin(st_x);
            if (st_y.count(k)) count++;
            st_x.erase(k);
            //cout << "i " << i << " count " << count << " k " << k << endl;
        }
        while (!st_y.empty()){
            st_y.erase(*begin(st_y));
        }
        count_f = max(count, count_f);
        count = 0;
    }
    cout << count_f << endl;
}

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

int main(void)
{
  int a[200], b[200];
  int i = 0;
  while (scanf("%d %d", &a[i], &b[i]) != EOF){
    i++;
  }
  
  for (int j = 0; j < i; j++){
    int x = a[j] + b[j];
    int digit = 0;
    while (x >= pow(10, digit)){
      digit++;
    }
    printf("%d\n", digit);
  }
  return 0;
}


Measured memory_bytes: 2040
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <cassert>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	sort(A,A+n);
	ll ret=0;
	if(n%2==0)
	{
		int k=n/2;
		for(int i=0;i<k;i++) ret-=2LL*A[i];
		for(int i=k;i<2*k;i++) ret+=2LL*A[i];
		ret+=A[k-1];
		ret-=A[k];
	}
	if(n%2==1)
	{
		int k=n/2;//k>=1
		for(int i=0;i<k;i++) ret-=2LL*A[i];
		ret+=A[k];
		ret+=A[k+1];
		for(int i=k+2;i<2*k+1;i++) ret+=2LL*A[i];
		ll ret2=0;
		for(int i=0;i<k-1;i++) ret2-=2LL*A[i];
		ret2-=A[k-1];
		ret2-=A[k];
		for(int i=k+1;i<2*k+1;i++) ret2+=2LL*A[i];
		ret=max(ret,ret2);
	}
	printf("%lld\n",ret);
	return 0;
}


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

void insertionSort(int A[], int N){
    for(int i=1; i<N; i++){
        int v, j;
        v = A[i];
        j = i - 1;
        while((j >= 0)&&(A[j] > v)){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        
        for(int k=0; k<N; k++){
            if(k==N-1){
                cout << A[k];
            }else{
                cout << A[k] << " ";
            }
        }
        cout << endl;
        
         
    }
        
}


int main(){
    int N;
    cin >> N;
    int A[N];

    for(int i=0; i<N; i++){
        cin >> A[i];
        if(i!=N-1){
            cout << A[i]<<" ";
        }else{
            cout << A[i];
        }
    }
    cout << endl;

    insertionSort(A, N);
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> h[i];
        if (h[i] >= k){
            sum += 1;
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 640
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N;
vi A,B;
int ans;

signed main(){

    in(N);
    resz(N,A,B);
    in(A,B);

    rep(i,N){
        ans+=A[i]-B[i]>0?A[i]-B[i]:0;
    }

    out(ans);

    return 0;
}


Measured memory_bytes: 888
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main(void) {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}

Measured memory_bytes: 3616
k, n = map(int, input().split())
arr = list(map(int, input().split()))

prev = arr[0]
maxi = 0
sums = 0
for a in arr[1:]:
    sums += a - prev
    maxi = max(maxi, a - prev)
    prev = a

sums += k - (arr[-1] - arr[0])
maxi = max(maxi,  k - (arr[-1] - arr[0]))
print(sums - maxi)


Measured memory_bytes: 25836
#!/usr/bin/env python3
import sys
import math
def solve(N: int, K: int, A: "List[int]"):
    # 最小値は絶対1になる
    cur = K
    answer = 1 + math.ceil((N-K)/(K-1))
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


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

#define    ll    long long int

int main( )
{
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << setprecision(10) << (1.0 / 2.0) << '\n';
    }
    else {
        cout << setprecision(10) << ( (n / 2 + 1.0) / (n * 1.0) ) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAXN = 100000;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<bool> d(10, 0);
    rep(i, k) {
        int a;
        cin >> a;
        d[a] = 1;
    }

    int res = 0;

    REP(i, n, MAXN) {
        if (i < n) continue;
        string s = to_string(i);
        int t = s.length();
        bool ok = true;
        rep(j, t) {
            if (d[s[j]-'0']) ok = false;
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

#define MAX 500000
#define SENTINEL 2000000000


int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid   - left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for(int k=left; k<right; k++){
  cnt++;
    if ( L[i] <= R[j] )  {
    A[k] = L[i++];}
    else {
    A[k] = R[j++];
}
}
}

void mergeSort(int A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}


int main() {
  int A[MAX], n, i;
  cnt = 0;

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

  mergeSort(A, n, 0, n);

  for ( i = 0; i < n; i++ ){
    if ( i ) cout << " ";
    cout << A[i];
}
  cout << endl;

  cout << cnt << endl;

 return 0;
}
 


Measured memory_bytes: 6912
#import numpy as np
N,M,Q=map(int, input().split())
matrix=[]
for _ in range(Q):
    c=list(map(int, input().split()))
    matrix.append(c)
#matrix = np.array(matrix)
import itertools
ansscore = 0
combi = list(itertools.combinations_with_replacement(range(1,M+1),N))
for i in combi:
    i = list(i)
    i.sort()
    score=0
    for l in matrix:
        a=l[0]
        b=l[1]
        c=l[2]
        d=l[3]
        if i[b-1]-i[a-1]==c:
            score+=d
    ansscore = score if score>ansscore else ansscore

print(ansscore)

Measured memory_bytes: 21540
#include <iostream>
using namespace std;
int main(void){
    int table[200][200] = {{0}};
    int c,r;
    cin >> r >>c;
    for(int i = 0 ; i < r; i++ ) {
        for(int j = 0 ; j < c; j++ ){
        cin >> table[i][j];
        }
    }
    for(int i = 0 ; i < r+1; i++ ) {
        int sum = 0;
        for(int j = 0 ; j < c; j++ ){
            sum += table[i][j];
        }
        table[i][c] = sum;
    }
    //横の計算
    for(int i = 0 ; i < r+1; i++ ) {
        int sum = 0;
        for(int j = 0 ; j < c; j++ ){
            sum += table[i][j];
        }
        table[i][c] = sum;
    }
    //縦計算をする
    for(int j = 0 ; j < c+1; j++ ){
        int sum = 0;
        for(int i = 0 ; i < r; i++ ) {
            sum += table[i][j];
        }
        table[r][j] = sum;
    }
    
    for(int i = 0 ; i < r+1; i++ ) {
        for(int j = 0 ; j < c; j++ ){
            cout << table[i][j] << " ";
        }
            cout << table[i][c] << endl;
     }

 

}



Measured memory_bytes: 3248
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
        int a = sc.nextInt();
        char op = sc.next().charAt(0);
        int b = sc.nextInt();
        if(op == '+') System.out.println(a+b);
        if(op == '-') System.out.println(a-b);
        if(op == '*') System.out.println(a*b);
        if(op == '/') System.out.println(a/b);
        if(op == '?') break;
        }
    }
}


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


void solve(long long A, long long B){
    cout << A * B << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
int n;cin>>n;
vl vec(n);
map<ll,ll> mp;
rep(i,0,n){
	cin>>vec[i];
	ll val=vec[i];
	for(int j=2;j*j<=1000000;j++){
		if(val%j) continue;
		ll cnt=0;
		while(val%j==0){
			cnt++;
			val/=j;
		}
		if(mp.count(j)) mp[j]=max(mp[j],cnt);
		else mp[j]=cnt;
	}
	if(val!=1){
		if(!mp.count(val)) mp[val]=1;
	}
}
ll ans=0;
ll lc=1;
for(auto it:mp){
	ll v=it.f;
	ll ex=it.se;
	ll mul=v;
	while(ex){
		if(ex&1) lc=((lc%mod)*(mul%mod))%mod;
		mul=((mul%mod)*(mul%mod))%mod;
		ex>>=1;
	}
}
for(int i=0;i<n;i++){
	ans = (ans+(lc*mi(vec[i],mod)%mod))%mod;
	ans%=mod;
}
cout<<ans;

}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

char ca[200005];

int main(){
	int n;
	int i,j,k;
	LL a,b,c;
	LL s=0;
	bool flag=true,t=false;
	cin>>n;
	n*=2;
	cin>>ca;
	if(ca[0]=='W')flag=false;
	a=1;
	s=1;
	for(i=1;i<n;i++){
		if(!t){
			if(ca[i]==ca[i-1])s*=a--,t=true;
			else a++,t=false;
		}else{
			if(ca[i]!=ca[i-1])s*=a--,t=true;
			else a++,t=false;
		}
		if(a<0)flag=false;
		if(s>=MAX)s%=MAX;
	}
	if(a!=0)flag=false;
	if(!flag)s=0;
	for(a=1;a<=n/2;a++){
		s*=a;
		if(s>=MAX)s%=MAX;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 1000001;
constexpr ll MOD = 1e9+7;

ll fact[MN] = { 1 }, ifact[MN] = { 1 };

inline ll pw(ll base, ll exp) {
	ll res = 1;
	while (exp) {
		if (exp & 1) (res *= base) %= MOD;
		exp >>= 1, (base *= base) %= MOD;
	}
	return res;
}

inline ll inv(ll x) { return pw(x, MOD - 2); }

inline ll nCr(int n, int k) { return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD; }

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; cin >> N;

    for (int i = 0; i < N; ++i) fact[i+1] = (i+1ll)*fact[i]%MOD, ifact[i+1] = inv(fact[i+1]);
    
    ll sum = 0, ans = 0;
    for (int i = N/2; i < N; ++i) {
        ll tmp = nCr(i-1, N-i-1)*fact[i]%MOD*fact[N-i-1]%MOD;
        (ans += i*(tmp-sum+MOD)) %= MOD;
        sum = tmp;
    }
    cout << ans;

    /*for (int N = 2; N <= 10; ++N) {
        //int N = 7;
        vector<int> P(N-1);
        iota(begin(P), end(P), 0);
        vector<int> ans(N-1);
        do {
            vector<bool> A(N, 0);
            ll cnt = 0;
            for (int i = 0; i < N-1; ++i) {
                A[P[i]] = A[P[i]+1] = 1;
                if (count(begin(A), end(A), 1) == N) {
                    ++ans[i];
                    if (i == 3) {
                        for (int x : P) cout << x << ' ';
                        cout << '\n';
                    }
                    break;
                }
            }
        } while (next_permutation(begin(P), end(P)));
        for (int x : ans) cout << setw(6) << x << ' ';
        cout << '\n';
    }*/
}


Measured memory_bytes: 19240
#include<bits/stdc++.h>
#define NAME "D"
#define vt vector
#define ll long long
#define fi first
#define se second
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

void init()
{
    freopen(NAME".inp","r",stdin);
    freopen(NAME".out","w",stdout);
}

const int N=105;
int n,a[N],W;
int b[N];

void inp()
{
    cin>>n>>W;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
}

ll f[105][100005];

void out()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(j-a[i]>=0) f[i][j]=f[i-1][j-a[i]]+b[i];
            f[i][j]=max(f[i][j],f[i-1][j]);
        }
    }
    cout<<f[n][W];
}

int main()
{
   // init();
    inp();
    out();
}


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

int main()
{
	int N;
	string S;
	cin >> N >> S;
	if (N % 2 == 1)
	{
		cout << "No" << endl;
	}
	else
	{
		string S1 = S.substr(0,N/2), S2 = S.substr(N/2,N/2);
		if (S1 == S2)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++) {
        int t; cin >> t;
        sum += t;
    }
    cout << max(-1, n - sum);
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int i;
	int sum;
	char* px;
	char x[1001];
	
	px = x;
	
	for(i = 0; i < 1001; i++)
	{
		x[i] = '0';
	}
	
	while(1)
	{
		sum = 0;
		for(i = 0; i < 1001; i++)
		{
			x[i] = '0';
		}
		while(1)
		{
			px = x;
			scanf("%s", x);
			//printf("%s\n", x);
			while(*px != '\0')
			{
				sum += (*px - '0');
				px++;
			}
			px = x;
			break;

		}
		
		if(x[0] != '0')
		{
			printf("%d\n", sum);
		}
		else
		{
			//printf("break\n");
			break;
		}
	}
	return 0;
}

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

main(){
  ll n,i,ans=0;
  cin >> n;
  vector<ll> b(n-1); 
  for(i=0;i<n-1;i++) cin >> b[i];
  
  ans=b[0];
  for(i=0;i<n-2;i++){
    //cout << min(b[i],b[i+1]) << endl;
    ans+=min(b[i],b[i+1]);
  }
  ans+=b.back();
  
  cout << ans << endl;
}  

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

void solve(){
  string s;
  cin>>s;
  int n=s.size();
  vector<int> v[10010];
  
  int level=0;
  int num=0;
  for(int i=0;i<n;i++){
    if(s[i]=='[') level++;
    else if(s[i]>='0'&&s[i]<='9'){
      num=num*10+(s[i]-'0');
    }else{
      if(num>0){
        level--;
        v[level].push_back((num+1)/2);
        num=0;
      }else{
        sort(v[level].begin(),v[level].end());
        int m=v[level].size();
        int res=0;
        for(int j=0;j<=m/2;j++){
          res+=v[level][j];
        }
        
        v[level].clear();
        level--;
        v[level].push_back(res);
      }
    }
  }
  
  cout<<v[0].front()<<endl;
}

int main(){
  int T;
  cin>>T;
  for(int i=0;i<T;i++) solve();

  return 0;
}



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

int main() {
  int H, W, cnt = 0;
  cin >> H >> W;
  char C;
  while (cin >> C) if (C == '#') cnt++;
  cout << ((cnt == H + W - 1) ? "Possible" : "Impossible") << "\n";
}

Measured memory_bytes: 3548
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
using namespace std;

const int INF = 1<<30;
#define rep(i, n) for(int i = 0; i < (n); i++)


int N;
vector<int> w;
int can[310][310];
int dp[310];
bool saiki(int l, int n){
  if(can[l][n] != -1) return can[l][n];
  if(n % 2) return can[l][n] = 0;
  if(n == 0) return can[l][n] = 1;

  bool res = 0;
  for(int i = 1; i <= n-1; i++) if(saiki(l, i) && saiki(l+i, n-i)) res = 1;
  if(saiki(l+1, n-2) && abs(w[l] - w[l+n-1]) <= 1) res = 1;
  return can[l][n] = res;
}


void solve(){
  rep(i, 310)rep(j, 310) can[i][j] = -1;
  rep(i, N)rep(j, N+1){
    if(i+j<=N) saiki(i, j);
  }
  rep(i, 310) dp[i] = -INF;
  dp[0] = 0;
  rep(i, N){
    dp[i+1] = max(dp[i+1], dp[i]);
    for(int j = 1; j <= N; j++){
      if(i+j<=N && can[i][j]) dp[i+j] = max(dp[i+j], dp[i] + j);
    }
  }
  cout << dp[N] << endl;
}


int main(){
  while(true){
    cin >> N;
    if(N == 0) return 0;
    w.resize(N);
    rep(i, N) cin >> w[i];
    solve();
  }

}



Measured memory_bytes: 3464
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int f[50];
    f[0]=f[1]=1;
    for(int i = 2;i <= n;i++)
    f[i]=f[i - 1] + f[i - 2];
    cout<<f[n]<<endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int X, Y;
  cin >> X >> Y;
  cout << X + Y / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	static int[]z;
    public static int a,b,n,w,t;
	private static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        w=sc.nextInt();
        n=sc.nextInt();
        z = new int[w];
        mmm();
        for(int i=0;i<w;i++)
            System.out.println(z[i]);
            }
    static void mmm(){
    	   for(int i=0;i<w;i++){
               z[i] = i+ 1;
           }
    	for(int i= 0; i< n; i++) {
            String mm= sc.next();
            String[] a1 = mm.split(",");
            a = Integer.parseInt(a1[0]) -1;
            b = Integer.parseInt(a1[1]) -1;
            t=z[a];
            z[a]=z[b];
            z[b]=t;
        }
    	
    	
    }
    }

Measured memory_bytes: 17192
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(int, "a", int, "b");

void main() {
    int N;
    scan(N);
    auto s = readln.chomp.map!(ch => ch - '0').array;

    auto dp = new bool[][](1000, 4);
    dp[0][0] = 1;

    foreach (i ; 0 .. N) {
        foreach_reverse (k ; 0 .. 4) {
            foreach (j ; 0 .. 1000) {
                if (dp[j][k] && k < 3) {
                    dp[10*j + s[i]][k + 1] |= dp[j][k];
                }
            }
        }
    }

    int ans;

    foreach (j ; 0 .. 1000) {
        ans += dp[j][3];
    }

    writeln(ans);
}







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

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

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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 508
n=int(input())
L=[]
for _ in range(n-1):
    L.append(tuple(map(int,input().split())))
ans=[]
for i in range(n-1):
    c,t,f=L[i]
    t += c
    for j in range(i+1,n-1):
        cn,sn,fn=L[j]
        if t>sn:
            t=-int(-t//fn)*fn
        else:
            t=sn
        t += cn
    ans.append(t)
ans.append(0)
for i in ans:
    print(i)

Measured memory_bytes: 3188
<?php
$nums = explode(" ", trim(fgets(STDIN)));
$n = trim(fgets(STDIN));
$a = $nums[0];
$b = $nums[1];
$c = $nums[2];
$j = 0;
for ($i = $n; $i > 0; $i--) {
  if ($c <= 2*$b) {
    $c *= 2;
  } else {
    $b *= 2;
  }
}
if ($a < $b && $b < $c) {
    echo 'Yes';
} else {
    echo 'No';
}

Measured memory_bytes: 16072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] strArray = input.split(" ");

        int a = Integer.parseInt(strArray[0]);
        int b = Integer.parseInt(strArray[1]);
        int c = Integer.parseInt(strArray[2]);

        int count = 0;

        for(int i = a; i <= b; i++ ){
            if(c % i == 0){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/
const int MAXN=1000+10;
ll a[MAXN],b[MAXN],c[MAXN];
bool cmp(ll x,ll y){
    return x>y;
}
void go(){
    int x,y,z,t;
    R(x,y,z,t);
    rep(i,1,x){
        R(a[i]);
    }
    rep(i,1,y){
        R(b[i]);
    }
    rep(i,1,z){
        R(c[i]);
    }
    sort(a+1,a+1+x,cmp);
    sort(b+1,b+1+y,cmp);
    sort(c+1,c+1+z,cmp);
    vector<ll> ans;
    rep(i,1,x){
        rep(j,1,y){
            rep(k,1,z){
                if(1LL*i*j*k<=t){
                   ans.pb(1LL*a[i]+b[j]+c[k]);
                   //W(i,j,k);
                }else{
                    break;
                }
            }
        }
    }
    sort(ans.rbegin(),ans.rend());
    rep(i,0,t-1){
        W(ans[i]);
    }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}
const int N = 2e6 + 5;
ll fact[N], inv[N];

void pre()
{
	fact[0] = 1; inv[0] = 1;
	for(ll i=1;i<N;i++)
	{
		fact[i] = (fact[i-1]*i)%M;
		inv[i] = powerm(fact[i],M-2);
	}
}

ll C(ll n,ll r)
{
	ll ans = (fact[n]*inv[r])%M;
	ans = (ans*inv[n-r])%M;
	return ans;
}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	ll z = 26;
	ll k; cin>>k; 
	string s; cin>>s;
	ll n = k + s.length();
	pre();
	ll ans = powerm(z,n);
	for(ll i=0;i<s.length();i++)
	{
		ll gg = (C(n,i)*powerm(z-1,n-i))%M;
		ans = (( ans - gg )%M + M)%M;
	}
	cout<<ans;

	return 0;
}


Measured memory_bytes: 35624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) cout << k;
    else {
        k -= a;
        if (k <= b) cout << a;
        else {
            k -= b;
            cout << a - k;
        }
    }
}


Measured memory_bytes: 3620
def resolve():
    S = int(input())

    x1, y1 = 0, 0
    x2, y2 = 1, 10 ** 9

    x3 = (S + y2 - 1) // y2
    y3 = x3 * y2 - S

    print(x1, y1, x2, y2, x3, y3)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 8984
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.WriteLine(Math.Max(-1, N - A.Sum()));
        }
    }
}


Measured memory_bytes: 28620
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n, m, ans;
ll pr[111111];
ll a[111111];

int find(int u)
{
	if(pr[u]==u) return u;
	else return pr[u]=find(pr[u]);
}

void unite(int u, int v)
{
	if(find(u)==find(v)) return;
	else pr[find(u)]=v;
}

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m; int i, u, v;
	for(i=1 ; i<=n ; i++) pr[i]=i;
	for(i=1 ; i<=n ; i++) cin>>a[i];
	for(i=1 ; i<=m ; i++)
	{
		cin>>u>>v;
		unite(a[u],a[v]);
	}
	for(i=1 ; i<=n ; i++) if(find(i)==find(a[i])) ans++;
	cout<<ans; return 0;
}


// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 1792
A = []
for i in range(3):
    array = list(map(int, input().strip().split()))
    A.append(array)
N=int(input())
b=[int(input()) for i in range(N)]

for k in b:
	for i in range(len(A)):
		for j in range(len(A[i])):
			if A[i][j] == k:
				A[i][j]=0

if A[0]==[0,0,0] or A[1]==[0,0,0] or A[2]==[0,0,0] or A[0][0]==A[1][0]==A[2][0]==0 or A[0][1]==A[1][1]==A[2][1]==0 or A[0][2]==A[1][2]==A[2][2]==0 or A[0][0]==A[1][1]==A[2][2]==0 or A[0][2]==A[1][1]==A[2][0]==0:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
n = int(input())

ans = [0, 0]

for i in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        ans[0] += 3
    elif cards[0] < cards[1]:
        ans[1] += 3
    else:
        ans[0] += 1
        ans[1] += 1

print(*ans)



Measured memory_bytes: 5600
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

def main():
    S=input()

    A=[0 for _ in range(len(S)-1)]
    mode="L"
    s=0
    b=0
    e=0
    l=0
    for i in range(len(S)):
        c=S[i]
        if mode=="L" and c==mode:
            mode="R"
            b=i-1
        elif mode=="R" and c==mode:
            mode="L"
            e=i-1

            l=e-s+1
            if l//2==0:
                A[b]=A[b+1]=l/2
            else:
                A[b]=(b-s)//2+(e-b)//2+1
                A[b+1]=l-A[b]
            
            s=i
        elif c=="\n":
            e=i-1

            l=e-s+1
            if l//2==0:
                A[b]=A[b+1]=l/2
            else:
                A[b]=(b-s)//2+(e-b)//2+1
                A[b+1]=l-A[b]

    print(*A)

main()

Measured memory_bytes: 77708
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n, int r) {
vvl v(n + 1,vl(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}


int main(){
	int a,b;
	cin>>a>>b;
	string s,t;
	rep(i,0,a)s+=b+'0';
	rep(i,0,b)t+=a+'0';
	if(s.size()<t.size())print(t);
	else print(min(s,t));


}

Measured memory_bytes: 256
#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#include<cstring>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int a[maxn],b[maxn];
int main()
{
    int n ,x;
      ll sum=0,e=0;
     cin>>n;
      rep(i,0,n)
      {
          scanf("%d",&x);
          sum+=x;
          e+=x*x;
      }

       ll ans;
     if(sum%n==0)
       ans=e-sum*sum/n;
     else
     {
         //x=ceil((double)sum/n);
          int bei=sum/n;
         if(sum>=0)
         x=n*(bei+1)-sum>sum-n*bei?floor((double)sum/n):ceil((double)sum/n);
         else
            x=n*(bei+1)-sum>sum-n*bei?ceil((double)sum/n):floor((double)sum/n);


         ans=n*x*x-2*x*sum+e;
     }
        cout<<ans<<endl;
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << "ABC" + to_string(n) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int number_of_500yen, x;

    cin >> number_of_500yen >> x;
    if(500*number_of_500yen >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

template<typename T>
struct Compress {
private:
    vector<T> value;
    
public:
    Compress() {}
    Compress(const vector<T> &v, bool distinct = true) {
        int n = v.size();
        value.resize(n);
        value = v;
        sort(value.begin(), value.end());
        if (distinct) value.erase(unique(value.begin(), value.end()), value.end());
    }
    
    int size() {
        return value.size();
    }
    
    int val(int idx) {
        return value[idx];
    }
    
    int get(int v) {
        return lower_bound(value.begin(), value.end(), v) - value.begin();
    }
};

template<class T>
struct SegmentTree {
private:
    int n;
    vector<T> node;
    T def;
    function<T(T,T)> lop;
    function<T(T,T)> out;
    
public:
    SegmentTree() {}
    SegmentTree(const vector<T> &v, T _def, function<T(T,T)> _lop, function<T(T,T)> _out) {
        int vl = (int)v.size();
        n = 1;
        while(n < vl) n *= 2;
        def = _def; lop = _lop; out = _out;
        node = vector<T>(2 * n - 1, def);
        for(int i = 0; i < vl; i++) node[i + n - 1] = v[i];
        for(int i = n - 2; i >= 0; i--) node[i] = out(node[i * 2 + 1], node[i * 2 + 2]);
    }
    
    void update(int idx, T val) {
        idx += (n - 1);
        node[idx] = lop(node[idx], val);
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = out(node[idx * 2 + 1], node[idx * 2 + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if ((r <= a) || (b <= l)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        return out(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> h(n), a(n);
    rep(i, n) cin >> h[i];
    rep(i, n) cin >> a[i];
    Compress<ll> ch(h);
    auto lop = [](ll a, ll b){ return b; };
    auto out = [](ll a, ll b){ return max(a, b); };
    SegmentTree<ll> st(vector<ll>(ch.size(), 0), 0, lop, out);
    rep(i, n) {
        ll idx = ch.get(h[i]);
        ll val = st.query(0, idx);
        st.update(idx, val + a[i]);
    }
    cout << st.query(0, ch.size()) << endl;
    return 0;
}


Measured memory_bytes: 13504
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  int d = x / y;
  int r = x % y;
  double f = (double)x / y;
  cout << d << " " << r <<  " ";
  printf("%.5f\n",f);
  return 0;
}

Measured memory_bytes: 1240
string = input()
n = int(input())
for _ in range(n):
    query = input().split()
    if query[0] == 'replace':
        op, a, b, p = query
        a, b = int(a), int(b)
        string = string[:a] + p + string[b + 1:]
    elif query[0] == 'reverse':
        op, a, b = query
        a, b = int(a), int(b)
        string = string[:a] + ''.join(reversed(string[a:b + 1])) + string[b + 1:]
    elif query[0] == 'print':
        op, a, b = query
        a, b = int(a), int(b)
        print(string[a: b + 1])

Measured memory_bytes: 6724
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int main() {
	ll N;
	cin >> N;
	if(N%2==0) cout << N << endl;
  	else cout << N*2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,a,b,num=0,ans=0;cin>>n>>m;
  map<ll,ll> mp;
  rep(i,n) {cin>>a>>b;mp[a]+=b;}
  bool is_continue=true;
  for(auto itr:mp) {
    rep(i,itr.second) {
      ans+=itr.first;
      num++;
      if(num==m) {is_continue=false;break;}
    }
    if(!is_continue) break;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 6528
import math

def primes(x):
    if x < 2: return []
 
    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない
 
    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
 
    return [prime for prime in primes if prime != 0]
  
n = int(input())
prime_nums = primes(55555)
ans = []
for p in prime_nums:
  if str(p)[-1] == '1':
    ans.append(p)
  if len(ans) == n:
    for a in ans:
      print(a, end = ' ')
    quit()


Measured memory_bytes: 5272