akhauriyash/Code-Regression huggingface dataset:
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 5005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");
	
	int H, W;
	scanf("%d %d", &H, &W);
	vector <string> mapp(H);
	for (int r = 0; r < H; r++) {
		char line[MAX_N];
		scanf("%s", line);
		mapp[r] = string(line);
	}
	vector <vector<int>> dpr(H, vector <int>(W));
	vector <vector<int>> dpc(H, vector <int>(W));
	for (int r = 0; r < H; r++){
		int sum = 0;
		for (int c = 0; c < W; c++) {
			if (mapp[r][c] == '#') sum = 0;
			else sum++;
			dpr[r][c] = sum;
		}
		sum = 0;
		for (int c = W - 1; c >= 0; c--) {
			if (sum == 0) sum = dpr[r][c];
			else if (dpr[r][c] == 0) sum = 0;
			else dpr[r][c] = sum;
		}
	}
	
	for (int c = 0; c < W; c++) {
		int sum = 0;
		for (int r = 0; r < H; r++) {
			if (mapp[r][c] == '#') sum = 0;
			else sum++;
			dpc[r][c] = sum;
		}
		sum = 0;
		for (int r = H - 1; r >= 0; r--) {
			if (sum == 0) sum = dpc[r][c];
			else if (dpc[r][c] == 0) sum = 0;
			else dpc[r][c] = sum;
		}
	}

	int res = 0;
	for (int r = 0; r < H; r++) for (int c = 0; c < W; c++) {
		res = max(res, dpr[r][c] + dpc[r][c] - 1);
	}
	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 35712
#include <stdio.h>
int main(void)
{
	int x, y;
	int tmp1, tmp2;
	
	scanf("%d %d", &x, &y);

	if (y > x){
		tmp1 = y;
		y = x;
		x = tmp1;
	}

	while(1) {
		tmp2 = x % y;
		x = y;
		y = tmp2;
		if (tmp2 == 0) {
			break;
		}
	}

	printf("%d\n", x);

	return 0;
}


Measured memory_bytes: 2124
from sys import stdin


def main():
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    x = [int(x) for x in stdin.readline().rstrip().split()]
    x1 = [-i for i in x if i < 0][::-1]
    x2 = [i for i in x if i >= 0]
    x1 = [0] + x1
    x2 = [0] + x2
    result = 10000000000
    for l in range(min(K + 1, len(x1))):
        r = K - l
        if len(x2) <= r:
            continue
        tmp = x1[l] * 2 + x2[r]
        result = min(result, tmp)
    for r in range(min(K + 1, len(x2))):
        l = K - r
        if len(x1) <= l:
            continue
        tmp = x1[l] + x2[r] * 2
        result = min(result, tmp)
    print(result)


if __name__ == '__main__':
    main()


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


def simu(pro, q):
    end_time = 0

    while bool(pro):
        if pro[1] > q:
            end_time += q
            pro.append(pro[0])
            pro.append(pro[1] - q)
            pro.pop(0)
            pro.pop(0)

        elif pro[1] <= q:
            end_time += pro[1]
            print('{0} {1}'.format(pro[0], end_time))
            pro.pop(0)
            pro.pop(0)


n, q = list(map(int, input().split()))

pro = []
for i in range(n):
    name, time = list(input().split())
    pro.append(name)
    pro.append(int(time))

simu(pro, q)



Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n ;cin >> n;
    map<string,ll> mp;
    rep(i,n){
        string s; cin >> s;
        mp[s]++;
    }
    cout << "AC" << ' ' << 'x' << ' ' << mp["AC"] << endl;
    cout << "WA" << ' ' << 'x' << ' ' << mp["WA"] << endl;
    cout << "TLE" << ' ' << 'x' << ' ' << mp["TLE"] << endl;
    cout << "RE" << ' ' << 'x' << ' ' << mp["RE"] << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
multiset<int> ms;
bool del(int x){
    //printf("remove %d ",x);
    auto it = ms.find(x);
    if (it == ms.end()) return false;
    else ms.erase(it);
    return true;
}
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    int k = 0;
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        ms.insert(a[i]);
        k = max(k,a[i]);
    }
    int half = (k+1)/2;
    for (int i = half; i <= k; i++){
        if (i == half && (k & 1) == 0){
            if (!del(i)){
                printf("Impossible");
                return 0;
            }
        }
        else{
            if (!del(i)){
                printf("Impossible");
                return 0;
            }
            if (!del(i)){
                printf("Impossible");
                return 0;
            }
        }
    }
    for (auto x : ms){
        if (x < half+1){
            printf("Impossible");
            return 0;
        }
    }
    printf("Possible");

}


