akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
	 int n;
	 cin>>n;
	 int a[n];
	 int ans=0;
	 for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>1&&((a[i]>a[i-1]&&a[i-1]>a[i-2])||(a[i]<a[i-1]&&a[i-1]<a[i-2]))){
            ans++;
        }
	 }
	 cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n,count;
	n = sc.nextInt();
	int a[] = new int[n];
	count = 0;
	for(int i = 0;i < n;i++){
	    a[i] = sc.nextInt();
	    while(a[i] % 2 == 0){
		a[i] /= 2;
		count++;
	    }
	}
	System.out.println(count);
    }
}


Measured memory_bytes: 35996
#include<cstdio>
using namespace std;
const int f[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int a,b,Nowa=1,Nowb=1,Ans;
int main(){
	scanf("%d%d",&a,&b);
	while(Nowa^a||Nowb^b){
		if(Nowa==Nowb) Ans++;
		Nowb++;
		if(Nowb>f[Nowa]) Nowa++,Nowb=1;
	}
	Ans+=(a==b);
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 128
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
mx = r1 - r0
mn = min(r1, r0)

for i in map(int, sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
        if 0 > i - mn:
            mn = i
    elif mn > i:
        mn = i

print(mx)

Measured memory_bytes: 19836
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

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

    int n = 3;
    vector<Int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a), greater<>());

    bool isdiv = false;
    for (int i = 0; i < n; i++) {
        isdiv |= !(a[i] & 1);
    }

    if (isdiv) {
        cout << 0 << endl;
    } else {
        cout << a[1] * a[2] << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
def main():
    from math import ceil

    n, *csf = map(int, open(0).read().split())
    csf = list(zip(csf[::3], csf[1::3], csf[2::3]))
    times = []
    for i in range(n):
        time = 0
        for c, s, f in csf[i:]:
            g = time > s
            time = s + int(g) * ceil((time - s) / f) * f + c
        times.append(str(time))

    ans = "\n".join(times)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let [| n; k |] = reada int
    let hs = reada int64 |> Array.sortDescending

    for i in 0 .. (min n k) - 1 do
        hs.[i] <- 0L

    hs
    |> Array.sum
    |> puts
    ()

main()
writer.Close()


Measured memory_bytes: 38464
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  long  int x,y,N,D,count=0;
  scanf("%ld%ld",&N,&D);
  while(N--)
  {
  	scanf("%ld%ld",&x,&y);
    if(sqrt(x*x+y*y)<=(double)D)
    	count++;
  }
  printf("%ld",count);
  return 0;
}

Measured memory_bytes: 3744
#include <iostream>
using namespace std;
int N;
void solve()
{
    int num=0,sum=0;
    while(N--)
    {
        int x;
        cin>>x;
        if (x%4==0) sum++;
        else if (x%4==2) num++;
        else sum--;
    }
    if (sum>=0) cout<<"Yes";
    else if (sum==-1)
    {
        if (num) cout<<"No";
        else cout<<"Yes";
    }
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>N)
        solve();
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(in);
    int n = sc.nextInt();
		int[][] f = new int[n][10];
		long[][] p = new long[n][11];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = sc.nextLong();
			}
		}

		long answer = Long.MIN_VALUE;

		for (int i = 1; i < (1 << 10); i++) {
			long point = 0;
			for (int j = 0; j < n; j++) {
				int cnt = 0;
				for (int k = 9; k >= 0; k--) {
					if (((i >> k) & f[j][9-k]) == 1) {
						cnt++;
					}
				}
				point += p[j][cnt];
			}
			answer = Math.max(answer, point);
		}

		System.out.println(answer);
	}
}


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

namespace ConsoleApp11
{
    class Class6
    {
        public static void Main()
        {
            var I = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            long gcd = GCD(I[0], I[1]);
            int count = 0;
            for(int i = 2; i <= gcd|i==gcd; i++)
            {
                if (gcd % i == 0)
                {
                    count += 1;
                    while (gcd % i == 0)
                        gcd /= i;
                    continue;
                }
                if (i > Math.Ceiling((decimal)gcd / i))
                {
                    count += 1;
                    break;
                }
                    
            }
            Console.WriteLine(count + 1);
        }
        public static long GCD(long a,long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
    }        
}


Measured memory_bytes: 13396
#include <stdio.h>
int max(int a,int b){
  if (a > b) {
    return a;
  }
  return b;
}

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",max(a+b,max(a,b)*2-1));
  return 0;
}


Measured memory_bytes: 128
n = int(input())
lst = []
for i in range(n):
    s = input()
    lst.append(s)
