akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long 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;
    }
}
// 二項係数計算
long long 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() {
  ll MAX=111111;
  vector<int> s(MAX,1);
  s[0]=0;s[1]=0;
  for(int i=2;i<MAX;i++){
    if(s[i]!=1)continue;
    for(int j=i*2;j<MAX;j+=i)s[j]=0;
  }
  vector<ll> sum(MAX,0);
  sum[1]=0;
  for(int i=3;i<MAX;i+=2){
    if(s[i]==1&&s[(i+1)/2]==1)sum[i]=sum[i-2]+1;
    else sum[i]=sum[i-2];
  }
  int q;cin>>q;
  int a[q];
  rep(i,q){
    int l,r;
    cin>>l>>r;
    a[i]=sum[r]-sum[max(0,l-2)];
  }
  rep(i,q)cout<<a[i]<<endl;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
char a,b;
  cin>>a>>b;
  if(a>b){
    cout<<'>'<<endl;
  }
  else if(a<b){
    cout<<'<'<<endl;
  }
  else{
    cout<<'='<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int K,a,b,c,MIN,A =0;
  if((scanf("%d",&K)) == 1);;
  for(a=1;a<=K;a++){
    for(b=1;b<=K;b++){
      for(c=1;c<=K;c++){
        MIN = a;
        if(MIN>b){
          MIN= b;
        }
        if(MIN>c){
          MIN = c;
        }
        for(;MIN >0;MIN--){
          if(a%MIN == 0 && b%MIN == 0 && c%MIN == 0 ){
                A = A + MIN;
            break;
          }
        }
      }
    }
  }
  printf("%d",A);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y

using namespace std;
typedef pair<int, int> P;

int main() {
	FAST;
	int a,b;
	cin >> a >> b;
	cout << (a-1)*(b-1) << "\n";

	return 0;
}

Measured memory_bytes: 256
c = 0
while True:
    a = input().split(' ')
    x = int(a[0])
    y = int(a[1])

    if (x or y) == 0:
        break;
    elif x < y:
        print(x,y)
    elif x > y:
        print(y,x)
    elif x == y:
        print(x,y)
    c += 1

Measured memory_bytes: 6728
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  string s,t;
  cin>>N>>s>>t;
  rep(i,N+1){
    if(s.substr(i)==t.substr(0,N-i)){
      cout<<N+i<<endl;
      return 0;
      
    }
    
  }
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int primesize,prime[maxn],miu[maxn];
bool notprime[maxn];
void init()
{
    notprime[1]=1;miu[1]=1;
    for(int i=2;i<=100000;i++)
    {
        if(!notprime[i])
        {
            prime[++primesize]=i;
            miu[i]=mod-1;
        }
        for(int j=1;j<=primesize&&i*prime[j]<=100000;j++)
        {
            notprime[i*prime[j]]=1;
            if(i%prime[j]==0)
            {
                miu[i*prime[j]]=0;
                break;
            }
            miu[i*prime[j]]=mod-miu[i];
        }
    }
}
int n,K,ans;
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
int main()
{
    init();
    n=read();K=read();
    for(int i=1;i<=K;i++)
    {
        int sum=0;
        for(int j=1;j*i<=K;j++)
        {
            sum=(sum+1ll*miu[j]*quick_pow(K/(i*j),n))%mod;
        }
        ans=(ans+1ll*sum*i)%mod;
    }
    cout<<ans<<endl;
    return 0;
}   

Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define D(a) (double)(a)
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define For(a,n,in) for(int i=a; i<n; i+=in)
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI acos(-1)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mod 999999937
const int N=1000005;
vll a(N),b(N);
int n;
int main()
{
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,anns=0;
    double d,dd;
    cin>>n;
    cin>>d;
    double x,y;
    for(int i=0; i<n; i++)
    {
        cin>>x>>y;
        dd = sqrt(x*x+y*y);
        if(dd<=d)anns++;
    }
    cout<<anns<<endl;
}


Measured memory_bytes: 18692
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, u, v;
vector<vector<int>> g;
int ug[100005];
int vg[100005];

void dfs(int from, int now, int count, int *vd) {
  vd[now] = count;
  REP(i, g[now].size()) {
    int to = g[now][i];
    if(from == to) continue;
    dfs(now, to, count + 1, vd);
  }
}

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

  cin >> n >> u >> v;
  g.reserve(n + 1);
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs(-1, u, 0, ug);
  dfs(-1, v, 0, vg);

  int ans = 0;
  FOR(i, 1, n + 1) {
    if(ug[i] < vg[i]) ans = max(ans, vg[i]);
  }

  cout << ans - 1 << endl;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using itn = int;
using ld = long double;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()


int main(){
    ll n;
    cin >>n;
    vec<ll> a(n);
    REP(i,n) cin >>a[i];

    bool fir=true;
    int ju=0,ans=1;
    REP(i,n-1){
      if(a[i] != a[i+1]){
        if(a[i] > a[i+1]){
          if(fir){
            fir = false;
            ju = 0;
          }else if(ju == 1){
            ++ans;
            fir = true;
          }
        }else if(a[i] < a[i+1]){
          if(fir){
            fir = false;
            ju = 1;
          }else if(ju == 0){
            ++ans;
            fir = true;
          }
        }
      }
    }

    cout <<ans <<endl;
}


Measured memory_bytes: 1024
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""

# --------------------------------------------

dp = None

def main():
    N = int(input())
    A = list(map(int, input().split()))

    op = 0

    while True:
        for a in A:
            if a % 2 != 0:
                print(op)
                return

        A = list(map(lambda a:a//2, A))
        op += 1

main()


Measured memory_bytes: 4804
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N,K;
    cin >> N >> K;
    int p[N];
    int ans = 0;
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    sort(p,p+N);
    
    for(int j=0;j<K;j++){
        ans += p[j];
    }
    cout << ans <<endl;
    
}


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

int main ()
{
int A,B;
cin>>A>>B;
if(A!=0&&A<=20&&B!=0&&B<=20){
    if(A<=9&&B<=9){
        cout<<A*B;
    }
    else{
        cout<<-1;
    }
}
return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		String[] abc = sc.nextLine().split(" ");
		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);

//		Integer ia = new Integer(a);

		if (a > b) {
			int temp = a;
			a = b;
			b = temp;
		}
		if (b > c) {
			int temp = b;
			b = c;
			c = temp;
		}
		if (a > b) {
			int temp = a;
			a = b;
			b = temp;
		}

		System.out.println(a + " " + b + " " + c);
	}

}

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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if (a >= b && a >= c)
	{
		cout << a * 10 + b + c << endl;
	}
	else if(b >= a && b >= c)
	{
		cout << a + b * 10 + c << endl;
	}
	else
	{
		cout << a + b + c * 10 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a,b,c,d,s=0;

   scanf("%d",&a);
   scanf("%d",&b);
   scanf("%d",&c);
   scanf("%d",&d);
   if(a>b) s+=b;
   else s+=a;
   if(c>d) s+=d;
   else s+=c;

   printf("%d\n",s);
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int now;
string str;

void check(char c){
	if(c == 'm'){
		if(str.substr(now-4,5) == "dream"){
			now=now-5;
			if(now == -1){
				cout << "YES" << endl;
				return;
			}
			check(str[now]);
		}
		else{
			cout << "NO" << endl;
			return;
		}
	}
	else if(c == 'e'){
		if(str.substr(now-4,5) == "erase"){
			now=now-5;
			if(now == -1){
				cout << "YES" << endl;
				return;
			}
			check(str[now]);
		}
		else{
			cout << "NO" << endl;
			return;
		}
	}
	else if(c == 'r'){
		if(str.substr(now-5,6) == "eraser"){
			now=now-6;
			if(now == -1){
				cout << "YES" << endl;
				return;
			}
			check(str[now]);
		}
		else if(str.substr(now-6,7) == "dreamer"){
			now=now-7;
			if(now == -1){
				cout << "YES" << endl;
				return;
			}
			check(str[now]);
		}
		else{
			cout << "NO" << endl;
			return;
		}
	}
	else{
		cout << "NO" << endl;
		return;
	}
}

int main(){
	cin >> str;
	now = str.length()-1;

	check(str[now]);

	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(), d.end());
  int ans = d[n/2] - d[n/2 - 1];
  cout << ans << endl;
}

Measured memory_bytes: 640
r=lambda x:p[x]>0and r(p[x])or x
(n,m,k),*t=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
s=p[:]
for a,b in t:
 x,y=sorted((r(a),r(b)))
 if(x!=y)*m>0:p[x]+=p[y];p[y]=y=x
 if x==y:s[a]-=1;s[b]-=1;m-=1
print(*[s[i+1]-p[r(i+1)]for i in range(n)])

Measured memory_bytes: 96856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;

vector<bool> seen;
map<pair<int,int>,int> m;
int ans=0;
void dfs(const Graph &G,int v,int c){
    seen[v]=true;
    int co=1;
    for(auto nv:G[v]){
        if(seen[nv])continue;
        if(co==c)co++;
        m[make_pair(v,nv)]=co;
        dfs(G,nv,co);
        co++;
    }
    ans=max(ans,co-1);
}



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

    int N;
    cin>>N;

    pair<int,int> a[N-1];
    Graph G(N);
    rep(i,N-1){
        int q,w;
        cin>>q>>w;
        q--;
        w--;
        G[q].push_back(w);
        G[w].push_back(q);
        a[i]=make_pair(q,w);
    }
    seen.assign(N,false);
    dfs(G,0,0);
    cout << ans << endl;
    rep(i,N-1){
        cout << m[a[i]]<<endl;
    }
    

    



}


