akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double getAlpha(int[],int);
int main(void)
{
  int *arr;
  int i,n;
  for(;;)
    {
      scanf("%d",&n);
      if(n==0) break;
      arr=(int*)malloc(sizeof(int)*n);
      for(i=0;i<n;i++) scanf("%d",&arr[i]);
      printf("%f\n",getAlpha(arr,n));
    }
  return 0;
}
double getAlpha(int arr[],int n)
{
  int i;
  double m=0;
  double alpha=0;
  for(i=0;i<n;i++) m+=arr[i];
  m/=n;
  for(i=0;i<n;i++) alpha+=pow(arr[i]-m,2);
  alpha/=n;
  return sqrt(alpha);
}


Measured memory_bytes: 2032
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string A, B; cin >> A >> B;
    cout << (A > B&&A.size()>=B.size() ? "GREATER" : (A < B||A.size()<B.size() ? "LESS" : "EQUAL")) << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			int index1 = i;
			int index2;
			for (int j = s.size() - 1; j >= i; j--) {
				if (s[j] == 'Z') {
					index2 = j;
					break;
				}
			}
			ans = index2 - (index1 - 1);
			printf("%d\n", ans);
			return 0;
		} 
	}
	
	
}

Measured memory_bytes: 640
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let n: usize = read();

    let mut a: i64 = 2;
    let mut b: i64 = 1;
    for _i in 1..n {
        let t = a + b;
        a = b;
        b = t;
    }
    println!("{}", b);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int64_t zyou5(int64_t x){
	x = x*x*x*x*x;
    return x;
}


