akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i, n, m) for(int i = n; i < (int)m; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
using ll = std::int_fast64_t;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 1000000007;
constexpr long double eps = 1e-15;
template<typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> p) {
    os << to_string(p.first) << " " << to_string(p.second);
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, v.size()) {
        if(i) os << " ";
        os << to_string(v[i]);
    }
    return os;
}

class union_find {
public:
    union_find(int n)
    : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }
    
    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) {
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    int size(int x) {
        return -par_[root(x)];
    }
    
private:
    std::vector<int> par_;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> c(n);
    REP(i, n) cin >> c[i];
    REP(i, n) c[i]--;
    vector<pair<ll, P>> e;
    REP(i, m) {
        int a, b, w;
        cin >> a >> b >> w;
        a--; b--;
        if(c[a] != -1) a = c[a];
        else a += k;
        if(c[b] != -1) b = c[b];
        else b += k;
        e.pb({w, {a, b}});
    }
    sort(ALL(e));
    ll ans = 0;
    int cnt = 0;
    union_find uf(n + k);
    for(auto edge: e) {
        if(cnt == k - 1) continue;
        if(!uf.same(edge.second.first, edge.second.second)) {
            uf.unite(edge.second.first, edge.second.second);
            ans += edge.first;
            cnt++;
        }
    }
    if(cnt != k - 1) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int A, B;
    cin >> A >> B;

    cout << A * B << endl;

    return 0;
}

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

int n = 0, a[100000] = { 0 };

int partition(int a[100000], int p, int r) {
	int x = a[r - 1];
	int i = p - 1;

	for (int j = p; j < r; j++) {
		if (a[j - 1] <= x) {
			i++;
			swap(a[i - 1], a[j - 1]);
		}
	}
	swap(a[i], a[r - 1]);
	return i + 1;
}

int main()
{
	cin >> n;

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

	int k = 0;

	k = partition(a, 1, n);

	for (int i = 0; i < k - 1; i++)
		cout << a[i] << " ";

	if (k < n) {
		cout << "[" << a[k - 1] << "] ";

		if (k < n - 1) {
			for (int i = k; i < n - 1; i++)
				cout << a[i] << " ";
		}

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

    return 0;
}

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

const int INF = 1 << 29;
const int LIM = 1000000;

int dp1[LIM], dp2[LIM];

int main(){
    fill(dp1, dp1 + LIM, INF);
    fill(dp2, dp2 + LIM, INF);
    dp1[0] = dp2[0] = 0;
    for(int i = 1; i * (i + 1) * (i + 2) / 6 < LIM; i++){
        int num = i * (i + 1) * (i + 2) / 6;
        for(int j = num; j < LIM; j++){
            dp1[j] = min(dp1[j], dp1[j-num] + 1);
        }
        if(num % 2 == 0) continue;
        for(int j = num; j < LIM; j++){
            dp2[j] = min(dp2[j], dp2[j-num] + 1);
        }
    }
    int N;
    while(true){
        scanf("%d", &N);
        if(N == 0) break;
        printf("%d %d\n", dp1[N], dp2[N]);
    }
    return 0;
}

Measured memory_bytes: 9000
#include <iostream>

using namespace std;


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

    float A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    double ans_inverse = 0;
    for (int i = 0; i < N; i++) {
        ans_inverse += 1 / A[i];
    }
    cout << 1 / ans_inverse << endl;

    return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = [int(w) for w in input().split()]
dx = tx-sx
dy = ty-sy
first = "U"*dy+"R"*dx+"D"*dy+"L"*dx
second = "L"+"U"*(dy+1)+"R"*(dx+1)+"D" +\
         "R"+"D"*(dy+1)+"L"*(dx+1)+"U"

print(first+second)


Measured memory_bytes: 9144
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<usize>();
    let M = read::<usize>();
    let mut ROADS = Vec::new();
    ROADS.resize(N, 0);
    for m in 0..M {
        let a = read::<usize>();
        ROADS[a-1] += 1;
        let b = read::<usize>();
        ROADS[b-1] += 1;
    }
    for n in 0..N {
        println!("{}", ROADS[n]);
    }
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
)

