akhauriyash/Code-Regression huggingface dataset:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("YES") if fl else print("NO")
import collections
import math
import itertools
import heapq as hq
def isok1(x,ls1,ls2,cnt=0):
    ##ls1 :minus -2,-1  ls2 :plus 1,2,..
    l1,l2=0,0
    while l1<len(ls1) and l2<len(ls2):
        if ls1[l1]*ls2[l2] <= x:
            cnt+=len(ls2) -l2
            l1+=1
        else:
            l2+=1
    return cnt<k
def isok2(x,ls1,ls2,cnt=0):
    ##ls1 :minus -2,-1,  ls2 :plus 2,1,..
    l,r=0,0
    tmp=0
    while r<len(ls1) and l<len(ls1):
        if ls1[-l-1]*ls1[r] <=x:
            tmp+=len(ls1)-r
            l+=1
        else:
            r+=1
    for i in range(len(ls1)):
        if ls1[i]**2 <=x:tmp-=1
    cnt+=tmp//2
    l,r=0,0
    tmp=0
    while r<len(ls2) and l<len(ls2):
        #print(ls2[-l-1]*ls2[r],l,r)
        if ls2[-l-1]*ls2[r] <=x:
            tmp+=len(ls2)-r
            #print(tmp,ls2[-l-1]*ls2[r],l,r)
            l+=1
        else:
            r+=1
    for i in range(len(ls2)):
        if ls2[i]**2 <=x:tmp-=1
    cnt+=tmp//2
    #print(x,cnt)
    return cnt<k



n,k = ma()
A = lma()
pA = [a for a in A if a>0]
mA = [a for a in A if a<0]
pn = len(mA)*(len(mA)-1)//2 +len(pA)*(len(pA)-1)//2
mn = len(pA) *len(mA)
z = n*(n-1)//2 -pn -mn
if k<=mn:
    f=True
    pA.sort()
    mA.sort()
elif k>mn+z:
    f=False
    pA.sort(reverse=True)
    mA.sort()
else:
    print(0)
    exit()
#print(isok2(6,mA,pA,cnt=mn+z))
ok = -10**18-2
ng = 10**18+2
x = (ok+ng)//2

while ng-ok>1:
    if f:
        if isok1(x,mA,pA):
            ok = x
        else:
            ng=x
        x = (ok+ng)//2
    else:
        if isok2(x,mA,pA,cnt=mn+z):
            ok = x
        else:
            ng=x
        x = (ok+ng)//2
print(ng)


Measured memory_bytes: 110020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    
    for(int i = 0; i<n; i++){
        if(s[i] == 'R')count++;
    }

    string op;
    for(int i = 1; i<=n; i++){
        if(i<=count)op.push_back('R');
        else op.push_back('W');
    }

    int pairs = 0;

    for(int i = 0; i<n; i++){
        if(op[i] != s[i])pairs++;
    }

    cout << (pairs+1)/2 << "\n";
    return 0;
}

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

long long MOD = 1000000007;
static long long F[1000010] = {}, RF[1000010] = {};

long long Calc(long long X, long long Y) {
	if (Y == 0) return 1;
	if (Y % 2 == 0) {
		long long Z = Calc(X, Y / 2);
		return (Z * Z) % MOD;
	}
	return (X * Calc(X, Y - 1)) % MOD;
}

void init() {
	F[0] = F[1] = RF[0] = RF[1] = 1;
	for (long long i = 2; i <= 1000000; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		RF[i] = Calc(F[i], MOD - 2);
	}
	return;
}

long long Comb(long long X, long long Y) {
	if (Y < 0 || X < Y) return 0;
	long long RET = F[X];
	RET *= RF[Y];
	RET %= MOD;
	RET *= RF[X - Y];
	RET %= MOD;
	return RET;
}