Measured memory_bytes: 256
// Problem : C - Peaks
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n,m;
		cin>>n>>m;
		int arr[n+1];
		for(int i=1;i<=n;++i)
		cin>>arr[i];
		map<int,vector<int>>mp;
		for(int i=0;i<m;++i)
		{
			int l,r;
			cin>>l>>r;
			mp[l].pb(r);
			mp[r].pb(l);
		}
		int ans = 0;
		for(int i=1;i<=n;++i)
		{
			int xxx = mp[i].size();
			if(!xxx)
			{
				ans++;
				continue;
			}
			int ct = 0;
			for(auto x:mp[i])
			{
				if(arr[i]>arr[x])
				ct++;
			}
			if(ct==xxx)
			ans++;
		}
		cout<<ans;  	
    }
    return 0;
}



Measured memory_bytes: 15728
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var K = int.Parse(ReadLine());

        var ans = 0;

        for (int i = 1; i <= K; i++)
        {
            for (int j = 1; j <= K; j++)
            {
                for (int k = 1; k <= K; k++)
                {
                    ans += GCD(GCD(i, j), k);
                }
            }
        }

        WriteLine(ans);
    }

    static int GCD(int m, int n)
    {
        if (m < n)
            (m, n) = (n, m);

        while(n != 0)
        {
            var _n = n;
            n = m % n;
            m = _n;
        }

        return m;
    }
}


