akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())
ans = float('Inf')
sq = int(math.sqrt(N)) + 1
for i in range(1, sq):
    if N % i == 0:
        a = len(str(i))
        b = len(str(N // i))
        if a > b:
            num = a
        else:
            num = b
        if ans > num:
            ans = num
print(ans)

Measured memory_bytes: 38896
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    cout << (b - a == c - b ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,m,d;
  cin >> n >> m >> d;

  cout << Decimal;
  if(d==0)
    cout << (m-1.0)/n << endl;
  else
    cout << (m-1.0)*2*(n-d)/pow(n, 2) << endl;
  
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
    int src,to,limit;
    T cost;

    edge() = default;
    edge(int to, T cost, int limit) : src(-1), to(to), cost(cost), limit(limit) {}
    //edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

double dist[30][30][31];
using Tu = tuple<double, int, int, int>; 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int N,M; cin >> N >> M;
        if (N+M==0) break;
        int S,g; cin >> S >> g;
        --S; --g;
        vector<vector<edge<double>>> G(N);
        rep(i,M) {
            int u,v,d,c; cin >> u >> v >> d >> c;
            --u; --v;
            G[u].emplace_back(v,d,c);
            G[v].emplace_back(u,d,c);
        }

        rep(i,30) rep(j,30) rep(k,31) dist[i][j][k] = 1e18;
        dist[S][S][0] = 0;
        priority_queue<Tu, vector<Tu>, greater<Tu>> pq;
        pq.emplace(0,S,S,0);
        while (!pq.empty()) {
            double d;
            int v,pv,s;
            tie(d,v,pv,s) = pq.top(); pq.pop();
            if (d > dist[v][pv][s]+1e-10) continue;
            for (auto &e : G[v]) {
                if (e.to == pv) continue;
                for (int i = -1; i <= 1; i++) {
                    int ns = s + i;
                    if (ns < 1 || ns > e.limit) continue;
                    if (chmin(dist[e.to][v][ns], dist[v][pv][s] + e.cost/ns)) {
                        pq.emplace(dist[e.to][v][ns], e.to, v, ns);
                    }
                }
            }
        }

        double ans = 1e18;
        rep(i,N) chmin(ans,dist[g][i][1]);
        if (ans == 1e18) cout << "unreachable" << ln;
        else cout << fixed << setprecision(10) << ans << ln;
    }
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<long long>A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.push_back(a);
	}
	sort(A.begin(),A.end());
	vector<long long>minus;
	vector<long long>plus;
	minus.push_back(A[0]);
	plus.push_back(A[N-1]);
	for(int i=1;i<N-1;i++){
		if(A[i]<0){
			minus.push_back(A[i]);
		}else{
			plus.push_back(A[i]);
		}
	}
	sort(minus.begin(),minus.end());
	sort(plus.begin(),plus.end());
	vector<pair<long long,long long> >ans;
	for(int i=0;i<plus.size()-1;i++){
		ans.push_back(make_pair(minus[0],plus[i]));
		minus[0]-=plus[i];
	}
	for(int i=0;i<minus.size();i++){
		ans.push_back(make_pair(plus[plus.size()-1],minus[i]));
		plus[plus.size()-1]-=minus[i];
	}
	cout<<plus[plus.size()-1]<<endl;
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].first;
		cout<<" ";
		cout<<ans[i].second<<endl;
	}
}
	

Measured memory_bytes: 5872
n, m = map(int, input().split())
answer = 0
penalty = 0
ans = [0] * n
pen = [0] * n

for x in range(m):
  p, s = input().split()
  pi = int(p) - 1
  if ans[pi] == 1:
    continue

  if s == 'AC':
    answer += 1
    ans[pi] = 1
    penalty += pen[pi]
  elif s == 'WA':
    pen[pi] += 1

print(f'{answer} {penalty}')



