akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    int N,R; cin >> N >> R;
    if(N<10){
        cout << R+100*(10-N) << endl;
    }else{
        cout << R << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{
  static int[] Input(){
    return Console.ReadLine().Split().Select(int.Parse).ToArray();
  }

  static int[][] Input2(int n){
    int[][] X = new int[n][];
    for(int i = 0; i < n; i++){
      X[i] = Input();
    }
    return X;
  }

  static void Main()
  {
    int[] NC = Input();
    int[] A = Input();
    int[] B = Input();
    int[] C = Input();
    Array.Sort(A);
    Array.Sort(B);
    Array.Sort(C);
    long R = 0;
    for(int i = 0; i < NC[0]; i++){
      long tr = 1;
      int b = B[i];

      int mx = NC[0]; int mn = 0;
      int idx = mx/2;
      while(mx-mn>1){
        if (A[idx] >= b){
          mx = idx; idx = (idx+mn)/2;
          continue;
        }
        mn = idx; idx = (idx+mx)/2;
      }
      if (A[0]>=b)idx=-1;
      if (A[NC[0]-1]<b)idx=NC[0]-1;
      tr *= idx+1;

      mx = NC[0]; mn = 0;
      idx = mx/2;
      while(mx-mn>1){
        if (C[idx] > b){
          mx = idx; idx = (idx+mn)/2;
          continue;
        }
        mn = idx; idx = (idx+mx)/2;
      }
      if (C[0]>b)idx=-1;
      if (C[NC[0]-1]<=b)idx=NC[0]-1;
      //Console.WriteLine(NC[0]-idx-1);
      tr *= NC[0]-idx-1;
      R += tr;
    }
    Console.WriteLine(R);
  }
}


Measured memory_bytes: 41396
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << "\n";
    }
    else if (s == "Cloudy") {
        cout << "Rainy" << "\n";
    }
    else {
        cout << "Sunny" << "\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,cnt;//制御変数
  int n;
  scanf("%d",&n);
  cnt=0;
  
  for(a=1;a<n;a++){
    for(b=1;b<n;b++){
      if(a*b>=n)
        break;
      //cの期待値を求める
      c=n-a*b;
      if(c>0){//cは0以上
        cnt++;
      }
    }
  }
  printf("%d",cnt);
}

Measured memory_bytes: 1732
# ABC133-A

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,a,b=LI()
  return min(n*a,b)

print(main())


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

int main() {
  string s;
  cin >> s;
  int ans = 999;
  for (int i = 0; i < s.size() - 2; ++i) {
    int x = stoi(s.substr(i, 3));
    ans = min(ans, abs(x - 753));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    cout << (n+1)/2 << endl;
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> cs(N + 2, 0);
  int l, r;
  for(int i = 1; i <= M; ++i) {
    cin >> l >> r;
    cs[l]++;
    cs[r + 1]--;
  }
  int ans = 0;
  int value = 0;
  for(int i = 0; i < cs.size(); ++i) {
    value += cs[i];
    if(value == M) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a,b;
 cin >> a >> b;
  int c[a];
  for(int i = 0;i<a;i++){
    cin >> c[i];
  }
  for(int i = b;i<a;i++){
    if(c[i]>c[i-b]) cout << "Yes" <<endl;
    else cout << "No" << endl;
  }
}


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

int main() {

    int n, x, y; cin >> n >> x >> y;
    x--;
    y--;
    vector<int> ans(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int tmp = min({ abs(i - j),abs(i - x) + 1 + abs(y - j),abs(i - y) + 1 + abs(x - j) });
            ans[tmp]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n, a[10005];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
	}
	long long sum1 = 0, sum2 = 0;
	for (int i = 1; i <= n; ++i) {
		int x;
		read(x);
		a[i] -= x;
		if (a[i] > 0) {
			sum1 += a[i];
		} else {
			sum2 += -a[i] / 2;
		}
	}
	if (sum1 <= sum2) {
		printStr("Yes");
	} else {
		printStr("No");
	}
}


Measured memory_bytes: 3232
#include <bits/stdc++.h> 
using namespace std;
#define float long double 
#define int long long
#define vl vector<int> 
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define MAXN 100009
#define CASET int ___T; scanf("%lld", &___T); for(int cs=1; cs <= ___T; cs++)
template<class T> bool umin(T& a, T b) { if(a > b){ a = b;return 1;}return 0;}
template<class T> bool umax(T& a, T b) { if(a < b){ a = b;return 1;}return 0;}
const int N = 200 * 1000 + 9;
const int  inf = 1e18;
const int mod=998244353;

int i,j,k;
void solve(){
   int n; cin >> n;
   int t = n / 500;
   int ans = t * 1000;
   int rem  = n % 500;
   ans = ans + (rem / 5) * 5 ; 
   cout <<  ans << endl;

   return ; 
}
    signed main(){
    
    //CASET
    solve();
    
   
    return 0;
}


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

int main()
{
    int n;
    long long int power = 1;
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        power *= i;
        power = power % (long long int)(pow(10, 9) + 7);
    }

    cout << power;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
#include <bitset>
#include <math.h>
#include <vector>
#include <set>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    int h, w;
    cin >> h >> w;

    int area = H * W;

    area -= W * h;
    area -= (H - h) * w;
    cout << area << endl;
    return 0;
}

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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }
    long long minv = -1;
    long long sumh = 0;
    for (int i = 0; i < N; ++i) {
        if (minv > A[i]) sumh += (minv-A[i]);
        else {
            minv = A[i];
        }
    }
    std::cout << sumh << '\n';
}

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

