akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

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

template<int Modulo = MOD> struct Mint {

	lint val;
	constexpr Mint(lint v = 0) noexcept : val(v % Modulo) { if (val < 0) v += Modulo; }

	constexpr Mint& operator += (const Mint &r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint &r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint &r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint &r) noexcept {
		lint a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			lint t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}

	constexpr Mint operator + (const Mint &r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint &r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint &r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint &r) const noexcept { return Mint(*this) /= r; }

	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }

	constexpr bool operator == (const Mint &r) const noexcept { return val == r.val; }
	constexpr bool operator != (const Mint &r) const noexcept { return val != r.val; }

	friend ostream &operator << (ostream &os, const Mint<Modulo> &x) noexcept { return os << x.val; }
	friend istream &operator >> (istream &is, Mint<Modulo> &x) noexcept {
		lint tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo> &a, lint n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	int N;
	string S;
	cin >> N >> S;

	vector<int> alp(26, 1);
	for (int i = 0; i < N; i++) alp[S[i] - 'a']++;

	mint ans = 1;
	for (int i = 0; i < 26; i++) ans *= alp[i];

	cout << ans - 1 << "\n";

	return 0;
}

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

using namespace std;
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

void _psum (int &, int);
int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int n, m, k, inv[N], f[N], res[N];
vector <int> X;

int x[] = {0, 0, -1, +1};
int y[] = {-1, +1, 0, 0};
string s[N];

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

	string s;
	cin >> s;
	int ans = 700;
	for (char c: s)
		if (c == 'o')
			ans += 100;
	cout << ans << endl;
}

int gcd (int a, int b) {
	return !b? a : gcd (b, a % b);
}

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

void _psum (int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

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

struct RSQ{
  int n=(1<<17),data[(1<<18)];
  RSQ(){
    memset(data,0,sizeof(data));
  }
  void add(int i,int v){
    i++;
    while(i<=n){
      data[i]+=v;
      i+=i&-i;
    }
  }
  int sum(int i){
    int res=0;
    while(i>0){
      res+=data[i];
      i-=i&-i;
    }
    return res;
  }
  int sum(int x,int y){
    return sum(y)-sum(x);
  }
};


main(){
  RSQ plus,all;
  int n,m,ans=-1e17;
  cin>>n>>m;
  r(i,n){
    int a;
    cin>>a;//cout<<a<<endl;
    if(a>0)plus.add(i,a);
    all.add(i,a);
  }
  r(i,n-m+1){
    int s1=plus.sum(0,i);
    int s2=plus.sum(i+m,n);
    int s3=max(all.sum(i,i+m),(int)0);
    ans=max(ans,s1+s2+s3);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    bool a = true;
    for(int i = 0; i <n ; ++i){
        int temp;
        cin >>temp;
        if(temp%2==0){
            if(temp%3 != 0 && temp%5 != 0){
            a = false;
            }
        }
    }
    if(a){
        cout<<"APPROVED";
    }
    else{
        cout<<"DENIED";
    }
}

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

const int MOD = 1e9 + 7;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	int negs = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 0)
			negs++;
	}
	sort(a.begin(), a.end(), greater<int>());
	int resp = 1;
	for (int i = 0, esq = 0, dir = n - 1; i < k; i++) {
		if (negs > 1 && (k - i) > 1 && (a[dir] * 1ll * a[dir - 1]) > (a[esq] * 1ll * a[esq + 1])) {
			resp = (resp * 1ll * a[dir]) % MOD;
			resp = (resp * 1ll * a[dir - 1]) % MOD;
			dir -= 2;
			negs -= 2;
			i++;
		} else {
			resp = (resp * 1ll * a[esq]) % MOD;
			esq++;
		}
	}
	if (resp < 0) {
		resp = 1;
		for (int i = 0; i < n; i++)
			a[i] = abs(a[i]);
		sort(a.begin(), a.end());
		for (int i = 0; i < k; i++) {
			resp = (resp * 1ll * a[i]) % MOD;
		}
		resp *= -1;
		resp = MOD - abs(resp);
	}
	cout << resp % MOD << endl;
	return 0;
}

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

int main(){
    using namespace std;
    using tuplis = array<int, 3>;
    const int sq = 1600;
    
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int& i : c){
        cin >> i;
        i--;
    }
    vector<tuplis> query(q);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--;
        query[i] = {l, r, i};
    }
    sort(query.begin(), query.end(), [&](const tuplis& a, const tuplis& b){ if(a[0] / sq == b[0] / sq) return a[1] < b[1]; return a[0] < b[0]; });
    vector<int> ans(q);
    vector<int> cnt(n);
    int types = 0, L = 0, R = 0;
    for(auto [l, r, i] : query){
        while(L < l){
            cnt[c[L]]--;
            types -= !cnt[c[L]];
            L++;
        }
        while(L > l){
            L--;
            types += !cnt[c[L]];
            cnt[c[L]]++;
        }
        while(R > r){
            R--;
            cnt[c[R]]--;
            types -= !cnt[c[R]];
        }
        while(R < r){
            types += !cnt[c[R]];
            cnt[c[R]]++;
            R++;
        }
        ans[i] = types;
    }
    for(int i : ans) cout << i << ' ';
}

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