Measured memory_bytes: 10200
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

    int n, ans = INF;
    string s;
    cin >> n >> s;
    map<char,int> cnt, cnt2;
    for(int i = 0; i < n; i++)
        cnt[s[i]]++;
    for(int i = 0; i < n; i++) {
        cnt[s[i]]--;
        ans = min(ans, cnt2['W']+cnt['E']);

        cnt2[s[i]]++;
    }
    cout << ans;



	return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int h, w; cin >> h >> w;
    string s;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        cin >> s;
        if (s == "snuke") {
            cout << char('A' + j) << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define reg register
#define LL long long
char s[5];
int main(){
    std::scanf("%s",s+1);
    int a=0,b=0;
    if(s[1]=='A') a=1;
    else b=1;
    if(s[2]=='A') a=1;
    else b=1;
    if(s[3]=='A') a=1;
    else b=1;
    if(a&&b) std::puts("Yes");
    else std::puts("No");
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    map<int, int> mp1, mp2;
    rep(i, n) {
        int a; cin >> a;
        if(i&1) mp2[a]++;
        else mp1[a]++;
    }

    vector<P> v1, v2;
    for(auto e : mp1) {
        v1.push_back(P(e.second, e.first));
    }
    for(auto e : mp2) {
        v2.push_back(P(e.second, e.first));
    }
    sort(v1.begin(), v1.end(), greater<P>());
    sort(v2.begin(), v2.end(), greater<P>());
    if(v1[0].second != v2[0].second){
        cout << n - v1[0].first - v2[0].first << '\n';
    } else{
        cout << n - max(v1[0].first + v2[1].first, v1[1].first + v2[0].first) << '\n';
    }
    return 0;
}

Measured memory_bytes: 6140
import sys
import math

count = 0

num_list = []

for line in sys.stdin.readlines():
    num_list.append(int(line.strip()))

num_list.remove(num_list[0])

for num in num_list:
        flag = 0
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = 1
                break
        if flag == 0:
            count += 1

print count

Measured memory_bytes: 7216
N = int(input())
Alist = list(map(int,input().split()))
M = 10**9+7
Asum = sum(Alist)
Answer = 0
for i in range(len(Alist)):
    Asum -= Alist[i]
    Answer += (Alist[i]%M)*(Asum%M)
    Answer = Answer%M
print(Answer)

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

int main() {
  
  int N, K;
  cin >> N >> K;
  int x, y = 0;
  
  for (int i = 0;N > i;i++){
    cin >> x;
    if (K / 2 < x){
      y += (K - x) * 2;
    }
    else{
      y += x * 2;
    }
  }
  cout << y << endl;
}

Measured memory_bytes: 3604
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let mut ab = arr(n, |_| (scan.read::<i64>(), scan.read::<i64>()));
    ab.sort_by_key(|&p| -(p.0 + p.1));
    let mut ret = -ab.iter().map(|x| (*x).1).sum::<i64>();
    for i in 0..n {
        if i % 2 == 0 {
            ret += ab[i].0 + ab[i].1;
        }
    }
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

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

    if(a % 3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        std::cout << "Possible";

    }
    else std::cout << "Impossible";
    return 0;

}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

#include <iostream>
#include <string>

using namespace std;

class BShiftOnly {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        int A[N];
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }

        int cnt = 0;
        bool loop = true;
        while (loop) {
            for (int i = 0; i < N; ++i) {
                if (A[i] % 2 != 0) {
                    loop = false;
                    break;
                }
                A[i] = A[i] / 2;
            }
            if (loop) {
                ++cnt;
            }
        }

        out << cnt << endl;
    }
};


int main() {
	BShiftOnly solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  string S; cin >> S;
  
  int ans = 0;
  
  rep(i, N-1) {
    string X = S.substr(0, i+1);
    string Y = S.substr(i+1, N-i-1);
    
    unordered_map<char,int> xmap, ymap;
    
    rep(j, X.size()) xmap[X[j]]++;
    rep(j, Y.size()) ymap[Y[j]]++;
    
    int a = 0;
    
    for(auto p : xmap) if(ymap[p.first] > 0) a++;
    
    ans = max(ans, a);
  }
  
  cout << ans << endl;
  

}


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

#ifdef DEBUG
#define DEBUG_LOG(fmt, ...)   printf(fmt, ##__VA_ARGS__)
#else
#define DEBUG_LOG(fmt, ...)
#endif

struct P3 {
    bool enable;
    P3() { enable = false; }
};

