akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#ABC140 E
#類題 AGC5 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
if s[:1] == 'k' and s[-6:] == 'eyence':
    print('YES')
elif s[:2] == 'ke' and s[-5:] == 'yence':
    print('YES')
elif s[:3] == 'key' and s[-4:] == 'ence':
    print('YES')
elif s[:4] == 'keye' and s[-3:] == 'nce':
    print('YES')
elif s[:5] == 'keyen' and s[-2:] == 'ce':
    print('YES')
elif s[:6] == 'keyenc' and s[-1:] == 'e':
    print('YES')
elif s[:7] == 'keyence' or s[-7:] == 'keyence':
    print('YES')
else:
    print('NO')
    

Measured memory_bytes: 38376
// Original: https://github.com/tanakh/competitive-rs
#[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")
    };
}

#[allow(dead_code)]
fn chmin<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x > y && {
        *x = y;
        true
    }
}

#[allow(dead_code)]
fn chmax<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x < y && {
        *x = y;
        true
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input!(l: usize, r: usize);

    let mut ans = 1 << 50;
    let m = 2019;
    let lim = min(r + 1, l + m);
    for i in l..lim {
        for j in l..lim {
            if i == j {
                continue;
            }
            ans = min(ans, (i * j) % m);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int t = 0;
  while (a >= b) {
    b *= 2;
    t++;
  }
  while(b >= c){
    c *= 2;
    t++;
  }
  if( t <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
     
}

Measured memory_bytes: 3628
import java.io.*;

public class Main{
  public static void main(String[] args){
    BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
    try{
      String line;
      while((line=reader.readLine())!=null){
        if(line.equals("0")) break;
        int sum=0;
        char[] x=line.toCharArray();
        for(char a:x) sum+=a-'0';
        System.out.println(sum);
      }
    }catch(IOException e){
      System.out.println(e);
    }
  }
}



Measured memory_bytes: 24232
n = int(input())
a = map(int, input().split())
d = {}
s = 0
c = 0
for i in a:
    s += i
    if s == 0:
        c+=1
    if s in d:
        c+=d[s]
        d[s]+=1
    else:
        d[s]=1

print(c)

Measured memory_bytes: 45036
H, W = map(int, input().split())

grid = []
for _ in range(H):
    line = input()
    # 後で都合が良いので末尾に足しておく
    line += "#"
    grid.append(line)

# 後で都合が良いので末尾に足しておく
grid.append("#" * W)
# print(grid)

G_h = []
for h in range(H):
    g = [-1] * W
    lamp_start = -1
    lamp = 0
    line = grid[h]
    for w in range(W):
        if line[w] == "#":
            g[w] = 0
        elif line[w] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = w
                # print("lampstart", w)
            if line[w + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, w + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_h.append(g)

# print(G_h)

G_v = []
for w in range(W):
    g = [-1] * H
    lamp_start = -1
    lamp = 0
    line = []
    for hi in range(H):
        line.append(grid[hi][w])
    line.append("#")
    # line = grid[w]
    for h in range(H):
        if line[h] == "#":
            g[h] = 0
        elif line[h] == ".":
            lamp += 1
            if lamp_start == -1:
                lamp_start = h
                # print("lampstart", w)
            if line[h + 1] == "#":
                # print("lampend", w)
                for i in range(lamp_start, h + 1):
                    g[i] = lamp
                lamp_start = -1
                lamp = 0
    G_v.append(g)

# print(G_v)

ans = 0
for h in range(H):
    for w in range(W):
        tmp_ans = G_h[h][w] + G_v[w][h] - 1
        ans = max(ans, tmp_ans)
print(ans)


Measured memory_bytes: 143536
#include <stdio.h>

int main(void){
    int K, A, B;
    int x;

    scanf("%d%d%d", &K, &A, &B);
    x = A + (K - A % K);
    if(A % K == 0 || x <= B)
        printf("OK\n");
    else
        printf("NG\n");

    return 0;
}


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

long long mod = 1000000007;

class UnionFind
{
public:
   vector<int> parent;
   UnionFind(int N)
   {
      for (int i = 0; i < N; i++)
      {
         parent.push_back(-1);
      }
   }
   int root(int A)
   {
      if (parent[A] < 0)
         return A;
      return parent[A] = root(parent[A]);
   }
   int size(int A)
   {
      return -parent[root(A)];
   }

   bool unite(int A, int B)
   {
      A = root(A);
      B = root(B);
      if (A == B)
         return false;
      if (size(A) < size(B))
         swap(A, B);
      parent[A] += parent[B];
      parent[B] = A;
      return true;
   }
};

int main(void)
{
   int N, M;
   cin >> N >> M;
   vector<int> A(M), B(M);
   UnionFind UF(N);
   for (int i = 0; i < M; i++)
   {
      cin >> A[i] >> B[i];
      A[i]--;
      B[i]--;
   }
   for (int i = 0; i < M; i++)
   {
      UF.unite(A[i], B[i]);
   }
   int ans = 0;
   for (int i = 0; i < N; i++)
   {
      ans = max(ans, UF.size(i));
   }
   cout << ans << endl;
   return 0;
}


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

#define dbg(a)	cerr << #a << " = " << a << endl;

int main(){
	int n, k;	cin >> n >> k;
	int ans = 0;
	while (n > 0){
		ans++;
		n /= k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


a, b, c = invr()
res = 0

while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    if a == b == c:
        res = -1
        break
    ra = a/2
    rb = b/2
    rc = c/2

    a = ra + rc
    b = rb + ra
    c = rc + rb
    res += 1
print(res)


Measured memory_bytes: 3188
import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
p = na()


p.sort()

print(sum(p[:k]))

Measured memory_bytes: 68908
#include <stdio.h>

int main(void)
{
	int num[51][51] = {0};
	char bomb[51][51];
	int H,W;
	int i,j;
	
	scanf("%d",&H);
	scanf("%d",&W);
	
	for (i = 0;i < H;i++){
		scanf("%s",bomb[i]);
	}
	
	for (i = 0;i < H;i++){
		for (j = 0;j < W;j++){
			if (bomb[i][j] == '#'){
				if (i-1 >= 0){
					num[i-1][j]++;
				}
				if (i+1 < 50){
					num[i+1][j]++;
				}
				if (j-1 >= 0){ 
					num[i][j-1]++;
				}
				if (j+1 < 50){ 
					num[i][j+1]++;
				}
				if (i-1 >= 0 && i-1 >= 0){ 
					num[i-1][j-1]++;
				}
				if (i-1 >= 0 && j+1 < 50){ 
					num[i-1][j+1]++;
				}
				if (i+1 < 50 && j-1 >= 0){ 
					num[i+1][j-1]++;
				}
				if (i+1 < 50 && j+1 < 50){  
					num[i+1][j+1]++;
				}
			}
		}
	}
	
	for (i = 0;i < H;i++){
		for (j = 0;j < W;j++){
			if(bomb[i][j] == '#'){
				printf("#");
			}
			else {
			printf("%d",num[i][j]);
			}
		}
		printf("\n");
	}
	return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VLL ru(n+1);
    REP(i,0,n) ru[i+1] = ru[i] + a[i];
    LL ans = ru[n];
    REP(i,0,n) ans = min(ans, abs(ru[n] - ru[i+1] * 2));
    cout << ans << endl;
}

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

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int a,b;cin>>a>>b;
    if(a<=8&&b<=8)cout<<"Yay!";
    else cout<<":(";;
    return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N;
		int i;
		N = sc.nextLine();
		for (i = 0; i < N.length() / 2; i++) {
			if (N.charAt(i) != N.charAt(N.length() - i - 1)) {
				System.out.println("No");
				break;
			}
		}
		if (i == N.length() / 2) {
			System.out.println("Yes");
		}
	}
}


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

using namespace std;
typedef pair<int, int> P;

int main(){
    int n;
    cin >> n;
    vector<P> anslist[15];
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++)
        {
            int x,y;
            cin >> x>>y;
            x--;
            anslist[i].push_back(P(x, y));
        }
    }
    bool ok = false;
    int ans = 0;
    int cnt = 0;
    for (int bit = 0; bit < (1 << n); bit++) /*正直者のパターンを全列挙*/
    {
        ok = true;
        for (int i = 0; i < n; i++) /*正直者と仮定した人の証言チェック*/
        {
            if(bit & (1<<i))
            {
                
                for(auto p : anslist[i])//正直者と仮定した人の証言リストを全探索
                {
                    if(p.second == 0 &&  bit & (1<<p.first))
                    {
                        /*不親切と証言した人が正直者と仮定されていたら*/
                        ok = false;
                        break;
                    }
                    if(p.second == 1 && !( bit & (1<<p.first) ))
                    {
                        /*不親切と仮定した人が正直者と証言されていたら*/
                        ok = false;
                        break;
                    }

                }

                
            }

        }
        if(ok)
        {
            ans = max(ans, __builtin_popcount(bit));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back

int main()
{
    double R;
    cin >> R;
    cout << setprecision(3) << 2*M_PI*R << endl;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
const int N = 2e6 + 5;

int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}
int32_t main(){
	fast;
	precompute();
	
	int r1,c1,r2,c2;
	
	cin >> r1 >> c1 >> r2 >> c2;
	
	int ans = 0;
	int n = r2 - r1 + 1;
	for(int i= r1 + c1 ; i <= r1 + c2 ; i++)
	{
		ans += nCr(i + n , r1 + n - 1);
		ans %= MOD;
		ans = (ans - nCr(i ,r1 - 1) + MOD)%MOD;
	}
	cout << ans;
}



Measured memory_bytes: 31488
S = str(input())
ans = []
for i in [int(S[1]),-int(S[1])]:
    for j in [int(S[2]),-int(S[2])]:
        for k in [int(S[3]),-int(S[3])]:
            if int(S[0]) == 7 - (i+j+k):
                ans = [i,j,k]
sg = []
for a in ans:
    if a < 0:
        sg.append('-')
    else:
        sg.append('+')
ek =''.join([S[0],sg[0],S[1],sg[1],S[2],sg[2],S[3]])
print(ek + '=7')



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
int r;
int main() {
	cin >> r;
	printf("%.12lf\n", 2.0*PI*r);
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> 
void __print(const pair<T, V> &x)
{
	cerr << '{'; __print(x.first);
	cerr << ','; __print(x.second);
	cerr << '}';
}

template<typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}

void _print()
{
	cerr << "]\n";
}

template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", "; _print(v...);
}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

	int flag=1;
	// push_back inerts at back
	// push_front inserts at front

	deque<char> alpha;
	string s;
	cin >> s;
	for (int i=0;i<=s.length()-1;i++)
	{
		alpha.push_back(s[i]);
	}    

	int q;
	cin >> q;
	for (int i=0;i<=q-1;i++)
	{
		int t;
		cin >> t;
		if (t==1)
		{
			// reverse the string 
			if (flag==1)
			{
				flag=0;
			}
			else
			{
				flag=1;
			}
		}
		else
		{
			int f;
			char c;
			cin >> f >> c;
			if (f==1)
			{
				// c is added at beginning
				if (flag==1)
				{
					alpha.push_front(c);
				}
				else
				{
					alpha.push_back(c);
				}
			}
			else
			{
				// c is added at the back
				if (flag==1)
				{
					alpha.push_back(c);
				}
				else
				{
					alpha.push_front(c);
				}
			}
		}
	}

	if (flag==1)
	{
		while (alpha.size()!=0)
		{
			cout << alpha.front();
			alpha.pop_front();
		}
	}
	else
	{
		while (alpha.size()!=0)
		{
			cout << alpha.back();
			alpha.pop_back();
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 976
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		double ans=0;
		for(int i=0;i<n;i++){
			double x=scanner.nextDouble();
			String u=scanner.next();
			if(u.equals("JPY")){
				ans+=x;
			}else{
				ans+=380000*x;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int n,k;
long long h[100010], g[100010];

int main() {


	std::cin >> n >> k;

	for (int i = 1; i <= n; ++i) {
		std::cin >> h[i];
		g[i] = 1000000000;
	}

	g[1] = 0;
	

	for (int i = 2; i <= n; ++i) {
		if (i == 2) {
			g[i] = g[i - 1] + std::abs(h[i - 1] - h[i]);
		}
		else {
			for (int j = 1; j <= k; ++j) {
				if (i - j <= 0) {
					continue;
				}
				g[i] = std::min(g[i], g[i - j] + std::abs(h[i - j] - h[i]));
			}
		}
	}
	std::cout << g[n] << std::endl;
	//system("pause");
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    string s;
    cin>>s;
    int count=0;
    int N=s.length();
    for(int i=0;i<s.length()-i-1;i++){
        if(s[i]!=s[N-1-i]){
            count++;
        }
    }
    out(count);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using std::cin;using std::cout;using std::endl;using std::cerr;

typedef long long ll;

const ll mod = 998244353,mmax = 3000;

ll a,b,c,d;
ll dp[mmax + 10][mmax + 10];

int main(){

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

	cin>>a>>b>>c>>d;
	dp[a][b] = 1;

	for(ll i = a;i <= c;i++){
        for(ll j = b;j <= d;j++){
            if(i == a && j == b) continue;
            (dp[i][j] = (dp[i][j - 1] * i) % mod + (dp[i - 1][j] * j) % mod - (((dp[i - 1][j - 1] * (i - 1) ) % mod )* (j - 1)) % mod) %= mod;
         }
	}

	cout<<(dp[c][d] + mod) % mod;

	return 0;
}


Measured memory_bytes: 74188
#include<iostream>
using namespace std;
int a[200005];
int main() {
	int n;
	int pos = 1,flag=1,on_off=0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = pos; i <= n; i++) {
		if (a[i] == flag) {
			on_off = 1;
			++flag;
			pos = i;
		}
	}
	if (on_off == 0)
		return cout << -1, 0;
	else
		return cout << n - flag+1, 0;
}

Measured memory_bytes: 1024
<?php
  $s = "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";
  $arr = explode(", ", $s);
  $k = trim(fgets(STDIN));
  echo $arr[$k - 1];
 ?>

Measured memory_bytes: 4728
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e5);

vecl ADJ[3*INIT+1];
bool visit[3*INIT+1]={false};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	READV(N);
	READV(M);
	FORI(i,0,M)
	{
		READV(u);
		READV(v);
		ADJ[u].push_back(INIT+v);
		ADJ[INIT+u].push_back(2*INIT+v);
		ADJ[2*INIT+u].push_back(v);
	}
	READV(S);
	READV(T);
	queue<pll> bfs;
	bfs.push({S,0});
	visit[S]=true;
	while(sz(bfs)>0)
	{
		pll u=bfs.front();
		bfs.pop();
		if (u.fi==T)
		{
			cout<<u.se/3<<endl;
			break;
		}
		for (auto v:ADJ[u.fi])
		{
			if (!visit[v])
			{
				visit[v]=true;
				bfs.push({v,u.se+1});
			}
		}
	}
	if (!visit[T])
	{
		cout<<-1<<endl;
	}

	return 0;
}

Measured memory_bytes: 17024
function hoge(x,y,z)
    if x<= z && z<=y
        println("Yes")
    else
        println("No")
    end
end

input = readline() 
a,b,c = split(input," ")
a = parse(Int,a)
b = parse(Int,b)
c = parse(Int,c)
hoge(a,b,c)

Measured memory_bytes: 163728
#include <bits/stdc++.h>
#define pb push_back
#define pp pair<int, int>
#define fr(n) for(int i=0;i<n;i++)
#define fr1(n) for(int i=1;i<=n;i++)
typedef long long ll;
using namespace std;


ll power(int x, unsigned int y)
{
    int temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

const int mod = 1000000007;
const int MAX = 1000001;
bool prime[MAX];

void sieve ()
{
    int i,j;
    prime[0] = prime[1] = true;

    for (i=4; i<MAX; i+=2)
        prime[i] = true;

    for (i=3; i*i<=MAX; i+=2)
        if (!prime[i])
            for (j=i*i; j<MAX; j+=2*i)
                prime[j] = true;
}

        int res=0;




int findUniquePair(int arr[], int n)
{
    int XOR = arr[0];
    for (int i = 1; i < n; i++)
        XOR = XOR ^ arr[i];

    int set_bit_no = XOR & ~(XOR-1);
    int x=0,y=0;

    for (int i = 0; i < n; i++)
    {
        if (arr[i] & set_bit_no)
            x = x ^ arr[i];
        else
            y = y ^ arr[i];
    }

    return abs(x-y);

}

const int N=5009;


ll n,m,k;
ll a[N],sum[N];






/*

ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

*/
int mostFrequent(int arr[], int n)
{

    sort(arr, arr + n);


    int max_count = 1, res = arr[0], curr_count = 1;
    for (int i = 1; i < n; i++) {
        if (arr[i] == arr[i - 1])
            curr_count++;
        else {
            if (curr_count > max_count) {
                max_count = curr_count;
                res = arr[i - 1];
            }
            curr_count = 1;
        }
    }

    if (curr_count > max_count)
    {
        max_count = curr_count;
        res = max_count ;
    }

    return res;
}
int dp[1000001];


int main()
{
int n;
cin >> n;
int x[n];
    for(int i=0;i<n;i++)
        cin >> x[i];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(x[1]-x[0]);

    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(x[i]-x[i-1]),dp[i-2]+abs(x[i]-x[i-2]));
cout<<dp[n-1];



    return 0;

}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
 
#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif
 
struct Narou{
	using D = ll;
	priority_queue<D> L;
	priority_queue<D,V<D>,greater<D>> R;
	ll offL = 0, offR = 0;
	ll bottom = 0;
 
	// initially f(x) = 0
 
	void Min(D l,D r){	// f'(x) := min_[y+l,y+r] f(y)
		assert(l <= r);
		offL -= r;
		offR -= l;
	}
	void Add(ll s){		// f'(x) := f(x) + |x-s|
		offL -= s, offR -= s;
		if(L.empty()){
			L.push(0-offL); R.push(0-offR);
			offL += s, offR += s;
			return;
		}
		D le = L.top() + offL, ri = R.top() + offR;
		if(le <= 0 && 0 <= ri){
			L.push(0-offL); R.push(0-offR);
		}else if(ri < 0){
			bottom += -ri;
			L.push(ri-offL); R.pop();
			R.push(0-offR); R.push(0-offR);
		}else{
			bottom += le;
			R.push(le-offR); L.pop();
			L.push(0-offL); L.push(0-offL);
		}
		offL += s, offR += s;
	}
	void AddConst(ll c){	// f'(x) = f(x) + c
		bottom += c;
	}
	D f(ll s){		//O(N) :(
		offL -= s, offR -= s;
		D le = L.top() + offL, ri = R.top() + offR;
		ll res = bottom;
		if(le <= 0 && 0 <= ri){
		}else if(ri < 0){
			auto cp = R;
			rep1(k,cp.size()){
				R.pop();
				D nri = R.empty() ? 0 : R.top() + offR;
				if(nri >= 0){
					R = cp;
					res += (-ri) * k;
					break;
				}
				res += (nri-ri) * k;
				ri = nri;
			}
		}else{
			auto cp = L;
			rep1(k,cp.size()){
				L.pop();
				D nle = L.empty() ? 0 : L.top() + offL;
				if(nle <= 0){
					L = cp;
					res += le * k;
					break;
				}
				res += (le-nle) * k;
				le = nle;
			}
		}
		offL += s, offR += s;
		return res;
	}
};
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	V<ll> l(N),r(N);
	rep(i,N) cin >> l[i] >> r[i];
	Narou f;
	rep(i,N){
		if(i) f.Min(l[i-1]-r[i-1],r[i]-l[i]);
		f.Add(l[i]);
	}
	cout << f.bottom << endl;
}

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

int snxt[4010][2];
int tnxt[4010][2];
tuple<int, int, char> rec[4010][4010];
bool visited[4010][4010];
int main() {
	string s, t; cin >> s >> t;
	s = "$" + s;
	t = "$" + t;
	int sn = s.size(), tn = t.size();
	int las0 = sn, las1 = sn;
	snxt[sn][0] = snxt[sn][1] = sn;
	for(int i = sn - 1; i >= 0; --i) {
		snxt[i][0] = las0;
		snxt[i][1] = las1;
		if(s[i] == '0') las0 = i;
		if(s[i] == '1') las1 = i;
	}
	las0 = las1 = tn;
	tnxt[tn][0] = tnxt[tn][1] = tn;
	for(int i = tn - 1; i >= 0; --i) {
		tnxt[i][0] = las0;
		tnxt[i][1] = las1;
		if(t[i] == '0') las0 = i;
		if(t[i] == '1') las1 = i;
	}

	queue<tuple<int, int, char>> que;
	que.push(make_tuple(0, 0, '$'));
	visited[0][0] = true;
	rec[0][0] = make_tuple(-1, -1, '$');
	string ans;
	while(que.size()) {
		int si, ti;
		char c;
		tie(si, ti, c) = que.front();
		que.pop();
		if(si == sn and ti == tn) {
			ans = c;
			break;
		}
		int nsi0 = snxt[si][0], nti0 = tnxt[ti][0];
		if(not visited[nsi0][nti0]) {
			visited[nsi0][nti0] = true;
			rec[nsi0][nti0] = make_tuple(si, ti, c);
			que.push(make_tuple(nsi0, nti0, '0'));
		}
		int nsi1 = snxt[si][1], nti1 = tnxt[ti][1];
		if(not visited[nsi1][nti1]) {
			visited[nsi1][nti1] = true;
			rec[nsi1][nti1] = make_tuple(si, ti, c);
			que.push(make_tuple(nsi1, nti1, '1'));
		}
	}
	int si = sn, ti = tn;
	while(true) {
		char pc;
		tie(si, ti, pc) = rec[si][ti];
		if(pc == '$') {
			cout << ans << endl;
			return 0;
		}
		ans = pc + ans;
	}
	return 0;
}


Measured memory_bytes: 130996
import functools


@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(((rec(N)-1)//10)//365+1)

Measured memory_bytes: 8296
#include<bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long a,b,k;
	cin>>a>>b>>k;
	if(k<a)a-=k,k=0;
	else k-=a,a=0;
	
	//cout<<a<<" "<<b<<" "<<k<<endl;
	if(k<b)b-=k,k=0;
	else b=0,k-=b;
	cout<<a<<" "<<b;
}

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

int main() {
  int N;
  cin >> N;    
    
  int a;
  a= N%10;
  N = (N-a)/10;
  
  int b;
  b= N%10;
  
  N= (N-b)/10;
  int c;
  c= N%10;
  
  if(a==7 || b==7 || c==7){
    cout <<"Yes"<< endl;
  }
  else{
  
  cout <<"No"<< endl;
  }
  return 0;
  
}


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


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int n, k;
	vector<int> x, y;
	set<P> zahyo;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		x.pb(a);
		y.pb(b);
		zahyo.insert(P(a,b));
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	usd llong int ans = 0;
	auto itbegin = zahyo.begin(), itend = zahyo.end();
	for(int l = 0; l < n-1; l++){
		for(int r = l+1; r < n; r++){
			for(int d = 0; d < n-1; d++){
				for(int u = d+1; u < n; u++){
					int left = x[l], right = x[r], down = y[d], up = y[u];
					int cnt = 0;
					for(auto it = itbegin; it != itend; it++){
						P check = *it;
						if(left <= check.first && check.first <= right &&
							down <= check.second && check.second <= up) cnt++;
					}
					// cout << right << " " << left << " " << up << " " << down << endl;
					usd llong int now = ((usd llong int)right-left)*((usd llong int)up-down);
					// cout << now << endl;
					if((ans == 0 || now < ans) && cnt >= k) ans = now;
					// cout << now << " " << ans << endl;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int A, B, X;
    scanf("%d %d %d", &A, &B, &X);

    if (A + B < X) {
        printf("NO\n");
    } else if (A > X) {
        printf("NO\n");
    } else {
        printf("YES\n");
    }

    return 0;
}


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

int N, Q;
struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};
int main() {
    cin >> N >> Q;
    LazySegmentTree seg( vector<ll>(N, 0) );
    for(int i=0; i<Q; i++) {
        int query; cin >> query;
        if(query == 0) {
            int s, t, x; cin >> s >> t >> x;
            seg.add(s-1, t, x);
        }
        else {
            int s, t; cin >> s >> t;
            cout << seg.getsum(s-1, t) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7600
import sys
input = sys.stdin.readline

n=int(input())
D={}

for i in range(1,n+1):
    s=(str(i)[0],str(i)[-1])
    if s not in D:
        D[s]=1
    else:
        D[s]+=1
ans=0
for i in D:
    t=(i[1],i[0])
    if t in D:
        ans+=D[t]*D[i]
print(ans)

Measured memory_bytes: 40428
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


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


    cout << "A" << b[0] << "C" << endl;
    return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    int counter = 0;
    int s = 1;
    while(s <= B){
        if(s == B) break;
        else{
            counter++;
            s += (A - 1);
        }
    }
    cout << counter << endl;
}

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

vector < int > vec;
int n;

bool check(){

  for(int i=0;i<vec.size();i++) if(vec[i] != i+1) return false;

  return true;
}

int main(){
  
  while(cin >> n, n){
    
    vec.clear();
    for(int p, i=0;i<n;i++){
      cin >> p;
      vec.push_back(p);
    }

    int ans = 0;
    for(;ans<10000;ans++){
      if(check()) break;
      
      int cnt = vec.size();
      for(int i=0;i<vec.size();i++){
	vec[i]--;
	if(!vec[i]) vec.erase(vec.begin()+i--);
      }
      
      vec.push_back(cnt);
      
    }
    if(ans == 10000) cout << -1 << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 1236
#include<iostream>

using namespace std;

int w[105];
int abs(int x){
  if(x>=0)return x;
  else return -x;
}
int main(){
  int n;
  cin>>n;
  int ans=1e5+5;;
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>w[i];
    sum+=w[i];
  }
  int tmp_sum=0;
  for(int i=0;i<n-1;i++){
    tmp_sum+=w[i];
    ans=min(ans,abs(sum-2*tmp_sum));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 0, mod = (int) 0;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    string t = "";
    for (int i = 0; i < 4; ++i)
        t += s[i];
    t += " ";
    for (int i = 4; i < 12; ++i)
        t += s[i];
    cout << t << endl;


}


Measured memory_bytes: 256
import heapq
from itertools import accumulate, groupby, islice
 
s = input()
n = int(input())
 
gens = [accumulate(s[i:]) for i in range(len(s))]
sm = heapq.merge(*gens)
res, _ = next(islice(groupby(sm), n-1, n))
print(res)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, k;
	cin >> n >> k;
	cout << setprecision(15);
	double ans = 0;;
	// サイコロを振って i がでたときの勝率を全て足せば求まる。
	for(int i = 1; i <= n; i++){
		// i スタートのとき、何回2倍すればk以上になるか
		int tmp = i;
		int count = 0;
		while(tmp < k){
			tmp *= 2;
			count ++;
		}
		//debug(count);
		// count回連続で表が出ればok
		ans += 1./(1.* pow(2,count));
	}
	cout << ans/(1.*n) << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    string n;
    string ans = "";
    cin >> n;
    REP(i, n.length()) {
        if(n[i] == '1') { ans += '9'; }
        else { ans += '1'; }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n, i = 1, x;
  cin >> n;
  for(i = 1; i <= n; i++){
    x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      while(x > 0) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        } else {
          x /= 10;
        }
      }
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3116
s = list(input())
l = len(s)

ans = 0

for bit in range(2 ** (l-1)):
    f = s[0]
    for i in range(l-1):
        if ((bit >> i) & 1):
            f += '+'
        f += s[i+1]

    ans += sum(map(int, f.split("+")))
print(ans)

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

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


int main(void){
    string ABCD;
    cin >> ABCD;
    
    for (int i = 0; i < (1 << 3); i++) {
        bitset<3> pn_sign(i);
        int sum = 0;
        string fomula = "";

        sum += (int)(ABCD.at(0) - '0');        
        fomula += ABCD.at(0);
        for (int j = 0; j < 3; j ++) {
            if(pn_sign.test(j) == 1) {
                sum += (int)(ABCD.at(j+1) - '0');
                fomula += ((string)"+" + ABCD.at(j+1));
            } else if (!pn_sign.test(j)) {
                sum -= (int)(ABCD.at(j+1) - '0');
                fomula += ((string)"-" + ABCD.at(j+1));
            }
        }
        if (sum == 7) {
            cout << fomula << "=7" << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,c=0;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(((i+1)%2!=0)&&(arr[i]%2!=0))
        c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3632
import sys, copy
sys.setrecursionlimit(100)

def g(mat, ind):
  return [k for k in range(len(mat)) if mat[ind][k]==1]

def f(mat, ind, sumi):
  sumi[ind]=1
  linknode=g(mat, ind)
  for j in linknode:
    if sumi[j]==0:
      sumi=f(mat, j, sumi)
  return sumi

N, M=map(int, input().split())
ab=[list(map(int, input().split())) for i in range(M)]
net=[[0]*(N+1) for i in range(N+1)]
for i in range(M):
  net[ab[i][0]][ab[i][1]]=1
  net[ab[i][1]][ab[i][0]]=1
  
counter=0
for i in range(M):
  temp=copy.deepcopy(net)
  temp[ab[i][0]][ab[i][1]]=0
  temp[ab[i][1]][ab[i][0]]=0
  if sum(f(temp, 1, [0]*(N+1)))!=N:
    counter+=1
print(counter)


Measured memory_bytes: 3544
def simple_is_prime(n):
    if n == 1:
        return False
    for i in range(2, n):
        if n%i==0:
            return False
    return True

N = int(input())
ans = []
for i in range(31, 55555, 30):
    if simple_is_prime(i):
        ans.append(i)
        N -= 1
    if N == 0:
        break
print(*ans)


Measured memory_bytes: 2940