akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve() {
    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 3628
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    scanner.close();

    int g = 0;
    int p = 0;
    for(int i=0; i<s.length(); i++){
      switch(s.charAt(i)){
        case 'g':
          g++;
          break;
        case 'p':
          p++;
          break;
      }
    }

    System.out.println((g-p)/2);
  }
}


Measured memory_bytes: 39480
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列以外を出力する
    void write(){

    }
    template<typename First, typename... Rest>
    void write(First first, Rest... rest){
        cout << first << " ";
        write(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int N, M, C;
    io.read(N, M, C);
    vector<int> B(M);
    for(int i = 0; i < M; i++){
        io.read(B[i]);
    }
    vector<vector<int>> A(N, vector<int>(M));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            io.read(A[i][j]);
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){   
        int sum = C;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if(sum > 0) ans++;
    }
    io.write(ans);
    return 0;
}

Measured memory_bytes: 384
import math
A,B,H,M = map(int,input().split())

H_deg = (60*H+M)*0.5
M_deg = M*6
H_rad = math.radians(H_deg)
M_rad = math.radians(M_deg)

theata = abs(H_rad-M_rad)
if(theata == 0):
  ans = abs(A-B)
else:
  C = A*A+B*B-2*A*B*math.cos(theata)
  ans = math.sqrt(C)
  
print(ans)  

Measured memory_bytes: 9452
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	float a,d;
	float ans=0;
	while(n--){
		 d=0;
		 a=0;
		cin>>a;
		d=(1/a);
		ans+=d;
	}
	///float w=1/ans;
	cout<<(1/ans)<<endl;
	return 0;
}


Measured memory_bytes: 384
import sys
import math
import bisect
 
 
sys.setrecursionlimit(1000000000)
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())
 
def finput():
    return float(input())
 
def tinput():
    return input().split()
 
def rinput():
    return map(int, tinput())
 
def rlinput():
    return list(rinput())
 
def modst(a, s):
    res = 1
    while s:
        if s % 2:
            res *= a
        a *= a
        s //= 2
    return res

 