struct P2 {
    bool enable;
    P3 p3[10];
    P2() { enable = false; }
};

struct P1 {
    bool enable;
    P2 p2[10];
    P1() { enable = false; }
};

using namespace std;
int main()
{
    uint32_t n, ans=0;
    P1 p1[10];
    char lnum[30001];

    scanf(" %u", &n);
    scanf(" %s", lnum);
    DEBUG_LOG("%u %s\n", n, lnum);

    int i1, i2;
    char *cp;
    uint32_t num;

    for (cp=lnum; *cp!='\0'; cp++) {
        num = *cp - '0';

        for (i1=0; i1<10; i1++) {
            if (p1[i1].enable) {
                for (i2=0; i2<10; i2++) {
                    if (p1[i1].p2[i2].enable) {
                        bool& p3enable = p1[i1].p2[i2].p3[num].enable;
                        if (p3enable == false) {
                            p3enable = true;
                            ans++;
                            DEBUG_LOG("ans++ %u %u %u\n", i1, i2, num);
                        }
                    }
                }
                p1[i1].p2[num].enable = true;
            }
        }
        p1[num].enable = true;
    }
    printf("%u\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx, y = ty - sy;
        for(int i = 0; i < y; i++) cout << 'U';
        for(int i = 0; i < x; i++) cout << 'R';
        for(int i = 0; i < y; i++) cout << 'D';
        for(int i = 0; i < x; i++) cout << 'L';
        
        cout << 'L';
        for(int i = 0; i < y+1; i++) cout << 'U';
        for(int i = 0; i < x+1; i++) cout << 'R';
        cout << 'D';
        cout << 'R';
        for(int i = 0; i < y+1; i++) cout << 'D';
        for(int i = 0; i < x+1; i++) cout << 'L';
        cout << 'U';
        cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;


int main()
{
  ll N, W;
  cin >> N >> W;
  vector<pll> vw(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> vw.at(i).first >> vw.at(i).second;
  }
  vector<ll> dp(W + 1, 0);
  for (ll i = 0; i < W; ++i)
  {
    for (ll j = 0; j < N; ++j)
    {
      if (i + vw.at(j).second <= W)
      {
        dp.at(i + vw.at(j).second) = max(dp.at(i + vw.at(j).second), dp.at(i) + vw.at(j).first);
      }
    }
  }
  cout << dp.at(W) << endl;
}



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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    if(int(s[0])>96 && int(s[0])<123){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }


}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
#define mod 1000000007
/****************************/
using namespace std;
int n,m;
vi g[200010];
bool vis[200010];
ll ans=0,res=0;;
void dfs(int x)
{
	vis[x]=true;
	res++;
	rep(i,g[x].size())
	{
		if(!vis[g[x][i]])
		{
			dfs(g[x][i]);
		}
	}
	return;
}
int main()
{
	zero(vis);
	cin>>n>>m;
	ll now=0;
	rep(i,m)
	{
		ll a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	rep(i,n)
	{
		if(!vis[i])
		{
			res=0;
			dfs(i);
			ans=max(ans,res);
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
	int n; cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	rep(i, n) cin >> x[i] >> u[i];
	double ans = 0;
	rep(i, n) {
		if (u[i] == "JPY") {
			ans += x[i];
		}
		else {
			ans += x[i] * 380000;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main 
{
  	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long temp = 1;

		for(long i = 2; i <= n; i++)
		{
			temp *= i;
			temp = temp % 1000000007;
		}

		System.out.println(temp);
  	}
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	string s;
	string t;
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b));
	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// dp[r][g][b]: r,b,gがそれぞれ赤,緑,青を最後に塗ったマスの座標である塗り方の総数
// 座標i+1を例えば赤で塗るときはdp[i+1][g][b] += dp[r][g][b]とすればいい
// 条件チェックはk=max(r,g,b)としてr==kの条件だけ確認して、アウトならdp[r][g][b]を0にするようにする
int n, m, l, r, x, dp[301][301][301], ans;
vpii c[301];

bool inc(int t) {return l<=t && t<=r;}

signed main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> l >> r >> x;
		c[r].pb({l,x});
	}
	dp[0][0][0] = 1;
	rept(i,n) rept(j,n) rept(k,n) {
		if (dp[i][j][k]==0) continue;
		int mx = tmax(i,j,k);
		// 条件チェック
		each(p,c[mx]) {
			tie(l,x) = p, r = mx;
			if (inc(i) + inc(j) + inc(k) != x) {
				dp[i][j][k] = 0;
				continue;
			}
		}
		if (mx==n) {
			(ans += dp[i][j][k]) %= mod;
			continue;
		}
		(dp[mx+1][j][k] += dp[i][j][k]) %= mod;
		(dp[i][mx+1][k] += dp[i][j][k]) %= mod;
		(dp[i][j][mx+1] += dp[i][j][k]) %= mod;
	}
	cout << ans << ln;
}

Measured memory_bytes: 106752
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <valarray>
#include <iterator>
#include <stack>
#include <set>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <list>
#include <map>
#include <strstream>
#include <streambuf>
#include <string>
#include <sstream>
//#include "graph.cpp"

#define vi vector<int>
#define vii vector< pair<int,int> >
#define last(arr) arr.size()-a
#define loop(i,n) for(ll i=0 ; i<n ; ++i)
#define all(v) ((v).begin()),((v).end())
#define pb push_back
#define ll long long
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a > b){
        cout<<a-1<<endl;
    }else{
        cout<<a<<endl;
    }
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readInputLine().split(" ").map { it.toInt() }
    
    for (i in 0..w + 1) {
        print('#')
    }
    
    print('\n')
    
    for (i in 0 until h) {
        print('#')
        val aList = readInputLine().split(" ")
        for (a in aList) {
            print(a)
        }
        println("#")
    }
    
    for (i in 0..w + 1) {
        print('#')
    }
    
    print('\n')
}
 
fun readInputLine(): String {
    return readLine()!!
}

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

int main() {
  int n;

  cin >> n;

  int i;
  int h[n + 1];
  rep(i,1,n + 1) cin >> h[i];

  long long dp[n + 1];

  rep(i,0,n + 1) dp[i] = 100100100100;

  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);

  rep(i,3,n + 1) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),dp[i - 2] + abs(h[i] - h[i - 2]));

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int poor=0;
	if(a==b&&b!=c) poor=1;
	if(b==c&&c!=a) poor=1;
	if(c==a&&a!=b) poor=1;
	if(poor)
	{
		puts("Yes");
		
	}
	else
	{
		puts("No");
	}
	return 0;
}

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