int main(){
   int n, k;
   cin >> n >> k;
   int count = 0;
   while (n > 0)
   {
       n /= k;
       count += 1;
   }
   cout << count << endl;
   return 0;
}

Measured memory_bytes: 3584
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
d = defaultdict(int)
m = 0
for i in a:
    d[i] += 1
    m = max(m,i)
res = 1
tmp = 1
for i in range(m+1):
    if i == 0:
        if d[i] != 1 or a[0] != 0:
            print(0)
            quit()
        continue
    if d[i] == 0:
        res = 0
        break
    if i == 1:
        tmp = d[i]
        continue
    res = (res * tmp ** d[i] )%998244353
    tmp = d[i]
print(res%998244353)


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

int main() {
    string S;
    cin >>S;
    if(S.at(0) == S.at(1) && S.at(1) != S.at(2) && S.at(2) == S.at(3)){
        cout << "Yes" <<endl;
    }
    else if(S.at(0) == S.at(2) && S.at(2) != S.at(3) && S.at(1) == S.at(3)){
        cout << "Yes" <<endl;
    }
    else if(S.at(0) == S.at(3) && S.at(0) != S.at(1) && S.at(1) == S.at(2)){
        cout << "Yes" <<endl;
    }
    else cout <<"No" <<endl;
    }


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

using namespace std;