Measured memory_bytes: 27368
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);

    int k = 2;
    while (k*(k-1)/2 < n) {
        k++;
    }

    if (n != k*(k-1)/2) {
        writeln("No");
        return;
    }

    writeln("Yes");
    writeln(k);

    auto ans = new int[][](k, 0);

    int num = 1;

    foreach (i ; 0 .. k) {
        foreach (j ; i+1 .. k) {
            ans[i] ~= num;
            ans[j] ~= num;
            num++;
        }
    }

    foreach (ansi ; ans) {
        writefln("%d %(%s %)", k - 1, ansi);
    }
}




































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 2940
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int A,B,C;
	cin>>A>>B>>C;
	int a=max({A,B,C});
	int b=min({A,B,C});
	int c=A+B+C-a-b;
	if(a==b+c){
		ce("Yes")
	}else{
		ce("No")
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    bool flagone = true,flagtwo=false;
    long long int counterone=0,countertwo =0;
    for(int i=0; i<s.size(); ++i){
        if(s[i]=='1' and flagone==false){
            counterone++;
        }
        if(s[i]=='0' and flagone == true){
            counterone++;
        }
        if(s[i]=='0' and flagtwo== true){
            countertwo++;
        }
        else if(s[i]=='1' and flagtwo == false){
            countertwo++;
        }
        flagone = !flagone;
        flagtwo = !flagtwo;
    }
    printf("%d\n",min(counterone,countertwo));
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;


struct Node {
    vector<int>connected;
    bool visited;
    int sign;
    Node() {
        visited = false;
    }
};

vector<Node>rooms;
queue<int>br_f;
int room_count = 0;

void Br() {
    vector<int>coonect;
    int room_now = br_f.front();
    coonect = rooms[room_now].connected;
    for (int i = 0; i < coonect.size(); i++) {
        if (!rooms[coonect[i]].visited) {
            br_f.push(coonect[i]);
            rooms[coonect[i]].visited = true;
            rooms[coonect[i]].sign = br_f.front();
        }
    }
    br_f.pop();
    room_count++;
}

int main()
{

    int room_num, pass_num;
    cin >> room_num >> pass_num;
    rooms.resize(room_num + 1);
    for (int i = 0; i < pass_num; i++) {
        int a, b;
        cin >> a >> b;
        rooms[a].connected.push_back(b);
        rooms[b].connected.push_back(a);
    }
    br_f.push(1);
    rooms[1].visited = true;
    while (!br_f.empty()) {
        Br();
    }
    if (room_count < room_num) {
        cout << "No";
    }
    else {
        cout << "Yes" << endl;
        for (int i = 2; i < rooms.size(); i++) {
            cout << rooms[i].sign << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 10412
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int x[N], y[N];
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> x[i] >> y[i];
	long double ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i; j <= n; j++){
			int dis = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
			ans = ans + 1.0*sqrt(dis)*2.0/n;
		}
	}	
	cout << setprecision(10) << fixed << ans;
	return 0;
}

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


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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

long long mod_power(long long a, long long p, long long M = 1000000007) {
    long long ans = 1;
    while (p > 0) {
        if (p & 1LL) {
            ans = (ans * (a % M)) % M;
            p--;
        }
        p /= 2;
        a = ((a % M) * (a % M)) % M;
    }
    return ans;
}

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

    int n, k;
    cin >> n >> k;
    ll a = n - k + 1, b = 1;
    cout << a * b << endl;
    for (int i = 2; i <= k; i++) {
        if (n - k < i - 1) {
            cout << 0 << endl;
            continue;
        }
        a = (a * (n - k + 1 - i + 1)) % MOD;
        a = (a * (mod_power(i, MOD - 2))) % MOD;
        b = (b * (k - 1 - i + 2)) % MOD;
        b = (b * (mod_power(i - 1, MOD - 2))) % MOD;
        cout << (a * b) % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# 2019-11-10 20:23:41(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    info = [[int(x) for x in sys.stdin.readline().split()] for _ in range(n)]
    
    # 基準を決める
    for i in range(n):
        if info[i][2] >= 1:
            x0, y0, h0 = info[i][0], info[i][1], info[i][2]
            break
    # else: すべてのhは h = 0

    for x in range(101):
        for y in range(101):
            H = h0 + abs(x - x0) + abs(y - y0)
            for i in range(n):   # 中心(x, y, H)が条件を満たしているか確認する
                h = max(H - abs(x - info[i][0]) - abs(y - info[i][1]), 0)
                if h != info[i][2]: #　本当に中心なら同じ値になるはず
                    break     # そうでないならこれは正しくない
            else:  # 全ての座標に対して条件を満たしていたなら
                res = [x, y, H]
                break # 中心は一意に決まるので見つかったらそれ以上調べる必要ない
    
    for i in range(3):
        res[i] = str(res[i])
    
    print(' '.join(res))
            

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n: usize = read();
    let mut x_vec: Vec<i32> = read_vec();
    x_vec.sort();
    let min = x_vec[0];
    let max = x_vec[n - 1];
    let mut min_cost = std::u32::MAX;
    for p in min..max + 1 {
        let mut cost = 0;
        for x in x_vec.clone() {
            cost += (x - p) * (x - p);
        }
        min_cost = std::cmp::min(min_cost, cost as u32);
    }
    println!("{}", min_cost);
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
//#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;

int main(){
    long long N,K;
    cin>>N>>K;
    long long A[N],sum=0;
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    sort(A,A+N);
    long long mi=1,ma=A[N-1];
    while(mi<ma){
        long long mid=(mi+ma)/2;
        long long t=0;
        bool flag=true;
        rep(i,N){
            t+=(A[i]-1)/mid;
            if (t>K){
                flag=false;
                break;
            }
        }
        if (flag){
            ma=mid;
        }
        else{
            mi=mid+1;
        }        
        if (mi+1==ma) break;
    }
    bool flag=true;
    long long t=0;
    rep(i,N){
        t+=(A[i]-1)/mi;
        if (t>K){
            flag=false;
            break;
        }
    }
    if (flag) cout<<mi<<endl;
    else cout<<ma<<endl;
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	string s;
	cin>>s;

	stack<int> st;

	REP(i,0,s.size()){
		if(s.at(i)=='0')st.push(0);
		else if(s.at(i)=='1')st.push(1);
		else{
			if(st.size()!=0)st.pop();
		}
	}

	string ans;
	while(st.size()){
		ans.push_back((char(st.top()+'0')));
		st.pop();
	}

	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n <= 999) {
        cout << "ABC";
    } else {
        cout << "ABD";
        n -= 999;
    }
    cout << endl;
    return 0;
    if (n < 10) {
        cout << "00" << n;
    } else if (n < 100) {
        cout << "0" << n;
    } else {
        cout << n;
    }
    cout << endl;
}


Measured memory_bytes: 3628
//
// Created by Hideaki Imamura on 2019-07-04.
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int ind(char c) {
    return int(c) - 97;
}

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

    int a[26], b[26];
    memset(a, -1, sizeof(a));
    memset(b, -1, sizeof(b));

    for (int i = 0; i < s.length(); ++i) {
        if (a[ind(s[i])] >= 0) {
            if (a[ind(s[i])] != t[i]) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            a[ind(s[i])] = t[i];
        }
        if (b[ind(t[i])] >= 0) {
            if (b[ind(t[i])] != s[i]) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            b[ind(t[i])] = s[i];
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int N;
string S;

int C[1200];

int check(int k) {

	int a[4];

	a[0] = k / 100;
	a[1] = (k / 10) % 10;
	a[2] = k % 10;

	//for (int q = 0; q <= 2; q++) { cout << a[q] << endl; }

	int q = 0;
	for (int i = 0; i <= N - 1; i++) {
		//cout << S[i]-'0' << "  " << a[q] << " " << (S[i]==a[q]) << endl;
		if ((S[i] -'0')== a[q]) { q++;    if (q >= 3) { return 1; } }
	}

	return 0;
}

int main(void) {

	cin >> N >> S;

	
	
	for (int k = 0; k <= 999; k++) {
		
		if (check(k) == 1) { C[k] = 1; }
	}

	int ans = 0;

	for (int k = 0; k <= 999; k++) {
		if (C[k] == 1) { ans++; }
	}

	cout << ans << endl;


	return 0;
}

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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    int N, K;
    cin >> N >> K;
    int *P = new int[N]();
    Fr(i, 0, N) cin >> P[i];
    ll sum = K;
    Fr(i, 0, K) sum += P[i];
    ll mx = sum;
    Fr(i, K, N) {
        sum += P[i]-P[i-K];
        mx = max(mx, sum);
    }
    printf("%.7lf\n", mx/double(2));

}


Measured memory_bytes: 1024
A = [ord(a)-97 for a in input()]
N = len(A)
X = [0] * 26
Y = [0] * (N + 2)
NE = [0] * N
R = [N] * 26
s = 0
t = 1
for i in range(N)[::-1]:
    a = A[i]
    if X[a] == 0:
        X[a] = 1
        s += 1
        if s == 26:
            s = 0
            X = [0] * 26
            t += 1
    Y[i] = t
    NE[i] = R[a]
    R[a] = i

ANS = []
ii = 0
for i, a in enumerate(A):
    if i == ii:
        for j in range(26):
            if Y[R[j]+1] < Y[i]:
                ANS.append(j)
                ii = R[j]+1
                break
    R[a] = NE[i]

print("".join([chr(a+97) for a in ANS]))

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

using namespace std;

int pre[100100];

int main()
{
    int n,q;  cin >> n >> q;
    string s; cin >> s;
    for(int i = 0;i<s.size() - 1;i++){
        if(s[i] == 'A' && s[i + 1] == 'C')  pre[i + 1]++;
    }
    for(int i = 1;i<s.size();i++)  pre[i]+=pre[i - 1];
    while(q--){
        int l,r;  cin >> l >> r;
        cout << pre[r - 1] - (l >= 1 ? pre[l - 1] : 0) << '\n';
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
//for (int i = 0; i < N; i++){}

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

    vector<int> v;
    int larg = min(A,B);
    for (int i = 1; i <= larg; i++){
        if(A%i==0 && B%i==0){
            v.push_back(i);
        }
    }
    sort(v.begin(), v.end(), greater<int>());
    cout << v[K-1] << endl;
}

Measured memory_bytes: 256
N=2*10**5+3
mod=10**9+7
fac=[1]*(N+1)
for i in range(1,N+1):
    fac[i]=fac[i-1]*i%mod
inv_fac=[1]*(N+1)
inv_fac[N]=pow(fac[N],mod-2,mod)
for i in range(N-1,0,-1):
    inv_fac[i]=inv_fac[i+1]*(i+1)%mod
def nCr(n,r):
    if n<0 or r<0 or r>n:
        return 0
    return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod
h,w,a,b=map(int,input().split())
ans=nCr(h+w-2,h-1)
for i in range(b):
    ans=(ans-nCr(h-a+i-1,i)*nCr(a+w-i-2,a-1))%mod
print(ans)

Measured memory_bytes: 18804
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
      	if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
        
    }
}



Measured memory_bytes: 23636
K = int(input())
A = list(map(int, input().split()))
mi = 2
ma = 2
for i in range(K-1, -1, -1):
    a = A[i]
    if ma < a:
        print(-1)
        exit()
    mi = ((mi-1)//a+1)*a
    ma = ma//a*a+a-1
    if mi > ma:
        print(-1)
        exit()
print(mi, ma)


Measured memory_bytes: 14252
#include<queue>
#include<cassert>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int X, Y, Z;
struct Data {
    LL x, y, z;
    bool operator<(const Data &t) const {
	return y - x < t.y - t.x;
    }
} D[100011];

struct CmpZX {
    bool operator()(const Data &a, const Data &b) const {
	return a.z - a.x < b.z - b.x;
    }
};
struct CmpZY {
    bool operator()(const Data &a, const Data &b) const {
	return a.z - a.y < b.z - b.y;
    }
};

int N;

LL Xg[100011];
LL Yg[100011];

void MAIN() {
    scanf("%d%d%d", &X, &Y, &Z);
    N = X+Y+Z;
    REP (i, N) {
	int x, y, z;
	scanf("%d%d%d", &x, &y, &z);
	D[i].x = x;
	D[i].y = y;
	D[i].z = z;
    }
    sort(D, D+N);

    {
	LL sum = 0;
	priority_queue<Data, vector<Data>, CmpZX> Q;
	REP (i, X) {
	    Q.push(D[i]);
	    sum += D[i].x;
	}
	Xg[0] = sum;
	for (int i=X, k=0; i<N-Y; i++, k++) {
	    LL tmp1 = D[i].z;
	    LL tmp2 = D[i].x - Q.top().x + Q.top().z;
	    if (tmp1 >= tmp2) {
		Xg[k+1] = Xg[k] + tmp1;
	    } else {
		Xg[k+1] = Xg[k] + tmp2;
		Q.pop();
		Q.push(D[i]);
	    }
	}
    }
    {
	LL sum = 0;
	priority_queue<Data, vector<Data>, CmpZY> Q;
	for (int i=N-Y; i<N; i++) {
	    Q.push(D[i]);
	    sum += D[i].y;
	}
	Yg[0] = sum;
	for (int i=N-Y-1, k=0; i>=X; i--, k++) {
	    LL tmp1 = D[i].z;
	    LL tmp2 = D[i].y - Q.top().y + Q.top().z;
	    if (tmp1 >= tmp2) {
		Yg[k+1] = Yg[k] + tmp1;
	    } else {
		Yg[k+1] = Yg[k] + tmp2;
		Q.pop();
		Q.push(D[i]);
	    }
	}
    }

    LL ans = 0;
    REP (i, Z+1) {
	amax(ans, Xg[i] + Yg[Z-i]);
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 7256
#include <bits/stdc++.h>
using namespace std;
int n;
int cnt[3] = {};

int sim(int zero,int one,int two,int sum){
  int res = 0;
  while(1){
    if(zero && sum%3) res++,zero--;
    else if(two && (sum+2)%3) res++,sum=(sum+2)%3,two--;
    else if(one && (sum+1)%3) res++,sum=(sum+1)%3,one--;
    else if(zero || one || two) return res+1;
    else return res;
  }
}

int sim2(int zero,int one,int two,int sum){
  int res = 0;
  while(1){
    if(zero && sum%3) res++,zero--;
    else if(one && (sum+1)%3) res++,sum=(sum+1)%3,one--;
    else if(two && (sum+2)%3) res++,sum=(sum+2)%3,two--;
    else if(zero || one || two) return res+1;
    else return res;
  }
}

int calc(){
  return max(sim(cnt[0],cnt[1],cnt[2],0),
	     sim2(cnt[0],cnt[1],cnt[2],0));
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    cnt[a%3]++;
  }
  cout<<calc()<<endl;
  return 0;
}

Measured memory_bytes: 3096
n,m = map(int,input().split())
c = [0]*n
for i in range(m):
    a,b = map(lambda x: int(x)-1,input().split())
    c[a]+=1
    c[b]+=1
ans = 'YES'
for i in c:
    if i%2==1:
        ans = 'NO'
print(ans)

Measured memory_bytes: 75392
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> a(n+1, 0);
    for(int i=1; i<=w/2; ++i)
        ++ a[i+1];
    for(int i=w/2+1; i<w; ++i){
        for(int j=3*i; j<=n; j+=i){
            ++ a[j-w+1];
            -- a[j-i+1];
        }
    }

    int ret = w;
    for(int i=1; i<=n-w+1; ++i){
        ret += a[i];
        cout << ret;
        if(i < n-w+1)
            cout << ' ';
        else
            cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1532
import sys
sys.setrecursionlimit(10 ** 7)

def main():
    N = int(input())
    V = [set() for _ in range(N)]
    E = {}
    for j in range(N - 1):
        a, b = [int(i) - 1 for i in input().split()]
        V[a].add(j)
        V[b].add(j)
        E[(a, j)] = b
        E[(b, j)] = a
    C = [0] * (N - 1)
    clrs = max(len(i) for i in V)
    def color(n, p):
        for e in V[n]:
            if C[e] != 0:
                continue
            c = p + 1
            if c > clrs:
                c = 1
            C[e] = c
            color(E[(n, e)], c)
            p = c
    color(0, 0)
    print(clrs)
    for i in C:
        print(i)

main()


Measured memory_bytes: 131608
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int dp[10010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> v(N), w(N), m(N); rep(i, 0, N) { cin >> v[i] >> w[i] >> m[i]; }
	memset(dp, 0, sizeof(dp));
	rep(i, 0, N) {
		int m_ = m[i];
		for (int a = 1; m_ > 0; m_ -= a, a <<= 1) {
			int a_ = min(a, m_);
			rrep(j, 0, W + 1) {
				if (j + w[i] * a_ > W)continue;
				chmax(dp[j + w[i] * a_], dp[j] + v[i] * a_);
			}
		}
	}
	cout << dp[W] << endl;
	return 0;
}

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

int main(){
  int debt = 100000, n;
  cin >> n;
  while(n--){
  	debt = debt * 105 / 100;
  	if(debt % 1000 > 0){
  		debt /= 1000;
  		debt++;
  		debt *= 1000;
  	}
  }
  cout << debt << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int l = max(a, b);
    int s = min(a, b);
    int ans = 0;
    for (int i = 0; i < l; i++)ans += s*pow(10, i);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define Rep(i,a,b) for(int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    ll x=0;char f=0;char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);pc('\n');}
IL void wri(ll x){write(x),pc(' ');}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define y1 ____y1
#define hash __hash
#define union _union
#define ramdom ((double)rand() / RAND_MAX)
#define x first
#define y second
const int maxn = 5e5+233;
struct Edge{
	int to,nxt;
	Edge(){}
	Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn*2];
int first[maxn],nume;
void Addedge(int a,int b){
	edge[nume] = Edge(b,first[a]);
	first[a] = nume++;
}
int mxdep[maxn],wson[maxn],sz[maxn];
int dfn[maxn],dfx[maxn],n,k;
int dp_array[maxn];
int *f[maxn];
void init(int u,int fa){
	mxdep[u] = 0;wson[u] = 0;sz[u] = 1;
	for(int e=first[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v == fa) continue;
		init(v,u);
		mxdep[u] = max(mxdep[u],mxdep[v] + 1);
		sz[u] += sz[v];
		if(!wson[u] || mxdep[v] > mxdep[wson[u]])
			wson[u] = v;
	}
}
void pre(int u,int fa){
	dfx[dfn[u] = ++*dfn] = u;
	f[u] = dp_array + dfn[u];
	if(wson[u]) pre(wson[u],u);
	for(int e=first[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v==fa || v==wson[u]) continue;
		pre(v,u);
	}
}
int g[maxn],h[maxn],ans;
void dfs(int u,int fa){
	if(wson[u]) dfs(wson[u],u);
	f[u][0] = wson[u] ? sz[wson[u]] : 0;
//	printf("#8999 %d %d\n",u,mxdep[u]);
	int m = min(k,mxdep[u]);
//	Rep(i,0,m) wri(f[u][i]);puts("");
	for(int e=first[u];~e;e=edge[e].nxt){
		int v = edge[e].to;
		if(v==wson[u] || v==fa) continue;
		dfs(v,u);
		int len = min(k,mxdep[v] + 1);
		g[0] = sz[v];Rep(i,1,len) g[i] = f[v][i-1];
		Rep(i,0,len) h[i] = f[u][i];
//		puts("~~"); 
//		wri(g[0]),writeln(h[0]);

//		Rep(i,0,len) wri(g[i]);puts("");
//		Rep(i,0,len) wri(h[i]);puts("");
//		puts("~~~~~~~~~~~~");

		Rep(i,0,len) f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);
		Rep(i,len+1,min(m,k-len-1)) f[u][i] += g[len];
		Rep(i,max(len+1,k-len),min(m,k)) f[u][i] += g[k-i];
		Rep(i,1,len) f[u][i] = min(f[u][i],f[u][i-1]);
		Rep(i,max(len+1,k-len),min(m,k)) f[u][i] = min(f[u][i],f[u][i-1]);
	}
	ans = min(ans,n - sz[u] + f[u][min(k,m)]);
	//从root往上搞一格
}
int main(){
	mem(first,-1);nume = 0;
	n = read();k = read();ans = n;
	rep(i,1,n) {
		int x = read(),y = read();
		Addedge(x,y);
		Addedge(y,x);
	} init(1,0);
	*dfn = 0;
	pre(1,0);
	dfs(1,0);
	writeln(ans);
	return 0;
}


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

int main(){
  int N;cin>>N;
  double X[N],Y[N];
  rep(i,N) cin>>X[i]>>Y[i];
  rep(i,N){
    vector<double> angle;
    rep(j,N) if(j!=i){
      angle.push_back(atan2(X[j]-X[i],Y[j]-Y[i]));
    }
    sort(angle.begin(),angle.end());
    angle.push_back(angle[0]+2*M_PI);
    double res=0;
    rep(j,N-1){
      if(angle[j+1]-angle[j]>M_PI) res=angle[j+1]-angle[j]-M_PI;
    }
    cout<<setprecision(15);
    cout<<res/(2*M_PI)<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
s = input().split(" ")
k = int(s[0])
n = int(s[1])

d = input().split(" ")
dist = []

for i in d:
    dist.append(int(i))

res = dist[n-1] - dist[0]

for i in range(1, n):
    diff = dist[i] - dist[i-1]
    aux = k - diff
    if aux < res:
        res = aux

print(str(res))


Measured memory_bytes: 26444
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/05/02.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC165
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const int MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  int N, K;
  
  cin >> N >> K;
  
  vector<int> A(N,0);

  REP(i,K){
    int d;
    cin >> d;
    REP(j,d){
      int a;
      cin >> a;
      a--;
      A[a]=1;
    }
  }
  
  int ans=0;
  REP(i,N){
    if(A[i]==0){
      ans++;
    }
  }
  cout << ans << endl;
  return;
}



#define TESTCASES 1

int main() {


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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}




Measured memory_bytes: 3652
x = int(input())
if 400 <= x < 600:
    re = 8
elif 600 <= x < 800:
    re = 7
elif 800 <= x < 1000:
    re = 6
elif 1000 <= x < 1200:
    re = 5
elif 1200 <= x < 1400:
    re = 4
elif 1400 <= x < 1600:
    re = 3
elif 1600 <= x < 1800:
    re = 2
elif 1800 <= x < 2000:
    re = 1
print(re)


Measured memory_bytes: 9176
N = int(input())
D = list(map(int,input().split()))
output = 1
cnt = [0]*N
flag = 0

if D[0]!=0:
    flag = 1

for i in range(1,N):
    cnt[D[i]-1]+=1
    if D[i]==0:
        flag = 1

if flag != 1:
    for i in range(1,len(cnt)):
        # if cnt[i]==0:
        #     continue
        for j in range(cnt[i]):
            output *= cnt[i-1]
            output = output%998244353

if flag == 1:
    output = 0
print(output)

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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	ll n;
	cin >> n;
	ll ans = 0, hoge = 1;
	while (n != 0) {
		ans += hoge;
		hoge *= 2;
		n /= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int Q;
	cin >> Q;
	int c[Q],a[Q],n[Q];
	for(int i=0;i<Q;i++){
		int cun=0;
		cin >> c[i] >> a[i] >> n[i];
		while(true){
			bool flg=0;
			if(c[i] >0 && a[i] >0 && n[i] > 0){
				c[i]--;a[i]--;n[i]--;
				cun++;
				flg =1;
			}
			else if(c[i] > 1 && a[i] > 0 && flg==0){
				c[i] -=2; a[i]--;
				cun++;
				flg=1;
			}
			
			else if(c[i]>2 && flg==0){
				c[i] -=3;
				cun++;
				flg=1;
			}
			if(flg==0)
				break;
		}
		cout << cun << endl;
	}
	return 0;
} 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    pair<int, int> s;
    [&] {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (a[i][j] == 'S') {
                    s = {i, j};
                    return;
                }
            }
        }
    }();
    const int dx[4] = {-1, 1, 0, 0};
    const int dy[4] = {0, 0, -1, 1};
    auto inside     = [&](int y, int x) { return 0 <= y && y < h && 0 <= x && x < w; };
    queue<pair<int, int>> q, emp;
    q.push(s);
    vector<vector<lint>> dist(h, vector<lint>(w, inf));
    dist[s.first][s.second]    = 0;
    bool ok                    = false;
    vector<pair<int, int>> fst = {s};
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        if (dist[p.first][p.second] == k)
            continue;
        for (int i = 0; i < 4; ++i) {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if (a[ny][nx] != '#' && (ny == 0 || ny == h - 1 || nx == 0 || nx == w)) {
                ok = true;
                swap(q, emp); // break
            } else if (inside(ny, nx) && a[ny][nx] != '#') {
                if (dist[ny][nx] != inf)
                    continue;
                dist[ny][nx] = 1 + dist[p.first][p.second];
                q.push({ny, nx});
                fst.push_back({ny, nx});
            }
        }
    }
    if (ok) {
        cout << 1 << "\n";
        return 0;
    } else {
        int ret = 1 << 30;
        for (auto &p : fst) {
            chmin(ret, p.first);
            chmin(ret, p.second);
            chmin(ret, h - p.first - 1);
            chmin(ret, w - p.second - 1);
        }
        cout << (ret + k - 1) / k + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 15604
import sys
input = sys.stdin.readline# 最小公倍数
 
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)    
a, b, c, d = map(int, input().split())
e = lcm(c, d)
count_c = b // c - (a - 1) // c
count_d = b // d - (a - 1) // d
count_e = b // e - (a - 1) // e
print(b - a + 1 - (count_c + count_d - count_e))

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count = 0;
  for(int i = 0; i < n-2; i++){
    char a,b,c;
    a = s.at(i);
    b = s.at(i+1);
    c = s.at(i+2);
    if(a=='A'&&b=='B'&&c=='C'){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    int i, l, r, d, count = 0;
    
    scanf("%d %d %d",&l,&r,&d);

    for(i=l;i<=r;i++){
        if(i%d==0){
            count++;
        }
    }

    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int l;
  cin>>l;
  int c[1000];
  int x;
  for(int i=0;i<l;i++){
    cin>>x;
    if(i==0){
      if(x<0){
	cout<<1<<endl;
	return 0;
      }
      c[0]=x;
    }else{
      if(x<0){
	int ans;
	int k;
	for(k=i-1;k>=0;k--){
	  if(c[k]!=0)
	    ans=k;
	  if(c[k]!=0)
	    break;
	}
	if(-x==c[k]){
	  c[i]=0;
	  c[k]=0;
	}else if(x*(-1)!=c[k]){
	  cout<<i+1<<endl;
	  return 0;
	}
      }else{
	for(int j=0;j<i;j++){
	  if(c[j]==x){
	    cout<<i+1<<endl;
	    return 0;
	  }
	}
	c[i]=x;
      } 
    }
  }
  cout<<"OK"<<endl;
  return 0;
  
}






Measured memory_bytes: 3092
import java.util.*;

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

        int N = sc.nextInt();
        int x = sc.nextInt();

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

        long ret = 0;

        for (int i = 1; i < N; i++) {
            long sum = a[i] + a[i-1];

            if (sum <= x) continue;

            long pickNum = Math.min(a[i], sum - x);
            long prevPickNum = Math.max((sum - pickNum) - x, 0);

            ret += pickNum + prevPickNum;

            a[i] -= pickNum;
            a[i-1] -= prevPickNum;
        }

        System.out.println(ret);
    }
}

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)