int main() {
	init();
	long long X, Y;
	cin >> X >> Y;
	if ((X + Y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	long long P = (X + Y) / 3;
	if (X < P || Y < P) {
		cout << 0 << endl;
		return 0;
	}
	cout << Comb(P, X - P) << endl;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int solve(vector<int> &a,int i,int n,vector<int> &dp){
    if(i==n){
        return 0;
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    int c1=INT_MAX;
    int c2=INT_MAX;
if(i+1<=n){
    c1=abs(a[i+1]-a[i])+solve(a,i+1,n,dp);
}
if(i+2<=n){
    c2=abs(a[i+2]-a[i])+solve(a,i+2,n,dp);
}

return dp[i]=min(c1,c2);
}

int main(){
    int n;
    cin>>n;
    vector<int> a(n+1,0);
    for(int i=1;i<=n;i++){

        cin>>a[i];
    }
    vector<int> dp(n+1,-1);
    cout<<solve(a,1,n,dp);

  return 0;
}


Measured memory_bytes: 11924
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
 
int32_t main(){
	IOS;
	int n,r;
	cin>>n>>r;
	if(n>=10) cout<<r<<endl;
	else cout<<r+100*(10-n)<<endl;	
}

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

d = [0] * N
for i in range(0, N-1):
    for j in range(i+1, N):
        k = min(j-i, abs(X-1-i) + 1 + abs(Y-1-j))
        d[k] += 1

for i in range(1, N):
    print(d[i])


Measured memory_bytes: 46428
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N; cin >> N;
	int T, A; cin >> T >> A;
	vector<int> H(N, 0);
	rep (i, N){
		cin >> H[i];
	} // end rep

	int res = INF;
	int ans = -1;

	rep (i, N){
		int curr = 1000 * T - H[i] * 6;
		int diff = abs(1000 * A - curr);
		if (diff < res){
			ans = i;
			res = diff;
		} // end if
	} // end rep

	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

bool is_used[26];
int main()
{
  std::string s;
  std::string::iterator it;
  std::cin >> s;
  //std::cout << 'z' - 'a' << std::endl;

  for (int i = 0; i < 26; i++) {
    is_used[i] = false;
  }

  std::string judge = "yes";
  for (it = s.begin(); it != s.end(); it++) {
    if (is_used[*it - 'a'] == true) {
      judge = "no";
      break;
    }
    is_used[*it - 'a'] = true;
  }

  std::cout << judge << std::endl;
  return 0;
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int a,b,c,x,y;

/*
min a*i+b*j+c*k
i+k/2>=x
j+k/2>=y
kを動かして最小化したい
*/

int i=0,j=0,k;
int mi;

int main(){
  cin >>a>>b>>c>>x>>y;
  k = max(2*x,2*y);
  mi = c*k;
  while(k>=0){
    i = max(x - k/2,0);
    j = max(0,y - k/2);
    mi = min(mi,a*i+b*j+c*k);
    k -= 2;
  }
  cout << mi << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
typedef long long ll; const int inf=2e9;
typedef double lf; const lf err=1e-7;
typedef pair<int,int> pii;
#define repeat(i,a,b) for(int i=(a),iE=(b);i<iE;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,iE=(a);i>=iE;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define Clear(a) {a=decltype(a)();}
#define qwq {cerr<<"qwq"<<endl;}
#define orz(x) {cerr<<#x": "<<x<<endl;}
ll read(){ll n; scanf("%lld",&n); return n;}
const int N=2010;
const int mod=1e9+7;
//#define int ll
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a,b;
	cin>>a>>b;
	if(a>b)swap(a,b);
	repeat(i,0,b)
		cout<<a;
	return 0;
}

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

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

	if (a==b){
		cout << "a == b" <<endl;
	}
		else if(a<b){
			cout << "a < b" <<endl;
	}
		else if(a>b){
			cout << "a > b" <<endl;
	}
return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
using vll=vector<ll>;
int main(){
  ll n,m,b,c,e=0,i,ans=0;
  map<ll,ll> mp;
  cin>>n>>m;
  vll a(n),d(0);
  for(i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  for(i=0;i<m;i++){
    cin>>b>>c;
    if(mp.count(-c)) mp.at(-c)+=b;
    else mp[-c]=b;
  }
  for(auto z:mp){
    for(i=0;i<z.second;i++){
      d.push_back(-z.first);
      e++;
      if(e==n) break;
    }
    if(e==n) break;
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  for(i=0;i<min(n,e);i++) ans+=max(a.at(i),d.at(i));
  for(i=min(n,e);i<n;i++) ans+=a.at(i);
  cout<<ans<<endl;
}

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

#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define bug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

#define int ll

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


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

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

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

const int maxn = 1e5+5;

vector<int> g[maxn];
int p[maxn];
vector<int> lf[maxn];
int ch[maxn];
set<int> hl; // Have leaf children

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n; cin>>n;
    FOR(i,1,n){
        int x; cin>>x; g[x-1].pb(i); p[i] = x-1;
        ch[x-1]++;
    }
    REP(i,n){
        if (ch[i] == 0) {
            lf[p[i]].pb(i);
            hl.insert(p[i]);
        }
    }
    int nr = 0;
    while (!hl.empty()) {
        nr++;
        vector<int> add, del;
        for (int x : hl){
            lf[x].pop_back(); ch[x]--; if (SZ(lf[x])==0) del.pb(x);
            if (ch[x]==0) {
                add.pb(p[x]);
                if (x==0) break;
            }
        }
        for (int x : del) hl.erase(x);
        for (int x : add) lf[x].pb(-1), hl.insert(x);
    }
    cout<<nr-1<<'\n';
} 

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());

        long[][] dp = new long[N+1][W+1];

        for(int i = 1; i < N + 1; i++) {

            String[] input_array = br.readLine().split(" ");
            int weight = Integer.parseInt(input_array[0]);
            long value = Long.parseLong(input_array[1]);
            
            for(int j = 0; j <= W; j++) {
                if(j - weight >= 0) {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j - weight] + value);
                }
                dp[i][j] = Math.max(dp[i-1][j], dp[i][j]);
            }
        }
        
        pw.println( dp[N][W]);
        pw.close();
        br.close();
    }
}


Measured memory_bytes: 138904
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	ll A=gi(),B=gi(),C=gi(),cnt=0;
	while(1.0*clock()/CLOCKS_PER_SEC<1&&(~A&1)&&(~B&1)&&(~C&1)){
		ll _A=A>>1,_B=B>>1,_C=C>>1;
		A=_B+_C,B=_A+_C,C=_A+_B;
		++cnt;
	}
	if((~A&1)&&(~B&1)&&(~C&1))puts("-1");
	else printf("%lld\n",cnt);
	return 0;
}