int main()
{
  int64_t n, m;
  cin >> n >> m;
  multiset<int64_t> a;

  for(int64_t i = 0;
      i < n;
      ++i)
    {
      int64_t ai;
      cin >> ai;
      a.insert(ai);
    }

  for(int64_t i = 0;
      i < m;
      ++i)
    {
      auto it = a.end();
      --it;
      int64_t x = *it/2;
      a.erase(it);
      a.insert(x);
    }
  int64_t ans = 0;
  for(auto it = a.begin();
      it != a.end();
      ++it)
    {
      ans += *it;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <algorithm>
using namespace std ;
int main(){
    int a, b, c, n ;
    cin >> a >> b >> c ;
    
    if(a - b <= c){
        n = c - (a - b) ;
        cout << n << endl ; 
    }
    else{
        cout << "0" << endl ;
    }
    
    

    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())

if (b-a)%2 == 0:
    print((b-a)//2)
else:
    left = a+((b-a)-1)//2
    right = (n-b+1)+(n-(a+n-b+1))//2
    print(min(right,left))

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

int cnt[11];

int main(){
  rep(i,4){
    int a; cin>>a;
    cnt[a]++;
  }
  if(cnt[1]&&cnt[4]&&cnt[7]&&cnt[9]) cout<<"YES\n";
  else cout<<"NO\n";
  return 0;
}


Measured memory_bytes: 256
import java.*;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger num1 = new BigInteger("1");
		BigInteger result = new BigInteger("1");
		while(n>0) {
			num1 = BigInteger.valueOf(n);
			result = result.multiply(num1);
			n--;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 26244
#include<stdio.h>

int main(void)

{

int a,b,c;

int count=0;

int i;

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

for(i=a;i<=b;i++)

{

if(c%i==0)count++;

}

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

return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  int c;
  cin >>a >> b>> c;
  if(a==b) cout<< c;
  if(a==c) cout << b;
  if(b==c) cout <<a;
  cout fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int x,y;
    scanf("%d %d",&x,&y);
    if(x==2)
      x=0;
    else if(x==4||x==6||x==9||x==11)
      x=-1;
    else
      x=-2;
    if(y==2)
      y=0;
    else if(y==4||y==6||y==9||y==11)
      y=-1;
    else
      y=-2;
    if(x==y)
      printf("Yes");
    else
      printf("No");
}


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

using namespace std;
using ll = long long;
int gcd(ll a, ll b) {
    if(min(a, b) == 0)return max(a, b);
    return gcd(min(a, b), max(a, b)%min(a, b));
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll E = C*D/gcd(C, D);

    cout << B - A + 1 - B/C + (A - 1)/C - B/D + (A - 1)/D + B/E - (A - 1)/E << endl;



    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <deque>

int main(){
	std::deque<int> que;
	int tmp;
	while(std::cin >> tmp){
		if(tmp == 0){
			std::cout << que.back() << std::endl;
			que.pop_back();
		}
		else que.push_back(tmp);
	}
		return 0;
	}

Measured memory_bytes: 1200
#include<stdio.h>

int n,pf[101],connect[101][101],numb[101],maxpath=1;
 
void search(int now,int path){
    int j;
    pf[now]=1;
    path++;
    if(maxpath<path) maxpath=path;
    for(j=0;connect[now][j]>0;j++){
        if(pf[connect[now][j]]==0){
                search(connect[now][j],path);
        }
    }
    pf[now]=0;
}
 
int main(){
    int i,a,b,j;
    scanf("%d",&n);
    while(n!=0){
    	for(i=0;i<101;i++){
    		numb[i]=0;
    		pf[i]=0;
    		for(j=0;j<101;j++){
    			connect[i][j]=0;
    		}
    	}
        for(i=0;i<n;i++){
            scanf("%d %d",&a,&b);
            connect[a][numb[a]]=b;
            connect[b][numb[b]]=a;
            numb[a]++;
            numb[b]++;
        }
        maxpath=1;
        for(i=1;i<=100;i++){
            search(i,0);
        }
        printf("%d\n",maxpath);
        scanf("%d",&n);
    }
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
template<typename Monoid, typename OperatorMonoid, typename F, typename G, typename H>
struct LazySegmentTree{
	int sz;
	vector<Monoid> data;
	vector<OperatorMonoid> lazy;
	const F f;
	const G g;
	const H h;
	const Monoid e1;
	const OperatorMonoid e0;

	LazySegmentTree(int n, const F f, const G g, const H h, const Monoid &e1, const OperatorMonoid &e0): f(f), g(g), h(h), e1(e1), e0(e0){
		sz=1;
		while(sz<n) sz<<=1;
		data.resize(2*sz-1, e1);
		lazy.resize(2*sz-1, e0);
	}

	void build(vector<Monoid> v){
		for(int i=0; i<v.size(); i++) data[i+sz-1]=v[i];
		for(int i=sz-2; i>=0; i--) data[i]=f(data[2*i+1], data[2*i+2]);
	}

	void eval(int k, int l, int r){
		if(lazy[k]!=e0){
			data[k]=g(data[k], lazy[k], r-l);
			if(k<sz-1){
				lazy[2*k+1]=h(lazy[2*k+1], lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2], lazy[k]);
			}
		}
		lazy[k]=e0;
	}

	void update(int a, int b, const OperatorMonoid &x, int k, int l, int r){
		eval(k, l, r);
		if(r<=a || b<=l) return;
		if(a<=l && r<=b){
			lazy[k]=h(lazy[k], x);
			eval(k, l, r);
		}else{
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			data[k]=f(data[2*k+1], data[2*k+2]);
		}
	}
	void update(int a, int b, const OperatorMonoid &x){
		return update(a, b, x, 0, 0, sz);
	}

	Monoid find(int a, int b, int k, int l, int r){
		eval(k, l, r);
		if(b<=l || r<=a) return e1;
		if(a<=l && r<=b) return data[k];
		else return f(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
	}
	Monoid find(int a, int b){
		return find(a, b, 0, 0, sz);
	}
	Monoid operator[](const int &k){
		return find(k, k+1);
	}
};
struct myon{
	ll c0, c1, cv;
	myon(){}
	myon(ll c0, ll c1, ll cv):c0(c0), c1(c1), cv(cv){}
};
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    vector<myon> v(n);
    for(int i=0; i<n; i++){
        int a;
        scanf("%d", &a);
        if(a) v[i]=myon(0, 1, 0);
		else v[i]=myon(1, 0, 0);
    }
	auto f=[&](myon a, myon b){
		return myon(a.c0+b.c0, a.c1+b.c1, a.cv+b.cv+a.c1*b.c0);
	};
	auto g=[&](myon a, bool x, int len){
		if(x) return myon(a.c1, a.c0, a.c0*a.c1-a.cv);
		else return a;
	};
	auto h=[&](bool x, bool y){
		return x^y;
	};
    LazySegmentTree<myon, bool, decltype(f), decltype(g), decltype(h)> seg(n, f, g, h, myon(0, 0, 0), 0);
    seg.build(v);
    while(q--){
        int t, l, r;
        scanf("%d %d %d", &t, &l, &r);
		l--;
        if(t==1){
            seg.update(l, r, 1);
        }else{
            printf("%lld\n", seg.find(l, r).cv);
        }
    }
    return 0;
}


Measured memory_bytes: 25004
# coding: utf-8
import sys

def func(num_list):
    count = 0
    for i in range(2):
        while(True):
            # print(num_list[i], num_list[i+1])
            if num_list[i] < num_list[i+1]:
                break
            else:
                num_list[i+1] = num_list[i+1] * 2 
                count = count + 1
    return count


if __name__ == "__main__":
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    
    tmp = lines[0].split(' ')
    num_list = []
    for n in tmp:
        num_list.append(int(n))

    count = func(num_list)
    if count <= int(lines[1]):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    FOR(i, 1, n+1) {
        ll count = n / i;
        ans += (i + count * i) * count / 2;
    }
    cout << ans;
}

Measured memory_bytes: 3632
def main():
    x = list(map(int, input().split()))
    k = x[0]
    n = x[1]
    a = list(map(int, input().split()))

    max_distance = 0

    for i in range(n):
        distance = a[i]-a[i-1]
        if distance < 0:
            distance = k+distance
        if max_distance < distance:
            max_distance = distance

    answer = k - max_distance
    print(answer)


if __name__ == "__main__":
    main()

Measured memory_bytes: 92164
n,x,y = map(int, input().split())

ans = [0]*n
for i in range(n-1):
  for j in range(i+1, n):
    d = min(j-i, abs(i-x+1)+abs(j-y+1)+1)
    ans[d] += 1
    
ans = ans[1:]

for a in ans:
  print(a)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define fi first
#define se second
#define ii pair<int, int>
#define int long long
using namespace std;

const int INF = 1e9;
int n, m;
int ans = INF;
int a[85][85], b[85][85];
bool f[85][85][52000];

void attempt(int i, int j, int diff)
{

    if (i == n && j == m)
    {
        ans = min(ans, abs(diff + a[i][j] - b[i][j]));
        ans = min(ans, abs(diff - a[i][j] + b[i][j]));
        return;
    }
    if (f[i][j][diff])
        return;
    f[i][j][diff] = 1;

    if (i < n){
        attempt(i+1, j, abs(diff + a[i][j] - b[i][j]));
        attempt(i+1, j, abs(diff - a[i][j] + b[i][j]));
    }
    if (j < m){
        attempt(i, j+1, abs(diff + a[i][j] - b[i][j]));
        attempt(i, j+1, abs(diff - a[i][j] + b[i][j]));
    }

}

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

//    freopen("in.inp", "r", stdin);
//    freopen("out.out", "w", stdout);

    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> b[i][j];

    attempt(1, 1, 0);
    cout << ans;
}


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

using namespace std;

int n;
vector<int> a;

signed main() {
	scanf("%d", &n);
	a.resize(2*n);
	for (int i = 0; i < 2*n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end());
	int res = 0;
	for (int i = 0; i < 2*n; i+=2) {
		// cout << a[i] << "\n";
		res += a[i];
	}
	cout << res;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = r*2*pi;
        System.out.printf("%f %f", area, length);
        sc.close();
    }
}


Measured memory_bytes: 28212
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	rep(i,0,3){
		if(n%10==7){
			cout<<"Yes";
			return 0;
		}
		n/=10;
	}
	cout<<"No";
	return 0;
}



Measured memory_bytes: 3648
import copy

n = int(input())


s = []
def dfs(A):
    if len(A) == len(str(n)):
        return
    for i in ['7', '5', '3']:
        A.append(i)
        if len(set(A)) == 3 and int(''.join(A)) <= n:
            s.append(int(''.join(A)))
        dfs(A)
        A.pop()

dfs([])

#print(s)
print(len(s))

Measured memory_bytes: 52188
directions=input()
sens=["N","S","W","E"]
compteur=[0]*4
for direction in directions:
    compteur[sens.index(direction)]+=1

if (compteur[0]>0 and compteur[1]==0) or (compteur[1]>0 and compteur[0]==0) or (compteur[2]>0 and compteur[3]==0) or (compteur[3]>0 and compteur[2]==0):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
INF = 100000000000

n, m, x = gets.split.map(&:to_i)

cs = []
as = []

n.times do |i|
  cas = gets.split.map(&:to_i)
  c = cas[0]
  a = cas[1..-1]

  cs << c
  as << a
end

mn = INF

[false, true].repeated_permutation(n) do |combs|
  abilities = Array.new(m, 0)
  price = 0

  n.times do |i|
    if combs[i]
      price += cs[i]
      m.times do |j|
        abilities[j] += as[i][j]
      end
    end
  end

  if abilities.all? {|v| v >= x }
    mn = [price, mn].min
  end
end

if mn == INF
  p -1
else
  p mn
end


Measured memory_bytes: 14684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
int main(){
    int h,w; cin>>h>>w;
    int ch,cw,dh,dw;
    cin>>ch>>cw>>dh>>dw;
    ch--;
    cw--;
    dh--;
    dw--;
    vector<string> field(h);
    rep(i,h){
        cin>>field[i];
    }

    //魔法を使った回数
    vector<vector<ll>> magic(h,vector<ll>(w,INF));
    magic[ch][cw]=0;

    queue<P> que,visited;
    que.push(P(ch,cw));
    while(!que.empty() || !visited.empty()){
        ll nowx,nowy;
        if(!que.empty()){
            nowx=que.front().first;
            nowy=que.front().second;
            que.pop();
            visited.push(P(nowx,nowy));
            rep(i,4){
                ll nextx=nowx+dx[i];
                ll nexty=nowy+dy[i];
                if(nextx<0||nextx>=h||nexty<0||nexty>=w) continue;
                if(field[nextx][nexty]=='#') continue;

                if(magic[nowx][nowy]<magic[nextx][nexty]){
                    magic[nextx][nexty]=magic[nowx][nowy];
                    que.push(P(nextx,nexty));
                }
            }
        }
        else{
            nowx=visited.front().first;
            nowy=visited.front().second;
            visited.pop();
            for(int i=-2; i<=2;i++){
                for(int j=-2; j<=2; j++){
                    int nextx=nowx+i;
                    int nexty=nowy+j;
                    if(nextx<0||nextx>=h||nexty<0||nexty>=w) continue;
                    if(field[nextx][nexty]=='#') continue;

                    if(magic[nowx][nowy]+1<magic[nextx][nexty]){
                       magic[nextx][nexty]=magic[nowx][nowy]+1;
                       que.push(P(nextx,nexty));
                    }
                }
            }
        }
    }
    if(magic[dh][dw]==INF) cout<<-1<<endl;
    else cout<<magic[dh][dw]<<endl;

}

Measured memory_bytes: 13436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC014A
{
    class Program
    {
        static void Main(string[] args)
        {
            long A, B, C;
            string[] vals = Console.ReadLine().Split(' ');

            A = long.Parse(vals[0]);
            B = long.Parse(vals[1]);
            C = long.Parse(vals[2]);

            long x = A - B;
            long y = B - C;
            long z = C - A;

            if(x == 0 && y == 0 && z == 0)
            {
                if (A % 2 == 0)
                    Console.WriteLine(-1);
                else
                    Console.WriteLine(0);
            }
            else
            {
                long count = 0;
                if (x != 0)
                {
                    while (x % 2 == 0)
                    {
                        count++;
                        x /= 2;
                    }
                }
                else
                {
                    count = long.MaxValue;
                }

                long county = 0;
                if (y != 0)
                {
                    while (y % 2 == 0)
                    {
                        county++;
                        y /= 2;
                    }
                    if (count > county)
                        count = county;
                }


                long countz = 0;
                if (z != 0)
                {
                    while (z % 2 == 0)
                    {
                        countz++;
                        z /= 2;
                    }

                    if (count > countz)
                        count = countz;
                }
                Console.WriteLine(count);
            }

        }
    }
}


Measured memory_bytes: 11092
import sys
from queue import Queue


def print_costs(costs):
    for c in costs:
        print(c)


def solve(inp):
    (H, W) = map(int, inp.readline().strip().split(' '))
    S = [list(inp.readline().strip()) for i in range(H)]

    max_cost = 0
    for start_y in range(H):
        for start_x in range(W):
            if S[start_y][start_x] == '#':
                continue
            costs = [[0 for w in range(W)] for h in range(H)]
            costs[start_y][start_x] = 1
            queue = Queue()
            queue.put((start_y, start_x))
            cost = 1
            while not queue.empty():
                (y, x) = queue.get()
                # print("({},{}): {}".format(y, x, c))
                for (next_y, next_x) in [(y - 1, x), (y, x + 1), (y + 1, x), (y, x - 1)]:
                    if 0 <= next_y < H and 0 <= next_x < W and S[next_y][next_x] == '.' and costs[next_y][next_x] == 0:
                        costs[next_y][next_x] = costs[y][x] + 1
                        if cost < costs[next_y][next_x]:
                            cost = costs[next_y][next_x]
                        queue.put((next_y, next_x))
            if cost > max_cost:
                max_cost = cost
            # print("--- cost={}".format(max_cost))
            # print_costs(costs)
            # print()

    return str(max_cost - 1)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
//=========================
//  author:hliwen
//  date:2020.1.19
//=========================
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DEBUG puts("ok")
#define tie0 cin.tie(0),cout.tie(0)
#define fastio ios::sync_with_stdio(false)
#define File(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout)
using namespace std;
typedef long long ll;

template <typename T> inline void read(T &x) {
	T f = 1; x = 0; char c;
    for (c = getchar(); !isdigit(c); c = getchar()) if (c == '-') f = -1;
    for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x *= f;
}

int a, b;

int main() {
	read(a), read(b);
	if (a <= b) {
		for (int i = 1; i <= b; ++i)
			printf("%d", a);
	}
	else {
		for (int i = 1; i <= a; ++i)
			printf("%d", b);
	}
	return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable.ListBuffer
import scala.util.Try
object Main extends App {
  val sr = new StdinReader
  val n, m = sr.nextInt
  val conditions = Array.fill(n + 1)(new ListBuffer[(Int, Int)])
  (1 to m).foreach{i => 
    val l, r, d = sr.nextInt
    conditions(l) += ((r, d))
    conditions(r) += ((l, -d))
  }

  val checked = Array.fill(n + 1)(Int.MaxValue)

  case class Check(index: Int, position: Int)

  @scala.annotation.tailrec
  def check(cs: List[Check]): Unit = {
    val checks = new ListBuffer[Check]
    if (cs.nonEmpty) {
      cs.foreach{c =>
        if (checked(c.index) == Int.MaxValue) {
          checked(c.index) = c.position
          checks ++= conditions(c.index).map{case (to, d) => Check(to, c.position + d)}
        } else if (checked(c.index) != c.position) {
          throw new Exception
        }
      }
      check(checks.toList)
    }
  }

  val result = try{
    (1 to n).foreach{i => if (checked(i) == Int.MaxValue) check(List(Check(i, 0)))}
    true
  } catch {
    case e: Throwable => e.printStackTrace;false
  }
  println(if (result) "Yes" else "No")
}

class StdinReader {
  val buffer = new Array[Byte](1024 * 1024)
  var size = 0
  var pos = 0

  private def readByte: Byte = {
    if (pos >= size) {
      pos = 0;
      size = System.in.read(buffer);
    }
    if (size < 0) -1
    else {
      val ret = buffer(pos)
      pos += 1
      ret
    }
  }

  def next: String = {
    @scala.annotation.tailrec
    def r(sb: StringBuilder, reading: Boolean): String = {
      readByte match {
        case b if ('!' <= b && b <= '~') => r(sb.append(b.asInstanceOf[Char]), true)
        case _ => if (reading) sb.toString else r(sb, false)
      }
    }
    r(new StringBuilder, false)
  }

  def nextInt: Int = {
    @scala.annotation.tailrec
    def r(i: Int, reading: Boolean): Int = {
      readByte match {
        case '-' => r(i * -1, true)
        case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)
        case _ => if (reading) i else r(i, false)
      }
    }
    r(0, false)
  }
}

Measured memory_bytes: 104732
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  string s; cin >> s;
  for(char c = 'a'; c <= 'z'; ++c) {
    bool flag = true;
    rep(i, s.length()) {
      if(s[i] == c) flag = false;
    }
    if(flag) {
      cout << c << '\n';
      return 0;
    }
  }
  cout << "None" << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
    char a[3];
    int i,total,count=0;
    scanf("%s",a);
    for(i=0;i<3;i++){
       if(a[i]=='o'){
         count++;
       }

    }
    total=700+count*100;
    printf("%d\n",total);
    return 0;
}