const ll mod = 1e9+7;

void add(ll &a, ll b) {
	if (b>=mod) b-=mod;
	a += b; if (a >= mod) a-=mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n,m; cin>>m>>n;
	ll dp[n+1][m+1][2];
	f(i,0,n+1) f(j,0,m+1) f(k,0,2)
		dp[i][j][k] = 0;
	f(j,0,m+1) dp[0][j][!j]=1;
	f(i,0,n) f(j,0,m+1) f(k,0,2) if (dp[i][j][k]) {
		if (j) add(dp[i+1][j-1][k|(j==1)],dp[i][j][k]);	
		if (j) add(dp[i+1][j][k|(j==1)],dp[i][j][k]);
		if (j<m) add(dp[i+1][j][k],dp[i][j][k]);
		if (j<m) add(dp[i+1][j+1][k],dp[i][j][k]);
	}
	ll ans = 0;
	f(j,0,m+1) add(ans,dp[n][j][1]);
	cout << ans << endl;
	
	

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 140928
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  	int k;
   	cin >> k;
  	cout << (k / 2) * (k - k/2)  	;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n, a[100], tmp, c=0;

void print(){
    for(int i=0 ; i<n ; i++)
        if(i==n-1)    printf("%d\n", a[i]);
        else            printf("%d ", a[i]);
}

int count(){
    for(int i=0 ; i<n ; i++){
        for(int j=n-1 ; j>i ; j--){
            if(a[j]<a[j-1]){
                tmp = a[j], a[j] = a[j-1], 
                a[j-1] = tmp, c++;
            }
        }
    }
    return c;
}

int main(void){
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++)
        scanf("%d",&a[i]);
    c=count();    
    print();
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 2100
using System;
using System.Collections.Generic;

class A{
	public static void Main(){


		string[] input = Console.ReadLine ().Split (' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		int c = int.Parse(input[2]);

		List<int> l = new List<int> ();
		l.Add (a);
		l.Add (b);
		l.Add (c);
		l.Sort ();

		Console.WriteLine ("{0} {1} {2}", l [0], l [1], l [2]);


	}
}

Measured memory_bytes: 9336
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
bool used[200000];
int perm[200000];
int main() {
	int N, x;
	cin >> N >> x;
	if (x == 1 || x == 2 * N - 1) {
		cout << "No" << endl;
		return 0;
	}
	else if (N == 2) {
		cout << "Yes" << endl;
		cout << 1 << endl;
		cout << 2 << endl;
		cout << 3 << endl;
		return 0;
	}
	else if (x == 2) {
		used[1] = used[2] = used[3] = used[4] = 1;
		perm[N-2] = 3;
		perm[N-1] = 2;
		perm[N] = 1;
		perm[N+1] = 4;
	}
	else {
		used[x - 2] = used[x - 1] = used[x] = used[x + 1] = 1;
		perm[N-2] = x - 1;
		perm[N-1] = x;
		perm[N] = x + 1;
		perm[N + 1] = x - 2;
	}
	int k = 1;
	rep(i, 2*N-1) {
		if (perm[i]) continue;
		while (used[k]) k++;
		perm[i] = k;
		used[k] = 1;
	}
	cout << "Yes" << endl;
	rep(i, 2*N-1) {
		cout << perm[i] << endl;
	}
}

Measured memory_bytes: 2432
from collections import deque
n = int(input())
l = deque()
for _ in range (n):
    cmd = input().split(' ')
    if cmd[0]=='insert':
        l.appendleft(cmd[1])  
    if cmd[0]=='delete':
        try:l.remove(cmd[1])
        except :pass
    if cmd[0]=='deleteFirst':
        l.popleft()
    if cmd[0]=='deleteLast':
        l.pop()
print(*l)



Measured memory_bytes: 69732
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s,t,u="YES";
    cin>>s;
    int l = s.length();
    while(l>4){
        t=s.substr(l-5,5);
        if(t=="dream"||t=="erase"){
            l-=5;
        }else if(l<=5){
            l=-1;
        }else{
            t=s.substr(l-6,6);
            if(t=="eraser"){
                l-=6;
            }else if(l<=6){
                l=-1;
            }else{
                t=s.substr(l-7,7);
                if(t=="dreamer"){
                    l-=7;
                }else{
                    l=-1;
                }
            }
        }
    }
    if(l!=0){
        u="NO";
    }
    cout<<u<<endl;
    
}


Measured memory_bytes: 512