akhauriyash/Code-Regression huggingface dataset:
from itertools import accumulate
n, k = map(int, input().split())
a = list(map(int, input().split()))


left_sum = [0 for i in range(n+1)]
sum_value = 0
for i in range(n):
    if a[i] > 0:
        sum_value += a[i]
    left_sum[i+1] = sum_value


c = list(accumulate(a))
range_sum = [0 for i in range(n-k+1)]
range_sum[0] = max(c[k-1], 0)
for i in range(1, n-k+1):
    range_sum[i] = max(c[i+k-1] - c[i-1], 0)


a.reverse()


right_sum = [0 for i in range(n+1)]
sum_value = 0
for i in range(n):
    if a[i] > 0:
        sum_value += a[i]
    right_sum[i+1] = sum_value


ans = 0
for i in range(n-k+1):
    ans = max(ans, left_sum[i] + range_sum[i] + right_sum[n-k-i])
print(ans)

Measured memory_bytes: 33608
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String S = scan.next();
	int count = 0;
	for (int i = 0; i < S.length()-1; i++) {
	    if(S.charAt(i) != S.charAt(i+1)) count++;
	}

	System.out.println(count);
	scan.close();
    }
}


Measured memory_bytes: 24920
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 110
#define INF 1e9
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> State;
  
struct Edge{
    int to,cost;
    Edge(){}
    Edge(int to,int cost) : to(to),cost(cost) {}
};
  
int N,M,L,K,A,H;
bool l[MAX];
vector<Edge> G[MAX];
  
void init(){
    for(int i = 0 ; i < MAX ; i++){
	l[i] = false;
	G[i].clear();
    }
}
  
int dijkstra(){
    priority_queue<State,vector<State>,greater<State> > Q;
    Q.push(State(pii(0,A),M));
   
    int Time[MAX][MAX];
    fill(Time[0],Time[0]+MAX*MAX,INF);
    Time[A][M] = 0;
  
    while(!Q.empty()){
	State s = Q.top(); Q.pop();
	int v = s.F.S, m = s.S;
	if(Time[v][m] < s.F.F) continue;
 
	if(v == H){
	    return Time[H][m];
	}
 
	if(l[v]){
	    for(int i = 1 ; i <= M-m ; i++){
		if(Time[v][m] + i < Time[v][m+i]){
		    Time[v][m+i] = Time[v][m] + i;
		    Q.push(State(pii(Time[v][m+i],v),m+i));
		}
	    }
	}
  
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    Edge e = G[v][i];
	    if(m - e.cost >= 0){
		if(Time[v][m] + e.cost < Time[e.to][m-e.cost]){
		    Time[e.to][m-e.cost] = Time[v][m] + e.cost;
		    Q.push(State(pii(Time[e.to][m-e.cost],e.to),m-e.cost));
		}
	    }
	}
    }
    return INF;
}
  
