akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
vector<int>C;
int deg[12345];
int num[12345];
vector<pair<int, int>>ed;
vector<int>G[12345];

int main() {
	cin >> N;
	for (int i = 1; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		deg[a]++;
		deg[b]++;
		ed.push_back({ a,b });
		G[a].push_back(b);
		G[b].push_back(a);
	}
	multiset<pair<int, int>>vec;
	for (int i = 0; i < N; ++i) {
		int c;
		cin >> c;
		C.push_back(c);
		vec.insert({ deg[i],i });
	}
	sort(C.begin(), C.end());
	for (int i = 0; i < N; ++i) {
		int v = vec.begin()->second;
		num[v] = C[i];
		vec.erase({ deg[v],v });
		deg[v] = 0;
		for (int a : G[v]) {
			if (deg[a]) {
				vec.erase(vec.find({ deg[a],a }));
				deg[a]--;
				vec.insert({ deg[a],a });
			}
		}
	}
	LL ans = 0;
	for (auto e : ed) {
		ans += min(num[e.first], num[e.second]);
	}
	cout << ans << endl;
	for (int i = 0; i < N; ++i) {
		cout << num[i] << " \n"[i == N - 1];
	}
	return 0;
}

Measured memory_bytes: 1664
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def is_nth_bit_set(x, n):
    if x & (1 << n):
        return True
    else:
        return False


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

    comments = [[] for _ in range(N)]
    for i in range(N):
        A = int(input())
        for _ in range(A):
            x, y = map(int, input().split())
            x -= 1
            comments[i].append((x, y))

    total = 2 ** N
    ans = 0
    for pattern in range(total):
        flag = True
        tmp = 0
        for i in range(N):
            if is_nth_bit_set(pattern, i):
                tmp += 1
                for x, y in comments[i]:
                    if is_nth_bit_set(pattern, x) == bool(y):
                        continue
                    else:
                        flag = False
                        break
            else:
                continue

            if not flag:
                break

        if flag:
            if tmp > ans:
                ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    auto itr = max_element(a.begin(), a.end(), [](int &x, int &y) -> bool {
        return abs(x) < abs(y);
    });

    queue<pair<int, int>> hist;
    for (int i = 0; i < n; i++) {
        if ((ll)a[i] * (*itr) < 0) hist.push(make_pair((int)(itr - a.begin() + 1), i + 1));
    }
    for (int i = 0; i < n - 1; i++) {
        hist.push(make_pair((*itr >= 0 ? i + 1 : n - i), (*itr >= 0 ? i + 2 : n - i - 1)));
    }

    cout << hist.size() << endl;
    while (!hist.empty()) {
        auto p = hist.front(); hist.pop();
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}

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


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;
}

bool is_kaibun(string S) {
    bool flag = true;
    REP(i, S.size()/2) {
        if(S[i] != S[S.size() - 1 - i]) {
            flag = false;
            break;
        }
    }
    return flag;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    vector<ll> num_a(n, 0);
    REP(i, n) {
            num_a[a[i] - 1] += 1;
        }
    ll sum;
    REP(i, n) {
        sum += num_a[i] * (num_a[i] - 1) / 2;
    }

    REP(k, n){
        cout << sum + 1 - num_a[a[k] - 1] << endl;
    }

}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, l;
  cin >> n >> l;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = -1;
  rep(i, n - 1) if(a[i] + a[i + 1] >= l) ans = i;
  if(ans >= 0) {
    cout << "Possible" << '\n';
    rep(i, ans) cout << i + 1 << '\n';
    for(ll i = n - 2; i >= ans + 1; i--) cout << i + 1 << '\n';
    cout << ans + 1 << '\n';
  } else
    cout << "Impossible" << endl;
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut aa = aa;
    aa.sort();

    let mut ans = 0;
    let mut cnt = 0;
    for i in 0..n {
        if i == 0 {
            cnt += 1;
            continue;
        }

        if aa[i] != aa[i-1] {
            if cnt < aa[i-1] {
                ans += cnt;
            } else {
                ans += cnt - aa[i-1];
            }
            cnt = 1;
        } else {
            cnt += 1;
        }
    }

    if cnt < aa[aa.len()-1] {
        ans += cnt;
    } else {
        ans += cnt - aa[aa.len()-1];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
typedef long long int ll;
ll a, b, c, d, e, N, H, W, K;

void input()
{
    cin >> N >> K;
}

ll solve()
{
}

int main()
{
    input();
    if (N % K == 0)
        cout << 0 << endl;
    else
        cout << 1 << endl;
}

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

using namespace std;

int main(void) {
    long long N;
    scanf("%lld", &N);

    long long a[N];
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }

    sort(&a[0], &a[N]);
    
    cout << a[N-1] - a[0] << endl;
    
}