Measured memory_bytes: 14336
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#define endl "\n"
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

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

const int nmax = 2e5+7;

void solveTC()
{
    int n;
    cin>>n;

    vector<int>a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];

    vector<int>endPA(n+1,-1); /// ending position in a
    vector<int>stPA(n+1,-1); /// starting position in a

    for(int i=0;i<n;i++) endPA[a[i]] = i;
    for(int i=n-1;i>=0;i--) stPA[a[i]] = i;

    int max_shift = 0;

    for(int i=0;i<n;i++)
    {
        if(i>0 && b[i]==b[i-1]) continue;
        if(endPA[b[i]]==-1) continue;

        int stPB = i;
        if(stPB <= endPA[b[i]])
        {
            int shift = endPA[b[i]] - stPB + 1;
            max_shift = max(shift,max_shift);
        }
    }

    vector<int>new_pos(n),ans(n);

    for(int i=0;i<n;i++) new_pos[i] = (i + max_shift) % n;
    for(int i=0;i<n;i++) ans[new_pos[i]] = b[i];

    bool hobe = true;
    for(int i=0;i<n;i++) if(a[i]==ans[i]) hobe = false;

    if(hobe)
    {
        cout<<"Yes"<<endl;
        for(int x:ans) cout<<x<<" ";
        cout<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    DBG(ans);
}