int main(){
    int a,b,c;
    while(cin >> N >> M >> L >> K >> A >> H, N){
	init();
	for(int i = 0 ; i < L ; i++){
	    cin >> a;
	    l[a] = true;
	}
	for(int i = 0 ; i < K ; i++){
	    cin >> a >> b >> c;
	    G[a].push_back(Edge(b,c));
	    G[b].push_back(Edge(a,c));
	}
	int res = dijkstra();
	if(res == INF){
	    cout << "Help!" << endl;
	}else{
	    cout << res << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3184
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,k;
    ll ans=0;
    cin>>n>>k;
    ll a[200010];
    map<ll,ll> mp;
    vll v;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(auto i:mp){
        v.pb(i.sc);
    }
    sort(all(v));
    ll m=v.size();
    if(v.size()>k){
        rep(i,m-k){
            ans+=v[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16500
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let abc = readn::<usize>(" ");
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];

    if a + b == c || b + c == a || c + a == b {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		sc.nextLine();
		String st=sc.nextLine();
		int x=0;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(st.charAt(i)=='I') x++;
			else x--;
			ans=Math.max(ans, x);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35700
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

//qsort用(昇順，降順)
int cmp_asc( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}
int cmp_desc( const void *p, const void *q ) {
    return *(int*)q - *(int*)p;
}

int main(void){
	int n;
	scanf("%d",&n);
	ll a[n];
	rep(i,n){
		scanf("%lld",&a[i]);
	}
	ll ax[n],ay[n];
	qsort(a,n,sizeof(ll),cmp_desc);
	int count=0,i=1,io=1,ie=1;
	ax[n/2]=a[0];
	while(1){
		if(i%2!=0){
			ax[n/2-i]=a[n-(2*io-1)];
			ax[n/2+i]=a[n-(2*io)];
			if((n/2-i)==0) break;
			i++;
			io++;
		}
		else{
			ax[n/2-i]=a[2*ie-1];
			ax[n/2+i]=a[2*ie];
			if((n/2-i)==0) break;
			i++;
			ie++;
		}
	}
	//rep(i,n){printf("%lld, ",ax[i]);}
	//printf("\n");


	qsort(a,n,sizeof(ll),cmp_asc);
	count=0;
	i=1;
	io=1;
	ie=1;
	ay[n/2]=a[0];
	while(1){
		if(i%2!=0){
			ay[n/2-i]=a[n-(2*io-1)];
			ay[n/2+i]=a[n-(2*io)];
			if((n/2-i)==0) break;
			i++;
			io++;
		}
		else{
			ay[n/2-i]=a[2*ie-1];
			ay[n/2+i]=a[2*ie];
			if((n/2-i)==0) break;
			i++;
			ie++;
		}
	}
	//rep(i,n){printf("%lld, ",ay[i]);}
	//printf("\n");


	ll ansx=0,ansy=0;
	rep(i,n-1){
		if(ax[i]-ax[i+1]<0) ansx+=(ax[i]-ax[i+1])*-1;
		else ansx+=(ax[i]-ax[i+1]);
		if(ay[i]-ay[i+1]<0) ansy+=(ay[i]-ay[i+1])*-1;
		else ansy+=(ay[i]-ay[i+1]);
	}
	//printf("%lld %lld",ansx,ansy);
	if(ansx>=ansy) printf("%lld",ansx);
	else printf("%lld",ansy );

	return 0;
}

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

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

	string s, t;
	cin >> s >> t;

	string ret;
	for (int i = 0; i < n; ++i) {
		ret += s[i];
		ret += t[i];
	}

	cout << ret << endl;

	return 0;

}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val u = List.fill(n)(BigDecimal(sc.nextInt)).sorted
    println(calc(u)(0))

    def calc(us: List[BigDecimal]): List[BigDecimal] = us.length == 1 match {
      case true => us
      case _ => {
        calc(us.take(2).sum / 2 :: us.drop(2))
      }
    }
  }
}

Measured memory_bytes: 25928
using System;

class Program {
    static void Main(string[] args) {

        int n = int.Parse(Console.ReadLine());

        float kisu = 0;
        for(int a = 1; a <= n; a++) {
            if (a % 2 == 1) kisu++;
        }
        Console.WriteLine(kisu / n);
    }
}



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

signed main(){
    int n;cin>>n;
    vector<int> v(5,0);
    for(auto&& x:v)cin>>x;
    int a=v[0];
    for(auto&& x:v)a=min(a,x);
    //cout<<a;
    cout<<5+(n-1)/a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	ll n;
	cin >> n;
	string ans;
	while (n > 0) {
		n--;
		ans += (char) ('a' + n % 26);
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

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

int main()
{
    int r, c, i, j;

    int A[101][101];
    cin >> r >> c;

    for(i = 0; i < r; i++) A[i][c] = 0;
    for(j = 0; j < c; j++) A[r][j] = 0;
    A[r][c] = 0;

    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            cin >> A[i][j];
            A[i][c] = A[i][c] + A[i][j];
            A[r][j] = A[r][j] + A[i][j];
            A[r][c] = A[r][c] + A[i][j];
        }
    }

    for(i = 0; i <= r; i++){
        for(j = 0; j < c; j++){
            cout << A[i][j] << " ";
        }
        cout << A[i][c] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1200
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    from math import ceil
    if (B-A)%2 == 0:
        print((B-A)//2)
        
    else:
        print(min(A-1, N-B)+1+(B-A-1)//2)


    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
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, tmp = 0, ans = 0;
  ll inv = pow(10, 9) + 7;
  cin >> N;
  vector<ll> As(N);
  vector<ll> bits(60, 0);

  for (ll i = 0; i < N; i++) {
    cin >> As.at(i);
    bitset<60> tmp(As.at(i));
    for (int j = 0; j < 60; j++) {
      if (tmp.test(j)) bits.at(j)++;
    }
  }

  for (ll i = 0; i < 60; i++) {
    ll tmp_a = pow(2, i);
    tmp_a %= inv;
    ll tmp_b = bits.at(i) * (N - bits.at(i)) % inv;
    tmp = tmp_a * tmp_b % inv;
    ans = (ans + tmp) % inv;
  }
  
  cout << ans << endl;
  
}

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

int main() {
  string s;
  int n;
  cin >> n;
  cin >> s;
  string check="ABC";
  int count=0;
  for(int i=0;i<s.size()-2;i++) {
    if(s.substr(i,3)==check) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define OFFSET 200001
using namespace std;
int main()
{
    string s;
    cin>>s;
    char ans[500111];
    for(int i=0;i<s.size();i++)
    {
        ans[i+OFFSET] = s[i];
    }
    int q;
    cin>>q;
    bool rev = false;
    int fr = OFFSET-1, bk=s.size()+OFFSET;
    for(int i=0;i<q;i++)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            rev = 1-rev;
        }
        else
        {
            int f;
            cin>>f;
            char c;
            cin>>c;
            if(rev)
            {
                f = 3-f;
            }
            if(f==1)
            {
                ans[fr]=c;
                fr--;
            }
            else
            {
                ans[bk] = c;
                bk++;
            }
        }
    }
    if(rev)
    {
        for(int i=bk-1;i>=fr+1;i--)
        {
            cout<<ans[i];
        }
        cout<<"\n";
    }
    else
    {
        for(int i=fr+1;i<=bk-1;i++)
        {
            cout<<ans[i];
        }
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1024
function Main(input){
    input=input.split("\n");  //ここまで必須
    var line=input[0].split(" ");
    var result="";
    for (i=0;i<5;i++){
        if (line[i]==0){result=i}
    }
    console.log(parseInt(result)+1)
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 29564
import java.io.*;
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args){
    
    try {
      
      //標準入力受け取り
      Scanner scan = new Scanner(System.in);
      int page = Integer.parseInt(scan.next());
      
      //用紙算出
      int paper = page/2;
      
      if (page % 2 != 0) {
        paper = page/2 + 1;
      } 
      
      System.out.println(paper);
      
    } catch (Exception e) {
      
      System.out.println("error");

    }
  }
}


Measured memory_bytes: 21716
import sys

s = input()
i = 0
while i < 100 and i < len(s):
    if s[i] != "R" and s[i] != "U" and s[i] != "D":
        print("No")
        sys.exit()
    i += 2
i = 1
while i < 100 and i < len(s):
    if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
        print("No")
        sys.exit()
    i += 2

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int INF = (int)1e9;

#define maxn 100010
#define mod (ll) (1e9 + 9)

ll inv(ll a, ll b){
    return 1 < a ? b - inv(b % a, a) * b / a : 1;
}

int main() {
#ifdef BZ
    freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(6);

    int n;
    cin >> n;

    vector <vi> a (n, vi (3));

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

    vector <vi> dp (n + 1, vi (3, -INF));

    for (int i = 0; i < 3; i++) {
        dp[0][i] = 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp[i + 1][k] = max (dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    int res = 0;
    for (int i = 0; i < 3; i++) {
        res = max (res, dp[n][i]);
    }

    cout << res << "\n";

}

Measured memory_bytes: 11264
import java.awt.print.Printable;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
import java.lang.Math;
  
public class Main{      
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        while(true){
        int n = sc.nextInt();
        if(n==0)
            break;
        int scores[]=new int[n];
        int sum=0;
        double ave=0.0;
        double div=0.0;
        for(int i=0;i<n;i++){
            scores[i]=sc.nextInt();
            sum+=scores[i];
        }
        ave = (double)sum/(double)n;

        for(int i=0;i<n;i++){
            div += (Math.pow(scores[i]-ave,2))/n;
        }

        System.out.println(Math.pow(div, 0.5));
     }
        sc.close();
        
    }   
}


Measured memory_bytes: 31152
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

int N;
int s[301];
double e[301][301][301];

double E(int a, int b, int c) {
  if (a == 0 && b == 0 && c == 0) return 0;
  if (e[a][b][c] > -0.5) return e[a][b][c];
  const double p_stay = ((double)(N - (a + b + c))) / N;
  double result = 1.0;
  if (a != 0) result += ((double)a / N)*E(a - 1, b, c);
  if (b != 0) result += ((double)b / N)*E(a + 1, b - 1, c);
  if (c != 0) result += ((double)c / N)*E(a, b + 1, c - 1);
  result /= (1.0 - p_stay);
  return e[a][b][c] = result;
}

int main() {
  for (int i = 0; i < 301; ++i)
    for (int j = 0; j < 301; ++j)
      for (int k = 0; k < 301; ++k)
        e[i][j][k] = -1;
  std::cin >> N;
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < N; ++i) {
    std::cin >> s[i];
    if (s[i] == 1) ++A;
    if (s[i] == 2) ++B;
    if (s[i] == 3) ++C;
  }
  std::cout << std::fixed << std::setprecision(12);
  std::cout << E(A, B, C) << '\n';
  return 0;
}


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

int main(){
    ll n,m,c;
    cin>>n>>m>>c;
    vector<ll> b;
    ll tmp;
    rep(i,m){
        cin>>tmp;
        b.push_back(tmp);
    }
    ll ans=0;
    ll a;
    rep(i,n){
        ll sum=0;
        rep(j,m){
            cin>>a;
            sum+=a*b[j];
        }
        if((sum+c)>0)ans++;
    }

    cout<<ans<<endl;


}



Measured memory_bytes: 3580
#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>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//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);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int a, b;
    cin >> a >> b;

    int ans = (a + b) / 2 + (a + b) % 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
  [_,c,k] <- map read . words <$> getLine
  ts <- sort . map read . words <$> getContents
  print (abus 0 c k ts)

abus acc _ _ [] = acc
abus acc c k tts@(t:ts)
  | x <= c = abus (acc+1) c k (drop x tts)
  | otherwise = abus (acc+1) c k (drop c tts)
  where
    x = length $ takeWhile (<= t+k) ((t+k):ts)

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

int main(){
  int n;
  int count = 0;
  scanf("%d\n", &n);

  int nums[n];
  for(int i=0;i<n;i++){
    scanf("%d", &nums[i]);
  }

  int flag = 1;
  while(flag){
    flag = 0;
    for(int i=n-1; i > -1; i--){
      if(nums[i] < nums[i-1]){
        count ++;
        int tmp = nums[i-1];
        nums[i-1] = nums[i];
        nums[i] = tmp;
        flag = 1;
      }
    }
  }

  for(int i=0; i<n-1;i++){
    printf("%d ",nums[i]);
  }
  printf("%d\n",nums[n-1]);
  printf("%d\n", count);
}



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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s.back() == '3') cout << "bon\n";
    else if(s.back() == '0' || s.back() == '1' || s.back() == '6' || s.back() == '8') cout << "pon\n";
    else cout << "hon\n";

    return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using myui = uint64_t;
using myint = int64_t;

template<typename T>
T diff(const T& a, const T& b) {
    return a > b ? a - b : b - a;
}

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

    {
        myint n;
        cin >> n;
        vector<myint> vs;
        vector<myint> cs;
        for (myint i = 0; i < n; i++) {
            myint v;
            cin >> v;
            vs.push_back(v);
        }
        for (myint i = 0; i < n; i++) {
            myint c;
            cin >> c;
            cs.push_back(c);
        }

        vector<myint> diffs;
        for (myint i = 0; i < n; i++) {
            diffs.push_back(vs[i]-cs[i]);
        }

        sort(diffs.begin(), diffs.end(), greater<myint>());

        myui ret = 0;
        myui i = 0;

        while(diffs[i] > 0 && i < n) {ret += diffs[i]; i++;}

        cout << ret << endl;
    }

    return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main(){

    long long N;
    cin >> N;
    auto res = prime_factorize(N);
    long long sum = 0;
    
    //for (auto p : res)cout << p.first <<" "<<p.second << endl;
    for (auto p : res) {
        int j = 1;
        for (int i = 0; i < p.second;){
            if(i + j <= p.second){
                //cout << sum <<" "<< i <<" "<< j <<endl;
                sum++;
                i += j;
                j++;
            }else break;
        }
    }
    cout << sum <<endl;


}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String[] line = br.readLine().split(" ");
    int[] relation = new int[n];
    int[] answer = new int[n];
    for(int i = 0; i < line.length; i++){
      int boss = Integer.parseInt(line[i]) - 1;
      relation[i + 1] = boss;
    }
    for(int i = n - 1; i > 0; i--){
      answer[relation[i]]++;
    }
    for(int a : answer){
      System.out.println(a);
    }
  }
}

Measured memory_bytes: 64544
n=int(input())
s=input()
list(s)
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for j in range(n):
    m=min(j,n-j-1)
    if m==0:
        continue
    for ik in range(m):
        ii=s[j-ik-1]
        jj=s[j]
        kk=s[j+ik+1]
        if (ii!=jj)&(jj!=kk)&(kk!=ii):ans-=1
print(ans)

Measured memory_bytes: 9052
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    odd = 0
    for i in range(n):
        if a[i] % 2:
            odd += 1
    
    if odd % 2:
        print("NO")
    else:
        print("YES")
        
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 14104
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		double nn = n/1.08;
      	int x = (int)nn;
      	int check = 0;
      	double check0 = x*1.08;
      	int check1 = (int)check0;
      	double check2 = (x+1)*1.08;
      	int check3 = (int)check2;
      	if(check1==n){
          System.out.println(x);
        }else if(check3==n){
          System.out.println(x+1);
        }else{
          System.out.println(":(");
        }
	}
}


Measured memory_bytes: 35632
import scala.collection.mutable._
import io.StdIn.readLine

object Main extends App {
  val map = new HashMap[String,Int]
  val s = readLine.split(" ")
  s.foreach(e => {
    if(!map.contains(e)) map.put(e,1)
    else map.put(e,map(e)+1)
  })
  val maxF = map.maxBy(_._2)._1
  val l = s.map(_.length).max
  val maxL = s.find(_.length == l).get

  println(maxF + " " + maxL)
}


Measured memory_bytes: 43772
N=int(input())
a=[0]+list(map(int,input().split()))+[0]
sm = 0
for i in range(1,N+2):
    sm += abs(a[i-1]-a[i])
for i in range(1,N+1):
    print(sm-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]))

