akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=10;

int h,w;
vvi g(M,vi(M));

int main(){
	cin>>h>>w;
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) cin>>g[i][j];
	for(int k=0;k<M;k++) for(int i=0;i<M;i++) for(int j=0;j<M;j++) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	int res=0;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		int A;
		cin>>A;
		if(A!=-1){
			res+=g[A][1];
		}
	}
	cout<<res<<endl;
}

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

ll N;
ll L[4000];

void input(){
  cin >> N;
  for(int i=1;i<=N;i++) cin >> L[i];
}

void solve(){
  input();
  vector<ll> v(N);
  for(int i=0;i<N;i++) 
  {
    v[i] = L[i+1];
//    printf("v[%d]=%d L[%d]=%d\n",i,v[i],i,L[i]);
  }
  sort(v.begin(),v.end());
  ll ans=0;
  for(ll high=N-1 ; high>= 0; high--)
  {
    for(ll mid = high-1; mid > 0; mid--)
    {
//      cout << " high=" << high << " mid=" << mid;
      auto itr = upper_bound(v.begin(), v.end() , v[high] - v[mid]);
//      cout << " v[high]-v[mid]=" << v[high] - v[mid] << " itr=" << *itr;
      ll ng = distance(v.begin(), itr );
//      cout << " ng=" << ng;
      if( (ng < mid ) && (ng>=0)) ans += (mid - ng);
//      cout << " ans=" << ans << endl;
    }
  }
  
  cout << ans << endl;
  
  return;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
// Problem: A - Tenki
// Contest: AtCoder - AtCoder Beginner Contest 139
// URL: https://atcoder.jp/contests/abc139/tasks/abc139_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;
void solve()
{
	string s,t;
	cin>>s>>t;
	cout<<(s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]);
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
    string ss;
    getline(cin,ss);
    set<char>s;
    int l = ss.length();
    
    REP(i,l){
        s.insert(ss[i]);
    }
    
    if (l == s.size()) printf("yes\n");
    else printf("no\n");
    
    
   	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 5e3 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;

ll n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    cout<<n + n*n + n*n*n;
}



Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
auto in = [](auto &&... args) { (cin >> ... >> args); };


signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int N;
  cin >> N;
  vector<int> a(N+1);
  vector<int> dp(N+1,0);

  for(int i = 1; i <= N; i++){
    cin >> a[i];
  }
  dp[1] = 0;
  dp[2] = abs(a[1] - a[2]);

  for(int i = 3; i <= N; i++) {
    dp[i] = min(abs(a[i] - a[i - 2]) + dp[i - 2] , abs(a[i] - a[i - 1]) + dp[i - 1]);
  }
  cout << dp[N] << '\n';
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