Measured memory_bytes: 256
import java.util.*
 
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val V = readLine()!!.split(" ").map(String::toLong).toList()
    var ans = 0L
 
    for (l in 0..K) {
        for (r in 0..K-l) {
            if (l+r > N) break
            val list = mutableListOf<Long>()
            list.addAll(V.subList(0,l))
            list.addAll(V.subList(N-r,N))
            val ng = list.count{it<0}
            list.sort()
            val sum = list.drop(Math.min(ng,K-l-r)).sum()
            ans = Math.max(ans,sum)
        }
    }
    println(ans)
}

Measured memory_bytes: 39840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int[] cnt = new int[26];
		for (int i = 0; i < s.length; i++) {
			cnt[s[i] - 'A']++;
		}

		int cnt2 = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == 2) {
				cnt2++;
			}
		}
		if (cnt2 == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();
		sc.close();
		
		String o [] = O.split("");
		String e [] = E.split("");
		
		String ans = "";
		int min = Math.min(O.length(), E.length());
		
		for (int i=0; i<min; i++){
			ans+=o [i];
			ans+=e [i];
		}
		
		if (O.length()>E.length()){
			ans+=o[O.length()-1];
		}
		else if (O.length()<E.length()){
			ans+=e[E.length()-1];
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
int main(){

	int a,b,c,d,n,i;

	while(std::cin>>n&&n){
	i=0;

	for(a=0;a<=9;a++){
		for(b=0;b<=9;b++){
			for(c=0;c<=9;c++){
				for(d=0;d<=9;d++){
					if(a+b+c+d==n){
						i++;
			

						}
					}
				}
			}
		}

	std::cout<<i<<std::endl;
}
	return 0;
	}

Measured memory_bytes: 1160
class Dice:
    def __init__(self,l1,l2,l3,l4,l5,l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.top = 1
        self.front = 2
        self.right = 3

    def get_top(self):
        return eval("self." + 'l' + str(self.top))

    def get_right(self):
        return eval("self." + 'l' + str(self.right))

    def get_front(self):
        return eval("self." + 'l' + str(self.front))

    def get_bottom(self):
        return eval("self." + 'l' + str(7-self.top))

    def get_left(self):
        return eval("self." + 'l' + str(7-self.right))

    def get_back(self):
        return eval("self." + 'l' + str(7-self.front))

    def rot(self):
        self.front,self.right = self.right,7-self.front

    def move(self, order):
        if order == 'S':
            pretop = self.top
            self.top = 7 - self.front
            self.front = pretop
        elif order == 'E':
            pretop = self.top
            self.top = 7 - self.right
            self.right = pretop


def match_top(dice,target):
    for i in range(4):
        dice.move('S')
        if dice.get_top() == target:
            return dice
    return False


l = list(map(int,input().split()))
d1 = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

l = list(map(int,input().split()))
d2 = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

d1_top = d1.get_top()
d1_front = d1.get_front()
d1_right = d1.get_right()
d1_bottom = d1.get_bottom()
d1_back = d1.get_back()
d1_left = d1.get_left()
ret = match_top(d2,d1_top)

if ret == False:
    d2.move('E')
    ret = match_top(d2,d1_top)
if ret == False:
    print('No')
else:
    matched = False
    for i in range(4):
        d2.rot()
        if d2.get_front() == d1_front and \
        d2.get_right() == d1_right and \
        d2.get_bottom() == d1_bottom and \
        d2.get_left() == d1_left and \
        d2.get_back() == d1_back:
            matched = True
            print ('Yes')
            break
    if not matched:
        print('No')

Measured memory_bytes: 7928
N, M = map(int, input().split())
X = {}
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a in X:
        X[a].append(b)
    else:
        X[a] = [b]

    if b in X:
        X[b].append(a)
    else:
        X[b] = [a]

ans = [0 for _ in range(N)]
ans[0] = 1
que = [[0, X[0]]]
while len(que) > 0:
    f, targets = que.pop(0)
    for t in targets:
        if ans[t] == 0:
            ans[t] = f + 1
            que.append([t, X[t]])

if 0 in ans:
    print("No")
else:
    print("Yes")
    for a in ans[1:]:
        print(a)

Measured memory_bytes: 45120
/* written by : vipin kumar */
#include<iostream>
#include<set>
#include<map>
#include<unordered_set>
#include<cmath>
#include<algorithm>
using namespace std;
#include<vector>
#define int long long int
#define mod 1000000007
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int j,arr[n];
	for(j=0;j<n;j++)
	{
		cin>>arr[j];
	}
	int answer=0;
	int i;
	for(i=0;i<n;i++)
	{
		int total=0;
		for(j=0;j<n;j++)
		{
			if(arr[j]<arr[i])
			    total++;
		}
		int next=0;
		for(j=i+1;j<n;j++)
		{
			if(arr[j]<arr[i])
			    next++;
		}
		answer+=(k*next);
		answer%=mod;
		int val=(k*(k-1))/2;
		val%=mod;
		answer+=(total)*(val);
		answer%=mod;
	}
	cout<<answer<<endl;
}



Measured memory_bytes: 3568
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=200005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
char st[MAXN];
int main()
{
	scanf("%s",st+1);
	int n=strlen(st+1),flag=(st[1]=='0')|(st[n]=='1');
	for (int i=1;i<n;i++) flag|=(st[i]!=st[n-i]);
	if (flag) { puts("-1"); return 0; }
	for (int i=1,rt=1;i<n;i++) printf("%d %d\n",rt,i+1),rt=(st[i]=='1')?i+1:rt;
	return 0;
}

Measured memory_bytes: 3208
import sys

if __name__ == "__main__":
    a, b, c = [int(x) for x in input().split(" ")]
    if a + b >= c:
        print("No")
        sys.exit(0)
    if 4 * a * b < (c - a - b) ** 2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 61928
import java.awt.*;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    // 移動4方向のベクトル
    private static int[] dx = {1, 0, -1, 0};
    private static int[] dy = {0, 1, 0, -1};

    private static int[][] moves;

    private static char[][] display;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int H = Integer.parseInt(scanner.next());
        int W = Integer.parseInt(scanner.next());

        char[][] area = new char[H][W];
        display = new char[H][W];
        for (int i = 0; i < H; i++) {
            area[i] = scanner.next().toCharArray();
            display[i] = area[i];
        }

        scanner.close();

        int startY = 0;
        int startX = 0;
        Point start = new Point(startX, startY);
        Point goal = new Point(W - 1, H - 1);

        int whiteCount = 0;
        // 移動数を保持する配列
        moves = new int[H][W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                moves[i][j] = -1;
                if (area[i][j] == '.') {
                    whiteCount++;
                }
            }
        }

        // スタート地点を入れとく
        Queue<Point> queue = new LinkedList<>();
        queue.add(start);
        // スタート地点の距離を0とする
        moves[startY][startX] = 0;
        display[startY][startX] = '@';

        while (queue.size() > 0) {
            Point p = queue.remove();

            // 移動4方向のループ
            for (int i = 0; i < 4; i++) {
                // 移動後の座標
                int nx = p.x + dx[i];
                int ny = p.y + dy[i];

                // 移動可能でかつ、訪れたことがない位置か
                if (0 <= nx && nx < W && 0 <= ny && ny < H &&
                        moves[ny][nx] == -1 && area[ny][nx] != '#') {

                    if (new Point(nx, ny).equals(goal)) {
                        int count = moves[p.y][p.x];
                        // 白マスの数 - 最短経路 でスコアを出す
                        System.out.println(whiteCount - (count + 1 + 1));
                        return;
                    }
                    // 移動できるのでキューに入れて、その移動を記録する
                    queue.add(new Point(nx, ny));
                    moves[ny][nx] = moves[p.y][p.x] + 1;
                    display[ny][nx] = '@';
                }
            }

//            printArea(display);
        }
        System.out.println(-1);
    }

    private static void printArea(char[][] area) {
        for (char[] a : display) {
            for (char b : a) {
                System.out.print(b);
            }
            System.out.println("");
        }
        System.out.println("-----------------");
    }
}


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

