akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll lcm(ll a,ll b)
{
	return a/__gcd(a,b)*b; 
}
int main()
{
	ll a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld\n",lcm(a,b));
	return 0;
} 

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

#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<int,pi>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define debug cout<<"debugging"<<endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int I_LIMIT = 999999999;
ll L_LIMIT = 19999999999999999;
ll mod = 998244353;

void solve()
{
    ll n,x,m,i,ans=0,p,s,c,sum1,sum2,k;
    cin>>n>>x>>m;
    ll A[m];
    for(i=0;i<m;i++)
        A[i] = (i*i)%m;
    
    bool visited[m];
    memset(visited,false,sizeof(visited));
    
    p = x;
    while(visited[p]==false)
    {
        visited[p] = true;
        p = A[p];
    }

    s = A[p];
    c = 1;
    sum1 = p;
    while(s!=p)
    {
        sum1 += s;
        s = A[s];
        c++;
    }

    s = A[x];
    sum2 = x;
    n--;
    while(n>0 && s!=p)
    {
        n--;
        sum2 += s;
        s = A[s];
    }

    if(n==0)
    {
        cout<<sum2<<"\n";
        return;
    }
    
    k = n/c;
    ans = sum2 + k*sum1;
    
    n = n%c;

    if(n==0)
    {
        cout<<ans<<"\n";
        return;
    }
    s = A[p];
    sum1 = p;
    n--;
    while(n>0)
    {
        n--;
        sum1 += s;
        s = A[s];
    }

    ans += sum1;
    cout<<ans<<"\n";
}
int main()
{
    IOS;
    solve();
}


Measured memory_bytes: 4500
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll mod[2019];
    memset(mod,0,sizeof mod);
    mod[0]=1;
    ll ant=0;
    ll ans=0;
    ll n = sz(s);
    ll base = 1;
    per(i,n,0){
        ll modact = (ant+(s[i]-'0')*base)%2019;
        ant=modact;
        // cout<<modact<<" "<<mod[modact]<<endl;
        ans+=mod[modact];
        base*=10;
        base%=2019;
        mod[modact]++;
    }
    cout<<ans<<'\n';
    return 0;   
}

Measured memory_bytes: 3760
//
//NOMURA 2020
//A - Study Scheduling
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ans = (h2*60+m2) - (h1*60+m1) - k;
    if (ans < 0) ans = 0;

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


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

int main() {
  int n;
  cin >> n;
  int num = 0;
  
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    num += r - l + 1;
  }
  
  cout << num << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

int main()
{
    int n;
    cin >> n;
    bool y = true;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            if (!((a % 3 == 0) or (a % 5 == 0))) y = false; 
        }
    }
    if (y) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc051/tasks/abc051_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#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++)

void printmap(pii diff) {
    if (diff.second > 0) {
        REP(i, diff.second) cout << "U";
    } else {
        REP(i, -diff.second) cout << "D";
    }
    if (diff.first > 0) {
        REP(i, diff.first) cout << "R";
    } else {
        REP(i, -diff.first) cout << "L";
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    pii from, to, diff;
    cin >> from.first >> from.second >> to.first >> to.second;
    diff.first = to.first - from.first;
    diff.second = to.second - from.second;
    printmap(diff);
    diff.first = -diff.first;
    diff.second = -diff.second;
    printmap(diff);
    diff.first = -diff.first;
    diff.second = -diff.second;
    diff.first++;
    diff.second++;
    cout << "L";
    printmap(diff);
    cout << "DR";
    diff.first = -diff.first;
    diff.second = -diff.second;
    printmap(diff);
    cout << "U\n";
    return 0;
}
// UURDDLLUUURRDRDDDLLU
// UURDDLLUUURRDRDDDLLU

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    int an;
    cin >> n;
    
    long long max,min,sum;
    max = -1000000;
    min = 1000000;
    sum = 0;
    
    for (int x = 0; x < n; x++) {
        cin >> an;
        if (an > max) {
            max = an;
        }  
        if (an < min) {
            min = an;
        }
       
        sum += an;    
    }
    
    cout << min << " " << max << " " << sum << endl;
    
    
    return 0;
}