print("AC x " + str(lst.count("AC")))
print("WA x " + str(lst.count("WA")))
print("TLE x " + str(lst.count("TLE")))
print("RE x " + str(lst.count("RE")))

Measured memory_bytes: 16108
S, T = input(), input()
q = int(input())

ls, lt = len(S), len(T)
acs, act = [0]*(ls+1), [0]*(lt+1)

for i in range(1, ls+1):
    acs[i] = acs[i-1] + (S[i-1]=="A")
for i in range(1, lt+1):
    act[i] = act[i-1] + (T[i-1]=="A")

for _ in range(q):
    a, b, c, d = map(int, input().split())
    sa = acs[b]-acs[a-1]
    sb = b-a+1-sa
    ta = act[d]-act[c-1]
    tb = d-c+1-ta
    print("YES" if (2*sa+sb)%3==(2*ta+tb)%3 else "NO")


Measured memory_bytes: 53848
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    long long n, m;
    std::cin >> n >> m;

    UnionFind<long long, 100000> union_find;

    std::vector<long long> ans(m + 1, n * (n - 1) / 2);

    std::vector<std::pair<long long, long long>> pairs(m);

    for (int i = 0; i < m; i++) {
        std::cin >> pairs[i].first >> pairs[i].second;
        pairs[i].first--;
        pairs[i].second--;
    }

    std::reverse(pairs.begin(), pairs.end());
    for (int i = 0; i < m; i++) {
        if (union_find.IsSame(pairs[i].first, pairs[i].second)) {
            ans[i + 1] = ans[i];
        } else {
            ans[i + 1] = ans[i] - union_find.GetSize(pairs[i].first) * union_find.GetSize(pairs[i].second);
            union_find.Unite(pairs[i].first, pairs[i].second);
        }
    }

    std::reverse(ans.begin(), ans.end());
    for (int i = 1; i <= m; i++) {
        std::cout << ans[i] << std::endl;
    }
}


Measured memory_bytes: 6016
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

static const int maxn = 3000 + 5;

int N;
ll score[maxn];
ll dp[maxn][maxn][2];
bool memoize[maxn][maxn][2];

inline ll solve(int i, int j, int turn)
{
    if (i > j)
        return 0;
    ll &ret = dp[i][j][turn];
    bool &mem = memoize[i][j][turn];
    if (mem)
        return ret;
    mem = 1;
    if (turn == 0)
    {
        if (i == j)
        {
            ret = (-score[i] + solve(i + 1, j, 1));
        }
        else
        {
            ll takeFront = -score[i] + solve(i + 1, j, 1);
            ll takeBack = -score[j] + solve(i, j - 1, 1);
            ret = min(takeFront, takeBack);
        }
    }
    else
    {
        if (i == j)
        {
            ret = score[i] + solve(i + 1, j, 0);
        }
        else
        {
            ll takeFront = score[i] + solve(i + 1, j, 0);
            ll takeBack = score[j] + solve(i, j - 1, 0);
            ret = max(takeFront, takeBack);
        }
    }
    return ret;
}

int main()
{
    cin >> N;
    for (int i = 1; i <= N; i++)
        cin >> score[i];
    cout << (solve(1, N, 1));
}


Measured memory_bytes: 158208
#include<iostream>
#include<algorithm>
using namespace std;
long long ttt(long long n,long long x,long long *arr,long long *brr)
{
	if(x<=n)		//提前结束并不会使下面循环x<=0 
	{
		return 0;	
	}
//	if(n==1)
//	{
//		if(x==1)
//		{
//			return 0;
//		}
//		else if(x==2)
//		{
//			return 1;
//		}
//		else if(x==3)
//		{
//			return 2;
//		}
//		else
//		{
//			return 3;
//		}
//		if(x==5)
//		{
//			return 3;
//		}
//	}
	if(n==0)
	{
		return 1;
	 } 
	 if(x==arr[n])
	 {
	 	return brr[n];
	 }
	while(1)
	{
		if(arr[n]/2==x)
		{
			return brr[n-1];
		}
		else if(arr[n]/2>x)
		{
			n--;
			x--;
		}
		else
		{
			break;
		}
	}
	long long sum=brr[n-1]+ttt(n-1,x-arr[n-1]-2,arr,brr)+1;//加中间那个肉片 
	return sum;
	
}
int main()
{
	long long n,x;
	cin>>n>>x;
	long long arr[51];
	long long brr[51];
	brr[0]=1;
	arr[0]=1;
	for(int i=1;i<=n;i++)
	{
		arr[i]=arr[i-1]*2+3;
		brr[i]=brr[i-1]*2+1;
	}
	long long sum=ttt(n,x,arr,brr);
	cout<<sum;
}

