akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif
//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
typedef long long int 	LL;
typedef long double 	LD;
typedef pair<int,int>   II;
typedef vector<int>     VI;
const int MOD = 1e9 + 7;
const int N = 100011;


int main() {
    int n, m, k;
    SI(n), SI(m), SI(k);
    bool ok = 0;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= m; ++j) {
            int t = (n - i)*j + i*(m - j);
            if(t == k) ok = 1;
        }
    }
    for(int i = 0; i <= m; ++i) {
        for(int j = 0; j <= n; ++j) {
            int t = (m - i)*j + i*(n - j);
            if(t == k) ok = 1;
        }
    }
    if(ok) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,j,k;
        long sum;
        int[][] A = new int[101][101];
        int[][] B = new int[101][101];
        int[] n = new int[990];
        String[] str = new String[990];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().split(" ");
        for(i=0;i<3;i++){
            n[i]=Integer.parseInt(str[i]);   
        }
        for(i=0;i<n[0];i++){
            str = in.readLine().split(" ");
            for(j=0;j<n[1];j++){
                A[i][j]=Integer.parseInt(str[j]);
            }
        }
        for(i=0;i<n[1];i++){
            str = in.readLine().split(" ");
            for(j=0;j<n[2];j++){
                B[i][j]=Integer.parseInt(str[j]);
            }
        }
        for(i=0;i<n[0];i++){
            for(j=0;j<n[2];j++){
                sum=0;
                for(k=0;k<n[1];k++){
                    sum += B[k][j]*A[i][k];             
                }
                if(j!=0) System.out.print(" ");
                System.out.print(sum);
            }
            System.out.println();
        }      
        System.out.flush();
    }
}

Measured memory_bytes: 37876
//提出時は下二行と一番下のコメントアウトを外す。
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

/// 空白で区切られた複数の値の読み込む。
/// # Example
/// ```ignore
/// use cp_template::*;
///
/// let (a,b):(usize,usize);
/// input!(a,b);
/// ```
#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

/// 文字列を一行読み込む
/// # Example
/// ```ignore
/// use cp_template::*;
///
/// let s = input_line_str();
/// ```
#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

/// 一つの変数を出力する。
/// ```
/// use cp_template::*;
///
/// let a=100;
/// p(a);
/// //上と下は等価です。
/// println!("{}",a);
/// ```
#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

/// 指定した行数を読み込み、二次元配列に変換する。
/// # Examples
/// ```ignore
/// use cp_template::*;
///
/// //10行読み込む。
/// let v = input_vector2d::<usize>(10);
/// ```
#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

/// 一行読み込み、配列(Vec)に変換する。
/// # Examples
/// ```ignore
/// use cp_template::*;
///
/// let v=input_vector::<usize>();
/// ```
#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

/// String(str)を配列(Vec<char>)に変換する。
/// # Examples
/// ```ignore
/// use cp_template::*;
///
/// let s = String::from("abc");
/// let v = str2vec(&s);
/// let v = str2vec(&input_line_str());
/// ```
#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

//提出用
#[allow(unused_imports)]
use input::*;

fn calc(v: &Vec<Vec<usize>>, n: usize, i: usize) -> usize {
    if n == i + 1 {
        return 0;
    }
    let mut ans = v[i][0] + v[i][1];
    for z in i + 1..n - 1 {
        if ans < v[z][1] {
            ans += v[z][1] - ans + v[z][0];
        } else {
            if (ans - v[z][1]) % v[z][2] == 0 {
                ans += v[z][0];
            } else {
                ans += v[z][2] - ((ans - v[z][1]) % v[z][2]) + v[z][0];
            }
        }
    }
    ans
}

fn main() {
    let n: usize;
    input!(n);
    let v = input_vector2d::<usize>(n - 1);
    for z in 0..n {
        p(calc(&v, n, z));
    }
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a)) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

const int N=1e5+3;
int dp[N]={-1},n,k,ar[102];

int solve(int sum){
    // if sum is negative, the previous player looses (0 return )
    if(sum<0)return 1;
    else if(sum==0)return 0;
    // if the result is already calculated, reutrn it
    else if(dp[sum]!=-1)return dp[sum];
    int s=1;
    for(int i=0;i<n;i++)
        s=min(s,solve(sum-ar[i]));
    return dp[sum]=(!s);
}