int32_t main()
{
    optimizeIO();

    int tc = 1;

    while(tc--)
    {
        solveTC();
    }

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 7920
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,Q = II()
S = str(input())
l,r = Line(Q)

a = [0]*N
for i in range(N-1)[::-1]:
    if S[i:i+2] == 'AC':
        a[i] = a[i+1]+1
    else:
        a[i] = a[i+1]

for i in range(Q):
    print(a[l[i]-1]-a[r[i]-1])

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	VI sk(4);
	rep(i, n){
		string s;
		cin >>s;
		if(s[0]=='A') sk[0]++;
		else if(s[0]=='W') sk[1]++;
		else if(s[0]=='T') sk[2]++;
		else sk[3]++;
	}
	
	cout <<"AC x "<<sk[0]<<"\nWA x "<<sk[1];
	cout <<"\nTLE x "<<sk[2] <<"\nRE x " <<sk[3] <<"\n";
	return 0;
}


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

// Use of dynamic bitset to convert decimal numbers.
// https://stackoverflow.com/questions/42759330/use-of-dynamic-bitset-to-convert-decimal-numbers
// 10進数 → 2進数.
// @param n: 2進数へ変換したい10進数.
// @param d: 2進数表記する桁数.
// @return: 2進数.
string decimalToBinary(int n, int d) {
    string ret;
    int ln = abs(n);
    while(ln){
        ret = string((ln & 1) ? "1" : "0") + ret;
        ln /= 2;
    }
    while(ret.size() < d) ret = "0" + ret;
    if(n < 0) ret = "-" + ret;
    return ret;
}