def main():
    n = iinput()
    for i in range(int(n ** 0.5) + 1, 0, -1):
        if n % i == 0:
            print(i - 2 + n // i)
            break
main()

Measured memory_bytes: 38512
const toInt = x=>parseInt(x,10);
const toIntArr = arr=>arr.map(x=>toInt(x));
const abs = x=>x>0?x:-x;
function min(){let rest = arguments,val=rest[0];for(let i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){let rest = arguments,val=rest[0];for(let i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(inputText){
	let input = inputText.split('\n');
	input = input.map(e => toIntArr(e.split(' ')));
	let x = input[0][0], n = input[0][1], ps = input[1];
	if(n===0){
		console.log(x);return 0;
	}
	let ans = 1000;
	for(let i = -1; i < 101; i++){
		if(ps.indexOf(i+1)===-1 && (i+1-x)<abs(ans)) ans = i+1-x;
	}
	console.log(ans+x);
	return 0;
}

Measured memory_bytes: 29652
n = int(input())
a = list(map(int, input().split()))
m = 65 # a<2**m
mod = 10**9+7

xor_num = [0]*m
for i in range(n):
    for j in range(m):
        if ((a[i] >> j) & 1):
            xor_num[j] += 1

b = 1
ans = 0
for i in range(m):
    ans += b*xor_num[i]*(n-xor_num[i])
    b *= 2
    b %= mod
print(ans%mod)


Measured memory_bytes: 124556
/* https://atcoder.jp/contests/arc084/tasks/arc084_a */

#include <iostream>
#include <vector>
#include <algorithm>

/* {{{ Variables */
int N;
std::vector<int> A;
std::vector<int> B;
std::vector<int> C;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> N;

  A = std::vector<int>(N);
  B = std::vector<int>(N);
  C = std::vector<int>(N);

  for (int& e: A)
    std::cin >> e;

  for (int& e: B)
    std::cin >> e;

  for (int& e: C)
    std::cin >> e;
  /* }}} */

  /* {{{ Output */
  std::sort(A.begin(), A.end());
  std::sort(B.begin(), B.end());
  std::sort(C.begin(), C.end());

  long long num_combination = 0;

  for (int i = 0; i < N; ++i) {
    int b = B.at(i);

    int idx_A = std::lower_bound(A.begin(), A.end(), b) - A.begin();
    int idx_C = std::upper_bound(C.begin(), C.end(), b) - C.begin();

    long long num_A = idx_A;
    long long num_C = N-idx_C;
    num_combination += num_A*num_C;
  }

  std::cout << num_combination << std::endl;
  /* }}} */

  return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int gi()
{
	char c;int num=0,flg=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')flg=-1;
	while(c>='0'&&c<='9'){num=num*10+c-48;c=getchar();}
	return num*flg;
}
#define N 200005
int fir[N],to[2*N],nxt[2*N],cnt;
void adde(int a,int b)
{
	to[++cnt]=b;nxt[cnt]=fir[a];fir[a]=cnt;
	to[++cnt]=a;nxt[cnt]=fir[b];fir[b]=cnt;
}
int fa[N],cir[N],clen,dep[N];bool onc[N];
void findcir(int u,int ff)
{
	fa[u]=ff;
	dep[u]=dep[ff]+1;
	for(int v,p=fir[u];p;p=nxt[p]){
		if((v=to[p])!=ff){
			if(!dep[v])findcir(v,u);
			else if(dep[v]<dep[u]){
				for(int t=u;;t=fa[t]){
					onc[t]=1;cir[++clen]=t;
					if(t==v)break;
				}
			}
		}
	}
}
int f[N];bool vis[N];
void dfs(int u,int ff)
{
	for(int v,p=fir[u];p;p=nxt[p])if((v=to[p])!=ff&&!onc[v])dfs(v,u);
	for(int v,p=fir[u];p;p=nxt[p])if((v=to[p])!=ff&&!onc[v])vis[f[v]]=1;//  KKK
	while(vis[f[u]])f[u]++;
	for(int v,p=fir[u];p;p=nxt[p])if((v=to[p])!=ff&&!onc[v])vis[f[v]]=0;
}
int main()
{
	int n=gi(),i;
	for(i=1;i<=n;i++)adde(gi(),i);
	findcir(1,0);
	for(i=1;i<=clen;i++)dfs(cir[i],0);
	bool flg=0;
	for(i=2;i<=clen;i++)
		if(f[cir[i]]!=f[cir[1]]){flg=1;break;}
	if(!flg&&(clen&1))printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
}

Measured memory_bytes: 15104
n = int(input())
a = list(map(int,input().split()))

#奇数か偶数かを判定する関数
def cal_one(n):
    return n%2
#2で割った数を返す関数
def cal_two(n):
    return n//2

ans = 0
while True:
    if sum(list(map(cal_one,a))):
        print(ans)
        exit()
    else:
        a = list(map(cal_two,a))
        ans += 1

Measured memory_bytes: 3060
import Data.List (isPrefixOf)

main :: IO ()
main = do
  s <- getLine
  putStrLn $ hantei (reverse s)

hantei :: String -> String
hantei str
  | str == [] = "YES"
  | isPrefixOf "remaerd" str = hantei $ drop 7 str
  | isPrefixOf "maerd" str = hantei $ drop 5 str
  | isPrefixOf "resare" str = hantei $ drop 6 str
  | isPrefixOf "esare" str = hantei $ drop 5 str
  | otherwise = "NO"

Measured memory_bytes: 7548
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    println("$(s[1])$(length(s)-2)$(s[end])")
end
main()

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && A != C) cout << "Yes";
    else if(B == C && B != A) cout << "Yes";
    else if(C == A && A != B) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
fun main (args:Array<String>){
    val a = readLine()!!.toInt()
    var num = 0L
    for (i in 1..a)  {
        if(i % 3 == 0){
            continue
        }
        if(i % 5 == 0){
            continue
        }
        num += i
    }
    print(num)
}


Measured memory_bytes: 34560
#include <stdio.h>
int main(void){
  int n,m,i,j,k,a,s=0,f[30]={};
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++){
      scanf("%d",&k);
      for(j=0;j<k;j++){
          scanf("%d",&a);
          f[a-1]++;
      }
  }
  for(i=0;i<m;i++){
      s+=(f[i]==n);
  }
  printf("%d",s);
}

Measured memory_bytes: 128
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    for(ll i=0;i<n;i++)
    {
        cin >> a[i];
        sum += a[i];
        sum %= MOD;
    }
    for(ll i=0;i<n;i++)
    {
        sum -= a[i];
        sum = (sum + MOD)%MOD;
        ll temp = sum * a[i];
        temp %= MOD;
        ans = (ans + temp)%MOD;
    }
    cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 5200
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
bool f = 0;
int a,b,n,cnt = 0,m,k = 0;
int x[100],y[100];
int mas[100][100];
int dx[2] = {0,1},dy[2] = {1,0};
void dfs(int x, int y);
int main(){
  while(1){
    cnt = 0;
    cin >> a >> b;
    if(a == 0 && b == 0)break;
    cin >> n;
    m = a * b;
    for(int i = 0; i <= b; i++){
      for(int j = 0; j <= a; j++){
	mas[i][j] = 0;
      }
    }
    for(int i = 0; i < n; i++){
      scanf("%d %d",&x[i],&y[i]);
      mas[y[i]][x[i]] = -1;
      m--;
    }
    dfs(1,1);
    cout << cnt << endl;
  }
}
void dfs(int x, int y){
  if(x == a && y == b){
    cnt++;
    return;
  }
  mas[y][x]++;
  for(int i = 0; i < 2; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx <= a && ny <= b && mas[ny][nx] != -1 && nx > 0 && ny > 0){
      dfs(nx, ny);
    }
  }
}

Measured memory_bytes: 1248
n,m=(int(i) for i in input().split())
b=[]
v=[]
for i in range(m):
  a=[]
  for j in input().split():
    a.append(int(j))
  b.append(a[1:])
for j in input().split():
  v.append(int(j))
r=0
for i in range(2**n):
  c=i
  t=[0 for l in range(m)]
  for j in range(n):
    if c-(c//2)*2==1:
      for k in range(m):
        if j+1 in b[k]:
          t[k]=(t[k]-1)**2
    c=c//2
  if t==v:
    r=r+1
print(r)

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	long n;


	cin >> n;

	cout << n * (n - 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();
        int[] B = new int[M];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }
        int[][] A = new int[N][M];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < M; ++j) {
                A[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(A, B, C));

        sc.close();
    }

    static int solve(int[][] A, int[] B, int C) {
        return (int) Arrays.stream(A).filter(Ai -> IntStream.range(0, B.length).map(j -> Ai[j] * B[j]).sum() + C > 0)
                .count();
    }
}