Measured memory_bytes: 128
N=int(input())
a=list(map(int,input().split()))
a=[bin(a[i])[2:].zfill(20) for i in range(N)]
ans=0
x=[-1]*20
tmp=-1
for i in range(N):
    for j in range(20):
        if a[i][j]=="1":
            x[j],tmp=i,max(tmp,x[j])
    ans+=i-tmp

print(ans)

Measured memory_bytes: 27820
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let txy = get!(i64, i64, i64; N);

    let mut ans = "Yes";
    let mut u = 0;
    let mut v = 0;
    for (t, x, y) in txy {
        let d = ((x - u).abs() + (y - v).abs());
        if !(d <= t && (t - d) % 2 == 0) {
            ans = "No";
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>

using namespace std;

typedef long long ll;
int main() {
    ll L, R, min = 2020;

    cin >> L >> R;
    if(R-L >= 2019) min = 0;
    else {
        for(ll i=L; i<=R-1; i++) {
            for(ll j=i+1; j<=R; j++) {
                ll t = (i*j)%2019;
                if(t<min) min = t;
            }
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
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));
        

		// 1行目数字、2行目文字
		int N = Integer.parseInt(br.readLine());
		String s = br.readLine();

		int max = 0;
		int n = 0;
		int j=0;
		
		for(int i = 0; i < N; i++){
			
			if (s.substring(i, i+1).equals("I")) {
				n = n + 1;
			} else {
				n = n - 1;
			}
			//System.out.println(n);
			max = (max > n) ? max : n;  //Max

		}
		


        System.out.println(max);
        return;
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}

Measured memory_bytes: 8272
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll w=0,b=0;
    rep(i,0,2*n-1){
        if(s[i]=='W') w++;
        else b++;
    }
    if(s[0]=='W' || s[2*n-1]=='W'){cout<<"0";return;}
    // if(w!=b) {cout<<0;return;}
    ll k=1;
    rep(i,2,n) k=(k*i)%hell;
    ll ans=k;
    ll arr[2*n];
    arr[0]=0;
    rep(i,1,2*n-1){
        if(s[i]==s[i-1]) arr[i]=!arr[i-1];
        else arr[i]=arr[i-1];
    }
    ll cl=0;
    rep(i,0,2*n-1){
        if(arr[i]){
            ans=(ans*cl)%hell;
            cl--;
        }
        else cl++;
    }
    if(cl==0)
    cout<<ans;
    else cout<<0;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] a = new int[3];
        a[0] = in.nextInt();
        a[1] = in.nextInt();
        a[2] = in.nextInt();
        in.nextLine();
        String[] s = new String[n];
        char[] out = new char[n];
        for(int i = 0; i < n; i++)
            s[i] = in.nextLine();
    

        for(int k = 0; k < n; k++){
            int i = (int)s[k].charAt(0)-(int)'A';
            int j= (int)s[k].charAt(1)-(int)'A';

            if(a[i] > a[j]){
                a[i]--;
                a[j]++;
                out[k] = (s[k].charAt(1));
            }
            else if(a[i] < a[j]){
                a[i]++;
                a[j]--;
                out[k] = (s[k].charAt(0));
            }
            else{
                if(a[i] + a[j] == 0){
                    System.out.println("No");
                    return;
                }
                if(k == n-1 || s[k+1].charAt(0) == s[k].charAt(0) || s[k+1].charAt(1) == s[k].charAt(0)){
                    a[i]++;
                    a[j]--;
                    out[k] = (s[k].charAt(0));
                }
                else{
                    a[i]--;
                    a[j]++;
                    out[k] = (s[k].charAt(1));
                }
            }
        }
        System.out.println("Yes");
        for(int i = 0; i < n; i++)
            System.out.println(out[i]);
    }
}

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


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

  
  int ans = pow(3,N),num = 1;
  for(int i = 0;i < N;i++) {
    int a;
    cin >> a;
    if(a % 2 == 0) num *= 2;
  }

  cout << ans - num << endl;


}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
int abss(int k){
  return (k < 0 ? k * -1 : k);
}
int main(){
  int n;
  cin >> n;
  int a[n];
  int sum = 0;
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  rep(i,n){
    a[i] *= n;
    a[i] = abss(a[i] - sum);
  }
  int mn = sum;
  int mnnm;
  rep(i,n){
    if(a[i] < mn){
      mn = a[i];
      mnnm = i;
    }
  }
  cout << mnnm << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner; 

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		 Dice2 di = new Dice2();

		int[] dice = new int[6];		//dice
		for(int i=0; i<6; i++) {
			 dice[i] = scan.nextInt();
			}
		
		int[] dice2 = new int[6];		//dice2

		for(int i=0; i<6; i++) {
			 dice2[i] = scan.nextInt();
			}

        int answer[] = new int[6];	//同じサイコロの形

        //N方向回転
		for(int i=0; i<4; i++) {

			if(Arrays.equals(dice, answer)) {
				break;
			}
			answer = di.command(dice2, 'N');

			//横回転
			for(int j=0; j<4; j++) {

				if(Arrays.equals(dice, answer)) {
					break;
				}
				answer = di.command(dice2, 'R');
			}
		}

		//W方向回転
		for(int i=0; i<4; i++) {

			if(Arrays.equals(dice, answer)){
				break;
			}
			answer = di.command(dice2, 'W');

			//横回転
			for(int j=0; j<4; j++) {

				if(Arrays.equals(dice, answer)) {
					break;
				}
				answer = di.command(dice2, 'R');

			}
		}
		
		//出力
		if(Arrays.equals(dice, answer)) {
			System.out.println("Yes");
		}else
			System.out.println("No");
	}
}

