akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc045/tasks/abc045_b
S_ABC = []
for _ in ra(3):
    S_ABC.append(deque(read()[:-1]))

now = 'a'
while len(S_ABC[ord(now) - ord('a')]):
    now = S_ABC[ord(now) - ord('a')].popleft()
print(now.upper())


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

int main(){
  string masu;
  int ans = 0;
  cin >> masu;
  for(int i = 0; i < 3; i++){
    if(masu[i] == '1') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
		int a=0,b=0,c=0,d=0;
		string s;
		cin>>s;
		for(int i=0;i<s.size();i++){
			if(s[i]=='N')a=1;
			if(s[i]=='W')b=1;
			if(s[i]=='S')c=1;
			if(s[i]=='E')d=1;
		}
		if(a==c&&b==d)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int N, i;
int A[200000];
long long int ans;

int main(){
  scanf("%d", &N);
  for(i=0; i<N; i++){
    scanf("%d", A+i);
  }
  if(A[0] != 0){
    printf("-1\n");
    return 0;
  }
  for(i=0; i<N-1; i++){
    if(A[i]+1 < A[i+1]){
      printf("-1\n");
      return 0;
    }
  }
  for(i=1; i<N; i++){
    if(A[i-1]+1 == A[i]){
      ans++;
    }else{
      ans += A[i];
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 896
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int K = sc.nextInt();
		// スペース区切りの整数の入力
		int X = sc.nextInt();
	if(K*500>=X){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    }
}

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

using namespace std;

using ll = long long;



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int K;
    cin >> K;
    int n = s.size();
    if (n == 1) {
        cout << K / 2 << "\n";
        return 0;
    }

    if (K < 4) {
        string s2 = "";
        for (int i = 0; i < K; i++) {
            s2 += s;
        }

        ll ans = 0;
        for (int i = 1; i < s2.size(); ) {
            if (s2[i - 1] != s2[i]) {
                i++;
            } else {
                ans++;
                i += 2;
            }
        }
        cout << ans << "\n";
        return 0;
    }

    int src = 1;
    vector<ll> dp(2, -1);
    vector<int> memo;
    for (int loop = 0; loop < 4; loop++) {
        int lst = 0;
        bool f = false;
        if (dp[src] == -1) {
            dp[src] = 0;
            f = true;
        }
        for (int i = src; i < n; ) {
            if (s[(i + n - 1) % n] != s[i]) {
                i++;
            } else {
                if (f) dp[src]++;
                lst = i;
                i += 2;
            }
        }
        memo.push_back(src);
        src = (lst == n - 1);
    }

    if (memo[2] == 0) {
        cout << dp[1] + dp[0] * (K - 1) << "\n";
    } else {
        ll ans = 0;
        ll sum = 0;
        for (int i = 0; i < 4; i++) {
            sum += dp[memo[i]];
        }

        ans += sum * (K / 4);
        for (int i = 0; i < K % 4; i++) {
            ans += dp[memo[i]];
        }
        cout << ans << "\n";
    }
    return 0;
}

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

using namespace std;
int main(){
  int n;
   cin >>n;
  
  vector<int> rate(9,0);
   int a;
  for(int i=0;i<n;i++){
   cin >> a;
    int b=min(8,a/400);
    rate[b]++;
  }
   
   int res=0;
  for(int i=0;i<8;i++){
    if(rate[i]) res++;
  }
  
   if(res) cout << res << " "; 
   else cout << 1 << " ";    
  
     
     cout << res+rate[8] << endl;
}

Measured memory_bytes: 256
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int[] a = new int[5];

		for (int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}

		int k = sc.nextInt();

		boolean f = false;
		for (int i = 0; i < a.length; i++) {
			for (int j = i; j < a.length; j++) {
				if (Math.abs(a[i] - a[j]) > k) {
					f = true;
				}
			}
		}

		if (f) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n, m;
    cin >> n >>  m;
    vector<pair<int, int>> ab(n);
    rep(i, n){
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end());
    DEBUG_VAL("ab", ab[n-1].first);
    ll ans = 0;
    priority_queue<int> Q;
    int j = 0;
    for(int i = 1;i <=m; i++){
        DEBUG_VAL("i", i);
        while(j < n && ab[j].first <= i){
            Q.push(ab[j].second);
            j++;
        }
        if(!Q.empty()){
            ans += Q.top();
            Q.pop();
        }
    }
    cout << ans << endl;
}

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

const int MAXN = 1e5;

int N, M;
vector<int> G[MAXN + 10];

bool in_path[MAXN + 10];

int main() {
   scanf("%d%d", &N, &M);
   for(int i = 0; i < M; i++) {
      int u, v; scanf("%d%d", &u, &v);
      G[u].push_back(v);
      G[v].push_back(u);
   }
   deque<int> path;
   path.push_back(1); path.push_back(G[1][0]);
   in_path[1] = in_path[G[1][0]] = true;
   while(true) {
      int u = path.front(), v = path.back();
      int un = -1;
      for(int p : G[u]) {
         if(!in_path[p]) {
            un = p;
         }
      }
      if(un != -1) {
         in_path[un] = true;
         path.push_front(un);
         continue;
      }
      int vn = -1;
      for(int p :  G[v]) {
         if(!in_path[p]) {
            vn = p;
         }
      }
      if(vn != -1) {
         in_path[vn] = true;
         path.push_back(vn);
         continue;
      }
      break;
   }
   printf("%d\n", (int)path.size());
   for(int u : path) {
      printf("%d ", u);
   }
   printf("\n");
}


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

using namespace std;

const int N = 1e3 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;

int a, b, k, tmpk, i = 2;

bool flag;
int main()
{
	cin >> k >> a >> b;
	tmpk = k;
	for(int i = 1 ; i < N; ++i)
	{
		if(k * i <= b && k * i >= a)
			flag = 1;
	}
	if(flag)
		puts("OK");
	else 
		puts("NG");
	return 0;
}

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

int main()
{
	string S, T;
	cin >> S >> T;

	string ans = "No";
	if( T.size() == S.size() + 1 && T.substr( 0, S.size() ) == S ) ans = "Yes";

	cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int  partition(int A[],int n,int p,int r){

	int i=p-1;
	int x=A[r];
	for(int j=p;j<r;j++){
		if(A[j]<=x){
			++i;
			int t=A[j];
			A[j]=A[i];
			A[i]=t;
		}
	}
	A[r]=A[i+1];
	A[i+1]=x;

	return i+1;
}
int main(){
	int n;
	cin>>n;
	int *A=new int[n];
	for(int i=0;i<n;i++)cin>>A[i];

    int q=partition(A,n,0,n-1);
 
    for(int i=0;i<n;i++){
    	if(i>0)cout<<' ';
    	if(i==q)cout<<"[";
    	cout<<A[i];
        if(i==q)cout<<"]";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<int> vll;
typedef pair<ll, ll> pll;
const int INF = 1e9 + 7;
void init() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
}

int main() {
    init();
    int N;
    cin >> N;
    vector<int> aa(N), bb(N), cc(N);
    for (int i = 0; i < N; ++i) {
        cin >> aa[i] >> bb[i] >> cc[i];
    }
    vector<int> hap[N];
    for(int i = 0; i < N; ++i){
        hap[i].resize(3);
    }
    hap[0][0] = aa[0];
    hap[0][1] = bb[0];
    hap[0][2] = cc[0];
    for (int i = 1; i < N; ++i) {
        hap[i][0] = max(hap[i-1][1]+aa[i],hap[i-1][2]+aa[i]);
        hap[i][1] = max(hap[i-1][0]+bb[i],hap[i-1][2]+bb[i]);
        hap[i][2] = max(hap[i-1][0]+cc[i],hap[i-1][1]+cc[i]);

    }
    cout << max({hap[N-1][0],hap[N-1][1],hap[N-1][2]}) << '\n';
}


Measured memory_bytes: 6912
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;
int k;

int main() {
	cin >> s >> k;
	vector<string> v;
	REP(i, s.size()) {
		for (int j = 1; j <= k; j++) {
			v.emplace_back(s.substr(i, j));
		}
	}
	sort(ALL(v));
	UNIQUE(v);
	cout << v[k - 1] << endl;
}

Measured memory_bytes: 1660
package main

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

func main() {
	S := nextString()
	s := strings.Split(S, "/")
	log.Println(s)
	time, _ := strconv.Atoi(s[0])
	m, _ := strconv.Atoi(s[1])
	d, _ := strconv.Atoi(s[2])
	time *= 10000
	time += m * 100
	time += d
	log.Println(time)
	if time > 20190430 {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}

var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var inf = int(1e9)

func fill(a *[]int, n int) {
	for i := 0; i < len(*a); i++ {
		(*a)[i] = n
	}
}

func makeDoubleSlice(n int, m int) [][]int {
	s := make([][]int, n)
	for i := 0; i < n; i++ {
		s[i] = make([]int, m)
	}
	return s
}

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}
func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

import itertools
m = 4
n = N
bit_list = list(itertools.product([i for i in range(m)], repeat=n))

res = 10 ** 18
for b in bit_list:
    tmp1 = 0
    tmp2 = 0
    tmp3 = 0
    check1 = False
    check2 = False
    check3 = False
    cost = 0
    for i in range(n):
        if b[i] == 1:
            tmp1 += L[i]
            if check1:
                cost += 10
            check1 = True       
            
        if b[i] == 2:
            tmp2 += L[i]
            if check2:
                cost += 10
            check2 = True
            
        if b[i] == 3:
            tmp3 += L[i]
            if check3:
                cost += 10
            check3 = True
    if min(tmp1, tmp2, tmp3) != 0:
        res = min(res, abs(tmp1 - A)+abs(tmp2 - B)+abs(tmp3 - C)+cost)
print(res)

Measured memory_bytes: 10996
import sys

l = []
for i in sys.stdin:
    l.append(i)

for i in range(0,len(l)):
    if int(l[i]) == 0:
        break
    count = 0
    for j in range(0,len(l[i])-1):
        count += int(l[i][j])
    print(count)


Measured memory_bytes: 5616
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)

typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

struct pp {
	ll num; ll pos;
};
bool order(pp x, pp y) {
	return x.num < y.num;
}
ll const MAX = 100005;
ll a[MAX];
ll b[MAX];
pp v[MAX];
pp u[MAX];

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		if (i % 2 == 1) {
			cin >> a[(i + 1) / 2];
		}
		else {
			cin >> b[i / 2];
		}
	}
	REP(i, 0, MAX - 1) {
		u[i] = v[i] = { 0,i };
	}
	n /= 2;
	SORT(a, n); SORT(b, n);
	REP(i, 1, n) {
		u[a[i]].num++;
		v[b[i]].num++;
	}
	sort(u, u + MAX, order);
	sort(v, v + MAX, order);
	ll ans;
	if (u[MAX - 1].pos == v[MAX - 1].pos) {
		ans = max(u[MAX - 1].num + v[MAX - 2].num, u[MAX - 2].num + v[MAX - 1].num);
	}
	else {
		ans = u[MAX - 1].num + v[MAX - 1].num;
	}
	cout << n * 2 - ans << endl;
}

Measured memory_bytes: 4608
a,b = map(int,input().split())
count = 0
for i in range(a,b+1):
    s = str(i)
    kaibun = True
    for j in range(len(s)):
        if not s[j] == s[len(s)-1-j]:
            kaibun = False
    if kaibun:
        count+=1

print(count)

Measured memory_bytes: 41324
#include<bits/stdc++.h>
using namespace std;
string s,ss="abcdefghijklmnopqrstuvwxyz";
int f1(int le)
{
    for(int i=0; i<26; i++)
        for(int j=0; j<le; j++)
            if(ss[i]==s[j])break;
            else if(j==le-1)
            {
                s+=ss[i];
                return 0;
            }
    return 0;
}
int main()
{
    cin>>s;
    int le=s.length();
    if(le<26)
    {
        f1(le);
        cout<<s;
    }
    else
    {
        int i;
        string s1=s;
        if(next_permutation(&s[0],&s[26]))
        {
            for(i=1; i<=26; i++)
                if(s.substr(0,i)!=s1.substr(0,i))break;
            cout<<s.substr(0,i);
        }
        else cout<<-1;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{ 

 int a,b,c,x,y,z;

 

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





 if(a > b){


x = a;


a = b;


b = x;


}


if(b > c){


y = b;


b = c;


c = y;


}


if(a > b){


z = a;


a = b;


b = z;


}





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





return 0;


}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x1, y1, x2, y2, x3, y3, x4, y4; cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2-x1, dy = y2-y1;
    x3 = x2 - dy; y3 = y2 + dx;
    x4 = x3 - dx; y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#define x first
#define y second
using namespace std;

const int oo = 0x3f3f3f3f;
const int NMAX = 100003;

typedef pair<int, int> point;

int n;

inline bool cmp(point a, point b)
{
	if (a.y != b.y) return a.y < b.y;
	return a.x < b.x;
}

inline point operator -(point a, point b)
{
	return { a.x - b.x, a.y - b.y };
}

inline int operator *(point a, point b)
{
	return a.x * b.y - a.y * b.x;
}

int st[NMAX];
point v[NMAX];

int main()
{
	cin >> n;

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

	sort(v + 1, v + n + 1, cmp);

	int vf = 0;

	for (int i = 1; i <= n; ++i)
	{
		while (vf >= 2 && (v[i] - v[st[vf]]) * (v[st[vf - 1]] - v[st[vf]]) < 0)
			--vf;
		st[++vf] = i;
	}
	for (int i = n - 1; i >= 1; i--) {
		while (vf >= 2 && (v[i] - v[st[vf]]) * (v[st[vf - 1]] - v[st[vf]]) < 0)
			vf--;
		st[++vf] = i;
	}

	cout << vf - 1 << "\n";

	for (int i = 1; i < vf; ++i)
		cout << v[st[i]].x << " " << v[st[i]].y << "\n";

	return 0;
}



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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n;
	cin >> n;
	double p[3000];
	REP(i, n)cin >> p[i];
	vector<double> dp(3010);
	
	dp[0] = 1;
	REP(i, n) {
		vector<double> dpp(3010);
		REP(j, n+1) {
			if (j == 0)dpp[j] = dp[j] * (1 - p[i]);
			else dpp[j] = dp[j] * (1 - p[i]) + dp[j - 1] * p[i];
		}
		dp = dpp;
		
	}

	double ans = 0;
	FOR(i, n / 2 + 1, n + 1)ans += dp[i];
	cout <<fixed<<setprecision(15)<< ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define fi first
#define se second 
#define pb push_back
int a[200005];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,k; 
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	ll sum = 0;
	for(int i=0;i<n-k;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}


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

using ll = long long;
using vll = vector<ll>;
ll Mod = 1000000007;

int main() {
  int N, C;
  cin >> N >> C;
  auto A = vll(N);
  for(int i=0; i<N; ++i) {
    cin >> A[i];
    A[i] -= 1;
  }
  auto B = vll(N);
  for(int i=0; i<N; ++i) {
    cin >> B[i];
  }
  auto D = *max_element(B.begin(), B.end());

  auto ss = vector< vll >(D+1, vll(C+1, 0));
  for(int i=1; i <= D; ++i) {
    ll j = 1;
    for(int m = 0; m <= C; ++m) {
      ss[i][m] = (ss[i-1][m] + j + Mod) % Mod;
      j = j * i % Mod;
    }
  }

  auto gs = vll(C+1, 0);
  auto hs = vll(C+1, 0);
  for(int m=0; m<=C; ++m) {
    hs[C-m] = (ss[B[N-1]][m] - ss[A[N-1]][m] + Mod) % Mod;
//    cout << ss[B[N-1]][m] << " " << ss[A[N-1]][m] << endl;
  }

  auto dab = vll(C+1);
  for(auto k = N-2; 0 <= k; --k) {
    swap(gs, hs);
    auto ssb = ss[B[k]];
    auto ssa = ss[A[k]];
    for(int m = 0; m <= C; ++m) {
      dab[m] = (Mod + ssb[m] - ssa[m]) % Mod;
      ll s = 0;
      ll r = C - m;
      for(int i = 0; i <= m; ++i) {
        s = (s + dab[i]*gs[r+i]) % Mod;
      }
      hs[r] = s;
    }
  }
  
  cout << hs[0] << endl;
}


Measured memory_bytes: 1536
<?php
list($n) = ints();
$a = ints();
rsort($a);
$alice = $bob = 0;
for ($i = 0; $i < $n; $i++) {
    if ($i % 2 === 0) $alice += $a[$i];
    else $bob += $a[$i];
}
echo $alice - $bob;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
def f(str1, str2, it1, arr)
  #p [str1, str2, it1, arr]
  result = Array.new(arr.size)
  result[0] = it1
  str2[1..-1].each_with_index{|i, idx|
    if str1[it1] == i
      result[idx + 1] = arr[idx]
    else
      result[idx + 1] = arr[idx + 1] > result[idx] ? result[idx] + 1 : arr[idx +  1] + 1
    end
  }
  if it1 != str1.size - 1
    f(str1, str2, it1 + 1, result)
  else
    #p result[-1]
    return result[-1]
  end
end
def lgs(str1, str2)
  return ((str1.size + str2.size) - f([" "] + str1.split(//), [" "] + str2.split(//), 1, Array.new(str2.size + 1){|i|i})) / 2
end
def main(input = STDIN)
  input.gets.to_i.times do
    puts lgs(input.gets.chomp, input.gets.chomp)
  end
end
main

Measured memory_bytes: 21548
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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




void solve() {
	int n, k; cin >> n >> k;
	vector<bool> exi(n);
	rep(i, k) {
		int d; cin >> d;
		rep(j, d) {
			int t; cin >> t; t--;
			exi[t] = true;
		}
	}
	int ans = 0;
	rep(i, n)if (!exi[i])ans++;
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//experi();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

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

long int mod = 1000000007;

int main(){
    long int N;
    cin >> N;
    long int ans = 1, k = 1;
    for (int i = 0; i < N; i++){
        k = k * 10 % mod;
    }
    ans = k;
    k = 1;
    for (int i = 0; i < N; i++){
        k = k * 9 % mod;
    }
    ans = (ans - k) % mod;
    ans = (ans - k) % mod;
    k = 1;
    for (int i = 0; i < N; i++){
        k = k * 8 % mod;
    }
    ans = (ans + k) % mod;
    cout << (ans + mod) % mod << endl;

}


Measured memory_bytes: 3620
import java.util.*;

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

        int N = sc.nextInt();

        int[] ts = new int[N + 1];
        int[] xs = new int[N + 1];
        int[] ys = new int[N + 1];

        ts[0] = 0;
        xs[0] = 0;
        ys[0] = 0;
        for (int i = 0; i < N; i++) {
            ts[i + 1] = sc.nextInt();
            xs[i + 1] = sc.nextInt();
            ys[i + 1] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            int duration = ts[i + 1] - ts[i];
            int distance = Math.abs(xs[i + 1] - xs[i]) + Math.abs(ys[i + 1] - ys[i]);
            boolean just = (distance == duration);
            boolean ok = (duration > distance && ((duration - distance) % 2 == 0));
            if (!just && !ok) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 90408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin>>t;
  int arr[t];
  int cnt=0;
  for(int i=1;i<=t;i++)
  {
    cin>>arr[i];
  } 
  for(int i=1;i<=t;i+=2)
  {
    if(arr[i]%2 ==1)
      cnt++;
  } 
  cout<<cnt;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

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

int main()
{
    ins(a);ins(b);ins(c);
    M<int,int> mp;
    mp[a]++;mp[b]++;mp[c]++;
    int cnt=0;
    rep(i,101) if(mp[i]>0)cnt++;
    print(cnt);
    return 0;
}


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



int main() {
    int n;
    cin >> n;
    
    vector<int> x(n), y(n), num(n);
    rep(i,n) {
        cin >> x[i] >> y[i];
        num[i] = i;
    }
    
    double sum = 0;
    int cnt = 0;
    do {
        cnt++;
        rep(i,n-1) {
            int xd = x[num[i+1]] - x[num[i]];
            int yd = y[num[i+1]] - y[num[i]];
            sum += sqrt(xd * xd + yd * yd);
        }
    } while(next_permutation(num.begin(),num.end()));
    
    cout << fixed << setprecision(8) << sum / cnt << endl;
    
    
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	vector<int> cnt(n);
	for (int i = n - 1; i >= 0; i--) {
		int temp = 0;
		for (int j = i; j < n; j += i + 1) {
			if (j == i) continue;
			if (cnt[j]) temp++;
		}
		if (temp % 2 != v[i]) cnt[i]++;
	}
	vector<int> ans;
	rep(i,n) if (cnt[i]) ans.push_back(i + 1);
	cout << ans.size() << endl;
	if (ans.size()) {
		rep(i,ans.size()) cout << ans[i] << " "; 
		cout << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 5324
#include <stdio.h>

int main(void)
{
	int N,i,j,t,c,A[100];
	
	scanf("%d",&N);
	
	for(i=0; i<N; i++)
	{
		scanf("%d",&A[i]);
	}
	c=0;
	
	for(i=0; i<N; i++)
	{
		for(j=N-1; j>=1; j--)
		{
			if(A[j]<A[j-1])
			{
				t=A[j];
				A[j]=A[j-1];
				A[j-1]=t;
				
				c++;
			}
		}
		
	}
    	
	for(i=0; i<N; i++)
	{
		printf("%d",A[i]);
		
		if(i!=N-1)
		{
			printf(" ");
		}
	}
	
    printf("\n");
    printf("%d\n",c);
	
	
    return 0;
}



Measured memory_bytes: 2712
bingo = []
bingo.push gets.split(' ').map(&:to_i)
bingo.push gets.split(' ').map(&:to_i)
bingo.push gets.split(' ').map(&:to_i)
re = []
n = gets.to_i
n.times do
  re.push gets.to_i
end
re.each do |r|
  0.upto 2 do |g|
    0.upto 2 do |s|
      bingo[g][s] = 0 if r == bingo[g][s]
    end
  end
end
3.times do |i|
  if bingo[i].all? { |b| b == 0 }
    puts 'Yes'
    exit
  end
end
3.times do |i|
  t = 0
  3.times do |j|
    t += bingo[j][i]
  end
  if t == 0
    puts 'Yes'
    exit
  end
end
t = 0
3.times do |i|
  t += bingo[i][i]
end
if t == 0
  puts 'Yes'
  exit
end
t = 0
3.times do |i|
  t += bingo[i][2 - i]
end
if t == 0
  puts 'Yes'
  exit
end
puts 'No'


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;

bool solve(string &s) {
  for(int i = 0; i + 1 < s.size(); ++i)
    if(s[i] == 'A' && s[i + 1] == 'C')
      return true;
  return false;
}

int main() {
  string s;
  cin >> s;
  if(solve(s)) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

     ios::sync_with_stdio(0);
     cin.tie(0);

    int n ;
    cin >> n ; 
    vector<int> arr(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> arr[i];
    }
    long long int sum = 0;
    for(int i = 0 ; i < n ; ++i) {
        for(int j = i+1 ; j < n ; ++j ){
            sum += arr[i] * arr[j];
        }
    }
   cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int n;
double x;
int main() {
	cin >> n;
	x = n / 1.08;
	for(int i=x; i<x+5; i++) {
		if(int(i*1.08) == n) {cout << i << endl; return 0;}
	}
	puts(":(");
	return 0;
}

Measured memory_bytes: 3552
use std::collections::BTreeMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();
    let mut btm: BTreeMap<String, i32> = BTreeMap::new();

    for _ in 0..n {
        let s: String = read();
        *btm.entry(s).or_insert(0) += 1;
    }

    let mut vec = Vec::new();
    let mut max = 0;

    for (k,v) in btm.iter() {
        if *v > max {
            max = *v;
            vec.clear();
            vec.push(k);
        } else if *v == max {
            vec.push(k);
        }        
    }

    for s in vec.iter() {
        println!("{}", s);
    }
}


Measured memory_bytes: 24444
#define NDEBUG

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;
using tii = tuple<int, int>;

#ifdef NDEBUG
#  define debug(...)
#else
#  include "debug.hh"
#endif

bool debut(int n) {
  int d = n%10;
  n/=10;
  while (n > 0) {
    if (n%10 != d) return false;
    n /= 10;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
  int n;
  cin >> n;
  while (!debut(n)) n++;
  cout << n << endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    set <string> ms;
    multiset <string> mp;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        ms.insert(s);
        mp.insert(s);
    }
    int cnt = 0;
    for(auto i:ms)
    {
        int cx = mp.count(i);
        cnt = max(cnt, cx);
    }
    for(auto i:ms)
    {
        if(mp.count(i)==cnt)
        {
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
 
int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)    cin >> a[i];

    int ans = 0;
    rep(i,n) {
        if((i+1)%2 ==1 && a[i]%2 == 1)  ans++;
    }

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<vec<int>> A(N, vec<int>(N));
    vec<vec<int>> K(N, vec<int>(N));

    ll sm = 0;
    rep(i, N) rep(j, N) {
        cin >> A[i][j];
        sm += A[i][j];
    }
    K = A;

    vec<vec<int>> Checked(N, vec<int>(N, false));
    function<void(int)> warshall_floyd = [&](int n) {
        for (int k = 0; k < n; k++) {            // 経由する頂点
            for (int i = 0; i < n; i++) {        // 始点
                for (int j = 0; j < n; j++) {    // 終点
                    if (K[i][j] == K[i][k] + K[k][j] && i != k && j != k
                        && Checked[i][j] == false) {
                        sm -= K[i][j];
                        Checked[i][j] = true;
                    }
                    K[i][j] = min(K[i][j], K[i][k] + K[k][j]);
                }
            }
        }
    };

    warshall_floyd(N);
    rep(i, N) rep(j, N) {
        if (A[i][j] != K[i][j]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << sm/2 << endl;
}


Measured memory_bytes: 4660
// AGC 028 A
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define mod 1000000007
    #define MAX 100000
    void inarray(int a[], int n){
        for(int i = 0; i < n; i++) cin >> a[i];
    }

    // 最大公約数
    ll gcd(ll a, ll b){
        // a > b
        if(b == 0) return a;
        else return  gcd(b, a%b);
    }

    // 最小公倍数
    ll lcm(ll a, ll b){
        // a > b
        return (a*b)/gcd(a,b);
    }

    int main(){
        ll n,m; cin >> n >> m;
        string s,t; cin >> s >> t;
        if(n < m){
            int w = n; n = m; m = w;
            string W = s; s = t; t = W;
        }
        ll ans = lcm(n,m);
        int sch[n], tch[m];
        for(int i = 0; i < n; i++){
            sch[i] = i*(ans/n) +1;
        }
        for(int i = 0; i < m; i++){
            tch[i] = i*(ans/m) +1;
        }
        int j = 0;
        for(int i = 0; i < n && j < m;){
            if(sch[i] == tch[j]){
                if(s[i] != t[j]){
                    cout << -1 << endl;
                    return 0;
                }
                j++;
            }else if(sch[i] < tch[j]){
                i++;
            }else{
                j++;
            }
        }

        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm

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

int64_t A, B, C, D; cin >> A >> B >> C >> D;
int64_t LCM = boost::integer::lcm(C, D);

cout << (B - (B/C + B/D - B/LCM)) - (A - (A/C + A/D - A/LCM)) + ((A%C && A%D) ? 1:0) << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
/* ex5_4
   nabe9393 */

#include<stdio.h>

int main(void){
  //NULL文字含め11文字
  char str[11];
  //ポインタ
  char *ptr;
  //変数
  int answer=0, save=0;
  //入力
  scanf("%s",str);
  
  ptr = str;
  
  while(*ptr != '\0'){
    //ACGTのいずれかが現れた時、saveに1を加え、answerとの比較
    if(*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
      save++;
      if(save > answer){
        answer = save;
      }
    }
    //異なる場合はsaveを初期化
    else{
      save = 0;
    }
    //ポインタをずらす
    ptr++;
  }
  //出力
  printf("%d\n",answer);
  return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        sum += X[i];
    }
    int ave = sum / N;
    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i < N; ++i) {
        ans1 += (X[i] - ave) * (X[i] - ave);
        ans2 += (X[i] - ave - 1) * (X[i] - ave - 1);
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int K;
	cin >> K;
	cout << a[K - 1]<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <set>
#include <cassert>

using namespace std;

#define print(x) cout << x << endl
#define input(x) cin >> x

int n;
std::string buffer;

void dfs(int cur) {
    if (cur == n) {
        puts(buffer.c_str());
        return;
    }

    set<char> st;
    for (int i = 0; i < cur; i++) {
        if (st.count(buffer[i])) {
            continue;
        }
        buffer.push_back(buffer[i]);
        dfs(cur + 1);
        buffer.pop_back();
        st.insert(buffer[i]);
    }

    char nxt = st.empty()? 'a': *st.rbegin() + 1;
    assert(nxt - 'a' == st.size());
    buffer.push_back(nxt);
    dfs(cur + 1);
    buffer.pop_back();
}

int main() {
    input(n);

    dfs(0);

    return 0;
}


Measured memory_bytes: 1536
import           Control.Applicative
import           Control.Monad
import           Data.List

toRadians :: Float -> Float
toRadians deg = deg * (pi / 180)

solve :: [(Float, Float)] -> (Float, Float)
solve = fst . foldl f ((0, 0), toRadians 90)
  where f ((x, y), r) (l, nd) = ((x + l * cos r, y + l * sin r), r - toRadians nd)

main :: IO ()
main = getContents >>= printResult . solve . parseInput
  where printResult (x, y) = let x' = truncate x
                                 y' = truncate y
                             in  print x' >> print y'

parseInput :: Read a => String -> [(a, a)]
parseInput = map (l2t . words) . lines . map c2s
  where c2s ',' = ' '
        c2s c   = c
        l2t (x:y:_) = (read x, read y)

Measured memory_bytes: 3932
use std::cell::RefCell;
use std::cmp::{max, min};
use std::io::{self, stdout, BufWriter, Read, Write};
use std::iter::FromIterator;

#[allow(dead_code)]
struct Source {
    chars: Box<Iterator<Item = char>>,
}

#[allow(dead_code)]
impl Source {
    fn next_chr(&mut self) -> char {
        self.chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .next()
            .expect("eof")
    }

    fn next_str(&mut self) -> String {
        let it = self
            .chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .take_while(|c| !char::is_whitespace(*c));
        let s = String::from_iter(it);
        if s.is_empty() {
            panic!("eof")
        } else {
            s
        }
    }

    fn from_stdin() -> Self {
        let mut data = String::new();
        io::stdin().read_to_string(&mut data).expect("Input error");
        Self::from_str(&data)
    }

    fn from_str(s: &str) -> Self {
        let data = String::from(s);
        let chars = data.chars().collect::<Vec<char>>().into_iter();
        Source {
            chars: Box::new(chars),
        }
    }
}

thread_local!(static SRC: RefCell<Source> = RefCell::new(Source::from_stdin()));

#[allow(unused_macros)]
macro_rules! input {
    ($($elem:tt)*) => {
        input_inner!(SRC, $($elem)*)
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($src:expr) => {};
    ($src:expr,) => {};
    ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {
        let mut $var = $src.with(|src| {
            let mut src = src.borrow_mut();
            parse!(src, $ty)
        });
        input_inner!($src $($rest)*)
    };
    ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {
        let $var = $src.with(|src| {
            let mut src = src.borrow_mut();
            parse!(src, $ty)
        });
        input_inner!($src $($rest)*)
    };
}

#[allow(unused_macros)]
macro_rules! parse {
    ($src:expr, ( $($ty:tt),* )) => {
        ( $(parse!($src,$ty)),* )
    };
    ($src:expr, char) => {
        $src.next_chr()
    };
    ($src:expr, [ $ty:tt; $len:expr ]) => {
        (0..$len).map(|_| parse!($src,$ty)).collect::<Vec<_>>()
    };
    ($src:expr, $ty:tt) => {
        parse_str!($src,$ty)
    };
}

#[allow(unused_macros)]
macro_rules! parse_str {
    ($src:expr, chars) => {
        $src.next_str().chars().collect::<Vec<char>>()
    };
    ($src:expr, $ty:ty) => {
        $src.next_str().parse::<$ty>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32, b: i32, c: i32
    }

    println!("{}", min(c, b / a))
}


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

typedef unsigned long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    priority_queue<double, std::vector<double>, std::greater<double>> q;
    REP(i,N){
       ll v;
       cin >> v;
       q.push((double)v);
    }

    while(q.size() != 1){
        double v1 = q.top();
        q.pop();
        double v2 = q.top();
        q.pop();
        q.push( (v1+v2)/2);
    }

    cout << q.top() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if ( abs(x - a) < abs(x - b) ) {
        cout << "A" << endl;
    }
    else {
        cout << "B" << endl;
    }
}

Measured memory_bytes: 256
import sys
import itertools
tokens = itertools.chain.from_iterable(map(str.split, sys.stdin))

mod = 1000000007
n = int(next(tokens))
a = [int(next(tokens)) % mod for _ in range(n)]

sms = []
sma = sum(a)
for i in range(n):
    sma -= a[i]
    sms.append(sma)
#print(sms)

m = 0
for i in range(n - 1):
    sm = sms[i]
    #print(i, a[i], sm)
    m = (m + a[i] * sm) % mod

print(m)


Measured memory_bytes: 39236
#include<bits/stdc++.h>
#define int long long
#define MOD 1e9+7
using namespace std;
signed main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    int num[30]={};
    for(int i=0;i<s.size();i++){
        int a = s[i] - 48 - '0';
        num[a]++;
    }
    int ans=1;
    for(int i=0;i<30;i++){
        if(num[i]==0) continue;
        ans*=num[i]+1;
        ans%=(int)MOD;
    }
    cout<<ans-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int t=n;
  int total=0;
  while(n>0)
  {
    total+=((t/n)-(t%n==0));
    n--;
  }
  cout<<total<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B && B == C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

#define f(i,a,b) for(int i=a;i<=b;i++)
#define md 1000000007

int n;
int a[50000];
long long ans=1;

int main()
{
	scanf("%d",&n);
	
	f(i,1,n)
	{
		int tmp=i;
		
		f(j,2,tmp)while(tmp%j==0)
		{
			a[j]++;
			tmp/=j;
		}
	} 
	
	for(int i=1;i<1000;i++)
	{
		ans*=(a[i]+1)%md;
		ans=ans%md;
	}
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256