Measured memory_bytes: 20620
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
int main() {
	string n;
	cin >> n;
	if (n[5] == '0' && n[6] == '4') {
		cout << "Heisei" << endl;
	}
	else {
		if (n[5] == '0' && n[6] == '3') {
			cout << "Heisei" << endl;
		}
		else {
			if (n[5] == '0' && n[6] == '2') {
				cout << "Heisei" << endl;
			}
			else {
				if (n[5] == '0' && n[6] == '1') {
					cout << "Heisei" << endl;
				}
				else {
					cout << "TBD" << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<string>
using namespace std;
int n[1000000],n1,n2;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		n[i]=int(s[i])-int('0');
		if(n[i]==1)
		{
			n1++;
		}
		else
		{
			n2++;
		}
	}
	cout<<2*min(n1,n2);
	return 0;
}

Measured memory_bytes: 896
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, K = inpl()
X = inpl()

A = [0]
B = []
for i in range(N):
    if X[i] >= 0:
        A.append(X[i])
    else:
        B.append(-X[i])
B.append(0)
B = B[::-1]

# for i in range(1, len(A)):
#     A[i] += A[i-1]
#
# for i in range(1,len(B)):
#     B[i] += B[i-1]


ans = INF
for i in range(K+1):
    cost = INF
    j = K - i
    if i > len(A) - 1 or j > len(B) - 1:
        continue

    if i == K:
        cost = A[i]

    elif j == K:
        cost = B[j]

    else:
        cost_rl = 2 * A[i] + B[j]
        cost_lr = A[i] + 2 * B[j]
        cost = min(cost_rl, cost_lr)

    ans = min(ans, cost)

print(ans)

Measured memory_bytes: 14660
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
/*void solve()
{
    int n,x,y,i,b,c;cin>>n;
    int cnt;
    foe(i,1,n)
    {
        cnt=0;
        for(x=1;x<i*i;x++)
        {
            for(y=1;y<i*i;y++)
            {
                b=x+y;c=(x*x+y*y+x*y)-i;
                int d=b*b-4*c;
                if(d<=0)break;
                int sd=sqrt(d);
                if(d>0&&d==sd*sd&&(sd-b>0)&&((sd-b)%2==0))cnt+=2;
            }
        }
        cout<<cnt/2<<"\n";
    }
}*/
void solve()
{
    int x,y,z,n;cin>>n;
    map<int,int>M;
    for(x=1;x*x<n;x++)
    {
        for(y=1;x*x+y*y+x*y<n;y++)
        {
            for(z=1;z<n*n;z++)
            {
                int d=x*x+y*y+z*z+x*y+y*z+z*x;
                if(d>n)break;
                M[d]++;
            }
        }
    }
    int i;
    foe(i,1,n)cout<<M[i]<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3968
import math
n, k = [int(e) for e in input().split()]
m = math.ceil(math.log(k, 2))
if k <= n:
  result = sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, k)) / n
  result += (n - (k - 1)) / n
else:
  result = sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, n + 1)) / n