Measured memory_bytes: 38660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b;
	cin>>a>>b;
	printf("%d\n",(a+b+((a+b)%2))/2);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        for (int i = 0; i < n; i++) {
            ary[i] = Integer.parseInt(sc.next());
        }
        long[][][] dp = new long[n + 1][n + 1][2501];
        dp[0][0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                for (int k = 0; k <= 2500; k++) {
                    if (j > 0 && (k - ary[i - 1]) >= 0) {
                        dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - ary[i - 1]];
                    } else {
                        dp[i][j][k] = dp[i - 1][j][k];
                    }
                }
            }
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += dp[n][i][i * a];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 85052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if ((a+b)%2) cout << (a+b)/2+1 << endl;
  else cout << (a+b)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;


long long extgcd(long long a)
{
	long long b = MOD;
	long long u = 1, v = 0, q; 
	while ( b > 0 ) {
		q = a / b; 
		a -= q * b; swap(a,b);
		u -= q * v; swap(u,v);
	}
	u %= MOD;
	while (u<0)
		u+=MOD;
	return u;
}
long long comb(long long n,long long k)
{
	long long t = 1;
	long long j = k;
	for(long long i = n; i  >= n-k+1; i--) {
		t *= i;
		t %= MOD;
		t *= extgcd(j);
		t %= MOD;
		j--;
	}  
  	while (t<0)
		t += MOD;
	return t;
}