int main(){
cin>>n>>k;
memset(dp,-1,sizeof(dp));
for(int i=0;i<n;i++)
    cin>>ar[i];
ll sum=0;

sum=solve(k);
if(sum)
    cout<<"First\n";
else cout<<"Second\n";

}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<char> ans;
  bool last=false;
  while(!last){
    if(n<=26) last=true;
    long long int pre=n%26;
    char add;
    if(pre==0) {
      add='z';
    }else{
      add='a'+pre-1;
    }
    n/=26;
    if(pre==0) n--;
    ans.push_back(add);
  }
  reverse(ans.begin(),ans.end());
  for(long long int i=0; i<ans.size(); i++){
    cout<<ans.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int a, b;
	int f = 0;
	cin >> a>>b;
	vector<vector<int>> vv(a, vector<int>(2));
	for (int i = 0;i < a;i++) {
		cin >> vv[i][0] >> vv[i][1];
		if (pow(vv[i][0], 2) + pow(vv[i][1], 2) <= pow(b, 2)) f+=1;
	}
	cout << f;
}

Measured memory_bytes: 14344
from functools import reduce
def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a

def lcd(a, b):
    return (a*b)//gcd(a,b)

N = int(input())
T = [int(input()) for _ in range(N)]
l = reduce(lcd, T)
print(l)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];
ll a[100001]={};
int main() {
	int n;
	cin>>n;
	vector<Pii> vec;
	rep(i,n){
		int a;
		cin>>a;
		vec.push_back(Pii(a,i+1));
	}
	sort(vec.begin(),vec.end());
	cout<<vec[0].second;
	rep(i,n-1)cout<<" "<<vec[i+1].second;
	return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long int n,d;
	cin >> n;
	long long int sum = 0;
	unordered_map <long long int,long long int> m;
	for (int i = 0; i < n; ++i){
		cin >> d;
		++m[d];
		sum += d;		
	}
	long long int q;
	cin >> q;
	while(q--){
	long long int b, c;
	cin >> b >> c;
	sum -= m[b]*b;
	m[c] += m[b];
	sum += m[b]*c;
	m[b] = 0;
	cout << sum << "\n";
	}	
	return 0;
}


Measured memory_bytes: 7072
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

const int MAX = 300009;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  COMinit();
  ll N, A, B, K; cin >> N >> A >> B >> K;
  ll ans = 0;
  for (int a=0;a<=N;a++){
    if ((K-a*A)%B==0){
      int b = (K-a*A)/B;
      (ans += COM(N, a)*COM(N,b)) %= MOD;
    }
  }
  cout << ans << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 10488
///attention
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[101][100001];
int w[100001];
int v[100001];
ll call(ll n,ll cap)
{
  //  cout<<n<<" "<<cap<<endl;
    if(cap<0)return INT_MIN;
    if(cap==0||n<0)return 0;

    if(dp[n][cap]==-1)
    {
        ll inc = v[n]+call(n-1,cap-w[n]);
        ll exc = call(n-1,cap);
        dp[n][cap]=max(inc,exc);
    }
    //cout<<n<<" "<<cap<<" "<<"dp = "<<dp[n][cap]<<endl;
    return dp[n][cap];
}
int main()
{
    memset(dp,-1,sizeof(dp));
    int n,cap;
    cin>>n>>cap;
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    ll z=call(n-1,cap);
    cout<<z<<endl;
}


Measured memory_bytes: 79104
#include <vector>
#include <list>
#include <map>
#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 <bitset>

using namespace std;
//using Graph = vector<vector<int>>;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
    int s;
    cin >> s;
    int h = s/3600;
    s%=3600;
    int m = s/60;
    s%=60;
    cout << h << ':' << m << ':' << s << endl;
}
    





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