Measured memory_bytes: 1160
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
N = int(input())
A = list(map(int, input().split()))
ans =0
for i in range(1,N):
    a =A[i-1] -A[i]
    if a >0:
        A[i] +=a
        ans +=a
print(ans)

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}



int main(void)
{
    int N;
    cin >> N;
    vector<int> d;
    FOR(i, 2, N + 1) {
        int n = i;
        FOR(j, 2, n + 1) {
            while (n % j == 0) {
                n /= j;
                d.pb(j);
            }
        }
    }
    sort(all(d));
    PRINTA(d, 0, d.size());
    int cnt = 1;
    vector<int> v;
    FOR(i, 1, d.size() + 1) {
        if (i == d.size() || d[i] != d[i - 1]) {
            v.pb(cnt);
            cnt = 1;
        } else {
            cnt++;
        }
    }
    //sort(all(v), greater<int>());
    sort(all(v));
    PRINTA(v, 0, v.size());
    int result = 0;
    int x74 = v.end() - lower_bound(all(v), 74);
    int x24 = v.end() - lower_bound(all(v), 24);
    int x14 = v.end() - lower_bound(all(v), 14);
    int x4 = v.end() - lower_bound(all(v), 4);
    int x2 = v.end() - lower_bound(all(v), 2);

    // p_1^74
    result += x74;
    PRINT(x74);

    // p_1^4 * p_2^14
    if (x14 > 0) {
    result += x14 * (x4 - 1);
    PRINT(x14 * (x4 - 1));
    }
    
    // p_1^2 * p_2^24
    if (x24 > 0) {
    result += x24 * (x2 - 1);
    PRINT(x24 * (x2 - 1));
    }

    if (x4 >= 2) {
    // p_1^2 * p_2^4 * p_3^4
    result += x4 * (x4 - 1) / 2 * (x2 - 2);
    PRINT(x4 * (x4 - 1) / 2 * (x2 - 2));
    }

    cout << result << endl;
    return 0;
}

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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="RRR")
        cout<<3;
    else if(s=="RRS"||s=="SRR")
        cout<<2;
    else if(s=="SSS")
        cout<<0;
    else
    {
        cout<<1;
    }
       
    return 0;
}

Measured memory_bytes: 10644
n, k = map(int, input().split())
a = list(map(int, input().split()))
sum_a = [0]
for ai in a:
    sum_a.append(sum_a[-1] + (ai if ai > 0 else 0))
sum_sk = sum(a[:k])
ans = max(sum_sk + sum_a[n] - sum_a[k], sum_a[n] - sum_a[k])
for i in range(n - k):
    sum_sk = sum_sk - a[i] + a[i + k]
    ans = max(ans,
              sum_sk + sum_a[n] - (sum_a[i + k + 1] - sum_a[i + 1]),  # 黒色
              sum_a[n] - (sum_a[i + k + 1] - sum_a[i + 1]))  # 白色
print(ans)

Measured memory_bytes: 14468
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int N;
vector<int> A(N);

int out(vector<int> &A,int N){
    cout<<A[0];
    FOR(i,1,N) cout<<" "<<A[i];
    cout<<endl;
}

int intsertionSort(vector<int> &A,int N){
    FOR(i,1,N){
        RFOR(j,i,0){
            if(A[j] < A[j-1]) swap(A[j],A[j-1]);
        }
        out(A,N);     
    }
}


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

    vector<int> A(N);
    FOR(i,0,N) cin>>A[i];

    out(A,N);
    intsertionSort(A,N);
 
}


Measured memory_bytes: 3076
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

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

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(all(a), greater<ll>());

    ll sum = 0;
    ll m = n / 2;
    rep(i, m) {
        sum += 2 * a[i];
    }

    sum -= a[0];
    if (n % 2 == 0) {
        cout << sum << endl;
    } else {
        sum += a[m];
        cout << sum << endl;
    }
}

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

int n,a,b,p,problemone,problemtwo,problemthree;