int D[25];

int main(){
    
    // 1. 入力情報.
    int N, d;
    scanf("%d", &N);
    map<int, int> m;
    rep(i, N){
        scanf("%d", &d);
        D[d]++;
    }
    
    // 2. N が 24以上ならば, 0 の はず.
    if(N >= 24){
        printf("%d\n", 0);
        return 0;
    }
    
    // 3. もし, 3個以上選択していたら, 0 を 出力して終了.
    rep(i, 25){
        if(D[i] > 2){
            printf("%d\n", 0);
            return 0;
        }
    }
    
    // 4. 時刻をカウント.
    // ex.
    // 3
    // 7 12 8
    // -> 7 8 12 16 17 を 保存.
    set<int> s;
    rep(i, 25) if(D[i] > 0) s.insert(i), s.insert(24 - i);
    // for(auto &p : s) printf("%d ", p);
    // printf("\n");
    
    // 5. 考えられる時刻の差を書き出したときの最小値を, 
    // それぞれ計算し, その中で, 最大となるものを取得.
    //  0,  1, ... , 12 の 13桁分は, bit = 1 で 探索対象.
    // 13, 14, ... , 24 の 12桁分は, bit = 0 で 探索対象.
    // ex.
    // c[7] = '1' だったら,  7 が 比較対象の時刻.
    // c[7] = '0' だったら, 17 が 比較対象の時刻.
    string c;
    int ans = 0;
    rep(i, 1 << 13){
        c = decimalToBinary(i, 13);
        // printf("%s\n", c.c_str());
        
        // チェック対象かを確認.
        vector<int> v;
        v.push_back(0);
        rep(j, 13){
            if(D[j] == 2 && s.count(j) > 0){
                v.push_back(j);
                v.push_back(24 - j);
                continue;
            }
            if(s.count(j) > 0      && c[j] == '1') v.push_back(j);
            if(s.count(24 - j) > 0 && c[j] == '0') v.push_back(24 - j);
        }
        
        // 人数チェック(※なくても良さそうに見える).
        if(v.size() != N + 1) continue;
        
        // (N + 1)人 の 差分を確認.
        int diff = 123454321;
        int t = 0;
        rep(j, N + 1){
            rep(k, N + 1){
                t = abs(v[j] - v[k]);
                if(j != k) diff = min(diff, min(t, 24 - t));
            }
        }
        
        // 更新.
        ans = max(ans, diff);
    }
    
    // 6. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int x, y, sum;
      string op;
      cin >> x >> op >> y;
      if (op == "+"){
        sum = x + y; 
      } else if(op == "-"){
        sum = x - y;
      } 
      cout << sum << endl;
    }

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

