akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int abs(int a){
  if(a >= 0) return a;
  else return -a;
}

int min(int a,int b){
  if(a >= b) return b;
  else return a;
}

int main(){
  int n;
  scanf("%d\n",&n);
  int h[n];
  for(int i = 0; i < n; ++i) scanf("%d", &h[i]);
  int cost = 0, tmp = 0, tmp2;
  if(n == 2) cost = abs(h[0] - h[1]);
  else if(n > 2){
    for(int i = 1; i < n; ++i){//i番目(足場i+1)の総和コスト
      if(i == 1) cost = abs(h[0] - h[1]);
      else if(i > 1){
        tmp2 = cost;
        cost = min(cost + abs(h[i] - h[i-1]), tmp + abs(h[i] - h[i-2]));
        tmp = tmp2;
      }
    }
  }
  printf("%d\n", cost);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;

cc N, K, Ans = 3000, i, j, k, D, X[2], sub, L, R;
cc judge=0, judge2 = 0, judge3 = 0;

string S;


int main() {
	cin >> L >> R;
	K = R - L;
	if (K < 2019) {
		for (i = L; i <= R - 1; i++) {
			for (j = i + 1; j <= R; j++) {
				judge = (i*j) % 2019;
				if (Ans > judge)
					Ans = judge;
			}
		}
	}
	else
		Ans = 0;

	cout << Ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] l = new int[6];
            for (int i = 0, s; i < 6; l[i++] = sc.nextInt())
                ;
            if (l[0] == 0) {
                break;
            }
            int[] count = new int[3];
            for (int i = 0; i < 3; i++) {
                int q = 1;
                do {
                    q = l[i * 2] * q % l[i * 2 + 1];
                    count[i]++;
                } while (q != 1);
            }
            long t = count[0] * count[1] / g(count[0], count[1]);
            System.out.println(t * count[2] / g(t, count[2]));
        }
    }

    static long g(long x, long y) {
        return y == 0 ? x : g(y, x % y);
    }
}




Measured memory_bytes: 27480
def solve(string):
    n, *a = map(int, string.split())
    a = [0] + a + [0]
    base = sum([abs(j - i) for i, j in zip(a, a[1:])])
    ans = []
    for i in range(1, n + 1):
        if min(a[i - 1], a[i + 1]) <= a[i] <= max(a[i - 1], a[i + 1]):
            ans.append(str(base))
        elif max(a[i - 1], a[i + 1]) < a[i]:
            ans.append(str(base - 2 * abs(a[i] - max(a[i - 1], a[i + 1]))))
        else:
            ans.append(str(base - 2 * abs(a[i] - min(a[i - 1], a[i + 1]))))
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 16700
S=input()
A="abcdefghijklmnopqrstuvwxyz"
minimum=len(S)//2
for a in A:
    ans_max=0
    p=0
    for s in S:
        if a==s:
            ans_max=max(p,ans_max)
            p=0
        else:
            p+=1
    ans_max=max(p,ans_max)
    minimum=min(ans_max,minimum)
print(minimum)

Measured memory_bytes: 3060
N,M,V,P = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i).sort

require 'pp'
PP.pp [N,M,V,P], STDERR
PP.pp A, STDERR
def check a
  return true if a >= A[-P]
  return false if A[-P] > a + M
  if V <= P
    return A[-P] <= a + M
  end

  point = (V-P) * M
  skip_self = false
  A[0,A.size - (P - 1)].each do |aa|
    if aa == a && !skip_self
      skip_self = true
      next
    end
    if aa <= a
      point -= M
    elsif aa > a && (a+M) > aa
      point -= (a+M-aa)
    end
    return true if point <= 0
  end
  return true if point <= 0
  return point <= 0
end
line = A.bsearch{|a| check a }
puts A.find_all{|a| a >= line}.size

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

int func(vector<int>arr,int n,int k,int minv)
{
    vector<int>dp(k+1,1);

    for(int i=0;i<minv;i++)
    dp[i]=0;

    for(int i=minv;i<=k;i++)
    {
        for(int p=0;p<n;p++)
        {
           if(arr[p] <= i)
           {    
                int rem = i - arr[p];
                dp[i] = dp[i] & dp[rem];
                // if(dp[rem]==0) dp[i]=1;
           }
        }
        dp[i]=!dp[i];
    }

    return dp[k];
}

int main() {
    
    int n,k;  cin>>n>>k;
    vector<int>arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    int minv = *min_element(arr.begin(),arr.end());
    int ans = func(arr,n,k,minv);
    if(ans==1) cout<<" First "<<endl;
    else cout<<" Second "<<endl;
}


Measured memory_bytes: 3768
#include <iostream>

using namespace std;

using ull = unsigned long long;

