akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	n, k := readInt(), readInt()

	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = readInt64()
	}

	for i := k; i < n; i++ {
		if a[i] <= a[i-k] {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,temp1,temp2,y,sum=0,o,n,m,k;
    string a;
    cin >> n >> m >> k >> t;
    ll x = (k+m-1)/m;
    y = (n+t-1)/t;
    x<=y ? cout << "Yes" : cout << "No";
    // ll c=0;
    // n = a.size();
    // for(i=0;i<n-3;i++){
    //     for(j=4;j<n-i;j++){
    //         ll aa = stoll(a.substr(i,j));
    //         if(aa%2019==0){
    //             c++;
    //         }
    //     }
    // }
    // cout << c;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

const int mod = 998244353;

int n;
int m;

string s;

map<string, ii> res;

ii go (string s) {
	if (sz (s) == 1) {
//		cout << s << " " << s[0] - '0' + 1 << " " << s[0] - '0' + 1 << endl;
		re mp (s[0] - '0' + 1, s[0] - '0' + 1);
	}	
	if (res.count (s)) re res[s];
	int split = 0, repeat = 0;
	int m = sz (s);
	for (int i = 1; i < m; i++)
		split = (split + (ll)go (s.substr (0, i)).se * go (s.substr (i, m - i)).fi) % mod;
	for (int i = 1; i < m; i++)
		if (m % i == 0) {
			string t = s.substr (0, i);
			for (int j = 0; j < i; j++)
				for (int k = j; k < m && t[j] == '1'; k += i)
					if (s[k] == '0')
						t[j] = '0';
			repeat = (repeat + go (t).fi) % mod;
		}
//	cout << s << " " << split << " " << repeat << endl;
	re res[s] = mp ((split + repeat) % mod, repeat);
}

int main () {
	cin >> s;
	n = sz (s);
	cout << go (s).fi << endl;
}

Measured memory_bytes: 7552
N, A, B, C, D = map(int, input().split())

div = abs(B-A)
if (div > D*(N-1)):
    print("NO")
    exit()
check = div // C
upcount = check + (N-1-check) // 2
downcount = N-1 - upcount


if (N-1) % 2 == 0:
    ans = div % (2*C)
    if (ans <= upcount*(D-C)) or (ans >= 2*C - (downcount-1)*(D-C)):
        print("YES")
    else:
        print("NO")
else:
    ans = (div - C) % (2*C)
    if (ans <= upcount*(D-C)) or (ans >= 2*C - (downcount-1)*(D-C)):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define INF INT_MAX
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
	string s;cin>>s;
	ll cnt=0;
	for(int i=0;i<s.length();i++)if(s[i]=='o')cnt++;
	ll p=15-s.length();
	if(cnt+p>=8)cout<<"YES";
	else cout<<"NO";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int people[4][3][10], n, b, f, r, v, i, ii, iii;
	for (i = 0; i <= 3; i ++) for (ii = 0; ii <= 2; ii ++) for (iii = 0; iii <= 9; iii ++) people[i][ii][iii] = 0;
	scanf("%d", &n);
	for (i = 0, scanf("%d %d %d %d", &b, &f, &r, &v); i <= n - 1; i ++, scanf("%d %d %d %d", &b, &f, &r, &v)) {
		people[b - 1][f - 1][r - 1] += v;
	}
	for (i = 0; i <= 3; i ++) {
		for (ii = 0; ii <= 2; ii ++) {
			for (iii = 0; iii <= 9; iii ++) {
				printf(" %d", people[i][ii][iii]);
			}
			printf("\n");
		}
		if (i != 3) {
			for (ii = 0; ii <= 19; ii ++) printf("#");
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
	//
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	int n, k;
	cin>>n>>k;
	int st[n];
    for(int i=0; i<n; i++) cin>>st[i];
    vector<int> dp(n, 0);
	dp[0] = 0;
	for(int i=1; i<n; i++){
		int m = INT_MAX;
		for(int j=1; j<=k; j++){
			if(i>=j){
				m = min(m, (dp[i-j] + abs(st[i] - st[i-j])));
				// cout<<i<<" "<<j<<" ";
			}
		}
		dp[i] = m;
		// cout<<m<<" ";
	}
	cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 4028
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = (1 << 26);
const int MAX_NM = 201;

int n, m, dp[MAX_NM];
vector<P> mato;

int loop(int i){
    if(dp[i] != 0) return dp[i];
    rep(j, mato.size()) if(mato[i].first > mato[j].first && mato[i].second > mato[j].second) dp[i] = max(dp[i], loop(j) + 1);
    return dp[i];
}


int main(){
    while(cin >>n && n != 0){
        mato.clear();
        rep(i, MAX_NM) dp[i] = 0;

        rep(i, n){
            int a, b; cin >>a >>b; mato.push_back( P(a, b) );
        }
        cin >>m;
        rep(i, m){
            int a, b; cin >>a >>b; mato.push_back( P(a, b) );
        }

        int ans = 0;
        rep(i, mato.size()) ans = max(ans, loop(i));
        cout <<ans + 1 <<endl;
    }
    return 0;
}

Measured memory_bytes: 1200
import sys
import numpy as np


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    x, y = map(int, input().split())
    if x > 0:
        if y > 0:
            if x > y:
                answer = x - y + 2
            else:
                answer = y - x
        elif y == 0:
            answer = x + 1
        else:
            if -x <= y:
                answer = y + x + 1
            else:
                answer = abs(y) - x + 1
    elif x == 0:
        if y > 0:
            answer = y
        else:
            answer = -y + 1
    else:
        if y > 0:
            if abs(x) >= y:
                answer = abs(x) - y + 1
            else:
                answer = y - abs(x) + 1
        elif y == 0:
            answer = abs(x)
        else:
            if abs(x) > abs(y):
                answer = abs(x) - abs(y)
            else:
                answer = abs(y) - abs(x) + 2
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12496
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val n = sc.nextInt()
    val ab = (0 until n).map { sc.next().toInt() to sc.next().toInt() }
    println(problem154e(h, n, ab))
}

fun problem154e(h: Int, n: Int, ab: List<Pair<Int, Int>>): Int {
    val pow = Math.pow(10.0, 9.0).toInt()
    val dp = Array(n + 1) { IntArray(h + 1) { pow } }
    dp[0][0] = 0;
    for (i in 0 until n) {
        for (j in 0..h) {
            dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j])
            dp[i + 1][Math.min(j + ab[i].first, h)] = Math.min(dp[i + 1][Math.min(j + ab[i].first, h)], dp[i + 1][j] + ab[i].second)
        }
    }
    return dp[n][h]
}

Measured memory_bytes: 85160
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
  int k;
  cin>>k;
  cout<<vec[k-1]<<endl;
}