int main(){
	int n;
	cin >>n;
	printf("%8.8lf\n", 2*3.14159*(long long)n);
}


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

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<long long> sum(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &sum[i]);
		if (i) sum[i] += sum[i - 1];
	}
	long long min{(long long)1 << 60};
	int p_i{0}, r_i{2};
	for (int left{1}; left < n - 2; left++)
	{
		if (r_i == left) r_i++;
		for (; p_i < left - 1 && std::abs(sum[left] - 2 * sum[p_i]) > std::abs(sum[left] - 2 * sum[p_i + 1]); p_i++);
		for (; r_i < n - 2 && std::abs(sum[n - 1] + sum[left] - 2 * sum[r_i]) > std::abs(sum[n - 1] + sum[left] - 2 * sum[r_i + 1]); r_i++);
		long long pqrs[4]{sum[p_i], sum[left] - sum[p_i], sum[r_i] - sum[left], sum[n - 1] - sum[r_i]};
		min = std::min(min, *std::max_element(pqrs, pqrs + 4) - *std::min_element(pqrs, pqrs + 4));
	}
	printf("%lld\n", min);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
    int a,b,ab,x,y;
    cin >> a >> b >> ab >> x >> y;
    int cost=0;
    if(ab*2<a+b){
        cost+=(ab*2)*min(x,y);
        if(x>y){
            if (ab*2<a){
                cost+=abs(x-y)*ab*2;
            }else{
                cost+=abs(x-y)*a;
            }
        }else{
            if (ab*2<b){
                cost+=abs(x-y)*ab*2;
            }else{
                cost+=abs(x-y)*b;
            }
        }
    }else{
        cost=a*x+b*y;
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long K, long long N, std::vector<long long> A) {
  ll max = 0;
  rep(i, N) {
    ll diff;
    if (i == 0) {
      diff = (K - A[N - 1]) + A[i];
    } else {
      diff = A[i] - A[i - 1];
    }
    if (diff > max) {
      max = diff;
    }
  }
  ANS(K - max);
}

// clang-format off
int main() {
  long long K;
  scanf("%lld",&K);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(K, N, std::move(A));
  return 0;
}


Measured memory_bytes: 1792
import itertools 
n = int(input())
s = [input() for _ in range(n)]

march = [0]*5
ans = 0
for i in range(n):
  if s[i][0] == "M":
    march[0] += 1
  elif s[i][0] == "A":
    march[1] += 1
  elif s[i][0] == "R":
    march[2] += 1
  elif s[i][0] == "C":
    march[3] += 1
  elif s[i][0] == "H":
    march[4] += 1

for j in itertools.combinations(march,3):
    comb_multi = 1
    for k in range(3):
      comb_multi *= j[k]
    ans += comb_multi
print(ans)

Measured memory_bytes: 9776
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#define SE -1e10
#define EE 2e10
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int a,b,q;
  cin>>a>>b>>q;
  vector<long>s(a+2),t(b+2);
  for(int i=1;i<=a;i++)
  {
    cin>>s[i];
  }
  for(int i=1;i<=b;i++)
  {
    cin>>t[i];
  }
  s[0]=SE;t[0]=SE;
  s[a+1]=EE;t[b+1]=EE;
  long x;
  long res;
  for(int i=0;i<q;i++)
  {
    cin>>x;
    auto si=lower_bound(s.begin(), s.end(), x);
    auto ti=lower_bound(t.begin(), t.end(), x);
    long sr=*si,sl=*(si-1),tr=*ti,tl=*(ti-1);
    res=min(x-min(sl,tl),max(sr,tr)-x);
    res=min(res,tr-sl+min(tr-x,x-sl));
    res=min(res,sr-tl+min(sr-x,x-tl));

    cout<<res<<"\n";




  }

  return 0;

}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

ll a, b, c;