int main(){
	cin>>n>>a>>b;
	for(int i = 1;i <= n;i++){
		cin>>p;
		if(p <= a){
			problemone++;
		}else if(p <= b){
			problemtwo++;
		}else{
			problemthree++;
		}
	}
	cout<<min(min(problemone,problemtwo),problemthree)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main (void){
  long int n,a,b,c,d,e = 0;

  scanf("%ld %ld %ld",&n,&a,&b);

  c = a + b;

  d = (n / c);
  n = n - (c * d);
  if (n >= a){
    e = a * d + a;
  }else{
    e = a * d + n;
  }
  printf("%ld\n",e);
  return 0;
}

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

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

ll GCD(ll a, ll b){ll gcd, g;g = __gcd(a, b);return g;}
ll LCM(ll a, ll b){ll gcd, g;g = __gcd(a, b);return (a/g)*b;}
ll PowFun(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}



const ll INF_LONG = 1LL<<61;
const unsigned int inf_int = 1<<31;
const ll mod = 1e9+7;
double phi = acos(-1);

int main()
{
    fastInputOutput();
    int n, k;
    cin >> n >> k;
    int mark[n+4] = {};
    for(int i = 1; i <= k; i++)
    {
        int d;
        cin >> d;
        for(int j = 1; j <= d; j++)
        {
            int tem;
            cin >> tem;
            mark[tem]++;
        }
    }
    int Count = 0;
    for(int i = 1; i <= n; i++)
    {
        if(mark[i] == 0)
        {
            Count++;
        }
    }
    cout << Count << endl;
    return 0;
}


Measured memory_bytes: 3648
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);