int main() {
	string S;
  cin >> S;
  
  if ("Sunny" == S) {
    cout << "Cloudy" << endl;
  } else if ("Cloudy" == S) {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
void solve()
{
    ll n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3&&i%5)
            ans+=i;
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9 + 7;

int32_t main(){
	fastio;
	
	char c; cin >> c;
	if(c>='a' && c<='z'){
		cout << 'a' << endl;
	}else{
		cout << 'A' << endl;
	}
	return 0;
}
		


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cctype>
using namespace std;
int a[100010];
int main()
{
	int i; a[0] = 0;
	for(i = 1; i < 100001; i++)
		a[i] = a[i-1] + i;
	//printf("%d %d\n", a[2], a[4]);
	int x;
	while(scanf("%d", &x) != EOF)
	{
		int k = lower_bound(a, a + 100000, x) - a;
		printf("%d\n", k);
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<pair<int, int>>A;
  rep(i,N){
    int a=0;
    cin>>a;
    A.push_back(make_pair(a,i+1));
  }
  sort(A.begin(),A.end());
  rep(i,N){
    cout<<A[i].second<<"\n";
    }
}

Measured memory_bytes: 1780
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,n,nxt,code,MAX,sel;
int num[20],dist[20],wei[20],next[36000][20];
double time[36000][20],speed[36000],ttt,tim;

int main(){
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&dist[i],&wei[i]);
		wei[i]*=20;
	}

	MAX=1<<n;

	for(code=MAX-2;code>=0;code--){
		sel=0;
		for(j=0;j<n;j++){
			if(code >> j & 1)sel+=wei[j];
		}
		speed[code]=2000.0/(sel+70);
	}

	for(code=MAX-2;code>0;code--){
		for(i=0;i<n;i++){
			if(code >> i & 1){
				ttt=99999999;
				for(j=0;j<n;j++){
					if( !(code>>j&1) ){
						tim=time[code+ (1<<j) ][j]+abs(dist[i]-dist[j])/speed[code];
						if(tim<ttt){ttt=tim;sel=j;}
					}
				}
				time[code][i]=ttt;
				next[code][i]=sel;
			}
		}
	}

	ttt=99999999;
	for(j=0;j<n;j++){
		tim=time[1<<j][j];
		if(tim<ttt){ttt=tim;sel=j;}
	}
	time[0][0]=ttt;
	next[0][0]=sel;

	for(i=0,j=0;i<MAX-1;){
		nxt=next[i][j];
		printf("%s%d",i>0?" ":"",num[nxt]);
		i+=1<<nxt;
		j=nxt;
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 9040
using System;
      class Program
    {

        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = a, ans = 1;
            if (b == 1)
            {
                Console.WriteLine(0);
                return;
            }
            while (c < b)
            {
                c--;
                c += a;
                ans++;
            }
            Console.WriteLine(ans);

        }
    }

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

int main(){
  int a[4],b[4];
  while(1){
  rep(i,4)cin >> a[i];
  rep(i,4)cin >> b[i];
  if(cin.eof())break;

  int blow=0,hit=0;

  rep(i,4){
    if(a[i]==b[i])hit++;
}
  rep(i,4)for(int j=0;j<4;j++){
    if(a[i]==b[j]&&i!=j)blow++;
}
  cout << hit <<" "<< blow << endl;
  }

}

Measured memory_bytes: 1160
def main():
    N=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    count=0
    for i in range(N):
        if A[i]<=B[i]:
            if A[i+1]<=B[i]-A[i]:
                count+=A[i+1]+A[i]
                A[i+1]=0
            else:
                count+=B[i]
                A[i+1]=A[i+1]-(B[i]-A[i])
        if A[i]>B[i]:
            count+=B[i]
    print(count)
if __name__=="__main__":
    main()

Measured memory_bytes: 18752
n = int(input())
array = [[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    if array[i][0]**2+array[i][1]**2 == array[i][2]**2:
        print("YES")
    elif array[i][0]**2+array[i][2]**2 == array[i][1]**2:
        print("YES")
    elif array[i][1]**2+array[i][2]**2 == array[i][0]**2:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7836
#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 REPr(i,n) for(int i=(n)-1;i>=0; --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 SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&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 VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#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 SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
	string s;
	getline(cin,s);
	int n = s.length();

	bool pos = true;
	if (s[0] == '0') pos = false;
	if (s[n-1] == '1') pos = false;

	FORq(i,1,n-1){
		if (s[i-1] != s[n-i-1]) pos = false;
	}

	if (pos == false){
		PRINTD(-1);
		return 0;
	}

	s[n-1] = '1';
	int right = 1;

	REP(i,n-1){
		for(int j = max(i+1,right) ;j <= n-1 ;++j){
			if (s[j] == '0') {
				right = max(j,right);
				continue;
			}

			printf("%d %d\n",i+1,j+1);
			break;
		}
	}

}


Measured memory_bytes: 1664
#include <iostream>

using namespace std;

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

    cout << a[0] << b[0]<<c[0]<<endl;
    return 0;
}
//while (cin >> str) {
///* 何か処理 */
//}
//long long n,t;
//long long a[100005];
//long long uru[100005]={0};
//cin>>n>>t;
//for(int i=0;i<n;i++){
//cin>>a[i];
//}
//#include<stdio.h>
//#include<algorithm>
//using namespace std;
//char in[110000];
//int main(){
//    scanf("%s",in);
//    int ret=0;
//    for(int i=0;in[i];i++){
//        if(i&&in[i]!=in[i-1])ret++;
//    }
//    printf("%d\n",ret);
//}

//int a,b;scanf("%d%d",&a,&b);
//for(int i=0;i<a;i++)scanf("%d",p+i);
//#include <iostream>
//#define REP(i,n) for (int i=0;i<(n);i++)

//int main() {
//
//    std::cout << "Hello, World!" << std::endl;
//    return 0;
//}

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

int main() {
 	int n,q;
  	cin >>n;
 	int A[n]; 
  	rep(i,n) {
      scanf("%d",&A[i]);
    }
  	cin >>q;
  	int m[q];
  	rep(i,q){
    scanf("%d",&m[i]);
    }
  	int sum=0;
  	int flag=0;
  	int sss=0;  
  	rep(i,n) {
      sss+=A[i];
    }
  rep(k,q){
  	
    	flag=0;
      	sum=0;
  if(sss>=m[k]){
    for(int tmp=0;tmp<(1<<n);tmp++){
  		flag=0;
      	sum=0;
     	bitset<20> bs(tmp);
  		rep(i,n){
          if(bs.test(i)){
          sum+=A[i];
          }
        }
  		if(sum==m[k]){flag=1;break;} 
    }
  }
    if(flag==1){printf("yes\n");}
    else{printf("no\n");}
   }
   
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main()
{
  int S, W;
  cin >> S >> W;
  if(S<=W){
    puts("unsafe");
  }else{
    puts("safe");
  }
}

Measured memory_bytes: 3596
function Main(input) {
  lines = input.split('\n')
  N = lines.shift() * 1
  ans = 0
  d = {}
  for (i=0; i<N; i++) {
      l = lines[i].split('').sort().join('')
      if (!d[l]) {
          d[l] = 1
      } else {
          d[l] += 1
      }
  }
  k = Object.keys(d)
  for (i=0; i<k.length; i++) {
      if (d[k[i]] > 1) {
          j = d[k[i]] - 1
          while (j > 0) {
              ans += j
              j--
          }
      } 
  }
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 42848
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, k;
	int ans;
	while (true){
		int a[100001] = {}, b[100001] = {};
		n = 0; k = 0;
		ans = 0;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int x = 0; x<k; x++){
			b[1] += a[x + 1];
		}
		ans = b[1];
		for (int i = 2; i <= n; i++){
			if ((i+k)==(n+1))	break;
			b[i] = b[i - 1] - a[i - 1] + a[i + k - 1];
			ans = max(b[i], ans);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1944
INF = float('inf')
from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, From, To, cost=1):
        self.graph[From].append((To,cost))

    def get_nodes(self):
        return self.graph.keys()

class Dijkstra(object):

    def __init__(self, graph, start):
        self.g = graph.graph
        self.dist = defaultdict(lambda:INF)
        self.dist[start] = 0
        self.prev = defaultdict(lambda: None)
        self.Q = []
        heappush(self.Q,(self.dist[start], start))

        while  self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, cost in self.g[u]:
                alt = dist_u + cost
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q,(alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]

        return path[::-1]

N, M = map(int,input().split())
g = Graph()

for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g.add_edge(a,b)

ans = INF
d = [Dijkstra(g,i).dist for i in range(N)]
k = -1
l = -1
for i in range(N-1):
    for j in range(i+1,N):
        if d[i][j]+d[j][i] < ans:
            k = i
            l = j
            ans = d[i][j]+d[j][i]
    
if ans != INF:
    path = Dijkstra(g,k).shortest_path(l)[:-1]+Dijkstra(g,l).shortest_path(k)[:-1]
    print(ans)
    for node in path:
        print(node+1)
else:
    print(-1)

Measured memory_bytes: 126424
# coding: utf-8
# Your code here!

while True:
    n = input()
    if n == "0":
        break
    a = n[1:].count("A")
    b = n[1:].count("B")
    if a < b:
        (a1, b1) = (0, 1)
    else:
        (a1, b1) = (1,0)
    print(a+a1, b+b1)


Measured memory_bytes: 5564
N = int(input())
A = list(map(int, input().split()))

index = 0

for a in A:
  if a % 2 == 0:
    if a % 3 != 0 and a % 5 != 0:
      index += 1

if index > 0:
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 3060
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll h, w, a, b; cin >> h >> w >> a >> b;
  cout << w * h - (a * (h / a)) * (b * (w / b)) << endl;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const ll MAX = 2000000;
const ll MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void Main(){
    COMinit();
    ll x;cin>>x;
    ll y;cin>>y;
    if((x+y)%3==0&&x<=y*2&&y<=x*2)ans+=COM((x+y)/3,x-(x+y)/3);
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int m = n - k + 1;
  double ans = 0.0;
  rep(i, k) ans += ((double)p[i] + 1) / 2;
  double now = ans;
  for(int i = 0; i + k < n; i++) {
    now += ((double)p[i + k] + 1) / 2;
    now -= ((double)p[i] + 1) / 2;
    ans = max(ans, now);
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double complex<long double>
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;


signed main() {
	int N, K;
	cin >> N >> K;

	if (K % 2 == 1) {
		int zero = N / K;
		// zero **3;
		cout << zero * zero * zero << "\n";
		return 0;
	}
	else {
		int zero = 0;
		int d2 = 0;

		REPS(i, N) {
			int mo = i % K;
			if (mo == 0) {
				zero++;
			}
			if (mo == K / 2) {
				d2++;
			}

			
		}
		cout << zero * zero * zero + d2 * d2 * d2 << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl h(n);rep(i,n)cin >> h[i];
    vl dp(n,INF);dp[0]=0;
    rep(i,n-1){
        chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        if(i+2<n)chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] <<endl;
}

Measured memory_bytes: 4844
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N ;
    cin >> N ;

    int count = 0 ;
    char s[N];
    
    for(int j = 0; j < N ; j++){
        cin >> s[j] ;
    }

    for(int i = 0; i < N -2 ; i++){
        
        if(s[i] == (char)'A'){
            if(s[i+1] == (char)'B'){
                if(s[i+2] == (char)'C'){
                     count++ ;
                }
            }
        }
    }
     
    cout << count << endl;

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
	string s;
	cin>>s;
	if (s[2] == s[3] && s[4] == s[5]) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

int main()
{
  int count = 0;
  string S, T;
  cin >> S >> T;

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

  cout << count << endl;
}

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

int main() {
    string s;
    cin >> s;
    int a = (s[0]-'0') * 10 + (s[1]-'0');
    int b = (s[2]-'0') * 10 + (s[3]-'0');
    
    if(a == 0){
        if(0<b && b<13){
            printf("YYMM\n");
        }else{
            printf("NA\n");
        }
    }
    else if(a>12){
        if(b>12 || b==0){
            printf("NA\n");
        }else{
            printf("YYMM\n");
        }
    }else{
        if(b>12 || b==0){
            printf("MMYY\n");
        }else{
            printf("AMBIGUOUS\n");
        }
    }
}



Measured memory_bytes: 256
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        x: i64,
        y: i64,
    }
    for i in 0..100 {
        for j in 0..100 {
            if i + 3 * j == y - x && i + j == x {
                dbg!(i, j);
                println!("{}", "Yes");
                return;
            }
        }
    }
    println!("{}", "No");
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    int H, W;
    cin >> H >> W;
    H+=2;W+=2;
    vector<vector<char>> grid(H,vector<char>(W,'#'));
    for(int i=1; i<H-1; i++){
        for(int j=1; j<W-1; j++){
            cin >> grid[i][j];
        }
    }

    vector<vector<int>> cnt(H,vector<int>(W,0));
    for(int i=0; i<H; i++){
        int c=0;
        int s=-1;
        for(int j=0; j<W; j++){
            if(grid[i][j]=='.'){
                c++;
            }else{
                for(; s<j && s>=0; s++){
                    cnt[i][s]+=c;
                }
                s=j+1;
                c=0;
            }
        }
    }
    //cout_mat(cnt);cout<<endl;
    for(int j=0; j<W; j++){
        int c=0;
        int s=-1;
        for(int i=0; i<H; i++){
            if(grid[i][j]=='.'){
                c++;
            }else{
                for(; s<i && s>=0; s++){
                    cnt[s][j]+=c-1;
                }
                s=i+1;
                c=0;
            }
        }
    }
    int ans=0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            ans=max(ans,cnt[i][j]);
        }
    }
    //cout_mat(cnt);
    cout << ans << endl;
}

Measured memory_bytes: 19968
from itertools import permutations
import math
menu = 5
times = [int(input()) for i in range(menu)]
orders = list(permutations(times,menu))
minimum = sum(math.ceil(time/10)*10 for time in times)
for order in orders:
  total = 0
  for i in range(menu-1):
    total += math.ceil(order[i]/10)*10
  total += order[4]
  minimum = min(minimum,total)
  
print(minimum)
  
      
      

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	ll X;
	cin >> X;
	ll a, b, c;
	a = X;
	b = X;
	c = X;
	cout <<bitset<32>(X)<<endl;
	cout << bitset<32>(~a) << endl;
	cout << bitset<32>(b<<1) << endl;
	cout << bitset<32>(c>>1) << endl;
	return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    cin >> n;
    vector<ll> arr(n+2, 1e6);
    unordered_map<ll, int> pos;
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
        pos[arr[i]] = i;
    }
    set<ll> tree = {{0, n+1}};
    ll ans = 0;
    for(ll val = n; val >= 1; val--) {
        ll p = pos[val];
        auto it = tree.lower_bound(p);
        if (*it != n+1) { // next & next^2 larger
            ans += val * (*next(it) - *it) * (p-*prev(it));
        }
        if (*prev(it) != 0) { // prev & prev^2 larger
            ans += val * (*prev(it)-*prev(prev(it))) * (*it-p);
        }
        tree.insert(p);
    }
    cout << ans << endl;
    return 0;
}




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

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  int max=0;
  int x=0;
  for(auto itr=S.begin();itr!=S.end();itr++){
    if(*itr=='I'){
      ++x;
    }else{
      --x;
    }
    if(x>=max) max=x;
  }
  cout << max << endl;
  
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  int ans = 0;
  int num = 1;
  for(int i = 1; i <= N; i++){
    int tmp = i;
    int tmp_ans = 0;
    while(tmp%2==0){
      tmp /= 2;
      tmp_ans++;
    }
    if(chmax(ans, tmp_ans)){
      num = i;
    }
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
def use_fast_io():
    global input
    import io, sys
    f = io.BytesIO(sys.stdin.buffer.read())
    input = f.readline

use_fast_io()


from scipy.sparse.csgraph import floyd_warshall

N, M, L = map(int, input().split())
graph = [[float("inf")] * N for _ in range(N)]
for _ in range(M):
    s, t, w = map(int, input().split())
    if w <= L:
        graph[s-1][t-1] = graph[t-1][s-1] = w
dist = floyd_warshall(graph, directed=False)
dist = floyd_warshall(dist <= L, directed=False)
dist[dist == float("inf")] = 0.0

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(int(dist[s-1][t-1]) - 1)
print(*ans, sep='\n')


Measured memory_bytes: 21136