Measured memory_bytes: 256
use std::cmp::max;
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//usage
//input! {
//  h: i32;
//  v: [i32; n]
//  x: [[i32; n]; m]
//  f: chars <- Vec<char>
//}

fn main() {
    input!{
        s: chars,
        t: chars
    }

    let mut dp = vec![vec![0; s.len() + 1]; t.len() + 1];

    for i in 1..t.len() + 1 {
        for j in 1..s.len() + 1 {
            dp[i][j] = max(max(dp[i - 1][j - 1] + (t[i - 1] == s[j - 1]) as i64, dp[i - 1][j]), dp[i][j - 1]);
        }
    }

    let mut ans: Vec<char> = Vec::new();
    let (mut slen, mut tlen) = (s.len(), t.len());
    while slen > 0 && tlen > 0 {
        if dp[tlen][slen] == dp[tlen - 1][slen] {
            tlen -= 1;
        }
        else if dp[tlen][slen] == dp[tlen][slen - 1] {
            slen -= 1;
        }
        else {
            tlen -= 1;
            slen -= 1;
            ans.push(s[slen])
        }
    }
    println!("{}", ans.into_iter().rev().collect::<String>());

}

Measured memory_bytes: 90364
import java.util.*;

import sun.net.www.content.text.plain;

import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        for(int i = 0; i < s.length()/2;i++){
            if(str[i]!=str[str.length-i-1]){
                System.out.println("No");
                return;
            }
        }
        for(int i = 0;i < s.length()/4;i++){
            if(str[i]!=str[str.length/2-i-1]){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
                return;
    }       
}






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

int len[100005];
int n,l;

int main(){
scanf("%d%d",&n,&l);
for (int x = 0; x<n; x++){
    scanf("%d",&len[x]);
}
int maxf = -1;
int indf = -1;
for (int x = 1; x<n; x++){
    if (len[x]+len[x-1]>maxf){
        maxf = len[x]+len[x-1];
        indf = x;
    }
}
if (maxf<l){
    printf("Impossible");
    return 0;
}
printf("Possible\n");
for (int x = 1; x<indf; x++){
    printf("%d\n",x);
}
for (int x = n-1; x>=indf; x--){
    printf("%d\n",x);
}
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

ll N, K;
ll ans = -1LL<<60;
void func(vector<ll>& v) {
	ll M = v.size();
	ll n = K / M;// n周する
	ll m0 = K % M;// +m個

	ll a = 0;// 和
	for (int i = 0; i < M; i++) {
		a += v[i];
	}

	vector<ll> res(M + 1, 0);
	for (int m = 0; m <= M; m++) {
		ll b = 0;
		ll c = -1LL << 60;
		for (int i = 0; i < m; i++) {
			b += v[i];
		}
		for (int i = 0; i < M; i++) {
			b += v[(i + m) % M] - v[i];
			chmax(c, b);
		}
		res[m] = c;
	}
	ll x = -1LL << 60;
	if (a > 0) {
		for (int i = 0; i < M; i++) {
			if (i > m0) {
				if (n > 0) {
					chmax(x, a * (n - 1) + res[i]);
				}
			}
			else {
				chmax(x, a * n + res[i]);
			}
		}
	}
	else {
		for (int i = 1; i <= min(M, K); i++) {
			chmax(x, res[i]);
		}
	}
	chmax(ans, x);
}

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

	cin >> N >> K;
	vector<ll> p(N);
	vector<ll> c(N);
	vector<bool> b(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i]; p[i]--;
		b[i] = false;
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}

	for (int i = 0; i < N; i++) {
		if (b[i] == false) {
			vector<ll> temp;
			ll x = i;
			while (1) {
				b[x] = true;
				temp.push_back(c[x]);
				x = p[x];
				if (x == i) { break; }
			}
			func(temp);
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, t;
  cin >> s >> t;
  
  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));
  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      if (s.at(i - 1) == t.at(j - 1)) dp.at(i).at(j) = dp.at(i - 1).at(j - 1) + 1;
      else dp.at(i).at(j) = max(dp.at(i).at(j - 1), dp.at(i - 1).at(j));
    }
  }
  
  int nows = s.size(), nowt = t.size();
  vector<char> x;
  while (nows > 0 && nowt > 0) {
    if (dp.at(nows).at(nowt) == dp.at(nows - 1).at(nowt)) nows--;
    else if (dp.at(nows).at(nowt) == dp.at(nows).at(nowt - 1)) nowt--;
    else {
      x.emplace_back(s.at(nows - 1));
      nows--;
      nowt--;
    }
  }
  
  for (int i = x.size() - 1; i >= 0; i--) cout << x.at(i);
  cout << '\n';
}