class Dice2{

	int[] command(int[] dice, char com) {
	    	int top = dice[0];	//dice[0]を覚えておく
	    	int side1 = dice[1];	//dice[1]を覚えておく

	    	switch (com) {

	    	case 'N':
	    		dice[0] = dice[1];
	    		dice[1] = dice[5];
	    		dice[5] = dice[4];
	    		dice[4] = top;
	    		break;

	    	case 'W':
	    		dice[0] = dice[2];
	    		dice[2] = dice[5];
	    		dice[5] = dice[3];
	    		dice[3] = top;
	    		break;


	    	case 'R':
	    		dice[1] = dice[3];
	    		dice[3] = dice[4];
	    		dice[4] = dice[2];
	    		dice[2] = side1;
	    		break;
	    	}
		return dice; 		//配列を返す
	 }
}



Measured memory_bytes: 26380
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n;
	cin >> n;

	int ans = 1;
	rep(i,n)ans = ans*(i+1)%MOD;
	cout << ans << endl;
	
	
	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc055.contest.atcoder.jp/tasks/abc055_b

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s; ll k;
    cin >> s >> k;
    int n = s.size();
    int ok = 1;
    for (int i = 0; i < n-1; ++i) {
        if(s[i] != s[i+1]) ok = 0;
    }
    if(ok){
        cout << n*k/2 << "\n";
        return 0;
    }
    if(s.front() == s.back()){
        ll ans = 0, ans2 = 0, a = 0, b = 0;
        s += s;
        s += "?";
        int cur = 0;
        while(cur < n){
            int curr = cur;
            auto c = s[cur];
            while(c == s[curr]) curr++;
            if(cur == 0){
                a += (curr-cur)/2;
            }else if(curr >= n){
                b += (n-cur)/2;
                ans2 += (curr-cur)/2;
            }else {
                ans += (curr-cur)/2;
            }
            cur = curr;
        }
        cout << ans*k + ans2*(k-1)+a+b << "\n";
    }else {
        ll ans = 0;
        s += s;
        s += "?";
        int cur = 0;
        while(cur < n){
            int curr = cur;
            auto c = s[cur];
            while(c == s[curr]) curr++;
            ans += (curr-cur)/2;
            cur = curr;
        }
        cout << ans*k << "\n";
    }

    return 0;
}

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

