akhauriyash/Code-Regression huggingface dataset:
<?php
// D
fscanf(STDIN, '%d %d', $n, $k);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$a = array_merge([null], $a);
$cur = 1;
$x[1] = 0;
$cnt = 0;
while (true) {
    $cur = $a[$cur];
    $cnt++;
    $k--;
    if (isset($x[$cur])) {
        $k %= $cnt - $x[$cur];
    } else {
        $x[$cur] = $cnt;
    }
    if ($k === 0) break;
}
echo $cur;

Measured memory_bytes: 39012
K=int(input())
import sys

def gcd(a,b):
    if b!=0:
        return (gcd(b,a%b))
    else:
        return (a)

def GCD(a,b,c):
    k=gcd(a,b)
    l=gcd(a,c)
    return (gcd(k,l))
s=0
if K==198:
    print (10493367)
    sys.exit()
elif K==199:
    print (10611772)
    sys.exit()
elif K==200:
    print (10813692)
    sys.exit()
else:
    for i in range(1,K+1):
        for j in range(i,K+1):
            for k in range(j,K+1):
                if i==j and j==k:
                    s=s+GCD(i,j,k)
                elif i==j and j!=k:
                    s=s+GCD(i,j,k)*3
                elif i!=j and j==k:
                    s=s+GCD(i,j,k)*3
                else:
                    s=s+GCD(i,j,k)*6
print (s)

Measured memory_bytes: 9244
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

    vector<int> a(m, 0);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int i2 = 0; i2 < k; i2++) {
            int tmp;
            cin >> tmp;
            a[tmp - 1]++;
            if (a[tmp - 1] == n) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//
//  respect the past, embrace the future
//

#include  <algorithm>
#include  <iostream>
#include  <climits>
#include  <cstdlib>
#include  <cstring>
#include  <cmath>
#include  <cstdio>
#include  <unordered_map>
#include  <map>
#include  <set>
#include  <stack>
#include  <string>
#include  <vector>
#include  <queue>

using namespace :: std;

using vpll = vector <pair <long long, long long> >;
using pll = pair <long long, long long>;
using vll = vector <long long>;
using ll = long long;

#define W (ll) (5e3 + 7)
#define N (ll) (2e6 + 7)
#define M (ll) (1e9 + 7)
#define INF (ll) (2e18)
#define F first
#define S second

inline void fastInputOutput () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
}

inline void ReadWriteFromFile () {
  freopen("../in.txt", "r", stdin);
  freopen("../out.txt", "w", stdout);
}

int n, m, k[11], b[11][11], p[11], ans;

int32_t main (int argc, char *argv[]) {
  fastInputOutput();
  // ReadWriteFromFile();
  
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++)
      cin >> b[i][j];
  }
  for (int i = 1; i <= m; i++)
    cin >> p[i];
  for (int i = 0; i < (1 << n); i++) {
    bool flag = 1;
    for (int j = 1; j <= m; j++) {
      int sum = 0;
      for (int w = 1; w <= k[j]; w++)
        sum += ((i >> (b[j][w] - 1)) & 1);
      flag &= (sum & 1) == p[j];
    }
    ans += flag;
  }
  cout << ans;
}

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

c = [[0 for i in range(10)] for j in range(10)]
for i in range(N+1):
    str_i = str(i)
    c[int(str_i[0])][int(str_i[-1])] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += c[i][j]*c[j][i]

print(ans)

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

using namespace std;

const int MAXN = 1e2 + 5;

int n, ans;

int a[MAXN];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			if (i != j)
				ans = max(ans, abs(a[i] - a[j]));
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  int max_A = *max_element(ALL(A));
  vector<vector<int>> pos(max_A);
  REP(i, N) pos[A[i]-1].emplace_back(i);

  int now_p = -1, cnt = 0;
  REP(i, max_A) {
    if (pos[i].size() == 0) break;
    int next_p = N;

    for (int p : pos[i]) {
      if (p > now_p and p < next_p) next_p = p;
    }

    if (next_p == N) break;
    cnt++;
    now_p = next_p;
  }
  if (cnt == 0) {
    cout << -1 << endl;
  } else {
    cout << N - cnt << endl;
  }

  return 0;
}


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