func main() {
	var X, N int
	fmt.Scanf("%d %d", &X, &N)

	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &p[i])
	}

	val := X
	dx := 0

	found := false
	for i := 0; i < N; i++ {
		if p[i] == val {
			found = true
			break
		}
	}
	if !found {
		fmt.Println(X)
		return
	}

	for {
		dx++
		val = X - dx
		found = false

		for i := 0; i < N; i++ {
			if p[i] == val {
				found = true
				break
			}
		}
		if !found {
			fmt.Println(val)
			return
		}

		val = X + dx
		found = false
		for i := 0; i < N; i++ {
			if p[i] == val {
				found = true
				break
			}
		}
		if !found {
			fmt.Println(val)
			return
		}
	}

}


Measured memory_bytes: 1828
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent

struct Vacation {
	int Swim, bugs, homework;
};
int n;
vector<Vacation> v;
//int mem[N][4];
int dp[N][4];
/*int solve(int idx = 0, int prev = 0)
{
	if (idx == n)
		return 0;
	int& ret = mem[idx][prev];
	if (~ret)return ret;
	ret = 0;
	if (prev != 1)
		ret = max(ret, solve(idx + 1, 1) + v[idx].Swim);
	if (prev != 2)
		ret = max(ret, solve(idx + 1, 2) + v[idx].bugs);
	if (prev != 3)
		ret = max(ret, solve(idx + 1, 3) + v[idx].homework);

	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n;
	v = vector<Vacation>(n);
	for (int i = 0; i < n; i++)
		cin >> v[i].Swim >> v[i].bugs >> v[i].homework;
	//cout << solve() << endl;

	//baseCase
	dp[n][1] = dp[n][2] = dp[n][3] = 0;


	for (int idx = n-1; idx >=0; idx--) {
		int& ret1 = dp[idx][1];
		int& ret2 = dp[idx][2];
		int& ret3 = dp[idx][3];
		ret1 = ret2 = ret2 = 0;;

		ret1 = max(ret1, dp[idx + 1][2] + v[idx].Swim);
		ret1 = max(ret1, dp[idx + 1][3] + v[idx].Swim);

		ret2 = max(ret2, dp[idx + 1][1] + v[idx].bugs);
		ret2 = max(ret2, dp[idx + 1][3] + v[idx].bugs);

		ret3 = max(ret3, dp[idx + 1][1] + v[idx].homework);
		ret3 = max(ret3, dp[idx + 1][2] + v[idx].homework);

	}

	cout << max({ dp[0][1],dp[0][2],dp[0][3] }) << endl;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  long long max, min;
  long long sum=0;
  
  for(int i = K; i < N + 2; i++){
    min = (i - 1);
    min *= i ;
    min /= 2;
    max = (2 * N - i + 1) ;
    max *= i ;
    max /= 2 ;
    //cout << max - min << endl;
    if(max-min >= 0){
      sum += (max - min);
      sum += 1;
    }
  }
  cout << sum % (1000000000 + 7) << endl;
}

Measured memory_bytes: 3636
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b && b < c) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3088
class UnionFind(object):

    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


def main():
    N, M = map(int, input().split())

    uf = UnionFind(N)
    for _ in range(M):
        a, b = map(int, input().split())
        uf.union(a-1, b-1)

    ans = max(uf.get_size(i) for i in range(N))
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20104
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String T = sc.nextLine();
    String S = sc.nextLine();
    
    int count = 0;
    int store = S.length();
    
    for(int i = 0; i<=T.length()-S.length();i++){
      count = 0;
      for(int j = 0;j<S.length();j++){
      	if(S.charAt(j)!=T.charAt(i+j)){
        	count++;
      	}
      }
      if (store>=count) store = count; 
    }
    System.out.println(store);
  }
}
      

Measured memory_bytes: 27048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);
		
		for(int i=0;i<=1000000000;i++) {
			int a=Math.abs(h-i);
			int b=Math.abs(w-i);
			
			if(a==b) {
				System.out.println(i);
				return;
			}
		}
		
		System.out.println("IMPOSSIBLE");
		
		/*int k = Integer.parseInt(str[2]);

		String matrix[][] = new String[h][w];

		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
			}
		}

		int cur = 1;
		int ans[][] = new int[h][w];

		for (int i = 0; i < h; i++) {
			boolean first = true;
			for (int j = 0; j < w; j++) {
				if (matrix[i][j].equals("#")) {
					if (first)
						first = false;
					else
						cur++;
				}
				ans[i][j] = cur;
			}
			cur++;
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(ans[i][j] + " ");
			}
			System.out.println();
		}*/
	}
}