Measured memory_bytes: 35584
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()

	arr := GetDivisor(n)
	// debug(arr)
	dp := make([]map[int]int, k+1)
	dp[0] = map[int]int{}
	dp[0][1] = 1
	for i := 0; i < k; i++ {
		dp[i+1] = map[int]int{}
		pre := 0
		sum := 0
		for _, e := range arr {
			num := e-pre
			sum += (dp[i][e]*num)%MOD
			sum %= MOD
			dp[i+1][n/e] = sum
			pre = e
		}
		// debug(dp[i+1])
	}
	ans := 0
	pre := 0
	for i:= 0; i < len(arr); i++ {
		num := arr[i]-pre
		ans += dp[k][arr[i]]*num
		ans %= MOD
		pre = arr[i]
	}

	fmt.Fprintln(wr, ans)

}

// MOD constant
const MOD = 1000000007

// GetDivisor is function that get all divisors of n
func GetDivisor(n int) []int {
	res := []int{}
	tmp := []int{}
	for i := 1; i*i <= n; i++ {
		// if n%i != 0 {
		// 	continue
		// }
		res = append(res, i)
		tmp = append(tmp, n/i)
	}
	if res[len(res)-1] == tmp[len(tmp)-1] {
		tmp = tmp[:len(tmp)-1]
	}
	for i := 0; i < len(tmp); i++ {
		res = append(res,tmp[len(tmp)-1-i])
	}
	return res
}


Measured memory_bytes: 436096
from collections import defaultdict

MOD = 10 ** 9 + 7

N = int(input())
c = [int(input()) for _ in range(N)]

dp = [0 for _ in range(N + 1)]
dp[0] = 1
# dp[index] = 場合の数
# 1-indexed

d = defaultdict(lambda: -1)
# d[色] = index
# 指定色が直前に出現した位置
# 1-indexed

for i, cc in enumerate(c, 1):
    dp[i] = dp[i - 1]
    # 手前までの塗り方に
    # i番目の石をつなげたパターン
    # dp[i - 1] = 手前までの色の塗り方
    if 1 <= d[cc] < i - 1:
        # 指定色が出現している場合
        # （出現なし -> -1）
        dp[i] += dp[d[cc]]
        # 直前の指定色からi番目の石までの区間を色変更したパターン
        # dp[d[cc]] = 直前の指定色までの色の塗り方
    dp[i] %= MOD
    d[cc] = i
    # print(d)
    # print(dp)
print(dp[N])

Measured memory_bytes: 36884
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int a[200010];

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

	for (int i = 2; i <= n; ++i)
	{
		int boss;
		cin >> boss;
		a[boss]++;
	}

	for (int i = 1; i <= n; ++i)
	{
		cout << a[i] << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 4376
using System;

namespace abc163_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            string[] homework = Console.ReadLine().Split(' ');
            int[] a = new int[m];
            for(int i = 0; i < m; ++i)
            {
                a[i] = int.Parse(homework[i]);
            }
            int sum = 0;
            for (int i = 0; i < m; ++i)
            {
                sum = sum + a[i];
            }
            if (sum > n)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(n-sum);
            }
        }
    }
}


Measured memory_bytes: 28456
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

int const inf = 1e9;

template<class T> using PQ_G = priority_queue<T, vector<T>, greater<T>>;

ll dist[111][26];
ll bitcost[1<<8];
typedef tuple<int, int, int> state; // cost, time, pos

typedef tuple<int, ll, int, int> edge;
vector<vector<edge>> g;

int dijkstra(int start, int goal, int H, int S) {
  PQ_G<state> pq;
  pq.emplace(0, 0, start);

  while(!pq.empty()) {
    ll cost, stime; int pos; tie(cost, stime, pos) = pq.top(); pq.pop();

    if(pos == goal) return cost;

    for(auto && e: g[pos]) {
      int b, c, h, r; tie(b, c, h, r) = e;
      ll ntime = stime + h;
      if(ntime > H) continue;
      if(S >> r & 1) {
        if(dist[b][ntime] <= cost) continue;
        dist[b][ntime] = cost;
        pq.emplace(dist[b][ntime], ntime, b);
      }
      else {
        ll ncost = cost + c;
        if(dist[b][ntime] <= ncost) continue;
        dist[b][ntime] = ncost;
        pq.emplace(dist[b][ntime], ntime, b);
      }
    }
  }
  return inf;
}