int main(){
  int64_t N ;
  cin >> N;
  int count = 0;
  for(int i = 0 ; i < 10000 ; i++){
    if(count > 0){
    break;
    }
  	for(int j = 0 ; j < 10000 ; j++){
    	if( (zyou5(i) + zyou5(j)) == N ){
        	cout << i << " " << -1*j << endl;
          	count++;
          	break;
        }
        if( (zyou5(i) - zyou5(j)) == N ){
        	cout << i << " " << j << endl;
          	count++;
          	break;
        }
    }
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  rep(i,ty-sy)cout<<'U';
  rep(i,tx-sx)cout<<'R';
  rep(i,ty-sy)cout<<'D';
  rep(i,tx-sx)cout<<'L';
  cout<<'L';
  rep(i,ty-sy+1)cout<<'U';
  rep(i,tx-sx+1)cout<<'R';
  cout<<'D'<<'R';
  rep(i,ty-sy+1)cout<<'D';
  rep(i,tx-sx+1)cout<<'L';
  cout<<'U';
  cout<<endl;
}




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

int main(){
  int n,k;
  cin >> n >> k;
  if(n%k==0) cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 3000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
vector <string> S;
string s, f[MAX_N+5];
string sol() {
	vector <int> a, b, id, p;
	for (int i = 0; i < (int)s.size(); i++)
		if (s[i] == 'a') a.push_back(i);
		else b.push_back(i);
	for (int i = 0, pa = 0, pb = 0; i < (int)s.size(); i++)
		if (s[i] == 'a') id.push_back(pa), p.push_back(b[pa]), pa++;
		else id.push_back(pb), p.push_back(a[pb]), pb++;
	string ret = "";
	if (s[0] == 'a') {
		for (int i = 0; i < (int)s.size(); i++)
			if (s[i] == 'a') ret += "ab", i = p[i];
	} else {
		for (int i = (int)id.size()-1; ~i; i--) {
			string ss = "";
			for (int j = 0; j < (int)s.size(); j++)
				if (id[j] >= i) ss.push_back(s[j]);
			ret = max(ret, ss);
		}
	}
	return ret;
}
int main() {
	int n; read(n); string str; cin >> str, s = "";
	for (int i = 0, cnt = 0; i < (int)str.size(); i++) {
		s.push_back(str[i]), cnt += str[i] == 'a' ? 1 : -1;
		if (!cnt) S.push_back(sol()), s.clear();
	}
	string ans = "";
	for (int i = (int)S.size()-1; ~i; i--) {
		f[i] = S[i];
		for (int j = i+1; j < (int)S.size(); j++)
			f[i] = max(f[i], S[i]+f[j]);
		ans = max(ans, f[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10624
def run(N):
    p_list = primes(555555)
    # 選択した素数が、5で割って余りが1のもののみ選択すれば、必ず合成数になる
    ret = []
    for p in p_list:
        if p % 5 == 1:
            ret.append(p)
        if len(ret) == N:
            break
    return ' '.join([str(p) for p in ret])


def primes(n):
    '''
    エラトステネスの篩にて、素数のリストを作成
    '''
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]


def main():
    N = int(input())
    print(run(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
import math
mod = 10 ** 9 + 7

def combination(n, k):
    if n - k < 0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(k) * math.factorial(n - k))

N, K = map(int, input().split(' '))
for i in range(1,K+1):
    # k-1 C i-1 * (N-K C i-1 + 2 * N-K C i)
    ans = combination(K-1, i - 1) * (combination(N-K, i - 1) + combination(N-K, i)) % mod
    print(ans)

Measured memory_bytes: 3316
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	a,b,c,d = map(int,input().split())
	print(max(a*b,c*d))
	

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 63724
#include <iostream>
#define MAX_N 1000000
using namespace std;

int main(){
	int n;
	bool num[MAX_N];
	for(int i=0;i<MAX_N;i++) num[i]=false; 

	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(num[i]) continue;
			for(int j=2;j<=n/i;j++) num[i*j]=true;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2136
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, M := ReadInt(), ReadInt()
	uf := InitUnionFind(N)
	for m := 0; m < M; m++ {
		x, y, _ := ReadInt()-1, ReadInt()-1, ReadInt()
		uf.Unite(x, y)
	}

	m := make(map[int]bool)
	for i := 0; i < N; i++ {
		m[uf.Root(i)] = true
	}
	fmt.Println(len(m))
}

func InitUnionFind(size int) UnionFind {
	parent := make([]int, size)
	for i := 0; i < size; i++ {
		parent[i] = i
	}
	return parent
}

type UnionFind []int

func (uf UnionFind) Unite(x, y int) {
	x = uf.Root(x)
	y = uf.Root(y)
	if x != y {
		uf[x] = y
	}
}

func (uf UnionFind) Connected(x, y int) bool {
	return uf.Root(x) == uf.Root(y)
}

func (uf UnionFind) Root(x int) int {
	if uf[x] == x {
		return x
	}
	uf[x] = uf.Root(uf[x])
	return uf[x]
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll k;
  ll v[32] = {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};
  cin >> k;
  k--;

  cout << v[k] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int MAX_N = 10000;
const int INF = 1 << 20;

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

struct edge {
  int to;
  int distance;
  int cost;

  edge(): to(0), distance(0), cost(0) {}
  edge(int to, int distance, int cost): to(to), distance(distance), cost(cost) {}
};

vector<edge> G[MAX_N + 1];
int d[MAX_N + 1];
int cost[MAX_N + 1];

void dijkstra(int s, int V)
{
  priority_queue<P, vector<P>, greater<P> > que;
  for (int i = 0; i < V; i++) d[i] = INF;

  d[s] = 0;
  que.push(P(0LL, s));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;

    if (d[v] < p.first) continue;

    for (int i = 0; i < (int)G[v].size(); i++) {
      edge e = G[v][i];

      if (d[e.to] > d[v] + e.distance) {
        d[e.to] = d[v] + e.distance;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main()
{
  while (true) {
    int N, M; scanf("%d%d", &N, &M);
    if (N == 0 && M == 0) break;

    for (int i = 0; i <= N; i++) G[i].clear();

    for (int i = 0; i < M; i++) {
      int from, to, distance, cost;
      scanf("%d%d%d%d", &from, &to, &distance, &cost);

      G[from].push_back(edge(to, distance, cost));
      G[to].push_back(edge(from, distance, cost));
    }

    dijkstra(1, N + 1);

    ll ans = 0;
    for (int i = 2; i <= N; i++) {
      int minCost = INF;
      for (int j = 0; j < (int)G[i].size(); j++) {
        edge e = G[i][j];
        if (d[i] == d[e.to] + e.distance) {
          minCost = min(minCost, e.cost);
        }
      }
      // printf("d[%d]=%d, minCost=%d\n", i, d[i], minCost);
      ans += minCost;
    }

    printf("%lld\n", ans);
  }
  return 0;
}



Measured memory_bytes: 4696
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;

void swap(int &a, int &b) {
    a ^= b;
    b ^= a;
    a ^= b;
}

uint tzcnt(uint x) {
    x = ~x & (x - 1);
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

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

    string n;
    cin >> n;

    n[3] = '8';

    out(n);

    int ttttttt;
    cin >> ttttttt;
}

Measured memory_bytes: 256
m = 2019
C = [0]*m
C[0] = 1
s = list(input())
now = 0
cnt = 0
while s:
  now += pow(10, cnt, m) * int(s.pop())
  now %= m
  C[now] += 1
  cnt += 1
ans = 0
for c in C:
  ans += c*(c-1)//2
print(ans)

Measured memory_bytes: 10608
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

n,k = map(int, input().split())
h = list(map(int, input().split()))

ans = 0
for i in range(n):
    if h[i] >= k:
        ans += 1
print(ans)


Measured memory_bytes: 18392
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}

ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}



int32_t main(){
  fastio;
  int tot=0;
  int n;
  cin>>n;
  string s;
  cin >> s;
  for(int i=0;i<n;){
    char c = s[i];
    while(i<n and s[i]==c)i++;
    tot++;

  }cout <<tot<<endl;


  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3728
#include<stdio.h>

int main(){
	char a,b;
	int value;

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

	if( b == 'H' ){
		value = 1;
	}else if( b == 'D' ){
		value = -1;
	}

	
	if( a == 'H' ){
		value *= 1;
	}else if( a == 'D' ){
		value *= -1;
	}

	if( value == 1 ){
		printf("H\n");
	}else if( value == -1 ){
		printf("D\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    ll A = 0;
    rep(i,n) A+=a[i];

    ll ans = LLONG_MAX;
    ll t = 0;
    rep(i,n-1)
    {
        A -= a[i];
        t += a[i];
        ans = min(ans,abs(A-t));
    }

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


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

int main() {
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int s = h1 * 60 + m1, e = h2 *60 + m2;
    int ans = e - s - k;
    cout << ans << endl;
    return 0;
}

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

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    int a[A], b[B];
    int x[M], y[M], c[M];
    int a_min=1000000, b_min=1000000;
    rep(i,A) {
        cin >> a[i];
        if(a[i] < a_min)    a_min = a[i];
    }
    rep(i,B) {
        cin >> b[i];
        if(b[i] < b_min)    b_min = b[i];
    }
    rep(i,M) cin >> x[i] >> y[i] >> c[i];

    int res = a_min + b_min;
    int price = 0;
    
    for(int i=0; i<M; i++){
        price = a[x[i]-1] + b[y[i]-1] - c[i];
        if(price < res){
            res = price;
        }
    }
    
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 5512
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n,m;
  cin >> n >>m;
  vector<vector<int> > vec(n,vector<int>(m));
  rep(i,n){
    rep(j,m){
      int a;
      cin >> a;
      vec[i][j]=a;
    }
  }
  vector<int>b(m);
  rep(i,m) cin >> b[i];
  rep(i,n){
    int sum=0;
    rep(j,m){
      sum+=vec[i][j]*b[j];
    }
    cout << sum << endl;
  }
  
  return 0;

      
}



Measured memory_bytes: 3176
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        // お菓子を持っているすぬけ君のみ格納する
        Set<Integer> candy = new HashSet<Integer>();
        while(sc.hasNext()){
            int d = sc.nextInt(); // お菓子1をもっている人数
            // System.out.println(d);
            for(int i = 0;i < d;i++) {
                candy.add(sc.nextInt());
                // System.out.println(candy);
            }
        }
        System.out.println(N - candy.size());
    }
}


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

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

  int s=0;
  int t=1;
  std::vector<std::vector<int>> S(2);

  for (int i=0; i<N; i++) {
    if (s < t) {
      S[s].push_back(i+1);
      S[t].push_back(i+1);
      s++;
    } else {
      S[0].push_back(i+1);
      S.push_back({i+1});
      s=1;
      t++;
    }
  }

  // std::cerr << s << ' ' << t << std::endl;

  if (s == t) {
    std::cout << "Yes" << '\n';
    std::cout << S.size() << '\n';
    for (auto const& s : S) {
      std::cout << s.size();
      for (auto t: s) {
        std::cout << ' ' << t;
      }
      std::cout << '\n';
    }
  } else {
    std::cout << "No" << '\n';
  }

  return 0;
}


Measured memory_bytes: 2304
#include<iostream>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    rep(i,3){
        int h,m,s,H,M,S; cin>>h>>m>>s>>H>>M>>S;
        int dt=S-s+(M-m)*60+(H-h)*3600;
        cout<<dt/3600<<" ";
        dt%=3600;
        cout<<dt/60<<" ";
        dt%=60;
        cout<<dt<<endl;
    }
}

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

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

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

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

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

/* ---------- Constants  */
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, A, B;
    cin >> N >> A >> B;

    int nmax = min(A, B);
    int nmin = -1;

    if (A + B <= N) {
        nmin = 0;
    } else {
        nmin = (A + B) - N;
    }

    cout << nmax << " " << nmin << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;
void call(int n){
	int i=1;
	do{
		int x=i;
		if(x%3==0){
			cout<<" "<<i;
		}else{
			do
			{
				if(x%10==3){
					cout<<" "<<i;	
					break;
				}
				x/=10;
			}while(x);
		}
	}while(++i<=n); 
	cout << endl;
 }
 
 int main()
{
 	int n;
 	scanf("%d",&n);
 	call(n);
}



Measured memory_bytes: 3220
#include <stdio.h>
int main(void){
int a,b,count=0,hoji;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a==1){printf("%d",b);return 0;}
hoji=b-a+1;
for(;;){
printf("%d ",hoji);
  count++;
  hoji++;
    if(count==a*2-1){break;}
}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MAXN = 2e5 + 5;
ll n, ans = 0, num = 0;
ll A[MAXN];

void input() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
}

void solve() {
	ll j = 0;
	for (ll i = 0; i < n; i++) {
		while (j < n && ((A[j] ^ num) == A[j] + num)) {
				num += A[j];
				j++;
		}
		num -= A[i];
		ans += j - i;
	}
	cout << ans << "\n";
}

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

	input();
	solve();
	
	return 0;
}


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

void func(char* t, int i){
  for (int j = 0; j < 3; j++){
    int r = i % 10; t[j] = '0' + r;
    i /= 10;
  }
}

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i < 1000; i++){
    char t[3]; func(t, i);
    bool ok = false;
    int cur = 0;
    for (int j = 0; j < n; j++){
      if (s.at(j) == t[cur]) cur++;
      if (cur >= 3){
        ok = true;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(void) {
    int R0, W0, C, R;
    while (cin >> R0 >> W0 >> C >> R, R0) {
        for (int i = 0; ; i++) {
            if ((double)(R0 + i * R) / C - W0 >= 0) {
                cout << i << endl;
                break;
            }
        }      
    }  
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=(1<<30)-1;
const int MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll n, pri[1001], ans = 1LL;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    fill(pri, pri+1001, 1);
    erep(i, 2, n) {
        int x = i;
        for (int j = 2; j * j <= 1000; j++) {
            while (x%j == 0) {
                pri[j]++;
                x /= j;
            }
        }
        pri[x]++;
    }
    rep(i, 2, 1001) {
        ans = ans * pri[i] % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
k, s = gets.split(' ').map(&:to_i)
#puts (0..k).to_a.product((0..k).to_a).map { |x, y| s - x - y } .select { |z| 0 <= z && z <= k } .size
puts (k + 1).times.map { |x| (k + 1).times.map { |y| s - x - y } .select { |z| 0 <= z && z <= k}.size } .inject(&:+)


Measured memory_bytes: 42364
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll N, M, V, P;
vector<ll> A;
bool isGood(ll x) {
     if (x < P) return true;
     ll now = A[x] + M;
     if (A[P - 1] > now) return false;
     ll score = 0;
     score += (P - 1) * M;
     score += (N - x) * M;
     for (ll i = P - 1; i < x ; i++) {
         score += min(M, max(0ll, now - A[i]));
     }
     return score >= M * V;
 }


int main()
{
  cin >> N >> M >> V >> P;
  A = vector<ll>(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  // cout << "A" << endl;
  // for (ll i = 0; i < N; ++i)
  // {
  //   cout << A.at(i) << ' ';
  // }
  // cout << endl;
  ll l = -1, r = N;
  ll m;
  while (l + 1 != r)
  {
    m = (l + r) / 2;
    if (isGood(m))
    {
      l = m;
    }
    else
    {
      r = m;
    }
  }
  cout << l + 1 << endl;
  // cout << "l" << l << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  int N = 13, M = 1e9 + 7;
  vector<int> DP(N);
  DP.at(0) = 1;
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    vector<int> V(N);
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < 10; k++) {
        if (S.at(i) == '?' || S.at(i) == '0' + k) {
          (V.at((j * 10 + k) % 13) += DP.at(j)) %= M;
        }
      }
    }
    DP = V;
  }

  cout << DP.at(5) << "\n";
}

Measured memory_bytes: 512
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;



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

		int ans = 0;

		Map<String, Integer> words = new HashMap<String, Integer>();

		for (int i = 0; i < N; i++) {
			String target = sc.next();
			if (words.containsKey(target)) {
				words.put(target, words.get(target) + 1);
			}else {
				words.put(target, 1);
			}
		}

		int M= sc.nextInt();
		for (int i = 0; i < M; i++) {
			String target = sc.next();
			if (words.containsKey(target)) {
				words.put(target, words.get(target) - 1);
			}else {
				words.put(target, -1);
			}
		}

		for (String string : words.keySet()) {
			ans = Math.max(ans, words.get(string));
		}

		System.out.println(ans);
	}
}


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

int main(){
    int n,m; cin >> n >>m;
    int x,y;
    vector<vector<int>> cnct(n+1,vector<int>(0));
    rep(i,m){
        cin >> x >> y;
        cnct[x].push_back(y);
        cnct[y].push_back(x);
    }
    for(auto p: cnct[1]){
        for(auto q: cnct[p]){
            if(q==n){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;


}

Measured memory_bytes: 12016
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        int n = scan.nextInt();
        int[][] c = new int[h][w];
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = scan.nextInt();
        int index = 0;
        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) {
                for (int j = 0; j < w; j++) {
                    c[i][j] = index + 1;
                    if (--a[index] == 0)
                        index++;
                }
            } else {
                for (int j = w - 1; j >= 0; j--) {
                    c[i][j] = index + 1;
                    if (--a[index] == 0)
                        index++;
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (j == 0)
                    System.out.print(c[i][j]);
                else {
                    System.out.print(" " + c[i][j]);
                }
            }
            System.out.println();
        }
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 34916
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0;
  string q,s,t;
  cin>>n>>s>>t;
  for(int i=1; i<=n; i++){
    if(s.substr(n-i,i)==t.substr(0,i)){
      count=i;
    }
  }
  cout<<n*2-count<<'\n';

  return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> as(H);
  for (int i = 0; i < H; i++) {
    cin >> as.at(i);
  }
  
  string bar(W + 2, '#');
  
  cout << bar << endl;
  for (int i = 0; i < H; i++) {
    cout << '#' << as.at(i) << '#' << endl;
  }
  cout << bar << endl;
}


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

typedef long long ll;
ll mod = 1e9 + 7;
int main() {
    int N, M;
    int a;
    std::cin >> N >> M;
    vector<ll> DP(N+1);
    DP[0]=1;
    vector<int>input(N+1,true);
    for (int i = 0; i < M; i++) {
        std::cin >> a;
        input[a] = false;
    }
    
    for (int i = 0; i < N; i++) {
        for (int k = i+1; k <= min(N,i+2); k++) {
            if (input[k]) {
                DP[k]+=DP[i];
                DP[k]%=mod;
            }
        }
    }
    
    std::cout << DP[N] << std::endl;
    
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    int n, m; cin >> n >> m;
    vector<pair<int, int>> key(m);
    rep(i, m)
    {
        int a, b; cin >> a >> b;
        int v = 0;
        rep(j, b)
        {
            int c; cin >> c;
            v |= (1 << (c - 1));
        }
        key[i].first = a;
        key[i].second = v;
    }
    priority_queue<pair<int, int>> q;
    int all = (1 << n) - 1;
    vector<int> cost(1 << n);
    rep(i, (1 << n)) cost[i] = (1 << 30);
    rep(i, m) 
    {
        q.emplace(-key[i].first, key[i].second);
        cost[key[i].second] = key[i].first;
    }
    while(!q.empty())
    {
        auto next = q.top();
        q.pop();
        int v = next.second;
        if( v == all )
        {
            cout << -next.first << endl;
            return 0;
        }
        if( cost[v] < -next.first ) continue;
        rep(i, m)
        {
            if( (v & key[i].second) == key[i].second ) continue;
            int nextv = (v | key[i].second);
            if( -next.first + key[i].first >= cost[nextv] ) continue;
            cost[nextv] = -next.first + key[i].first;
            q.emplace(-cost[nextv], nextv);
        }
    }
    cout << -1 << endl;
    return 0;    
}

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

int main() {
    ll n;
    cin >> n;
    string str;
    set<string> s;

    for (int i = 0;i < n;i++) {
        cin >> str;
        s.insert(str);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 19116
#include<bits/stdc++.h>
using namespace std;
//int t[1000000],x[1000000],y[1000000];
int main(){
    int n;
    cin >> n;
    int sum = 0;
    int t,x,y;
    for(int i=0;i<n;i++){
        //cin >> t[i] >> x[i] >> y[i];
        cin >> t >> x >> y;
        int sum = x + y;
        if(t%2==0 && sum%2==1){
            cout << "No" << endl;
            return 0;
        }else if(t%2==1 && sum%2==0){
            cout << "No" << endl;
            return 0;
        }else if(abs(x) + abs(y) > t){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

int main(){
    while(1){
        int n; cin >> n;
        if(n == 0) break;
        vector<vector<bool>> exist(5001, vector<bool>(5001, false));
        vector<int> x(n), y(n);
        for(int i=0; i<n; i++){
            cin >> x[i] >> y[i];
            exist[x[i]][y[i]]=true;
        }
        ll res=0;
        for(int i=0; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                int dx, dy;
                dx=x[i]-x[j];
                dy=y[i]-y[j];
                int x1=-dy+x[i], y1=dx+y[i];
                int x2=-dy+x[j], y2=dx+y[j];
                if(x1<0 || x1>5000 || y1<0 || y1>5000) continue;
                if(x2<0 || x2>5000 || y2<0 || y2>5000) continue;
                if(exist[x1][y1] && exist[x2][y2]){
                    res=max(res, (ll)dx*dx+dy*dy);
                }
                x1=dy+x[i], y1=-dx+y[i];
                x2=dy+x[j], y2=-dx+y[j];
                if(x1<0 || x1>5000 || y1<0 || y1>5000) continue;
                if(x2<0 || x2>5000 || y2<0 || y2>5000) continue;
                if(exist[x1][y1] && exist[x2][y2]){
                    res=max(res, (ll)dx*dx+dy*dy);
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}




Measured memory_bytes: 6240
#include<bits/stdc++.h>
using namespace std;
vector<int> v[210];
bool vis[210];
int dep[210];
inline void dfs(int np)
{
	vis[np]=1;
	for(int x:v[np])
	{
		if(vis[x])
		{
			if(dep[x]==dep[np])
			{
				puts("-1");
				exit(0);
			}
		}
		else
		{
			dep[x]=dep[np]^1;
			dfs(x);
		}
	}
}
int n,ans=0;
void bfs(int st)
{
	memset(vis,0,sizeof(vis));
	memset(dep,0,sizeof(dep));
	queue<int> q;
	vis[st]=1;
	q.push(st);
	dep[st]=1;
	while(!q.empty())
	{
		int fr=q.front();q.pop();
		for(int x:v[fr])
		{
			if(!vis[x])
			{
				dep[x]=dep[fr]+1;
				vis[x]=1;
				q.push(x);
			}
		}
	}
	for(int i=1;i<=n;i++)ans=max(ans,dep[i]);
}
char s[210][210];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=n;j++)
		{
			if(s[i][j]=='1')v[i].push_back(j);
		}
	}
	dfs(1);
	for(int i=1;i<=n;i++)bfs(i);
	printf("%d\n",ans);
	return 0;
}

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

/**
 * Created by Ayushi on 14 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int x = Integer.parseInt(st.nextToken());
        int y = Integer.parseInt(st.nextToken());
        br.close();

        if (((y % 2) == 0) && ((x - ((y - (2 * x)) / 2)) >= 0) && ((2*x) <= y)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 32492
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int n, m, d;

signed main()
{
	cin >> n >> m >> d;

	int a = (n - d) * 2 * (m - 1);

	if (d == 0) a /= 2;

	int b = pow(n, 2);

	double ans = a / (double)b;

	cout << fixed << setprecision(10);
	cout << ans << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;



int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int> >a(h,vector<int>(w));
    rep(i,h)rep(j,w)cin>>a[i][j];
    vector<pair<P,P> >sousa;
    rep(i,h-1){
        rep(j,w){
            if(a[i][j]%2==0)continue;
            a[i+1][j]+=a[i][j];
            sousa.push_back({{i+1,j+1},{i+2,j+1}});
        }
    }
    rep(j,w-1){
        if(a[h-1][j]%2==0)continue;
        a[h-1][j+1]+=a[h-1][j];
        sousa.push_back({{h,j+1},{h,j+2}});
    }
    int n = sousa.size();
    cout << n << endl;
    rep(i,n){
        int X1,X2,Y2,Y1;
        Y1 = sousa[i].first.first;
        X1 = sousa[i].first.second;
        Y2 = sousa[i].second.first;
        X2 = sousa[i].second.second;
        printf("%d %d %d %d\n",Y1,X1,Y2,X2);
    }
    return 0;
}


Measured memory_bytes: 6372
def divide_h(h, w):
    min_diff = 1e12
    for x in range(1, h):
        h_rem = h - x
        s_A = x * w

        # vertical devide
        w1 = w // 2
        s_B = w1 * h_rem
        s_C = (w - w1) * h_rem

        tmp = max(s_A, s_B, s_C) - min(s_A, s_B, s_C)
        if min_diff > tmp:
            min_diff = tmp

        # horizontal devide
        h1 = h_rem // 2
        s_B = w * h1
        s_C = w * (h_rem - h1)
        tmp = max(s_A, s_B, s_C) - min(s_A, s_B, s_C)
        if min_diff > tmp:
            min_diff = tmp

    return min_diff



H, W = map(int, input().split())

a1 = divide_h(H, W)
a2 = divide_h(W, H)

print(min(a1, a2))

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void)
{
  int N; cin>>N;
  int ans = 0;
  for(int i=0;i<N;i++){
    int l,r; cin>>l>>r;
    ans+=(r-l+1);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int H,W;
string s[30][30];
string tmp = "snuke";
bool flag;
int main()
{
	scanf("%d%d",&H,&W);
	flag = false;
	for(int i=1;i<=H;i++)
	for(int j=1;j<=W;j++)
	{
		cin>>s[i][j];
		if(flag)continue;
		if(s[i][j] == tmp)
		{
			char y = j+'A'-1;
			int x = i;
			printf("%c%d",y,x);
			flag = true;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# include <iostream>

using namespace std;

int main()
{
	int N, D, X;
	int A[100] = {0};

	cin >> N;
	cin >> D >> X;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int num = X;
	int count[100] = {0};

	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= D; j += A[i]) {
			count[i]++;
		}
	}

	for (int i = 0; i < N; i++) {
		num += count[i];
	}

	cout << num << '\n';
}

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



namespace Test1 {

    

    class ClassMain {



        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                string[] strs = line.Split(' ');
                int[] inputs = strs.Select(int.Parse).ToArray();
                if (inputs[0] < 0) { break; }
                Console.WriteLine(
                    dayCount_from000(inputs[3],inputs[4],inputs[5])-
                    dayCount_from000(inputs[0],inputs[1],inputs[2])
                    );
            }
        }


        public static int dayCount_from000(int y, int m, int d) {
            int count=0;
            for (int i = 0; i < y; i++) {
                count += (isUruu(i)) ? 366 : 365;
            }
            for (int i = 1; i < m; i++) {
                if (i == 2) { count += (isUruu(y)) ? 29 : 28; }
                else if (i == 1 || i == 3 || i == 5 ||
                    i == 7 || i == 8 || i == 10 || i == 12) {
                    count += 31;
                }
                else { count +=30;}
            }
            count += d;
            //Console.WriteLine(count);
            return count;
        
        }

        public static bool isUruu(int year) {
            if (year % 400 == 0) { return true; }
            if (year % 100 == 0) { return false; }
            if (year % 4 == 0) { return true; }
            return false;
        }



    }

    
}

Measured memory_bytes: 5948
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int a[200000];
int val;

signed main(){
	int h, n;
	cin >> h >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		val += a[i];
	}
	if(val >= h)cout << "Yes" << endl;
	else cout << "No" <<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int main(void){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(b >= c){
	printf("delicious\n");
	} else if (b + a < c){
	printf("dangerous\n");
	} else {
	printf("safe\n");
	}
	return 0;
}

Measured memory_bytes: 128
a, b, c, d = map(int, input().split())

takahashi = a // d
aoki = c // b

if a%d != 0 :
    takahashi += 1
else :
    takahashi += 0

if c%b != 0 :
    aoki += 1
else :
    aoki += 0

if takahashi >= aoki :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



int main(){

double A,B;
cin>>A>>B;
double tmp1,tmp2;
tmp1 = A/0.08;
tmp2 = B/0.1;

double tt = max(tmp1,tmp2);

ll atari = (ll)(tt+1);

ll ans=-1;
for(ll i=0;i<40;i++){
ll tar = atari-i;
if((ll)(tar*0.08)==A&&(ll)(tar*0.1)==B){
    ans = tar;
}

}

cout<<ans<<endl;

}


Measured memory_bytes: 256
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
d={}
d[4]=a=h//2*(w//2)
d[1]=b=h%2and w%2
d[2]=(h*w-a*4-b)//2
for i in map(s.count,set(s)-{'\n'}):
  for j in(4,2,1):
    while d[j]and i>=j:
      i-=j
      d[j]-=1
print('YNeos'[sum(d.values())>0::2])

Measured memory_bytes: 3064
N, K = map(int, input().split())
ans = 0
for p in range(K+1, N+1):
  k = N//p
  l = N%p
  a = k*(p-K)+ max(l-K+1,0)
  if(K == 0):
    a -= 1
  ans += a
print(ans)

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


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


Measured memory_bytes: 3764
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int n,m,ans=0,cnt=1;
string s;
int main(){
    scanf("%d%d",&n,&m);
    cin>>s;
    char pre=s[0];
    for(int i=1;i<n;i++){
        if(s[i]==pre)ans++;
        else pre=s[i],cnt++;
    }

    if(cnt-m*2>=1)cnt-=m*2;
    else cnt=1;
    printf("%d\n",n-cnt);
    return 0;
}

Measured memory_bytes: 3348