Measured memory_bytes: 33332
h, w = map(int, input().split())
dat = []
res = []
for i in range(h):
    l = input()
    dat.append(l)
    res.append([99999] * w)
    # None: なし, 0:通路, 1:壁
if dat[0][0] == "#":
    res[0][0] = 1
else:
    res[0][0] = 0

dx = [0, -1]
dy = [-1, 0]

for hh in range(h):
    for ww in range(w):
        for dir in range(len(dx)):
            px = ww + dx[dir]
            py = hh + dy[dir]
            if px >= -1 and py >= -1:
                if dat[py][px] == dat[hh][ww]: # 地形が一緒
                    res[hh][ww] = min(res[hh][ww], res[py][px])
                elif dat[hh][ww] == ".":
                    res[hh][ww] = min(res[hh][ww], res[py][px])
                else:
                    res[hh][ww] = min(res[hh][ww], res[py][px] + 1)
print(res[h-1][w-1])
#print(res)


Measured memory_bytes: 42096
x = int(input())
y = input()
y2 = y.split(" ")
max = 0
sum = 0
for i in range(x):
    if(max < int(y2[i])):
        max = int(y2[i])
    sum += int(y2[i])

if(max < sum-max):
    print("Yes")
else:
    print("No")

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

int main() {
        int N, K;
        string S;
        cin >> N >> S >> K;

        char base = S[K-1];
        for (int i = 0; i < N; ++i) {
                if (S[i] != base) {
                        S[i] = '*';
                }
        }
        cout << S << "\n";
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,K,ans,count,cnt;
  cin >> N >> K;
  if(K%2==1){
    count=N/K;
    ans=count*count*count;
  }
  else{
    count=N/K;
    ans=count*count*count; 
    cnt=N/(K/2);
    ans+=(cnt-count)*(cnt-count)*(cnt-count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int K,T; cin >> K >> T;
    vei a(T); rep(i,T) cin >> a[i];

    int sum = acc(all(a), 0);
    sum -= maxel(a);

    if(maxel(a) - sum - 1 <= 0) cout << 0 << endl;
    else cout << maxel(a) - sum - 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
printf("0");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10?18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 4540
/*
Owner: dxxrk
Problem: Prefix and Suffix
Date: 21/11/2019
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

vector<int> prefix_function(string s){
	int n = s.size();
	vector<int> pref(n, 0);
	for(int i = 1; i < n; i++){
		int j = pref[i - 1];
		while(j > 0 && s[i] != s[j]){
			j = pref[j - 1];
		}
		if(s[i] == s[j]){
			j++;
		}
		pref[i] = j;
	}
	
	return pref;
}

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n; cin >> n;
	string s, t; cin >> s >> t;
	
	string p = t + "#" + s;
	
	vector<int> pi = prefix_function(p);
	
	int ans = 0;
	for(int i = int(t.size()) + 1; i < p.size(); i++){
		ans = max(ans, pi[i]);
	}
	
	cout << int(p.size()) - 1 - ans;
	return 0;
}


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

using namespace std;

/*****************MACRO*****/

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

/*******CONSTANT***********/
#define INF (1<<30) //infinity value
#define EPS 1e-9
#define MOD 10000007
#define SIZ 1005
#define PI (acos(-1))


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);
    int  n, k;
    cin>>n>>k;
    cout<<n-k+1<<"\n";




    return 0;
}

/**********************************************************************************







*************************************************************************************/



Measured memory_bytes: 256
n = int(input())
s = []
t = []
for i in range(n):
    xa,la = map(int,input().split())
    s.append(xa-la)
    t.append(xa+la)
#print(s)
#print(t)

itv = []
for i in range(n):
    itv.append([t[i],s[i]])
itv.sort()

#print(itv)
ass = 0
tt = -1000000000
for i in range(n):
    if tt <= itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)

Measured memory_bytes: 73688
l = [0]*3
for i in range(3):
  l[i] = list(map(int, input().split()))

for i in range(2):
  if l[0][i]-l[1][i] != l[0][i+1]-l[1][i+1]:
    print('No')
    exit()
  if l[1][i]-l[2][i] != l[1][i+1]-l[2][i+1]:
    print('No')
    exit()
else:
  print('Yes')

Measured memory_bytes: 38512
// https://atcoder.jp/contests/abc126/tasks/abc126_b

package main

import "fmt"