print('%.12f' % result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)
const ll MOD = 1000000007;
ll FAC_MAX = 2e6;
ll mpow(ll a, ll n) {  // a^n (mod MOD)
  // 二分累乗法 O(log n)
  ll ans = 1;
  while (n != 0) {
    if (n & 1) ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return ans;
}

vi fac_vec;
ll fac(ll n) {  // n! (mod MOD)
  if (fac_vec.empty()) {
    fac_vec = vi(FAC_MAX + 10);  // (FAC_MAX+10)! まで対応
    fac_vec[0] = 1;
    for (ll i = 1; i < fac_vec.size(); i++) {
      fac_vec[i] = (fac_vec[i - 1] * i) % MOD;
    }
  }
  return fac_vec[n];
}

vi ifac_vec;
ll ifac(ll n) {  // (n!)^(-1) (mod MOD)
  // フェルマーの小定理より、k^(-1)≡k^(MOD-2) なので、
  // (n!)^(-1)≡(n!)^(MOD-2)
  if (ifac_vec.empty()) {
    ifac_vec = vi(FAC_MAX + 10);  // {(FAC_MAX+10)!}^(-1) まで対応
    ifac_vec[0] = 1;
    for (ll i = 1; i < ifac_vec.size(); i++) {
      ifac_vec[i] = (ifac_vec[i - 1] * mpow(i, MOD - 2)) % MOD;
    }
  }
  return ifac_vec[n];
}

ll comb(ll a, ll b) {  // aCb (mod MOD)
  // aCb = a! * (b!)^(-1) * {(a-b)!}^(-1)
  if (a < b || a < 0 || b < 0) return 0;
  return (fac(a) * ifac(b) % MOD) * ifac(a - b) % MOD;
}

int main() {
  ll K;
  string S;
  cin >> K >> S;
  ll l = S.length();

  ll ans = 0;
  for (ll i = l; i <= l + K; i++) {  // i:Sの最後の文字の位置
    ll a = comb(i - 1, l - 1);  // Sの最後以外の文字の位置の選び方
    a *= mpow(25, i - l);  // Sの最後の文字の位置以前の、S以外の文字の選び方
    a %= MOD;
    a *= mpow(26, l + K - i);  // Sの最後の文字の位置以降の、S以外の文字の選び方
    a %= MOD;
    ans += a;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 35552
import java.util.Scanner;
import java.util.Stack;

public class Main {

	static boolean[][] map = new boolean[12][12];
	static int[] dx = new int[]{-1,0,1,0}, dy = new int[]{0,-1,0,1};

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while(scan.hasNext()){
			for (int i = 0; i < 12 ; i++) {
				String num = scan.next();
				for (int j = 0; j < 12 ; j++) {
					if(num.charAt(j)=='0') map[i][j]=false;
					else map[i][j]=true;
				}
			}

			int cnt = 0;
			for (int i = 0; i < 12 ; i++) {
				for (int j = 0; j < 12 ; j++) {
					if(map[i][j]){
						dfs(i,j);
						cnt++;
					}
				}
			}

			System.out.println(cnt);
		}
	}

	public static void dfs(int y,int x){
		Stack<int[]> stk = new Stack<int[]>();
		stk.push(new int[]{y,x});
		while(!stk.isEmpty()){
			int[] pos = stk.pop();
			int py = pos[0];
			int px = pos[1];
			map[py][px]=false;
			for (int i = 0; i < 4; i++) {
				int nx = px + dx[i];
				int ny = py + dy[i];
				if(0<=nx && nx<12 && ny>=0 && ny<12 && map[ny][nx]) stk.push(new int[]{ny,nx});
			}
		}
	}
}

Measured memory_bytes: 17184
class Grid
  def initialize(rows, width = rows[0].size, height = rows.size)
    @rows = rows
    @width = width
    @height = height
  end

  def [](i, j)
    return nil if i < 0 || j < 0
    @rows.fetch(i){return nil}[j]
  end

  def []=(i, j, v)
    @rows[i][j] = v
  end
end

h, w = gets.split.map(&:to_i)
ss = $<.map(&:chop).map(&:chars)
g = Grid.new(ss)
h.times do |i|
  w.times do |j|
    next if g[i, j] == '.'
    directions = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    adjacent = []
    directions.each do |d|
      adjacent << g[i+d[0], j+d[1]]
    end
    if !adjacent.include?('#')
      puts 'No'
      exit
    end
  end
end
puts 'Yes'

Measured memory_bytes: 2428
import sys
input = sys.stdin.readline

import numpy as np

MOD = 10**9 + 7

N,K = map(int,input().split())

U=int(10**4.5+10)
div = np.arange(1,U,dtype=np.int64)
div = div[N%div==0]
div = sorted(np.union1d(div,N//div))

A = {d:pow(K,int((d+1)//2),MOD) for d in div}
B = {}
for d in div:
    B[d] = A[d] - sum(B[dd] for dd in div if dd < d and d%dd == 0)

answer = sum(B[d] * (d//2 if d%2 == 0 else d) for d in div)
answer %= MOD
print(answer)

Measured memory_bytes: 19244
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<vector<Pll>> xy(n);
    rep(i,n){
        ll a; cin >> a;
        rep(j,a){
            ll x,y; cin >> x >> y;
            x--;
            xy[i].emplace_back(Pll(x,y));
        }
    }
    ll res = 0;
    rep(i,1LL << n){
        bool ok = true;
        bitset<30> bs(i);
        rep(j,n){
            if(i & (1LL << j)){
                for(auto k : xy[j]){
                    if(bs[k.first] != k.second)ok = false;
                }
            }
            // else{
            //     for(auto k : xy[j]){
            //         if(bs[k.first] == k.second)ok = false;
            //     }
            // }
        }
        ll t = bs.count();
        debug(i);
        debug(bs);
        debug(t);
        if(ok){
            res = max(res, t);
            debug(bs);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	bitset<2000*2000> dp;
	dp.set(0);
	cin >> N;
	int sum=0;
	for(int i=0;i<N;i++){
		int x;
		cin >> x;
		dp = dp | (dp << x);
		sum+=x;
	}
	int mid=(sum+1)/2;
	while(!dp.test(mid))mid++;
	cout<<mid<<endl;
}


Measured memory_bytes: 2176
//压行课次
#include<bits/stdc++.h>
using namespace std;
int read(){int sss=0,fff=1;char ccc;ccc=getchar();while(ccc<'0'||ccc>'9'){if(ccc=='-')fff=-1;ccc=getchar();}while(ccc>='0'&&ccc<='9')sss=(sss<<1)+(sss<<3)+(ccc^'0'),ccc=getchar();return sss*fff;}
int main()
{
//	freopen("123.in","r",stdin);
//	freopen("123.out","w",stdout);
	int n=read();
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			if(i*j==n)
			{
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll b,c,d,e,k,l,m,n,o=0,p=-1,q,x,y,z,max1=0,ans=0,min1=1000000000;
    string s,t,u;
    cin>>n;
    ll a[n];
    for (ll i=0; i<n; i++) {
        cin>>a[i];
        ans+=max(a[i],a[i]*p);
        if (a[i]<0) {
            o++;
        }
        min1=min(min1,max(a[i],a[i]*p));
    }
    if (o%2==1) {
        ans-=min1*2;
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint ans = 1;
	for(int i = 1; i <= n; i++) ans *= i, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(ll i = 0;i < n;i++)
#define FOR(i,a,b) for(ll i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

const int MAX = 1e4 + 1;
const int NMAX = 100 + 1;
bool dp[NMAX][MAX];
int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	REP(i, n)cin >> v[i];
	ll ans = LMAX;
	FOR(i, -100, 101) {
		ll tmp = 0;
		REP(j, n)tmp += pow(v[j] - i, 2);
		if (tmp < ans)ans = tmp;
	}
	dump(ans);
}




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

using namespace std;

complex<double> naive(vector<double> angles) {
    int n = (int) angles.size();
    complex<double> total_sum(0);
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                total_sum += polar(1., (angles[i]+angles[j])/2) + polar(1., (angles[j]+angles[k])/2) - polar(1., (angles[i]+angles[k])/2);
            }
        }
    }
    return total_sum / ((double) n * (n-1) * (n-2) / 6);
}

complex<double> smart(vector<double> angles) {
    int n = (int) angles.size();
    complex<double> ij_sum;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ij_sum += polar(1., (angles[i]+angles[j])/2) * ((double) (n-j-1));
        }
    }
    complex<double> jk_sum;
    for (int j = 0; j < n; ++j) {
        for (int k = j + 1; k < n; ++k) {
            jk_sum += polar(1., (angles[j]+angles[k])/2) * ((double) j);
        }
    }
    complex<double> ik_sum;
    for (int i = 0; i < n; ++i) {
        for (int k = i + 1; k < n; ++k) {
            ik_sum += polar(1., (angles[i]+angles[k])/2) * ((double) k-i-1);
        }
    }
    complex<double> total_sum = ij_sum + jk_sum - ik_sum;
    return total_sum / ((double) n * (n-1) * (n-2) / 6);
}

complex<double> simpler(vector<double> angles) {
    int n = (int) angles.size();
    complex<double> total_sum;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            total_sum += polar(1., (angles[i]+angles[j])/2) * ((double) n - 2*j + 2*i);
        }
    }
    return total_sum / ((double) n * (n-1) * (n-2) / 6);
}

complex<double> faster(vector<double> angles) {
    int n = (int) angles.size();
    complex<double> simple_sum, square_sum, total_sum;
    complex<double> running_i, running_j;
    for (int i = 0; i < n; ++i) {
        simple_sum += polar(1., angles[i]/2);
        square_sum += polar(1., angles[i]);
        total_sum += 2. * running_i * polar(1., angles[i]/2);
        running_i += polar(1., angles[i]/2) * ((double) i);
    }
    for (int i = n-1; i >= 0; --i) {
        total_sum -= 2. * running_j * polar(1., angles[i]/2);
        running_j += polar(1., angles[i]/2) * ((double) i);
    }
    total_sum += (simple_sum*simple_sum - square_sum) * ((double) n / 2.);
    return total_sum / ((double) n * (n-1) * (n-2) / 6);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, L;
    cin >> n >> L;
    double pi = atan(1)*4;
    vector<double> angles(n);
    for (auto& angle : angles) {
        cin >> angle;
        angle *= 2*pi/L;
    }
    complex<double> result = faster(angles);
    cout << setprecision(20) << real(result) << " " << imag(result) << endl;
    return 0;
}


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

using namespace std;
int n, k;
int ans, a[100001];
int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int mn = 1e9;
    for(int i = 1; i <= n; i++){
        if(i - k + 1 > 0){
            if(a[i - k + 1] < 0 && a[i] >= 0){
                mn = min (a[i - k + 1] * 2 * (-1) + a[i], mn);
                mn = min(a[i - k + 1] * (-1) + a[i] * 2, mn);
            }
            if(a[i - k + 1] < 0 && a[i] < 0){
                mn = min(mn, a[i - k + 1] * (-1));
            }
            if(a[i - k + 1] >= 0 && a[i] >= 0){
                mn = min(mn, a[i]);
            }
        }
    }
    cout << mn;
}


Measured memory_bytes: 640