signed main() {

  int N, M, H, K;
  while(cin >> N >> M >> H >> K && (N|M|H|K)) {
    g.clear();
    g.resize(N);

    rep(i, M) {
      int a, b, c, h, r; cin >> a >> b >> c >> h >> r;
      a --, b --; r --;
      g[a].emplace_back(b, c, h, r);
      g[b].emplace_back(a, c, h, r);
    }

    int start, goal; cin >> start >> goal; start --, goal --;

    rep(i, 1 << 8) bitcost[i] = inf;
    bitcost[0] = 0;

    int P; cin >> P;

    rep(i, P) {
      int l, d; cin >> l >> d;
      int S = 0;
      rep(j, l) {
        int k; cin >> k; k--;
        S |= 1 << k;
      }
      bitcost[S] = d;
    }

    rep(S, 1 << K) {
      if(bitcost[S] >= inf) continue;
      rep(T, 1 << K) {
        if(bitcost[T] >= inf) continue;
        bitcost[S|T] = min(bitcost[S|T], bitcost[S] + bitcost[T]);
      }
    }

    ll ans = inf;

    rep(S, 1 << K) {
      rep(i, 111) rep(j, 26)
        dist[i][j] = inf;
      dist[start][0] = 0;
      if(bitcost[S] < inf)
        minimize(ans, dijkstra(start, goal, H, S) + bitcost[S]);
    }

    cout << (ans == inf ? -1 : ans) << endl;
    
  }
  
  return 0;
}

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

using namespace std;

int main()
{
	long long x, y;
	cin >> x >> y;
	long long ans;
	for (long long i = 0; y >= x; i++)
	{
		ans = i + 1;
		x *= 2;
	}
	cout << ans << endl;

	return 0;
}


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

typedef complex<double> P;
typedef pair<double, P> C;
vector<C> circles;
#define FST first
#define SND second
typedef pair<P, P> S;
#define EPS (1e-5)

double dot(P a, P b) {
  return a.real()*b.real()+a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag()-a.imag()*b.real();
}

double distanceLP(S s, P a) {
  // d = |y||sin(th)| = |x||y|sin(th)/|x| = |cross(x, y)|/|x|
  return abs(cross(s.SND-s.FST, a-s.FST)) / abs(s.SND-s.FST);
}

double distanceSP(S s, P a) {
  // 2ベクトルのなす角が鈍角なら端点と１点との距離を返す
  if (dot(s.SND-s.FST, a-s.FST) < EPS) return abs(a-s.FST);
  if (dot(s.FST-s.SND, a-s.SND) < EPS) return abs(a-s.SND);
  
  return distanceLP(s, a);
}

int main() {
  int N;
  while(cin >> N && N) {
    circles.clear();
    circles.resize(N);
    for(int i=0; i<N; i++) {
      int x, y, r;
      cin >> x >> y >> r;
      circles[i] = C(r, P(x, y));
    }
    int Q; cin >> Q;
    while(Q--) {
      int x, y;
      cin >> x >> y; P taro(x, y);
      cin >> x >> y; P ogre(x, y);
      for(int i=0; i<N; i++) {
        if(distanceSP(S(taro, ogre), circles[i].SND) < circles[i].FST + EPS) {
          if(  abs(circles[i].SND-taro) > circles[i].FST + EPS
	    || abs(circles[i].SND-ogre) > circles[i].FST + EPS) {
            cout << "Safe" << endl;
            goto EXIT;
          }
        }
      }
      
      cout << "Danger" << endl;
      
    EXIT:;
    }
  }
  
  return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	string a,b,c;
	std::cin >> a >> b >> c;
	std::cout << (char)(a[0]+'A'-'a') << (char)(b[0]+'A'-'a') << (char)(c[0]+'A'-'a')<< '\n';
	return 0;
}


Measured memory_bytes: 256
#Checkpoints
N, M = map(int, input().split())
a = [0 for _ in range(N)]
b = [0 for _ in range(N)]
c = [0 for _ in range(M)]
d = [0 for _ in range(M)]
for i in range(N):
    a[i], b[i] = map(int,input().split())
for i in range(M):
    c[i], d[i] = map(int, input().split())

for i in range(N):
    dis = 5 * 10**8
    n = 1
    k = 0
    for j in range(M):
        k = abs(a[i]-c[j])+abs(b[i]-d[j])
        if k < dis:
            dis = k
            n = j+1
    print(n)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;

	int n = s.size();
	int ans = 0;
	for (int i = 0; i < n; i++) {

		int len = 0;
		for (int j = i; j < n; j++) {
			char c = s[j];
			if (c == 'A' || c == 'G' || c == 'C' || c == 'T') {
				len++;
			} else {
				break;
			}
		}
		ans = max(ans, len);
	}

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