Measured memory_bytes: 256
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
set<LL> aa;
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
		aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	LL n, m;
	cin >> n >> m;
	set<LL>set;
	for (int i = 1; i <= sqrt(m); i++) {
		if (m % i == 0) {
			set.insert(i);
			set.insert(m / i);
		}
	}
	LL ans = 1;
	for (auto x : set)
	{
		if (x*n <= m)
			ans = x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
s = 0 
def main():
    n, k = map(int, readline().split())
    a = [int(i)-1 for i in readline().split()]
    done = [0 for _ in range(n)] 
    cycle = []
    def dfs(x):
        global s
        if done[x] == 1:
            s = x
            return
        nx = a[x]
        done[x] = 1
        cycle.append(x)
        dfs(nx)

    dfs(0)
    start_idx = cycle.index(s)
    ln = len(cycle)
    if k < ln: 
        print(cycle[k]+1)
    else:
        k -= start_idx
        idx = start_idx+(k%(ln-start_idx))
        print(cycle[idx]+1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 247108
#include <iostream>
#include<climits>
#include<vector>
using namespace std;
 
int MCM(int p[],int n) {
    vector<vector<int> > m(n+1,vector<int>(n+1));
    for (int i = 0; i <= n; i++)
        m[i][i] = 0;
    for (int l = 2; l <= n; l++) {
        for (int i = 1; i <= n - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = INT_MAX;
            for (int k = i; k <= j-1; k++) {
                int q = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
                if (m[i][j] > q) {
                    m[i][j] = q;
                }
 
            }
        }
 
    }
    return m[1][n];
}
 
int main() {
    int n, p[200];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i] >> p[i + 1];
    }
    cout << MCM(p, n) << endl;
    return 0;
}

Measured memory_bytes: 3184
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000




int main(void){
char s[BUFSIZE];
scanf("%s",s);
int cnt =0 ;
char rem;

for(int i = 0 ;i < 4;i++){
  for(int j = 0;j < 4;j++){
    if(i == j)  break;
    if(s[i] == s[j]){
    if(s[i] == rem){
      printf("No");
      exit(0);
    }
      cnt++;
      rem = s[i];
      break;
    }

  }

}

if(cnt == 2) printf("Yes");
else printf("No");

return 0;



}


