akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define Rep(i,s,f) for(int i=(int)s;i<(int)f;i++)
using ll=long long;
using namespace std;


int main()
{
	int N;
	cin>>N;
	int prev=0;
	ll ans=0;
	rep(i,N)
	{
		ll a;
		cin>>a;
		if(a==0)
		{
			prev=0;
		}
		ans+=(a+prev)/2;
		prev=(a+prev)%2;	
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define mx 1e18
#define mod 998244353
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll bino()
{
        vector<ll>inv(200005);vector<ll>fact(200005); vector<ll>inversef(200005);
    inv[0] = 1;inv[1]=1;
for(int i = 2; i < 200005; ++i)
    inv[i] = (inv[mod%i]*(mod-mod/i)) % mod;
    
    fact[0]=1;
    for(int i=1;i<200005;i++)
    fact[i]=(i*fact[i-1])%mod;
   
    inversef[0]=1;inversef[1]=1;
    for(int i=2;i<200005;i++)
    inversef[i]=(inversef[i-1]*inv[i])%mod;
}
ll powe(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return powe(((x%mod)*(x%mod))%mod,n/2);
    else                             //n is odd
        return ((x%mod*(powe(((x%mod)*(x%mod))%mod,(n-1)/2))%mod)%mod);
}
int main()
{
   io
  int n,m;cin>>n>>m;
  vector<int>h(n+1);
 
  vector<vector<int>>v(n+1);
  for(int i=1;i<=n;i++)cin>>h[i];int x,y;int pp=0;
  while(m--)
  {cin>>x>>y;
     v[x].pb(y);v[y].pb(x); 
  }ll ans=0;
  for(int i=1;i<=n;i++)
  {
      if(v[i].size()==0)
      {
        ans++; 
      }
      else
      {pp=0;
          for(int j=0;j<v[i].size();j++)
          {
              if(h[v[i][j]]>=h[i])
              {
                  pp=1;break;
              }
          }
          if(pp==0)ans++;
      }
  }
  cout<<ans<<endl;
 // for(int i=1;i<=n;i++)cout<<v[i].size()<<" ";
}

Measured memory_bytes: 8752
n=input()
s=input()+"2"
p=input()
a=[0]
i=0
d=1
while i<len(p):
    if s[i]==s[i+1]:
        if a[-1]==0:
            d*=6
        if a[-1]==1:
            d*=2
        if a[-1]==2:
            d*=3
        a.append(2)
        i+=2
    else:
        if a[-1]==0:
            d*=3
        if a[-1]==1:
            d*=2
        a.append(1)
        i+=1
print(d%(10**9+7))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n<=999)cout<<"ABC";
    else cout<<"ABD";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	k, a, b := r.nextInt(), r.nextInt(), r.nextInt()

	ans := k + 1
	if a+2 < b && k+1 >= a {
		ans = a + (k-(a-1))/2*(b-a) + (k-(a-1))%2
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))
 
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;
 
template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}
 
string S, T;
bool ok;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> S >> T;
    for (int i = 0; i < sz(S); i++) {
        string Srot;
        for (int i1 = i; i1 < sz(S); i1++)
            Srot += S[i1];
        for (int i1 = 0; i1 < i; i1++)
            Srot += S[i1];
        if (T == Srot)
            return !(cout << "Yes\n");
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int a,b;
	scanf("%d %d",&a,&b);
	if((a*b)%2==0)printf("Even\n");
	else printf("Odd\n");
	return 0;
}

Measured memory_bytes: 128
import collections

n = int(input())
a = list(map(int, input().split()))

b = collections.Counter(a)
c = b.most_common()
c.sort(key=lambda x: x[0])
cnt = 1
if n % 2 == 1:
    cnt = 0

for i, j in c:
    # print(i, j)
    if cnt == 0:
        if j != 1:
            print(0)
            exit()
        else:
            cnt += 2
    else:
        if i != cnt or j != 2:
            print(0)
            exit()
        else:
            cnt += 2