typedef long long LL;
const int maxn = 2e5 + 5;
int a[maxn], cnt[maxn];

int main() {

    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }

    LL sum = 0;
    for(int i = 0; i <= n; i++)
        sum += (LL)cnt[i]*(cnt[i]-1)/2;


    bool first = true;
    for(int i = 0; i < n; i++) {
        if(first) first = !first;
        else printf("\n");
        printf("%lld", sum-(LL)cnt[a[i]]*(cnt[a[i]]-1)/2+(LL)(cnt[a[i]]-1)*(cnt[a[i]]-2)/2);
    }
    return 0;
}


Measured memory_bytes: 3712
N,K=gets.chomp.split(' ').map{|n| n.to_i}
array=gets.chomp.split(' ').map{|n| n.to_i}
count = 0

# piの最大値を求める
max = 0
array.each do |i|
  if i > max then
    max = i
  end
end

# 期待値を保持する配列を作成
e = []
sum = 0
1.upto(max) do |i|
  sum = sum + i
  e.push(sum.to_f / i)
end

max = 0
maxidx = 0
tmp = 0
0.upto(K-1) do |i|
  tmp = tmp + e[array[i]-1]
  max = tmp
end
(K).upto(N-1) do |i|
  tmp = tmp - e[array[i-K]-1] + e[array[i]-1]

  if tmp > max then
    max = tmp
    maxidx = i
  end
end

puts max