int main() {
	fast;
	read(a)
	ll m=a/500;
	a=a%500;
	ll n=a/5;
	cout<<m*1000+n*5<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#include<math.h>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
		--a[i];
	}
	vector<int>b(n);
	rep(i, n) {
		cin >> b[i];
	}
	vector<int>c(n - 1);
	rep(i, n) {
		cin >> c[i];
	}
	int ans = 0;
	rep(i, n) {
		ans += b[a[i]];
		if (i > 0 && a[i] == a[i - 1] + 1) {
			ans += c[a[i - 1]];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define il inline
#define stt static
#define rg register
#define ll long long
#define db double
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define y1 substitute_of_y1
#define DEBUG(x) cerr<<#x" = "<<x<<endl;
using namespace std;

template<typename T> il T rd(){
	T nmb=0;int sgn=0;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')sgn=1;chr=getchar();}
	while(isdigit(chr)){nmb=(nmb<<3)+(nmb<<1)+chr-'0';chr=getchar();}
	return sgn?-nmb:nmb;
}
template<typename T> void wt(T nmb){
	if(nmb>9)wt(nmb/10);
	putchar(nmb%10+'0');
}
template<typename T> il void cmax(T &x,T y){x=x>y?x:y;}
template<typename T> il void cmin(T &x,T y){x=x<y?x:y;}
inline void proc_status(){
	ifstream t ("/proc/self/status");
	cerr<<string(istreambuf_iterator<char>(t),istreambuf_iterator<char>())<<endl;
	/*freopen("/proc/self/status","r",stdin);
	char ch[100];
	while(scanf("%s",ch)!=EOF)cerr<<ch<<endl;*/
}

const int N=5e3+5;
const int P=1e9+7;

vector<int>g[N];

int G[N];
il void getG(int n){
	G[2]=1;
	for(int i=4;i<=n;i+=2)
		G[i]=(ll)G[i-2]*(i-1)%P;
}

int dp[N][N],tmp[N];
int siz[N];
void dfs(int x,int f){
	dp[x][1]=1;
	siz[x]=1;
	for(int T=g[x].size()-1;~T;--T){
		int k=g[x][T];
		if(k==f)continue;
		dfs(k,x);
		for(int i=1;i<=siz[x]+siz[k];++i)tmp[i]=0;
		for(int i=1;i<=siz[x];++i)
			for(int j=0;j<=siz[k];++j)
				(tmp[i+j]+=(ll)dp[x][i]*dp[k][j]%P)%=P;
		for(int i=1;i<=siz[x]+siz[k];++i)
			dp[x][i]=tmp[i];
		siz[x]+=siz[k];
	}
	if(x==1)
		for(int i=1;i<=siz[x];++i)
			(dp[x][0]+=(ll)dp[x][i]*G[i]%P)%=P;
	else
		for(int i=1;i<=siz[x];++i)
			(dp[x][0]+=(ll)(P-dp[x][i])*G[i]%P)%=P;
}

int main(){
	int n=rd<int>();
	for(int i=1;i<n;++i){
		int x=rd<int>(),y=rd<int>();
		g[x].pb(y),g[y].pb(x);
	}
	getG(n);
	dfs(1,0);
	printf("%d\n",dp[1][0]);
	return 0;
}

Measured memory_bytes: 97536
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
void solve() {

    int t = 1;
    //cin >> t;
   while(t--){
        int l,r,i,ans=0,x,n;
        cin>>n;
       for(i=1;i<=n;i++){
        cin>>x;
        if(i%2==1&&x%2==1)
            ans++;
       }
       cout<<ans<<endl;

    }
}

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

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

int N;

int main()
{
	string s;
	cin >> s;
	int res = 0, cnt = 0;
	for(int i=0; i<s.size(); i++)
	{
		if (s[i]=='R') cnt++;
		else
		{
			res = max(res, cnt);
			cnt = 0;
		}
	}
	res = max(res, cnt);
	cnt = 0;
	cout << res;
	return 0;
}

Measured memory_bytes: 3620
K,N = map(int,input().split())
a = [int(i) for i in input().split()]
max_dist = 0
for i in range(N):
    nxt = (i+1)%N
    dist = a[nxt] - a[i]
    if dist < 0:
        dist += K
        
    max_dist = max(max_dist,dist)
print(K-max_dist)

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

template<typename T> vector<T> make_vec(size_t a, T init){return vector<T>(a, init);}
template<typename T,typename... Ts> auto make_vec(size_t a, Ts... ts)
{
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<class T> inline bool chmax(T &a, T b)
{
    if(a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, K;
    cin >> H >> W >> K;
    vector<int> R(K), C(K), V(K);
    for(int i=0; i<K; i++)
    {
        cin >> R[i] >> C[i] >> V[i];
        R[i]--; C[i]--;
    }

    vector<vector<ll>> mp(H+1, vector<ll>(W+1, 0));
    for(int i=0; i<K; i++)
    {
        mp[R[i]][C[i]] = V[i];
    }


    auto dp = vector<vector<vector<ll>>>(H+1, vector<vector<ll>>(W+1, vector<ll>(5, 0)));
    if(mp[0][0] != 0) dp[0][0][1] = mp[0][0];
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            for(int k=0; k<4; k++)
            { 
                if(mp[i+1][j] != 0) chmax(dp[i+1][j][1], dp[i][j][k] + mp[i+1][j]);
                chmax(dp[i+1][j][0], dp[i][j][k]);
                if(mp[i][j+1] != 0) chmax(dp[i][j+1][k+1], dp[i][j][k] + mp[i][j+1]);
                chmax(dp[i][j+1][k], dp[i][j][k]);
            }
        }
    }
    cout << max(dp[H-1][W-1][0], max(dp[H-1][W-1][1], max(dp[H-1][W-1][2], dp[H-1][W-1][3]))) << endl;

    return 0;
}


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

public class Main {
    private static final int MOD = 998244353;

    private long[] nu;
    private long[] de;

    private long pow(long a, long n) {
        long ret = 1, base = a;
        while (n > 0) {
            if ((n & 1) > 0) {
                ret = (ret * base) % MOD;
            }
            base = (base * base) % MOD;
            n >>= 1;
        }
        return ret;
    }

    private long inv(long a) {
        return pow(a, MOD - 2);
    }

    private long c(int n, int m) {
        if (m == 0 || n == m) {
            return 1;
        }
        return (nu[m] * inv(de[m])) % MOD;
    }

    private void solve() {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();

        nu = new long[N];
        de = new long[N];
        nu[0] = de[0] = 1;
        for (int i = 1; i < N; i++) {
            nu[i] = ((N - i) * nu[i - 1]) % MOD;
            de[i] = (i * de[i - 1]) % MOD;
        }

        long ans = 0;
        for (int i = 0; i <= K; i++) {
            long t = c(N - 1, N - 1 - i);
            t = t * pow(M - 1, N - 1 - i) % MOD;
            t = t * M % MOD;
            ans = (ans + t) % MOD;
        }
        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 36212
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 20;
const int INF = 1e9 + 100;

int dp[SIZE];
int tab[SIZE];
int n, w, wi, val;

    void prepro(){
        for(int i = 0; i < SIZE; i++)
            dp[i] = INF;
        dp[0] = 0;
    }

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> w;
    prepro();

    while(n--){
        cin >> wi >> val;

    for(int i = 1e5 + 12; i >= 0; i--)
        if(dp[i] != INF && i + val < SIZE - 10)
            dp[i + val] = min(dp[i + val], dp[i] + wi);
    }

    int licz = 0;

    for(int i = 0; i < SIZE; i++)
        if(dp[i] <= w && i > licz)
            licz = i;

    return cout << licz, 0;
}

Measured memory_bytes: 640
#include<iostream>
#include    <algorithm>
#include    <vector>
#include    <string>
using namespace std;


int main(){
	int n;
	cin >> n;
	int n_ = n/2-1;
	vector<int> data;
	for(int i=0;i<n;i++) {
		int a;
		cin >> a;
		data.push_back(a);
	}
	sort(data.begin(),data.end());
	int m = data[n_];
	int M = data[n_+1];
	int ans = M-m ;
	//cout << M <<" "<<m<<endl;
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
N = int(input())
S = input()
l = 0
r = S[1:].count('E')
ans = l + r
for i in range(1, N):
	if S[i - 1] == 'E':
		r -= 1
	if S[i] == 'W':
		l += 1
	ans = min(ans, l + r)
print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <functional>
#include <utility>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

struct node
{
    int x, y;
};

const int inf = 0x3f3f3f3f;

char s[60][60];
int l[60][60];
int k[60][60];
int g[60][60];
int rx[1010], ry[1010];
int vis[60][60];

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int r, c, m;
int mx, my;
vector <node> a;
vector <node> z;

int dfs(int x, int y, int fx, int fy)
{
    if(x == mx && y == my)
        return 1;
    for(int i = 0; i < 4; i++)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx < 0 || nx >= r || ny < 0 || ny >= c || s[nx][ny] == '#')
            continue;
        if(nx == fx && ny == fy)
            continue;
        if(dfs(nx, ny, x, y) == 1)
        {
            node xin;
            xin.x = nx, xin.y = ny;
            a.push_back(xin);
            return 1;
        }
    }
    return 0;
}

int main()
{
    while(~scanf("%d%d%d", &r, &c, &m))
    {
        memset(vis, -1, sizeof(vis));
        for(int i = 0; i < r; i++)
            scanf("%s", s[i]);
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                scanf("%d", &l[i][j]);
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                scanf("%d", &k[i][j]);
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                scanf("%d", &g[i][j]);
        for(int i = 0; i < m; i++)
            scanf("%d%d", &rx[i], &ry[i]);
        z.clear();
        node qi;
        qi.x = rx[0], qi.y = ry[0];
        z.push_back(qi);
        for(int i = 1; i < m; i++)
        {
            a.clear();
            if(rx[i] == rx[i - 1] && ry[i] == ry[i - 1])
                continue;
            mx = rx[i], my = ry[i];
            dfs(rx[i - 1], ry[i - 1], -1, -1);
            for(int j = a.size() - 1; j >= 0; j--)
            {
                node aa = a[j];
                z.push_back(aa);
            }
        }
//        printf("\n\n");
//        for(int i = 0; i < z.size(); i++)
//        {
//            printf("%d %d\n", z[i].x, z[i].y);
//        }
        long long sum = 0;
        int i;
        for(i = 0; i < z.size(); i++)
        {
            int nx = z[i].x;
            int ny = z[i].y;
            sum += k[nx][ny] + g[nx][ny];
            //cout << sum << endl;
            if(vis[nx][ny] == -1)
            {
                vis[nx][ny] = i;
                continue;
            }
            if((long long)(i - vis[nx][ny]) * l[nx][ny] <  k[nx][ny] + g[nx][ny])
            {
               // printf("%d\n", (k[nx][ny] + g[nx][ny]) - (i - vis[nx][ny) * l[nx][ny]);
                sum -= (k[nx][ny] + g[nx][ny]) - (i - vis[nx][ny]) * l[nx][ny];
            }
            //printf("\n");
            vis[nx][ny] = i;
        }
        //sum += g[rx[i]][ry[i]];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 19652
L, R = gets.split.map(&:to_i)
(puts 0; exit) if R - L >= 2019 - L % 2019

array = (L..R).to_a

min = 2018
array.combination(2) do |a, b|
  break if min == 0
  mod = (a * b) % 2019
  min = mod if mod < min
end

puts min

Measured memory_bytes: 1788
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

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

const int N = 1e5 + 5;
int p[N], q[N];
int r[3 * N];

void solve() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; ++i) cin >> p[i];
    for (int i = 0; i < b; ++i) cin >> q[i];
    for (int i = 0; i < c; ++i) cin >> r[i];
    sort(p, p + a, greater<int>());
    sort(q, q + b, greater<int>());
    for (int i = 0; i < x; ++i) r[c++] = p[i];
    for (int i = 0; i < y; ++i) r[c++] = q[i];
    sort(r, r + c, greater<int>());
    ll re = 0;
    for (int i = 0; i < x + y; ++i) re += r[i];
    cout << re << '\n';
}

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

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    // preprocess();
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}


Measured memory_bytes: 2176
#include <stdio.h>

int ANTEI(char *,int *,char *,int *);

int main()
{
  int n,i,j,flag,min,koukan;
  char change;

  scanf("%d",&n);

  char A[n],As[n];//アルファベットを入れる配列
  int B[n],Bs[n];//数字を入れる配列

  for(i=0;i<n;i++)
    {
      scanf(" %c%d",&A[i],&B[i]);
      As[i]=A[i];
      Bs[i]=B[i];
    }

  for(i=0;i<n;i++)
    {
      /*バブルソート*/
      for(j=n-1;j>i;j--)
	{
	  if(B[j]<B[j-1])
	    {
	      change=A[j-1];
	      A[j-1]=A[j];
	      A[j]=change;

	      koukan=B[j-1];
	      B[j-1]=B[j];
	      B[j]=koukan;
	    }
	}
      
      /*選択ソート*/
      min=i;
      for(j=i+1;j<n;j++)
	{
	  if(Bs[j]<Bs[min])min=j;
	}
      if(min!=i)
	{
	  change=As[min];
	  As[min]=As[i];
	  As[i]=change;

	  koukan=Bs[min];
	  Bs[min]=Bs[i];
	  Bs[i]=koukan;
	}
    }
  /*安定デスカ？*/
  flag=1;
  for(i=0;i<n;i++)
    {
      if(A[i]!=As[i])
	{
	  flag=0;
	  break;
	}
    }
  /*出力*/
  /*バブルソート*/
  for(i=0;i<n-1;i++)printf("%c%d ",A[i],B[i]);
  printf("%c%d\n",A[n-1],B[n-1]);
  printf("Stable\n");
  /*選択ソート*/
   for(i=0;i<n-1;i++)printf("%c%d ",As[i],Bs[i]);
  printf("%c%d\n",As[n-1],Bs[n-1]);
  if(flag==0)printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll ans = 0;
    ans += (x / 11) * 2;
    x -= (x / 11) * 11;
    if (x >= 7) ans += 2;
    else if (x >= 1) ans++;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=2e5+1000;
int a[maxn];
int n,m;
bool check(int l){
    for(int i=l*2+1,j=2*n;i<j;i++,j--){
        if(a[i]+a[j]<m)return 0;
    }
    return 1;
}
int main(){
    ios::sync_with_stdio(0);
   cin>>n>>m;rep(i,1,2*n)cin>>a[i];
    sort(a+1,a+1+2*n);
    int l=0,r=n;
    while(l<r){
        int mid=(l+r)>>1;
        if(check(mid))r=mid;
        else l=mid+1;
    }
    int ans=0;
    for(int i=1,j=l*2;i<=l;i++,j--)ans=max(ans,(a[i]+a[j])%m);
    for(int i=l*2+1,j=2*n;i<j;i++,j--)ans=max(ans,(a[i]+a[j])%m);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4432
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

def match(i,j):
    # i,j <= N-M
    for k in range(M):
        row = A[i+k][j:j+M]
        if row != B[k]:
            return(False)
    return(True)

answer = False
for i in range(N-M+1):
    if answer:
        break
    for j in range(N-M+1):
        if answer:
            break
        if match(i,j):
            answer = True
if answer:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
const int mod = 1000000007;

int main(){
    int n;cin >> n;
    map<ll,ll> mp;
    for(int i=n;i>=2;i--){
        int v=i;
        for(int j=2;j*j<=i;j++){
            while(v%j==0){
                mp[j]++;
                v/=j;
                //cout << v << endl;
                //cout << mp[3] << " " << mp[2] << endl;
            }
        }
        if(v!=1) mp[v]++;
    }
    vector<ll> nums;
    for(auto p: mp){
        nums.push_back(p.second+1);
    }
    sort(nums.begin(),nums.end());
    ll num75=nums.end()-lower_bound(nums.begin(),nums.end(),75);
    ll num25=nums.end()-lower_bound(nums.begin(),nums.end(),25);
    ll num15=nums.end()-lower_bound(nums.begin(),nums.end(),15);
    ll num5=nums.end()-lower_bound(nums.begin(),nums.end(),5);
    ll num3=nums.end()-lower_bound(nums.begin(),nums.end(),3);
    if(num5<2||num3<3){
        cout << 0 << endl;
        return 0;
    }
    ll ans=num5*(num5-1)/2*(num3-2);
    ans+=num25*(num3-1);
    ans+=num15*(num5-1);
    ans+=num75;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int N;
  cin>>N;
  int f[N][10], p[N][11];
  REP(i, N)REP(j, 10) cin>>f[i][j];
  REP(i, N)REP(j, 11) cin>>p[i][j];
  int ans=-2000000001, ei[10];
  int work, cand;
  for(int i=1; i<1024; ++i){
    work=1;
    REP(j, 10){
      ei[9-j] = (i&work)?1:0;
      work *=2;
    }

    cand=0;
    REP(j, N){
    work=0;
      REP(k, 10) {if(ei[k]==1&&f[j][k]==1) ++work;}
      cand += p[j][work];
    }
    ans = max(ans, cand);
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

# all selected
upper = sum(range(N+1))
lower = sum(range(N+1))
answer = 1

for k in range(N, K - 1, -1):
    upper -= N - k
    lower -= max(0, k)
    answer += upper - lower + 1
    # print(k, upper, lower, answer)
print(answer % (10 ** 9 + 7))

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	ll n;
	cin>>n;
	ll ans=pow(((int)sqrt(n)),2);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int K = Integer.parseInt(tokens[1]);
		Map<Integer, List<Integer>> map = getMap(N, K);
		long result = 0;
		long size = map.get(0).size();
		result += size * size * size;
		if (K % 2 == 0) {
			size = map.get(K / 2).size();
			result += size * size * size;
		}
		System.out.println(result);

		in.close();
	}

	public static Map<Integer, List<Integer>> getMap(int N, int K) {
		Map<Integer, List<Integer>> result = new TreeMap<>();
		for (int i = 0; i < K; ++i) {
			result.put(i, new ArrayList<Integer>());
		}
		for (int i = 1; i <= N; i = i + K) {
			for (int j = i; j < i + K; ++j) {
				if (j > N) {
					break;
				}
				result.get(j % K).add(j);
			}
		}
		return result;
	}
}

Measured memory_bytes: 55664
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def solve(N: int, M: int, a: "List[int]"):
    dp = [0] * (N + 2)
    dp[0] = 1
    a =set(a)

    for i in range(1, N+1):
        if i in a:
            dp[i] = 0
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % MOD
    return dp[N]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    result = solve(N, M, a)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16188
lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int,s)
intSub(s::SubString{String})=parse(Int,s)
intLine()=map(intSub,split(input()))
function main()
  n,x=intLine()
  println(searchsortedlast(cumsum(intLine()),x)+1)
end
main()

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

int main() {
    int A, B;
    cin >> A >> B;

    for (int i = 1; i <= 1000; i++){
        if (i * 0.08 < A || i * 0.08 >= A + 1){
            if (i == 1000){
                cout << -1 << endl;
            }
            continue;
        } else if (i * 0.1 < B || i * 0.1 >= B + 1){
            if (i == 1000){
                cout << -1 << endl;
            }
            continue;
        } else {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    int s = (n - 1) * (n - 2) / 2 - k;
    cout << n - 1 + s << endl;
    for (int i = 2; i <= n; i++)
    {
        cout << 1 << " " << i << endl;
    }

    int cnt = 0;
    for (int i = 2; i <= n - 1; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (cnt == s)
                break;
            cout << i << " " << j << endl;
            cnt++;
        }
    }
}

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

double waterVolume(int a, int b, double rad)
{
    if (rad < atan(1.0 * b / a))
    {
        return a * a * b - (a * (a * tan(rad)) / 2 * a);
    }
    else
    {
        return b * (b * tan(M_PI / 2 - rad)) / 2 * a;
    }
}

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double min = 0, max = M_PI / 2;
    while (true)
    {
        double m = (min + max) / 2;
        double vol = waterVolume(a, b, m);
        if (abs(vol - x) < pow(10, -6))
        {
            cout << setprecision(8) << m / M_PI * 180 << endl;
            return 0;
        }
        else if (vol > x)
        {
            min = m;
        }
        else
        {
            max = m;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int w[] = new int[n];
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n; i++) {
				w[i] = sc.nextInt();
				s2 += w[i];
			}

			int ans = s2;
			int dif = 0;
			for (int i = 0; i < n; i++) {
				s1 += w[i];
				s2 -= w[i];
				dif = Math.abs(s1 - s2);
				if (dif < ans) {
					ans = dif;
				}
			}
			
			System.out.println(ans);
		}
	}
}


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


// type {{{
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
// }}}


// macro {{{
#define rep(i,n) for (ll i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i,n) for (ll i=1, i##_len=(n); i<=i##_len; ++i)
#define SZ(x) ((ll)(x).size())
#define all(x) begin(x),end(x)
// }}}


// debug {{{
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    rep (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << " " << p.second << ")";
}
// }}}


// chmax, chmin {{{
template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) { a = b; return true; }
    return false;
}
// }}}