int main(void)
{
	for(string str; cin >> str, str != "-"; ) {
		int m;
		int h[100];

		cin >> m;

		for(int i = 0; i < m; i++) {
			cin >> h[i];
			string tmp = str.substr(0, h[i]);
			str = str.substr(h[i]) + tmp;
		}

		cout << str << endl;
	}

	return 0;
}

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

int FindSum (int n) {
  int sum =0;
  while (n>0) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main () {
  int N; cin >> N;
  
  int ans =0, min = 100000;
  for (int i=1; i<N; i++) {
    ans = FindSum(i) + FindSum(N-i);
    if (ans < min) min = ans;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
A , B , C , X ,Y = map(int,input().split())
C_val = C * 2
ans = 0
if A + B >= C_val:
    if X >= Y:
        XYmax , XYmin = X , Y
        cmp = A
    else:
        XYmax , XYmin = Y , X
        cmp = B
    ans += XYmin * C_val
    remain = XYmax - XYmin
    if cmp >= C_val:
        ans += C_val * remain
    else:
        ans += cmp * remain
    print(ans)
else:
    print(A * X + B * Y)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  while(n!=0||x!=0){
    int i,j,k;
    int o=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x) o++;
	}
      }
    }

    cout << o << endl;

    cin >> n >> x;
  }


  return 0;
}