Measured memory_bytes: 1732
use std::io;
use std::str::FromStr;

fn drawrectangle(h: i32, w: i32) {

    for i in 0..h {
        for j in 0..w {
            if (i + j) % 2 == 0 {
                print!("#");
            }
            else {
                print!(".");
            }
        }
        println!("");
    }
    println!("");
}

fn main() {

    for i in 1.. {
        let stdin = io::stdin();
        let mut buf = String::new();
        stdin.read_line(&mut buf).ok();
        let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());

        let h = it.next().unwrap() as i32;
        let w = it.next().unwrap() as i32;

        if w == 0 && h == 0 {
            break;
        }
        else {
            drawrectangle(h, w);
        }
    }
}



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

int main() {
  int i, a, b, sum=0, r, s, t, u;
  cin >> a >> b;
  for(i=a; i<=b; i++) {
    r=i/10000;
    s=(i/1000)%10;
    t=(i/10)%10;
    u=i%10;
    if(r==u && s==t) {
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if (a == b && b == c || (a != b && b != c && a != c)) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int a,c,i,min,max;
	long long int sum = 0;
	scanf("%d\n",&i);
	scanf("%d ",&a);
	min = a;
	max = a;
	sum = a;
	for(c=0;c<(i-1);c++){
	scanf("%d ",&a);
		if(min > a) min = a;
		if(max < a) max = a;
		sum = (long long int)sum + a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 604
use proconio::{input, fastout};
use proconio::marker::Chars;
use std::collections::{HashMap, HashSet};

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    s: Chars,
    t: Chars
  };

  let mut pair = HashMap::new();
  let mut used = HashSet::new();
  for (sc, tc) in s.iter().zip(t.iter()) {
    match pair.get(sc) {
      Some(pv) => {
        if pv != tc {
          echo!("No");
          return;
        }
      },
      None => {
        if used.contains(tc) {
          echo!("No");
          return;
        }
        pair.insert(*sc, *tc);
        used.insert(*tc);
      }
    }
  }
  echo!("Yes");
}


Measured memory_bytes: 4032
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-27 14:05:19
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 INF = 1e18;

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

  int n, m; int64 l;
  cin >> n >> m >> l;
  int64 dis[n][n];
  fill(dis[0], dis[n], INF);
  for (int i = 0; i < n; ++i) dis[i][i] = 0LL;

  for (int i = 0; i < m; ++i) {
    int a, b; int64 c; cin >> a >> b >> c;
    --a; --b;
    dis[a][b] = dis[b][a] = c;
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (dis[i][k] == INF || dis[k][j] == INF) continue;
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }

  int64 dis2[n][n];
  fill(dis2[0], dis2[n], INF);
  for (int i = 0; i < n; ++i) dis2[i][i] = 0LL;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (dis[i][j] <= l) {
        dis2[i][j] = dis2[j][i] = 1LL;
      }
    }
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (dis2[i][k] == INF || dis2[k][j] == INF) continue;
        dis2[i][j] = min(dis2[i][j], dis2[i][k] + dis2[k][j]);
      }
    }
  }  

  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    int s, t; cin >> s >> t; --s; --t;
    if (dis2[s][t] == INF) {
      cout << -1 << '\n';
    } else {
      cout << dis2[s][t] - 1LL << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 1920
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


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

#define int long long

using namespace std;

int cnt[4 * 100000];

signed main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
    {
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j)
        {
            int aa;
            cin >> aa;
            cnt[aa]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= m; ++i)
    {
        if (cnt[i] == n)
            ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;


typedef long long ll;

const int N = 2e5 + 10;
const int MOD = 1e9 + 7;

int n;
int a[N];

int kin[N], last[N];



ll psumf[N];
ll f[N];
ll fuel[N];
void prepare() {
    int _n;
    cin >> _n >> a[1];
    n = 1;
    for(int i = 2; i <= _n; i++) {
        cin >> a[n + 1];
        if (a[n + 1] != a[n]) n++;
    }
    for(int i = 1; i <= n; i++) {
        kin[i] = last[a[i]];
        last[a[i]] = i;
    }
}
long long solve() {
    psumf[0] = 1;
    for(int i = 1; i <= n; i++) {
        f[i] = fuel[kin[i]];
        psumf[i] = (psumf[i - 1] + f[i]) % MOD;
        fuel[i] = (fuel[kin[i]] + psumf[i - 1]) % MOD;
    }
    return psumf[n];
}
int main() {
    prepare();
    cout << solve();
}


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

using namespace std;

const int maxN = 3e3 + 5;

double dp[2][maxN];
double pH[maxN];
int n;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> pH[i];
	}

	dp[1][0] = (1 - pH[1]);
	dp[1][1] = pH[1];

	for (int i = 2; i <= n; ++i)
	{
		int curr = i % 2, prev = (i + 1) % 2;
		for (int j = 0; j <= i; ++j)
		{
			if (j > 0)
				dp[curr][j] = (dp[prev][j - 1] * pH[i]) + (dp[prev][j] * (1 - pH[i])); 
			else
				dp[curr][j] = (dp[prev][j] * (1 - pH[i]));
		}
	}

	int curr = (n % 2);
	double sum = 0;
	for (int i = n / 2 + 1; i <= n; ++i)
	{
		sum += dp[curr][i];
	}

	cout << setprecision(10) << sum << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    length = len(str(n))

    if length == 1:
        print(n)
    elif length == 2:
        print(9)
    elif length == 3:
        print(n - 90)
    elif length == 4:
        print(909)
    elif length == 5:
        print(n - 9090)
    else:
        print(90909)

main()


Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, i = MAP()
print(N-i+1)

Measured memory_bytes: 5192
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){

	int a,b,c;
	cin>>a>>b>>c;

	double theta = (c/180.)*M_PI;
	
	cout << fixed << setprecision(6);
	
	cout << a*b*sin(theta)/2. << endl;
	cout << a + b + sqrt( a*a + b*b - 2.*a*b*cos(theta)) << endl;
	cout << b*sin(theta) << endl;

	return 0;	
}



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
















