akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
#define PI 3.141592653589793
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long a, b, x;
    cin >> a >> b >> x;
    long floor = a * b;
    double height =  2.0 * x / floor;
    if(height > a)
    {
        double residual = x - floor * a / 2.0;
        double second_height = 2.0 * residual / (a * a);
        cout << fixed << setprecision(10) << atan2f(b - second_height, a) * 180.0 / PI << endl;
    }
    else
    {
        cout << fixed << setprecision(10) << 90.0 - atan2f(height, b) * 180.0 / PI << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x = Tp()) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

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

  auto count = make_vector({10_zu, 10_zu}, 0);
  for (int i = 1; i <= n; ++i) {
    std::string s = std::to_string(i);
    ++count[s[0]-'0'][s.back()-'0'];
  }

  intmax_t res = 0;
  for (int i = 1; i <= n; ++i) {
    std::string s = std::to_string(i);
    res += count[s.back()-'0'][s[0]-'0'];
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
#from queue import Queue


def solve(N: int, a: "List[int]", b: "List[int]", C: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)
    #counts = [Queue() for _ in range(N)]
    counts = [[] for _ in range(N)]
    for i in range(N):
        l = len(conn[i])
        #counts[l].put([i, conn[i]])
        counts[i] = [len(conn[i]), conn[i], 0, i]
    #counts.sort(key=lambda x: x[0])

    ret = 0
    #print(counts)
    C.sort()
    idx = 0
    while idx < N:
        for cnt in counts:
            if cnt[2] == 0 and cnt[0] <= 1:
                cnt[2] = C[idx]
                idx += 1
                for node in cnt[1]:
                    counts[node][0] -= 1
            ##ret += C[i] * cnt[0]
    vals = [0] * N
    for cnt in counts:
        vals[cnt[3]] = cnt[2]
    for i in range(N - 1):
        ret += min(vals[a[i] - 1], vals[b[i] - 1])
    print(ret)
    print(' '.join([str(v) for v in vals]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8948
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define IT iterater
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
signed main()
{
	int n,R=0,ans=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++)
	if(s[i]=='R') R++;
	for(int i=0;i<R;i++)
	if(s[i]=='W')ans++;
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3752
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;


long long int N,dp[55]={};
int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    dp[0]=1;
    dp[1]=1;
    for(long long int i = 2; i < 50; i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout<<dp[N]<<endl;
}




Measured memory_bytes: 3108
N = int(input())
L, H = [0] * N, [0] * N

for i in range(N):
    L[i], H[i] = list(map(int, input().split()))

L.sort()
H.sort(reverse=True)
if N%2 == 1:
    i = (N-1)//2
    l, h = L[i], H[i]
    print(h-l+1)
else:
    i = N//2
    ll, lh = L[i-1], L[i]
    hl, hh = H[i-1], H[i]
    print((hh+hl) - (lh+ll) + 1)



Measured memory_bytes: 82252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
    vector<long long> cumsum(N+1, 0);
    ll ans = 0;
    for(ll i = 0; i < N; ++i){
        cumsum[i+1] = cumsum[i] + A[i];
    }
    for(ll i = 0; i < N; ++i){
        ans += A[i] * ((cumsum[N] - cumsum[i+1]) % MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 6412
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
import itertools
import math
# import networkx as nx
from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
A=n1()

A2=[A[i-1]-i for i in range(1,n+1)]
A2.sort()

if n%2==1:
    b=A2[n//2]
    ans=sum([abs(A[i-1]-i-b) for i in range(1,n+1)])
else:
    b1=A2[n//2-1]
    b2=A2[n//2]
    ans1=sum([abs(A[i-1]-i-b1) for i in range(1,n+1)])
    ans2=sum([abs(A[i-1]-i-b2) for i in range(1,n+1)])
    ans=min(ans1,ans2)
print(ans)

Measured memory_bytes: 28004
#include<iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int c, d;
  for(int i = 1; 1; i++){
    if(b == 1){
      d = 0;
      break;
    }
    c = a * i - i + 1;
    if(c >= b){
      d = i;
      break;
    }
  }
  
  cout << d;
}

Measured memory_bytes: 3600
#include <iostream>
using ll = long long;

using namespace std;

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

	ll total_a = 0;
	ll total_b = 0;

	ll greater_a_diff = 0;
	ll greater_b_diff = 0;

	ll a[n];
	ll b[n];

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


	for (int i = 0; i < n; i++) {
		total_a += a[i];
		total_b += b[i];
		if (a[i] > b[i]) {
			greater_a_diff += a[i] - b[i];
		} else {
			greater_b_diff += (b[i] - a[i] + 1) / 2;
		}
	}
	ll op = total_b - total_a;
	if (op < 0) {
		cout << "No" << endl;
		return 0;

	}

	if (greater_b_diff > op) {
		cout << "No" << endl;
		return 0;

	}	
	cout << "Yes" << endl;

	return 0;


}

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

int main() {
  int n;
  ll k;
  string s;
  cin>>n>>k>>s;
  string copy=s;
  sort(copy.begin(),copy.end());
  string copyb=copy;
  string copyc=s;
  string copyd=s;
  string copye;
  reverse(copyd.begin(),copyd.end());
  for(int i=0;i<n;i++){
    copyb[i]=copy[n-1];
  }
  string copyf=copyb;
  if(k>=15){
    for(int i=0;i<n;i++){
      cout<<copy[0];
    }
    cout<<endl;
    return 0;
  }
  for(int i=0;i<k-1;i++){
    s=copyc+copyd;
    for(int j=0;j<=n;j++){
      copye=s.substr(j,n);
      reverse(copye.begin(),copye.end());
      if(copyb>copye){
        copyb=copye;
      }
    }
    copyc=copyb;
    copyd=copyc;
    reverse(copyc.begin(),copyc.end());
    copyb=copyf;
  }
  //cout<<copyc<<" "<<copyd<<endl;
  s=copyc+copyd;
  for(int i=0;i<=n;i++){
    copye=s.substr(i,n);
    if(copyb>copye){
      copyb=copye;
    }
  }
  cout<<copyb<<endl;
}

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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main(){

  string s;
  cin >> s;
  if(isupper(s[0])){
    cout << 'A';
  }else{
    cout << 'a';
  }

  //cout << << endl;

  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<ctype.h>
int main(){
	int i=0,a;
	char c[100];
	while(1){
		scanf("%c",&c[i]);
		if(c[i]=='\n')break;
		else i++;
	}
	a=i;
	for(i=0;i<a;i++)c[i]=toupper(c[i]);
	for(i=0;i<=a;i++)printf("%c",c[i]);
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    vec S(N + 1); S[0] = 0;
    REP(i, N) S[i + 1] = S[i] + A[i];
    int ans = INF;
    REP(i, N + 1){
        int tmp = S[N] - 2 * S[i];
        Min(ans, llabs(tmp));
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 3456
import itertools
import numpy as np

N, M, Q = map(int, input().split())

A = np.array(list(itertools.combinations_with_replacement(range(1, M+1), N)))
s = np.zeros(len(A), np.int32)

for i in range(Q):
    a, b, c, d = map(int, input().split())
    s += d * (A[:, b-1] - A[:, a-1] == c)

print(s.max())

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

int main(){
    std::string o,e;
    std::cin >> o >> e;
    std::string pas;
    for(auto oitr=o.begin(),eitr=e.begin();oitr!=o.end();++oitr,++eitr){
        pas += *oitr;
        if(eitr != e.end()){
            pas += *eitr;
        }
    }
    std::cout << pas << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
  int a, b, c, x, y, sum_0, sum_1, sum_2, ans;
  cin >> a >> b >> c >> x >> y;
  sum_0 = a * x + b * y;
  if (x > y) sum_1 = y * c * 2 + (x - y) * a;
  else sum_1 = x * c * 2 + (y - x) * b;
  sum_2 = c * max(x, y) * 2;
  ans = min(sum_0, sum_1);
  ans = min(ans, sum_2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = System.Console.ReadLine().Split(' ');
            float b = (int.Parse(a[0]) + int.Parse( a[1])) / 2f ;
            int c = (int)(b + 0.5);

            Console.Write(c);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,m;
int sum;
int main(){
    scanf("%d%d%d",&n,&m,&sum);
    int k=0;
    for(int i=0;i<n;i++){
        if(k<m){
            printf("%d ",sum);
            k++;
        }
        else {
            if(sum<1000000000-1){
                printf("%d ",sum+1);
            }
            else printf("%d ",1000000000-3);
        }
    }
    printf("\n");
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

ll power(ll a, ll n, int p){
    ll res=1;
    a%=p;
    for(;n>0;n>>=1){
        if(n&1)res=res*a%p;
        a=a*a%p;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,p;cin>>n>>p;
    string s;cin>>s;
    map<int,ll> m;m[0]++;
    if(p!=2&&p!=5){
        int num = 0;
        for(int i=0; i<n; i++){
            num = (10*num+(s[i]-'0'))%p;
            ll d = num*power(10,n-i-1,p)%p;
            m[d]++;
        }
        ll ans = 0;
        for(pair<int,ll> p:m){
            ans += p.second*(p.second-1)/2;
        }
        cout<<ans<<endl;
    }
    else if(p==2){
        ll ans = 0;
        for(int i=0; i<n; i++){
            int num = (s[i]-'0');
            if(num%2==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
    }
    else{
        ll ans = 0;
        for(int i=0; i<n; i++){
            int num = (s[i]-'0');
            if(num%5==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 1044
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        K: i64,
        A: i64,
        B: i64,
    }

    for i in A..B+1 {
        if i % K == 0 {
            println!("OK");
            return;
        }
    }

    println!("NG")
}


Measured memory_bytes: 2068
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<double,double>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main() {
    int n;cin>>n;int suma=0,sumb=0;int a[114514],b[114514];
    rep(i,0,n){
        cin>>a[i];suma+=a[i];
    }
    rep(i,0,n){
        cin>>b[i];sumb+=b[i];
    }
    int need=sumb-suma;
    int cnta=0,cntb=0;
    rep(i,0,n){
        if(a[i]>=b[i])cntb+=a[i]-b[i];
        else if((b[i]-a[i])%2==1){
            cntb++; cnta+=(b[i]+1-a[i])/2;
        }
        else {
            cnta+=(b[i]-a[i])/2;
        }
    }
    if(cntb>need||cnta>need){
        cout<<"No"<<endl;
        return 0;
    }
    if((need-cnta)*2+cntb==need)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int, input().split()))
M=[0]*N
maxi=sum(A)

M[0]=maxi//4
tmp=10**9

while M[0]/2 != tmp:
  for i in range(1,N):
    M[i]= 2*(A[i-1]-M[i-1]//2)
  tmp = A[-1] - M[N-1]//2
  #print(M,tmp)
  if M[0] != tmp*2:
    M[0] = (M[0]+tmp*2)//2
    if M[0]%2!=0:
      M[0] +=1
else:
  print(*M)

Measured memory_bytes: 14624
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();

        var z = 1 / seqA.Sum(x => 1 / x);
        Console.WriteLine(z);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 1;
    REP(i, N-1){
        if(S[i] != S[i+1])ans++;
    }
    pr(ans);
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int i=0,j;
  double m,g,tmp,a={0};
  while(scanf("%lf",&a) != EOF){
    if(i == 0){
      m=a;
      g=a;
      i=1;
    }
    else{
      if(m < a){
	m=a;
      }
      else if(g > a){
	g=a;
      }
    }
  }
  printf("%lf\n",m-g);
  return (0);
}

Measured memory_bytes: 648
#include <stdio.h>

int main(){
  int N;
  char s[3*100000];
 int i;
  scanf("%d", &N);
  scanf("%s", s);
  
  int p = 0;
  int c = 0;
  int x = 0;
  int maxc = 0;
  
  for(i = 1; i < N; i++){
    if(s[i-1] == 'W')
      c -= 1;
    else
      c += 1;
    
    if(c > maxc){
     maxc = c; 
      p = i;
    }          
  }
  
  for(i = 0; i < N; i++){
  if(i < p)
    if(s[i] == 'W')
      x += 1;
    
    if(i > p)
      if(s[i] == 'E')
      x += 1;
  }
  
  printf("%d\n", x);
  
  return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    int H, W, M;

    public void Solve()
    {
        var sc = new Scanner();
        H = sc.NextInt();
        W = sc.NextInt();
        M = sc.NextInt();


        var rCnt = new int[H];
        var cCnt = new int[W];

        var hs = new HashSet<(int h, int w)>();
        for (int i = 0; i < M; i++)
        {
            int h = sc.NextInt() - 1;
            int w = sc.NextInt() - 1;
            rCnt[h]++;
            cCnt[w]++;
            hs.Add((h, w));
        }


        // iに置くとi行のやつ
        // jに置くとj列のやつ
        // (i,j)にあるなら1つ減る

        var cSorted = new int[W];
        for (int i = 0; i < W; i++)
        {
            cSorted[i] = i;
        }

        int ans = int.MinValue;
        Array.Sort(cSorted, (l, r) => cCnt[r].CompareTo(cCnt[l]));
        for (int i = 0; i < H; i++)
        {
            // 横rCnt[i]個
            foreach (int j in cSorted)
            {
                if (hs.Contains((i, j)))
                {
                    ans = Math.Max(ans, rCnt[i] + cCnt[j] - 1);
                }
                else
                {
                    ans = Math.Max(ans, rCnt[i] + cCnt[j]);
                    break;
                }
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 56116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a+b >= c ? "Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[31][400400];
ll dd[400400];

int main() {
  clr(d,0);
  clr(dd,0);
  ll n,c;
  cin>>n>>c;
  rep(i,0,n){
    ll a,b,c1;
    cin>>a>>b>>c1;
    a *= 4;
    b *= 4;
    b--;
    c1--;
    d[c1][a]++;
    d[c1][b+1]--;
  }
  rep(i,0,c){
    rep(j,1,400400){
      d[i][j] += d[i][j-1];
    }
  }
  vector<pair<ll,ll> > v;
  rep(i,0,c){
    ll a,b;
    rep(j,0,400400-1){
      if(d[i][j]==0&&d[i][j+1]==1){
        a = j-1;
      }
      if(d[i][j]==1&&d[i][j+1]==0){
        b = j;
        v.pb(mp(a,b));
      }
    }
  }
  rep(i,0,v.sz){
    dd[v[i].fi]++;
    dd[v[i].se+1]--;
  }
  rep(i,1,400400){
    dd[i] += dd[i-1];
  }
  ll mx = 0;
  rep(i,0,400400){
    mx = max(mx,dd[i]);
  }
  cout << mx << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int64_t r = 0;
    int64_t g = 0;
    int64_t b = 0;
    rep(i,n) {
        if (s[i] == 'R') r++; 
        if (s[i] == 'G') g++;
        if (s[i] == 'B') b++;
    }
    int64_t ans = r * g * b;
    int64_t cnt = 0;
    for (int d = 1; d < n; d++) {
        for (int lef = 0; lef+d*2 < n; lef++) {
            if (s[lef] != s[lef+d] && s[lef+d] != s[lef+2*d] && s[lef+2*d] != s[lef]) cnt++;
        }
    }
    ans -= cnt;
    cout << ans << endl;
}

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

using namespace std;
vector<vector<bool> >v;
vector<bool>v2;
int N=0;
void gen(int i=0){
if(i==N){v.push_back(v2);return;}
v2.push_back(0);
gen(i+1);
v2.pop_back();
v2.push_back(1);
gen(i+1);
v2.pop_back();
}
int main(){
int n=0,m=0,k=0,ans=0;
char grid[10][10];
cin>>n>>m>>k;
N=n+m;
for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>grid[i][j];
gen();
for(auto bit:v){
int cnt=0;
for(int i=0;i<n;i++)for(int j=0;j<m;j++)cnt+=(grid[i][j]=='#'&&!bit[i]&&!bit[n+j]);

ans+=(cnt==k);
}



cout<<ans;

    return 0;
}


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

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

  int a[n];
  int max,min;
  long long tot = 0; // in this question, long long is beter than int.
  
  for(int i=0; i < n; i++)
    {
      cin >> a[i];
      if(i == 0)
	{max = a[0];    min = a[0];}
      else
	{
	  if(a[i] > max)
	    {max = a[i];}
	  if(a[i] < min)
	    {min = a[i];}
	}
      tot = tot + a[i];
    }

  cout << min << " " << max << " " << tot << endl;

  return 0;
}
      


Measured memory_bytes: 3144
#include <stdio.h>

struct Node{int p,l,r;};

struct Node T[100000];
int n,D[100000];

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);

  if(T[u].p==-1){
    printf("root, ");
  }
  else if(T[u].l==-1){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }

  printf("[");
  for(i=0,c=T[u].l;c!=-1;i++,c=T[c].r){
    if(i==0){
      printf("%d",c);
    }
    else{
      printf(", %d",c);
    }
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].r!=-1){
    rec(T[u].r,p);
  }
  if(T[u].l!=-1){
    rec(T[u].l,p+1);
  }
  return 0;
}

int main(){
  int i,j,d,v,c,l,r;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	T[v].l=c;
      }
      else{
	T[l].r=c;
      }
      l=c;
      T[c].p=v;
    }
  }
  
  for(i=0;i<n;i++){
    if(T[i].p==-1){
      r=i;
    }
  }

  rec(r,0);

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;

}


Measured memory_bytes: 6456
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;
const ld pi = (acos(-1));




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >> n;
  vector<int> p(n,0);
  rep(i,0,n-1){
    int a; cin >> a;
    a--;
    p[a]++;
  }
  rep(i,0,p.size()){
    cout << p[i] << endl;
  }
}

Measured memory_bytes: 3992
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 200050;

long long A[MAX_N];
int N;

long long AC[MAX_N];

long long sum(const int begin, const int end) {
    return AC[end] - AC[begin - 1];
}

long long score(const int begin, const int end, const int mid) {
    long long val1 = sum(begin, mid - 1);
    long long val2 = sum(mid, end);
    return labs(val1 - val2);
}

int get_best(const int begin, const int end) {
    if (begin + 1 == end) {
        return end;
    }

    int from = begin;
    int to = end;
    while (true) {
        int mid = (from + to) / 2;
        if (score(begin, end, mid+1) < score(begin, end, mid)) {
            from = mid;
        } else {
            to = mid;
        }
        if (from + 1 == to) {
            break;
        }
    }
    return to;
}

long long max_dist(const long long v1, const long long v2, const long long v3, const long long v4) {
    std::vector<long long> vec;
    vec.push_back(v1);
    vec.push_back(v2);
    vec.push_back(v3);
    vec.push_back(v4);

    std::sort(vec.begin(), vec.end());
    return vec[vec.size()-1] - vec[0];
}

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

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    AC[0] = 0;
    for (int i = 1; i <= N; i++) {
        AC[i] = AC[i-1] + A[i];
    }

    long long ret = AC[N];

    for (int mid = 2; mid <= N - 2; mid++) {
        int mid1 = get_best(1, mid);
        int mid2 = get_best(mid+1, N);
        long long P = sum(1, mid1-1);
        long long Q = sum(mid1, mid);
        long long R = sum(mid+1, mid2-1);
        long long S = sum(mid2, N);
        long long tmp = max_dist(P, Q, R, S);
        //std::cout << mid1-1 << " " << mid << " " << mid2-1 << std::endl;
        //std::cout << P << " " << Q << " " << R << " " << S << std::endl;
        //std::cout << tmp << std::endl;
        ret = std::min(ret, tmp);
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  bool first_half[26],second_half[26];
  int max = 0;
  for(int i=1;i<n;i++){
    int count =0;
    for(int i=0;i<26;i++){
      first_half[i]=0;
      second_half[i]=0;
    }
    for(int j=0;j<i;j++){
      first_half[s[j]-'a']=1;
    }
    for(int k=i;k<n;k++){
      second_half[s[k]-'a']=1;
    }
    for(int l=0;l<26;l++){
      if(first_half[l]==1 && second_half[l]==1){
        count++;
      }
    }
    if(count>max){
      max = count;
    }
  }
  cout<<max<<endl;
}


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

using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);}


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

  Int n;
  cin>>n;

  if(n==1){
    cout<<"Yes"<<endl;
    cout<<1<<endl;
    return 0;
  }

  if(n&1) drop("No");

  vector< vector<Int> > ans(n,vector<Int>(n,-1));

  Int cnt=1;
  for(Int i=0;i<n;i++) ans[i][i]=cnt;
  cnt++;

  for(Int t=0;t<2;t++){
    auto add_edge=
      [&](Int p,Int q,Int x){
        p=(p+n)%n;
        q=(q+n)%n;
        if(t==0) if(p>q) swap(p,q);
        if(t==1) if(p<q) swap(p,q);
        ans[p][q]=x;
      };
    for(Int i=0;i<n-1;i++){
      add_edge(i,n-1,cnt);
      for(Int j=1;j<n/2;j++){
        Int p=(i+(n-1)+j)%(n-1);
        Int q=(i+(n-1)-j)%(n-1);
        add_edge(p,q,cnt);
      }
      cnt++;
    }
  }

  cout<<"Yes"<<endl;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 4904
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  for (int i=0; i<X; i++)
    cin >> A[i];
  for (int i=0; i<Y; i++)
    cin >> B[i];
  for (int i=0; i<Z; i++)
    cin >> C[i];
  
  sort(A.rbegin(),A.rend());
  sort(B.rbegin(),B.rend());
  sort(C.rbegin(),C.rend());
  
  priority_queue<tuple<ll, int, int, int>> Q;
  Q.emplace(A[0]+B[0]+C[0], 0, 0, 0);
  set<int> IsChecked;
  IsChecked.insert(0);
  ll s;
  int a, b, c;
  for (int i=0; i<K; i++) {
    tie(s, a, b, c) = Q.top(); Q.pop();
    cout << s << endl;
    
    if (a+1 < X){
      if (IsChecked.find(((a+1)<<20) + (b<<10) + c) == IsChecked.end()){
        Q.emplace(A[a+1]+B[b]+C[c], a+1, b, c);
        IsChecked.insert(((a+1)<<20) + (b<<10) + c);
      }
    }
    if (b+1 < Y){
      if (IsChecked.find((a<<20) + ((b+1)<<10) + c) == IsChecked.end()){
        Q.emplace(A[a]+B[b+1]+C[c], a, b+1, c);
        IsChecked.insert((a<<20) + ((b+1)<<10) + c);
      }
    }
    if (c+1 < Z){
      if (IsChecked.find((a<<20) + (b<<10) + c+1) == IsChecked.end()){
        Q.emplace(A[a]+B[b]+C[c+1], a, b, c+1);
        IsChecked.insert((a<<20) + (b<<10) + c+1);
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
const char CH[]={'R','D','L','U'};
const long long DR[]={-1,0,1,0};
const long long DC[]={0,1,0,-1};
int n;
long long x[maxn],y[maxn];
int cnt[2];
bool test(long long x,long long y,int d){
  return abs(x)+abs(y)<=(1<<d)-1;
}
int main(){
  //freopen("aa.in","r",stdin);
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%lld%lld",x+i,y+i);
    cnt[abs(x[i]+y[i])&1]++;
  }
  if(cnt[0] && cnt[1])return puts("-1"),0;
  if(cnt[0]){
    for(int i=1;i<=n;i++){
      x[i]++;
    }
    printf("%d\n%d ",32,1);
  }else printf("%d\n",31);
  for(int i=0;i<=30;i++)printf("%d ",1<<i);
  puts("");
  for(int i=1;i<=n;i++){
    vector<char>op;
    for(int j=30;~j;j--){
      int step=1<<j;
      for(int k=0;k<4;k++){
        if(test(x[i]+DR[k]*step,y[i]+DC[k]*step,j)){
          x[i]+=DR[k]*step;
          y[i]+=DC[k]*step;
          op.push_back(CH[k]);
          break;
        }
      }
    }
    // printf("round %d  :",i);
    if(cnt[0])op.push_back('L');
    reverse(op.begin(),op.end());
    for(char c:op)putchar(c);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int W,H,x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(W>=x+r && 0<=x-r && H>=y+r && 0<=y-r){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return (0);
}





Measured memory_bytes: 2104
import sys
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

INF = 10 ** 15

def warshall_floyd(dist, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
    return dist

N, M, L = lr()
dist = [[INF] * (N+1) for _ in range(N+1)] # 1-indexed
for _ in range(M):
    a, b, c = lr()
    if c > L:
        continue
    dist[a][b] = c
    dist[b][a] = c

dist = warshall_floyd(dist, N+1)
supply = [[INF] * (N+1) for _ in range(N+1)] # 1-indexed 距離L以下で供給が1回必要
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if dist[i][j] <= L:
            supply[i][j] = supply[j][i] =  1

supply = warshall_floyd(supply, N+1)
Q = ir()
for _ in range(Q):
    s, t = lr()
    x = supply[s][t] - 1
    print(-1 if x + 1 == INF else x)


Measured memory_bytes: 58204
q = int(input())
ll = []
rr = []
for i in range(q):
    l,r = map(int,input().split())
    ll.append(l)
    rr.append(r)

m = min(ll)
M = max(rr)
cnt = [0]*(M+2)

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            return False
    return True

s = 0
for i in range(m,M+1,2):
    if is_prime(i) and is_prime((i+1)//2):
        s += 1
    cnt[i] = s

for i in range(q):
    print(cnt[rr[i]]-cnt[ll[i]-2])

Measured memory_bytes: 12756
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 1000010
#define LL long long
using namespace std;

const LL P=998244353;

int n,m;
LL fac[MAXN],invfac[MAXN];

LL getPow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P;
		y>>=1;
	}
	return res;
}

void init(){
	fac[0]=1;
	for(int i=1;i<MAXN;i++) fac[i]=fac[i-1]*i%P;
	invfac[MAXN-1]=getPow(fac[MAXN-1],P-2);
	for(int i=MAXN-2;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%P;
}

LL getC(int x,int y){
	return fac[x]*invfac[y]%P*invfac[x-y]%P;
}

LL calc(int x,int y){
	return getC(x+y,x);
}

int main(){
	scanf("%d%d",&n,&m);
	init();
	if(n<m) n^=m^=n^=m;
	LL ans=calc(n,m)*n%P;
	for(int i=1;i<=m;i++)
		ans=(ans+calc(n-i,m-i)*calc(i-1,i))%P;
	ans=ans*getPow(calc(n,m),P-2)%P;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
 using namespace std;
 int main()
 {
     string s;
     cin>>s;
     reverse(s.begin(),s.end());
     if(s[0]=='s')
     {
         reverse(s.begin(),s.end());
         s+='e';
         s+='s';
     }
     else
     {
         reverse(s.begin(),s.end());
         s+='s';
     }
     cout<<s<<endl;
 }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
while(True):
  n = input()
  if n == 0:
    break;
  sl = 1001
  sh = 0
  ret = 0
  for i in range(n):
    tmp = input()
    ret += tmp
    if tmp < sl:
      sl = tmp
    if tmp > sh:
      sh = tmp
  ret -= (sl + sh)
  print "%d" % (ret/(n-2))

Measured memory_bytes: 4216
import math

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    cnt += math.sqrt((a[i][0] - a[j][0]) ** 2 + (a[i][1] - a[j][1]) ** 2)
print(cnt * 2 / n)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef unsigned long long ll;
ll mod=1000000007;

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

ll lcm(ll a, ll b){
  ll g = gcd(a,b);
  return a/g*b;
}

int main() {
  ll a,b,c,d; cin >> a >>b >> c >> d;
  ll divc = b/c - (a-1)/c;
  ll divd = b/d - (a-1)/d;
  ll alcm = lcm(c,d);
  ll divcd = b/alcm - (a-1)/alcm;
  cout  << (b-a+1) - divc - divd + divcd << endl;
  return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -Wall #-}

import Control.Exception
import Data.Array
import Data.List

readInt :: String -> Int
readInt = read

calcDp :: Int -> Int -> Array Int Int -> Array (Int,Int) Int
calcDp n m cs = assert (cs!0 == 1) dp
    where
        dp = listArray ((0,0),(m-1,n)) [f i j | i<-[0..m-1], j<-[0..n]]
        f _ 0 = 0
        f 0 j = j
        f i j
            | j >= c    = min (1+dp!(i,j-c)) (dp!(i-1,j))
            | otherwise = dp!(i-1,j)
            where
                c = cs!i

main :: IO ()
main = do
    [n,m] <- fmap (map readInt . words) getLine
    cs    <- fmap (map readInt . words) getLine
    let cs' = listArray (0,m-1) $ sort cs

    let dp  = calcDp n m cs'
    let ans = dp!(m-1,n)

    --print $ dp
    print $ ans



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

int main() {
    int K;
    cin >> K;
    cout << (K/2) * (K-K/2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	int ans = 0;
	cin >> S;
	rep(i, 3) {
		if (S[i] == '1') ans++;
	}
	dunk(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<int>pnt(n+1);
        for(int i=0;i<n;i++)cin>>pnt[i];
        pnt[n]=0;
        vector<int>latte;
        for(int i=0;i<n+1;i++)
            for(int j=i;j<n+1;j++)
                latte.push_back(pnt[i]+pnt[j]);

        sort(latte.begin(),latte.end());
        int Max=0;
        for(int i=1;i<latte.size()&&latte[i]<=m;i++){
            int s=*(upper_bound(latte.begin(),latte.end(),m-latte[i])-1)+latte[i];
            Max=max(Max,s);
            //cout<<latte[i]<<" "<<s-latte[i]<<" "<<s<<endl;
        }
        cout<<Max<<endl;

    }
}

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

int main(){
  int N;
  cin >> N;
  int count=0;
  for(int i=1; i<=N; i++){
    int A; cin >> A;
    if(A%2==1) count++;
  }
  if(count%2==1){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> ans(10050, 0);
    for (int i = 1; i < 105; i++) {
        for (int j = 1; j < 105; j++) {
            for (int k = 1; k < 105; k++) {
                int v = i*i + j*j + k*k + i*j + j*k + i*k;
                if (v < 10050)
                    ans.at(v)++;
            }
        }
    }
    for (int i = 1; i <= N; i++)
        cout << ans.at(i) << endl;
}

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

int n,k;
int num[100001];
int dp[100001];

int main(){
    memset(dp,63,sizeof dp);
    cin>>n>>k;
    for(int qq=1;qq<=n;qq++)
        cin>>num[qq];
    dp[1]=0;
    for(int qq=2;qq<=n;qq++){
        for(int ww=qq-1;ww>=qq-k;ww--){
            if(ww<=0)continue;
            dp[qq]=min(dp[qq],abs(num[ww]-num[qq])+dp[ww]);
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
   int a, b;
   cin >> a >> b;
   cout << a*b;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
    int s[3];
    scanf("%d %d %d",&s[0],&s[1],&s[2]);
    if(s[0]==7 && s[1]==5 && s[2]==5){
        printf("YES\n");
    }else if(s[0]==5 && s[1]==7 && s[2]==5){
        printf("YES\n");
    }else if(s[0]==5 && s[1]==5 && s[2]==7){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128