akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

int modpow(int a, int n, int mod) {
    int res=1;
    while(n>0) {
        if(n&1) res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
int modinv(int a,int mod){
    return modpow(a,MOD-2,MOD);
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,b; cin>>n>>b; int r=n-b;

    for(int k=1; k<=b; k++){
        int res=1;
        for(int i=r+1; i>r+1-k; i--){
            res*=i; res%=MOD;
        }
        for(int i=1; i<=k; i++){
            //res*=modpow(i,MOD-2,MOD); res%=MOD;
            res*=modinv(i,MOD); res%=MOD;
        }
        for(int i=b-1-k+1+1; i<=b-1; i++){
            res*=i; res%=MOD;
        }
        for(int i=1; i<=k-1; i++){
            res*=modinv(i,MOD); res%=MOD;
        }
        cout<<res<<endl;
    }
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

// エラトステネスのふるい
// min_prime[x] = x の最小の素因数
// x が素数なら 1、x = 0,1 なら 0
const ll N = 1000010;
vector<ll> min_prime(N, 1);

void sieve(){
    min_prime[0] = 0;
    min_prime[1] = 0;
    for(int i=2; i*i <= N; i++){
        if(min_prime[i] == 1){
            for(int j=2; i*j <= N; j++){
                if(min_prime[i*j] == 1) min_prime[i*j] = i;
            }
        }
    }
}

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

int main(){
    sieve();

    ll n; cin >> n;
    VL a(n);
    rep(i,n) cin >> a[i];

    vector<set<ll>> S(n);
    rep(i,n){
        ll cur = a[i];
        bool flag = true;

        if(cur==1) continue;

        while(flag){
            ll x = min_prime[cur];
            if(x == 1){
                S[i].insert(cur);
                flag = false;
            }else{
                S[i].insert(x);
                cur /= x;
            }
        }
    }

    VL prime_factor_count(N,0);
    rep(i,n){
        for(auto x : S[i]){
            prime_factor_count[x]++;
        }
    }

    bool not_coprime = false;
    bool not_pairwise = false;
    rep(i,N){
        if(prime_factor_count[i] == n) not_coprime = true;
        if(prime_factor_count[i] > 1) not_pairwise = true;
    }

    if(not_pairwise){
        if(not_coprime){
            cout << "not coprime" << endl;
        }else{
            cout << "setwise coprime" << endl;
        }
    }else{
        cout << "pairwise coprime" << endl;
    }

    // rep2(i,1,30){
    //     if(min_prime[i] == 1) cout << i << " " << prime_factor_count[i] << endl;
    // }

    return 0;
}

Measured memory_bytes: 310488
#include <iostream>
#include <vector>
#include <tuple>

using lli=long long;

template <typename T>
void dfs(T& t_arr, int current, int parent, lli length, std::vector<lli>& length_arr){
  length_arr[current] = length;
  for(auto&& it: t_arr[current]){
    lli neigh, nlength;
    std::tie(neigh,nlength) = it;
    if(neigh == parent) continue;
    dfs(t_arr, neigh, current, length+nlength, length_arr);
  }
}

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

  std::vector<std::vector<std::tuple<int,int>>> t_arr(N);
  for(int i = 0; i < N-1; i++){
    lli a,b,c;
    std::cin >> a >> b >> c;
    a--; b--;
    t_arr[a].push_back(std::make_tuple(b,c));
    t_arr[b].push_back(std::make_tuple(a,c));
  }

  int Q,K;
  std::cin >> Q >> K;
  K--;

  std::vector<lli> length_arr(N);
  dfs(t_arr, K, -1, 0, length_arr);

  for(int q = 0; q < Q; q++){
    int x,y;
    std::cin >> x >> y;
    x--; y--;
    std::cout << length_arr[x]+length_arr[y] << std::endl;
  }

  return 0;
}



Measured memory_bytes: 15872
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.Map as M

solve :: Int -> M.Map Int Int -> [[Int]] -> M.Map Int Int
solve n m [] = m
solve n m (s:sc)
    | n > 1 && x == 1 && y == 0 = M.empty
    | m' == Nothing = solve n (M.insert x y m) sc
    | (fromJust m') == y = solve n m sc
    | otherwise = M.empty
        where
            x = s!!0
            y = s!!1
            m' = M.lookup x m

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    sc <- replicateM m (map read . words <$> getLine) :: IO [[Int]]
    if m == 0
        then if n == 1
            then print $ 0
            else print $ (10^(n-1))
        else do
            let m' = solve n M.empty sc
            if m' == M.empty
                then print $ -1
                else do
                    let m'' = M.foldlWithKey (\acc k v -> acc + (10^(n-k)*v)) 0 m'
                    if m'' < (10^(n-1)) && n > 1
                        then print $ m'' + (10^(n-1))
                        else print $ m''


Measured memory_bytes: 3924
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int a, b, h, m;
	scanf ("%d %d %d %d", &a, &b, &h, &m);

	double pi = acos(-1.0);
	double ax = a * cos(2 * pi * (h * 60 + m) / 720);
	double ay = a * sin(2 * pi * (h * 60 + m) / 720);
	double bx = b * cos(2 * pi * m / 60);
	double by = b * sin(2 * pi * m / 60);

	printf ("%.15lf\n", hypot(ax - bx, ay - by));

	return 0;
}


Measured memory_bytes: 2532
#include <bits/stdc++.h>
using namespace std;
string words[100];
int n;
bool ans = true;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> words[i];
        for (int j = 0; j < i; j++)
        {
            if (words[j] == words[i])
            {
                ans = false;
                break;
            }
            if (words[i - 1].back() != words[i].front())
            {
                ans = false;
                break;
            }
        }
    }
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#define bp(x) __builtin_popcountll(x)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ll int64_t
#define fw(i, l, r, c) for(ll i = l; i <= r; i += c)
#define bw(i, r, l, c) for(ll i = r; i >= l; i -= c)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
const ll mod = 1e9 + 7, inf = 1061109567, N = 2e5 + 5;
const long long infll = 4557430888798830399;

ll ans = 1;
ll dis[N] = {0};
ll check[N] = {0}, make[N] = {0};
vii adj[N];
vi e;

void dfs(ll x){
	if(ans == 0) return;
	check[x] = 1;
	for(auto i: adj[x]){
		if(make[i.fi] == 0){
			dis[i.fi] = dis[x] + i.se;
			make[i.fi] = 1;
			if(check[i.fi] == 0) dfs(i.fi);
		}else{
			if(dis[i.fi] != dis[x] + i.se){
				ans = 0;
				return;
			}
			if(check[i.fi] == 0) dfs(i.fi);
		}	
	}
}

signed main(){
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	fastio;
	ll n, m;
	cin >> n >> m;
	while(m--){
		ll l, r, d;
		cin >> l >> r >> d;
		adj[l].pb(ii(r, d));
		adj[r].pb(ii(l, -d));
		e.pb(l);
	}
	for(auto i: e){
		if(check[i] == 1) continue;
		dis[i] = 0;
		make[i] = 1;
		dfs(i);
		if(ans == 0) break;	
	}
	if(ans == 0) cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 25924
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
#define MOD 2019

int main(){
	int N;
  	cin >> N;
  	int A[N];
  	int S[N];
  	ll sum = 0;
  	for(int i = 0; i < N; i++){
    	cin >> A[i];
      	sum += A[i];
    }
  	sum = sum/2;
  	ll sum2 = 0;
  	for(int i = 0; i*2+1 < N; i++){
    	sum2 += A[i*2 + 1];
    }
  	S[0] = sum - sum2;
    for(int j = 1; j < N; j++){
      S[j] = A[j-1] - S[j-1];
    }
  	for(int i = 0; i < N-1; i++){
    	cout << 2*S[i] << ' ';
    }
  	cout << 2*S[N-1] << endl;
}

Measured memory_bytes: 2048
#!python3.8
# -*- coding: utf-8 -*-
# abc179/abc179_c
import sys
from math import ceil

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

m = 10**6 + 1000
div = [0, 1] + [2] * m
for i in range(2, len(div)):
    for j in range(2 * i, len(div), i):
        div[j] += 1

def main():
    N = i2n()
    ans = 0
    for n in range(1, N):
        ans += div[n]
    print(ans)
    return

main()


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

int k[75];

int main() {
	int n, q;
	string s;
	cin >> n >> s >> q;
	for(int i=0;i<q;i++) {
		cin >> k[i];
	}
	for(int i=0;i<q;i++) {
		long long d = 0, m = 0, dm = 0, ans = 0;
		for(int j=0;j<n;j++) { // [j-k[i], j) -> [j-k[i]+1, j+1)
			if(j >= k[i]) {
				if(s[j-k[i]] == 'D') {
					d--; dm -= m;
				} else if(s[j-k[i]] == 'M') {
					m--;
				}
			}
			switch(s[j]) {
			case 'D':
				d++;
			break;
			case 'M':
				m++; dm += d;
			break;
			case 'C':
				ans += dm;
			break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1412
def getMinGap(data):
	result = list()
	for n in range(len(data)):
		for m in range(n + 1, len(data)):
			result.append(abs(data[n] - data[m]))
	result = set(result)
	return min(result)

while  True:
	n = int(input())
	if n == 0:
		break
	data = [int(x) for x in input().split()]
	print(getMinGap(data))



Measured memory_bytes: 56604
#include<iostream>
using namespace std;
int v[4][3][10];
int main(){
	int n;
	cin >> n;
		for (int b = 0; b < 4; b++){
			for (int f = 0; f < 3; f++){
				for (int r=0; r < 10; r++){
					v[b][f][r] = 0;
				}
			}
		}
		int b, f, r,m;
		for (int x = 0; x < n; x++){
			cin >> b >> f >> r>>m;
			v[b-1][f-1][r-1] += m;
		}
		for (int x = 0; x < 4; x++){
			for (int y=0; y < 3; y++){
				for (int z = 0; z < 10; z++){
					cout << ' ' << v[x][y][z];
				}
				cout << endl;
			}
			if (x < 3){
				cout << "####################" << endl;
			}
		}
	return 0;
}



Measured memory_bytes: 3088
/*input
6
010110
101001
010100
101000
100000
010000
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 205;
const int mod = 1e9 + 7;
int n, col[maxn], dist[maxn][maxn];
vector<int>adj[maxn];
void dfs(int v, int c)
{
	if(col[v] != -1)
	{
		if(col[v] != c)
		{
			cout << "-1\n";
			exit(0);
		}
		return;
	}
	col[v] = c;
	for(int to : adj[v])
		dfs(to, c ^ 1);
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n;

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			dist[i][j] = mod;

	for(int i = 1; i <= n; i++)
	{
		string s; cin >> s;
		s = '.' + s;
		for(int j = 1; j <= n; j++)
		{
			if(s[j] == '1')
			{
				dist[i][j] = 1;
				adj[i].pb(j);
			}
		}
	}

	memset(col, -1, sizeof col);
	for(int i = 1; i <= n; i++)
		if(col[i] == -1)
			dfs(i, 1);

	for(int k = 1; k <= n; k++)
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	int mx = 0;
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
			mx = max(mx, dist[i][j]);

	cout << mx + 1 << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
int n,m,x_[maxn],y_[maxn],ans[maxn],head[maxn],tot=1;
bool vis[maxn],deg[maxn],is_e[maxn];
struct node { int to,next; bool dir; } e[maxn<<1];
inline void addedge(int x,int y,bool dir)
{
	e[++tot].to=y;
	e[tot].dir=dir;
	e[tot].next=head[x];
	head[x]=tot;
}
void dfs1(int x)
{
	vis[x]=1;
	for(int i=head[x];i;i=e[i].next)
		if(!vis[e[i].to])
			is_e[i>>1]=1,dfs1(e[i].to);
}
void dfs2(int x,int ff)
{
	for(int i=head[x];i;i=e[i].next)
		if(is_e[i>>1] && e[i].to!=ff)
		{
			dfs2(e[i].to,x);
			if(deg[e[i].to]) ans[i>>1]=e[i].dir^1,deg[e[i].to]^=1;
			else ans[i>>1]=e[i].dir,deg[x]^=1;
		}
}
int main()
{
	scanf("%d%d",&n,&m);
	if(m&1) return printf("-1"),0;
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x_[i],&y_[i]),addedge(x_[i],y_[i],0),addedge(y_[i],x_[i],1);
	dfs1(1);
	for(int i=1;i<=m;i++)
		if(!is_e[i]) deg[x_[i]]^=1,ans[i]=0;
	dfs2(1,0);
	for(int i=1;i<=m;i++)
		if(!ans[i]) printf("%d %d\n",x_[i],y_[i]);
		else printf("%d %d\n",y_[i],x_[i]);
	return 0;
}

Measured memory_bytes: 13440
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k;
    cin >> k;
    
    vector<ll> ans(50, 49);
    
    for ( ll & x: ans )
        x += k / 50;

    for ( ll i = 0; i < k % 50; i++ ){
        ans[i] += 50;
        for ( ll j = 0; j < 50; j++ ){
            if ( i == j ) continue;
            --ans[j];
        }
    }
  
  cout << 50 << endl;
    
    for ( int i = 0; i < 50; i++ )
        cout << ans[i] << " ";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k - 1] = (char)(s[k - 1] - 'A' + 'a');
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    from collections import deque
    q = int(input())
    ans = deque()
    for _ in range(q):
        q = [int(i) for i in input().split()]
        if q[0] == 2:
            ans.pop()
        else:
            x = q[1]
            if q[0] == 0:
                ans.append(x)
            else:
                print(ans[x])


resolve()



Measured memory_bytes: 13868
n = int(input())
m = 10**9+7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*1001

for i in range(2, n+1):
    for j in primes:
        while(i % j == 0):
            D[j] += 1
            i //= j
    if i > 1:
        D[i] += 1

score = 1
for d in D:
    score = (score * (d + 1)) % m
print(score)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

void dfs(int, int);
int limx,limy,cnt=0,ni,nj;
char data[21][21];

int main(){
  int i,j;
  while(1){
    scanf("%d%d",&limx,&limy);
    if(limx==0 && limy==0)
      break;
    for(i=0;i<limy;i++)
      scanf("%s",data[i]);

    for(i=0;i<limy;i++)
      for(j=0;j<limx;j++)
	if(data[i][j]=='@') ni=i,nj=j;
    dfs(ni,nj);
    printf("%d\n",cnt);
    cnt=0;
  }
  return 0;
}

void dfs(int i, int j){
  int di[4]={0,-1,0,1};
  int dj[4]={1,0,-1,0};

  data[i][j]='#';
  cnt++;
  for(int r=0;r<4;r++){
    ni=i+di[r];
    nj=j+dj[r];
    if(data[ni][nj]=='.' && ni >= 0 && ni < limy && nj >= 0 && nj < limx) 
      dfs(ni,nj);
  }
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int N;
    int cnt[9];
    for(int i=0;i<9;i++) cnt[i]=0;

    cin >> N;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a<400) cnt[0]++;
        else if(a<800) cnt[1]++;
        else if(a<1200) cnt[2]++;
        else if(a<1600) cnt[3]++;
        else if(a<2000) cnt[4]++;
        else if(a<2400) cnt[5]++;
        else if(a<2800) cnt[6]++;
        else if(a<3200) cnt[7]++;
        else cnt[8]++;
    }
    int c=0,d=0;
    for(int i=0;i<=7;i++){
        if(cnt[i]==0) d++;
        else c++;
    }
    cout << (c>0?c:1) << ' ' << (c+cnt[8]) << endl;
    
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> s(n);

	for(int i = 0; i < k; ++i)
	{
		int d;
		cin >> d;
		// vector<int> v(d);
		for(int j = 0; j < d; ++j)
		{
			int a;
			cin >> a;
			s[a-1] = 10;
		}
	}

	int ans = 0;
	for(auto& v : s)
	{
		if(v != 10)
		{
			ans++;
		}
	}

	cout << ans << endl;


}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=long long;
using namespace std;
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 ll INF=1LL<<60;

int n;
string s,t;


int main(){
    cin>>n>>s>>t;
    int ans=2*n;
    rep(i,1,n+1){
        string ss=s.substr(n-i,i);
        string tt=t.substr(0,i);
        if(ss==tt) chmin(ans,2*n-i);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3632
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    cout<<fixed<<setprecision(10);
    READV(N);
    READV(K);
    READAR(A,N);
    ld ans=0;
    ld pre=0;
    FORI(i,0,K)
    {
        pre+=((ld)(A[i]+1))/((ld)2);
    }
    ans=max(ans,pre);
    FORI(i,K,N)
    {
        pre+=((ld)(A[i]+1))/((ld)2);
        pre-=((ld)(A[i-K]+1))/((ld)2);
        ans=max(ans,pre);
    }
    cout<<ans<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <iostream>
#define ll long long
using namespace std;

int main(){
  int n;
  cin>>n;
  ll vec[n][3];
  ll minabs[n];
  for(int i=0;i<n;i++){
    cin>>vec[i][0]>>vec[i][1]>>vec[i][2];
    minabs[i]=min(abs(vec[i][0]),abs(vec[i][1]));
  }
  ll ans[n+1];
  for(int i=0;i<=n;i++){
    ans[i]=1e13;
  }
  int vecb[n];
  int vecc[n];
  ll cost[n];
  ll sum,x;
  for(int bit=0;bit<(1<<n);bit++){
    int t=0;
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        vecb[i]=1;
        vecc[t]=i;
        t++;
      }
      else{
        vecb[i]=0;
      }
    }
    if(t==n){
      ans[t]=0;
      continue;
    }
    for(int i=0;i<n;i++){
      cost[i]=minabs[i];
    }
    /*x=0;
    for(int i=0;i<n;i++){
      if(vecb[i]==1){
        vecc[x]=i;
        x++;
      }
    }*/
    for(int bitb=0;bitb<(1<<t);bitb++){
      for(int i=0;i<t;i++){
        if(bitb&(1<<i)){ //縦に引く
          for(int j=0;j<n;j++){
            cost[j]=min(cost[j],abs(vec[j][0]-vec[vecc[i]][0]));
          }
        }
        else{ //横に引く
          for(int j=0;j<n;j++){
            cost[j]=min(cost[j],abs(vec[j][1]-vec[vecc[i]][1]));
          }
        }
      }
      sum=0;
      for(int i=0;i<n;i++){
        sum+=cost[i]*vec[i][2];
        cost[i]=minabs[i];
      }
      ans[t]=min(ans[t],sum);
    }
  }
  
  for(int i=0;i<n+1;i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <array>
#include <cstdio>
using std::cin;
using std::cout;
using std::endl;

int main(int argc, char* argv[])
{
  int l;
  cin >> l;
  double result = l / 3.0;
  double val = result * result * result;
  std::printf("%lf\n", val);
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<string> mat(N);
    for(int i=0; i<N; i++) cin >> mat[i];

    int ans = -1;
    for(int x=0; x<N; x++) {
        int rem = N;
        vector<int> group(N);
        group[x] = 1;
        
        vector<int> cur;
        cur.emplace_back(x);
        rem--;

        bool ok = true;
        while(rem) {
            vector<int> nxt;
            int g = group[ cur.front() ];

            bool update = false;
            for(auto e : cur) {
                for(int i=0; i<N; i++) {
                    if(mat[e][i] == '0' or group[i]) continue;
                    update = true;
                    nxt.emplace_back(i);
                    group[i] = g + 1;
                    rem--;
                }
            }

            if(!update) {
                ok = false;
                break;
            }
            swap(cur, nxt);
        }

        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                if(mat[i][j] == '0') continue;
                int diff = abs(group[i] - group[j]);
                if(diff != 1) ok = false;
            }
        }

        if(ok) ans = max(ans, *max_element(group.begin(), group.end()));
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int rn = uniform_int_distribution<int>(0, MAXN)(rng);

    int a, b, c, x, y;
    cin>>a>>b>>c>>x>>y;
    int res = INF;

    REP(i,max(2*x, 2*y)+1) {
        int p = x - i/2;
        int q = y - i/2;
        if(p < 0) p = 0;
        if(q < 0) q = 0;
        res = min(res, i*c + p*a + q*b);
    }
    cout<<res;
    return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll const MAX_N = 100;
ll const MAX_M = 100;

typedef pair<ll, ll> P;

// 入力
char maze[MAX_N][MAX_M + 1];  // 迷路を表す文字列の配列
ll H, W;
ll sx, sy;  // スタートの座標
ll gx, gy;  // ゴールの座標

ll d[MAX_N][MAX_M];

// 移動4方向のベクトル
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// (sx, sy)から(gx, gy)への最短距離を求める
// 辿り着けないとINF

int bfs() {
    queue<P> que;

    for (ll i = 0; i < H; i++)
        for (ll j = 0; j < W; j++) d[i][j] = INF;

    que.push(P(sx, sy));
    d[sy][sx] = 0;

    while (que.size()) {
        P p = que.front();
        que.pop();

        if (p.first == gx && p.second == gy) break;

        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if (0 <= nx && nx < W && 0 <= ny && ny < H && maze[ny][nx] != '#' &&
                d[ny][nx] == INF) {
                que.push(P(nx, ny));
                d[ny][nx] = d[p.second][p.first] + 1;
            }
        }
    }

    return d[gy][gx];
}

int main() {
    INIT;

    cin >> H >> W;
    rep(i, H) {
        rep(j, W) { cin >> maze[i][j]; }
    }

    ll ans = 0;
    rep(i, H) rep(j, W) if (maze[i][j] == '.') ans++;

    sx = 0;
    sy = 0;
    gx = W - 1;
    gy = H - 1;
    bfs();
    if (d[gy][gx] == INF) {
        cout << -1 << endl;
    } else {
        cout << ans - d[gy][gx] - 1 << endl;
    }

    // rep(i, H) {
    //     rep(j, W) {
    //         if (d[i][j] >= INF) {
    //             cout << "# ";
    //         } else {
    //             cout << d[i][j] << " ";
    //         }
    //     }
    //     cout << endl;
    // }

    return 0;
}

Measured memory_bytes: 3696
X, Y = map(int, input().split())

x = 2*X-1/2*Y
y = -X + 1/2*Y

if x.is_integer() and y.is_integer() == True:
  if x >= 0 and y >= 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 9148
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890123456
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//

//
//initialization finish


// your function is here
//


//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//
	string s; cin >> s;

	int m[4] = { 0 };
	rep(i, s.size())
	{
		if (s[i] == 'N')if (!m[0])m[0]++;
		if (s[i] == 'S')if (!m[1])m[1]++;
		if (s[i] == 'W')if (!m[2])m[2]++;
		if (s[i] == 'E')if (!m[3])m[3]++;
	}

	if ((m[0] ^ m[1]) or (m[2] ^ m[3]))No;
	else Yes;
	//
	// your code finished


	return 0;
}

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



int main() {
    string S;

    cin >> S;

    if(S[S.length()-1] == 's'){
        cout << S << "es" << endl; 
    }else{
        cout << S << "s" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3624
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
int f(int n, int k) {
    int ret = 0;
    while (n < k) { ret++; n *= 2; }
    return ret;
}
/* main */
int main(){
    double N, K;
    cin >> N >> K;
    double sum = 0;
    for (int i = 1; i <= N; i++) {
        int p = f(i, K);
        sum += pow(0.5, p);
    }
    cout << fixed << setprecision(10) << sum / N << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int M; cin >> M;
		if (!M)break;
		vector<vector<int>>piles(M);
		for (int i = 0; i < piles.size(); ++i) {
			piles[i] = vector<int>(1, i + 1);
		}
		while (1) {
			int a, b; cin >> a >> b;
			if (!a)break;
			pair<int, int>ap;
			for (int i = 0; i < piles.size(); ++i) {
				auto pile(piles[i]);
				auto it = find(pile.begin(), pile.end(), a);
				if (it != pile.end()) {
					ap = make_pair(i, it - pile.begin());
				}
			}
			if (!b) {
				if (ap.second == 0)continue;
				auto&apile(piles[ap.first]);
				while (apile.back() != a) {
					int n = apile.back();

					apile.pop_back();
					if (n != a) {

						piles.push_back(vector<int>(1, n));
					}
				}
				apile.pop_back();
				piles.push_back(vector<int>(1, a));
			}
			else {
				pair<int, int> bp;
				
				for (int i = 0; i < piles.size(); ++i) {
					auto pile(piles[i]);
					auto jt = find(pile.begin(), pile.end(), b);
					if (jt != pile.end()) {
						bp = make_pair(i, jt - pile.begin());
					}
				}

				if (ap.first == bp.first) {
					if (ap.second >= bp.second) {
						continue;
					}
					else {
						auto& apile(piles[ap.first]);
						while (apile.back() != a) {
							int n = apile.back();

							apile.pop_back();
							if (n != b) {

								piles.push_back(vector<int>(1, n));
							}
						}
						apile.pop_back();
						piles.push_back(vector<int>{b, a});
					}
				}
				else {
					auto&apile(piles[ap.first]);
					auto&bpile(piles[bp.first]);
					while (apile.back() != a) {
						int n = apile.back();

						apile.pop_back();
						if (n != a) {

							piles.push_back(vector<int>(1, n));
						}
					}
					apile.pop_back();
					bpile.push_back(a);
				}
			}
			
			{

				vector<vector<int>>nextpiles;
				for (auto&pile : piles) {
					if (!pile.empty())nextpiles.push_back(pile);
				}
				piles = nextpiles;
			}
		}
		vector<int>nums;
		for (auto pile : piles) {
			nums.push_back(pile.size());
		}
		sort(nums.begin(), nums.end());
		for (auto n : nums)cout << n << endl;
		cout << "end" << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    if n < 4:
        print(max(a))
        return
    odd = n % 2 == 1
    if odd:
        dp = [[0] * 3 for _ in range(n)]
    else:
        dp = [[0] * 2 for _ in range(n)]
    dp[0][0] = a[0]
    dp[1][1] = a[1]
    if odd:
        dp[2][2] = a[2]
    for i in range(2, n, 2):
        dp[i][0] = dp[i - 2][0] + a[i]
    for i in range(3, n, 2):
        dp[i][1] = max(dp[i - 2][1] + a[i], dp[i - 3][0] + a[i])
    if odd:
        for i in range(4, n, 2):
            dp[i][2] = max(dp[i - 2][2] + a[i], dp[i - 3]
                           [1] + a[i], dp[i - 4][0] + a[i])
    if odd:
        print(max(dp[-1][-1], dp[-2][-2], dp[-3][-3]))
    else:
        print(max(dp[-1][-1], dp[-2][-2]))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 51516
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int chumon_jikan(const std::vector<int>& v, int n){
    int ret = 0;

    for(int i=0; i<n-1; i++){
        ret += v[i];
        if(ret%10){
            ret += 10 - ret%10;
        }
    }
    ret += v[n-1];
    return ret;
}

int main(){
    std::vector<int> a(5);
    for(int i=0; i<5; i++){
        std::cin >> a[i];
    }
    std::sort(a.begin(),a.end());

    int ans = 1145141919;
    do{
        ans = std::min(chumon_jikan(a,5), ans);
    }while(std::next_permutation(a.begin(),a.end()));

    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3600
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;

signed main(){
    cin >> N >> M;
    cout << 1 << " " << (N+1)/2 << endl;
    int ul = 2;
    int dl = (N+1)/2-1;
    int ur = N;
    int dr = (N+1)/2+1;
    if(N%2 == 0) ur--;
    rep(i, M-1){
        if(i%2 == 0){
            cout << dr << " " << ur << endl;
            ur--;
            dr++;
        }
        else{
            cout << ul << " " << dl << endl;
            ul++;
            dl--; 
        }
    }
}

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

int main(){
 int a, b, c, K;
 cin >> K;
 int ans = 0, now;
 rep(a, K){
   rep(b, K){
     rep(c, K){
       now = gcd(b + 1, c + 1);
       ans += gcd(a + 1, now);
     }
   }
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <time.h>
#include <cstdio>
using namespace std;

long long a[110][110];
int main(){
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			cin >> a[i+1][j+1];
		}
	}
	for(int i = 0 ; i <= n ; i++){
		for(int j = 1 ; j <= n ; j++){
			a[i][j] += a[i][j-1];
		}
	}
	for(int i = 1 ; i <= n ; i++){
		for(int j = 0 ; j <= n ; j++){
			a[i][j] += a[i-1][j];
		}
	}
	int ans = -2e9;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= n ; j++){
			for(int k = 1 ; k+i-1 <= n ; k++){
				for(int l = 1 ; l+j-1 <= n ; l++){
					int sum = a[k+i-1][l+j-1] - a[k-1][l+j-1] - a[k+i-1][l-1] + a[k-1][l-1];
					//cout << i << " " << j << " " << k << " " << l << ": " << sum << endl;
					ans = max(ans,sum);
				}
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 1252
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int H, W, K, si, sj;
    cin >> H >> W >> K;
    vector<string> A(H);
    rep(i, H) {
        cin >> A[i];
        rep(j, W) {
            if (A[i][j] == 'S') {
                si = i;
                sj = j;
            }
        }
    }
    vector<vector<int>> d(H, vector<int>(W, 1e9));
    d[si][sj] = 0;
    queue<vector<int>> que;
    que.push({si, sj});
    int m = 1e9;
    while (!que.empty()) {
        int i = que.front()[0], j = que.front()[1];
        que.pop();
        m = min(m, i);
        m = min(m, H - 1 - i);
        m = min(m, j);
        m = min(m, W - 1 - j);
        if (d[i][j] == K) continue;
        rep(k, 4) {
            vector<int> di = {1, 0, -1, 0};
            vector<int> dj = {0, 1, 0, -1};
            int u = i + di[k];
            int v = j + dj[k];
            if (u < 0 || u >= H || v < 0 || v >= W) continue;
            if (d[u][v] < 1e9) continue;
            if (A[u][v] == '#') continue;
            d[u][v] = d[i][j] + 1;
            que.push({u, v});
        }
    }
    cout << (m + K - 1) / K + 1 << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	// your code goes here
	
	int n;
	cin>>n;
	for(int qq=0;qq<n;qq++){
		string s;
		cin>>s;
		map<string,int> ma;
		int l=s.length();
		for(int i=1;i<l;i++){
			string a1=s.substr(0,i);
			string b1=s.substr(i,l-i);
			string a2=a1,b2=b1;
			reverse(a2.begin(), a2.end());
			reverse(b2.begin(), b2.end());
		//	cout<<a1<<" "<<a2<<" "<<b1<<" "<<b2<<" "<<endl;;
		ma.insert(make_pair(a1+b1, 5));
		ma.insert(make_pair(a1+b2, 5));
		ma.insert(make_pair(a2+b1, 5));
		ma.insert(make_pair(a2+b2, 5));
		ma.insert(make_pair(b1+a2, 5));
		ma.insert(make_pair(b1+a1, 5));
		ma.insert(make_pair(b2+a2, 5));
		ma.insert(make_pair(b2+a1, 5));
		}
		cout<<ma.size()<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
    int x[3], k;
    rep(i,3) cin >> x[i];
    cin >> k;
    sort(x,x+3);
    cout << x[0] + x[1] + x[2]*pow(2,k) << endl;
    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))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, y;
    cin >> n >> y;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <=n-i; ++j) {
            for (int k=0; k<=n-i-j; ++k) {
                if (10000*i + 5000*j + 1000*k == y and i+j+k == n) {
                    cout << i << ' ' << j << ' ' << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

int power(long i){
  int counter = 0;
  while(i % 2 == 0){
    counter++;
    i /= 2;
  }
  return counter;
}

int main(){
  int N;
  cin >> N;
  vector<long> data(N);
  int counter = 0;
  for(int i = 0;i < N;i++){
    cin >> data[i];
    counter += power(data[i]);
  }
  cout << counter << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int d = scanner.nextInt();

    int area1 = a * b;
    int area2 = c * d;
    if(area1 >= area2) {
      System.out.println(area1);
    } else {
      System.out.println(area2);
    }
  }
}

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using pll = pair < ll , ll >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vl  = vector < ll >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;

void solve(){
    scanf("%d %d" , &n , &m);

    int x = m - n/2;

    for(int i = m - n + 1 ; i <= m + n - 1 ; i ++)
        cout << i << " ";
    cout << endl;
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}




Measured memory_bytes: 256
#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 = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && b == c) || (a != b && b != c && c != a)) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
    string str;
    while(cin >> str){
        reverse(str.begin(),str.end());
        cout << str << endl;
    }
    return 0;
}

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

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

	bool card[4][13] = { false };
	// 0 S
	// 1 H
	// 2 C
	// 3 D
	
	for (int i = 0; i < n; i++){
		char mark;
		int markN;
		int number;
		cin >> mark >> number;

		if (mark == 'S') markN = 0;
		else if (mark == 'H') markN = 1;
		else if(mark == 'C') markN = 2;
		else if (mark == 'D') markN = 3;
		
		card[markN][number - 1] = true;
	}
	
	char m[4] = { 'S', 'H', 'C', 'D'};
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			if (card[i][j] == false){
				cout << m[i] << " " << j + 1 << endl;
			}
		}
	}


}

Measured memory_bytes: 1160
N,K = map(int, input().split())
P = [[int(p) for p in input().split()] for _ in range(N)]

P.sort()

ans = 10**20
for i in range(N-K+1):
    X = P[i+K-1][0]
    x = P[i][0]
    Y = []
    for j in range(i, K+i):
        Y.append(P[j][1])
    Y.sort()
    ans = min(ans, (X-x)*(Y[-1]-Y[0]))
    for j in range(K+i, N):
        Y.append(P[j][1])
        Y.sort()
        for k in range(len(Y)-K+1):
            ans = min(ans, (P[j][0]-x)*(Y[k+K-1]-Y[k]))
            
print(ans)

Measured memory_bytes: 39408