akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())

def check(h, w):
	if h % 3 == 0 or w % 3 == 0:
		return 0

	else:
		block1 = w * (h // 3)
		block2 = (h - (h // 3)) * (w // 2)
		block3 = h * w - block1 - block2
		gap1 = max(block1, block2, block3) - min(block1, block2, block3)

		block4 = w * (h // 3 + 1)
		block5 = (h - 1 - (h // 3)) * (w // 2)
		block6 = h * w - block4 - block5
		gap2 = max(block4, block5, block6) - min(block4, block5, block6)

		return(min(gap1, gap2, min(w, h)))

print(min(check(H, W), check(W, H)))

Measured memory_bytes: 3064
n,q = map(int,input().split())
v = [[0,0] for i in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    v[a].append(b)
    v[b].append(a)
for i in range(q):
    p,x = map(int,input().split())
    v[p][1] += x
q = [1]
while q:
    now = q.pop()
    v[now][0] = 1
    for i in v[now][2:]:
        if v[i][0] == 0:
            v[i][1] += v[now][1]
            q.append(i)
s = []
for i in v:
    s.append(i[1])
print(*s[1:])

Measured memory_bytes: 122992
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		while(scan.hasNext()){
			int x=scan.nextInt();
			
			ArrayList<Integer> list=new ArrayList<Integer>();
			long sum=0;
			for (int i = 0; i < x; i++) {
				int n=scan.nextInt();
				sum +=n;
				list.add(n);
			}
			
			System.out.println(Collections.min(list)+" "+Collections.max(list)+" "+sum);
		}
	}

}

Measured memory_bytes: 32916
import math

N,K = map(int,input().split())
ans = 0

for i in range(1,N+1):
    if i > K:
        x = 0
    else:
        x = math.log2(K)-math.log2(i)
        x = int(x) if x.is_integer() else int(x) + 1
    ans += (1/N) * pow(1/2,x)
print(ans)

Measured memory_bytes: 3060
function Main(s) {
	s = s.split("\n");
	s[0] = s[0].split(" ").map(a => parseInt(a));
	var a = s[1] = s[1].split(" ").map(a => parseInt(a));
	const n = s[0][0];
	const x = s[0][1];
	var ans = 0;
	if(a[0] > x){
		ans += a[0] - x;
		a[0] = x;
	}
	for(var i = 1; i < n; i++){
		if(a[i-1] + a[i] > x){
			ans += a[i-1] + a[i] - x;
			a[i] = x - a[i-1];
		}
	}
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17804
#include <bits/stdc++.h>
using namespace std;
//define
#define itn int //for int typo error
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto&a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second
//typedef
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;
typedef pair<int, int> pii;
inline int rint(){int x; scanf("%d", &x); return x;}
//can modify here
const ll mod = 1000000007;
//don't ever modify here, a^b % mod function, extended euclid algo, gcd
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll eea(ll a, ll b, ll &x, ll &y){if(!b){x=1,y=0;return a;} ll x1,y1; ll d = eea(b,a%b,x1,y1);x=y1;y=x1-(ll)(a/b)*y1;return d;}
ll gcd(ll a, ll b){ll x; ll y; return eea(a,b,x,y);}




//code here
void solve()
{
    ll n, temp;
    cin >> n;
    ll ans = 0;
    if(n == 2)
    {
        cout << 1;
        return;
    }
    for(ll i = 2; i*i <= n-1; i++)
    {
        if((n-1)%i == 0)
        {
            ans++;
            if(i*i != n-1)ans++;
        }
    }
    ans++;
    for(ll i = 2; i*i <= n; i++)
    {
        if(n%i == 0)
        {
            temp = n;
            while(temp%i == 0)temp/=i;
            if(temp%i == 1)ans++;
            if(i*i != n)
            {
                temp = n;
                ll f = n/i;
                while(temp%f == 0)temp/=f;
                if(temp%f==1)ans++;
            }
        }
    }
    ans++;
    cout << ans;
}


int main() {
    //For faster IO, comment out for interative problems
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	solve();
	return 0;
}


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

const char SHCD[] = "SHCD";

int main() {
    long long bitvector[4] = {1, 1, 1, 1};
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        char suit; cin >> suit;
        int  rank; cin >> rank;
        for (int j = 0; j < 4; j++) {
            if (suit == SHCD[j]) {
                bitvector[j] |= 1 << rank;
            }
        }
    }
    for (int j = 0; j < 4; j++) {
        for (int k = 1; k <= 13; k++) {
            if ((bitvector[j] >> k & 1) == 0) {
                cout << SHCD[j] << " " << k << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#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; }
typedef long long int64;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

int64 gcd ( int64 a, int64 b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
int64 lcm ( int64 a, int64 b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int64 N, K; std::cin >> N >> K;
  std::vector<int64> A(N); rep(i,N) std::cin >> A[i];

  std::sort( all(A) );
  //rep(i,N) std::cout << A[i] << std::endl;

  auto intceil = [] (int64 a, int64 b) -> int64 {
    if ( a>=0 ) return (a+b-1)/b;
    else return a/b;
  };
  auto intfloor = [] (int64 a, int64 b) -> int64 {
    if ( a<0 ) return (a-b+1)/b;
    else return a/b;
  };

  int64 left = -(1LL<<62);
  int64 right = (1LL<<62);
  while(left < right-1) {
    int64 threshold = (left + right)/2;
    int64 cnt = 0;
    rep(i, N) {
      if (A[i] < 0) {
        int64 v = intceil(-threshold, -A[i]);
        cnt += A.begin() + i - std::lower_bound(A.begin(), A.begin() + i, v);
      }
      else if (A[i] == 0) {
        if (threshold >= 0) cnt += i;
      }
      else {
        int64 v = intfloor(threshold, A[i]);
        cnt += std::upper_bound(A.begin(), A.begin() + i, v) - A.begin();
      }
    }
    if ( cnt < K ) left = threshold;
    else right = threshold;
    //std::cout << "Search : " << left << " " << right << " : " << cnt << std::endl;
  }
  std::cout << right << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
abcd = [0] * q
for i in range(q):
    abcd[i] = list(map(int, input().split()))
# print(0)
# comb = [1] * n + [0] * (m - 1)
# combination_all = set(itertools.permutations(comb))  # 5!通り出力する
cmb = combinations_with_replacement([i for i in range(1, m + 1)], n)
all_array = list(cmb)
"""for i in combination_all:
    tmp = 1
    lis = []
    for j in range(len(i)):
        if i[j]:
            lis.append(tmp)
        else:
            tmp += 1
    all_array.append(lis)"""
# print(all_array)
ans = 0  # maxをとる
for arr in all_array:
    val = 0
    for j in range(q):
        if arr[abcd[j][1] - 1] - arr[abcd[j][0] - 1] == abcd[j][2]:
            val += abcd[j][3]
    ans = max(ans, val)
print(ans)
# bit 全探索で i が成り立つと仮定する
# 連結する奴の中で最大と最小の差がN-1以下なら成立
"""ans = 0

for i in range(2**n):
    score = 0
    emerge = []
    lis = []
    for j in range(n):
        if i>>j & j:
            if a[i] in emerge:"""


Measured memory_bytes: 21560
import java.util.*;
import java.io.*;

public class Main {
 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int result = 0;
        for (int i = 1; i <= n; i += 2) {
            int count = 0;
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    count++;
                }
            }
            if (count == 8) result++;
        }         
        System.out.println(result);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    
    public boolean hasNext() { 
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string a;
  cin>>a;
	int b=0;
	int c=0;
	for(int i=0;i<a.size();i++){
	if(a.at(i)=='A'||a.at(i)=='C'||a.at(i)=='G'||a.at(i)=='T'){
		b++;
}
	else
		b=0;
	if (b>c)
	c=b;
	}
	cout<<c;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	REPC(&i, s)if (i == ',')i = ' ';
	cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N, T;
	cin >> N >> T;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<Int> mx(N);//mx[i]:i～N-1までの最大値
	Int temp=-INF;
	for (Int i = N - 1; i >= 0; i--) {
		if (temp<a[i]) {
			temp = a[i];
			mx[i] = temp;
		}
		else {
			mx[i] = temp;
		}
	}

	vector<Int> diff(N - 1);
	for (Int i = 0; i < N-1; i++) {
		diff[i] = mx[i + 1] - a[i];
	}
	sort(diff.begin(), diff.end(), greater<Int>());

	temp = diff[0];
	Int cnt = 1;
	for (Int i = 1; i < N-1; i++) {
		if (diff[i]==temp) {
			cnt++;
		}
		else {
			break;
		}
	}
	cout << cnt << "\n";
}


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

int main(){
  int N;
  string A,B,C;
  cin >> N >> A >> B >> C;

  int ans=0;
  for(int i=0;i<N;i++){
    if(A.at(i)==B.at(i) && B.at(i)==C.at(i)) continue;
    if(A.at(i)==B.at(i) || B.at(i)==C.at(i) || C.at(i)==A.at(i))  ans++;
    else  ans+=2;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#define llint long long

using namespace std;

int n;
double x[10], y[10];

double dist(int p, int q)
{
  return sqrt((x[p]-x[q])*(x[p]-x[q]) + (y[p]-y[q])*(y[p]-y[q]));
}

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

  cin >> n;
  for(int i = 0; i < n; i++) cin >> x[i] >> y[i];

  int perm[10];
  for(int i = 0; i < n; i++) perm[i] = i;
  double ans = 0;
  do{
    for(int i = 0; i < n-1; i++){
      ans += dist(perm[i], perm[i+1]);
    }
  }while(next_permutation(perm, perm+n));

  llint fact = 1;
  for(int i = 1; i <= n; i++) fact *= i;
  ans /= fact;

  printf("%.11f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,i;
    cin >> N >> i;
    cout << N-i+1 << endl;



}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define lim 100010
#include <stdbool.h>

int max(int x, int y){return x<y?y:x;}
int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	char S[lim];
	scanf("%s",S);
	int one[lim]={0,1};
	int c=1;
	char p=S[0];
	for(int i=1;i<n;i++){
		if(S[i]==p)one[c]++;
		else{
			c++;
			p=S[i];
			one[c]=1;
		}
	}
	
	int ans=0,tmp=0;
	int num=0;
	int head=0;
	bool ok=true;
	for(int i=0;i<=c+1;i++){
		if(i==2){
			if(S[0]=='1')ok=true;
			else ok=false;
		}
		ok=!ok;
		if(num<2*k+1){
			tmp += one[i];
			num++;
			ans = max(ans,tmp);
		}else{
			tmp -= one[head++];
			tmp += one[i];
			if(ok)ans = max(ans,tmp);
		}
	}
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool isok = true;
    if(n%2!=0){
        isok = false;
    }else{
        if(s.substr(0,n/2) != s.substr(n/2, n/2)) isok = false;
    }
    if(isok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

import decimal

def main():
    tax = decimal.Decimal('1.08')
    n = int(input())

    for i in range(1,n+1):
        if int(i*tax)==n:
            print(i)
            exit()
        else:
            continue
    print(":(")

if __name__=="__main__":
    main()

Measured memory_bytes: 9892
import sys

printf = sys.stdout.write


abc = []
ans = [0 for i in range(26)]

for i in range(26):
    abc.append(str(chr(i + 97)))


word = []
for line in sys.stdin:
    word.append(line)

for i in range(len(word)):
    for j in range(len(word[i])):
        for k in range(29):
            if (k + 65) == ord(word[i][j]) or (k + 97) == ord(word[i][j]): 
                ans[k] += 1

for i in range(26):
    printf(abc[i] + " : " + str(ans[i]) + "\n")

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

namespace a
{
    class Pg
    {
        static void Main()
        {
            string line;
            for (int counter = 0; (line = Console.ReadLine()) != "0 0"; counter++)
            {
                if (counter != 0)
                {
                    Console.WriteLine();
                }
                var Leap = new List<string>();
                var Year = line.Split().Select(int.Parse).ToArray();
                for (int i = Year[0]; i <= Year[1]; ++i)
                {
                    if (DateTime.IsLeapYear(i))
                    {
                        Leap.Add(i.ToString());
                    }
                }
                Console.WriteLine(Leap.Count==0? "NA": string.Join("\n", Leap));
            }
        }
    }
}


Measured memory_bytes: 16356
N = int(input())

T , A = map(int,input().split())


for i in range(N-1):

    NT,NA = map(int,input().split())

    if T // NT > A // NA and T % NT == 0:

        n = T // NT
        #print ("ばあい１")

    elif T // NT < A // NA and A % NA == 0:

        n = A // NA
        #print ("ばあい２",A,NA)

    elif T // NT == A // NA and T % NT == 0 and A % NA == 0:

        n = T // NT
        #print ("ばあい３")

    else:

        n = max( T // NT , A // NA ) + 1
        #print ("ばあい４")

    T = n * NT
    A = n * NA

    #print (n)
    #print (T,A)

print (T+A)


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

class Program
{
    static void Main()
    {
        for (int I = 1; I <= 9; I++) {
            for (int J = 1; J <= 9; J++) {
                Console.WriteLine("{0}x{1}={2}", I, J, I * J);
            }
        }
    }
}

Measured memory_bytes: 5536
#include <stdio.h>

int main(){

int a,b,c,d;

scanf("%d %d %d",&a,&b,&c);

if (a>b){

d=a;

a=b;

b=d;

} //a<bになる

if (b>c){

d=b;

b=c;

c=d;

} //b<cになる

if (a>b){

d=a;

a=b;

b=d;

} //a<bになる

printf("%d %d %d\n",a,b,c);

return 0;

}

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


int main(){
    int n; cin>> n;
    vector<ll> a(100000);
    set<ll> memo;
    
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(memo.count(a[i])){
            memo.erase(a[i]);
        }else{
            memo.insert(a[i]);
        }
    }
    int ans = memo.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8696
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define pb push_back
typedef pair<ll,ll> pp;

ll mod = 1e9+7;
ll INF = 1e15;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

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





void solve()
{
  int n,k;
  cin>>n>>k;
  int freq[n+1] = {0};
  while(k--)
  {
    int x;
    cin>>x;
    while(x--)
    {
      int y;
      cin>>y;
      freq[y]++;
    }
  }
  int ans = 0;

  for(int i = 1;i<=n;i++)
  {
    if(!freq[i])ans++;
  }

cout<<ans<<"\n";

}



int main()
{
  int tc;
  // cin>>tc;
  tc = 1;
  while(tc--)
  {
    solve();
  }
}


Measured memory_bytes: 3576
using System;
using System.Linq;

namespace ConsoleApp1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();

            double tempAns = 0;

            foreach (var item in arr)
            {
                tempAns = tempAns + 1 / item;
            }

            tempAns = 1 / tempAns;

            Console.WriteLine(tempAns);
        }
    }
}

Measured memory_bytes: 13268
N = int(input())
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(N // 2) :
  cnt = len(list(filter(lambda x : x <= D[N // 2 - 1 + i], D)))
  if(cnt == N // 2) :
    ans += D[N // 2] - D[N // 2 - 1]
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)

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

def kitaichi(an,ad):
	c=0
	if ad==0:
		c=an*1.0
	elif an - ad>0:
		c=(an-ad)*2.0
	elif an == 0:
		return 0
	else:
		c=0
			
	return c/(an**2)


# スペース区切りの整数の入力
n, m, d = map(int, raw_input().split())
print kitaichi(n,d)*(m-1)




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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
			double[] value= Console.ReadLine() 
               .Split(' ')                     
               .Select(x => double.Parse(x)) 
               .ToArray();

            double buffer = 0.5;

           　Console.WriteLine(Convert.ToInt32(Math.Floor((value[2]+ buffer) /value[0]))*value[1]);

        }
    }
}

Measured memory_bytes: 13396
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll n,chk,a,b;
void solve()
{
    cin>>n;string s;cin>>s;
    ans=1;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])  
            ans++;
    }
    cout<<ans<<endl;
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < k; ++i) ans += a[i];
	cout << ans;

	return 0;
}


Measured memory_bytes: 3632
package main

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

func main() {
	const S = "HEISEI"
	io := NewIo()
	defer io.Flush()
	for io.Next() == S {
		y, m, d := io.NextInt(), io.NextInt(), io.NextInt()
		if y > 31 || y == 31 && m > 4 {
			io.Println("?", y-30, m, d)
		} else {
			io.Println(S, y, m, d)
		}
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



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

long long n, m = 0;
long long c[200000], y[200001];
const long long M = 1000000007;

int main()
{
    cin >> n;

    y[0] = 1;
    for (int i = 0; i < n; i++)
        y[i + 1] = y[i] * 4 % M;

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

    sort(c, c + n);

    if (n > 1) {
        for (int i = 0; i < n; i++)
            m = (m + ((n - i + 1) * y[n - 1] % M) * c[i]) % M;
    }
    else
        m = 2 * c[0] % M;
 
    cout << m << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int k[10000];

int main()
{

	int N, cnt, same, Not;

	while( 1 ) {

		cnt = 0;
		same = 0;
		Not = 0;

		for( int i = 0; i < 10000; i++ ) k[i] = 0;

	 	scanf( "%d", &N );
		if( N == 0 ) break;
		for( int i = 0; i < N; i++ ) {

			scanf( "%d", &k[i] );
			if( k[i] > 1 ) same++;
			else if( k[i] == 0 ) Not++;

		}

		if( N == 1 && k[0] >= 2 ) {
			printf( "2\n" );
			continue;
		}
		else if( same == 0 ) {
			printf( "NA\n" );
			continue;
		}

		printf( "%d\n", N + 1 - Not );

	}

	return 0;

}

Measured memory_bytes: 1076
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> S(N);
    vector<int> T(M);
    for (int i = 0; i < N; i++) cin >> S[i];
    for (int i = 0; i < M; i++) cin >> T[i];

    vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));
    vector<vector<int>> sum(N + 1, vector<int>(M + 1, 0));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            int tmp = 0;
            if (i >= 1) (tmp += sum[i-1][j]) %= MOD;
            if (j >= 1) (tmp += sum[i][j-1]) %= MOD;
            if (i >= 1 && j >= 1) {
                tmp -= sum[i-1][j-1];
                tmp = (tmp + MOD) % MOD;
            }
            (tmp += dp[i][j]) %= MOD;
            sum[i][j] = tmp;

            if (S[i] == T[j]) dp[i+1][j+1] = (tmp + 1) % MOD;
            else dp[i+1][j+1] = 0;
        }
    }

    int ret = 1;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            (ret += dp[i][j]) %= MOD;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 62976
N, L = map(int, input().split())
aji = []
for i in range(1, N+1):
    aji.append(L + i - 1)
aji.sort
if L < 0 and L+N-1 < 0:
    print(sum(aji[:len(aji)-1]))
elif L > 0:
    print(sum(aji[1:]))
else:
    print(sum(aji[:]))


Measured memory_bytes: 3060
import math
a, b, x = map(int, input().split())
h=x/(a**2)
if h<b/2:
    y=2*a*h/b
    shita=math.degrees(math.atan2(b,y))
if h>=b/2:
    y=2*h-b
    t=b-y
    shita=math.degrees(math.atan2(t,a))
print(shita)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int H, W;
    cin >> H >> W;
    vector<string> v(H);
    for (int i = 0; i < H; i++) cin >> v[i];
    vector<int> delRow(H), delCol(W);

    for (int i = 0; i < H; i++) {
        bool isWhite = true;
        for (int j = 0; j < W; j++) if (v[i][j] == '#') isWhite = false;
        if (isWhite) delRow[i] = 1;
    }
    for (int i = 0; i < W; i++) {
        bool isWhite = true;
        for (int j = 0; j < H; j++) if (v[j][i] == '#') isWhite = false;
        if (isWhite) delCol[i] = 1;
    }

    for (int i = 0; i < H; i++) {
        if (delRow[i]) continue;
        for (int j = 0; j < W; j++) {
            if (!delCol[j]) cout << v[i][j];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7
    
    N,M,C = LMIIS()
    B = LMIIS()
    A = [LMIIS() for _ in range(N)]

    ans = 0
    for i in range(N):
        dot = C
        for a,b in zip(A[i],B):
            dot += a*b
        if dot > 0:
            ans += 1
    print(ans)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 64876
import java.util.Scanner;

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

		int x = sc.nextInt(), y = sc.nextInt(), z = sc.nextInt();

		int t = 0;

		if (y < z && y + x > z)
		{
			System.out.println(0);
			return;
		}
		else
		{
			t = Math.min(Math.abs(z - y), Math.abs(z - (y + x)));
		}

		if (y < z + x && y + x > z + x)
		{
			System.out.println(0);
			return;
		}
		else
		{
			t = Math.min(Math.min(Math.abs(y - (z + x)), Math.abs(y + x - (z + x))), t);
		}

		System.out.println(t);
	}
}


Measured memory_bytes: 21588
s = "0" + input()
n = len(s)
S = []
for i in range(n-1,-1,-1):
    S.append(int(s[i]))

ans = sum(S)
ans0 = ans
D = [[0] * 3 for i in range(n)]
D[0] = [S[0], S[0]+1, 10-S[0]]
for i in range(1, n):
    D[i][0] = min(D[i-1][0], D[i-1][1]) + S[i]
    D[i][1] = D[i-1][2] + S[i] + 1
    D[i][2] = min(D[i-1][0]+10-S[i], D[i-1][1]+10-S[i], D[i-1][2]+9-S[i])

# print(D)
print(min(D[-1][:2]))


Measured memory_bytes: 223248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Player : IComparable
    {
        internal int id, point;

        public Player(int id, int point)
        {
            this.id = id;
            this.point = point;
        }

        public override string ToString()
        {
            return id + " " + point;
        }

        public int CompareTo(object obj)
        {
            Player other = (Player)obj;

            if (point == other.point)
            {
                return id - other.id;
            }
            return other.point - point;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Player[] players = new Player[n];

                for (int i = 0; i < n; i++)
                {
                    int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                    var query = input.Skip(1).ToArray();

                    int point = CalcPoint(query);

                    players[i] = new Player(input[0], point);
                }

                Array.Sort(players);

                foreach (var p in players)
                {
                    sb.AppendLine(p.ToString());
                }
            }
            Console.Write(sb);
        }

        static int CalcPoint(int[] arr)
        {
            int ret = 0, idx = 0;

            for (int game = 1; game < 10; game++)
            {
                if (arr[idx] == 10)
                {
                    ret += (arr[idx] + arr[idx + 1] + arr[idx + 2]);
                    idx++;
                }
                else
                {
                    int temp = arr[idx] + arr[idx + 1];

                    if (temp == 10)
                    {
                        ret += (temp + arr[idx + 2]);
                    }
                    else
                    {
                        ret += temp;
                    }
                    idx += 2;
                }
            }

            for (int i = idx; i < arr.Length; i++)
            {
                ret += arr[i];
            }
            return ret;
        }
    }
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    bool ans=true;
   ll n;
   cin>>n;
   vll h(n+1);
   rep(i,n)cin>>h.at(i+1);
   if(n==1)cout<<"Yes"<<endl;
   else{
   rep(i,n-1){
       if(h.at(n-i)>=h.at(n-i-1));
       else if(h.at(n-i)==h.at(n-i-1)-1)h.at(n-i-1)-=1;
       else{
          ans=false; 
          break; 
       } 
   }
   if(ans)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   }
}
   



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	long long n;
	std::cin >> n;
	std::string ans;
	while(n > 0) {
		ans += char('a' + (n-1) % 26);
		n = (n - 1) / 26;
	}
	std::reverse(ans.begin(), ans.end());
	std::cout << ans << '\n';
}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;

  vector<int> d(N);
  for(int i=0;i<N;i++)cin>>d[i];
  //for(int i=0;i<N;i++)cout<<d[i]<<' ';

  set<int> ans;
  for(int i=0;i<N;i++)ans.insert(d[i]);

  cout<<ans.size()<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    int N;
    cin >> N;
    vector<pair<int, int> > pairs;
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        pairs.push_back(make_pair(A, B));
    }    

    sort(pairs.begin(), pairs.end(), compare_by_b);

    long long t = 0;
    for (int i = 0; i < N; i++) {
        // cout << pairs[i].first << " "<< pairs[i].second << endl;
        pair<int ,int> p = pairs[i];
        t += p.first;
        if (t > p.second) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int x = input[0];
		int y = input[1];
		string ans = "No";
		List<int> a = new List<int>{ 1, 3, 5, 7, 8, 10, 12 };
		List<int> b = new List<int>{ 4, 6, 9, 11 };
		List<int> c = new List<int>{ 2 };
		if ((a.Contains(x) && a.Contains(y))||(b.Contains(x)&&b.Contains(y))||(c.Contains(x)&&c.Contains(y)))
            { ans = "Yes"; }
		Console.WriteLine(ans);
	}
}

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

using namespace std;

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

    vector <int> position(no_of_students + 1, 0);
    for(int i = 1; i <= no_of_students; i++)
        cin >> position[i];

    vector <int> correct_order(no_of_students + 1, 0);
    for(int i = 1; i <= no_of_students; i++)
        correct_order[position[i]] = i;

    for(int i = 1; i <= no_of_students; i++)
        cout << correct_order[i] << " ";

    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
//    cin >> A[i];
  int a ;
  cin >> a;
  if(a % 2 == 0)
{
  if(a % 3 != 0 && a % 5 != 0){
    cout << "DENIED" << endl;
    return 0;
  }
}
  }
cout << "APPROVED" << endl;
return 0;
}


Measured memory_bytes: 256
import sys
n, y = map(int, input().split())

max_yukiti = y // 10000
flag = False
for i in range(max_yukiti + 1):
    for j in range(n+1):
        k = n - i - j
        # print(i,j,k)
        if k < 0:
            break
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i,j,k)
            sys.exit()
if ~flag:
    print(-1,-1,-1)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int K = in.nextInt();
        String S = in.next();

        String st = "1";
        String fin = "1_";
        StringBuilder buf = new StringBuilder();
        buf.append(st);
        buf.append(S);
        buf.append(fin);
        S = buf.toString();

        int s1[] = new int[N];
        int f1[] = new int[N];
        int fi = 0;
        int si = 1;
        int cou = 0;

        loop:while(true){
            while(S.charAt(cou) == "1".charAt(0)){
                cou++;
                if(S.charAt(cou) == "_".charAt(0)){
                    f1[fi] = cou-1;
                    break loop;
                }
            }
            f1[fi] = cou-1;
            fi++;
            while(S.charAt(cou) == "0".charAt(0)){
                cou++;
            }
            s1[si] = cou-1;
            si++;
        }
        f1[fi]--;

        if(K >= si-1){
            out.println(S.length()-3);
        } else {
            int max = 0;
            for(int i=0; i<=si-1 - K + 1; i++){
                max = Math.max(max, f1[K+i]-s1[i]);
            }
            out.println(max);
        }

    }

}
}