print((2 ** (n // 2)) % (10 ** 9 + 7))


Measured memory_bytes: 16096
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
const int INF = 1e9;
int main() {
	ll n,m;
	cin >> n >> m;
	int l(0), r(INF);
	rep(i, m) {
		int p, q;
		cin >> p >> q;
		l = max(l, p);
		r = min(r, q);
	}
	int ans = r - l + 1;
	if (ans < 0)cout << 0;
	else cout << ans;
	
	return 0;
}



Measured memory_bytes: 3632
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n - 1]);
    let mut a_v = vec![0; n];
    for v in a {
        a_v[v - 1] += 1;
    }

    let ans = a_v.iter().take(n).join("\n");
    println!("{}", ans);
}


Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
vector<char> D = {'D', 'R', 'U',  'L'};
void dfs(vector<vector<char>> &c, int y, int x, int d, int cnt, string &S, string &ans){
  if (cnt == 1){
    ans = S;
  }
  for (int i = 0; i < 4; i++){
    if (abs(d - i) != 2){
      int y2 = y;
      int x2 = x;
      while (1){
        y2 += dy[i];
        x2 += dx[i];
        if (c[y2][x2] != '.'){
          break;
        }
      }
      if (c[y2][x2] == 'o'){
        c[y2][x2] = '.';
        S.push_back(D[i]);
        dfs(c, y2, x2, i, cnt - 1, S, ans);
        S.pop_back();
        c[y2][x2] = 'o';
      }
    }
  }
}
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> c(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      cin >> c[i][j];
    }
  }
  int cnt = 0;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (c[i][j] != '.'){
        cnt++;
      }
    }
  }
  int y, x, d;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (c[i][j] != '.' && c[i][j] != 'o'){
        y = i;
        x = j;
        if (c[i][j] == 'D'){
          d = 0;
        }
        if (c[i][j] == 'R'){
          d = 1;
        }
        if (c[i][j] == 'U'){
          d = 2;
        }
        if (c[i][j] == 'L'){
          d = 3;
        }
      }
    }
  }
  c[y][x] = '.';
  string S, ans;
  dfs(c, y, x, d, cnt, S, ans);
  cout << ans << endl;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define maxn 200005
#define Mod 1000000007
#define ll long long
#define Mod 1000000007
using namespace std;
inline int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
char s[maxn];
int a[26],mi[maxn],n,ans;
inline void add(int &x,int y){x+=y;x-=x>=Mod?Mod:0;}
int main(){
	n=read();scanf("%s",s+1);mi[0]=1;
	for(int i=1;i<=n;i++)mi[i]=2ll*mi[i-1]%Mod;
	for(int i=1;i<=n;i++){
		int res=1;int c=s[i]-'a';
		for(int j=0;j<26;j++)if(j!=c)res=1ll*res*(a[j]+1)%Mod;
		add(ans,res);
		a[s[i]-'a']++;
	}printf("%d\n",ans);return 0;
}

Measured memory_bytes: 768
import qualified Data.Vector.Unboxed as VU
import Data.Char

toTuple :: [Int] -> (Int, Int)
toTuple [a, b] = (a, b)

solve xys = let (a, b) = VU.foldl step (1, 1) xys in a + b 
    where
        step :: (Int, Int) -> (Int, Int) -> (Int, Int)
        step (a, b) (x, y) = (m*x, m*y)
            where
                qr = let (q, r) = quotRem a x in if r == 0 then q else q + 1
                st = let (s, t) = quotRem b y in if t == 0 then s else s + 1
                m = max qr st

main = do
    n <- readLn :: IO Int
    tas <- VU.replicateM n (toTuple . map read . words <$> getLine)
    print $ solve tas

Measured memory_bytes: 1148
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  for(i = 1; i < n+1; i++){
    key = A[i];
    j = i -1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
   trace(A,n);
  }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
using namespace std;