int main(){
    int day;
    cin >> day;
    cout << "Christmas";
    int times;
    times = 25 - day;
    for (int i = 0; i < times; i++) {
        cout << " Eve";
    }
    cout << endl;
    
}


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int k,a , b;
    cin >> k >> a >> b ;
    string ans  = "NG";
    FOR(i, a, b+1) {
        if(i % k == 0) {
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string str;
    cin >> str;
    int N=str.length();
    int n = N/2;
    int count=0;
    for (int i=0;i<n;i++){
        if(str[i]!=str[N-1-i]){
            count++;
        }
    }
    cout << count;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

set<li> st;
li n;
PI a[100100];

int main() {
    cin >> n;
    rin{
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(a, a + n);
    st.insert(-1);
    st.insert(n);
    li res = 0;
    for (li i = n - 1; i >= 0; i--) {
        st.insert(a[i].S);
        auto now = st.find(a[i].S);
        auto prev1 = now; prev1--;
        auto next1 = now; next1++;
        //p4(i, *prev1, *next1, res);
        if (*prev1 == -1 && *next1 == n) {
            continue;
        }
        if (*prev1 == -1) {
            auto next2 = next1; next2++;
            res += a[i].F * (a[i].S + 1) * (*next2 - *next1);
        } else if (*next1 == n) {
            auto prev2 = prev1; prev2--;
            res += a[i].F * (n - a[i].S) * (*prev1 - *prev2);
        } else {
            auto next2 = next1; next2++;
            auto prev2 = prev1; prev2--;
            res += a[i].F * (*prev1 - *prev2) * (*next1 - a[i].S);
            res += a[i].F * (*next2 - *next1) * (a[i].S - *prev1);
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],flag=1;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3!=0&&a[i]%5!=0)
			{
				flag=0;
				break;
			}
		}
	}
	if(flag==0) cout<<"DENIED"<<endl;
	else cout<<"APPROVED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


int main()
{
	int n, l;
	vector<string> s;
	cin >> n >> l;
	s.resize(n);
	string forFill = "";
	for (auto i = 0; i < l; ++i) {
		forFill += " ";
	}
	fill(s.begin(), s.end(), forFill);
	for (auto i = 0; i < n; ++i) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	string ans = "";
	for (auto i = 0; i < n; ++i) {
		ans += s[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
ll mod2(int n)
{
  ll res = 0;
  while (n % 2 == 0) {
    res++;
    n /= 2;
  }
  return res;
}
ll _gcd(ll a, ll b)
{
  return b != 0 ? _gcd(b, a % b) : a;
}

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  vector<ll> d(n);
  ll power2 = -1;
  rep(i, n)
  {
    debug(i);
    cin >> d[i];
    d[i] /= 2;
    if (power2 == -1)
      power2 = mod2(d[i]);
    if (power2 != mod2(d[i])) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll l = d[0];
  repz(i, 1, n)
  {
    ll g = _gcd(l, d[i]);
    l = l * d[i] / g;
    if(l>m){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << (m / l +1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 1152
#abc151d
from scipy.sparse.csgraph import floyd_warshall
h,w=map(int,raw_input().split())
s=[raw_input() for i in range(h)]
n=w*h
e=[[0]*n for i in range(n)]
d=[(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
 for j in range(w):
  if s[i][j]=='.':
   for x,y in d:
    ni,nj=i+x,j+y
    if 0<=ni<h and 0<=nj<w and s[ni][nj]=='.':
     e[w*i+j][w*ni+nj]=1
res=floyd_warshall(e)
INF=float("inf")
print int(max(max(a if a!=INF else 0 for a in a) for a in res))


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

using std::max; using std::swap; using std::abs; using std::priority_queue; using std::queue; using std::bitset; using std::make_tuple; 
using std::istream; using std::ostream; using std::fixed; using std::greater; using std::tuple; using std::tie; using std::make_pair;
using std::cout; using std::cerr; using std::endl; using std::lower_bound; using std::upper_bound; using std::deque; using std::min; 
using std::map; using std::string; using std::fill; using std::copy; using std::sort; using std::unique; using std::unordered_set; 
using std::multiset; using std::nth_element; using std::min_element; using std::max_element; using std::vector; using std::set; 
using std::unordered_map; using std::pair; using std::next_permutation; using std::reverse; using std::rotate; using std::cin; 
using std::iota; using std::function; using std::shuffle;

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

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.141592653589793238462643L;
std::mt19937 mt19937(960172);

ll rnd(ll x, ll y) { static auto gen = std::bind(std::uniform_int_distribution<ll>(), mt19937); return gen() % (y - x + 1) + x; }
bool is_prime(ll x) { if (x <= 1) return 0; for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return 1; }
ll sqr(int a) { return (ll) a * a; } ld sqr(ld a) { return a * a; } ll sqr(ll a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }

int const N = 100100;

int a[N], b[N];

void solve() {
    
    int n, m;
    scanf("%d%d", &n, &m);
    
    for (int i = 0; i < n; ++i) scanf("%d", a + i);
    for (int i = 0; i < m; ++i) scanf("%d", b + i);
    
    sort(a, a + n);
    sort(b, b + m);
    
    ll cost = 0;
    ll edges = 0;
    ll vs = (ll) (n + 1) * (m + 1);

    int ac = n + 1;
    int bc = m + 1;
    
    for (int i = 0, j = 0; edges < vs - 1;) {
        assert(i < n || j < m);
        if (j == m || (i < n && a[i] < b[j])) {
            edges += bc;
            cost += (ll)bc * a[i];
            ++i;
            --ac;
            //cerr << "a" << endl;
        } else {
            edges += ac;
            cost += (ll)ac * b[j];
            ++j;
            --bc;
            //cerr << "b" << endl;
        }
    }
    
    cout << cost << '\n';
}



int main() {
    
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    
    cout.precision(15);
    cout << fixed;
    cerr.precision(6);
    cerr << fixed;
    
    solve();
    
#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}

Measured memory_bytes: 1024
function exmodLeaf(head::Symbol,args...)
    if head == :call
        op = args[1]
        op ∈ [:+,:*] && return Meta.parse(reduce((a1,a2) -> "(($(a1))$(string(op))$(a2))%998244353",string.(args)[2:end]))
        op == :- && return Meta.parse("abs((($(args[2]))-($(args[3])))%998244353)")
        op == :/ && return Meta.parse("(($(args[2]))*invmod($(args[3]),998244353))%998244353")
        op == :^ && return Meta.parse("powermod($(args[2]),$(args[3]),998244353)")
    end
    head == :+= && return Meta.parse("$(args[1])=($(args[1])+$(args[2]))%998244353")
    head == :-= && return Meta.parse("$(args[1])=abs(($(args[1])-$(args[2]))%998244353)")
    head == :*= && return Meta.parse("$(args[1])=(($(args[1]))*$(args[2]))%998244353")
    head == :/= && return Meta.parse("$(args[1])=(($(args[1]))*invmod($(args[2]),998244353))%998244353")
    head == :^= && return Meta.parse("$(args[1])=powermod($(args[1]),$(args[2]),998244353)")
    Expr(head,args...)
end
exmod(ex) = ex
exmod(ex::Expr) = exmodLeaf(ex.head,exmod.(ex.args)...)
macro m(ex::Expr);ex |> exmod |> esc;end

import Base:getindex
struct C{T<:Integer}
    n::T
    d::Dict{T,T}
    function C(n::T) where {T<:Integer}
        new{T}(n,Dict(0=>1,1=>n))
    end
end
function getindex(c::C{T},k::T) where {T<:Integer}
    if (c.n<<1) < k
        k = n-k
    end
    haskey(c.d,k) && return c.d[k]
    @m c.d[k] = c[k-1]*(c.n-k+1)/k
end

function main()
    N,M,K = parse.(Int64,split(readline()))
    c = C(N-1)
    @m res = M*(M-1)^(N-1)
    for k in 1:K
        @m res += M*(M-1)^(N-1-k)*c[k]
    end
    print(res)
end
main()

Measured memory_bytes: 267684
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
  cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  deque<int> q;
  rep(i, n){
    if(i%2) q.push_front(a[i]);
    else q.push_back(a[i]);
  }
  rep(i, n){
    int x;
    if((n-1)%2){
      x = q.front(); q.pop_front();
    } else {
      x = q.back(); q.pop_back();
    }
    cout<<x<<" ";
  }
  cout<<endl;
	return 0;
}


Measured memory_bytes: 3840
H,W,K = map(int,input().split())

num = 1
num_no_s = 0
for hi in range(H):
  row = input()
  if '#' not in row:
    num_no_s += 1
    if hi == H-1:
      [print(*out_row) for _ in range(num_no_s)]
  else:
    row_total = row.count('#')
    row_i = 0
    out_row = []
    for i, s in enumerate(row):
      out_row.append(num)
      if s=='#':
        row_i += 1
        if row_i == row_total:
          out_row.extend([num]*(W-1-i))
          num += 1
          break
        num += 1
    [print(*out_row) for _ in range(num_no_s+1)]
    num_no_s = 0

Measured memory_bytes: 3964
#include <set>
#include <iostream>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int w, h;
int m[1000][1000];

class Matching{
  typedef vector<vector<int> > G;

  vector<bool> visited;

  const G &g; //g[i][j] = k <==> i is connected to k
  int n;      //number of node
  int m;      //number of left node

  bool augment(int left) {
    if (left < 0)
      return true;
    if (visited[left])
      return false;
    visited[left] = true;
    REP(i, g[left].size()) {
      int right = g[left][i];
      if (augment(matching[right])) {
        matching[right] = left;
        return true;
      }
    }
    return false;
  }

public:
  vector<int> matching;

  explicit Matching(const G &graph, int mm)
    : g(graph), m(mm){
    n = graph.size();
  }

  int solve() {
    int matches = 0;
    matching = vector<int>(n,-1);
    visited  = vector<bool>(n);
    REP(left, m) {
      visited.assign(n, false);
      if (augment(left))
        matches++;
    }
    return matches;
  }
};

int main(){
  bool ans = true;

  h = getInt();
  w = getInt();

  REP(i,h) REP(j,w) m[i][j] = getInt();

  REP(cc, 2){
    vector<bool> memo(h);
    vector<vector<int> > g(h);

    REP(i,h) REP(j,h) if(i != j){
      bool ok = true;
      REP(k,w){
	if(m[i][k] <= m[j][k]){
	  ok = false;
	  break;
	}
      }
      if(ok) g[i].push_back(j);
    }

    // puts("g:"); REP(i,h) { printf("%d: ", i); REP(j,g[i].size()) printf("%d ", g[i][j]); puts(""); }

    bool tmp = true;

    REP(i,h) memo[g[i].size()] = true;
    REP(i,h) if(!memo[i]) tmp = false;

    if(!tmp){
      REP(i,h) if(g[i].size() == h - 1){
	// for each start point
	vector<vector<int> > gg(2 + 2 * h);
	
	REP(j,h) if(j != i){
	  int r = 2 + j;
	  REP(k, g[j].size()) if(g[j][k] != i){
	    int l = 2 + h + g[j][k];
	    gg[l].push_back(r);
	    gg[r].push_back(l);
	  }
	}
	
	REP(k, g[i].size()){
	  int r = 2 + h + g[i][k];
	  gg[0].push_back(r); gg[1].push_back(r);
	  gg[r].push_back(0); gg[r].push_back(1);
	}
	
	int n = Matching(gg, 2 + h).solve();
	
	if(n == h - 1){
	  tmp = true;
	  break;
	}
      }
    }

    if(!tmp){
      ans = false;
      break;
    }

    // Repeat
    REP(i,max(h, w)) REP(j,i)
      swap(m[i][j], m[j][i]);
    swap(h, w);
  }

  puts(ans ? "YES" : "NO");

  return 0;
}

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

sixs = [6**i for i in range(1,7)]
nines = [9**i for i in range(1,6)]
tmp = {}

def dfs(n):
  if(n < 6):
    return n

  if(n in tmp):
    return tmp[n]

  m = 10**9+7
  if(n >= 9):
    max_nine = max(nine for nine in nines if nine <= n)
    if(n%max_nine == 0):
      m = min(m, n // max_nine)
    else:
      m = min(m, dfs(n - max_nine) + 1)

  max_six = max(six for six in sixs if six <= n)
  if(n%max_six == 0):
    m = min(m, n // max_six)

  tmp[n] = min(m, dfs(n - max_six) + 1)
  return tmp[n]

print(dfs(N))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int x,i,j,k;
cin>>x;
int dp[100005];
memset(dp,0,sizeof(dp));
dp[0]=1;
for(i=100;i<=105;i++){
    for(j=0;j<21;j++){
        int y=i*(1<<j);
        for(k=1e5-y;k>=0;k--){
            dp[k+y]|=dp[k];
        }
    }
}
cout<<dp[x]<<endl;
}


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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

// mod付きコンビネーション
const int MAX = 1100000;
const int MOD = 1000000007;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    Int n, k;
    cin >> n >> k;
    COMinit();
    Int res = 0;
    for (Int i = k; i <= (Int)n + 1; i++) {
        Int a = i * (n + 1 - i  + 1 + n + 1) % mod;
        a = a * inv[2] % mod;
        Int b = i * (1 + i) % mod;
        b = b * inv[2] % mod;
        //print(a, b);
        res += (a + 1 - b + mod) % mod;
        res %= mod;
    }
    print(res);
    return 0;
}

Measured memory_bytes: 29424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    for (int i = 0; i < 5; ++i) {
        ll a; cin >> a;
        if(a != i + 1){
            cout << i + 1 << endl;
            break;
        }
    }
    return;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <climits>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <list>

#define FOR(i,n)    for(int i = 0 ; i < n ; i++)
#define FORrev(i,n) for(int i = n - 1 ; i >= 0 ; i--)
#define ALL(a)      a.begin(),a.end()

typedef long long int ll; 

using namespace std;

int main() {
	ll n;
	cin>>n;
	if(n % 2 == 0) {
		cout<<(n / 2L) * (n - 1L);
	}
	else {
		cout<<((n - 1L) / 2L) * n;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
int main(){
    string str_s,str_n;
    cin >> str_s;
    int len,first,latter;
    len = str_s.length();
//    cout << len << endl;
    first = (len -1) / 2;
    latter = (len + 3) / 2 -1; 
/*  
    cout << "len :" << len << endl;  
	cout << "first :" << first << endl;
    cout << "latter :" << latter << endl;
*/
    string str_f,str_l;
    str_f = str_s.substr(0,first);
    str_l = str_s.substr(latter,len);
//    cout << str_f << endl;
//    cout << str_l << endl;
  	if(str_f == str_l){
      cout << "Yes" << endl; 
    }else{
      cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	sc    = bufio.NewScanner(os.Stdin)
	words = [4]string{"maerd", "remaerd", "esare", "resare"}
)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func solve(target string) bool {

	if len(target) == 0 {
		return true
	}

	for _, v := range words {
		if strings.HasPrefix(target, v) {
			return solve(target[len(v):])
		}
	}

	return false
}

func main() {
	var input string
	fmt.Scan(&input)

	input = strReverse(input)

	if res := solve(input); res {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 10368
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int L,cnt[205];
char t[63][205];
char s[205],tmp[205],sigma[75];
int ask(char*s)
{
	printf("? %s\n",s+1);
	fflush(stdout);
	int res;
	scanf("%d",&res);
	return res;
}
void merge(int x,int y)
{
	int l1=cnt[x],l2=cnt[y];
	int i=0,j=0;
	char*t1=t[x],*t2=t[y];
	while(i<l1&&j<l2)
	{
		tmp[i+j+1]=t2[j+1];
		for(int k=i+1;k<=l1;k++)tmp[j+1+k]=t1[k];
		tmp[j+1+l1+1]='\0';
		if(ask(tmp)==L-(j+1+l1))j++;
		else tmp[i+j+1]=t1[i+1],i++;
	}
	while(i<l1)
	{
		tmp[i+j+1]=t1[i+1];
		i++;
	}
	while(j<l2)
	{
		tmp[i+j+1]=t2[j+1];
		j++;
	}
	tmp[l1+l2+1]='\0';
	for(int i=1;i<=l1+l2;i++)t1[i]=tmp[i];
	cnt[x]+=cnt[y];
}
void solve(int l,int r)
{
	if(l==r)return;
	int mid=(l+r)>>1;
	solve(l,mid);
	solve(mid+1,r);
	merge(l,mid+1);
}
int main()
{
	for(int i=1;i<=26;i++)sigma[i]=(char)(i-1+'A');
	for(int i=27;i<=52;i++)sigma[i]=(char)(i-27+'a');
	for(int i=53;i<=62;i++)sigma[i]=(char)(i-53+'0');
	for(int i=1;i<=62;i++)
	{
		for(int j=1;j<=128;j++)s[j]=sigma[i];
		cnt[i]=128-ask(s);
	}
	for(int i=1;i<=62;i++)
	{
		for(int j=1;j<=cnt[i];j++)
		  t[i][j]=sigma[i],L++;
	}
	solve(1,62);
	t[1][L+1]='\0';
	printf("! %s\n",t[1]+1);
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define repi(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << 48 - n << endl;
    return 0;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	string a[h];
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	stringstream ss;
	for (int i = 0; i < w+2; i++) {
		ss << "#";
	}
	ss << "\n";
	for (int i = 0; i < h; i++) {
		ss << "#" << a[i] << "#\n";
	}
	for (int i = 0; i < w+2; i++) {
		ss << "#";
	}

	string ans = ss.str();

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define lvi vector<long long>
#define pi pair<int,int>
#define lpi pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define ll long long 
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mod1 1000000000000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>multiordered_set;
ll int pw(ll int a, ll int b,ll md) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2,md);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
vector<int> pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.push_back(p);
}
bool cmp(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    if(a.first==b.first)return a.second<b.second;
    return a.first>b.first;
}
ll int gcd(ll int a,ll int b)
{
    if(!a)return b;
    return gcd(b%a,a);
}
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 
map<int,int>pa;
int find(int i){
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}     
void join(int i,int j){
    int a=find(i);
    int b=find(j);
    if(b>=a)pa[b]=a;
    else pa[a]=b;
}               
int ddx[]={-1,-1,-1,0,1,1,1,0};
int ddy[]={-1,0,1,1,1,0,-1,-1};
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int main()
{
    faltu;
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        vi ed[n+1];
        while(m--)
        {
            int x,y;
            cin>>x>>y;
            ed[x].pb(y);
            ed[y].pb(x);
        }
        int vis[n+1];
        int ans=0,mx=0;
        memset(vis,0,sizeof(vis));
        function<void(int)>dfs=[&](int ind)
        {
            vis[ind]=1;
            ans++;
            for(auto it:ed[ind])
            {
                if(vis[it]!=1)
                {
                    dfs(it);
                }
            }
        };
        for(int i=1;i<=n;i++)
        {
            ans=0;
            if(vis[i])continue;
            dfs(i);
            mx=max(mx,ans);
        }
        cout<<mx<<endl;
    }
}

Measured memory_bytes: 27784
Public Class Program
  Shared Sub Main()
    Dim nk As Integer() = Cin.IntArr()
    Dim n As Integer = nk(0)
    Dim k As Integer = nk(1)
    Dim ans As Integer = 0
    Dim q As Integer = n
    Do While q > 0
      q \= k
      ans += 1
    Loop
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

void solve() {
    string s, t;
    cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    int ans = 1e7;
    int i = 0;
    for (int k = 0; k < n - m + 1; k++) {
        int cnt = 0, tmp = i;
        for (int j = 0; j < m; j++) {
            //cout << s[tmp] << ' ' << t[j] << endl;
            if (s[tmp] != t[j]) {
                cnt++;
            }
            tmp++;
        }
        i++;
        //cout << cnt << endl;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int n, s, cnt;
int list[10] = {0};


void cntAll(int i, int sum, int k)
{
    if (k==n && sum==s) cnt++;

    if (i==10 || k==n || sum>s) return;

    cntAll(i+1, sum+list[i], k+1);

    cntAll(i+1, sum, k);
}

int main()
{
    for (int j=0; j<10; j++) list[j] =j;
    while (scanf("%d %d", &n, &s))
    {
        cnt=0;
        if (n==0 && s==0) break;
        cntAll(0, 0, 0);
        printf("%d\n", cnt);
    }
    return 0;
}


Measured memory_bytes: 2024
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef vector<vvin> vvvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
vvvin g(201,vvin(201,vin(201)));
void gcdinit(){
  rep(i,1,201){
    rep(j,i,201){
      rep(k,j,201){
        g[i][j][k]=gcd(i,gcd(j,k));
        g[j][i][k]=g[i][j][k];
        g[i][k][j]=g[i][j][k];
        g[j][k][i]=g[i][j][k];
        g[k][j][i]=g[i][j][k];
        g[k][i][j]=g[i][j][k];
      }
    }
  }
}
int main(){
  int n;cin>>n;ll sum=0;
  gcdinit();
  rep(i,1,n+1){
    rep(j,1,n+1){
      rep(k,1,n+1){
        sum+=g[i][j][k];
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 36688
#include <bits/stdc++.h>
using namespace std; 
const int maxn = 100500;
const int mod = 1e9 + 7;
#define int long long

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    int gg[2], ss[2], bb[2];
    cin >> n;
    for(int i = 0 ; i < 2 ; ++i)
        cin >> gg[i] >> ss[i] >> bb[i];
    vector < pair < int, int > > a, b;
    if(gg[0] > gg[1]) a.push_back({gg[1], gg[0]});
    else b.push_back({gg[0], gg[1]});
    if(ss[0] > ss[1]) a.push_back({ss[1], ss[0]});
    else b.push_back({ss[0], ss[1]});
    if(bb[0] > bb[1]) a.push_back({bb[1], bb[0]});
    else b.push_back({bb[0], bb[1]});
    int ans = n;
    if((int)b.size() > 0){
        if((int)b.size() == 1) ans = b[0].second * (ans / b[0].first) + ans % b[0].first;
        if((int)b.size() == 2){
            int bst = 0;
            for(int i = 0 ; i <= ans ; ++i){
                if(i * b[0].first > ans) break;
                int sm = b[0].second * i;
                int rem = ans - i * b[0].first;
                sm += b[1].second * (rem / b[1].first);
                sm += rem % b[1].first;
                bst = max(bst, sm);
            }
            ans = max(ans, bst);
        }
        if((int)b.size() == 3){
            int bst = 0;
            for(int i = 0 ; i <= ans ; ++i)
                for(int j = 0 ; j <= ans; ++j){
                    if(i * gg[0] + j * ss[0] > ans) continue;
                    int sm = (i * gg[1]) + (j * ss[1]);
                    int rem = ans - i * gg[0] - j * ss[0];
                    sm += bb[1] * (rem / bb[0]);
                    rem %= bb[0];
                    bst = max(bst, sm + rem);
                }
            ans = max(ans, bst);
        }
    } 

    if((int)a.size() > 0){
        if((int)a.size() == 1) ans = a[0].second * (ans / a[0].first) + ans % a[0].first;
        if((int)a.size() == 2){
            int bst = 0;
            for(int i = 0 ; i <= ans ; ++i){
                if(i * a[0].first > ans) break;
                int sm = a[0].second * i;
                int rem = ans - i * a[0].first;
                sm += a[1].second * (rem / a[1].first);
                sm += rem % a[1].first;
                bst = max(bst, sm);
            }
            ans = max(ans, bst);
        }
        if((int)a.size() == 3){
            int bst = 0;
            for(int i = 0 ; i <= ans ; ++i)
                for(int j = 0 ; j <= ans; ++j){
                    if(i * gg[1] + j * ss[1] > ans) continue;
                    int sm = (i * gg[0]) + (j * ss[0]);
                    int rem = ans - i * gg[1] - j * ss[1];
                    sm += bb[0] * (rem / bb[1]);
                    rem %= bb[1];
                    bst = max(bst, sm + rem);
                }
            ans = max(ans, bst);
        }
    }
    cout << ans << '\n';
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long sum , minx, maxx, x, n;
	cin >> n;
	cin >> x;
	sum = minx = maxx = x;
	for(int i=2; i<=n; i++){
		cin >> x;
		sum += x;
		if(minx > x)
			minx = x;
		if(maxx < x)
			maxx = x;
	} 
	cout << minx << " " << maxx << " " << sum << endl;
	return 0;
} 


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

int mod = 1e9 + 7;

void solution(){

	int n, m; cin >> n >> m;
	int A[n+1][m+1];
	memset(A,0,sizeof(A));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			char x; cin >> x;
			if(x == '#') A[i][j] = 1;
		}
	}
	ll dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	dp[1][1] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(i == 1 && j == 1) continue;
			if(!A[i-1][j])
				dp[i][j] += dp[i-1][j];
			if(!A[i][j-1])
				dp[i][j] += dp[i][j-1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[n][m] << endl;





}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 15324
//C(a[i] + a[j] + b[i] + b[j], a[i] + a[j])
//(-a[i], -b[i])->(a[j], b[j])
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 4010, mod = 1e9 + 7;
int n, a[int(2e5) + 10], b[int(2e5) + 10], f[N][N], fac[2 * N], inv[2 * N];
int C(int n, int m) { return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod; }
int pw(int a, int b) { int w = 1; for(;b;b >>= 1, a = 1LL * a * a % mod) if (b & 1) w = 1LL * w * a % mod; return w; }
int main() {
	fac[0] = 1; rep(i,1,2 * N - 5) fac[i] = 1LL * i * fac[i - 1] % mod;
	inv[2 * N - 5] = pw(fac[2 * N - 5], mod - 2); dep(i,2 * N - 6,0) inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
	scanf("%d",&n);
	rep(i,1,n) scanf("%d%d",a + i, b + i);
	rep(i,1,n) f[2001 - a[i]][2001 - b[i]]++;
	rep(i,1,N - 5) rep(j,1,N - 5) 
		f[i][j] = ((f[i][j] + f[i - 1][j]) % mod + f[i][j - 1]) % mod;
	int ans = 0;
	rep(i,1,n) ans = (ans + f[2001 + a[i]][2001 + b[i]]) % mod;
	rep(i,1,n) ans = (ans - C(2 * a[i] + 2 * b[i], 2 * a[i])) % mod;
	if (ans < 0) ans += mod;
	printf("%lld\n",1LL * ans * pw(2, mod - 2) % mod);
	return 0;
}


Measured memory_bytes: 64640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>

using namespace std;

int main(){
	
	long n,ans;
	cin >> n;
	if(n%2==0){
		ans=(n-1)/2;
	}else{
		ans=n/2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(N)]
ab.sort(key=lambda x: x[0])
ans = 0
for a, b in ab:
    m = M
    M = max(M-b, 0)
    ans += a*(m-M)
print(ans)


Measured memory_bytes: 64728
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	long long t1,t2,a1,a2,b1,b2;
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(a1 < b1){
		swap(a1,b1);
		swap(a2,b2);
	}

	long long x = (a1 - b1)*t1*60ll,y=(a2-b2)*t2*60ll;
	// cout << x << " " << y << "\n";
	if(y + x > 0ll){
		cout << "0\n";
		return;
	}

	if(y+x == 0){
		cout << "infinity\n";
		return;
	}

	y = abs(y+x);
	cout << 2ll*(x/y) + (x%y ==0 ? 0 : 1)<< "\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	
	solve();
	
	return 0;
}

Measured memory_bytes: 256