int main(void)
{
  ull x;
  cin >> x;
  auto ans = 2 * (x / 11);
  x %= 11;
  ans += x > 6 ? 2 : x > 0 ? 1 : 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N;
int A[200005];
int l,r,xo;
long long rez;
int main()
{cin >> N;
for(int i = 1;i <= N;i++){
cin >> A[i];}
l = 1;
xo = 0;
for(int r = 1;r <= N;r++){
while(xo & A[r]){
xo ^= A[l];
l++;}
xo ^= A[r];
rez += r - l + 1;}
cout << rez;
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    string s;
    cin>>t;
    cin>>s;
    if(t >= (int)s.size())
    {
        cout<<s;
    }
    else
    {
        for(int i = 0; i < t; i++)
        {
            cout<<s[i]<<"";
        }
        cout<<"...";
    }
    
}

Measured memory_bytes: 3616
using System;

namespace B___Harshad_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var n = int.Parse(input);
            var f = 0;
            for (var i = 0; i < input.Length; i++)
            {
                f += int.Parse(input.Substring(i, 1));
            }
            if (n % f == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>
int main(void){
    int n,m,x[101],y[101];
    int i,j,max,min;
    scanf("%d %d %d %d",&n,&m,&x[0],&y[0]);
    max = x[0];
    min = y[0];
    for(i=1;i<=n;i++){
      scanf("%d",&x[i]);
      if(max<x[i])max=x[i];
    }
    for(i=1;i<=m;i++){
      scanf("%d",&y[i]);
      if(min>y[i])min=y[i];
    }
    printf(max<min?"No War":"War");
    return 0;
}


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


int main() {
  int N,K;
  cin >> N >> K;
  
  vector<int> vec(N);
 
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  int sum = 0;
  int i = 0;  
 
  while (i < K) {
    sum += vec.at(i);
    i++;
  }
  
  cout << sum <<endl;
}


Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        a: chars,
        b: chars,
    );
    if a.len() > b.len() {
        println!("GREATER");
        return;
    }
    else if a.len() < b.len() {
        println!("LESS");
        return;
    }

    for i in 0..a.len() {
        if a[i] > b[i] {
            println!("GREATER");
            return;
        }
        else if a[i] < b[i] {
            println!("LESS");
            return;
        }
    }
    println!("EQUAL");
}

fn main() {
    solve();
}

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

int main()
{
    string s;
    cin >> s;
    int j, k;
    int arr[s.length()];
    for(int i=0; i<s.length(); i++)
        arr[i] = 0;
    for(int i=0; i<s.length(); )
    {
        j = i;
        while(s[j] != 'L' && j < s.length())
            j++;
        int nr  = j-i;
        /// Count number of R's
        if(nr % 2 == 0)
        {
            /// If R's is even
            arr[j] += 1 + nr/2;
            arr[j-1] += 1 + (nr-1) -nr/2;
        }
        else
        {
            /// If R's is odd
            arr[j] += 1 + (nr-1) -nr/2;
            arr[j-1] += 1 + nr/2;
        }
        k = j;
        while(s[k] != 'R' && k < s.length())
            k++;
        /// Count number of L's
        int nl = k-j;
        if(nl % 2 == 0)
        {
            /// If even number of L's
            arr[j] += (nl-1)-nl/2;
            arr[j-1] += nl/2;
        }
        else
        {
            arr[j] += nl/2;
            arr[j-1] += (nl-1)-nl/2;
        }
        i = k;
    }
    for(int i=0; i<s.length(); i++)
        cout<<arr[i]<<" ";
}


Measured memory_bytes: 1024
#159 d bannedK
n=int(input())
a=list(map(int,input().split()))

bunpu=dict()
for x in a:
    if x not in bunpu:
        bunpu[x]=1
    else:
        bunpu[x]+=1
    
def choose2(num):
    return num*(num-1)//2

total=0
for value in bunpu.values():
    total+=choose2(value)
for x in a:
    ans=total
    ans-=choose2(bunpu[x])
    ans+=choose2(bunpu[x]-1)
    print(ans)
    






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

using namespace std; 

const int maxn = 1e6; 

int n; 
vector <int> G[maxn + 5]; 
int a[maxn + 5], dep[maxn + 5], f[maxn + 5], b[maxn + 5], fa[maxn + 5]; 
int siz[maxn + 5]; 

void dfs1(int u, int pre) { 
  for (auto v : G[u]) {
    if (v == pre) continue ; 
    fa[v] = u; 
    dfs1(v, u); 
  }
}