int main() {
	long long int a, b;
	cin >> a >> b;
	if (a%2==b%2) {
		
			cout << (b + a) / 2 << endl;
		
	}
	else {
		cout<< "IMPOSSIBLE" <<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long int i;
  long int N;
  long int answer = 0;
  
  scanf("%ld", &N);
  for(i = 1; i <= N; i++) {
    if(i % 3 != 0 && i % 5 != 0) {
      answer += i;
    }
  }
  
  printf("%ld", answer);
  
  return 0;
}

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

using namespace std;
using ll = long long;

ll solve(size_t K)
{
    set<ll> xs, ys;

    for (int i = 1; i < 10; ++i)
        xs.insert(i);

    while (xs.size() < K)
    {
        ys.clear();

        for (auto x : xs)
        {
            ys.insert(x);

            int d = x % 10;

            ys.insert(10*x + d);

            if (d > 0)
                ys.insert(10*x + (d - 1));

            if (d < 9)
                ys.insert(10*x + (d + 1));
        }

        ys.swap(xs);
    }

    auto it = xs.begin();

    while (--K)
        ++it;

    return *it;
}

int main()
{
    ios::sync_with_stdio(false);

    int K;
    cin >> K;

    auto ans = solve(K);

    cout << ans << '\n';

    return 0;
}


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

int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if((i+1)%2==1&&s[i]=='L') {printf("No\n");return 0;}
		if((i+1)%2==0&&s[i]=='R') {printf("No\n");return 0;}
	}  
	cout<<"Yes\n";
	return 0;
}


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

namespace id_0217cs
{
    class WalkingPerson
    {
        private int _personNumber;
        private int _walkingDistance;
        public int PersonNumber {  get { return _personNumber; } set { _personNumber = value; } }
        public int WalkingDistance { get { return _walkingDistance; } set { _walkingDistance = value; } }
        public WalkingPerson(int pn, int wd)
        {
            PersonNumber = pn;
            _walkingDistance = wd;
        }
        
    }
    class Program
    {
        static void Main(string[] args)
        {
            while (true) {
                var n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                List<WalkingPerson> walkingPeople = new List<WalkingPerson>();
                foreach (var i in Enumerable.Range(0, n))
                {
                    var vs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                    walkingPeople.Add(new WalkingPerson(vs[0], vs[1] + vs[2]));
                }
                var MaxWalkingDistance = walkingPeople.Max(x => x.WalkingDistance);
                var MaxPerson = walkingPeople.First(x => x.WalkingDistance == MaxWalkingDistance).PersonNumber;
                Console.WriteLine("{0} {1}",MaxPerson,MaxWalkingDistance);
                
            }

        }
    }
}



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

int main(){
  int64_t n;
  cin >> n;
  if(n%2==0){
    cout << n << " " << n << " " << n/2 << endl;
  }else{
    for(int i=1;i<=3500;i++){
      for(int j=1;j<=3500;j++){
        int64_t a=n*i+n*j;
        if(4*i*j>a&&(n*i*j)%(4*i*j-a)==0){
        cout << i << " " << j << " " << (n*i*j)/(4*i*j-a);
        return 0;
        }
      }
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;

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

    ll n, k, x, y, ans = 0;
    cin >> n >> k >> x >> y;

    if(n<=k) cout << n*x;
    else{
        ans = k*x, n -= k;
        cout << ans + n*y;
    }


    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()



def main():
    w,a,b = LI()
    if b < a:
        a,b = b,a
    return max(b-a-w,0)

print(main())


Measured memory_bytes: 5412
#include<stdio.h>

int n, A[50];
int solve(int i, int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res=solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}
int main(void){
    int q,M,i;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2092
num = gets.chomp.to_i
money = 0.0
for i in 1..num
  n = gets.chomp.split
  n[0] = n[0].to_f
  if n[1] == "JPY"
    money += n[0]
  else
    money += (n[0] * 380000.0)
  end
end
puts money

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {


		public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int ans[] = new int[26];
		
		while(scan.hasNext()){
			//??\??????????????±?????????????????¢???????????????????????°????¨??????????
			String moji = scan.nextLine();
			
			moji = moji.toLowerCase();
		
			int moji_len = moji.length();
			
			//??\????????????????????????????????????????????????????????§
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
			
				char moji_one = moji.charAt(cnt_len);
			
				//????????????????????????a~Z??????????????¨?????´????????????????????????
				int num = moji_one - 'a';  // ???????????????
				if(num >= 0 && num <= 26)
					ans[num]++; 
			}
		}
		//???????????¨???
		for(int cnt_arp = 0; cnt_arp < 26; cnt_arp++){
			
			System.out.println((char)(cnt_arp + 'a') + " : " + ans[cnt_arp]);
		}
		//????§????
		scan.close();
	}
}

Measured memory_bytes: 26124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static private long gcdInner(long a, long b) => (a % b == 0) ? b : gcdInner(b, a % b);
    static public long GCD(long a, long b) => (a > b) ? gcdInner(a, b) : gcdInner(b, a);
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();
    
    static void Main()
    {
        int N = Console.ReadLine().ToInt();

        int[] dList = Console.ReadLine().ToIntArray().OrderBy(n => n).ToArray();

        //4;
        //0 1 2 3


        var left = dList[dList.Length / 2 - 1];
        var right = dList[dList.Length / 2];

        Console.WriteLine(right - left);


    }
}

Measured memory_bytes: 23008
<?php
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));