Measured memory_bytes: 3088
N, M, X, Y = map(int, input().split())
x = [int(_) for _ in input().split()]
y = [int(_) for _ in input().split()]

x_max = max(x)
y_min = min(y)

if (y_min-x_max > 0) and (Y-X > 0) and (X<y_min) and (x_max<Y):
    print("No War")
else:
    print("War")

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;
static const ll MOD = 1000000007;
 #define LOOP 10000000


int main() {

  int a1, a2, a3;
  int ans;

  cin >> a1 >> a2 >> a3;

  ans = a1 + a2 + a3;

  if(ans >= 22)  cout << "bust" << endl;
  else cout << "win" << endl;



  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
  //  freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    ll b=0;
    for(int i=0;i<n;i++) b=(b^a[i]);
    for(int i=0;i<n;i++) a[i]=(a[i]&(~b));
    int sz=0;
    while(sz<n){
        int j=0;
        ll mx=0;
        for(int i=sz;i<n;i++){
            if(mx<a[i]){
                mx=a[i];
                j=i;
            }
        }
        if(mx == 0) break;
        swap(a[sz],a[j]);
        //if((x^a[sz])+(x^a[sz]^b)>x+(x^b)) x=(x^a[sz]);
        for(int i=sz+1;i<n;i++){
            if((a[i]^a[sz])<a[i])a[i]=(a[i]^a[sz]);
        }
        sz++;
    }
    for(int i=sz-1;i>-1;i--){
        for(int k=0;k<i;k++){
            if(a[k]>(a[i]^a[k])) a[k]=(a[i]^a[k]);
        }
    }
    ll x=0;
    for(int i=0;i<sz;i++){
        if((x^a[i])+(x^a[i]^b)>x+(x^b)) x=(x^a[i]);
    }
    cout<<x+(x^b);
    return 0;
}


Measured memory_bytes: 1024