void dfs(int u, int pre) {
  int mx = 0; 
  siz[u] = 0; 
  int p = 0; 
  for (auto v : G[u]) {
    if (v == pre) continue ; 
    dep[v] = dep[u] + 1; 
    dfs(v, u); 
    mx = max(mx, siz[v]); 
    siz[u] += siz[v];
    if (siz[v] > siz[p]) {
      p = v; 
    } 
  }
  if (mx * 2 <= siz[u]) {
    f[u] = siz[u] / 2; 
  }
  else {
    f[u] = siz[u] - mx + min(f[p], (2 * mx - siz[u]) / 2); 
  } 
  siz[u] += b[u];  
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%1d", &a[i]); 
  } 
  for (int i = 1; i < n; i++) {
    int u, v; 
    scanf("%d %d", &u, &v); 
    G[u].push_back(v); 
    G[v].push_back(u); 
  }
  int ans = 1e9; 
  for (int i = 1; i <= n; i++) {
    int sumd = 0; 
    dep[i] = 0; 
    for (int j = 1; j <= n; j++) b[j] = 0; 
    dfs1(i, 0);  
    for (int j = 1; j <= n; j++) {
      if (a[j] == 1) {
        int x = j; 
        while (x != i) {
          b[x]++; 
          x = fa[x]; 
        }
      }
    }
    dfs(i, 0);  
    for (int j = 1; j <= n; j++) {
    //  if (b[j])
      sumd += b[j];  
    }
//    cout << sumd << endl; 
    if (sumd / 2 == f[i] && sumd % 2 == 0) {
      ans = min(ans, f[i]); 
  //    cout << i << endl; 
    }
  }
  if (ans == 1e9) ans = -1; 
  cout << ans << endl; 
  return 0; 
}

Measured memory_bytes: 35072
public class Main {
	public static void main(String[] args){
		int S = new java.util.Scanner( System.in).nextInt();
		int h,m,s;
		h = S/3600;
		m = (S%3600)/60;
		s = (S%3600)%60;
		System.out.println(h + ":" + m + ":" +s);
	}

}