Measured memory_bytes: 256
import bisect
primes = [0, 0] + [1] * 32767
for i in range(2, 182):
    if primes[i]:
        for j in range(i*i, 32769, i):
            primes[j] = 0

prime_values = [i for i, v in enumerate(primes) if v]
while True:
    n = int(input())
    if n == 0:
        break
    eov = bisect.bisect(prime_values, n//2)
    print(sum(primes[n-p] for p in prime_values[:eov]))


Measured memory_bytes: 6044
n,m = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    csum = 0
    for k in range(m):
        csum = csum + b[k]*a[i][k]
    print('{}'.format(csum))



Measured memory_bytes: 6012
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N; cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];
    map<string,int> mp;
    int M = 0;
    rep(i,N){
        mp[S[i]]++;
        M = max(M,mp[S[i]]);
    }
    for(auto u : mp){
        if(u.second == M){
            cout << u.first << endl;
        }
    }
}



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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    (A.at(i))--;
  }
  for (int i = 0; i < N; i++) cin >> B.at(i);
  for (int i = 0; i < N-1; i++) cin >> C.at(i);

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += B.at(A.at(i));
    if (i < N-1) {
      if (A.at(i+1) == A.at(i) + 1) {
	sum += C.at(A.at(i));
      }
    }
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define ll long long

using namespace std;

int n, k, arr[100005];
int dp[100005];

int solve(int i)
{
	if (i == n - 1)return 0;
	if (dp[i] != -1)return dp[i];
	dp[i] = abs(arr[i] - arr[i + 1]) + solve(i + 1);
	for (int j = i + 2; j <= i + k && j < n; j++)
	{
		dp[i] = min(dp[i], abs(arr[i] - arr[j]) + solve(j));
	}
	return dp[i];
}

int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> arr[i];
	cout << solve(0) << '\n';
	return 0;
}

Measured memory_bytes: 5760
# -*- coding: utf-8 -*-

s_int = int(input().strip())

a = [s_int]
for i in range(1,1000000+1):
    if (a[-1]%2 == 0):
        a += [a[-1]/2]
    else:
        a += [3*a[-1] + 1]
    
    if a[-1] in a[:-2] :
        print(i+1)
        break
   

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

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力 : K N
# 入力 : A1 A2 ... AN
K,N = (int(x) for x in input().split())
A = list(map(int, input().split()))

# AN と A1 の距離
MaxLen = K-A[-1]+A[0]

for i in range(len(A)-1):
    if MaxLen < A[i+1]-A[i]:
        MaxLen = A[i+1]-A[i]