Measured memory_bytes: 26172
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

sys.setrecursionlimit(1000000)
dire, dire8 = [[1, 0], [0, 1], [-1, 0], [0, -1]], [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets, ALPHABETS = "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD, INF = 1000000007, float("inf")

def main():
    N, M = LI()
    SC = LIR(M)

    if N == 1:
        for i in range(0, 10):
            string = str(i)
            for s, c in SC:
                if int(string[s-1]) != c:
                    break
            else:
                print(i)
                break
        else:
            print(-1)
        return

    for i in range(10 ** (N-1), 10 ** N):
        string = str(i)
        for s, c in SC:
            if int(string[s-1]) != c:
                break
        else:
            print(i)
            break
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 77156
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する.
// yutaka1999氏
// https://atcoder.jp/contests/agc008/submissions/1041743
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    LL a, b, c, d, e, f, g;
    scanf("%lld %lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f, &g);
    LL ret = (a / 2) * 2LL + (d / 2) * 2LL + (e / 2) * 2LL;
    if(a >= 1 && d >= 1 && e >= 1) ret = max(ret, 3LL +((a - 1) / 2) * 2LL + ((d - 1) / 2) * 2LL + ((e - 1) / 2) * 2LL);
    printf("%lld\n", ret + b);
    return 0;
}

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

int main() {

	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int ax, ay, bx, by;
	ax= x2 - x1;
	ay= y2 - y1;
	bx = -ay;
	by = ax;
	int x3, y3, x4, y4;
	x3 = x2 + bx;
	y3 = y2 + by;
	x4 = x1 + bx;
	y4 = y1 + by;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#define INF 1000000
#define NIL -2
#define GRAY -3
#define WHITE -4
#define BRACK -5

using namespace std;

int n;
int M[101][101];
int d[101];//重み
//int p[101];//親
int color[101];

void Dijkstra(int u) {
	//cout << u << endl;
	color[u] = BRACK;

	//重みの更新
	for (int i = 1; i <= n; i++) {
		if (color[i] != BRACK && M[u][i] != 0) {
			color[i] = GRAY;
			if ((d[u] + M[u][i]) < d[i]) {
				d[i] = d[u] + M[u][i];
			}
		}
		//cout << d[i] << " ";
	}

	//cout << endl;

	int min = -1;
	d[min] = 100000;


	for (int v = 1; v <= n; v++) {
		if (color[v] != BRACK) {
			if (d[v] < d[min]) {
				min = v;
			}
			else {
				color[v] = WHITE;
			}
		}
	}

	if (min != -1) {
		Dijkstra(min);
	}
}

int main() {
	cin >> n;
	int v, k, g, weight; //v = 節点番号　g = 次数

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			M[i][j] = 0;
		}
	}

	for (int i = 1; i <= n; i++) {
		cin >> v >> g;
		for (int j = 1; j <= g; j++) {
			cin >> k;
			M[i][k] = 1;
		}
	}

	for (int i = 1; i <= n; i++) {
		color[i] = WHITE;
	}

	for (int i = 1; i <= n; i++) {
		d[i] = INF;
		//cout << d[i] << " ";
	}

	d[1] = 0;


	//関数
	Dijkstra(1);


	for (int i = 1; i <= n; i++) {
		if (d[i] == INF) {
			d[i] = -1;
		}
		cout << i << " " << d[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3120
S = input()

candidates = ["dream", "dreamer", "erase", "eraser"]

find_flag = 0
rest_S = S
while True:
#     print(rest_S[-5:], rest_S[-7:]) 
    if len(rest_S) == 0:
        find_flag = 1
        break
    elif (len(rest_S) >= 7) & (rest_S[-7:] in candidates):
        rest_S = rest_S[:-7]
    elif (len(rest_S) >= 6) & (rest_S[-6:] in candidates):
        rest_S = rest_S[:-6]
    elif (len(rest_S) >= 5) & (rest_S[-5:] in candidates):
        rest_S = rest_S[:-5]
    else:
        break

if find_flag:
    print("YES")
else:
    print("NO")

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

using namespace std;

const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;

int n, m;
char mat[MAXN][MAXN];
long long int DP[MAXN][MAXN];
bool bio[MAXN][MAXN];

long long int rek(int x, int y)
{
	if(bio[x][y])
		return DP[x][y];
	if(mat[x][y] == '#')
		return 0;
	if(x != 0)
		DP[x][y] += rek(x - 1, y);
	if(y != 0)
		DP[x][y] += rek(x, y - 1);
	bio[x][y] = true;
	return DP[x][y] = DP[x][y] % MOD;
}

int main()
{
	memset(bio, false, sizeof(bio));
	memset(DP, 0, sizeof(DP));
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> mat[i];
	DP[0][0] = mat[0][0] == '.' ? 1 : 0;
	cout << rek(n - 1, m - 1);	
	return 0;
}


Measured memory_bytes: 10240
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  set<string> st;
  ll n;
  cin >> n;
  for(ll i = 0; i < n; i++) {
    string x;
    cin >> x;
    st.insert(x);
  }
  cout << st.size() << endl;
  return 0;
} //good night.

Measured memory_bytes: 19244