int main()
{
    int n; cin >> n;
    vector<int> a{};
    for (int i = 1; i <= n; i++)
    {
        int x; cin >> x;
        a.push_back(x);
    }

    sort(a.begin(), a.end(), greater<int>());

    int d = abs(a[0] - a[1] * 2);
    for (int i = 2; i < n; i++)
    {
        int di = abs(a[0] - a[i] * 2);

        if (d >= di) d = di;
        else
        {
            cout << a[0] << " " << a[i - 1] << endl;
            return 0;
        }
    }

    cout << a[0] << " " << a[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 892
# -*- coding: utf-8 -*-

S = input()

ans = [0]*len(S)
r_counter = 0
l_first = 0
for i, s in enumerate(S):
    if i == len(S)-1 or (s == "L" and S[i+1] == "R"):
        l_counter = i-l_first+1
        ans[l_first] += int(l_counter/2) + l_counter%2
        ans[l_first-1] += int(l_counter/2)
    elif s == "R" and S[i+1] == "R":
        r_counter += 1
    elif s == "R" and S[i+1] == "L":
        r_counter += 1
        ans[i] += int(r_counter/2)+ r_counter%2
        ans[i+1] += int(r_counter/2)
        r_counter = 0
        l_first = i+1
print(' '.join(map(str, ans)))


Measured memory_bytes: 10484
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define itn int
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  ll k; cin >> k;
  ll n=50;
  vector<ll> ans(50);
  rep(i,50) ans[i]=i+k/n;
  for(int i=n-k%n;i<n;i++) ans[i]++;
  cout << n << endl;
  rep(i,n) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 3508
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  ll k,a,b;

  cin >> k >> a >> b;

  if(k <= a){
    cout << 1 << endl;
    return 0;
  }

  if(a-b <= 0){
    cout << -1 << endl;
    return 0;
  }

  cout << (k - a + (a-b-1)) / (a - b) * 2 + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

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

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

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

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

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

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

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

	X := scanInt()
	Y := scanInt()
	Z := scanInt()
	K := scanInt()
	a := scanInts(X)
	b := scanInts(Y)
	c := scanInts(Z)

	bc := []int{}
	for i := 0; i < Y; i++ {
		for j := 0; j < Z; j++ {
			bc = append(bc, b[i]+c[j])
		}
	}

	sort.Ints(bc)

	bc = bc[max(Y*Z-K, 0) : Y*Z]
	abc := []int{}

	for i := 0; i < len(bc); i++ {
		for j := 0; j < X; j++ {
			abc = append(abc, a[j]+bc[i])
		}
	}

	sort.Ints(abc)

	for i := 0; i < K; i++ {
		fmt.Fprintln(wr, abc[len(abc)-1-i])
	}

}


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

int cnt[3];

int main () {
    int N;
    scanf("%d", &N);
    for(int i=1;i<=N;i++) {
        int t;
        scanf("%d", &t);
        if(t%4==0) {
            cnt[2]++;
        } else if(t%2==0) {
            cnt[1]++;
        } else {
            cnt[0]++;
        }
    }
    
    for(int i=1;i<=cnt[0]-1;i++) {
        if(cnt[2] > 0) {
            cnt[2]--;
        } else {
            cout << "No";
            return 0;
        }
    }
    while(cnt[1] -(cnt[0]==0) > 0) {
        cnt[1]--;
        if(cnt[1] > 0) {
            cnt[1]--;
        } else if(cnt[2] > 0) {
            cnt[2]--;
        } else {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	int co[256]={0};
	rep(i,s.size())co[s[i]]++;
	int c=0;
	rep(i,256)c+=co[i]%2;
	if(c)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
const ll mod = 1e9 + 7;
char s[maxn];
int cnt[26];

int main() {
    int N;
    scanf("%d %s", &N, s + 1);
    for(int i = 1; i <= N; ++i) cnt[s[i] - 'a']++;
    ll ans = 1;
    for(int i = 0; i < 26; ++i) ans = (ans * (cnt[i] + 1)) % mod;
    printf("%lld\n", (ans + mod - 1) % mod);
    return 0;
}

Measured memory_bytes: 892
import java.util.*;

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

        int N = sc.nextInt();
        int T = sc.nextInt();
        int min = 1001;
        int[] c = new int[N];
        int[] t = new int[N];

        for(int i=0; i<N; i++){
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
            if(t[i]<=T){
                min = Math.min(min, c[i]);
            }
        }
        if(min==1001){
            System.out.println("TLE");
        }
        else{
            System.out.println(min);
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int selectionSort(int *,int);

int main(){
  int A[100],N;
  int i,count;

  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  count = selectionSort(A,N);
  for(i=0; i<N-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);
  return 0;
}

int selectionSort(int *A,int N){
  int i,j,minj,temp,count=0;

  for(i=0; i<=N-1; i++){
    minj = i;
    for(j=i; j<=N-1; j++){
      if(A[j] < A[minj])
	minj = j;
    }
    if(A[i] != A[minj]){
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      count++;
    }
  }
  return count;
}

Measured memory_bytes: 600
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int h,w,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},cnt=0,dist[55][55]={};
  char c[55][55]={};
  cin >> h >> w;
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      dist[i][j]=inf;
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> c[i][j];
      if(c[i][j]=='#') {
        cnt++;
      }
    }
  }
  queue<P> q;
  q.push(P(0,0));
  dist[0][0]=0;
  while(q.size()) {
    P p=q.front();
    q.pop();
    if(p.first==h-1&&p.second==w-1) {
      break;
    }
    for(int i=0; i<4; i++) {
      int nx=p.second+dx[i],ny=p.first+dy[i];
      if(0<=nx&&nx<w&&0<=ny&&ny<h&&c[ny][nx]=='.'&&dist[ny][nx]==inf) {
        q.push(P(ny,nx));
        dist[ny][nx]=dist[p.first][p.second]+1;
      }
    }
  }
  if(dist[h-1][w-1]==inf) {
    cout << -1 << endl;
  }
  else {
    cout << h*w-cnt-dist[h-1][w-1]-1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    string A,B;
    cin >> A >> B;
    if(A.size()>B.size()){
        cout << "GREATER" <<endl;
    }else if(A.size()<B.size()){
        cout <<"LESS"<<endl;
    }else{
        if((int)A[0] > (int)B[0]){
            cout << "GREATER" <<endl;
        }else if((int)A[0] < (int)B[0]){
            cout << "LESS" <<endl;
        }else{
            cout << "EQUAL" <<endl;
        }
    }
}

Measured memory_bytes: 3604
#!/usr/bin/env python3
n = int(input())
f = [[0]*10 for _ in range(n)]
p = [[0]*10 for _ in range(n)]
for i in range(n):
    f[i]  = list(map(int,input().split()))
for i in range(n):
    p[i]  = list(map(int,input().split()))
ans = - 10**9 -1 
for i in range(1,1024):
    rev = 0
    for j in range(n):# 時間帯jに関して何個かぶってるか
        cnt = 0#一致する店数
        for k in range(10):# 店k との一致する営業時間
            if 2**k & i and f[j][k]:#両方１なら開店
                cnt  += 1
        #print(cnt,j)
        rev += p[j][cnt]
    ans = max(rev,ans)
print(ans)



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

typedef long long ll;

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

const int maxn = 1e6 + 5;
ll n;
ll x = 8e18;

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

  cin>>n;
  for (int i=0; i<5; i++) {
	ll p; cin>>p;
    x = min(x, p);
  }
  ll batches = (n+x-1)/x;
  ll lag = batches-1;
  ll ans = lag + 5;
  out(ans);
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))