func main() {
	var x, y int
	fmt.Scanf("%02d%02d", &x, &y)

	var yymm, mmyy bool
	if 1 <= x && x <= 12 {
		mmyy = true
	}
	if 1 <= y && y <= 12 {
		yymm = true
	}

	if yymm && mmyy {
		fmt.Println("AMBIGUOUS")
	} else if !yymm && mmyy {
		fmt.Println("MMYY")
	} else if !mmyy && yymm {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define en <<endl
constexpr auto INF = 100000000000000;

int main()
{
	int a,b,c;
	in a >> b >> c;
	if (a + b + c > 21)
		out "bust" en;
	else
		out "win" en;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// ÉÏ ×ó ÏÂ ÓÒ
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,c,k,ans;
pair<long long,long long> t[N];
bool ok[N];
int main(){
	cin>>n>>c>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i].first;
		t[i].second=t[i].first+k;
	}
	sort(t+1,t+1+n);
	for(int i=1;i<=n;i++)
	{
		if(ok[i])
			continue;
		ans++;
		for(int j=1;j<=c;j++)
		{
			int num=i+j-1;
			if(t[num].first<=t[i].second)
				ok[num]=true;
			else
				break;
		}
	}
	cout<<ans;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;
long long board[2100][2100];
int count(int x1, int y1, int x2, int y2){
  return board[y1][x1] - board[y1][x2] - board[y2][x1] + board[y2][x2];
}
int main(){
  int N,K;
  cin >> N >> K;
  int x[N], y[N];
  rep(i,N){
    char c;
    cin >> x[i] >> y[i] >> c;
    // change B -> W
    if(c == 'W') x[i] += K;
    // copress
    x[i] = ( x[i] % (2 * K) ) + 1;
    y[i] = ( y[i] % (2 * K) ) + 1;
  }

  rep(i,N){
    board[y[i]][x[i]]++;
  }

  rep(i,2*K+1)FOR(j,1,2*K+1) {board[i][j] += board[i][j-1];}
  FOR(i,1,2*K+1)rep(j,2*K+1) {board[i][j] += board[i-1][j];}

  int tmp ,ans = 0;
  FOR(i,1,K+1){
    FOR(j,1,K+1){
    
      tmp = count(i,      j,    i+K,  j+K ) +
            count(0,      0,    i,    j   ) +
            count(i+K,    j+K,  2*K,  2*K ) +
            count(K+i,    0,    2*K,  j   ) +
            count(0,      K+j,  i,    2*K );
      //if(tmp == 3) cout << i << ' ' << j << endl;
      ans = max(ans,max(tmp,N-tmp));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 33792
// Problem : A - Rainy Season
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    string s;
    cin>>s;
    int ans;
    if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S') ans = 0;
    else{
        ans = 1;
        if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans += 2;
        else{
            if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) ans++;
        }
    } 
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, a, b; cin >> n >> a >> b;

    long long ans = (n / (a + b)) * 1ll * a;

    if(a) {
        ans += min(a, n % (a + b));
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll N, H; cin >> N >> H;
    vl a(N), b(N); REP(i, N) cin >> a[i] >> b[i];

    ll ans = 0;
    sort(ALL(a), greater<ll>());
    sort(ALL(b), greater<ll>());
    REP(i, N)
    {
        if(b[i] <= a[0]) break;
        ans++;
        H = max((ll)0, H-b[i]);
        if(H == 0) break;
    }
    cout << ans + (H+a[0]-1)/a[0] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,c;
int main(){
    cin>>n;
    for(int i=1;i<10;i++){
        for(int j=i;j<10;j++){
            if((i*j)==n){
                c++;
            }
        }
    }
    if(c==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#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>

#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()
{
    LL n, k;
    cin >> n >> k;
    VLL cnts(100000 + 1);
    int a, b;
    REP(i, 0, n)
    {
        cin >> a >> b;
        cnts[a] += b;
    }
    REP(i, 1, 100000 + 1)
    cnts[i] += cnts[i - 1];
    dump(*lower_bound(all(cnts), k));
    cout << distance(cnts.begin(), lower_bound(all(cnts), k)) << endl;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }

        int c = 0;

        for (int j = 0; j < q; j++) {
            for (int i = 0; i < n; i++) {
                if (S[i] == T[j]) {
                    c++;
                    break;
                }
            }
        }

        System.out.println(c);

        sc.close();
    }

}



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

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

  int l, r;
  l = a + b;
  r = c + d;
  
  if(l > r) {
    cout << "Left" << endl;
  } else if(l == r) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define mx 1e18
#define mod 1000000007
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll powe(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return powe(((x%mod)*(x%mod))%mod,n/2);
    else                             //n is odd
        return ((x%mod*(powe(((x%mod)*(x%mod))%mod,(n-1)/2))%mod)%mod);
}
int main()
{
    io
  
    int n;cin>>n;vector<int>a(n);vector<vector<ll>>dp(n,vector<ll>(n,1e18));
    vector<ll>prefix(n,0);cin>>prefix[0];
    for(int i=1;i<n;i++){
        ll x;cin>>x;
        prefix[i]=prefix[i-1]+x;
    }
    for(int i=0;i<n;i++)dp[i][i]=0;
    for(int i=n-1;i>=0;i--)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=i;k<j;k++)
            {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]);
            }
            dp[i][j]+=+prefix[j]-(i?prefix[i-1]:0);
        }
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 1536
N=int(input())

L=list(map(int,input().split()))
S=[0]*100010
for i in range(N):
    S[i]=L[i]

DP=[10**12]*100010

DP[0]=0
for i in range(N):
    if DP[i+1]>DP[i]+abs(S[i+1]-S[i]):
        DP[i+1]=DP[i]+abs(S[i+1]-S[i])
    if DP[i+2]>DP[i]+abs(S[i+2]-S[i]):
        DP[i+2]=DP[i]+abs(S[i+2]-S[i])


print(DP[N-1])

            

Measured memory_bytes: 13928
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int a,b;
int main(){
	scanf("%d",&a);
	rep(i,0,50000){
		if(i*108/100==a){
			printf("%d",i);
			return 0;
		}
	}
	printf(":(");
}

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

int main(){
  int N;
  cin >> N;
  std::vector<float> A(N);
  rep(i,N) cin >> A[i];
  
  
  sort(A.begin(),A.end());
  float r=0;
  for(int i=0; i<(N-1); i++){
    r = (A[0]+A[1])/2;
    A[0] = r;
    A.erase(A.begin() + 1);
    sort(A.begin(),A.end());
  }
  
  cout << A[0] << endl;

 return 0; 
}



Measured memory_bytes: 256
INF = float('inf')


def Bellmanford(node, edges, source):
    d = [INF] * node  # ある頂点までのコストを保存するリスト
    d[source] = 0

    for i in range(node):
        for start, goal, cost in edges:
            # 辺の始まりの頂点までのコストが INF でなく
            # 辺の向かう先の頂点のコストが、より軽くなる場合に、
            # リストを更新する
            if d[start] != INF and d[start] + cost < d[goal]:
                d[goal] = d[start] + cost
                if i == node-1 and goal == node-1:
                    return 'inf'
    return -d[node-1]


N, M = map(int, input().split())
abc = [map(int, input().split()) for _ in range(M)]
Edges = [None] * M

for i in range(M):
    ai, bi, ci = abc[i]
    Edges[i] = (ai-1, bi-1, -ci)


ans = Bellmanford(N, Edges, 0)
print(ans)


Measured memory_bytes: 44268
package main

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

func main() {
	var N int
	fmt.Scan(&N)
	X := make([]int, N)
	XC := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range X {
		sc.Scan()
		X[i], _ = strconv.Atoi(sc.Text())
		XC[i] = X[i]
	}
	sort.Ints(X)
	m1 := X[len(X)/2-1]
	m2 := X[len(X)/2]

	for i := 0; i < len(XC); i++ {
		if XC[i] <= m1 {
			fmt.Println(m2)
		} else {
			fmt.Println(m1)
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------
int V, E ;
vector<int> color ;
vector<int> seen ;
vector<int> dist ;
vector<vector<int> > graph ;
queue<int> que ;
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V ;
    E = V - 1 ;


    vector<int> zero(V,0) ;
    seen = zero ;
    dist = zero ;
    color = zero ;

    for(int i=0;i<V;i++){
        graph.push_back(vector<int>()) ;
    }

    vector<pair<int,int>> pai(E) ;

    for(int i=0;i<E;i++){
        int a, b ;
        cin >> a >> b ;
        graph[a-1].push_back(b-1) ;
        graph[b-1].push_back(a-1) ;
        pai[i] = MP(a-1,b-1) ;
    }

    que.push(0) ;
    seen[0] = 1 ;
    color[0] = 0 ;

    while(!que.empty()){
        int k = que.front() ;
        que.pop() ;
        int aa = 1 ;
        for(int i=0;i<graph[k].size();i++){
            if(seen[graph[k][i]]==0){
                que.push(graph[k][i]) ;
                seen[graph[k][i]] = 1 ;
                while(1){
                    if(aa!=color[k]){
                        color[graph[k][i]] = aa ;
                        aa++ ; 
                        break ;
                    }
                    aa++ ;
                }
            }
        }
    }

    vint vec = color ;
    sort(ALL(vec)) ;
    cout << vec[V-1] << endl ;
    REP(i,E){
        cout << color[pai[i].SE] <<endl ;
    }

    

    return 0;
}


Measured memory_bytes: 9584
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b-a<0&&c-b<0&&c-a<0)
    cout<<"No";
    else if(b-a<=d&&c-b<=d||c-a<=d)
    cout<<"Yes";
    else
    cout<<"No";


   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include<bits/stdc++.h>
typedef long long int ll;
const int maxn=1e6+7;
using namespace std;
//四步走，
//确定状态 1、最后一步2、化成子问题
//转移方程
//初始条件和边界情况
//计算顺序，确保要用到的都算过
int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   a=abs(a);
   ll t1=a/c;
   ll t2=a%c;
   ll flag;
   if(t1>b)flag=a-b*c;
   else{
        ll item=b-abs(t1);
        if(item%2==0){
            flag=abs(t2);
        }
        else{
            flag=abs(c-t2);
        }
   }
   printf("%lld\n",flag);
    return 0;
}

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

int main() {
  int K,N;
  cin >> K >> N;
  vector <int> A(N);
  rep(i,N){cin >> A.at(i);}
  int max_dis = 0;
  rep(i,N-1){max_dis=max(max_dis, A.at(i+1)-A.at(i));}
  max_dis = max(max_dis, K-A.at(N-1)+A.at(0));
  cout << K - max_dis << endl;
  return 0;
}

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

m = max(a) + 1
a = sorted(a)

count = [0] * m

for x in a:
    if count[x] != 0:
        count[x] = 2
        continue

    for i in range(x, m, x):
        count[i] += 1

ans = 0
for x in a:
    if count[x] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 32248
#include <iostream>
#include <string>
#include <map>
//using namespace std;
int main() {
	char b;
	std::cin >> b;
	std::map<char, char> s;
	s['A'] = 'T';
	s['C'] = 'G';
	s['G'] = 'C';
	s['T'] = 'A';

	std::cout << s[b] << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    double A,S=0;
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%lf\n", &A);
        S += (double)1/A;
    }
    printf("%lf\n",(double)1/S);
}


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

int main() {
    ll N;
    cin>>N;
    ll ans=0;
    for (ll i = 1; i <= N; i++){
        ll end=N/i;
        ans+=i*(end)*(end+1)/2;
    }
    cout<<ans<<endl;
}

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

int main()
{

    int x, y;
    cin >> x>>y;
    long long s = 0;
    if (x <= 3) {
        if (x == 1) {
            s += 300000;
        }
        else if (x == 2) {
            s += 200000;
        }
        else s += 100000;
    }
    if (y <= 3) {
        if (y == 1) {
            s += 300000;
        }
        else if (y == 2) {
            s += 200000;
        }
        else s += 100000;
    }
    if (y == 1 && x == 1) {
        s += 400000;
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    long K;
    int Q;
    cin >> N;
    cin >> K;
    cin >> Q;
    vector <int> correct(N);
    for (int i = 0; i < Q; ++i) {
        int a;
        cin >> a;
        a--;
        correct[a]++;
    }
    for (int i = 0; i < N; ++i) {
        if (Q - correct[i] >= K) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        System.out.println(s*t >= d ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 35688
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn solve(n: i32, a: i32, b: i32) -> i32 {
    (1..n + 1)
        .filter(|x| {
            let sum = x.to_string().chars().map(|c| c as i32 - 48).sum::<i32>();
            a <= sum && sum <= b
        })
        .sum::<i32>()
}

fn main() {
    input!{
        n: i32,
        a: i32,
        b: i32
    }
    println!("{}", solve(n, a, b))
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
  int n;
  int flg=1,cnt=0;
  int i,j;
  scanf("%d",&n);
  int s[n];
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  
  while(1){
    i=0;
    while(s[i]==0 && i<n){
      i++;
    }
    j=i;
    while(s[j]!=0 && j<n){
	  j++;
    }
    if(i<n){
      for(int k=i;k<=j-1;k++){
        s[k]--;
      }
      cnt++;
    }else{
      break;
    }
  }
  
  printf("%d\n",cnt);
  return(0);
}

Measured memory_bytes: 128
#include <iostream>

int prefix[300005];

int main(){
  int N;
  std::string str;
  std::cin>>N>>str;
  for(int i=0;i<N;i++){
    prefix[i+1]=prefix[i]+(str[i]=='W');
  }
  int best=1e9;
  for(int i=1;i<=N;i++){
    int left=prefix[i-1];
    int right=(N-i)-(prefix[N]-prefix[i]);
    best=std::min(best,left+right);
  }
  std::cout<<best<<std::endl;
  return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
int main()
{
	string a;
	cin>>a;
	if(a=="Sunny")
		cout<<"Cloudy";
	if(a=="Cloudy")
	cout<<"Rainy";
	if(a=="Rainy")
	{
		cout<<"Sunny";
	}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	int count=0;
	int c[1000], d[1000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < n; i++) {
		if (c[i] == d[i])
			count++;
		else count = 0;
		if (count == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#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 <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string s;
    cin >> s;

    string t = "";
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) t += 'g';
        else t += 'p';
    }

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == t[i]) continue;
        if (s[i] == 'p')ans--;
        else ans++;
    }

    cout << ans << endl;

    return 0;
}




















































































Measured memory_bytes: 640
#include<cstdio>

using namespace std;

int main(){
    long int n;
    scanf("%ld", &n);
    if (n % 2 == 1){
        puts("0");
        return 0;
    }

    long int ans = 0;
    long int r;
    long int t = 5;
    r = n / t;
    r = r / 2;
    ans += r;
    t *= 5;
    while (r != 0){
        r = n / t;
        r = r / 2;
        ans += r;
        t *= 5;
    }

    printf("%ld\n", ans);

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n;
	
		cin>>n;
		int arr[n][3];

		int dp[n][3];
		int i;
		for(i=0;i<n;i++)
			cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

		dp[0][0]=arr[0][0];
		dp[0][1]=arr[0][1];
		dp[0][2]=arr[0][2];

		for(i=1;i<n;i++)
		{
			dp[i][0]=max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
			dp[i][1]=max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
			dp[i][2]=max(dp[i-1][0]+arr[i][2],dp[i-1][1]+arr[i][2]);
		}

		cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
		return 0;
	
}

Measured memory_bytes: 5936
function dfs(G,D,u,p,x)
	D[u]=x
	for (v,c)=G[u]
		if v!=p
			dfs(G,D,v,u,x+c)
		end
	end
end
function main()
	lines=readlines()
	N=parse(Int,shift!(lines))
	G=[Pair{Int,Int}[] for _=1:N]
	for i=2:N
		a,b,c=map(x->parse(Int,x),split(shift!(lines)))
		push!(G[a],b=>c)
		push!(G[b],a=>c)
	end
	Q,K=map(x->parse(Int,x),split(shift!(lines)))
	D=[1145141919810 for _=1:N]
	dfs(G,D,K,-1,0)
	for s=lines
		x,y=map(x->parse(Int,x),split(s))
		println(D[x]+D[y])
	end
end
main()


Measured memory_bytes: 176908
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;


	for (ll i = 0; i < N; i++) {
		ll left = A + i * C - (N-1LL-i)*D;
		ll right = A + i * D - (N-1LL-i)*C;
		if (left <= B && B <= right) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string sp, t;
  cin >> sp >> t;
  string mi = "}";
  REP(i, 0, sp.length() - t.length() + 1) {
    string s(sp);
    bool ok = true;
    REP(j, i, i + t.length()) {
      if (s[j] == '?') {
	s[j] = t[j - i];
      }
      if (s[j] != t[j - i]) {
	ok = false;
	break;
      }
    }
    if (not ok) {
      continue;
    }
    REP(i, 0, s.length()) {
      if (s[i] == '?') {
	s[i] = 'a';
      }
    }
    mi = min(mi, s);
  }
  cout << (mi == "}" ? "UNRESTORABLE" : mi) << "\n";
}


Measured memory_bytes: 256