$i = 0;
$b = array();
if($n % 2 == 0){
while($i < $n){
if($i % 2 == 0){
$b[($n / 2) + $i] = $a[$i];
}else{
$b[($n / 2) - $i] = $a[$i];
}
++$i;
}
}else{
while($i < $n){
if($i % 2 == 0){
$b[floor($n / 2) - $i] = $a[$i];
}else{
$b[floor($n / 2) + $i] = $a[$i];
}
++$i;
}
}
ksort($b);
echo implode(" ",$b);

Measured memory_bytes: 63700
# AOJ 2825: Quiz
# Python3 2018.7.12 bal4u

while True:
	N, M = map(int, input().split())
	if N == 0: break
	mi, ma = [0]*N, [0]*N
	for i in range(M):
		a = list(map(int, input().split()))
		S = a.pop(0)
		K = a.pop(0)
		if K == 1:
			mi[a[0]-1] += S
			ma[a[0]-1] += S
		else:
			for j in a: ma[j-1] += S
	vmax = max(ma)
	mi.pop(ma.index(vmax))
	vmin = min(mi)
	print(vmax-vmin+1)


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
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; }
const ll inf = 1ll << 60;



int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    vector<vector<int>> upper(50, vector<int>(100, 0));
    vector<vector<int>> lower(50, vector<int>(100, 1));
    int pointer = 0;
    while(pointer < a-1) {
        lower.at((pointer/50) * 2 + 1).at((pointer%50) * 2) = 0;
        pointer ++;
    }
    pointer = 0;
    while(pointer < b-1) {
        upper.at((pointer/50) * 2).at((pointer%50) * 2) = 1;
        pointer ++;
    }
    printf("%d %d\n", 100, 100);
    rp(i, 0, 50) {
        rp(j, 0, 100) {
            if(upper.at(i).at(j) == 0) printf(".");
            else printf("#");
        }
        printf("\n");
    }
    rp(i, 0, 50) {
        rp(j, 0, 100) {
            if(lower.at(i).at(j) == 0) printf(".");
            else printf("#");
        }
        printf("\n");
    }
    
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



int main() {
	ll N,K;
	cin>>N>>K;
	if(K%2==0){
	ll ans=0;
	ll c1=N/(K/2);
	ll c2=c1-N/K;
	c1=c1-c2;
	ans=c1*c1*c1+c2*c2*c2;
	cout<<ans<<endl;
	}
	else{
		ll ans=0;
		ll c1=N/K;
		ans=c1*c1*c1;
		cout<<ans<<endl;
	}
}


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

const int MAX_N = 100000;

int main() {
  int N, a, odd = 0;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> a;
    if (a & 1) odd++;
  }
  cout << ((odd & 1) ? "NO" : "YES") << endl;
  return 0;
}


Measured memory_bytes: 384
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int gcd(int a, int b){
	if(a==0 || b==0) return a==0?b:a;
	int tmp, r;
	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
	}

	r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main(void){
	int n, i;
	int a[100001];
	int l[100002], r[100002];
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%d", a+i);
	}
	l[0]=0;
	for(i=1; i<=n; i++){
		l[i] = gcd(l[i-1], a[i]);
	}
	r[n+1]=0;
	for(i=n; i>0; i--){
		r[i] = gcd(r[i+1], a[i]);
	}
	int max=0;
	for(i=1; i<=n; i++){
		int now=gcd(l[i-1], r[i+1]);
		if(now>max) max=now;
	}
	printf("%d\n", max);
}


Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