int main(){

  

  int n;
  cin>>n;
  
  vector<int> data(n);
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  map<int,int> mycount0;
  
  map<int,int> mycount1;
  
  for (int i=0;i<n;i+=2){
    if (mycount0.find(data.at(i))!=mycount0.end()){
      mycount0[data.at(i)]++;
    }
    else {
      mycount0[data.at(i)]=1;
    }
  }
  
  for (int i=1;i<n;i+=2){
    if (mycount1.find(data.at(i))!=mycount1.end()){
      mycount1[data.at(i)]++;
    }
    else {
      mycount1[data.at(i)]=1;
    }
  }
  
  vector<pair<int,int>> vec0;
  vector<pair<int,int>> vec1;
  
 
  for (auto mypair:mycount0){
    int a=mypair.first;
    int b=mypair.second;
    pair<int,int> tmp;
    tmp=make_pair(b,a);
    vec0.push_back(tmp);
  }

  for (auto mypair:mycount1){
    int a=mypair.first;
    int b=mypair.second;
    pair<int,int> tmp;
    tmp=make_pair(b,a);
    vec1.push_back(tmp);
  }
  
  sort(vec0.begin(),vec0.end());
  reverse(vec0.begin(),vec0.end());
  sort(vec1.begin(),vec1.end());
  reverse(vec1.begin(),vec1.end());
  

  
  
  int answer=0;
  
  if (int(mycount0.size())==1 and int(mycount1.size())==1){
    if (vec0.at(0).second==vec1.at(0).second){
      answer=n/2;
    }
    else {
      answer=0;
    }
  }
  
  else if (int(mycount0.size())>=2 and int(mycount1.size())==1){
    if (vec0.at(0).second==vec1.at(0).second){
      answer=(n/2-vec0.at(1).first)+(n/2-vec1.at(0).first);
    }
    
    else {
      answer=(n/2-vec0.at(0).first)+(n/2-vec1.at(0).first);
    }
  }
  
  else if (int(mycount0.size())==1 and int(mycount1.size())>=2){
    if (vec0.at(0).second==vec1.at(0).second){
      answer=(n/2-vec0.at(0).first)+(n/2-vec1.at(1).first);
    }
    
    else {
      answer=(n/2-vec0.at(0).first)+(n/2-vec1.at(0).first);
    }
  }
    
  else {
    if (vec0.at(0).second==vec1.at(0).second){
      answer=min((n/2-vec0.at(0).first)+(n/2-vec1.at(1).first),(n/2-vec0.at(1).first)+(n/2-vec1.at(0).first));
    }
    
    else {
      answer=(n/2-vec0.at(0).first)+(n/2-vec1.at(0).first);
    }
  }
  
    
  cout<<answer<<endl;
  

      
      
    
    
    
    
    
    

  

  
  
    
    
      
   
    
  
  
  

    
    
    

  
}