int main(){
  int n;
  char s,t,b;
  double p[16][9];

  for(;;){
    scanf(" %d ",&n);
    if(!n)break;

    scanf(" %c %c %c ",&s,&t,&b);

    for(int i=0;i<=n;i++)
      for(int j=0;j<9;j++)p[i][j] = 0.0;

    p[0][s-'A'] = 1.0;

    for(int i=0;i<n;i++){
      for(int j=0;j<9;j++){
	if(j>=3 && j-3!=b-'A')p[i+1][j-3] += p[i][j]/4;
	else p[i+1][j] += p[i][j]/4;

	if(j%3!=2 && j+1!=b-'A')p[i+1][j+1] += p[i][j]/4;
	else p[i+1][j] += p[i][j]/4;

	if(j<6 && j+3!=b-'A')p[i+1][j+3] += p[i][j]/4;
	else p[i+1][j] += p[i][j]/4;

	if(j%3 && j-1!=b-'A')p[i+1][j-1] += p[i][j]/4;
	else p[i+1][j] += p[i][j]/4;
      }
    }

    printf("%.8lf\n",p[n][t-'A']);
  }
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	string a,s,c;
	cin >> a >> s >> c;
	cout << "A" << s[0] << "C" << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF 10e10
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

template <class T>
vector<T> dijkstra(LL S, LL G, LL N, vector<vector<T>> &edges, bool enable_goal=false){
    typedef pair<T, double> P;
    vector<T> shortest(N, INF);
    priority_queue<P, std::vector<P>, std::greater<P>> q;
    q.push(make_pair(0, S));
    while(!q.empty()){
        LL src = q.top().second;
        T l0 = q.top().first;
        q.pop();
        if(l0 >= shortest[src])continue;
        shortest[src] = l0;
        if(enable_goal && src == G)break;
        for(LL dst=0ll; dst<N; dst++){
            T l1 = edges[src][dst];
            if(l1 < INF && l0+l1 < shortest[dst]){
                q.push(make_pair(l0+l1, dst));
            }
        }
    }
    return shortest;
}

template <class T>
T dijkstra_g(LL S, LL G, LL N, vector<vector<T>> &edges){
    vector<T> shortest = dijkstra<T>(S,G,N,edges,true);
    return shortest[G];
}

template <class T>
vector<T> dijkstra_all(LL S, LL N, vector<vector<T>> &edges){
    return dijkstra<T>(S,-1,N,edges,false);
}

struct xyr{
    double x,y,r;
};

double dist(xyr p1, xyr p2){
    double d = sqrt(pow(p1.x-p2.x, 2)+pow(p1.y-p2.y, 2));
    return (d >= p1.r+p2.r ? d-(p1.r+p2.r) : 0.0);
}

void solve(long long x_s, long long y_s, long long x_t, long long y_t, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> r){
    vector<xyr> nodes(N+2);
    rep(i, N){
        nodes[i]={(double)x[i],(double)y[i],(double)r[i]};
    }
    nodes[N]={(double)x_s, (double)y_s, 0.0};
    nodes[N+1]={(double)x_t, (double)y_t, 0.0};
    vector<vector<double>> edges(N+2, vector<double>(N+2));
    rep(i,N+2){
        rep(j, N+2){
            if(i==j){
                edges[i][j] = INF;
            }else {
                edges[i][j] = dist(nodes[i], nodes[j]);
            }
        }
    }
    auto ans =  dijkstra_g<double>(N, N+1, N+2, edges);
    printf("%.10lf\n", ans);
}

int main(){
    long long x_s;
    scanf("%lld",&x_s);
    long long y_s;
    scanf("%lld",&y_s);
    long long x_t;
    scanf("%lld",&x_t);
    long long y_t;
    scanf("%lld",&y_t);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> r(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&r[i]);
    }
    solve(x_s, y_s, x_t, y_t, N, std::move(x), std::move(y), std::move(r));
    return 0;
}


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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    
    set<int> s;
    rep(i, n) s.insert(a[i]);
    if(s.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  long long  c[n];
  c[0]=2;
  c[1]=1;
  for(int i=2; i<=n;i++){
    c[i]=c[i-1]+c[i-2];
    }
  cout << c[n] <<endl;
  return 0;
  }

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