int M;

int lcm(int a,int b)
{
   int res=a/__gcd(a,b);
   //res*b<=M
   if(res<M/b or (res==M/b and res*b<=M)){
      res*=b;
   }else{
      res=M+1;
   }
   return res;
}

signed main()
{
   int N; cin>>N>>M;
   vector<int> a(N),p(N);
   for(int i=0;i<N;i++) cin>>a[i];
   for(int i=0;i<N;i++) cin>>p[i];

   double ans=0.0;
   for(int S=1;S<(1<<N);S++){
      int l=1,c=0;
      double q=1.0;
      for(int i=0;i<N;i++){
         if(~S>>i&1) continue;
         l=lcm(l,a[i]);
         c++;
         q*=1.0*p[i]/100;
      }
      int k=M/l;
      if(c&1) ans+=1.0*k*q;
      else    ans-=1.0*k*q;
   }
   cout<<fixed<<setprecision(10)<<ans<<endl;
}




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

int main() {
  long long int N;
  string S;
  cin >> N >> S;
  
  for (int i = 0; i < S.size(); i++) {
    S[i] += (N % 26);
    if (S[i] > 'Z') S[i] -= 26;
  }
  
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
#define X real()
#define Y imag()
#define EPS (1e-10)
using namespace std;

typedef complex<double> Point; // 点
typedef Point Vector; // ベクトル

struct Segment{ // 線分
  Point p1, p2;
  Segment(){};
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}; // p1,p2をセット
};

typedef Segment Line; // 直線

typedef vector<Point> Polygon; // 多角形

double dotproduct(Vector a, Vector b) // 内積
{
  return real((conj(a) * b));
}

double crossproduct(Vector a, Vector b) // 外積
{
  return imag(conj(a) * b);
}