signed main(){ INIT;
    VAR(int, n);
    VEC(int, d, n);
    sort(ALL(d));
    int ans = 1;
    REP(i, n-1) ans += d[i] != d[i+1];
    OUTL(ans);
RET;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//上記が使用不可な環境において
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <iomanip>  //setprecsion
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <cmath>  //sin, cos, tan
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <complex>
#include <bitset>
#include <utility>
#include <functional>
*/
using namespace std;

typedef long long int ll;

typedef vector<ll> vll;

//出力後改行を
#define fin(ans) cout << (ans) << endl;

//配列入力
template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

void Main()
{
  ll n; cin >> n;
  vll a(n); V(a);
  map<ll, ll> game;
  for(ll i = 0;i < n;i++)
  {
    if(game.count(a[i])) game.erase(a[i]);
    else game[a[i]] = 1;
  }
  fin(game.size())
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

using namespace std;
const int MAX = (int) 1e5;
int A[MAX], B[MAX], C[MAX];
signed main(){
    int N;
    cin >> N;
    cin >> A[0] >> B[0] >> C[0];
    for(int i=1; i<N; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        A[i] = max(B[i-1]+a, C[i-1]+a);
        B[i] = max(A[i-1]+b, C[i-1]+b);
        C[i] = max(B[i-1]+c, A[i-1]+c);
    }
    int res = max(A[N-1], max(B[N-1], C[N-1]));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

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

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

	vector<int> b(102, 0);

	for (int i = 0; i < n; i++)
	{
		b[a[i]] = 1;
	}

	if (b[x] == 0)
	{
		cout << x << endl;
		return 0;
	}

	int f = x;
	int g = x;

	while (x)
	{
		f--;
		g++;

		if (b[f] == 0)
		{
			cout << f << endl;
			return 0;
		}

		if (b[g] == 0)
		{
			cout << g << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
#include <string>
#include <strstream>
string dic_to_bin(int n)
{
    string s;
    while (n)
    {
        s+=(n%2)+'0';
        n/=2;
    }
    reverse(s.begin(),s.end());
    return s;
}
int bin_to_dic(string s)
{
    int mal=1;int dec=0;
    for(int i=s.size()-1;i>=0;--i)
    {
        dec+=(s[i]-'0')*mal;
        mal*=2;
    }
    return dec;
}
int setbit1(int num,int indx)
{
    return num|1<<indx;
}
int setbit0(int num,int indx)
{
    return num&~(1<<indx);
}
int flipbit(int num,int indx)
{
    return num^(1<<indx);
}
int getbit(int num,int indx)
{
    return (num>>indx)&1;
}
int count_ones(int num)
{
    int res=0;
    while (num)
    {
        res+=num&1;
        num>>=1;
    }
    return res;
}
void printsubset(string num)
{
    for(int i=0;i<(1<<num.size());++i)
    {
        for(int j=0;j<num.size();++j)

            if((i>>j)&1)
                cout<<num[j];
            cout<<endl;

    }
}
#include <vector>
bool prime(int num)
{
    for(int i=2;i<=num/2;i++)
    {
        if(num%i==0)
            return false;
    }
    return true;

}
int main()
{
int n;
cin>>n;
int x,c=0;
for(int i=1;i<=n;++i)
{
    cin>>x;
    if(i%2!=0&&x%2!=0)
        c++;
}
cout<<c<<endl;
}

Measured memory_bytes: 3136
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int search(int x) {

	int k = 0;
	int p = 1;
	while (p * 2 <= max_n)
	{
		p *= 2;
	}
	for (int i = p; i > 0; i /= 2)
	{
		if (i + k < max_n && bit[i + k] < x) {
			x -= bit[i + k];
			k += i;
		}
	}
	return k + 1;
}
void solv() {

	int n;
	cin >> n;
	ll r[200010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> r[i];
	}

	ll res = r[1] - r[0];
	ll mi = min(r[1], r[0]);
	for (size_t i = 2; i < n; i++)
	{
		res = max(r[i] - mi,res);
		mi = min(mi, r[i]);
	}
	cout << res << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



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

using namespace std;

#define memset_clear(_) memset(_,0,sizeof(_))
#define memset_clear_tre(_) memset(_,1,sizeof(_))
#define memset_clear_reg(_) memset(_,-1,sizeof(_))
#define memset_clear_max(_) memset(_,0x3f,sizeof(_))
#define memset_clear_min(_) memset(_,0x80,sizeof(_))
#define sqr(_) ((_)*(_))

#define int long long

inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}

signed main(){
	int n=read(),m=read();
	printf("%lld\n",n-m+1);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int A1,A2,A3,sum;
    scanf("%d %d %d", &A1,&A2,&A3);
    if((A1+A2+A3)>=22) {
        printf("bust");
    }
    else {
        printf("win");
    }
    return 0;
}


Measured memory_bytes: 256
/*
 * Author : Sadi
 * Mon 06/07/2020
 * 16:30:21.13
 */
#include <iostream>
#include <cstdio>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;

    return 0;
}


Measured memory_bytes: 3560
K = int(input())
import math
import itertools

def better_gcd(a,b,c):
    tup = set((a,b,c))
    kinds = len(tup)
    if kinds == 3:
        return math.gcd(a, math.gcd(b, c)) * 6
    elif kinds == 2:
        return math.gcd(*tup) * 3
    else:
        return a

ans = 0
cands = list(itertools.combinations_with_replacement(range(1,K+1), 3))
for c in cands:
    ans += better_gcd(*c)
print(ans)

Measured memory_bytes: 105340
/*
 * 0297.cc: The Last One is the Best
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  while (n--) {
    int k, p;
    cin >> k >> p;

    int ans = k % p;
    if (ans == 0) ans = p;
    printf("%d\n", ans);
  }
  return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == max({a,b,c})) cout << "A" << endl;
  else if(b == max({a,b,c})) cout << "B" << endl;
  else if(c == max({a,b,c})) cout << "C" << endl;
}



Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAX_N 100000
const ll INF = 1LL << 60;
int N, K;
ll dp[MAX_N + 1];

int main() {
    cin >> N >> K;
    int h[N + 1];
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < MAX_N; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i + j >= N) break;
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int sum = 0, c;
	rep(i,10) {
		cin >> c;
		sum += c;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================
/*
vi g[N];
int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    int t, i, j, k, p, q, r, x, y, u, v, n, m;

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
*/
int main()
{
  int l,r,d;
  cin>>l>>r>>d;
  int count = 0;
  for(int i  =l;i<=r;i++)
  {   
       if(i%d==0)
       {
       	count++;
	   }
  	
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main(){
	string O;
	string E;
	string W;
	int Length_O;
	int Length_E;
	int position;
	int position_O = 0;
	int position_E = 0;

	cin >> O;
	cin >> E;

	Length_O = O.length();
	Length_E = E.length();

	for(int i = 0; i < Length_O + Length_E; i++){
		position = i + 1;
		if(position % 2 == 1){
			W += O.at(position_O);
			position_O++;
		}else{
			W += E.at(position_E);
			position_E++;
		}
	}

	cout << W << endl;

	return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    ll n,d;
    cin >> n >> d;

    int ans = 0;

    rep(i, n){
        ll x,y;
        cin >> x >> y;

        if(x * x + y * y <= d * d) ans++;
    }

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


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string x;
    cin >> x;
    vector<int> next,prev;
    rep(i,0,x.size()){
        next.push_back(i+1);
        prev.push_back(i-1);
    }
    //vector<bool> f(x.size(),true);
    int i=0,ans=x.size();
    while(i<x.size()-1){
        if(x[i]=='S' and x[next[i]]=='T'){
            //f[i]=f[next[i]]=false;
            ans-=2;
            int j=prev[i];
            if(j>=0){
                next[j]=next[next[i]];
                prev[next[j]]=j;
                i=j;
            }else{
                i=next[next[i]];
                if(i<x.size()) prev[i]=-1;
            }
        }else i=next[i];
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 2448