int main() {
	ios_base::sync_with_stdio( false );

	int w;
	while( cin >> w ) {
		vector<int> a;

		int x = 0;
		for( int i = 0; i < 10; ++i ) {
			if( w & (1 << i) ) {
				x |= 1 << i;
				a.push_back( 1 << i );
			}

			if( x == w ) {
				break;
			}
		}

		for( int i = 0; i < a.size(); ++i ) {
			cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
		}
	}
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
long long n,ans=0,cnt=1;
int main(){
  cin >> n;
  long long a[n];
  pair<long long,long long>p[n+1];
  for(int i=0;i<n;i++){
    cin >> a[i];
    p[i]=make_pair(a[i]-1,i);
  }
  p[n]=make_pair(n,0);
  sort(p,p+n);
  for(int i=0;i<n;i++){
    if(p[i].second<p[i+1].second){
      cnt++;
    }else{
      cnt=1;
    }
    ans=max(ans,cnt);
  }
  cout << n-ans << endl;
  return 0;
}

Measured memory_bytes: 4992
n, k = input().strip().split(' ')
n, k = [int(n),int(k)]
l = []
for i in range(n):
    h = input()
    h = int(h)
    l.append(h)
dl = sorted(l)
ans = float('inf')
for j in range(n-k+1):
    if abs(dl[j+k-1] - dl[j]) <= ans:
        ans = abs(dl[j+k-1] - dl[j])
print(int(ans))


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  long long X, K, D;
  cin >> X >> K >> D;
  if(K <= abs(X) / D){
    cout << abs(X) - abs(K * D);
  } else{
    long long A = abs(X) % D;
    long long B = K - abs(X) / D;
    if(B % 2 == 0){
      cout << abs(A);
    } else{
      cout << abs(A - D);
    }
  }
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int h,w;
  string s;
  cin>>h>>w;
  rep(i,h){
    rep(j,w){
      cin>>s;
      if(s=="snuke")cout<<char(j+'A')<<i+1<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define   vpll   vector<pll >
#define   all(x) x.begin(),x.end()
#define   present(c,x)    ((c).find(x) != (c).end())
#define   dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#define   sz(a)  a.size()
#define   vll vector<int>
#define   pll pair<int,int>
#define   ff  first
#define   ss  second
#define   br  cout<<"\n";
#define   ld  long double
#define   int  long long int
const int  INF = 1e18+7;
const int  MAX = 1234567;
const int  MOD = 1000000007;


map < int , int > frq ;
void solve(){
	int n ;
	cin >> n ;
	vll a(n) ;
	
	for ( int i = 0 ; i < n ; i++ )
		cin >> a[i] , frq[a[i]] ++ ;
	int total = 0 ;
	for ( auto k : frq )
		total +=  max( 0ll , ( k.second * (k.second - 1 ) ) / 2 ) ;

	for ( int i = 0 ; i < n ; i++ ){
		int cnt = total ;
		cnt -= max(0ll , ( frq[a[i]] * ( frq[a[i]] - 1 ) ) / 2 ) ;
		frq[a[i]]--;
		cnt += max(0ll , ( frq[a[i]] * ( frq[a[i]] - 1 ) ) / 2 ) ;
		frq[a[i]]++;
		cout << cnt << "\n" ;	 
	}	    
}
int32_t main(){
    int t;
    t=1;
    cin.sync_with_stdio(0), cin.tie(0);
    //cin>>t;
    while(t--){
        solve();
        br;
    }
    return 0;
}
 
 
 
 
 
 

Measured memory_bytes: 11136
n = int(input())

li_action = list()

for _ in range(n):
    li_action.append(list(map(int, input().split())))

dp = list()
for _ in range(n):
    dp.append([0] * 3)


dp[0][0] = li_action[0][0]
dp[0][1] = li_action[0][1]
dp[0][2] = li_action[0][2]


for i in range(1, n):
    dp[i][0] = max(
        dp[i - 1][1] + li_action[i][0],
        dp[i - 1][2] + li_action[i][0],
    )
    dp[i][1] = max(
        dp[i - 1][0] + li_action[i][1],
        dp[i - 1][2] + li_action[i][1],
    )
    dp[i][2] = max(
        dp[i - 1][0] + li_action[i][2],
        dp[i - 1][1] + li_action[i][2],
    )
print(max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))



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

using namespace std;

bool t[2000000];

int main(){
	
	int n, m, sum;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		sum = 0;
		for(int i = 0; i < n / 4; i++){
			cin >> m;
			sum += m;
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    if(n%1000==0) cout<< "0";
    else{
    int x=(n/1000+1)*(1000)-n;
    cout<<x;
    }
    return 0;
}


Measured memory_bytes: 3648
#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 pair<string , int> s_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)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    ll ans = 0LL;
    vel A(N);
    rep(i,N) cin >> A[i];

    rep(i,N) {
        ans += A[i] / 2;
        A[i] = A[i] % 2;
        if(i != N - 1) if(A[i] == 1 and A[i+1] >= 1) { ans++; A[i]--; A[i+1]--; }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		String symbols = scanner.nextLine();
		String[] arr_split = symbols.split("",0);
		scanner.close();
		int ans = 0;
		for (String string : arr_split) {
			if (string.equals("+")) {
				ans++;
			} else {
				ans--;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23252
#include <stdio.h>
#define INF 10000000
//#define DEBUG
int map[100][100];
int dp[100][100];
int w,h;

int walk(int x,int y,int step){
	dp[x][y]=step;
	//printf("walk %d %d %d\n",x,y,step);
	if(x-1>-1&&map[y*2][x-1]!=1&&dp[x-1][y]>step+1)walk(x-1,y,step+1);
	if(x+1<w&&map[y*2][x]!=1&&dp[x+1][y]>step+1)walk(x+1,y,step+1);
	if(y-1>-1&&map[y*2-1][x]!=1&&dp[x][y-1]>step+1)walk(x,y-1,step+1);
	if(y+1<h&&map[y*2+1][x]!=1&&dp[x][y+1]>step+1)walk(x,y+1,step+1);
	return 0;
}


int main(void){
	int i,j,k;
	while(scanf("%d %d",&w,&h),(w||h)){
		for(i=0;i<w;i++){
			for(j=0;j<h;j++){
				dp[i][j]=INF;
			}
		}
		for(i=0;i<2*h-1;i++){
			if(i%2==0) j=w-1;
			else j=w;
			for(k=0;k<j;k++){
				scanf("%d",&map[i][k]);
			}
		}
#ifdef DEBUG
		printf("mapmake:\n");
		for(i=0;i<2*h-1;i++){
			for(j=0;j<w;j++){
				printf("%d ",map[i][j]);
			}
			printf("\n");
		}
#endif
		walk(0,0,1);
#ifdef DEBUG
		printf("listmake:\n");
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(dp[j][i]!=INF)printf("%d ",dp[j][i]);
				else printf("N ");
			}
			printf("\n");
		}
		printf("answer:\n");
#endif
	if(dp[w-1][h-1]==INF) printf("0\n");
	else printf("%d\n",dp[w-1][h-1]);
	}
	return 0;
}

Measured memory_bytes: 1104
def sieve(n):
  ass = []
  is_prime = [True]*(n+1)
  is_prime[0] = False
  is_prime[1] = False

  for i in range(2, int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2, n+1, i):
      is_prime[j] = False
  for i in range(n+1):
    if is_prime[i]:
      ass.append(i)
  return(ass)

l = sieve(55600)
l = [i for i in l if i%5 ==1]
n = int(input())
#print(*l[0:n])
print(*l[0:n])

Measured memory_bytes: 3572
import java.math.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int k=sc.nextInt();
		int ans=0;
		if(a>=k){
			ans+=k;
		}else if(a+b>=k){
			ans=a;
		}else if(a+b+c>=k){
			ans+=a;
			k-=a;
			k-=b;
			ans-=k;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35916
a,b=map(int,input().split())
xa=0
if a==b:
    print(a)
elif b-a<4:
    x=0
    for i in range(a,b+1):
        x^=i
    print(x)
else:
    if a%4:
        for i in range(4-a%4):
            xa^=a+i
    xb=0
    if b%4 != 3:
        for i in reversed(range(b%4+1)):
            xb^=b-i
    print(xa^xb)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 50;
int main()
{
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ok = 0;
    for(int i = 0;i < s.size();i++){
        ok += s[i] - '0';
    }
    if(ok % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

bool u[101];

int main()
{
    int n, k;

    std::cin >> n >> k;

    for (int i = 0; i < k; ++i)
    {
        int d;
        std::cin >> d;
        for (int j = 0; j < d; ++j)
        {
            int a;
            std::cin >> a;
            u[a] = 1;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (!u[i])
            ++cnt;
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 3188
l = list(map(int,input().split()))	
a = l[0]
b = l[1]
c = l[2]
d = l[3]
e = l[4]
f = l[5]
ass=0
ans = [100*a,0]
for i in range((f//(100*b))+1):
    for j in range((f-100*b*i)//(100*a)+1):
        hj = f-100*b*i-100*a*j
        for k in range((hj//d+1)):
            if f-hj!=0:
                w = 100*k*d/(f-hj)
                if w <= e:
                    r = min((e*(f-hj)/100-d*k)//c,(hj-d*k)//c)
                    if ass <=(d*k+c*r)*100/(f-hj+d*k+c*r):
                        ans[0] = f-hj+d*k+c*r
                        ans[1] = d*k + c*r
                        ass = (d*k+c*r)*100/(f-hj+d*k+c*r)
print(str(int(ans[0]))+' '+str(int(ans[1])))
#print(ass)
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll unsigned long long int
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int main()
{
	SPEED
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll d1 = a/c;
	ll d2 = b/c;
	ll r1 = a/d;
	ll r2 = b/d;
	ll reduce;
	if (c>d)
	{
		reduce = (c*d)/gcd(c,d);
	}
	else
	{
		reduce = (c*d)/gcd(d,c);
	}
	ll z1 = a/reduce;
	ll z2 = b/reduce;
	ll result = (d2 - d1) + (r2 - r1) - (z2 - z1);
	if (a%c==0)
		result++;
	if (a%d==0)
		result++;
	if (a%reduce==0)
		result--;
	ll ans = b-a+1-result;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, C[500], S[500], F[500];
	scanf("%d", &N);
	for (i = 1; i <= N - 1; i++) scanf("%d %d %d", &(C[i]), &(S[i]), &(F[i]));
	
	int j, ans[501] = {};
	for (i = 1; i <= N - 1; i++) {
		ans[i] = S[i] + C[i];
		for (j = i + 1; j <= N - 1; j++) {
			if (ans[i] <= S[j]) ans[i] = S[j] + C[j];
			else ans[i] = ans[i] + (F[j] - 1 - (ans[i] - 1) % F[j]) + C[j];
		}
	}
	
	for (i = 1; i <= N; i++) printf("%d\n", ans[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=205,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
const ll inf=10000000000000000ll;
int T;
ll n,a,b,c,d,ans;
map<ll,ll> h;
ll getans(ll n){
	if (n==0) return 0;
	if (h.count(n)) return h[n];
	ll t=(inf/d>=n) ? (n*d) : inf;
	t=min(t,getans(n/5)+c+n%5*d);
	t=min(t,getans(n/3)+b+n%3*d);
	t=min(t,getans(n/2)+a+n%2*d);
	if (n!=1){
		t=min(t,getans(n/5+1)+c+(5-n%5)*d);
		t=min(t,getans(n/3+1)+b+(3-n%3)*d);
		if (n!=2) t=min(t,getans(n/2+1)+a+(2-n%2)*d);
	}
	return h[n]=t;
}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	T=read();
	while (T--){
		scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
		ans=1e15;h.clear();
		printf("%lld\n",getans(n));
		//printf("%d\n",(int)h.size());
	}
	return 0;
}

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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<int(1e9) + 7>;

vector<num> fact;
vector<num> ifact;

void init(){
	fact = {1};
	for(int i = 1; i < 2000000; i++) fact.push_back(i * fact[i-1]);
	for(num x : fact) ifact.push_back(1 / x);	
}

num ncr(int n, int k){
	if(k < 0 || k > n) return 0;
	return fact[n] * ifact[k] * ifact[n-k];
}

num f(int a, int b){
	if(a < 0 || b < 0) return 0;
	return ncr(a+b+2, b+1) - 1;
}

num block(int a1, int a2, int b1, int b2){
	assert(a1 <= a2 && b1 <= b2);
	a1--; b1--;
	return f(a2, b2) - f(a1, b2) - f(a2, b1) + f(a1, b1);
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	init();
	int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;
	cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6;
	cin >> y1 >> y2 >> y3 >> y4 >> y5 >> y6;
	num ans = 0;
	for(int i = y3; i <= y4; i++){
		int val = x3 + i - 1;
		ans -= val * block(x3-1-x2, x3-1-x1, i-y2, i-y1) * block(x5-x3, x6-x3, y5-i, y6-i);
	}
	for(int i = x3; i <= x4; i++){
		int val = y3 + i - 1;
		ans -= val * block(i-x2, i-x1, y3-1-y2, y3-1-y1) * block(x5-i, x6-i, y5-y3, y6-y3);
	}
	for(int i = y3; i <= y4; i++){
		int val = x4 + i;
		ans += val * block(x4-x2, x4-x1, i-y2, i-y1) * block(x5-1-x4, x6-1-x4, y5-i, y6-i);
	}
	for(int i = x3; i <= x4; i++){
		int val = y4 + i;
		ans += val * block(i-x2, i-x1, y4-y2, y4-y1) * block(x5-i, x6-i, y5-1-y4, y6-1-y4);
	}
	cout << (int) ans << '\n';
}

Measured memory_bytes: 22632
h, w = map(int, input().split())

wall = ["." * (w + 2)]
s = wall + ["." + input() + "." for _ in range(h)] + wall

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == ".":
            t = s[i-1][j-1:j+2] + s[i][j-1:j+2] + s[i+1][j-1:j+2]
            s[i] = s[i][:j] + str(t.count("#")) + s[i][j+1:]
    else:
        print(s[i][1:-1])

Measured memory_bytes: 9140
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll sod(ll x)
{
    ll ans=0;
    while(x)
    {
        ans+=x%10;
        x/=10;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    if(x%sod(x)==0)
    {
        cout<<"Yes\n";
    }
    else cout<<"No\n";
}

Measured memory_bytes: 256
#encoding utf-8

import math
from functools import reduce

#複数の最大コゥ約数
def gcd(a,b):
    l = max(a,b)
    m = min(a,b)
    while m != 0:
        extra = l%m
        l = m
        m = extra
    return l

def gcd_multi(numbers):
    return reduce(gcd,numbers)

n,X = map(int, input().split())

x = [int(i) for i in input().split()]

x.append(X)

x.sort()

minus=[]

for i in range(len(x)-1):
    minus.append(x[i+1]-x[i])


D = gcd_multi(minus)

print(int(D))

Measured memory_bytes: 14764
n = int(input())
a = []
for i in range(n):
  a.append([input(),0])
m = int(input())
b = []
for i in range(m):
  b.append([input(),0])

res = 0
for i in range(n):
  c = 0
  if a[i][1] == 0:
    a[i][1] = 1
    for j in range(i,n):
      if a[i][0] == a[j][0]:
        c += 1
        a[j][1] = 1
    for j in range(m):
      if a[i][0] == b[j][0]:
        c -= 1
  res = max(res,c)
print(res)

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int k,x;
cin>>k>>x;
for(int i=-k+1;i<k;i++){
    cout<<x+i<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int H,W;
	cin>>H>>W;
	string S[H];
	rep(i,H) cin>>S[i];
	int w[H][W]={},h[H][W]={},ans=0;
	rep(i,H){
		int cnt=0;
		int p=0;
		rep(j,W){
			if(S[i][j]=='#'){
				w[i][j]=0;
				for(int k=p; k<j; k++) w[i][k]=cnt;
				cnt=0;
				p=j+1;
			}else{
				cnt++;
			}
		}
		for(int k=p; k<W; k++) w[i][k]=cnt;
	}
	rep(i,W){
		int cnt=0;
		int p=0;
		rep(j,H){
			if(S[j][i]=='.') cnt++;
			else{
				h[j][i]=0;
				for(int k=p; k<j; k++) h[k][i]=cnt;
				cnt=0;
				p=j+1;
			}
		}
		for(int k=p; k<H; k++) h[k][i]=cnt;
	}
	rep(i,H){
		rep(j,W){
			ans=max(ans,w[i][j]+h[i][j]-1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35584
#include<cstdio>
#include<cstring>
#define mod 1000000007
int a[8][2]={3,1,5,2,2,2,4,7,3,3,6,1,5,5,3,1};
int f[300100][8],n,i,j;
char S[300100];
int main(){
	scanf("%s",S);
	n=strlen(S);
	f[n][1]=f[n][2]=1;
	for(int i=n-1;i>=0;i--)
		for(int j=0;j<=7;j++){
	        if(S[i]!='0')f[i][j]+=f[i+1][a[j][1]];
	        if(S[i]!='1')f[i][j]+=f[i+1][a[j][0]];
	        f[i][j]%=mod;				
		}
	printf("%d\n",f[0][0]);
}

Measured memory_bytes: 9856
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

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

	vector<LL> v(N, 0);
	vector<LL> s(N, 0);

	REP(i, N) {
		cin >> v[i];
	}

	REP(i, N) {
		if (i == 0) {
			s[i] = v[i];
		}
		else {
			s[i] = s[i - 1] + v[i];
		}
	}

	LL min = 90000000000000;

	for (LL i = 0; i < N - 1; ++i) {
		if (abs(s[i] - (s[N - 1] - s[i])) < min) {
			min = abs(s[i] - (s[N - 1] - s[i]));
		}
	}

	cout << min << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define lli long long
int dp[100005];
int a[100005];

int main() 
{
    int n,k;
    cin >> n >> k;
    
    for(int i=1;i<=n;i++) cin >> a[i];
    
    dp[1] = 0;
    
    for(int i=2;i<=n;i++){
        int mn = INT_MAX;
        for(int j=i-1;j>=max(i-k,1);j--){
            mn = min(mn, dp[j]+abs(a[j]-a[i]));
        }
        dp[i] = mn;
    }
    
    cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




















int main(){
    ll n;
    cin >> n;
    set<ll> st;
    REP(i, n){
        ll a;
        cin >> a;
        st.insert(a);
    }
    cout << ((st.size() == n)? "YES" : "NO") << endl;
}

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

int main(){
    long a;
    string str;
    while (true){
        cin >> str;
        if (str == "0"){
            break;
        }
        int sum = 0;
        for (int i =0; i < str.size();i++){
            sum += str[i] - '0';
        }
        cout << sum << endl;



    }
    return 0;
}


Measured memory_bytes: 3156
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elif else if
#define unint unsigned int
#define sint short int
#define lint long long int

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    char x;
    cin>>x;
    cout<<++x<<endl;
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(N):
        if i + 3 <= N:
            if S[i] + S[i+1] + S[i+2] == 'ABC':
                ans += 1
    
    print(ans)
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]) {
	while (true) {
		int n = -1, k = -1;
		cin >> n >> k;
		if (n <= 0 || k <= 0) break;
		string s;
		cin >> s;
		vector<int> st(1, 0), ed;
		char prev = '1';
		for (int i = 0; i < (int)s.length(); ++i) {
			if (prev != s[i]) {
				if (s[i] == '0') {
					ed.push_back(i);
				} else {
					st.push_back(i);
				}
			}
			prev = s[i];
		}
		if (prev == '0') {
			st.push_back(s.length());
		}
		ed.push_back(s.length());
		int ans = 0;
		if (st.size() <= k) {
			ans = s.length();
		} else {
			for (int i = 0; i + k < st.size(); ++i) {
				ans = max(ans, ed[i + k] - st[i]);
			}
		}
   		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1020
import numpy as np

N,M = map(int,input().split())
A = list(map(int,input().split()))
Amax=max(A)

n0 = 2**int(np.ceil(np.log2(2*Amax+1)))#Amax+1以上となる最小の2のべき乗数

Afre=np.zeros(n0).astype(int)#パワーの頻度(1~Amax+1)
for i in range(N):
    Afre[A[i]]+=1

#astype(int)は切り捨てなので，rintで四捨五入してから．
S = np.rint(np.fft.irfft(np.fft.rfft(Afre)*np.fft.rfft(Afre))).astype(int)
Scum =S.cumsum()#累積和
bd = N*N-M#上からM個を取り出したい
i=np.searchsorted(Scum,bd)#価値iを生み出せる組みがM個以上ある
#価値iが生み出せる選び方の余分なものを引きたい
remove=((Scum[-1]-Scum[i])-M)*i
ans=0
for j in range(i+1,n0):
    ans+=S[j]*j
print(ans-remove)

Measured memory_bytes: 33548
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

LL a, b, extra;

vector<LL> healths;

bool check(LL turns) {
    LL need = 0;

    for (auto& h : healths) {
        LL left = h - turns * b;

        if (left > 0) {
            need += (left / extra) + (left % extra != 0);
        }
    }

    return need <= turns;
}

int main() {
    GI(n);
    GLL(a);
    GLL(b);

    extra = a - b;

    LL h;

    FORN(i, n) {
        GLL(h);
        healths.PB(h);
    }

    LL lo = 1; LL hi = 1000000000; LL res = -1;

    while (lo <= hi) {
        LL mid = (lo + hi) / 2;

        if (check(mid)) {
            res = mid;
            hi = mid - 1;
        }
        else {
            lo = mid + 1;
        }
    }

    printf("%lld\n", res);
    
    return 0;
}

Measured memory_bytes: 1400