print(K-MaxLen)


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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  int s[n], sum = 0;
  for(int i = 0; i < n; i++){
    cin >> s[i];
    sum += s[i]; 
  }

  sort(s, s+n);
  for(int i = 0; i < n and sum%10 == 0; i++){
    if(s[i]%10){
      sum -= s[i]; 
      break;
    }
  }

  if(sum%10 == 0) sum = 0;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
    char w[16];
    char t[1024];
    int cnt;
    int i;

    scanf("%s", w);
    for (i = 0; w[i]; ++i) w[i] = toupper(w[i]);

    cnt = 0;
    for (scanf("%s", t); strcmp(t, "END_OF_TEXT"); scanf("%s", t)){
        for (i = 0; t[i]; ++i) t[i] = toupper(t[i]);
        if (!strcmp(w, t)) ++cnt;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 548
import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val ls = List.fill(n)(sc.nextInt())

    val m = ls.max

    val ans = if (ls.sum - m > m) "Yes" else "No"

    println(ans)
  }
}

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  
  /*
  a1*(a2+a3+...+an);
  a2*(a3+a4*...+an);
  a3*(a4+a5+...+an);
  an-1*an;
  */
  ll ans = 0;
  ll sum = a[n-1];
  for(ll i=n-2;i>=0;i--){
    ans += a[i]*sum;
    sum += a[i];
    sum %= MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4900
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

uint64 gcd(uint64 a, uint64 b){ // greatest common divisor
    if(b==0){ return a; }
    return gcd(b, a%b);
}
uint64 lcm(uint64 a, uint64 b){ // least common multiple
    return a / gcd(a, b) * b;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N; cin >> N;
    vector<uint64> vT(N);
    for(uint i=0; i<N; ++i){
        cin >> vT[i];
    }
    
    uint64 ret = 1ull;
    for(uint i=0; i<N; ++i){
        ret = lcm(ret, vT[i]);
    }
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System. in);
		int c = 0;
		int a = sc.nextInt();
		String s = sc.next();
		int b = sc.nextInt();
		if(s.equals("+")) {
			c = a + b;
		}else if(s.equals("-")) {
			c = a - b;
		}
		System.out.print(c);
	}
}

Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    lint n;
    cin >> n;
    char ans[256];
    int i = 0;
    while (1)
    {
        n--;
        int num = (n) % 26;
        char c = 'a' + num;
        ans[i] = c;
        n /= 26;
        if (n == 0)
            break;
        i++;
    }
    for (int j = i; j >= 0; j--)
    {
        cout << ans[j];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<map>

class C
{
  int N;
  long long K;
  std::vector<int> A;
public:
  void input();
  void solve();
};

void C::input(){
  std::cin>>N>>K;
  A.resize(N);
  for(int i=0;i<N;i++){
    std::cin>>A[i];
  }
}

void C::solve(){
  C::input();
  
  const int LOG=44;
  for(int i=0;i<N;i++) A.push_back(A[i]);
  std::map<int,int> mp;
  // next[i][j]:jからスタートし、Kを2^i回行った後に空でなくなるときのindex
  int next[LOG][N+1];
  for(int i=2*N-1;i>=N;i--){
    mp[A[i]]=i;
  }
  for(int i=N-1;i>=0;i--){
    int x=mp[A[i]]+1;
    if(x>=N){
      next[0][i]=x-N;
    }else{
      next[0][i]=next[0][x];
    }
    mp[A[i]]=i;
  }
  
  next[0][N]=0;
  for(int i=1;i<LOG;i++){
    for(int j=0;j<=N;j++){
      next[i][j]=next[i-1][next[i-1][j]];
    }
  }

  int cur=0;
  K--;
  for(int i=0;i<LOG;i++){
    if((K>>i)&1){
      cur=next[i][cur];
    }
  }

  std::vector<int> ans;
  mp.clear();
  for(int i=cur;i<N;i++){
    if(mp.count(A[i])){
      while(ans.back()!=A[i]){
        mp.erase(ans.back());
        ans.pop_back();
      }
      mp.erase(A[i]);
      ans.pop_back();
    }else{
      ans.push_back(A[i]);
      mp[A[i]]=1;
    }
  }
  for(int a:ans) std::cout<<a<<" ";
  std::cout<<"\n";
  return;
}

int main(){
  C c;
  c.solve();
  return 0;
}
  

Measured memory_bytes: 47984
#include <stdio.h>

int isLeft( char c ) {
  if( 'a' <= c && c <= 'g' )  return( 0 );
  if( 'h' <= c && c <= 'p' )  return( 1 );
  if( 'q' <= c && c <= 't' )  return( 0 );
  if( c == 'u' )              return( 1 );
  if( 'v' <= c && c <= 'x' )  return( 0 );
  if( c == 'y' )              return( 1 );
                              return( 0 );
}

int main( void ) {
  
  while( 1 ) {
    int i;
    char ch[ 33 ];
    int rl, count = 0;

    scanf( "%s", ch );
    if( ch[ 0 ] == '#' ) break;

    rl = isLeft( ch[ 0 ] );

    for( i = 1; ch[ i ]; i++ ) {
      if( rl != isLeft( ch[ i ] ) )
        count++;

      rl = isLeft( ch[ i ] );
    }

    printf( "%d\n", count );
  }

  return( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e5 + 10;
int main(){
    int a = read(),b = read(),c = read();
    if (a > b){
        if (b <= c && c <= a){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if (a <= c && c <= b){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }   
    return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std;
#define MAX 500005
#define MOD 1000000007
#define EPS 0.00000000001
#define INF 2000000000000000000
vector<long long> on,off;
int main()
{
    int n,i;
    scanf("%d",&n);
    long long a[n];
    long long x=0;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        if(i>1) x=x^a[i];
    }
    long long temp,rem=(a[0]+a[1]-x);
    if(rem<0)
    {
        printf("-1");
        return 0;
    }
    for(i=0;i<45;i++)
    {
        temp=1;
        temp=temp<<i;
        temp=temp&x;
        if(temp)
        {
            on.push_back(temp);
        }
        else
        {
            temp=1;
            temp=temp<<i;
            off.push_back(temp);
        }
    }
    long long ans=0;
    for(i=off.size()-1;i>=0;i--)
    {
        if(off[i]*2<=rem)
        {
            rem=rem-off[i]*2;
            ans=ans|off[i];
        }
    }
    if(ans>a[0]||rem>0)
    {
        printf("-1");
        return 0;
    }
    for(i=on.size()-1;i>=0;i--)
    {
        if(ans+on[i]<=a[0])
        {
            ans=ans+on[i];
        }
    }
    ans=a[0]-ans;
    if(ans==a[0]) ans=-1;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>

int main(){
  long n, m;  scanf("%ld %ld", &n, &m);
  long ans = 0;
  if(n >= m/2){
    ans = m / 2;
  }else{
    ans = n + (m - n*2) / 4;
  }

  printf("%ld\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}
	if (abs(a - b) <= (v - w) * t) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  	int N;
  	double ans;
  	cin >> N;
  	if(N%2 == 0){
    	ans = 1.0f/2.0f;	
    }else{
    	ans = (floor(N/2.0f)+1.0f)/N;
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque


class Dinic:
    """
    1-indexed
    """

    def __init__(self, N):
        self.N = N
        self.edge = [[] for _ in range(N + 1)]
        self.level = [-1] * (N + 1)

    def add_edge(self, v_from, v_to, cap):
        self.edge[v_from].append([v_to, cap, len(self.edge[v_to])])
        self.edge[v_to].append([v_from, 0, len(self.edge[v_from]) - 1])

    def _BFS(self, s):
        """
        sからの最短距離をBFSで計算する  
        """
        level = [-1] * (self.N + 1)
        level[s] = 0
        que = deque([s])
        while que:
            s = que.popleft()
            for t, cap, _ in self.edge[s]:
                if cap > 0 and level[t] < 0:
                    level[t] = level[s] + 1
                    que.append(t)
        self.level = level[:]

    def _DFS(self, v, goal, f):
        """
        増加パスをDFSで探す
        """
        if v == goal:
            return f
        for i in range(self.iterate[v], len(self.edge[v])):
            self.iterate[v] = i
            to, cap, rev = self.edge[v][i]
            if cap > 0 and self.level[v] < self.level[to]:
                d = self._DFS(to, goal, min(cap, f))
                if d > 0:
                    self.edge[v][i][1] -= d
                    self.edge[to][rev][1] += d
                    return d
        return 0

    def get_maximumFlow(self, s, t):
        """
        s -> tの最大流を求める
        1-indexed
        """
        self.goal = t
        inf = 10**18
        flow = 0
        while True:
            self._BFS(s)
            if self.level[t] < 0:
                return flow
            self.iterate = [0] * (self.N + 1)
            while True:
                f = self._DFS(s, t, inf)
                if f <= 0:
                    break
                flow += f


if __name__ == "__main__":
    N, M = map(int, input().split())
    max_flow = Dinic(N)
    for _ in range(M):
        a, b, c = map(int, input().split())
        max_flow.add_edge(a, b, c)

    ans = max_flow.get_maximumFlow(0, N-1)
    print(ans)



Measured memory_bytes: 6248
#include <iostream>
using namespace std;
 
int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= 9; i++) {
		if (N % i == 0 && N / i <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
grid = [input() for _ in range(H)]

ans = [[0 for j in range(W)] for i in range(H)]

exist = [False for _ in range(H)]
for i in range(H):
    if '#' in grid[i]:
        exist[i] = True

if not exist[0]:
    for i in range(H):
        if exist[i]:
            grid[0],grid[i] = grid[i],grid[0]
            exist[0],exist[i] = exist[i],exist[0]
            break

no = 0
for i in range(H):
    flag = False
    if exist[i]:
        no += 1
        for j in range(W):
            if flag and grid[i][j] == '#':
                no += 1
            if grid[i][j] == '#':
                flag = True
            ans[i][j] = no
    else:
        for j in range(W):
            ans[i][j] = ans[i-1][j]

for a in ans:
    print(*a)

Measured memory_bytes: 47708
#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;
const int INF=1001001001;
const long long mod=1e9+7;
int dx[4]={1,0,-1,0};
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;
    vector <int> H(N);
    rep(i,N) cin >> H[i];
    
    vector <int> dp(N+1,INF);
    dp[0]=0;
    
    for (int now=0; now<N; now++){
        for (int next=now+1; next<=min(N-1,now+2); next++){
            chmin(dp[next],dp[now]+abs(H[next]-H[now]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define N 10005
using namespace std;

typedef long long ll;
ll n, s, l, r, md, u, a[N];
ll a1, a2;
int main()
{
	ll i, j;
//	freopen ("input.txt", "r", stdin);
	cin >> n;
//	a1 = 4 / (double)n;
	for (i = 1; i <= 3500; i++) {
		for (j = 1; j <= 3500; j++) {
			l = 1;
			r = 3501;
			while (l < r) {
				md = (l + r) / 2;
				u = n * l * r * md;
				a1 = 4 * i * j * md;
				a2 = n * (i * j + i * md + j * md);
//				a2 = (1 / (double)i) + (1 / (double)j) + (1 / (double)md);
				if (a1 == a2) {
					printf("%lld %lld %lld", i, j, md);
					return 0;
				}
				if (a1 < a2) {
					l = md + 1;
				} else {
					r = md;
				}
			}
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    long int s,t,d;
    scanf("%ld %ld %ld",&d,&t,&s);
    if(d  <= t * s)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-10;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
struct Point{double x,y;};
double dis(Point a,Point b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
Point tri(Point a, Point b, Point c){
  double a1,a2,b1,b2,c1,c2;
  a1=2*(b.x-a.x);
  b1=2*(b.y-a.y);
  c1=a.x*a.x-b.x*b.x+a.y*a.y-b.y*b.y;
  a2=2*(c.x-a.x);
  b2=2*(c.y-a.y);
  c2=a.x*a.x-c.x*c.x+a.y*a.y-c.y*c.y;
  Point p;
  p.x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  p.y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  return p;
}
int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,k,l,N;
  cin>>N;
  double ans=inf,fir;
  vector<Point> v(N);
  Point x;
  rep(i,N)cin>>v[i].x>>v[i].y;
  sort(all(v),[](auto a,auto b){if(a.x!=b.x){return a.x<b.x;}else{return a.y<b.y;}});
  rep(i,N)For(j,i+1,N){
    double res=dis(v[i],v[j])*0.5;
    fir=res;
    x.x=(v[i].x+v[j].x)/2;
    x.y=(v[i].y+v[j].y)/2;
    rep(k,N){
      if(i==k||j==k)continue;
      if(dis(x,v[k])>fir+eps){
        res=inf;
        break;
      }
    }
    chmin(ans,res);
  }
  rep(i,N)For(j,i+1,N)For(k,j+1,N){
    if((v[i].x-v[k].x)*(v[j].y-v[k].y)!=(v[i].y-v[k].y)*(v[j].x-v[k].x)){
      x=tri(v[i],v[j],v[k]);
      fir=dis(x,v[i]);
      rep(l,N){
        if(dis(x,v[l])>fir+eps){
        fir=inf;
        break;
        }
      }
      chmin(ans,fir);
    }
  }
  print(ans);
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i = a; i < b; ++i)
#define rep_(i,a,b) for (ll i = a; i > b; --i)
#define endl '\n'
const ll mod = 1e9 + 7;

const ll maxn = 1e5;

string s;

// #include "debug.h"
void solve() {
	cin >> s;
	int yes = 0;
	for (int i = 0; i < sz(s); ++i) {
		yes = (yes + s[i] - '0') % 9;
	}
	if (!yes) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void aux() {
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout<<fixed<<setprecision(10);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

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

int main() {
  string str;
  int size,count = 1,ans = 0,xx[100] = {0};
  char x[100];
  while(cin >> str) {
    char x[100] = {' '};
    int xx[100] = {0};
    size = str.size();
    for(int i=0;i<size;i++) {
      x[i] = *str.substr(i,1).c_str();
      if(x[i] == 'I') {
        xx[i] = 1;
      }
      else if(x[i] == 'V') {
        xx[i] = 5;
      }
      else if(x[i] == 'X') {
        xx[i] = 10;
      }
      else if(x[i] == 'L') {
        xx[i] = 50;
      }
      else if(x[i] == 'C') {
        xx[i] = 100;
      }
      else if(x[i] == 'D') {
        xx[i] = 500;
      }
      else if(x[i] == 'M') {
        xx[i] = 1000;
      }
    }

    for(int i=0;i<size-1;i++) {
      if(xx[i] >= xx[i+1]) {
        ans += xx[i];
        if(i == size-2) {
          ans += xx[i+1];
        }
      }
      else if(xx[i] < xx[i+1]) {
        ans -= xx[i];

        if(i == size-2) {
          ans += xx[i+1];
        }
      }
    }
    if(size == 1) {
      ans += xx[0];
        }
    cout << ans << endl;
    ans = 0;
  }
}

Measured memory_bytes: 0
S = input()

def is_atgc(T):
  for t in T:
    if t in ['A', 'T', 'G', 'C']:
      continue
    else:
      return False
  return True

max_ = 0
max_S = ''
for i in range(len(S)):
  for j in range(i+1, len(S)+1):
    SS = S[i:j]
    if is_atgc(SS):
      if len(SS) > max_:
        max_S = SS
        max_ = len(SS)
print(max_)


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    string s;
    cin >> s;

    if(s.at(0)-'0'==9||s.at(1)-'0'==9) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>A>>B;
	if(abs(X-A)>abs(X-B)) cout<<"B"<<endl;
	else cout<<"A"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto n = readln.chomp.filter!"a != ' '".array;
	(sqrt(n.to!float) % 1 == 0 ? "Yes" : "No").writeln;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
count = 0
another = 0
if(K%2==1):
    for i in range(1,N+1):
        if(i%K==0):
            count+=1
    print(count**3)
else:
    for i in range(1,N+1):
        if(i%K==0):
            count+=1
        elif(i%K==(K//2)):
            another+=1
    print((count)**3+(another)**3)

Measured memory_bytes: 9064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
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);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    int tmp;
    if (n >=100) {
        tmp = n %10;
        if (tmp == 2 || tmp==4 || tmp == 5 || tmp ==7 ||tmp == 9) {
            cout << "hon" << endl;
        } else if (tmp == 0 || tmp ==1 || tmp == 6 || tmp ==8) {
            cout << "pon" << endl;
        } else {
            cout << "bon" << endl;
        }

    } else if (n >=10 && n < 100) {
        tmp = n %10;
        if (tmp == 2 || tmp==4 || tmp == 5 || tmp ==7 ||tmp == 9) {
            cout << "hon" << endl;
        } else if (tmp == 0 || tmp ==1 || tmp == 6 || tmp ==8) {
            cout << "pon" << endl;
        } else {
            cout << "bon" << endl;
        }

    } else {
        tmp = n;
        if (tmp == 2 || tmp==4 || tmp == 5 || tmp ==7 ||tmp == 9) {
            cout << "hon" << endl;
        } else if (tmp == 0 || tmp ==1 || tmp == 6 || tmp ==8) {
            cout << "pon" << endl;
        } else {
            cout << "bon" << endl;
        }

    }

}

Measured memory_bytes: 3100
#include<iostream>
#include<stdio.h>
int main(){
	int a,b;
		for(a=1;a<10;a++){
			for(b=1;b<10;b++){
				std::cout<<a<<"x"<<b<<"="<<a*b<<std::endl;
				}
			}


  
      return 0;
	}

Measured memory_bytes: 1112
#include<bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a) > abs(x-b)){
    cout << 'B' << endl;
  }else{
    cout << 'A' << endl;
  }
}

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

if( n == 0 ):
    print(0)
    exit()
ans = []
while True:
    if(n == 0):
        break;
    elif(n % 2 == 1):
        ans.append(1)
        n -= 1
        n /= -2
    else:
        ans.append(0)
        n = n/(-2)
for i in reversed(range(len(ans))):
    print(ans[i],end='')


Measured memory_bytes: 3060
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_min = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            mod = i * j % 2019
            if mod <= mod_min:
                mod_min = mod
    print(mod_min)



Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;

#define INF (1e9)

int main() {
    char C;
    cin >> C;
    if (C == 'A') {
        C = 'T';
    } else if (C == 'T') {
        C = 'A';
    } else if (C == 'C') {
        C = 'G';
    } else if (C == 'G') {
        C = 'C';
    }
    cout << C << endl;
    return 0;
}


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

int f(long long a){
  int ans = 0;
  while(a > 0){
    ans++;
    a /= 10;
  }
  return ans;
}

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

  int ans = INT_MAX;
  for(long long i = 1;i*i <= n;i++){
    if(n % i == 0){
      ans = min(ans,max(f(i),f(n/i)));
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define DEBUG 0
#define MOD 1000000007
#define INF (1LL<<50)
 
lli flag[10];
lli data[10]={INF,2,5,5,4,5,6,3,7,6};
string dp[10010];
lli vis[10010];
 
string func(lli now){
	if(vis[now])return dp[now];
 
	if(DEBUG)cout<<"now="<<now<<endl;
	vis[now]=1;
	/*次の数は??*/
	string rtn="";
	for(lli i=9;i>=0;i--){
		string nextStr = "0";
		if(flag[i]==0)continue;
		nextStr[0] += i;
		lli useMatch = data[i];
		if(now-useMatch<0)continue;
		string afterStr=func(now-useMatch);
		if(afterStr=="-1")continue;
		string ans = nextStr + func(now-useMatch);
		if(rtn.size()==ans.size())rtn = max(ans,rtn);
		else if(rtn.size()<ans.size())rtn = ans;
	}
	if(rtn=="")rtn="-1";
	return dp[now]=rtn;
}
 
 
int main(){
 
	REP(i,0,10010)dp[i]="";
	lli data[10]={INF,2,5,5,4,5,6,3,7,6};
	vis[0]=1;
 
	lli n,m;
	cin>>n>>m;
 
	REP(i,0,m){
		lli a;
		cin>>a;
		flag[a]++;
	}
 
	cout<<func(n)<<endl;
 
	if(DEBUG)cout<<endl;
	if(DEBUG){
		REP(i,0,n){
			cout<<"i="<<i<<" dp[i]="<<dp[i]<<endl;
		}
	}
 
}

Measured memory_bytes: 43136
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int A, B, C, X; std::cin >> A >> B >> C >> X;
	int ans = 0;

	rep(i, A + 1)rep(j, B + 1)rep(k, C + 1) {
		int tmp = 500 * i + 100 * j + 50 * k;
		if (tmp == X)ans++;
	}

	std::cout << ans;

	return 0;
}

Measured memory_bytes: 256
using System;

class Program{
  static void Main(string[] args){
    
    int i;
    string[] c = new string[3];
    for(i = 0; i < 3; i++){
        c[i] = Console.ReadLine();
    }
    
    for(i = 0; i < 3; i++){
      Console.Write(c[i][i]);
    }
  }
}
    

Measured memory_bytes: 11092
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}


//深さ優先探索
void dfs(vector<vector<ll>> &gra, ll v, vector<bool> &seen){

	seen[v]=true;

	for(auto next: gra[v]){
		if(seen[next]){
			continue;
		}
		dfs(gra,next,seen);
	}
}


void solve(){
	ll ans=0;
	ll n,m;
	cin>>n>>m;

	vector<ll> a(m),b(m);

	for(ll i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--; //0~に直す
	}

	for(ll i=0;i<m;i++){

		vector<vector<ll>> gra(n);
		for(ll j=0;j<m;j++){
			
			if(j==i){
				continue;
			}
			
			gra[a[j]].push_back(b[j]);
			gra[b[j]].push_back(a[j]);
		}

		vector<bool> seen(n,false);

		dfs(gra,0,seen);

		for(ll j=0;j<n;j++){
			if(!seen[j]){
				ans++;
				break;
			}
		}
	}

	cout<<ans<<endl;
	
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

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

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<double>x(n);
	double total = 0;
	double ans = 0;
	rep(i, n) {
		cin >> x[i];
		total += x[i];
	}
	total /= n;
	double res = round(total);
	rep(i, n) {
		ans += (x[i] - res) * (x[i] - res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256