int main(void){
	char name[9][50];
	int num[9][2];
	int a;
	for(a=0;a<9;a++){
		scanf("%s%d%d",name[a],&num[a][0],&num[a][1]);
	}
	for(a=0;a<9;a++){
		printf("%s %d %d\n",name[a],num[a][0]+num[a][1],num[a][0]*200+num[a][1]*300);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

typedef struct point{
 float x;
 float y;
}point;

int main(){
 int n,i;
 point A,B,C,D;
 float m1,m2;
 scanf("%d",&n);
 for(i=0;i<n;i++){

  scanf("%f %f",&A.x,&A.y);
  scanf("%f %f",&B.x,&B.y);
  scanf("%f %f",&C.x,&C.y);
  scanf("%f %f",&D.x,&D.y);

  m1=(A.y-B.y)/(A.x-B.x);
  m2=(C.y-D.y)/(C.x-D.x);

  if(m1==m2)printf("YES\n");
  else printf("NO\n");

 }

 return 0;

}


Measured memory_bytes: 2008
import sys
import math
import numpy as np
import copy

def main():
    n, k, q = [int(t) for t in input().split()]
    dat = [k-q for _ in range(n)]
    for i in range(q):
        a = int(input())
        a -= 1
        dat[a] += 1

    print(*["Yes" if t > 0 else "No" for t in dat], sep="\n")


    return 0

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 18424
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x;
	cin >> n;
	vector<int> a(n);
	rep (i, n) cin >> a[i];
	bool two = false;
	rep (i, n) two |= (a[i] != a[0]);
	if (!two) {
		if (n / a[0] >= 2 || n == a[0] + 1) cout << "Yes\n";
		else cout << "No\n";
	} else {
		bool small = false;
		int p = 0, q = 0;
		rep (i, n) {
			small |= (a[i] < a[0]);
			if (a[i] != a[0]) {
				if (abs(a[i] - a[0]) != 1) {
					cout << "No\n";
					return 0;
				}
			}
		}
		if (small) {
			rep (i, n) {
				if (a[i] < a[0]) p++;
				else q++;
			}
		} else {
			rep (i, n) {
				if (a[i] > a[0]) q++;
				else p++;
			}
		}
		x = a[0] + (!small);
		if (p + 1 <= x && x <= p + (n - p) / 2) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

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

ll sa[101010], sum[101010];

int main() {
    int n;
    cin >> n;
    vector<ll> A(n), B(n);
    rep(i, n) cin >> A[i];
    rep(i, n) cin >> B[i];
    vector<ll> p1, p2;
    rep(i, n) {
        sa[i] = A[i]-B[i];
        if (sa[i] < 0) p1.push_back(-sa[i]);
        else if (sa[i] > 0) p2.push_back(sa[i]);
    }
    sort(p2.rbegin(), p2.rend());
    ll ans = 0;
    for (int i=1; i<=n; ++i) {
        sum[i] = sum[i-1] + sa[i-1];
    }

    if (sum[n] < 0) {
        cout << "-1" << endl;
        return 0;
    }
    if (p1.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    int idx = 0;
    bitset<101010> used;
    rep(i, p1.size()) {
        if (p1[i] <= p2[idx]) {
            p2[idx] -= p1[i];
            used[idx] = 1;
            if (p2[idx] == 0) idx++;
        }
        else {
            int tmp = p1[i] - p2[idx];
            used[idx++] = 1;
            while (tmp > 0) {
                if (tmp <= p2[idx]) {
                    p2[idx] -= tmp;
                    tmp = 0;
                    used[idx] = 1;
                    if (p2[idx] == 0) {
                        idx++;
                    }
                    break;
                }
                else {
                    int tmp2 = tmp - p2[idx];
                    used[idx] = 1;
                    tmp = tmp2;
                    idx++;
                }
            }
        }
    }

    ans = p1.size() + used.count();
    cout << ans << endl;

}


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

const int INF = 1e9;

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

  int ans = INF;
  rep(i, n) {
    int c, t;
    cin >> c >> t;
    if (t <= T) ans = min(ans, c);
  }
  if (ans == INF) cout << "TLE" << endl;
  else cout << ans << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
ll binary_search(ll time, ll f){
    ll ok = 1e9;
    ll ng = -1;
    while(abs(ok-ng)>1){
        ll mid = (ok + ng)/2;
        if(time <= f * mid){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    return f * ok;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int> C(N,0), S(N,0), F(N,0);
    rep(i,N-1){
        cin>>C[i]>>S[i]>>F[i];
    }
    rep(i,N){
        ll ans = S[i] + C[i];
        for(int j = i+1; j < N-1; ++j){
            //cerr<<i<<" "<<j<<" "<<binary_search(ans, F[j])<<endl;;
            if(ans < S[j]){
                ans = S[j]+C[j];
            }
            else{
                ans += binary_search(ans, F[j])-ans + C[j];
            }
            
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int numA[101][101];
int numB[101];
long long int numRes[101];

int main()
{
    int n, m;
    
    cin >> n >> m;
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> numA[i][j];
        }
    }
    
    for (int i = 0; i < m; i++)
    {
        cin >> numB[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            numRes[i] += numA[i][j] * numB[j];
        }
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << numRes[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3132
import java.util.Scanner; // ?????¨?????????????????????

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

        // ????????? sc ??? int ?????¨?????? 1 ?????\???????????????.
        int a[] = new int[3];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();

        // ????????????????????????.
        int nokori = 3;
        int hinan;
        while (nokori > 0) {
            for (int i = 0; i < nokori - 1; i ++) {
                if (a[i] > a[i + 1]) {
                    hinan = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = hinan;
                }
            }
            nokori --;
        }
        System.out.println(a[0] + " " + a[1] + " " + a[2]);
    }
}

Measured memory_bytes: 26096
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int A[N];
	int sum = 0;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	int minsum = (N * (N + 1)) / 2;
	if (sum % minsum != 0) {
		cout << "NO" << endl;
		return 0;
	}
	
	int diff_S = sum / minsum;
	int dicrease = diff_S * N;
	rep(i, N) {
		if (!(diff_S <= A[i] && A[i] <= diff_S * N)) {
			cout << "NO" << endl;
			return 0;
		}
		int diff_A = A[(i + 1) % N] - A[i];
		if ( diff_A == diff_S ) continue;
		// cout << "*" << (diff_S - diff_A) % N << endl;
		if ((diff_S - diff_A) % N != 0) {
			cout << "NO" << endl;
			return 0;
		}
		dicrease += -diff_S + diff_A;
		// cout << dicrease << endl;
	}
	if (dicrease != 0) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

    return 0;
}


Measured memory_bytes: 1024
A, B = map(int, input().split())


def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


A_factor = set(prime_factorization(A))
B_factor = set(prime_factorization(B))
print(len(A_factor & B_factor) + 1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
char a[100010];
int la,i;
int main()
{
	gets(a);
	la=strlen(a);
	for(i=0;i<=la/2;i++)
	{
		int l=i,r=la-i-1;
		if(a[l]=='b' && a[r]=='d' || a[l]=='d' && a[r]=='b' || a[l]=='p' && a[r]=='q' || a[l]=='q' && a[r]=='p');
		else
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int dp[27][12];
vector<string> dpp[27][12];

void solve(int lst,int ps,int n){
  if(ps==n+1) return;
  if(dp[lst][ps]!=-1) return ;
  dp[lst][ps] = 0;
  for(int i=1;i<=min(26,lst+1);i++){
    char h = 'a' + i-1;
    string f = ""; f += h;
    if(ps==n){
      dpp[lst][ps].push_back(f);
      continue;
    }
    solve(lst+(i==(lst+1)),ps+1,n);
    for(auto it:dpp[lst+(i==(lst+1))][ps+1]){
      dpp[lst][ps].push_back(f+it);
    }
  }
  return ;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  memset(dp,-1,sizeof(dp));
  int n;cin >> n;
  solve(0,1,n);
  sort(ALL(dpp[0][1]));
  for(auto it:dpp[0][1]) cout << it << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 28912
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<list>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int A[20], B[20], C[20];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, N)cin >> B[i];
	REP(i, N-1)cin >> C[i];
	int ans = 0;
	REP(i, N - 1) {
		ans += B[i];
		if (A[i + 1] == A[i] + 1) {
			ans += C[A[i]-1];
		}
	}
	ans += B[N - 1];
	print(ans);
}

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

int main() {
  int A;
  cin >> A;
  double B;
  if(A%2 == 0) {
    B =(double)1/2;
    cout << B <<endl;
  }
  else {
    B =(double)(A+1)/(A*2);
    cout << B <<endl;
  }
}


Measured memory_bytes: 256
import heapq

N,M=( int(x) for x in input().split())
A=[int(s)*-1 for s in input().split()]

heapq.heapify(A)

for i in range(M):
    A_max=heapq.heappop(A)*-1
    heapq.heappush(A,(A_max//2)*-1)    
print(sum(A)*-1)


Measured memory_bytes: 14180
import java.util.*;
import java.lang.*;

import static java.lang.StrictMath.abs;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        long min = 0;
        long min2=0;
        long max =0;
        long ans =0;
//        どれかが偶数ならば、０
//        全部奇数ならば、小さいやつ２つの積
        if(a%2==1 && b%2==1 && c%2 == 1){
            min =Math.min(a,b);
            max =Math.max(a,b);
            min2 = Math.min(max, c);
            ans = min* min2;
            System.out.println(ans);
        }else{
            System.out.println(0);
        }





    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	string a;
	int ok=0,sum=0,ans=0;
	cin>>a;
	int al=a.length();
	for(int i=0;i<al;i++)
	{
		if(a[i]=='A') ok=1;
		if(ok) sum++;
		if(a[i]=='Z') ans+=sum,sum=0;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int flag = 0;
    for(int i=0;i<=N/4;i++){
        if(s[i]!=s[N-1-i] || s[i]!=s[N/2-1-i] || s[N/2+1+i]!=s[N-1-i]){
            flag = 1;
            break;
        }
    }
    if(flag==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, D, X;
  cin >> N >> D >> X;
  vector<ll> A(N);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 1; j <= D; j += A[i]) {
      sum++;
    }
  }
  ll ans = sum + X;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>

#define MAX_M 100
#define MAX_N 1000000
#define min(a,b) (a < b ? a : b)

void insertionSort(int*,int,int,int*);
void shellSort(int*,int);
void print(int*,int*,int,int,int);

int main(){
  int n,A[MAX_N],i;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  shellSort(A,n);
  return 0;
}

void insertionSort(int *A,int n,int g,int *cnt){
  int i,j,v;
  for(i = g ; i < n ; i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      (*cnt)++;
    }
    A[j+g] = v;
  }
}

void shellSort(int *A,int n){
  int G[MAX_M],i,m = 1,cnt = 0;
  
  while(m*5+1 < n){ m = m*5+1; }
  for(i = 0 ; m > 0 ; m /= 5,i++){
    G[i] = m;
  }
  m = min(i,MAX_M);
  for(i = 0 ; i < m ; i++){
    insertionSort(A,n,G[i],&cnt);
  }
  print(A,G,n,m,cnt);
}

void print(int *A,int *G,int n,int m,int cnt){
  int i;
  printf("%d\n",m);
  for(i = 0 ; i < m ; i++){
    printf("%d%c",G[i],(i < m-1 ? ' ' : '\n'));
  }
  printf("%d\n",cnt);
  for(i = 0 ; i < n ; i++){
    printf("%d\n",A[i]);
  }
}

Measured memory_bytes: 4504
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D.sort()
T.sort()

flag = True
if N < M:
    flag = False
else:
    i = 0
    for ti in T:
        find = False
        while i < N:
            if ti == D[i]:
                find = True
                i += 1
                break
            else:
                i += 1
        if not find:
            flag = False

if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 35556
#include <cstdio>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    int cc[1000100] = {}, cm[1000100] = {};
    for (int i = 0; i < n; i++) {
        if (i > 0) { cc[i] = cc[i-1]; cm[i] = cm[i-1]; }
        if (s[i] == 'C') cc[i]++;
        else if (s[i] == 'M') cm[i]++;
    }
    // for (int i = 0; i < n; i++) printf("i = %d: cc = %d, cm = %d\n", i, cc[i], cm[i]);
    while (q--) {
        int k; cin >> k;
        long long mc[1000100] = {};
        for (int i = n-1; i >= 0; i--) {
            mc[i] = mc[i+1];
            if (i + k < n && s[i+k] == 'C') mc[i] -= cm[i+k] - cm[i];
            if (s[i] == 'M') mc[i] += cc[min(i+k-1, n-1)] - cc[i];
            // printf("i = %d: mc = %d\n", i, mc[i]);
        }
        long long ans = 0;
        for (int i = 0; i < n-1; i++)
            if (s[i] == 'D') ans += mc[i];
        cout << ans << endl;
    }
}


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

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    //cin >> t;
    for(int T = 0; T < t ; T++){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << max(a*c, max(b*c,max(b*d, a*d))) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
# 累積和(max)
N = int(input())
a = [int(input()) for _ in range(N)]
lcm = a[:]
rcm = a[:]
for i in range(1, N):
  lcm[i] = max(lcm[i], lcm[i - 1])
for i in range(N - 2, -1, -1):
  rcm[i] = max(rcm[i], rcm[i + 1])
print(rcm[1])
for i in range(1, N - 1):
  print(max(lcm[i - 1], rcm[i + 1]))
print(lcm[N - 2])


Measured memory_bytes: 15636
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

void dfs(int x, int y, int th, int amount, map<int, int> &mp) {
	if (mp[amount] == 1)return;
	if (th < amount) {
		return;
	}
	else if (amount <= th) {
		mp[amount] = 1;
	}

	dfs(x, y, th, amount + x, mp);
	dfs(x, y, th, amount + y, mp);
	return;
}

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	map<int, int> water;
	dfs(100 * A, 100 * B, F, 0, water);

	pair<int, int> ans;
	double maxCon = 0;
	for (auto _w : water) {
		if (_w.second == 0)continue;
		double w = _w.first;

		for (double i = 0;; ++i) {
			double _s = C * i;
			for (double j = 0;; ++j) {
				double s = _s + D * j;
				if ((E * w / 100.0) + 1 <= s) {
					break;
				}
				if (w + s <= F && maxCon < 100.0 * s / (w + s)) {
					ans = make_pair((int)w + s, (int)s);
					maxCon = 100.0 * s / (w + s);
				}
			}
			if ((E * w / 100.0) + 1 <= _s) {
				break;
			}
		}

	}

	if (ans.first == 0 && ans.second == 0) {
		for (auto x : water) {
			if (x.first != 0) {
				cout << x.first << " " << 0 << endl;
				return 0;
			}
		}
	}
	cout << ans.first << " " << ans.second << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef tuple<int, int, int> tp;
typedef pair<int, int> pi;
typedef vector<vector<int> > vv;
///-------------------------
const int MAXN = 1e5;
int cha[MAXN + 5];

void init(int n){
    for(int i=0; i<n; ++i){
        cha[i] = i;
    }
}

int Find(int x){
    return (cha[x] = (cha[x] == x ? x : Find(cha[x])));
}

int main()
{
    Phuong_; /// <3333
    int n,m;
    cin >> n >> m;
    init(n);
    while(m--){
        int u,v;
        cin >> u >> v;
        u--;
        v--;
        int x = Find(u);
        int y = Find(v);
        if (x==y) continue;
        cha[x] = y;
    }
    int ans =0;
    for(int i=0; i<n; ++i){
        if (i==cha[i]) ans ++;
    }
    cout << ans-1 << '\n';
    return 0;
}


Measured memory_bytes: 4040
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, M, ans;
vector <int> Graph[8];
bool visited[8];

int DFS(int Node, int turn){
  if (turn == N - 1){
    ans++; return 0;
  }

  for (int i = 0; i < Graph[Node].size(); i++){
    int next = Graph[Node][i];
    if (!visited[next]){
      visited[next] = true;
      DFS(next, turn + 1);
      visited[next] = false;
    }
  }
  return 0;
}

int main(){
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    A--; B--;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }
  visited[0] = true;
  DFS(0, 0);
  cout << ans << endl;
  
  return 0;
}


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

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			List<string> resultList = new List<string> ();

			string input;
			while((input = Console.ReadLine()) != null){
				resultList.Add (Classification(double.Parse(input)));
			}

			foreach(string s in resultList){
				Console.WriteLine (s);
			}

		}

		static string Classification(double weight){
			if (weight <= 48)
				return "light fly";
			else if (weight <= 51)
				return "fly";
			else if (weight <= 54)
				return "bantam";
			else if (weight <= 57)
				return "feather";
			else if (weight <= 60)
				return "light";
			else if (weight <= 64)
				return "light welter";
			else if (weight <= 69)
				return "welter";
			else if (weight <= 75)
				return "light middle";
			else if (weight <= 81)
				return "middle";
			else if (weight <= 91)
				return "light heavy";
			else
				return "heavy";
		}
	}














}

Measured memory_bytes: 5740