Measured memory_bytes: 16012
#
# abc047 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 4 2
2 1 1
3 3 4"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 4 3
2 1 1
3 3 4
1 4 2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3"""
        output = """64"""
        self.assertIO(input, output)


def resolve():
    W, H, N = map(int, input().split())
    a = []
    ox = 0
    oy = 0
    for _ in range(N):
        a.append(list(map(int, input().split())))
    for i in range(N):
        if a[i][2] == 1:
            ox = max(a[i][0], ox)
        elif a[i][2] == 2:
            W = min(a[i][0], W)
        elif a[i][2] == 3:
            oy = max(a[i][1], oy)
        elif a[i][2] == 4:
            H = min(a[i][1], H)
    print(max(W-ox, 0)*max(H-oy, 0))


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16196
n=int(input())
d,x=(int(i) for i in input().split())
a=[int(input()) for i in range(n)]
#print(n,d,x,a)

def choco(a,d):
  cnt=0
  d=d-1
  while d >= 0:
    d=d-a
    cnt+=1
  return cnt

ans=x
for i in range(n):
  ans+=choco(a[i],d)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define cs const 
//#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define fr first 
#define se second
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
cs int base = 233;
cs int ff = 2e6+1;
cs int mod = 998244353;
cs int inf = 1e9+1;
int n, x, y, ans[ff];
int kr(int i, int j)
{
	return min(abs(j-i), min(abs(j-x)+1+abs(i-y), abs(i-x)+1+abs(j-y)));
}
void init()
{
	cin >> n >> x >> y;
	if( x > y ) swap(x, y);
	rep(i, 1, n)
		rep(j, 1, n)
			if( i != j )
				ans[kr(i, j)]++;
	rep(i, 1, n-1)
		cout << ans[i] / 2 << endl;
}
signed main()
{
	int T = 1;
	while(T--) 
		init();
} 

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

//  Hより小さい最小の2のべき乗を根とした木を考え、節と葉の数の和が答えとなる。
int main(){
    ll H;
    cin >> H;

    ll cnt=1; 
    int power=0;
    while(true){ // Hより小さい最小の2のべき乗を探す
        cnt = cnt*2; power++;
        if(H < cnt){
            power--;
            break;
        }
    }
    ll res=1;
    for(int i=1; i<=power; i++){
        res += pow(2.0, i);
    }
    cout << res << endl;
}

Measured memory_bytes: 3972
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int i = 1;
    while (true) {
        int x;
        cin >> x;
        if (x != 0) {
        cout << "Case " << i << ": " << x << endl; 
        i++;
        } else {
            break;
        }
    }
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(i64, X);
    const i64 n = X / 100;
    print(100 * n <= X && X <= 105 * n);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll x;
int main(void){
    cin>>x;
    for(int i=1;i<=10000000;i++){
        if(x*i%360==0){
            cout<<i<<endl;
            return 0;
        }
    }

}



Measured memory_bytes: 3592
#17:57
a,b,c,k = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))
xy = []
for x0 in x:
  for y0 in y:
    xy.append(x0+y0)
xy.sort(reverse=True)
if a * b > 3000:
  xy = xy[:3000]
xyz = []
for xy0 in xy:
  for z0 in z:
    xyz.append(xy0+z0)
xyz.sort(reverse=True)
for i in range(k):
  print(xyz[i])

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

ll l1[10];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s;
    cin>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3652
(defun group (lst)
  (labels ((inner (lst k rev)
             (cond
               ((null lst) rev)
               ((not (equal (car lst) (cadr lst)))
                (inner (cdr lst) 1 (cons `(,(car lst) ,k) rev)))
               (t
                (inner (cdr lst) (1+ k) rev)))))
    (inner lst 1 '())))

(defun read-input (N)
  (loop for n from 1 upto N collect (read)))
  

(defun answer (lst k)
  (let ((freq (sort (group (sort lst #'<))
                    #'> :key #'cadr)))
    (if (<= (length freq) k)
        0
        (reduce #'(lambda (n p) (+ n (cadr p)))
                   (subseq freq k)
                   :initial-value 0))))

(defun main ()
  (let ((N (read)) (K (read)))
    (format t "~a~%" (answer (read-input N) K))))

(main)


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,a,b;cin >> x >> a >> b;
	if(abs(x-a)<abs(x-b)) cout << 'A' << endl;
	else cout << 'B' << endl;
}

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

const int N=3005;
int n,P,C[N][N],S[N][N],ans;

int qpow(int b_,int p_,int mod=P)
{
    int r_=1;
    for(;p_;p_>>=1,b_=1LL*b_*b_%mod)
        if(p_&1) r_=1LL*b_*r_%mod;
    return r_;
}

int main()
{
    scanf("%d%d",&n,&P);
    C[0][0]=S[0][0]=1;
    for(int i=1;i<=n+1;++i)
    {
        C[i][0]=1;
        for(int j=1;j<=i;++j)
        {
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%P,
            S[i][j]=(1LL*S[i-1][j]*j%P+S[i-1][j-1])%P;
        }
    }
    for(int i=0;i<=n;++i)
    {
        int s1=1LL*C[n][i]*qpow(2,qpow(2,n-i,P-1))%P;
        int s2=0;
        for(int j=0;j<=i;++j)
            s2=(s2+1LL*S[i+1][j+1]*qpow(qpow(2,n-i),j)%P)%P;
        ans=(ans+(i&1?-1LL:1LL)*s1*s2%P)%P;
        ans=(ans+P)%P;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 58928
#include<string>
#include<cstdio>
#include<cstdlib>
#define MAX 1000000007

int main() {

	long long int x, y;
	long long int count;
	long long int n;

	scanf("%lld", &x);
	n = x / 11;

	y = 11 * n;
	if (y != 0) {
		if (y == x) {
			count = 2 * n;
		}
		else if (y < x && x <= y + 6) {
			count = 2 * n + 1;
		}
		else if (y + 6 < x && x <= y + 10) {
			count = 2 * (n + 1);
		}
	}
	else {
		if (0 < x && x <= 6) {
			printf("1\n");
			return 0;
		}
		else if (7 <= x && x <= 10) {
			printf("2\n");
			return 0;
		}
	}

	printf("%lld", count);


	return 0;
}

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

int digits(int n){
	int ans(0);
	while(n>=1){
		n /= 10;
		ans++;
	}
	return ans;
}

int main(){
	int N;
	cin >> N;
	int ans(0);
	for(int i(1);i<=N;++i){
		if(digits(i) % 2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    vector<char> s(4);
    for(int i = 0; i < 4; i++){
        cin >> s[i];
    }
    sort(all(s));

    if( s[0] == s[1] && s[2] == s[3] && s[2] != s[1] ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

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

  if(a >= 13)
    cout << b << endl;
  else if(a <= 5)
    cout << "0" << endl;
  else
    cout << b/2 << endl;
  return 0;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long ans,n,k,a[200001],f[200001];
inline bool check(long long xx){
	long long tmp=k;
	for(register long long i=n;i;i--){
		if(a[i]*f[i]>xx){
			tmp-=a[i]-(int)(xx*1.0/f[i]);
			if(tmp<0)return false;
		}
	}
	return true;
}
inline bool cmp(long long x,long long y){
	return x>y;
}
void Binary(long long l,long long r){
	if(l>r)return;
	long long mid=(l+r)>>1;
	if(check(mid)){
		ans=mid;
		Binary(l,mid-1);
	}else Binary(mid+1,r);
}
int main(){
	scanf("%lld%lld",&n,&k);
	for(register long long i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(register long long i=1;i<=n;i++)scanf("%lld",&f[i]);
	sort(a+1,a+1+n);
	sort(f+1,f+1+n,cmp);
	Binary(0,a[n]*f[1]);
	printf("%lld",ans);
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	int n;
	int t = 0;
	cin>>n; 
	for(int i=1;i<=n;i++){
		t = t*10+7;
		t%=n;
		if(t%n==0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
//解説AC
  int main(){
     lint k;
     cin>>k;
     queue<lint> x;
     rep(i,9)x.emplace(i+1);
     lint ans;
        while(k--){
            ans=x.front();
            if(ans%10!=0)x.emplace(10*ans+ans%10-1);
            x.emplace(10*ans+ans%10);   
            if(ans%10!=9)x.emplace(10*ans+ans%10+1);   
            x.pop();
        }
        cout<<ans<<endl;
  }
  
     


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  vector<vector<int>> F(N);
  FOR(i, N) {
    F[i] = vector<int>(10);
    FOR(j, 10) { cin >> F[i][j]; }
  }
  vector<vector<int>> P(N);
  FOR(i, N) {
    P[i] = vector<int>(11);
    FOR(j, 11) { cin >> P[i][j]; }
  }
  int ans = -1000000000;
  FORIN(i, 1, 1024) {
    vector<int> count(N);
    FOR(j, 10) {
      if ((i >> j) & 1) {
        FOR(k, N) {
          if (F[k][j])
            count[k]++;
        }
      }
    }
    int sum = 0;
    FOR(j, N) { sum += P[j][count[j]]; }
    if (ans < sum)
      ans = sum;
  }
  print(ans);
  return 0;
}

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

int main(){
    int N, M, X;
    std::cin >> N >> M >> X;

    std::vector<int> C(N);
    std::vector<std::vector<int>> A(N, std::vector<int>(M));

    for(int i = 0; i < N; i++){
        std::cin >> C[i];
        for(int j = 0; j < M; j++){
            std::cin >> A[i][j];
        }
    }

    // BIT全探索 
    int ans = -1;
    int AMOUNT_OF_CASE = 1<<N;  // 000000(なにも買わない)から111111(全部買う)まで試す 
                                // 1<<M = 1*2^M 
    // 場合をみるループ 
    for(int i = 0; i < AMOUNT_OF_CASE; i++){
        // std::cout << "case" << i << ":";
        int tmpC = 0;                   // コスト 
        std::vector<int> skill(M, 0);   // アルゴリズム能力 
        // 買う本で学習度を測るループ 
        for(int j = 0; j < N; j++){
            if((1<<j) & i){ // 101:100 => 100 ifの条件を満たす 
                for(int k = 0; k < M; k++){
                    skill[k] += A[j][k];
                }
                tmpC += C[j];
            }
        }
        // チェック 
        bool isOk = true;
        for(int l = 0; l < M; l++){
            // std::cout << "(" << l << "-" << skill[l] << ")";
            if(skill[l] < X){
                isOk = false;
                 break;
            }
        }
        // if(isOk == true) std::cout << "|" << tmpC;
        if(isOk == true){
            if(ans != -1){  // 初回は-1なのでminで取ってこれない 
                ans = std::min(ans, tmpC);
            }else{
                ans = tmpC;
            }
        }
        // std::cout << std::endl;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >>n;
    int x[n],y[n],h[n];
    
    
    for(int i = 0;i<n;i++){

        cin >> x[i] >>y[i] >> h[i];
        
    }
    if(h[0]==0){
    int t = 0;
    int v,w,d;
    while(h[t]==0){
        t++;
        


    }
    v = x[t];
        w = y[t];
        d = h[t];
        x[t]=x[0];
        y[t]=y[0];
        h[t]=h[0];
        x[0]=v;
        y[0]=w;
        h[0]=d;
    }
   
    int a,p,q;
    
    for(int X = 0; X < 101;X++){
        for(int Y =0;Y <101;Y++){
            a = h[0] + abs(X- x[0]) + abs(Y - y[0]);
            for(int i = 1; i<n;i++){
                if(h[i]!=0 && a !=  h[i] + abs(X- x[i]) + abs(Y - y[i]) ){
                    a = -1;
                    break;
                }
                if(h[i]==0 && a > abs(X- x[i]) + abs(Y - y[i])){
                    a = -1;
                    break;
                }
                
                
            }
            if(a != -1){
                q = Y;
                break;
            }
        }
        if(a!= -1){
            p = X;
            break;
        }
    }
    cout <<  p << " " << q << " "  << a;
    return 0;
}

Measured memory_bytes: 256
/**
 * @author: shashankchdhry
 * @made:   2020-03-30 21:17:04 
**/
#include <bits/stdc++.h>

using namespace std;

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

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

    int mn = INT_MAX;
    for (int i = -100; i <= 100; i++)
    {
        int temp = 0;
        for (int j = 0; j < n; j++)
        {
            temp += pow(arr[j]-i, 2);
        }
        mn = min(temp, mn);
    }
    cout << mn << "\n";

    return 0;
}

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


long F(long A, long B) {
	return max((long)floor(log10(A)) + 1, (long)floor(log10(B)) + 1);
}

int main() {
	long N;
	cin >> N;
	long ans = LONG_MAX;
	for (long i = 1; i <= sqrt(N); i++) {
		if (N % i == 0) {
			ans = min(ans, F(i, N / i));
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
n, m, c  = map(int, input().split())
B = list(map(int, input().split()))
A = [[0]] * n
for i in range(n):
    A[i] = list(map(int, input().split()))

cnt = 0
sum_lst = 0
for i in range(n):
    for j in range(m):
        sum_lst += A[i][j] * B[j] 
    if sum_lst + c > 0:
        cnt += 1
        sum_lst = 0
    else:
        sum_lst = 0

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a[5];
	rep(i, 5) cin >> a[i];
	int k;
	cin >> k;
	rep(i, 5){
		rep(j, 5) if(i != j){
			if(abs(a[i] - a[j]) > k){
				cout << ":(" << endl;
				return 0;
			}
		}	
	}
	cout << "Yay!" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = ReadLongs();
            var A = inputs[0];
            var B = inputs[1];

            var x = A - 2 * B;

            return x > 0 ? x : 0;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 11348
import math
from collections import deque
from collections import defaultdict


#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))


a,b = list(map(float, input().split()))

c = int(b*1000)
a = int(a)
#print(c)

ans = (a*c)//1000
#print(type(ans))
print(ans)

Measured memory_bytes: 9420
#include <bits/stdc++.h> 
using namespace std; 
#include <stack>
#define ll long long 
const ll INF=1000000007;
#define vecpair vector<pair <ll,ll> >
#define pb push_back
#define mp make_pair
#define vel vector<ll>
bool prime[100001];
void SieveOfEratosthenes() 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=100000; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=100000; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
} 
ll bs(vel a,ll s,ll e,ll x){
	int l=s;
	int h=e;
	int m;
	while(l<=h){
		m=(l+h)/2;
		if(a[m]>x) h=m-1;
		else if(a[m]<x) l=m+1;
		else return m;
		}
		return -1;
	}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
SieveOfEratosthenes();
ll test;
test=1;
while(test--){
int n;
cin>>n;
string s;
cin>>s;
int r=0;
for(int i=0;i<n;i++){
	if(s.at(i)=='R') r++;
	}
	int ans=0;
	for(int i=0;i<r;i++){
		if(s.at(i)=='W') ans++;
		}
		ans=min(ans,n-r);
		cout<<ans;
}
}


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

int main ()
{
    int n;
    cin >> n;
    double times[] = {-1, -1}, dis[] = {-1, -1};
    vector<double> f(n), a(n), x(n), y(n);
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> f[i] >> a[i] >> t[i] >> x[i] >> y[i];
    }

    bool flag[] = {true, true};

    for (int i = 1; i < n; i++) {
        double dd = ((x[i] - x[i-1]) * (x[i] - x[i-1]) + (y[i] - y[i-1]) * (y[i] - y[i-1]));
        double tt = f[i] - f[i-1];
        if (t[i] != t[i-1]) continue;
        if (a[i] == a[i-1]) continue;
        if (dd > dis[t[i]]) {
            dis[t[i]] = dd;
            times[t[i]] = tt;
            flag[t[i]] = false;
        } else if (dd == dis[t[i]] && tt <  times[t[i]]) {
            times[t[i]] = tt;
            flag[t[i]] = false;
        }
    }

    if (flag[0]) {
        cout << -1 << " " << -1 << endl;
    } else {
        printf("%.6f %.6f\n", (sqrt(dis[0])), (times[0] / 60.0));
    }
    if (flag[1]) {
        cout << -1 << " " << -1 << endl;
    } else {
        printf("%.6f %.6f\n", (sqrt(dis[1])), (times[1] / 60.0));
    }

    return 0;
}

Measured memory_bytes: 1300
import Data.List
ac::String->[(Char,Char)]
ac s
 |null s = [('a','a')]
 |(length s) `mod` 2 == 1 = [('a','b'),('a','b')] 
 |otherwise = (s!!0,s!!1):(ac (drop 2 s)) 
f::[(Char,Char)]->Bool
f [] = True
f (x:xs) = if (fst x) == (snd x) then f xs else False
main=do
 s<-ac.sort<$>getLine
 putStrLn$if f s then "Yes" else "No"
 

Measured memory_bytes: 508
N = int(input())
sum_N = N * (N+1) // 2
three_count = N // 3
sum_three = 3 * (three_count * (three_count + 1) // 2)
five_count = N // 5
sum_five = 5 * (five_count * (five_count + 1) // 2)
fif_count = N // 15
sum_fif = 15 * (fif_count * (fif_count + 1) // 2)

print(sum_N - sum_three - sum_five + sum_fif)

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

int main()
{
    int a,b,c,k,sum,x=0;
    cin >> a >> b >> c >> k;
    if (k<=a+b) cout << min(a,k) << endl;
    else cout << (a-(k-b-a)) << endl;

}

Measured memory_bytes: 3632
n = gets.to_i
as = gets.split.map{|i|i.to_i}

ave = as.inject(:+) / as.length.to_f
min = 1000
min_index = 100

0.upto(n-1) do |i|
  if min > (as[i] - ave).abs
    min = (as[i] - ave).abs
    min_index = i
  end
end

puts min_index

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	N, W := getInt(), getInt()
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		w[i], v[i] = getInt(), getInt()
	}

	var dp [101][110000]int
	for i := 0; i < N; i++ {
		for j := 0; j < 110000; j++ {
			dp[i][j] = math.MaxInt32
		}
	}

	dp[0][0] = 0
	for i := 0; i < N; i++ {
		for j := 0; j < 110000; j++ {
			if j-v[i] < 0 {
				dp[i+1][j] = dp[i][j]
			} else {
				dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i])
			}
		}
	}

	max := 0
	for i := 0; i < 110000; i++ {
		if dp[N][i] <= W && i > max {
			max = i
		}
	}

	out(max)
}


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

int main(){
  int n , k;
  cin >> n >> k;
  //kが奇数
  if(k&1){
    int64_t count = n/k;
    cout << count*count*count;
  }else{
    //kが偶数
    k/=2;
    int64_t count = n/k;
    int64_t even = count/2;
    int64_t odd = (count+1)/2;
    
    cout << even*even*even+odd*odd*odd;
    
  }
}

Measured memory_bytes: 256
program manhattan_compass
  implicit none
  integer :: n, a, b, p(100001,3) = 0, length, tmp1, tmp2, i, cnt = 0
  integer :: s(100000) = 0, pre(1000000) = 0, nxt(1000000) = 0, h(100000) = 0
  logical :: vis(100000) = .false.
  integer(8) :: ans = 0_8
  read(*,*) n, a, b
  do i = 1, n
    read(*,*) tmp1, tmp2
    p(i,:) = (/tmp1+tmp2,tmp1-tmp2,i/)
  end do
  length = max(abs(p(a,1)-p(b,1)),abs(p(a,2)-p(b,2)))
  call solve(length)
  do i = 1, n
    call swap(p(i,1),p(i,2))
  end do
  call solve(length-1)
  call dfs(a)
  write(*,'(i0)') ans
contains
  subroutine swap(a,b)
    integer, intent(inout) :: a, b
    a = xor(a,b)
    b = xor(a,b)
    a = xor(a,b)
  end
  subroutine solve(d)
    integer, intent(in) :: d
    integer :: l, r, k, i
    call merge_sort(p(1:n,1:3))
    l = 1
    r = 0
    k = 1
    do i = 1, n
      do while (l < n .and. (p(l,1) < p(i,1)-length .or. &
      & (p(l,1) == p(i,1)-length .and. p(l,2) < p(i,2)-d)))
        l = l+1
      end do
      do while (r < n .and. (p(r+1,1) < p(i,1)-length .or. &
      & (p(r+1,1) == p(i,1)-length .and. p(r+1,2) <= p(i,2)+d)))
        r = r+1
      end do
      s(p(i,3)) = s(p(i,3))+r-l+1
      k = max(k,l)
      do while (k <= r)
        call add(p(i,3),p(k,3))
        k = k+1
      end do
      k = k-1
    end do
  end
  subroutine add(x,y)
    integer, intent(in) :: x, y
    cnt = cnt+1
    pre(cnt) = y
    nxt(cnt) = h(x)
    h(x) = cnt
    cnt = cnt+1
    pre(cnt) = x
    nxt(cnt) = h(y)
    h(y) = cnt
  end
  recursive subroutine dfs(x)
    integer, intent(in) :: x
    integer :: i
    vis(x) = .true.
    ans = ans+int(s(x),8)
    i = h(x)
    do while (i /= 0)
      if (.not.vis(pre(i))) call dfs(pre(i))
      i = nxt(i)
    end do
  end
  subroutine merge_sort(a)
    integer, intent(inout) :: a(:,:)
    integer :: n, m, l, i, u
    n = size(a,1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m/2
        u = min(2*i*l,n)
        call merger(a(2*(i-1)*l+1:(2*i-1)*l,:),a((2*i-1)*l+1:u,:))
      end do
      l = 2*l
      m = (m+1)/2
    end do
  end
  subroutine merger(a1,a2)
    integer, intent(inout) :: a1(:,:), a2(:,:)
    integer :: a(size(a1,1)+size(a2,1),size(a1,2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(a1,1)
    n2 = size(a2,1)
    do while (i1 <= n1 .and. i2 <= n2)
      if (a1(i1,1) < a2(i2,1) .or. &
      & (a1(i1,1) == a2(i2,1) .and. a1(i1,2) < a2(i2,2))) then
        a(i1+i2-1,:) = a1(i1,:)
        i1 = i1+1
      else
        a(i1+i2-1,:) = a2(i2,:)
        i2 = i2+1
       end if
    end do
    if (i1 <= n1) then
      a(i1+i2-1:n1+n2,:) = a1(i1:n1,:)
    else
      a(i1+i2-1:n1+n2,:) = a2(i2:n2,:)
    end if
    a1 = a(1:n1,:)
    a2 = a(n1+1:n1+n2,:)
  end
end program manhattan_compass

Measured memory_bytes: 12064
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


Measured memory_bytes: 5620
#include <stdio.h>

int main(void) {
  int i, j, k, n;
  while( 1 ) {
    scanf("%d", &n);
    if(!n) break;
    int h[n + 1];
    for(i = 0; i <= n;++i) scanf("%d", &h[i]);
    for(i = 0; i <= n; ++i) {
      int d, s = 1;
      if(!i) d = h[2] - h[1];
      else if(i == 1) d = h[2] - h[0];
      else d = h[1] - h[0];
      for(j = 2; j <= n; ++j) {
        if(i == j) continue;
        if(j == i + 1) {
          if(d != h[j] - h[j - 2]) {
           s = 0;
           break;
          }
        } else {
          if(d != h[j] - h[j - 1]) {
            s = 0;
            break;
          }
        }
      }
      if(s) break;
    }
    printf("%d\n", h[i]);
  }
  return 0;
}


Measured memory_bytes: 2752
s=input()
r=input()
n=len(s)
nn=len(r)
m=0
c=0
x=0
for i in range(n-nn+1):
    t=s[i:i+nn]
    c=0
    for j in range(nn):
        if(t[j]==r[j]):
            c+=1
    m=max(m,c)
print(nn-m)


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

using namespace std;

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

	int n, cnt=0;
	cin >> n;
	for(int i=1, num; i<=n; i++){
        cin >> num;
        if(i&1 && num&1)
            cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3644
//submitted by Himj
  #include<bits/stdc++.h>
  #define ll long long
  #define mod 1000000007
  #define pb push_back
  #define fi first
  #define se second
  #define fr(i,s,e) for(i=s;i<e;i++)
  #define ms(arr,val) memset(arr,val,sizeof(arr))
  using namespace std;

  const int mxn=2e5+1;

  int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);
 
    int t=1;
    //cin>>t;
      while(t--){
        ll a,b,q,i;
        cin>>a>>b>>q;
        ll t[a],s[b];
        fr(i,0,a)
        cin>>t[i];
        fr(i,0,b)
        cin>>s[i];
        while(q--)
        {
          ll x;
          cin>>x;
          vector<ll> tarr,sarr;
          ll t1=lower_bound(t,t+a,x)-t;
          if(t1==a)
          {
            tarr.pb(t[t1-1]);
          }
          else
          {
            tarr.pb(t[t1]);
            if(t1+1<a)
              tarr.pb(t[t1+1]);
            if(t1-1>=0)
              tarr.pb(t[t1-1]);
          }
          ll s1=lower_bound(s,s+b,x)-s;
         // cout<<s[s1]<<" ";
          if(s1==b)
          {
          	//cout<<"HI";
            sarr.pb(s[s1-1]);
          }
          else
          {
            sarr.pb(s[s1]);
            if(s1+1<b)
              sarr.pb(s[s1+1]);
            if(s1-1>=0)
              sarr.pb(s[s1-1]);
          }
          ll ans=1e15;
          for(ll te:tarr)
          {
            ll loser=0;
            for(i=0;i<sarr.size();i++)
            {
            	ll sh=sarr[i];
              if(te<x and sh>x)
              {
                loser=abs(x-te)+abs(sh-x)+min(abs(te-x),abs(sh-x));
           //     cout<<te<<" "<<sh<<" "<<loser<<" "<<x<<"\n";
              }
              else if(te>x and sh<x)
              {
                 loser=abs(x-te)+abs(sh-x)+min(abs(te-x),abs(sh-x));
           //      cout<<te<<" "<<sh<<" "<<loser<<" "<<x<<"\n";
              }
              else
              {
                loser=max(abs(x-te),abs(x-sh));
              //  cout<<te<<" "<<sh<<" "<<loser<<" "<<x<<"\n";
              }
              ans=min(ans,loser);
            }
          }
          cout<<ans<<"\n";
        }
        
         
      }
    return 0;
    }



Measured memory_bytes: 2944