Measured memory_bytes: 6520
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll r, D, x; cin >> r >> D >>x;
    REP(i, 10){
        x = r*x-D;
        cout << x << endstr;
    }
    
    return 0;
}


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

using namespace std;
typedef long long ll;
ll ans;
int cnt,len,k;
void dfs(int x,ll i){
    if(len==x){
        cnt++;
        if(cnt==k) ans=i;
        i/=10;
        return ;
    }
    ll u=i%10;
    for(ll j=u-1;j<=u+1;j++){
        if(j<0||j>9) continue;
        len++;
        dfs(x,i*10+j);
        len--;
    }
}
int main()


{
    cin>>k;
    for(int i=1;i<=10;i++){
        for(ll j=1;j<=9;j++){
            len=1;
            dfs(i,j);
        }
    }
    cout<<ans;
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;



class Program
{
    public const int INF = 1 << 25;

    static void Main()
    {
		string str;
		while (!string.IsNullOrEmpty(str = Console.ReadLine())) {
			string[] input = str.Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			int c = a + b;
			int ans = 1;
			while (c / 10 != 0) {
				c /= 10;
				ans++;
			}
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 5624
import numpy as np
N,W=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(N)]
vmax=sum([v for w,v in a])
INF=float("inf")
dp=np.full(vmax+1,INF)
dp[0]=0

for i in range(N):
    w,v=a[i]
    dp[v:]=np.minimum(dp[v:],dp[:-v]+w)
print(max([i for i in range(vmax+1) if dp[i]<=W]))
# print(dp)

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

int main(){
    string n; cin >> n;
    int a = 0;
    for(int i=0; i<n.size(); i++){
        a += (n[i] - '0');
        a %= 9;
    }

    if(a == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef complex<double> P;
typedef pair<P,P> L;

typedef pair<int,int> Pa;
typedef pair<double,Pa> state;

const double EPS = 1e-9;

namespace std {
  bool operator < (const P& a, const P&b ){
    return fabs( real(a) - real(b) ) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
};

int N,M;
vector<P> v;

map<Pa,double> H;

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

bool eq(double a,double b){ return abs(a-b)<EPS; }

double solve(){
  H.clear();
  priority_queue<state,vector<state>,greater<state> > q;
  q.push( state( 0.0, Pa( 0, M-1 ) ) );
  H[Pa(0,M-1)] = 0.0;
  while( !q.empty() ){
    state p = q.top(); q.pop();
    int idx = p.second.first, idy = p.second.second;
    // printf("%d %d %lf\n",idx,idy,p.first);
    double cost = p.first;
    if( p.first > H[ Pa(idx,idy) ]+EPS ) continue;    
    if( idx == idy ) return p.first;
    for(int i=0;i<8;i++){
      int nf1 = idx + dx[i];
      int nf2 = idy + dy[i];
    
      if( nf1 < 0 || nf2 < 0 || nf1 >= M || nf2 >= M ) continue;
      if( eq(v[nf1].imag(),v[nf2].imag()) ){
	double ky = abs(v[nf1]-v[idx]) + abs(v[nf2]-v[idy]);
	if( H.count(Pa(nf1,nf2)) == 0 || H[Pa(nf1,nf2)] > ky+cost ){
	  q.push( state( ky+cost, Pa( nf1, nf2 ) ) );
	  H[ Pa(nf1,nf2) ] = ky+cost;
	}
      }
    }       
  }
  return -1.0;
}

int main(){
  while( cin >> N && N ){
    v.clear();
    for(int i=0;i<N;i++){
      int x,y;
      cin >> x >> y;
      v.push_back( P(x,y) );
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<N-1;j++){
	P vx = v[j+1]-v[j];
	double miny = min(v[j].imag(),v[j+1].imag());
	double maxy = max(v[j].imag(),v[j+1].imag());
	//	  cout << miny << " "<< v[i].imag() << " "<< maxy << endl;
	if( miny+EPS < v[i].imag() && v[i].imag() < maxy-EPS ){

	  double sa1 = v[i].imag()-v[j].imag();
	  double sa2 = v[j+1].imag()-v[j].imag();
	  if( abs(sa2) < EPS ) continue;
	  P r = v[j] + sa1/sa2*vx;
	  v.push_back(r);
	}
      }
    }

    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());

    M = v.size();
    printf("%.10lf\n",solve());

  }
}

Measured memory_bytes: 3468
n=int(input())
a=list(map(int,input().split()))

if n==1:
  if a[0]==0:
    print(1)
    exit()
  exit(print(0))
mod=10**9+7
a.sort()
t=0
ans=1
if n%2==0:
  t=1
  for i in range(n):
    if i==0 or i==1:
      if a[i]!=1:exit(print(0))
      continue
    if i%2==0:t+=2
    if a[i]!=t:exit(print(0))
  for i in range(n//2):
    ans*=2
    ans%=mod
else:
  for i in range(n):
    if i==0 and a[i]!=0:exit(print(0))
    if i%2==1:
      t+=2
    if a[i]!=t:exit(print(0))
  for i in range(n//2):
    ans*=2
    ans%=mod
print(ans)  


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

int main()
{
    ll a,b; cin>>a>>b;
  
  ll low=0,high=100000000,min_=100000000;
  while(low<=high)
  {
    ll mid=(low+high)/2;
    
    if(floor(mid*0.08)>a || floor(mid*0.1)>b)
    {
      high=mid-1;
    }
    else if(floor(mid*0.08)<a || floor(mid*0.1)<b)
    {
      low=mid+1;
    }
    else if(floor(mid*0.08)==a || floor(mid*0.1)==b)
    {
      min_=min(min_,mid);
      high=mid-1;
    }

  }
  if(min_==100000000) cout<<-1;
  else cout<<min_;
    
  
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    long long N; cin >> N;
    long long K = 1;
    bool exist = false;
    for (K = 1; K <= N; ++K) {
        if (K * (K+1) / 2 == N) {
            exist = true;
            break;
        }
    }
        
    if (!exist) puts("No");
    else {
        puts("Yes");
        cout << K+1 << endl;
        vector<vector<long long> > res(K+1, vector<long long>());
        long long sum = 1;
        for (int k = K; k >= 1; --k) {
            for (int i = 0; i < k; ++i) {
                res[K-k].push_back(sum + i);
                res[K-k + i + 1].push_back(sum + i);
            }
            sum += k;
        }
            
        for (int i = 0; i < K+1; ++i) {
            cout << res[i].size();
            for (int j = 0; j < res[i].size(); ++j) cout << " " << res[i][j];
            cout << endl;
        }
    }
}


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

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

    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2 - (y2 - y1);
    int y3 = y2 + (x2 - x1);
    cout << x3 << " " << y3 << " ";
    int x4 = x3 - (y3 - y2);
    int y4 = y3 + (x3 - x2);
    cout << x4 << " " << y4 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll n;
    cin >> n;
    vector<string>A;
    map<string,int>T;
    int max= 0;
    REP(i,n){
        string s;
        cin >> s;
        T[s]++;
        if(max<T[s]) max= T[s];
        
    }
    for(auto x:T){
        if(x.second==max) cout << x.first << endl;
    }
    
}


Measured memory_bytes: 23808
#include <iostream>
#include <vector>
#include<algorithm>
#include<set>
#include<cmath>
const int v = 1000000000;
using namespace std;
int main() {
	long long int s;
    cin >> s;
	int x = (v - s % v) % v;
	int y = (s + x) / v;
	cout << "0 0 1000000000 1 " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
 
typedef pair<int,int> P;
 
int main(void)
{
	int friends[500], n, m, a, b;
	P p;
	while (cin >> n >> m && n && m) {
		queue<int> q;
		vector<P> v;
		for (int i = 0; i < n; i++) friends[i] = 0;
		for (int i = 0; i < m; i++) {
			cin >> a >> b;
			v.push_back(P(a,b));
		}
		for (int i = 0; i < m; i++) {
			p = v[i];
			if (p.first == 1 || p.second == 1) {
				friends[p.first-1] = friends[p.second-1] = 1;
				if (p.first > 1) q.push(p.first);
				else q.push(p.second);
				v[i] = P(0,0);
			}
		}
		while (q.size()) {
			int number = q.front();
			q.pop();
			for (int j = 0; j < m; j++) {
				p = v[j];
				if (p.first == number || p.second == number) {
					friends[p.first-1] = friends[p.second-1] = 1;
				}
			}
		}
		int ans = 0;
		for (int i = 1; i < n; i++) 
			if (friends[i] > 0) ans++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1328
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int R = sc.nextInt();
        final int C = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[][] Vs = new int[R][C];
        for (int k = 0; k < K; k++) {
            int r = sc.nextInt() - 1;
            int c = sc.nextInt() - 1;
            int v = sc.nextInt();
            Vs[r][c] = v;
        }
        
        final long[][][] dp = new long[R][C][4];
        
        // 原点
        {
            int v = Vs[0][0];
            if (0 < v) {
                dp[0][0][1] = v;
            }
        }
        
        // 左端
        for (int i = 1; i < R; i++) {
            dp[i][0][0] = Long.max(dp[i - 1][0][0], dp[i - 1][0][1]);
            
            int v = Vs[i][0];
            if (0 < v) {
                dp[i][0][1] = dp[i][0][0] + v;
            }
        }
        
        // 上端
        for (int j = 1; j < C; j++) {
            int v = Vs[0][j];
            if (0 < v) {
                dp[0][j][0] = dp[0][j - 1][0];
                dp[0][j][1] = Long.max(dp[0][j - 1][1], dp[0][j - 1][0] + v);
                dp[0][j][2] = Long.max(dp[0][j - 1][2], dp[0][j - 1][1] + v);
                dp[0][j][3] = Long.max(dp[0][j - 1][3], dp[0][j - 1][2] + v);
            } else {
                dp[0][j] = dp[0][j - 1];
            }
        }
        
        // メイン部分
        for (int i = 1; i < R; i++) {
            for (int j = 1; j < C; j++) {
                int v = Vs[i][j];
                long vFromUpper = max4(dp[i - 1][j]);
                if (0 < v) {
                    dp[i][j][0] = Long.max(dp[i][j - 1][0], vFromUpper);
                    dp[i][j][1] = max3(dp[i][j - 1][1], dp[i][j - 1][0] + v, vFromUpper + v);
                    dp[i][j][2] = Long.max(dp[i][j - 1][2], dp[i][j - 1][1] + v);
                    dp[i][j][3] = Long.max(dp[i][j - 1][3], dp[i][j - 1][2] + v);
                    
                } else if (dp[i][j - 1][0] < vFromUpper) {
                    dp[i][j][0] = vFromUpper;
                    dp[i][j][1] = dp[i][j - 1][1];
                    dp[i][j][2] = dp[i][j - 1][2];
                    dp[i][j][3] = dp[i][j - 1][3];
                } else {
                    dp[i][j] = dp[i][j - 1];
                }
            }
        }
        
        System.out.println(max4(dp[R - 1][C - 1]));
    }
    
    private static long max3(long val1, long val2, long val3) {
        return Long.max(Long.max(val1, val2), val3);
    }
    
    private static long max4(long[] vals) {
        return Long.max(Long.max(vals[0], vals[1]), Long.max(vals[2], vals[3]));
    }
}


Measured memory_bytes: 705272
using System;

namespace ITP1_8
{
    class Program
    {
        static void Main()
        {
            char[] al = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
            string s = "";

            while(true)
            {
                string _t = Console.ReadLine();
                if(_t == null) break;
                s += _t.Trim('\n').ToLower();
            }

            foreach(char c in al)
              Console.WriteLine("{0} : {1}", c, s.Length - s.Replace(c.ToString(), "").Length);
        }
    }
}

Measured memory_bytes: 9172
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

const int INF = pow(10, 9);

int N;
int A, B, C;
vector<int> ls;

int dfs(int idx, int a, int b, int c) {
  if (idx == N) {
    if (a == 0 || b == 0 || c == 0) {
      return INF;
    }
    return abs(A - a) + abs(B - b) + abs(C - c) - 30;
  }

  int v1 = dfs(idx + 1, a, b, c);
  int v2 = dfs(idx + 1, a + ls[idx], b, c) + 10;
  int v3 = dfs(idx + 1, a, b + ls[idx], c) + 10;
  int v4 = dfs(idx + 1, a, b, c + ls[idx]) + 10;

  return min(v1, min(v2, min(v3, v4)));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B >> C;
  ls.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> ls[i];
  }

  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
xy = [[int(x) for x in input().split()] for i in range(N)]
ans = 0
count = 0
for city in itertools.permutations(xy,2):
  ans += ((city[0][0]-city[1][0])**2 + (city[0][1]-city[1][1])**2)**0.5
  count += 1
print(ans/N)

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N, K;
  cin>>N>>K;
  cout << (N%K ==0 ? 0 : 1) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int main () {
  int H, W;
  cin >> H >> W;
    
  unordered_set<int> only_white_col;
  unordered_set<int> only_white_row;
  bool only_white;
    
  char sq[H][W];
  for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
          cin >> sq[i][j];
      }
  }
  
  for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
          if (sq[i][j] != '.') {
              only_white = false;
              break;
          } else {
              only_white = true;
          }
      }
      if (only_white) {
          only_white_row.insert(i);
      }
  }
    
  for (int i = 0; i < W; ++i) {
      for (int j = 0; j < H; ++j) {
          if (sq[j][i] != '.') {
              only_white = false;
              break;
          } else {
              only_white = true;
          }
      }
      if (only_white) {
          only_white_col.insert(i);
      }
  }
    
  for (int i = 0; i < H; ++i) {
      if (only_white_row.count(i) != 0) {
          continue;
      }
      for (int j = 0; j < W; ++j) {
          if (only_white_col.count(j) != 0) {
              continue;
          }
          cout << sq[i][j];
      }
      cout << "\n";
  }
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
   int n;
   while(cin >> n){
       if(n == 0)return 0;
       vector<float> v;
       for(int i = 0;i < n;i++){
           float b;cin >> b;
           v.push_back(b);
       }
       float sum = accumulate(v.begin(), v.end(), 0.0) / n;
       int ans = 0;
       for(auto f : v){
           if(sum >= f)ans++;
       }
       cout<<ans<<endl;
   }
}



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<PII> b(m);
    REP(i, m) cin >> b[i].second >> b[i].first;
    sort(ALL(a));
    sort(ALL(b), greater<>());

    ll idx = 0;
    REP(i, n) {
        if(idx < m && a[i] < b[idx].first) {
            a[i] = b[idx].first;
            b[idx].second--;
            if(b[idx].second == 0) idx++;
        }
    }

    ll ret = 0;
    REP(i, n) ret += a[i];
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 2560
// https://atcoder.jp/contests/dp/tasks/dp_k

#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n,k;cin>>n>>k;
  vector<int>stones(n);
  vector<bool>dp(k+1); // dp[i]- true if first player wins and there are i stones remainiing
  for(int i=0;i<n;i++)  cin>>stones[i];
  for(int x=0;x<=k;x++){
    for(int k: stones){
      if(x-k>=0 and !dp[x-k]) dp[x]=true; // if first player takes k stones, x-k are remaining and to first player to win dp[x-k] should be false
    }
  }
  dp[k]?cout<<"First":cout<<"Second"<<endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
xl = [list(map(int,input().split())) for _ in range(n)]
st = [[x-l, x+l] for x, l in xl]
st = sorted(st, key=lambda x: x[1])
result = 1
p = st[0][1]
for i in range(1, n):
    if p <= st[i][0]:
        p = st[i][1]
        result += 1
print(result)

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

int main(){
  int k, t; cin >> k >> t;
  int a[t];

  int m = 0;
  for(int i=0; i<t; i++){
    cin >> a[i];
    m = max(m, a[i]);
  }

  cout << max(m - 1 - (k-m), 0) << endl;

  return 0;
}


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

int main(){
  int A, B;
  int a, b, c, d, e;
  cin >> A >> B;
  int count = 0;
  for(int i=A; i <= B; i++){
    a = i/10000;
    b = (i - a*10000)/1000;
    c = (i - a*10000 - b*1000)/100;
    d = (i - a*10000 - b*1000 -c*100)/10;
    e = i%10;
    if(a==e && b==d)
      count++;
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct UnionFind{
	vector<int> par,ran;
	UnionFind(int n):par(n),ran(n,0){
		for(int i=0;i<n;i++){
			par[i]=i;
		}
	}
	int find(int x){
		return (x==par[x]?x:par[x]=find(par[x]));
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y){
			return;
		}else{
			if(ran[x]<ran[y]){
				par[x]=y;
			}else{
				par[y]=x;
				if(ran[x]==ran[y]){
					ran[x]++;
				}
			}
		}
	}
};
	int c[4];
int main(){
	int a,b;
	cin>>a>>b;
	a--;b--;
	c[a]++;
	c[b]++;
	cin>>a>>b;
	a--;b--;
	c[a]++;
	c[b]++;
	cin>>a>>b;
	a--;b--;
	c[a]++;
	c[b]++;
	int d=0,e=0;
	for(int i=0;i<4;i++){
		if(c[i]==1){
			d++;
		}else if(c[i]==2){
			e++;
		}
	}
	if(d==2&&e==2){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256