Measured memory_bytes: 256
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(m)]

L_max = 0
R_min = 10 ** 5 + 1
for L, R in LR:
    L_max = max(L_max, L)
    R_min = min(R_min, R)

ans = R_min - L_max + 1
if ans < 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 27332
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, a, b = sc.nextInt

    // 両者の間のマスの数が奇数ならAlice、偶数ならBorysの勝ち
    println(if((b-a-1) % 2 == 0) "Borys" else "Alice")
  }
}


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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n;
	cin >> n;
	cout << n*n*n << endl;
	return 0;
} 


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;

  int h = 100, w = 100;

  string white = "", black = "";
  for (int i = 0; i < w; i++) {
    white.push_back('.');
    black.push_back('#');
  }
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    if (i < h / 2)
      s[i] = white;
    else
      s[i] = black;
  }
  a--;
  b--;
  int cntw = 0, cnth = 0;
  // black
  for (int i = 0; i < b; i++) {
    s[cnth * 2][cntw * 2] = '#';
    cntw++;
    if (cntw >= w / 2) {
      cnth++;
      cntw = 0;
    }
  }
  // white
  cntw = 0;
  cnth = 49;
  for (int i = 0; i < a; i++) {
    s[cnth * 2 + 1][cntw * 2] = '.';
    cntw++;
    if (cntw >= w / 2) {
      cnth--;
      cntw = 0;
    }
  }
  cout << w << " " << h << endl;
  for (int i = 0; i < h; i++)
    cout << s[i] << endl;
  return 0;
}


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