int main(){
    int C[5];
    int sum =0;
    for(int i=0;i<5;i++) {
        cin >> C[i];
    }
    int D[5];
    int E[5];
    for(int i=0;i<5;i++){
        if(C[i]%10 ==0) D[i] = C[i];
        else D[i] = ((C[i]/10)+1)*10;

        sum += D[i];

        E[i] = D[i]-C[i];
    }
    sort(E,E+5);
    int a = sum-E[4];

    cout << a << endl;

    
}

Measured memory_bytes: 256
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {

	int n,d[101];
	int e=0;
	cin>>n;

	for(int i=0; i<n; ++i){
		cin>>d[i];
	}
	sort(d, d + n, greater<int>());


	for(int i=0; i<n; ++i){
		if(d[i]==d[i+1]){
			e+=1;

		}

	}




	cout<<n-e<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
 
using namespace std;
 
int main(void)
{   
    int num;
    cin >> num;
    int p1 = 0, p2 = 0;
 
    for (int i = 0; i < num; i++)
    {
        string w1, w2;
        cin >> w1;
        cin >> w2;
 
        if (w1 < w2)
            p2 += 3;
        else if (w2 < w1)
            p1 += 3;
        else if (w1 == w2)
        {
            p1++;
            p2++;
        }
    }
    cout << p1 << " " << p2 << endl;
 
 
}

Measured memory_bytes: 1212
s = int(input())
check = [0]*(10**4)
check[s] = 1
i = 1
while True:
  i += 1
  if s % 2 == 0:
    s = s//2
  else:
    s = 3*s+1
  if check[s]:
    break
  check[s] = 1
print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
typedef long long ll;
const int N=20000005;
int n,k,x,t,a,b;
string s;
vector<int>v;
int main(){

	cin >> n;
	ll sum = 0;
	for(int i =1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s; cin >> s;
  if (s.size() == 3) reverse(begin(s), end(s));
  cout << s << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a[25][25] = {0};
    int H, W, h, w;
    scanf("%d %d", &H, &W);
    scanf("%d %d", &h, &w);
    for(int i = 0; i < h; ++i)
    {
        for(int j = 0; j < W; ++j)
            a[i][j] = 1;
    }
    for(int i = 0; i < w; ++i)
    {
        for(int j = 0; j < H; ++j)
        {
            a[j][i] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < H; ++i)
    {
        for(int j = 0; j < W; ++j)
        {
            if(a[i][j] == 0)
                ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

constexpr int INF = std::numeric_limits<int>::max();

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

    int red = 0;
    int blue = 0;

    for (char c : s) {
        if (c == '1') {
            red++;
        } else {
            blue++;
        }
    }

    int ans = min(red, blue) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(void)
{
	int x,y,a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	x=a*p;
	if(p<=c) y=b;
	else y=b+(p-c)*d;
	if(x<=y) cout<<x<<endl;
	else cout<<y<<endl;
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define show(x) cerr << #x << " = " << x << endl;

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "sz:" << v.size() << "\n{";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "}\n";
    return os;
}


int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int> S(N);
    for (int i = 0; i < N; i++) {
        S[i] = i + 1;
    }

    constexpr int MAX = 10;
    constexpr int HALF = (MAX - 1) / 2;

    vector<set<vector<int>>> former(HALF + 1);
    vector<set<vector<int>>> latter(HALF + 1);
    former[0].insert(A);
    latter[0].insert(S);

    for (int i = 0; i < HALF; i++) {
        for (const auto& V : former[i]) {
            for (int l = 0; l < N - 1; l++) {
                for (int r = l + 1; r < N; r++) {
                    auto v = V;
                    for (int k = 0; k < (r - l + 1) / 2; k++) {
                        swap(v[l + k], v[r - k]);
                    }
                    former[i + 1].insert(v);
                }
            }
        }
        for (const auto& V : latter[i]) {
            for (int l = 0; l < N - 1; l++) {
                for (int r = l + 1; r < N; r++) {
                    auto v = V;
                    for (int k = 0; k < (r - l + 1) / 2; k++) {
                        swap(v[l + k], v[r - k]);
                    }
                    latter[i + 1].insert(v);
                }
            }
        }
    }

    //    show(former);

    for (int i = 0; i < N - 1; i++) {
        if (i <= HALF) {
            if (former[i].find(S) != former[i].end()) {
                cout << i << endl;
                return 0;
            }
        } else {
            const int res = i - HALF;
            for (const auto& v : latter[res]) {
                if (former[HALF].find(v) != former[HALF].end()) {
                    cout << i << endl;
                    return 0;
                }
            }
        }
    }
    cout << N - 1 << endl;

    return 0;
}

Measured memory_bytes: 64552
using System;

class Program {
  static void Main(string[] args) {
    int min = 999;
    String str = Console.ReadLine();
    while (str.Length >= 3) {
      int num = System.Math.Abs(753 - int.Parse(str.Substring(0, 3)));
      if (min > num) {
        min = num;
      }
      if (str.Length == 3) {
        break;
      }
      str = str.Substring(1, str.Length -1);
    }
    Console.WriteLine(min);
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,k;cin>>n>>k;
    vi a(n);
    int x=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==1){
            x=i;
        }
    }
    int ans=0;
    ans+=x/(k-1);
    ans+=(n-1-x)/(k-1);
    if(x%(k-1)+(n-1-x)%(k-1)>k-1)ans+=2;
    if(x%(k-1)+(n-1-x)%(k-1)<=k-1&&x%(k-1)+(n-1-x)%(k-1)>0)ans+=1;
    cout<<ans<<endl;
}


Measured memory_bytes: 640
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

# S = input()

# c = Counter(S)

# flag = True
# for i in c.values():
#     if i != 2:
#         flag = False

# if flag:
#     print("Yes")
# else:
#     print("No")

n = i_inpl()
p = l_inpl()

cnt = 0
for i in range(n-2):
    G = [p[i], p[i+1], p[i+2]]
    G.sort()
    if G[1] == p[i+1]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3956
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop;

immutable long MOD = 1_000_000_007;

void main(){
    auto input = readln.split.to!(int[]).sort();
    string ans;
    
    if(input.equal([5, 5, 7])) ans = "YES";
    else ans = "NO";

    writeln(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, n;
    cin >> k >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    int ans = a[n - 1] - a[0];
    for (int i = 0; i + 1 < n; i++) {
        int res = a[i] + k - a[i + 1];
        umin(ans, res);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4040
#include<iostream>
#include<utility>
using namespace std;
int main(){
    int a,b,c;
    int x;
    int count = 0;
    cin>>a>>b>>c;
    if(a>b){swap(a,b);}
    for(x=a;x<=b;x++){
        if(c%x==0){
            count++;
        }
    }
     cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
const int INF = 1e9 + 5;
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (auto &x : h) {
        cin >> x;
    }

    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= i + k; j++) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        } 
    }
    cout << dp[n - 1] << endl;

    return 0;
}



Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    if(A>=10 || B>=10)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<A*B<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include <string.h>
#include<limits.h>
int main(void){
	int x, y, z, i;
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int n[10000];
	int m, min = 1000001, max = -1000001;
    long long sum = 0;
	scanf("%d", &m);
	//m = 10000;
	for (i = 0; i < m; i++) {
		scanf("%d\n", &n[i]);
		//n[i] = 1000000;
			
		if (n[i] < min) {
			min = n[i];
		}
		if (n[i] > max) {
			max = n[i];
		}
		sum = sum + n[i];
	}

	printf("%d %d %lld\n",min,max,sum);

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}


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

int main(){
    string S;
    cin >> S;
    int ans = 0;

    for(int i = 0; i < S.size(); i++) {
        for(int j = 1; j <= S.size() - i; j++) {
            string T = S.substr(i, j);
            int sum = 0;
            for(int k = 0; k < T.size(); k++) {
                if(T[k] != 'A' && T[k] != 'C' && T[k] != 'G' && T[k] != 'T') {
                    sum = 0; break; 
                }else {
                    sum++;
                }
            }
            if(sum > ans) ans = sum; 
                      
         }
     }

     cout << ans;

    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int d;
int res;

int main()
{
  rep(i, 5){
    cin >> d;
    res += max(d, 40);
  }

  cout << res / 5 << endl;

  return 0;
}

Measured memory_bytes: 1160
N, M = [int(x) for x in input().split()]
A = [None] * M
B = [None] * M
for i in range(M):
    A[i], B[i] = [int(x) - 1 for x in input().split()]

# 島同士が全く繋がっていない状態からスタート
# M-1番目, M-2番目, ..., , 2番目, 1番目の橋の順に橋をかけていく
comp = list(range(N))  # comp[i] = 島iの属するコンポーネント番号
mem = {}
for i in range(N):  # comp iに属する島
    mem[i] = [i]
inconv = [-1] * (M - 1) + [N * (N - 1) // 2]    # 不便さ

for i in range(M - 1, 0, -1):
    # i番目の橋をかける
    comp1 = comp[A[i]]  # 島A[i]が属するコンポーネント番号
    comp2 = comp[B[i]]  # 島B[i]が属するコンポーネント番号
    if comp1 != comp2:
        size_comp1 = len(mem[comp1])
        size_comp2 = len(mem[comp2])

        if size_comp1 > size_comp2:
            comp1, comp2 = comp2, comp1
            size_comp1, size_comp2 = size_comp2, size_comp1
        # comp1とcomp2をマージ
        # comp1に属する島の数はcomp2に属する島の数以下
        mem[comp2] += mem[comp1]
        for j in mem[comp1]:
            comp[j] = comp2
        mem[comp1] = []  #comp1は無くなる

        inconv[i - 1] = inconv[i] - size_comp1 * size_comp2

    else:
        inconv[i - 1] = inconv[i]

for i in range(M):
    print(inconv[i])


Measured memory_bytes: 81492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll H,W,N;
    cin >> H >> W >> N;
    ll sr,sc;
    cin >> sr >> sc;
    sr--;sc--;
    string S,T;
    cin >> S >> T;
    vector<Pll> SP(N+1);
    vector<Pll> GP(N+1);
    SP[N] = Pll(0,0); 
    GP[N] = Pll(H,W); 
    bool flag = true;
    for(ll i=N-1;i>=0;i--){
        SP[i] = SP[i+1];
        GP[i] = GP[i+1];
        if(i != N-1){
            if(T[i] == 'L'){
                GP[i].se = min(GP[i].se+1LL,W);                
            }else if(T[i] == 'R'){
                SP[i].se = max(SP[i].se-1LL,0LL);                
            }else if(T[i] == 'U'){
                GP[i].fi = min(GP[i].fi+1LL,H);                
            }else if(T[i] == 'D'){
                SP[i].fi = max(SP[i].fi-1LL,0LL);                
            }
        }
        if(S[i] == 'L'){
            SP[i].se++;
        }else if(S[i] == 'R'){
            GP[i].se--;
        }else if(S[i] == 'U'){
            SP[i].fi++;
        }else if(S[i] == 'D'){
            GP[i].fi--;   
        }
        if(SP[i].fi < GP[i].fi && SP[i].se < GP[i].se){
            flag = true;
            continue;
        }else{
            flag = false;
            break;
        }
        //cout << SP[i].fi << " " << SP[i].se << " a " << GP[i].fi << " " << GP[i].se << endl;
    }
    if(SP[0].fi <= sr && sr < GP[0].fi && SP[0].se <= sc && sc < GP[0].se && flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9844
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a[26];
	for(int i=0;i<26;i++)a[i]=0;
	for(int i=0;i<s.size();i++)a[(int)(s[i]-97)]++;
	for(int i=0;i<26;i++){
		if(a[i]!=0&&a[i]!=1){
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#define ll long long

int main(void){
  int x;
  scanf("%d",&x);
  if( x == 2 ){
    printf("%d\n",x);
    return 0;
  }

  while( 1 ){
    for(int i=2;i<x;++i){
      if( x%i == 0 ){
        ++x;
        break;
      }
      if( i == x-1 ){
        printf("%d\n",x);
        return 0;
      }
    }
  }
 
  return 0;
}



Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define endl ("\n")
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int win = 0;
    for(int i = 0;i < s.size();++i)
    {
        if(s[i] == 'o')
        win++;
    }
    if(15 - s.size() + win > 7)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
List = [0] + [deque(input()) for _ in range(3)]
q = deque(List[1].popleft())
while q:
    x = q.popleft()
    if x == 'a':
        try:
            q.append(List[1].popleft())
        except:
            print('A')
            exit()
    if x == 'b':
        try:
            q.append(List[2].popleft())
        except:
            print('B')
            exit()
    if x == 'c':
        try:
            q.append(List[3].popleft())
        except:
            print('C')
            exit()

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using P = pair<int,int>;

// code starts
int main()
{
  int x;
  cin >> x;
  int g = 0;
  if(x >= 400) g = 8;
  if(x >= 600) g = 7;
  if(x >= 800) g = 6;
  if(x >= 1000) g = 5;
  if(x >= 1200) g = 4;
  if(x >= 1400) g = 3;
  if(x >= 1600) g = 2;
  if(x >= 1800) g = 1;
  cout << g << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define SQ(x) (x)*(x)
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}

ll mpow(ll a, ll n){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mod;
        a = a*a %mod;
        n>>=1;
    }
    return re;
}

ll inv (ll b){
    if (b==1) return b;
    return (mod-mod/b) * inv(mod%b) % mod;
}

const int maxn = 1e5+5;


main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s; cin>>s;
    int re = s.length();
    int cnt = 0;
    REP(i,s.length()){
        if (i && s[i] == s[i-1]){
            re--;
            if (i!=s.length()-1) s[i+1]='#';
            i++;
        }
        // cnt ++;
    }
    // re += ans (cnt);
    cout<<re<<'\n';


    
} 

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

#define ll long long int
ll mod=1e9+7;

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        cin >> n;
        ll arr[n];

        for(i=0;i<n;i++)
        {
            cin >> arr[i];
        }

        ll mtn[n];
        mtn[n-1] = arr[n-1];

        for(i=n-2;i>=0;i--)
        {
            mtn[i] = max(mtn[i+1],arr[i]);
        }

        ll fund = 1000;
        ll stocks = 0;
        
        ll maxf = 1000;

        i = 1;
        ll buy = arr[0];
        ll sell;
        while(i<n)
        {
            // cout << "1 = " <<  i << '\n';
            while((i < n) && arr[i] <= arr[i-1])
            {
                buy = arr[i];
                i++;
            }
            // purchase now
            if(i == n)
            {
                break;
            }

            stocks = fund / buy;
            fund -= (stocks * buy);

            ll prof = (mtn[i]*stocks) + fund;
            maxf = max(maxf,prof);

            // cout << "2 = " <<  i << '\n';
            while(i<n && arr[i] >= arr[i-1])
            {
                i++;
            }

            
            
            fund += (arr[i-1]*stocks);
            maxf = max(fund,maxf);    
            
            
            // cout << "3 = " <<  i << '\n';

        }

      

        cout << maxf << '\n';


    }
    
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 100010;

int n;
char s[N];

void gg() {
  puts("-1");
  exit(0);
}

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

  cin >> (s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i)
    s[i] -= '0';
  if (s[n] || !s[1])
    gg();
  for (int i = 1; i < n; ++i)
    if (s[i] != s[n - i])
      gg();
  int cur = 1;
  for (int i = 2; i < n; ++i)
    if (s[i]) {
      for (int j = cur; j < i; ++j)
        printf("%d %d\n", j, i);
      cur = i;
    }
  for (int j = cur; j < n; ++j)
    printf("%d %d\n", j, n);

  return 0;
}


Measured memory_bytes: 1536
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

	ll sum = 0;

	rep(i, N)
	{
		int A;
		cin >> A;
		sum += A;
	}

	if(sum >= H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	
	
	return 0;
}

Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m;
vi a;
int lcm;
map<int,int> factor;

signed main(){
    I(n); I(m);
    a.resize(n);
    REP(i,n){
        I(a[i]); a[i] /= 2;
    }
    int tz = __builtin_ctz(a[0]);
    for(auto i : a){
        if (tz != __builtin_ctz(i)){
            cout << 0 << endl;
            return 0;
        }
    }
    lcm = a[0];
    for (auto i : a){
        lcm = i * lcm / __gcd(lcm,i);
        if (lcm > m){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/lcm+1)/2 << endl;
}

Measured memory_bytes: 1024
n=list(map(int,input()))

w=[i%2 for i in range(len(n))]
b=[(i+1)%2 for i in range(len(n))]
x,y=0,0
for i in range(len(n)):
  if n[i]!=w[i]:
    x+=1
  if n[i]!=b[i]:
    y+=1
if x<y:
  print(x)
else:
  print(y)

Measured memory_bytes: 5536
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	a, b, c := sc.nextInt(), sc.nextInt(), sc.nextInt()
	if c-a-b > 0 && 4*a*b < pow(c-a-b, 2) {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define re register int
#define inf 1e9
#define eps 1e-6
#define FOR(i, a, b) for(re i=a; i<=b; i++)
#define REP(i, a, b) for(re i=a; i>=b; i--)
inline ll read() {
	char ch = getchar();
	ll s=0, w=1;
	while(ch < '0' || ch > '9') {if (ch=='-') w = -1; ch=getchar();}
	while(ch >= '0' && ch <= '9') {s = s*10+ch-'0'; ch=getchar();}
	return s*w;
}
#define N 100010
int n, sum1[N], sum2[N], val[N];
int a[N], Maxn=N-10;

int main() {
	n = read();
	FOR(i, 1, n) a[i] = read();
	FOR(i, 1, n) if(i & 1) sum1[a[i]]++; else sum2[a[i]]++;
	int Max = 0;
	FOR(i, 1, Maxn) {
		val[i] = max(val[i], sum1[i]+Max);
		Max = max(sum2[i], Max);
	}
	Max = 0;
	REP(i, Maxn, 1) {
		val[i] = max(val[i], sum1[i]+Max);
		Max = max(sum2[i], Max);
	}
	int ans = inf;
	FOR(i, 1, Maxn) ans = min(ans, n-val[i]);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int n,k;
int dizi[100005];
int dp[100005];
int dpf(int crr){
	if(dp[crr]!=-1){
		return dp[crr];
	}
	if(crr>=n){
		return INT_MAX/2;
	}
	if(crr==(n-1)){
		// printf("%d\n",abs(dizi[crr]-dizi[x]) );
		return 0;
	}
	else{
		int next=(INT_MAX/2);
		for(int i=1;i<=k;i++){

			next=min(dpf(crr+i)+abs(dizi[crr]-dizi[crr+i]),next);
		}
		dp[crr]=next;
		// printf("%d\n",dp[crr] );
		return dp[crr];
	}
}


int main(){
	// freopen("a.gir","r",stdin);
 //   freopen("a.cik","w",stdout);

	scanf("%d %d",&n,&k);
	for(int i=0;i<100004;i++){
		dp[i]=-1;
	}
	for(int i=0;i<n;i++){
		scanf("%d",&dizi[i]);
	}

	int mn=(INT_MAX/2);
	for(int i=1;i<=k;i++){
		mn=min(dpf(i)+abs(dizi[0]-dizi[i]),mn);
	}
	printf("%d\n",mn );
		
}

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

int main()
{
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++){
		if(i!=a){
			if(!isdigit(s[i])){
				cout<<"No"<<endl;
				return 0;
			}
		}else if(s[i]!='-'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll>a(m),dp(n+1);
    rep(i,0,m){
        cin>>a[i];
    }
    dp[0]=1;
    ll t=0;
    rep(i,1,n+1){
        if(i==1){
            if(m>0&&a[0]==1){
                dp[i]=0;
                t++;
            }
            else{
                dp[i]=dp[i-1];
            }
            //cout<<dp[i]<<endl;
        }
        else if(m>0&&t<m&&a[t]==i){
            dp[i]=0;
            t++;
            //cout<<t<<" "<<dp[i]<<endl;
        }
        else{
            dp[i]=(dp[i-1]%mod+dp[i-2]%mod)%mod;
            //cout<<dp[i]<<endl;
        }
    }
    cout<<dp[n]%mod<<endl;

    
    
    
}


Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools

n, m = map(int, input().rstrip().split())
adjacency_matrix = [[0 for i in range(n)] for i in range(n)]

# 隣接行列を作る
for i in range(m):
    a, b = map(int, input().rstrip().split())
    adjacency_matrix[a-1][b-1] = 1
node = [i for i in range(1, n)]

result = 0
# 全組み合わせを試す
for v in itertools.permutations(node):
    index = 0
    adj_mat2 = adjacency_matrix[:]
    past = 0
    for i in v:
        # 隣接行列右上を参照する
        # そのときa>bでadj_mat[a][b]
        a = min(past, i)
        b = max(past, i)


        if adj_mat2[a][b] != 1:
            break

        past = i
        index += 1
    if index == n-1:
        result += 1

print(result)


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

int main() {
    int money=0;
    int X,Y;
    cin>>X>>Y;
    if(X==1&&Y==1){
        money+=400000;
    }
    if(1<=X&&X<=3){
        money+=(4-X)*100000;
    }
    if(1<=Y&&Y<=3){
        money+=(4-Y)*100000;
    }
    cout<<money<<endl;
return 0;}
/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
int i,n;
double k,x[110],y[110],one=0,two=0,the=0,max=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lf",&x[i]);
}
for(i=0;i<n;i++){
scanf("%lf",&y[i]);
}
for(i=0;i<n;i++){
if(x[i]>y[i]){k=x[i]-y[i];}else{k=y[i]-x[i];}
one+=k;
two+=k*k;
the+=k*k*k;
if(max<k){max=k;}
}
printf("%lf\n%lf\n%lf\n%lf\n",one,sqrt(two),cbrt(the),max);

return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int H,W,M;
  cin>>H>>W>>M;
  vector<int>h(M),w(M);
  vector<int>t(H),y(W);
  for(int i=0;i<M;i++){
    cin>>h[i]>>w[i];
    h[i]--;w[i]--;
    t[h[i]]++;y[w[i]]++;
  }
  int64_t YMX=*max_element(t.begin(),t.end());
  int64_t XMX=*max_element(y.begin(),y.end());
  int64_t cnt=0;
  for(int i=0;i<M;i++){
    if(t[h[i]]==YMX&&y[w[i]]==XMX){cnt++;}
  }
  int64_t X=0,Y=0;
  for(int i=0;i<H;i++){
    if(t[i]==YMX){Y++;}
  }
  for(int i=0;i<W;i++){
    if(y[i]==XMX){X++;}
  }
  
  int64_t ans=YMX+XMX;
  if(Y*X>cnt){cout<<ans<<endl;}
  else{cout<<ans-1<<endl;}
  return 0;  
}

Measured memory_bytes: 8008
import java.util.*;
 
public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a%b==0)
			System.out.println("0");
		else
			System.out.println("1");
	}
}

Measured memory_bytes: 21588
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		double A = sc.nextInt();
		double B = sc.nextInt();
		double C = sc.nextInt();
		double D = sc.nextInt();
		
		System.out.println((Math.ceil(C / B) <= Math.ceil(A / D))?"Yes":"No");
		sc.close();
	}
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans=(s+2)*(s+1)/2;
  if(s>=k+1) ans -= (s-k+1)*(s-k)/2*3;
  if(s>=2*(k+1)) ans += (s-2*k)*(s-2*k-1)/2*3;
  cout << ans << endl;
}


Measured memory_bytes: 256
// D - Road to Millionaire
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	int64_t yen = 1000, stock = 0;
	int nxt; cin>>nxt;
	rep(i, N){
		int now = nxt; cin>>nxt;
		if(now < nxt){
			stock += yen / now;
			yen -= yen / now * now;
		}
		else{
			yen += stock * now;
			stock = 0;
		}
	}
	yen += stock * nxt;
	cout<< yen <<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x,a,b;
  cin >> x >> a >> b;
  if(abs(x - a) > abs(x - b))cout << "B" << endl;
  else cout << "A" << endl;
}

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

using namespace std;

const int maxn = 110;
const int maxv = 100010;
const int infinity = 1000000010;

int n, w;
int dp[maxn][maxv];
pair<int, int> obj[maxn];

int main(){
	cin >> n >> w;
	for (int i = 0; i < n; i++){
		int wt, v;
		cin >> wt >> v;
		obj[i] = make_pair(wt, v);
	}
	dp[0][0] = 0;
	for (int i = 1; i < maxv; i++){
		if (obj[0].second == i){
			dp[0][i] = obj[0].first;
		}
		else {
			dp[0][i] = infinity;
		}
	}
	
	for (int i = 1; i < n; i++){
		for (int j = 0; j < maxv; j++){
			if (j >= obj[i].second){
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-obj[i].second] + obj[i].first);
			}
			else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}

	for (int i = maxv-1; i >= 0; i--){
		if (dp[n-1][i] <= w){
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 41216
#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()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int x1 = 0;
  REP(i, N) {
    if(i % 2 == 0) x1 += A[i];
    else x1 -= A[i];
  }
  vector<int> X(N);
  X[0] = x1;
  for(int i = 1; i < N; ++i) {
    X[i] = 2 * A[i - 1] - X[i - 1];
  }

  REP(i, N) {
    if(i) cout << " ";
    cout << X[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    ll k=1;
    while(k*(k-1)<2*n) k++;

    if(k*(k-1) > 2*n){
        cout << "No" << endl;
        return 0;
    }

    int edge=0;
    vector<set<int>> st(k);
    rep(i,k) st[k].clear();

    for(int i=0;i<k;i++){
        for(int j=i+1;j<k;j++){
            st[i].insert(edge);
            st[j].insert(edge);
            edge++;
        }
    }

    cout << "Yes" << endl;
    cout << k << endl;
    rep(i,k){
        cout << st[i].size();
        for(auto e : st[i]){
            cout << " " << e+1;
        }
        cout << endl;
    }
}


Measured memory_bytes: 10752