double dist(Point p1, Point p2) // 二点間の距離
{
  return abs(p1 - p2);
}

Point project(Line l, Point p){ // 射影
  double r = dotproduct(p - l.p1, l.p2 - l.p1) / norm(l.p2 - l.p1);
  return l.p1 + (l.p2 - l.p1) * r;
}

#define EQ(a, b) (abs((a) - (b)) < EPS) // 二つのスカラーが等しいかどうか
#define EQV(a, b) (EQ((a).X, (b).X) && EQ((a).Y, (b).Y)) // 二つのベクトルが等しいかどうか

int main()
{
  Point p, q;
  cin >> p.X >> p.Y >> q.X >> q.Y;
  Line l(p,q);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    Point x;
    cin >> x.X >> x.Y;
    printf("%.10lf %.10lf\n", project(l, x).X, project(l, x).Y);
  }
}

Measured memory_bytes: 1272
from math import gcd
K = int(input())
ans = 0
for i in range(1,K + 1):
    for j in range(1,K + 1):
        if gcd(i,j) == 1: ans += K
        else:
            for k in range(1,K + 1):
                ans += gcd(gcd(i,j),k)
print(ans)


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> a(n), v_front(n), v_back(n);
    for (size_t i = 0; i < n; i++) cin >> a[i];

    int m = 0;
    for (int i = 0; i < n; i++) {
        v_front[i] = m;
        m = max(m, a[i]);
    }

    m = 0;
    for (int i = n-1; i >= 0; i--) {
        v_back[i] = m;
        m = max(m, a[i]);
    }

    for (size_t i = 0; i < n; i++) {
        cout << max(v_front[i], v_back[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 5580
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        double r = scanner.nextDouble();
        
        double area = Math.PI * r * r;
        double around = 2 * Math.PI * r;
        
        String str_area = String.format("%.5f", area);
        String str_around = String.format("%.5f", around);
        
        System.out.println(str_area + " " + str_around);

        
    }

}


Measured memory_bytes: 28064
n, m = gets.split().map(&:to_i)
a = Array.new
n.times do |i|
  a[i] = gets.chomp
end
f = true
m.times do |i|
  b = gets.chomp
  if ! a[i].index(b)
    f = false
  end
end
if f
  puts "Yes"
else
  puts "No"
end


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

int main() {
    int N;
    cin >> N;
    map<string, int> words;
    int count = 0;
    for (int i=0; i<N; i++) {
        string s;
        cin >> s;
        if (!(words.count(s))) {
            words[s] = 1;
        }
    }
    cout << words.size();
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}

struct node 
{ 
   int minimum; 
   int maximum; 
}; 
  

int getMid(int s, int e) {  return s + (e -s)/2;  } 
  
struct node MaxMinUntill(struct node *st, int ss, int se, int qs, 
                         int qe, int index) 
{ 
    
    struct node tmp,left,right; 
    if (qs <= ss && qe >= se) 
        return st[index]; 
  
    
    if (se < qs || ss > qe) 
    { 
       tmp.minimum = INT_MAX; 
       tmp.maximum = INT_MIN; 
       return tmp; 
     } 
  
    int mid = getMid(ss, se); 
    left = MaxMinUntill(st, ss, mid, qs, qe, 2*index+1); 
    right = MaxMinUntill(st, mid+1, se, qs, qe, 2*index+2); 
    tmp.minimum = min(left.minimum, right.minimum); 
    tmp.maximum = max(left.maximum, right.maximum); 
    return tmp; 
} 
  
 
struct node MaxMin(struct node *st, int n, int qs, int qe) 
{ 
    struct node tmp; 
  
    if (qs < 0 || qe > n-1 || qs > qe) 
    { 
        printf("Invalid Input"); 
        tmp.minimum = INT_MIN; 
        tmp.minimum = INT_MAX; 
        return tmp; 
    } 
  
    return MaxMinUntill(st, 0, n-1, qs, qe, 0); 
} 
  
void constructSTUtil(int arr[], int ss, int se, struct node *st, int si) 
{ 
    if (ss == se) 
    { 
        st[si].minimum = arr[ss]; 
        st[si].maximum = arr[ss]; 
        return ; 
    } 
  
    int mid = getMid(ss, se); 
    constructSTUtil(arr, ss, mid, st, si*2+1); 
    constructSTUtil(arr, mid+1, se, st, si*2+2); 
  
    st[si].minimum = min(st[si*2+1].minimum, st[si*2+2].minimum); 
    st[si].maximum = max(st[si*2+1].maximum, st[si*2+2].maximum); 
} 
  
struct node *constructST(int arr[], int n) 
{ 
    int x = (int)(ceil(log2(n))); 
  
    int max_size = 2*(int)pow(2, x) - 1; 
  
    struct node *st = new struct node[max_size]; 
  
    constructSTUtil(arr, 0, n-1, st, 0); 
  
    return st; 
} 


int main()
{ 
	string s; cin>> s;
	
	rep(i,0,3){
		if(i+1<= 3 && s[i] == s[i+1]){
			
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
	return 0; 
} 


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

//最大公約数を求める
long long int gcd(long long int x, long long int y){
    if(x>y){
        long long int swap = x;
        x = y;
        y = swap;
    }
    while(true){
        if(y%x==0){
            return x;
        }else{
            long long int amari = y%x;
            y = x;
            x = amari;
        }
    }
}

int main(void){
    int k;
    long long ans=0, tmp;
    cin >> k;
    
    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c=1; c<=k; c++){
                tmp = gcd(gcd(a,b), c);
                ans += tmp;
            }
        }    
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    string T;
    cin >> S >> T;

    int count = 0;
    for(int i=0; i<3; i++){
        if(S.at(i) == T.at(i)){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val n = nextLong()
    var ans = LINF
    for (a in 1..n) {
        if (a * a > n) break
        if (n % a != 0L) continue
        val b = n / a
        val step = a + b - 2
        ans = min(ans, step)
    }

    println(ans)

}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =
    listOf(a, b, c, d, e).max()!!.toLong()

fun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =
    listOf(a, b, c, d, e).min()!!.toLong()


Measured memory_bytes: 36332
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	long H;
	std::cin >> H;
	
	long n = 1;
	long result = 0;
	while (H > 0) {
		result += n;
		n *= 2;
		H = H / 2;
	}
	std::cout << result << "\n";
}


Measured memory_bytes: 256
let solve w =
  let rec doit i s acc =
    let g = 2. ** float i |> truncate in
    if g = s then g :: acc
    else if g > s then doit (i - 1) s acc
    else doit (i - 1) (s - g) (g :: acc) in
  doit 9 w []

let () =
  try
    while true do
      read_int ()
      |> solve
      |> List.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e);
      print_newline ()
    done
  with _ -> ()

Measured memory_bytes: 2264
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    int ans = 0;
    rep(i,n) {
        int mid = b[i];
        int aa = lower_bound(a.begin(),a.end(),mid)-a.begin();
        int cc = c.end()-upper_bound(c.begin(),c.end(),mid); 
        // cout << aa<<" "<<cc << endl;
        ans += (aa)*(cc);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5572
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <string.h>
#include <climits>
using namespace std;
int main() {cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    long long a[n];
    long long ans;
    long long sum=0;
    long long s=0;
    for(int i=0;i<n;++i){
        cin>>a[i];
        sum+=a[i];
    }
    ans=LLONG_MAX;
    for(int i=0;i<n-1;++i){
        s+=a[i];
        ans=min(ans,abs(2*s-sum));
    }
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
r, c = (int(i) for i in input().split())
table = tuple([int(x) for x in input().split()] for _ in range(r))
for cols in table:
  cols.append(sum(cols))
  print(*cols)
sums = tuple(sum(table[y][x] for y in range(r)) for x in range(c + 1))
print(*sums)

Measured memory_bytes: 8236
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 12:30-
int N;
string S[2];
const LL MOD=1000000007;
void solve() {
  LL res=1;
  if(S[0][0]==S[1][0]) res=3;
  else res=6;
  
  FOR(i,1,N) if(S[0][i]!=S[0][i-1]) {
    if(S[0][i]==S[1][i]) {
      // *
      // *
      if(S[0][i-1]==S[1][i-1]) res*=2;
    } else {
      // **
      // @@
      if(S[0][i-1]==S[1][i-1]) res*=2;
      else res*=3;
    }
    res%=MOD;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,2) cin>>S[i];
  solve();
  return 0;
}


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

int read(){
	int a = 0; char c = getchar(); while(!isdigit(c)) c = getchar();
	while(isdigit(c)){a = a * 10 + c - 48; c = getchar();} return a;
}

const int _ = 2e6 + 7;
int N , K , P[_] , tmp[_]; priority_queue < int > q;

#define mid ((l + r) >> 1)
#define lch (x << 1)
#define rch (x << 1 | 1)
int mn[_] , mrk[_];
void mark(int x , int v){mn[x] += v; mrk[x] += v;}
void down(int x){if(mrk[x]){mark(lch , mrk[x]); mark(rch , mrk[x]); mrk[x] = 0;}}

void ins(int x , int l , int r , int t){
	if(l == r){mn[x] = 0; return;}
	down(x); mn[x] = 0; mid >= t ? ins(lch , l , mid , t) : ins(rch , mid + 1 , r , t);
}

void add(int x , int l , int r , int L , int R , int v){
	if(l >= L && r <= R) return mark(x , v);
	down(x);
	if(mid >= L) add(lch , l , mid , L , R , v);
	if(mid < R) add(rch , mid + 1 , r , L , R , v);
	mn[x] = min(mn[lch] , mn[rch]);
}

void find(int x , int l , int r){
	if(mn[x]) return;
	if(l == r){mn[x] = 1e9; q.push(l); return;}
	down(x); find(lch , l , mid); find(rch , mid + 1 , r); mn[x] = min(mn[lch] , mn[rch]);
}

int main(){
	N = read(); K = read(); for(int i = 1 ; i <= N ; ++i) P[read()] = i;
	for(int i = 1 ; i <= N ; ++i){
		add(1 , 1 , N , max(1 , P[i] - K + 1) , min(N , P[i] + K - 1) , 1);	ins(1 , 1 , N , P[i]);
	}
	find(1 , 1 , N); vector < int > ans;
	while(!q.empty()){
		int t = q.top(); q.pop(); ans.push_back(t);
		add(1 , 1 , N , max(1 , t - K + 1) , min(N , t + K - 1) , -1); find(1 , 1 , N);
	}
	reverse(ans.begin() , ans.end());
	for(int i = 0 ; i < ans.size() ; ++i) P[ans[i]] = i + 1;
	for(int i = 1 ; i <= N ; ++i) printf("%d\n" , P[i]);
	return 0;
}

Measured memory_bytes: 24944
#include <iostream>
#include <map>

int main(int argc, char ** argv)
{
  //
  int n;
  std::cin >> n;

  std::map<std::string, int> m;
  for (int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    if (0 == m.count(s)) {
      m[s] = 1;
    } else {
      m[s] += 1;
    }
  }
  int max = 0;
  for (auto ite = m.begin(); ite != m.end(); ite++) {
    max = std::max(ite->second, max);
  }

  for (auto ite = m.begin(); ite != m.end(); ite++) {
    if (ite->second == max) {
      std::printf("%s\n", ite->first.c_str());
    }
  }
  return 0;
}


Measured memory_bytes: 17664
s = input()
count_1 = 0
count_0 = 0
ans = 0
for i in range(len(s)):
    if s[i] == "1":
        if count_0:
            ans += 2
            count_0 -= 1
        else:
            count_1 += 1
    else:
        if count_1:
            ans += 2
            count_1 -= 1
        else:
            count_0 += 1
print(ans)

Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):

    count = 1
    for i in range(N):
        if a[i] == count:
            count += 1

    if count == 1:
        print(-1)
    else:
        print(N - count + 1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25984
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,l[222];
	long long ans=0;
	cin>>n;
	for(int i=1;i<=2*n;i++)
		scanf("%d",&l[i]);
	sort(l+1,l+2*n+1);
	for(int i=1;i<=2*n;i++)
	if(i%2!=0)ans+=l[i];
  printf("%lld\n",ans);
}



Measured memory_bytes: 256