int find(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  
  for(int i = 1; i<=n; i++){
    int sum = find(i);
    if(a<=sum && sum<=b)
      total += i;
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	int m,d;
	cin>>m>>d;
	ll ans=0;
	for(int i=1;i<=m;i++){
		for(int k=1;k<=d;k++){
			int d1=k%10;
			int d10=k/10;
			if((d1>=2)&&(d10>=2)&&(d1*d10==i)){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int n, k;
  long long s=0;
  cin >>n>>k;
  vector<int> a(n);
  for(int i=0; i<n; i++){
  	cin >>a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i=0; i<n-k; i++){
  	s += a.at(i);
  }
  cout << s << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  vi h(n);
  rep(i,n) cin >> h[i];
  int ans = 0;
  int kamo = 0;
  rep(i,n-1){
    
    if(h[i]>=h[i+1]){
      kamo++;
      //cout << i << endl;
    }
    else{
      ans = max(kamo,ans);
      kamo = 0;
    }
    
  }
  ans = max(kamo,ans);
  cout << ans << endl;
}


Measured memory_bytes: 640
N,T = map(int,input().split())
t = [int(x) for x in input().split()]
p=0
s=t[0]
for i in range(1,N):
  if t[i] - t[i-1] >= T:
    s += t[i]-t[i-1]-T
print(t[-1]+T-s)


Measured memory_bytes: 25200
#include<bits/stdc++.h>
#define  ll   long long int
#define  sz   300010

using namespace std;


ll w[sz];
ll e[sz];


int main()
{

    string s;
    ll i,j,a,b,d,k,p,n,m;

    cin>>n;
    cin>>s;

    for(i=0; i<n; i++)
    {
        if(s[i]=='W')
        {
           w[i+1]=1;
        }
        else
        {
           e[i+1]=1;
        }
    }

    for(i=1;i<=n;i++)
    {
        w[i]=w[i-1]+w[i];
        e[i]=e[i-1]+e[i];
    }

    ll mn=100000000000;

    for(i=1;i<=n;i++)
    {
        a=w[i-1];
        b=e[n]-e[i];
        d=a+b;



        mn=min(mn,d);
    }

    cout<<mn<<endl;


    return 0;
}



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

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

int H,W;
int fld[10][10];
int lim;
bool change(int y,int x,int c,int f){
    fld[y][x]=c;
    int cnt=1;
    for(int d=0;d<4;d++){
        int ny=y+dy[d],nx=x+dx[d];
        if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]!=f)continue;
        cnt+=change(ny,nx,c,f);
    }
    return cnt;
}

bool dfs(int t=0,int sum=1){
    if(lim==t){
        bool ok=true;
        for(int i=0;i<H;i++)for(int j=0;j<W;j++){
            if(fld[0][0]!=fld[i][j])ok=false;
        }
        return ok;
    }

    int _fld[10][10];
    memcpy(_fld,fld,sizeof(_fld));

    bool ret=false;
    for(int k=0;k<3;k++)if(k!=fld[0][0]){
        int la=change(0,0,k,fld[0][0]);
        if(la>=sum)ret|=dfs(t+1,la);
        memcpy(fld,_fld,sizeof(fld));
    }

    return ret;
}
int main(){
    while(cin>>W>>H,W||H){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                char c;
                cin>>c;
                switch(c){
                case 'R':fld[i][j]=0;break;
                case 'G':fld[i][j]=1;break;
                case 'B':fld[i][j]=2;break;
                }
            }
        }

        for(lim=0;;lim++)if(dfs())break;
        cout<<lim<<endl;
    }

    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;

ll N, ans=0;
ll P[1005]={}, X[1005];
vector<int> child[1005];
ll dfs(int n){
	ll dp[2][5005]={};
	Fill(dp, INF);
	dp[0][0] = 0;
	ll sz = child[n].size();
	rep(k, sz){
		int t = child[n][k];
		ll m = dfs(t);
		ll x = X[t];
		for(ll i=0; i<=X[n]; i++){
			if(i+m <= X[n]) chmin(dp[(k+1)%2][i+m], dp[k%2][i] + x);
			if(i+x <= X[n]) chmin(dp[(k+1)%2][i+x], dp[k%2][i] + m);
		}
		Fill(dp[k%2], INF);
	}
	ll ret = INF;
	rep(i, X[n]+1) chmin(ret, dp[sz%2][i]);
	return ret;
}

int main(){
	//ios_base::sync_with_stdio(0);

	cin >> N;
	rep(i,N-1){
		cin >> P[i+1];
		P[i+1]--;
		child[P[i+1]].push_back(i+1);
	}
	rep(i,N) cin >> X[i];

	ll ret = dfs(0);

	cout << ((ret < INF)?"POSSIBLE":"IMPOSSIBLE") << endl;

	return 0;
}


Measured memory_bytes: 34048
N,M,K = map(int,input().split())

P = []
for i in range(0,N+1):
    for j in range(0,M+1):
        p = (i*j) + ((N-i)*(M-j))
        P.append(p)
        
if K in P:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 42684
N,M=gets.chomp.split.map(&:to_i)
h = Hash.new(0)
N.times do
  arr = gets.chomp.split.map(&:to_i)
  1.upto(arr.size-1) {|i| h[arr[i]]+=1}
end
ans=0
h.each do |k,v|
  ans += 1 if v == N
end
puts ans

Measured memory_bytes: 1788
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int N;
	cin >> N;
	vector<int>data(9);
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		if (n < 400) {
			data.at(0) = 1;
		}else if (n < 800) {
			data.at(1) = 1;
		}
		else if (n < 1200) {
			data.at(2) = 1;
		}
		else if (n < 1600) {
			data.at(3) = 1;
		}
		else if (n < 2000) {
			data.at(4) = 1;
		}
		else if (n < 2400) {
			data.at(5) = 1;
		}
		else if (n < 2800) {
			data.at(6) = 1;
		}
		else if (n < 3200) {
			data.at(7) = 1;
		}
		else {
			data.at(8)++;
		}
	}
	int ans = 0;
	for (int i = 0; i < 8; i++) {
		ans += data.at(i);
	}
	if (ans == 0) {
		if (data.at(8) == 0) {
			cout << 0 << " ";
		}
		else {
			cout << 1 << " ";
		}
	}
	else {
		cout << ans << " ";
	}
	cout << ans + data.at(8) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int const maxn=200;
int ar[maxn];
int main()
{
	int a,b;
	cin >> a >> b;
	if(a<=0 && b>=0)
		cout << "Zero";
	else if(a<0 && b<0)
	{
		if(abs(a-b+1)%2==0)
			cout << "Positive";
		else cout << "Negative";
	}
	else
		cout << "Positive";
}


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