char step(string now, string next){

  char ret;
  ll aa = a;
  ll bb = b;
  ll cc = c;
  if(now == "AB"){

    if(aa > bb){
      a--;
      b++;
      ret = 'B';
    }else if(bb > aa){
      a++;
      b--;
      ret = 'A';
    }else{
      if(next == "BC"){
        a--;
        b++;
        ret = 'B';
      }else{
        a++;
        b--;
        ret = 'A';
      }
    }
  }else if(now == "BC"){
    if(bb > cc){
      b--;
      c++;
      ret = 'C';
    }else if(cc > bb){
      b++;
      c--;
      ret = 'B';
    }else{
      if(next == "AC"){
        b--;
        c++;
        ret = 'C';
      }else{
        b++;
        c--;
        ret = 'B';
      }
    }
  }else{ // AC
    if(aa > cc){
      a--;
      c++;
      ret = 'C';
    }else if(cc > aa){
      a++;
      c--;
      ret = 'A';
    }else{
      if(next == "AB"){
        a++;
        c--;
        ret = 'A';
      }else{
        a--;
        c++;
        ret = 'C';
      }
    }
  }
  return ret;
}

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

  int n;
  cin >> n;
  cin >> a >> b >> c;

  vector<string> s(n);
  rep(i, n){
    cin >> s[i];
  }
  s.push_back("AA");

  vector<char> ans;
  rep(i, n){

    ans.push_back(step(s[i], s[i+1]));

    if(a < 0 || b < 0 || c < 0){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes"<< endl;
  rep(i, n){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 9544
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int l=sc.nextInt(),r=sc.nextInt(),d=sc.nextInt(),count=0;
	  for(int i=l;i<=r;i++)if(i%d==0)count++;
	  System.out.println(count);
  }
}


Measured memory_bytes: 35724
#include<stdio.h>
int main(void)
{
	int a,b,c;
	
	
	do{
		scanf("%d %d",&a,&b);
		if(a>b){
			c=a;
			a=b;
			b=c;
		}
		if(b!=0){
		printf("%d %d\n",a,b);
		}
	}
	while(b!=0);
	
	
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN];
int main() {
	int n, r = 0, b = 0; read(n);
	scanf("\n%s", s + 1);
	for (int i = 1; i <= n; i++)
		if (s[i] == 'R') r++;
		else b++;
	if (r > b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 10;
int a, b;

int main(){
    cin >> a >> b;
    int tmp = (a + b) / 2;
    if((a+b)%2 != 0) tmp++;
    cout << tmp << "\n";
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {

            string sin = Console.ReadLine();
            string pin = Console.ReadLine();
            string S = sin + sin;
            int ans = 0;
            for (int j = 0; j < S.Length; j++)
            {
                if (pin[0].Equals(S[j]))
                {
                    if (S.Length > (j + pin.Length - 1))
                    {
                        string S1 = S.Substring(j, pin.Length);
                        if (pin.Equals(S1))
                        {
                            ans += 1;
                            break;
                        }
                    }
                }
            }
            if (ans > 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }
}

Measured memory_bytes: 8976
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a,b=[0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
    
v,j=0,M

for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    v=max(v,i+j)

print(v)
       


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

int n;
vector<int> b, w;
vector<vector<int>> memo, dp, cntb, cntw;

int solve();

int main() {
  cin >> n;
  memo.assign(n, vector<int>(n, 0));
  cntb.assign(n, vector<int>(n + 1, 0));
  cntw.assign(n, vector<int>(n + 1, 0));
  for (int i = 0; i < 2 * n; ++i) {
    char c;
    int a;
    cin >> c >> a;
    --a;
    if (c == 'W') {
      w.push_back(a);
      for (auto p : b) memo[a][p] = 1;
    } else
      b.push_back(a);
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  auto bubble = [](vector<int> v) {
    int res = 0;
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j) res += v[i] > v[j];
    return res;
  };
  dp.assign(n + 1, vector<int>(n + 1, (int)1e8));
  dp[0][0] = 0;
  // w
  for (int i = 0; i < n; ++i)
    for (int j = n - 1; j >= 0; --j) {
      cntw[i][j] = memo[i][j];
      cntw[i][j] += cntw[i][j + 1];
    }
  // b
  for (int i = 0; i < n; ++i)
    for (int j = n - 1; j >= 0; --j) {
      cntb[i][j] = !memo[j][i];
      cntb[i][j] += cntb[i][j + 1];
    }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j) {
      if (i != 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + cntw[i - 1][j]);
      if (j != 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + cntb[j - 1][i]);
    }
  return dp[n][n] + bubble(b) + bubble(w);
}

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

const int N=1005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

int a,b,c;
cin>>a>>b>>c;
cout<<c<<" "<<a<<" "<<b;


}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
  int k,n;
  cin>>n>>k;
  int h[200000];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h, h +n,greater<int>());
  unsigned long long a=0;
  for(int i=0;i<n;i++){
    if(i>=k)
      a+=h[i];
  }
  cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  // read problem
  ll N, K, C;
  string S;
  cin >> N >> K >> C >> S;

  // calculate dp1, dp2
  vector<ll> dp1(N), dp2(N);

  ll tmp_pos, tmp_count;

  tmp_pos = -C-1;
  tmp_count = 0;
  for(ll i = 0; i < N; i++){
    if(S[i] == 'o' && i > tmp_pos+C){
      tmp_count++;
      tmp_pos = i;
    }
    dp1[i] = tmp_count;
  }

  cerr << "dp1:" << endl;
  for(ll i = 0; i < N; i++){
    cerr << dp1[i] << " ";
  }cerr << endl;

  tmp_pos = N+C;
  tmp_count = 0;
  for(ll i = N-1; i >= 0; i--){
    if(S[i] == 'o' && i < tmp_pos-C){
      tmp_count++;
      tmp_pos = i;
    }
    dp2[i] = tmp_count;
  }

  cerr << "dp2: " << endl;
  for(ll i = 0; i < N; i++){
    cerr << dp2[i] << " ";
  }cerr << endl;

  // solve problem
  if(C == 0){
    ll count_o = 0;
    for(ll i = 0; i < N; i++){
      if(S[i] == 'o'){
        count_o++;
      }
      
    }
    if(count_o <= K){
      for(ll i = 0; i < N; i++){
        if(S[i] == 'o'){
          cout << i+1 << endl;
        }
      }
      return 0;
    }
    else{
      
      return 0;
    }
  }
  vector<ll> vac_list;
  if(N > C && dp2[C] >= K){
    vac_list.push_back(0);
  }
  for(ll i = 1; i < N-C; i++){
    if(dp1[i-1] + dp2[i+C] >= K){
      vac_list.push_back(i);
    }
  }
  if(N>C && dp1[N-C-1] >= K){
    vac_list.push_back(N-C);
  }

  ll nvac = vac_list.size();
  ll l, r, mid;

  cerr << "nvac: " << nvac << endl;
  for(ll i = 0; i < nvac; i++){
    cerr << vac_list[i] << " ";
  }cerr << endl;

  cerr << "Answer:" << endl;
  if(nvac == 0){
    for(long long int i = 0; i < N; i++){
      if(i != N-1 && dp2[i+1] >= K){
        continue;
      }
      if(i != 0 && dp1[i-1] >= K){
        continue;
      }
      cout << i+1 << endl;
    }
    return 0;
  }
  for(ll i = 0; i < N; i++){
    if(S[i] == 'x'){
      continue;
    }
    if(vac_list[0] > i){
      l = 0;
    }
    else if(vac_list[nvac-1] <= i){
      l = nvac-1;
    }
    else{
      l = 0;
      r = nvac-1;
      while(r-l>1){
        mid = (l+r)/2;
        if(vac_list[mid] <= i){
          l = mid;
        }
        else{
          r = mid;
        }
      }
    }
    l = vac_list[l];
    if(l <= i && l > i-C){
      continue;
    }
    if(i < N-1 && dp2[i+1] >= K){
      continue;
    }
    if(i != 0 && dp1[i-1] >= K){
      continue;
    }
    cout << i+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 4996
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int ketawa(int a) {
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

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

	return 0;
}


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

using namespace std;

int calc(const std::vector<int>& as, int k) {
  int const n = as.size();
  if (k == n) {
    return 1;
  }
  if (k == n - 1) {
    return 2;
  }

  return (n + k - 3) / (k - 1);
}

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> as(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }
  std::cout << calc(as, k) << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define RANGE(i,n) for(ll i=0;i<n;i++)
typedef long long ll;

using namespace std;

struct BandC{
    ll b;
    ll c;
};

struct Cards{
    ll print;
    ll mai;
};

class Compare
{
public:
    bool operator() (Cards a, Cards b){
        return a.print > b.print;
    }
};

priority_queue<Cards, vector<Cards>, Compare> A_card;


signed main() {
    ll N, M;
    cin >> N >> M;
    
    auto card_comp = [](Cards a, Cards b) { return a.print < b.print;};
    //priority_queue<Cards, vector<Cards>, decltype(card_comp)> A_card;
    RANGE(i, N){
        ll a;
        cin >> a;
        Cards card = {a, 1};
        A_card.push(card);
    }

    vector<BandC> B_C(M);
    RANGE(i,M) {
        ll b,c;
        cin >> b >> c;
        BandC b_c = {b,c};
        B_C[i] = b_c;
    }
    sort(B_C.begin(), 
            B_C.end(), 
            [](BandC l_bc, BandC r_bc) {return l_bc.c > r_bc.c;});

    RANGE(i,M){
        BandC bc = B_C[i];
        if(bc.c < A_card.top().print ) break;
        ll koukan = 0;
        while(koukan < bc.b){
            if(A_card.top().print >= bc.c) break;
            else{
                if (A_card.top().mai <= bc.b - koukan){
                    koukan += A_card.top().mai;
                    A_card.pop();
                }
                else{
                    koukan = bc.b;
                    Cards n_cards = {A_card.top().print, A_card.top().mai - (bc.b - koukan)};
                    A_card.pop();
                    A_card.push(n_cards);
                }
            }
        }
        Cards add_cards = {bc.c, koukan};
        A_card.push(add_cards);
    }

    ll summ = 0;
    while(!A_card.empty()){
        summ += A_card.top().print * A_card.top().mai;
        A_card.pop();
    }
    cout << summ << endl;
}


Measured memory_bytes: 3956
#include <vector>
#include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cstdio>
#include <cmath>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>
#include <math.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll INF = 1e9;
const double eps=1e-8;
const ll MOD = (1e9)+7;
const ll MAX_N = 1 << 17;

ll conb(ll n, ll r){
	if(n==r)
		return 1;
	// (n-r)!/r!
	ll up=n;
	ll down=2;
	ll ret=1;
	while(up>=n-r+1){
		while(down<=r && ret%down==0){
			ret/=down;
			down++;
		}
		ret*=up;
		up--;
	}
	while(down<=r && ret%down==0){
		ret/=down;
		down++;
	}
	return ret;
}

int main(){
	ll N,A,B;
	cin >> N >> A >> B;
	vector<ll> v(N);
	for(int i=0;i<N;i++)
		cin >> v[i];
	sort(v.begin(),v.end());
	ll sum=0;
	for(int i=0;i<A;i++){
		sum+=v[v.size()-i-1];
	}
	double ans = (double)sum/A;
	ll point=v[v.size()-A];

	ll count=upper_bound(v.begin(),v.end(),point)-lower_bound(v.begin(),v.end(),point);
	ll rest=v.end()-upper_bound(v.begin(),v.end(),point);
	ll n=count;
	ll r1=min(A-rest,count);
	ll r2=min(B-rest,count);
	ll answer=0;
	for(ll r=r1;r<=r2;r++){
		if(r>r1 && v[v.size()-1]!=point)
			break;
		answer+=conb(n,r);
	}
	printf("%.10f\n",ans);
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi d(n);
	rep(i,n-1){
		int a;cin>>a;
		d[a-1]++;
	}
	rep(i,n)cout<<d[i]<<endl;
}











Measured memory_bytes: 4788
/**
*    author:  Dooloper
*    created: 02.05.2020 20:53:44
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;

int N,M,Q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    if(A.size() == N+1){
        int now = 0;
        for(int i = 0; i < Q; i++){
            if(A[b[i]] - A[a[i]] == c[i])now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= M){
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin.tie(0);
    cin>>N;cin>>M;cin>>Q;
    a = b = c = d = vector<int> (Q);
    for(int i = 0; i < Q; i++){
        cin>>a[i] >> b[i] >>c[i] >>d[i];
    }

    dfs(vector<int> (1,1));
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
a = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
     ]
print(A[a-1])

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


using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<unsigned long long> X(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = N-1; i > 0; i--)
    {
        X[i] = A[i];
        if (i < N - 1)
            X[i] += X[i + 1];
            X[i] %= 1000000007;
    }
    long long sum = 0;
    for (int i = 0; i < N - 1; i++)
    {

        long long num = A[i] * X[i+1] % 1000000007;
        sum += num;
    }
    sum %= 1000000007;
    cout << sum;
    return 0;
}

Measured memory_bytes: 6404
#include<iostream>

using namespace std;

int main() {
	int n;
	long long sum = 0;
	cin >> n;
	
	for (int i = 1;i <= n;i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;

		}
	}
	cout << sum << "\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const int maxn = 205;

signed main(void){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int N, K;
	cin >> N >> K;
	int l = 1;
	--K;
	while (K--)
		l += 2;
	if (l <= N) cout << "YES";
	else cout << "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B; cin >> A >> B;
    if(A>= 13) cout << B << endl;
    else if(A >= 6) cout << B/2 << endl;
    else cout << 0 << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=200010;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int h[maxn],dp[maxn],n,k;
int main()
{
    n=read(),k=read();
    for(int i=1;i<=n;i++)
        h[i]=read();
    for(int i=2;i<=n;++i)
    {
        dp[i]=0x3f3f3f3f;
        for(int j=1;j<=k;++j)
        {
            if(i-j<1)
                break;
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

ll N;
vector<ll> a;
vector<vector<ll>> memo;

ll solve(ll l, ll r) {
    if (l >= r) {
        return 0;
    }
    if (memo[l][r] != INT_MIN) {
        return memo[l][r];
    }

    ll s1 = a[l] - solve(l + 1, r);
    ll s2 = a[r - 1] - solve(l, r - 1);
    return memo[l][r] = max(s1, s2);
}

int main() {
    cin >> N;
    a.resize(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    memo.resize(N, vector<ll>(N + 1, INT_MIN));

    cout << solve(0, N) << endl;
}

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

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    int CA[N][M+1];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M+1; j++) {
            cin >> CA[i][j];
        }
    }
    int bit = 1 << N;
    int min = INT_MAX;
    for(int i = 0; i < bit; i++) {
        int A[M];
        for(int j = 0; j < M; j++) {
            A[j] = 0;
        }
        int sum = 0;
        for(int j = 0; j < N; j++) {
            if((i & (1<<j)) != 0) {
                sum += CA[j][0];
                for(int k = 0; k < M; k++) {
                    A[k] += CA[j][k+1];
                }
            }
        }
        bool success = true;
        for(int j = 0; j < M; j++) {
            if(A[j] < X) {
                success = false;
                break;
            }
        }
        if(success && sum < min) {
            min = sum;
        }
    }
    if(min == INT_MAX) {
        cout << -1 << endl;
    } else {
        cout << min << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF INT_MAX
#define NINF -INF
#define mp make_pair
#define endl '\n'
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const ll MOD = 1e9 + 7;
const int MAXN = 200005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
mt19937 rng;
int randint(int a, int b){ return uniform_int_distribution<int>(a, b)(rng);}
bool prime(int x) {
    if(x <= 1) return false;
    if(x == 2) return true;
    for(int i=2; i*i<=x; i++)
        if(x % i == 0) return false;
    return true;
}
int main() {
    //-----------FILE------------//
    //freopen("airprog.in", "r", stdin);
    //freopen("airprog.out", "w", stdout);
    //----------------------------//
    int x ; cin >> x;
    while(1) {
        if(prime(x)) {cout << x << endl; break;}
        x++;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		sc.close();
		if (a % 2 == 0 || b % 2 == 0)
			System.out.println("Even");
		else
			System.out.println("Odd");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll X;
    cin >> X;
    rep(a, 200) for (int b = -199; b < 200; ++b) {
        if ((ll)a * a * a * a * a - (ll)b * b * b * b * b == X) {
            cout << a << " " << b << endl;
            return 0;
        }
    }
}

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

int main() {
    string s; cin >> s;
    int blue = 0;
    int red = 0;
    for(char c : s){
        if(c == '0') red++;
        else blue++;
    }
    int ans = 2*min(blue,red);
    cout << ans << endl;
}


Measured memory_bytes: 512