Measured memory_bytes: 26072
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
     int n,m,k;
     string s[8];
     cin>>n>>m>>k;
     for(int i=0;i<n;i++)
     cin>>s[i];
     int ans=0;
     for(int i=0;i<(1<<n);i++)
     {
         for(int j=0;j<(1<<m);j++)
         {
             int sum=0;
             for(int x=0;x<n;x++)
                for(int y=0;y<m;y++)
             {
                 if(!((1<<x)&i)&&!((1<<y)&j)&&s[x][y]=='#')
                    ++sum;
             }
             if(sum==k)
             ++ans;
         }
     }
     cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    string S, T;
    cin >> S >> T;
    if (S.size() + 1 == T.size()) {
        for (int i = 0; i < S.size(); i++) {
            if (S[i] != T[i]) {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3624
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let _n = read_i64();
    let xs = read_vec_i64();
    let ys = read_vec_i64();
    let xs_sum: i64 = xs.iter().sum();
    let ys_sum: i64 = ys.iter().sum();
    let times = ys_sum - xs_sum;
    if times < 0 {
        println!("No");
        return;
    }
    let mut a = 0;
    let mut b = 0;
    for (&x,&y) in xs.iter().zip(ys.iter()) {
        if x < y {
            if (y-x)%2 == 0 {
                a += (y-x)/2;
            }
            else {
                a += (y-x)/2;
                a += 1;
                b += 1;
            }
        }
        if x > y {
            b += x-y;
        }
    }
    if a > times || b > times || (times-a)*2 != (times-b) {
        println!("No");
    }
    else {
        println!("Yes");
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<vll> p(n, vll(2)), q(n, vll(2));
  for (ll i = 0; i < n; i++) {
    cin >> p[i][0] >> p[i][1];
    q[i][0] = p[i][1];
    q[i][1] = p[i][0];
  }
  sort(all(p));
  sort(all(q));
  ll ans = inf;
  for (ll i = 0; i + k - 1 < n; i++) {
    for (ll j = i + k - 1; j < n; j++) {
      vector<vll> v;
      for (ll l = i; l <= j; l++) {
        v.push_back(p[l]);
        swap(v.back()[0], v.back()[1]);
      }
      sort(all(v));
      for (ll m = 0; m + k - 1 < v.size(); m++) {
        ll xmax = -1e9, xmin = 1e9, ymax = -1e9, ymin = 1e9;
        for (ll r = 0; r < k; r++) {
          xmax = max(xmax, v[m + r][0]);
          xmin = min(xmin, v[m + r][0]);
          ymax = max(ymax, v[m + r][1]);
          ymin = min(ymin, v[m + r][1]);
        }
        ans = min(ans, (xmax - xmin) * (ymax - ymin));
      }
    }
  }
  for (ll i = 0; i + k - 1 < n; i++) {
    for (ll j = i + k - 1; j < n; j++) {
      vector<vll> v;
      for (ll l = i; l <= j; l++) {
        v.push_back(q[l]);
        swap(v.back()[0], v.back()[1]);
      }
      sort(all(v));
      for (ll m = 0; m + k - 1 < v.size(); m++) {
        ll xmax = -1e9, xmin = 1e9, ymax = -1e9, ymin = 1e9;
        for (ll r = 0; r < k; r++) {
          xmax = max(xmax, v[m + r][0]);
          xmin = min(xmin, v[m + r][0]);
          ymax = max(ymax, v[m + r][1]);
          ymin = min(ymin, v[m + r][1]);
        }
        ans = min(ans, (xmax - xmin) * (ymax - ymin));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, M = map(int, input().split())
m = {}

for i in range(M):
    s, c = map(int, input().split())
    # sc.append(list(map(int, input().split())))
    if s in m and m[s] != c:
        print(-1)
        exit()
    else:
        m[s] = c

# print(m)

def isValid(x):
    # print(x)
    if len(str(x)) != n:
        return False
    if len(str(x)) > n:
        print(-1)
        exit()

    # print(x)
    for i in range(n):
        val = int(str(x)[i])
        # print(i, val)
        if i+1 not in m:
            continue
        elif val != m[i+1]:
            return False
    return True

for i in range(10**(n+1)):
    if isValid(i):
        print(i)
        exit()

print(-1)

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

int inputint(void){int n;cin>>n;return n;}
string inputstring(void){string s;cin>>s;return s;}
vector<int> inputvecint(int n){vector<int> vec(n);for(int i=0;i<n;i++)cin>>vec.at(i);return vec;}

int main(){
  int N=inputint();
  vector<int> a=inputvecint(N);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  int A=0,B=0;
  for(int i=0;i<N;i++){
    if(i%2==0) A+=a.at(i);
    else B+=a.at(i);
  }
  cout << A-B << endl;
  return 0;
}

Measured memory_bytes: 256
//To include everything you need
#include <bits/stdc++.h>
using namespace std;
typedef std::vector<int>  vi;
typedef std::vector<std::pair<int,int> > vpi;
typedef std::vector<string>  vs;
typedef std::vector<char>  vc;


int main(){

    long  n;
    int triangles = 0;
    cin>>n;
    vector<int> stickLength(n);

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

    std::sort(stickLength.begin(),stickLength.end(),std::greater<int>());
    for(int i =0;i<n-2; i++){
        for(int j=i+1;j<n-1;j++){
            for(int k =j+1;k<n;k++){
            int stick1 = stickLength[i];
            int stick2 = stickLength[j];
            int stick3 = stickLength[k];
            if(stick1<stick2 + stick3)
                triangles++;
            else
                break;
            }    
        }
    }
    cout<<triangles;

}

Measured memory_bytes: 384
//f[i]=min(f[i],f[i-a[j]]+1)
#include <bits/stdc++.h>
using namespace std;
int a[100001]={0},f[100001];
int init()
{
	a[1]=1;
	a[2]=6;
	a[3]=9;
	memset(f,1,sizeof(f));
	f[0]=0;
}
int main()
{
	int n,sum=6,pos=4,x=3,i,j;
	scanf("%d",&n);
	init();
	while(sum<=n)
	{
		sum*=6;
		if(sum<=n)
		{
			a[pos++]=sum;
			x++;
		}
	}
	sum=9;
	while(sum<=n)
	{
		sum*=9;
		if(sum<=n)
		{
			a[pos++]=sum;
			x++;
		}
	}
	sort(a+1,a+1+x);
	for(i=0;i<=n;i++)
		for(j=1;j<=x&&i-a[j]>=0;j++)
			f[i]=min(f[i],f[i-a[j]]+1);
	printf("%d",f[n]);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n,a,b;

	cin >> n >> a >> b;

	if (a > b)
	{
		cout << 0 << endl;
	}else if (a == b)
	{
		cout << 1 << endl;
	}else
	{
		if (n == 1)
		{
			cout << 0 << endl;
		}else
		{
			lld x = (n-2) * b;
			lld y = (n-2) * a;
			cout << x - y + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import math
N, H = map(int, input().split())

A = []
B = []
attack = []
used = [0 for i in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    attack += [[a, 0], [b, 1]]

attack.sort()
attack = attack[::-1]
count = 0
for i in range(N*2):
    if H <= 0:
        print(count)
        exit()
    if attack[i][1] == 0:
        print(count + math.ceil(H/attack[i][0]))
        exit()
    H -= attack[i][0]
    count += 1


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

typedef long long ll;
const int N = 3005;
int n, m, g[N][N], c[N][N];

int read() {
	int w = 0; char ch = getchar();
	while(ch > '9' || ch < '0') ch = getchar();
	while(ch <= '9' && ch >= '0') {
		w = w * 10 + ch - 48;
		ch =getchar();
	}
	return w;
}
int fpow(int a, int m, int MOD) {
	int ans = 1;
	for(; m; m >>= 1) {
		if(m & 1) ans = ans * 1ll * a % MOD;
		a = a * 1ll * a % MOD;
	}
	return ans;
}

int main() {
    n = read(); m = read();
    for(int i = 0; i <= n; i++) {
        g[i][0] = c[i][0] = 1;
    	for(int j = 1; j <= i; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % m;
            g[i][j] = (g[i - 1][j - 1] + (j + 1) * 1ll * g[i - 1][j] % m) % m;
    	}
    }
    ll ans = 0;
    for(int i = 0; i <= n; i++) {
    	int powp = fpow(2, fpow(2, n - i, m - 1), m);
    	int d = fpow(2, n - i, m), q = 1, f = 0;
    	for(int j = 0; j <= i; j++) f = (f + g[i][j] * 1ll * q % m) % m, q = q * 1ll * d % m;
        if(i & 1) {
        	ans = (ans + (m - c[n][i]) * 1ll * f % m * powp % m) % m;
        } else ans = (ans + c[n][i] * 1ll * f % m * powp % m) % m;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int n,m,f[100010],dis[100010],siz[100010],a[100010],A,B,C;

void find(int x)
{
	if (f[x]!=x)  find(f[x]),dis[x]^=dis[f[x]],f[x]=f[f[x]];
}

void work()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=n; i++)  f[i]=i,siz[i]=1;
	for (int i=1,u,v;	i<=m; i++)
		{
			scanf("%d %d",&u,&v),find(u),find(v);
			if (f[u]!=f[v])
				siz[f[u]]+=siz[f[v]],a[f[u]]|=a[f[v]],dis[f[v]]=dis[v]^1,f[f[v]]=u;
			else  a[f[u]]|=dis[u]^dis[v]^1;
		}	
	for (int i=1; i<=n; i++)
		if (f[i]==i)  (siz[i]==1?A:a[i]?C:B)++;
	printf("%lld",1LL*A*A+2LL*A*(n-A)+2LL*B*(B+C)+1LL*C*C);
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define lli long long int 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> a;
    vector<int> b;
    int n;
    cin>>n;
    a.resize(n);
    b.resize(n-1);
    int i,j;
    int ans = 0;
    for(i=0;i<(n-1);i++)
        cin>>b[i];
    a[0] = b[0];
    a[n-1] = b[n-2];
    for(i=1;i<(n-1);i++)
    {
        a[i] = min(b[i],b[i-1]);
    }
    for(i=0;i<n;i++)
        ans = ans + a[i];
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	int Four = 0, Odd = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0) Four++;
		else if (a % 2 != 0) Odd++;
	}
	cout << (Four >= Odd || (Four + 1 == Odd && Four + Odd == N) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    while (1) {
        int n;
        cin>>n;
        if(n==0)break;
        int x,y,h,w;
        int ans=0;
        for (int i=0; i<n; i++) {
            cin>>x>>y>>h>>w;
            int a=x+y+h;
            if(a<=60&&w<=2)ans+=600;
            else if(a<=80&&w<=5)ans+=800;
            else if(a<=100&&w<=10)ans+=1000;
            else if(a<=120&&w<=15)ans+=1200;
            else if(a<=140&&w<=20)ans+=1400;
            else if(a<=160&&w<=25)ans+=1600;
            
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3080
if __name__ == '__main__':
    N = input()
    if len(N) == 1:
        print(N)
    else:
        cand_1 = sum([int(_) for _ in N])
        cand_2 = 9 * (len(N) - 1) + int(N[0]) - 1

        if cand_1 > cand_2:
            print(cand_1)
        else:
            print(cand_2)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
#define Graph vector<vector<int>>
using namespace std;

vector<bool> seen;

void dfs(Graph &F,int v)
{
        seen[v]=true;
        for(auto next_v:F[v])
        {
                if(seen[next_v])continue;
                dfs(F,next_v);
        }
}

main()
{
        int n,m; cin>>n>>m;
        Graph G(n);
        vi a(m),b(m);
        int ans=0;
        rep(i,m)
        {
                cin>>a[i]>>b[i];
                a[i]--; b[i]--;
                G[a[i]].push_back(b[i]);
                G[b[i]].push_back(a[i]);
        }

        rep(i,m)
        {
                Graph F(n);
                rep(j,m)
                {
                        if(i==j)continue;
                        F[a[j]].push_back(b[j]);
                        F[b[j]].push_back(a[j]);
                }
                seen.assign(n,false);
                dfs(F,0);
                for(auto it:seen)
                {
                        if(!it)
                        {
                                ans++;
                                break;
                        }
                }
        }
        cout<<ans<<endl;
}

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

bool rotateMatrix(char mat[][3]) 
{ 
   if(mat[0][0]==mat[1][2]&&mat[0][1]==mat[1][1]&&mat[0][2]==mat[1][0])
   	return true;
   return false;
} 

int main()
{
	char a[2][3];
	
	for(int i=0;i<2;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	
	if(rotateMatrix(a))
		cout<<"YES";
	else
		cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
odd = [i for i in range(1, n+1, 2)]
[[a * b for a in range(1, 4)] for b in range(1, 4)]
yakusu_list = [[i for i in odd if j%i == 0] for j in odd]
c = len([i for i in yakusu_list if len(i) == 8])
print(c)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
using namespace std;
int a, b, c;
int main() {
    cin >> a >> b >> c;
    if(b-a==c-b) cout <<"YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
	int n,T,i,ans=10000;
	cin>>n>>T;
	int c,t;
	for(i=0;i<n;i++){
		cin>>c>>t;
		if(T>=t){
			ans=min(ans,c);
		}
	}
	if(ans==10000)cout<<"TLE\n";
	else cout<<ans<<endl;
}
/*reveres begin end
cout<<"\n";
  m.insert(std::make_pair('c', 30));
*/


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

using namespace std;
typedef complex<double> xy_t;

const double eps= 0.000000000001;
double x[4], y[4];
int N;
int main(){
  cin >> N;
  for(int t= 0; t<N; ++t){
    for (int i = 0; i < 4; ++i) cin >> x[i] >> y[i];
    xy_t a[2]={xy_t(x[0],y[0])-xy_t(x[1],y[1]), xy_t(x[2],y[2])-xy_t(x[3],y[3])};
    xy_t x=a[0],y=a[1];
    bool p = abs(x.real()*y.imag()-x.imag()*y.real()) < eps;
    cout << ( p ? "YES" : "NO" ) << endl ;
  }

}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
  int N = inputValue();
  double s = 1.0 - (N/2) * 1.0 / N;
  cout << setprecision(8) << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> solve(int a, int b, int n)
{
	if(n == 0) return vector<int> {a, b};
	int x = a ^ b;
	vector<int> ret;
	if(x & (1 << n))
	{
		auto lret = solve(a, a ^ 1, n - 1);
		auto rret = solve(a ^ 1 ^ (1 << n), b, n - 1);
		for(auto v : lret) ret.push_back(v);
		for(auto v : rret) ret.push_back(v);
		return ret;
	}
	else
	{
		auto sret = solve(a, b, n - 1);
		auto dret = solve(sret[0] ^ (1 << n), sret[1] ^ (1 << n), n - 1);
		ret.push_back(sret[0]);
		for(auto v : dret) ret.push_back(v);
		for(int i = 1; i < sret.size(); ++i) ret.push_back(sret[i]);
	}
	return ret;
}
int main()
{
	int a, b, n;
	cin >> n >> a >> b;
	if(__builtin_popcount(a ^ b) % 2 == 0)
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	auto ans = solve(a, b, n - 1);
	for(auto v : ans) printf("%d ", v);
	return 0;
}

Measured memory_bytes: 4436
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep4(i, a, b, c) for (int i = int(a), i##__b = int(b), i##__c = int(c); i < i##__b; i += i##__c)
#define rep1(n) rep4(i, 0, n, 1)
#define rep2(i, n) rep4(i, 0, n, 1)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define REP(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep3(i, a, b) for (int i = int(b) - 1, i##__a = int(a); i >= i##__a; i--)
#define rrep1(n) rrep3(i, 0, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep4(i, a, b, c) for (int i = int(a + (b - a - 1) / c * c), i##__a = int(a), i##__c = int(c); i >= i##__a; i -= i##__c)
#define RREP(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define FOR(i, x) for (auto &i : x)
#define ALL(v) (v.begin()), (v.end())
#define pb(x) emplace_back(x)
#define mp(x, y) make_pair(x, y)
#define mt make_tuple
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using vstring = vector<string>;
template <class T> using vec = vector<T>;
template <class T> using vv = vector<vector<T>>;
template <class T> using pq = priority_queue<T>;
template <class T> using rpq = priority_queue<T, vector<T>, greater<T>>;
#define vvint(A, H, W) vvint A(H, vint(W))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const ll LINF = 1e18;
template <class T> bool chmax(T &a, const T &b) {if (a < b) {a = b;return 1;}return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b < a) {a = b;return 1;}return 0;}
template <class T> void print(T x){cout<<x<<endl;}
// clang-format on

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vint C(n);
    vvint(A, n, m);
    REP(n) {
        cin >> C[i];
        FOR(a, A[i]) {
            cin >> a;
        }
    }
    ll ans = LINF;
    REP(b, 1 << n) {
        vll s(m);
        ll t = 0;
        REP(n) {
            if (b & (1 << i)) {
                t += C[i];
                REP(j, m) {
                    s[j] += A[i][j];
                }
            }
        }
        bool ok = 1;
        REP(m) {
            ok &= s[i] >= x;
        }
        if (ok) chmin(ans, t);
    }
    if (ans != LINF)
        print(ans);
    else
        print(-1);
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;

    map<ll, ll> cnt;
    for (ll x = 1; x <= 100; x++) {
        for (ll y = 1; y <= 100; y++) {
            for (ll z = 1; z <= 100; z++) {
                ll num = x*x+y*y+z*z+x*y+y*z+z*x;
                if (num > 10000) break;
                cnt[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }

    for (ll i = 1; i <= N; i++) {
        cout << cnt[i] << "\n";
    }
}

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




























int main () {
    long long N;
    cin >> N;
    long long sum = 0;
    for (long long i = 1; i <= N; i++) {
        sum += i * (N / i) * (N / i + 1) / 2;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3600
sx, sy, tx, ty = map(int, input().split())

print('U' * (ty - sy) + 'R' * (tx - sx) + 'D' * (ty - sy) + 'L' * (tx - sx) + 'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'DR'  + 'D' * (ty - sy + 1) + 'L' * (tx - sx + 1) + 'U')


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
void check(int x);
bool a[12][10010]={{0}};
int ans=1000000;
int co=0,vo=0;
int h;
int w;

int main(void){

	for(;;){
    ans=10000000;
	cin>>h>>w;

	if(h==0&&w==0)break;

	for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
	}
	check(0);

    cout<<h*w-ans<<endl;
	}
	return 0;
}
void check(int x){
    if(x==h){
        vo=0;
        for(int i=0;i<w;i++){
            co=0;
            for(int j=0;j<h;j++){
                co+=a[j][i];
            }
            vo+=min(co,h-co);

        }
        ans=min(ans,vo);

        return;
    }
    //cout<<x<<"+"<<endl;
    check(x+1);

    for(int i=0;i<w;i++){
        if(a[x][i]==0)a[x][i]=1;
        else a[x][i]=0;
        //cout<<a[x][i];
    }
    //cout<<x<<"-"<<endl;
    check(x+1);


}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll md[200005];
ll mdx(ll b, ll e, ll m){
	ll rs=1ll; b=(b%m);
	for(;e>0;){
		if(e%2==1) rs=(rs*b)%m;
		b=(b*b)%m; e/=2;
	}
	return rs;
}
ll cnt[2020];
int main(){
	string s; cin>>s;
	for(int i=s.size()-1; i>=0; i--){
		ll nw=(1ll*(s[i]-'0')*mdx(10ll, (ll)s.size()-1ll-(ll)i, 2019ll))%2019;
		md[i]=(md[i+1]+nw)%2019;
	}
	for(int i=0; i<s.size(); i++)
		cnt[md[i]]++;
	cnt[0]++;
	ll ans=0ll;
	for(int i=0; i<2019; i++)
		ans+=cnt[i]*(cnt[i]-1)/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 5328
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int h, w;
int c1, c2;
int d1, d2;
bool memo[1005][1005];

bool grid_inside(int y, int x) {
  if(0 <= y && y < h && 0 <= x && x < w) return true;
  else return false;
}

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

  cin >> h >> w >> c1 >> c2 >> d1 >> d2;
  vector<string> m;
  c1--; c2--; d1--; d2--;

  REP(i, h) {
    string s;
    cin >> s;
    m.push_back(s);
  }

  priority_queue<pair<int, P>, vector<pair<int, P>>, greater<pair<int, P>>> que;
  ll ans = -1;

  que.push(make_pair(0, P(c1, c2)));
  while(!que.empty()) {
    pair<int, P> p = que.top(); que.pop();
    P c = p.second;
    if(memo[c.first][c.second]) continue;
    if(c.first == d1 && c.second == d2) {
      ans = p.first;
      break;
    }
    memo[c.first][c.second] = true;

    REP(i, 4) {
      int ny = c.first + dy4[i];
      int nx = c.second + dx4[i];
      if(grid_inside(ny, nx) && m[ny][nx] == '.') que.push(make_pair(p.first, P(ny, nx)));
    }

    REP(i, 5) REP(j, 5) {
      int ny = c.first - i + 2;
      int nx = c.second - j + 2;

      if(grid_inside(ny, nx) && m[ny][nx] == '.') que.push(make_pair(p.first + 1, P(ny, nx)));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 8156
from heapq import heappush, heappop
INF = 10**10
a,b,c = map(int,input().split())
d = [[] for i in range(a)]
for i in range(b):
    ta,tb,tc = map(int,input().split())
    d[ta].append((tb,tc))

def dijkstra(N, G, s):
    dist = [INF] * N
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t, cost in G[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                heappush(que, (dist[t], t))
    for i in range(a):
        print(dist[i] if dist[i] < INF else "INF")
dijkstra(a,d,c)




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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

bool dp[85][85][14000];

void Main()
{
    arrayFill(dp, false);
    int h = in(), w = in();

    vvint a(h, vint(w));
    vvint b(h, vint(w));

    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];

    dp[0][0][abs(b[0][0] - a[0][0])] = true;

    rep(i, h) rep(j, w)
    {
        rep(k, 13000)
        {
            if (i < h - 1)
            {
                dp[i + 1][j][abs(k + (b[i + 1][j] - a[i + 1][j]))] |= dp[i][j][k];
                dp[i + 1][j][abs(k + (a[i + 1][j] - b[i + 1][j]))] |= dp[i][j][k];
            }
            if (j < w - 1)
            {
                dp[i][j + 1][abs(k + (b[i][j + 1] - a[i][j + 1]))] |= dp[i][j][k];
                dp[i][j + 1][abs(k + (a[i][j + 1] - b[i][j + 1]))] |= dp[i][j][k];
            }
        }
    }

    rep(i, 13000)
    {
        if (dp[h - 1][w - 1][i])
        {
            cout << i << endl;
            return;
        }
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 99072
S = str(input())
N = len(S)
T1=[]
T2=[]
a=0
b=0
for i in range(N):
  if i%2==1:
  	T1.append('0')
  else:
  	T1.append('1')
for i in range(N):
  if i%2!=1:
  	T2.append('0')
  else:
  	T2.append('1')  
for i in range(N):
  if S[i]!=T1[i]:
    a=a+1
  else:
    a=a
    
for i in range(N):
  if S[i]!=T2[i]:
    b=b+1
  else:
    b=b

if a>b:
  print("%d"% b)
else:
  print("%d"% a)  



Measured memory_bytes: 4860
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a;
    cin >> a;
    if((a/10-9)*(a%10-9)){
      cout << "No";
    }else{
      cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
const uint ege = -1;
 
int main() {
  //部屋数・通路数
  int N,M;
  cin >> N >> M;
  //vector<vector<bool>> pathway(N,vector<bool>(N,false));
  int A,B;
  vector<vector<uint>> pathway(N);
  for(int i=0;i < M;i++){
    cin >> A >> B;
    pathway.at(A-1).push_back(B-1);//.at(B-1) = true;
    pathway.at(B-1).push_back(A-1);//.at(A-1) = true;
  }
  
  
 
  //vector<bool> fixed(N,true);
  //vector<bool> answer1(N,false);
  vector<uint> distan(N,-1);
 
  queue<uint> nextway;
  
  uint convert ;
  for(uint i:pathway.at(0)){
   
    //convert = pathway.at(0).a
     
     distan.at(i)=1;
     nextway.push(i);
     
   
  }
 
  
  uint j;
  
 
  
  
    while(nextway.size()){
     	j=nextway.front();
      
    
      for(uint i:pathway.at(j)){
        
     
     
       	if(distan.at(i)==ege){
          distan.at(i)=j+1;
          nextway.push(i);
        }
      
        
        
          
        
      }
      
      nextway.pop();
    }
    
     bool aflg = true;
  //uint riri = -1;
   for(int i:distan){
    if(i==ege){
     aflg = false;
      break;
    }
   }
  
if (aflg){
  cout << "Yes" << endl;
   
      for(uint x=1;x<N;x++){
        cout << distan.at(x) << endl;
      }
     
    }else{
      cout << "No" << endl;
    }
  
}

Measured memory_bytes: 10236
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(1e5 + 20, 0);
    repeat(i, n) {
        int t;
        cin >> t;
        ++a[t];
        ++a[t+1];
        ++a[t+2];
    }
    sort(a.begin(), a.end(), greater<int>());
    cout << a[0] << endl;
}

Measured memory_bytes: 640
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
N = int(input())
l = make_divisors(N)
l.sort()
if len(l)%2 == 0:
    a = l[(len(l)//2)-1]-1
    b = l[(len(l)//2)]-1
    print(a+b)
else:
    a = l[(len(l)//2)]-1
    print(a*2)


Measured memory_bytes: 3268
"use strict";
const Main = (input) =>{
	let xs = input.trim().split(' ');
    if(xs[0]=="a"||xs[0]=="i"||xs[0]=="u"||xs[0]=="e"||xs[0]=="o"){
    console.log("vowel");
    }else{
    console.log("consonant");
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n,k);
	bool state = (n >= (1 + (k-1) * 2));
	OUT(state?"YES":"NO")BR;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll r; cin>>r;
    ll a = r*r;
    cout << a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

string a, b, c;

int main(void){
    
    cin >> a >> b >> c;
    printf("%c%c%c\n", a[0], b[1], c[2]);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  string s1, s2;
  cin >> s1 >> s2;

  int dp[s1.size() + 1][s2.size() + 1];
  memset(dp, 0, sizeof(dp));
  rep(i, 0, s1.size() + 1) dp[i][0] = i;
  rep(j, 0, s2.size() + 1) dp[0][j] = j;

  rep(i, 0, s1.size()) {
    rep(j, 0, s2.size()) {
      if(s1[i] == s2[j]) {
        dp[i + 1][j + 1] = dp[i][j];
      } else {
        dp[i + 1][j + 1] = min(dp[i][j] + 1, min(dp[i + 1][j] + 1, dp[i][j + 1] + 1));
      }
    }
  }
  cout << dp[s1.size()][s2.size()] << endl;
}



Measured memory_bytes: 7164
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b, k) = in.readLine.split(" ").map(_.toInt)
  val ans = (1 to 100).filter(i => (a%i == 0 && b%i == 0)).reverse(k-1)
  println(ans)
}

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

int main(){
    string S; cin >> S;
    int n=0, w=0, s=0, e=0;
    for(int i=0; i<S.length(); i++){
        if(S.at(i)=='N') n++;
        if(S.at(i)=='W') w++;
        if(S.at(i)=='S') s++;
        if(S.at(i)=='E') e++;
    }
    if((n>0 && w>0 && s>0 && e>0) || (n>0 && w==0 && s>0 && e==0) || (n==0 && w>0 && s==0 && e>0))
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632