// constants {{{
#define inf(T) numeric_limits<T>::max()
const ll MOD = 1e9+7;
const ld EPS = 1e-9;
// }}}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        int ans = 0;
        for (int i = 1; i*i <= n; ++i) {
            if (i*i == n) ++ans;
            for (int j = i; i*i + j*j <= n; ++j) {
                if (i*i + j*j == n) ++ans;
                for (int k = j; i*i + j*j + k*k <= n; ++k) {
                    if (i*i + j*j + k*k == n) ++ans;
                    for (int l = k; i*i + j*j + k*k + l*l <= n; ++l) {
                        if (i*i + j*j + k*k + l*l == n) ++ans;
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    int ans= -1;
    cin >> n;
    vector<vector<pair<int,int>>> syougen(n,vector<pair<int,int>>());
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            pair<int,int> p;
            int x,y;
            cin >> x >> y;
            x--;
            p = make_pair(x,y);
            syougen[i].push_back(p);
        }
    }
    rep(bit,1<<n){
        int cnt=0;
        bool ok=true;
        rep(i,n){
            if(bit>>i&1){
                rep(j,syougen[i].size()){
                    if((bit>>syougen[i][j].first&1) != syougen[i][j].second) ok=false;
                }
                cnt++; //正直者の人数
            }
        }
        if(ok) ans = max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a.at(i);
	}
	vector<int> min(n);
	min.at(0)=a.at(0);
	for (int i = 0; i < n-1; ++i)
	{
		if(min.at(i)<a.at(i+1)){
			min.at(i+1)=min.at(i);
		}
		else{
			min.at(i+1)=a.at(i+1);
		}

	}
  int count;
	for (int i = 0; i < n; ++i)
	{
		if(min.at(i)==a.at(i)){
			count++;
		}
	}
	cout << count << endl;

}

Measured memory_bytes: 1792