int main() {
char x,y; cin>>x>>y;
  if(x>y) cout<<'>'<<endl;
  else if(x<y) cout<<'<'<<endl;
  else cout<<'='<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	string s;
 	cin >> n >> s;
 	int cnt = 0;
 	for(int i=s.find("ABC"); i!=s.npos; i=s.find("ABC", i+1)) cnt++;
 	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,sub,ans=4000000;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  
  for(int i=a.at(0);i<a.at(N-1)+1;i++){
    sub=0;
    for(int j=0;j<N;j++)
      sub+=(a.at(j)-i)*(a.at(j)-i);
    ans=min(ans,sub);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int T = int.Parse(input[0]);
            int A = int.Parse(input[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            int ans = 1;
            
            double a = Math.Abs(A - (T - (int.Parse(input2[0]) * 0.006)));
            double[]  ans2 = new double[] { a, ans };
            foreach (string i in input2)
            {
                
                int i2 = int.Parse(i);
                a = Math.Abs(A - (T - (i2 * 0.006)));
                
                if (a < ans2[0])
                {
                   ans2 = new double[] { a, ans };
                }
                
                ans++;
            }
            Console.WriteLine(ans2[1]);
          
        }
    }
}


Measured memory_bytes: 11156
local n,k=io.read("n","n")
local edge={}

for i=1,n do
    edge[i]={}
end
for i=1,n-1 do
    local a,b=io.read("n","n")
    table.insert(edge[a],b)
    table.insert(edge[b],a)
end

local mod=1000000007
local pattern=1
local function dfs(me,parent,x)
    pattern=pattern*x%mod
    x=k-1
    if parent>0 then
        x=x-1
    end
    for _,v in pairs(edge[me]) do
        if v~=parent then
            dfs(v,me,x)
            x=x-1
        end
    end
end

dfs(1,0,k)
print(pattern)

Measured memory_bytes: 30712
use proconio::input;
// use std::collections::HashMap;
// use std::default::Default;

fn main() {
  input! {
    S: String,
  }

  let mut counts: [usize;2019] = [0;2019];
  let mut total = 0;
  let mut result = 0;
  let mut target_str: Vec<char> = S.chars().collect();
  let mut x = 1;
  target_str.reverse();
  
  for v in target_str.iter() {
    counts[total] += 1;
  	let val = v.to_string().parse::<usize>().unwrap();
    total = (total + val * x) % 2019;
    result += counts[total];
    x = x * 10 % 2019;
  }
  
  println!("{}", result);
}

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

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

    ll ans = 0;
    int ma = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;

        if(ma<a){
            ma = a;
            ans = a + b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 *   author: sahushivam
 *   created: 18 August 2019 (Sunday)  17:40:35
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> a(n);
    priority_queue <double, vector<double>, greater<double> > pq;
    for(int i=0;i<n;i++) cin>> a[i];
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++)
    {
        pq.push(a[i]);
    }
    double ans=0;
    while(pq.size()!=1)
    {
        double a1=pq.top();
        pq.pop();
        double a2=pq.top();
        pq.pop();
        ans=(a1+a2)/2;
        pq.push(ans);
    }
    cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    string S, res; cin >> S;
    res = "Yes";
    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D')
            {
                res = "No";
            }
        }
        else
        {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D')
            {
                res = "No";
            }
        }
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
    int N;
    cin>>N;
    int x,y,t;

    x = y = 0;
    t = 0;

    for(int i = 0;i < N;i++) {
        int c,a,b;
        cin>>c>>a>>b;

        if(((abs(x-a)+abs(y-b)) % 2 == (c-t) % 2) && abs(x-a)+abs(y-b) <= (c-t)) {
            
        } else {
            cout<<"No"<<endl;

            return 0;
        }

        x = a;
        y = b;
        t = c;
    }

    cout<<"Yes"<<endl;

    return 0;
}




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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
int h,n;
int a[maxn], b[maxn];
int dp[maxn];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>h>>n;
  for (int i=0; i<n; i++) {
    cin>>a[i]>>b[i];
  }
  memset(dp, inf, sizeof dp);
  dp[0] = 0;
  for (int x=1; x<=h; x++) {
    for (int j=0; j<n; j++) {
      if (x-a[j]<0) {
	dp[x] = min(dp[x], b[j]);
      } else {
	dp[x] = min(dp[x], b[j] + dp[x-a[j]]);
      }
    }
  }

  cout<<dp[h]<<endl;
  return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007


int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);
  //freopen (".in","r",stdin);
  //freopen (".out","w",stdout);
  ll S;
  cin>>S;
  if (S<=1000000000)
    cout<<0<<' '<<0<<' '<<0<<' '<<1<<' '<<S<<' '<<0<<endl;
  else{
    ll D=1000000000;
    ll B=S/D;
    ll CA=S-B*D;
    ll A=CA;
    ll C=1;
    if (A==0) C=0;
    cout<<B<<' '<<0<<' '<<B+C<<' '<<D<<' '<<0<<' '<<A<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
<?php

 $input = explode(" ", trim(fgets(STDIN)));

$N = $input[0];
$K = $input[1];

$cm = explode(" ", trim(fgets(STDIN)));

$count = 0;

for ($i = 0; $i < $N; $i++){
   
            if ($cm[$i] >= $K) {

                          $count++;

               }

}

  echo $count;
  

?>

Measured memory_bytes: 12792